chip8_test_suite.rs: Load program only once
This commit is contained in:
parent
83cc35c968
commit
40cc81181b
@ -24,13 +24,13 @@ fn setup_environment() -> (CPU, Bus) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct SuiteTest {
|
struct SuiteTest {
|
||||||
program: &'static [u8],
|
test: u16,
|
||||||
screen: &'static [u8],
|
screen: &'static [u8],
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_screentest(test: SuiteTest, mut cpu: CPU, mut bus: Bus) {
|
fn run_screentest(test: SuiteTest, mut cpu: CPU, mut bus: Bus) {
|
||||||
// Load the test program
|
// Set the test to run
|
||||||
bus = bus.load_region(Program, test.program);
|
bus.write(0x1feu16, test.test);
|
||||||
// The test suite always initiates a keypause on test completion
|
// The test suite always initiates a keypause on test completion
|
||||||
while !cpu.flags.keypause {
|
while !cpu.flags.keypause {
|
||||||
cpu.multistep(&mut bus, 8).unwrap();
|
cpu.multistep(&mut bus, 8).unwrap();
|
||||||
@ -48,7 +48,7 @@ fn splash_screen() {
|
|||||||
let (cpu, bus) = setup_environment();
|
let (cpu, bus) = setup_environment();
|
||||||
run_screentest(
|
run_screentest(
|
||||||
SuiteTest {
|
SuiteTest {
|
||||||
program: include_bytes!("chip8-test-suite/bin/chip8-test-suite.ch8"),
|
test: 0,
|
||||||
screen: include_bytes!("screens/chip8-test-suite/splash.bin"),
|
screen: include_bytes!("screens/chip8-test-suite/splash.bin"),
|
||||||
},
|
},
|
||||||
cpu,
|
cpu,
|
||||||
@ -58,11 +58,10 @@ fn splash_screen() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ibm_logo() {
|
fn ibm_logo() {
|
||||||
let (cpu, mut bus) = setup_environment();
|
let (cpu, bus) = setup_environment();
|
||||||
bus.write(0x1ffu16, 1u8);
|
|
||||||
run_screentest(
|
run_screentest(
|
||||||
SuiteTest {
|
SuiteTest {
|
||||||
program: include_bytes!("chip8-test-suite/bin/chip8-test-suite.ch8"),
|
test: 0x01,
|
||||||
screen: include_bytes!("screens/chip8-test-suite/IBM.bin"),
|
screen: include_bytes!("screens/chip8-test-suite/IBM.bin"),
|
||||||
},
|
},
|
||||||
cpu,
|
cpu,
|
||||||
@ -72,11 +71,10 @@ fn ibm_logo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn flags_test() {
|
fn flags_test() {
|
||||||
let (cpu, mut bus) = setup_environment();
|
let (cpu, bus) = setup_environment();
|
||||||
bus.write(0x1ffu16, 3u8);
|
|
||||||
run_screentest(
|
run_screentest(
|
||||||
SuiteTest {
|
SuiteTest {
|
||||||
program: include_bytes!("chip8-test-suite/bin/chip8-test-suite.ch8"),
|
test: 0x03,
|
||||||
screen: include_bytes!("screens/chip8-test-suite/flags.bin"),
|
screen: include_bytes!("screens/chip8-test-suite/flags.bin"),
|
||||||
},
|
},
|
||||||
cpu,
|
cpu,
|
||||||
@ -86,11 +84,10 @@ fn flags_test() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn quirks_test() {
|
fn quirks_test() {
|
||||||
let (cpu, mut bus) = setup_environment();
|
let (cpu, bus) = setup_environment();
|
||||||
bus.write(0x1feu16, 0x0104u16);
|
|
||||||
run_screentest(
|
run_screentest(
|
||||||
SuiteTest {
|
SuiteTest {
|
||||||
program: include_bytes!("chip8-test-suite/bin/chip8-test-suite.ch8"),
|
test: 0x0104,
|
||||||
screen: include_bytes!("screens/chip8-test-suite/quirks.bin"),
|
screen: include_bytes!("screens/chip8-test-suite/quirks.bin"),
|
||||||
},
|
},
|
||||||
cpu,
|
cpu,
|
||||||
|
Loading…
Reference in New Issue
Block a user