From 40cc81181b452a819dfd261fe034ad773a832c41 Mon Sep 17 00:00:00 2001 From: John Breaux Date: Sun, 2 Apr 2023 14:46:39 -0500 Subject: [PATCH] chip8_test_suite.rs: Load program only once --- tests/chip8_test_suite.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/chip8_test_suite.rs b/tests/chip8_test_suite.rs index b7a11aa..f5feba1 100644 --- a/tests/chip8_test_suite.rs +++ b/tests/chip8_test_suite.rs @@ -24,13 +24,13 @@ fn setup_environment() -> (CPU, Bus) { } struct SuiteTest { - program: &'static [u8], + test: u16, screen: &'static [u8], } fn run_screentest(test: SuiteTest, mut cpu: CPU, mut bus: Bus) { - // Load the test program - bus = bus.load_region(Program, test.program); + // Set the test to run + bus.write(0x1feu16, test.test); // The test suite always initiates a keypause on test completion while !cpu.flags.keypause { cpu.multistep(&mut bus, 8).unwrap(); @@ -48,7 +48,7 @@ fn splash_screen() { let (cpu, bus) = setup_environment(); run_screentest( SuiteTest { - program: include_bytes!("chip8-test-suite/bin/chip8-test-suite.ch8"), + test: 0, screen: include_bytes!("screens/chip8-test-suite/splash.bin"), }, cpu, @@ -58,11 +58,10 @@ fn splash_screen() { #[test] fn ibm_logo() { - let (cpu, mut bus) = setup_environment(); - bus.write(0x1ffu16, 1u8); + let (cpu, bus) = setup_environment(); run_screentest( SuiteTest { - program: include_bytes!("chip8-test-suite/bin/chip8-test-suite.ch8"), + test: 0x01, screen: include_bytes!("screens/chip8-test-suite/IBM.bin"), }, cpu, @@ -72,11 +71,10 @@ fn ibm_logo() { #[test] fn flags_test() { - let (cpu, mut bus) = setup_environment(); - bus.write(0x1ffu16, 3u8); + let (cpu, bus) = setup_environment(); run_screentest( SuiteTest { - program: include_bytes!("chip8-test-suite/bin/chip8-test-suite.ch8"), + test: 0x03, screen: include_bytes!("screens/chip8-test-suite/flags.bin"), }, cpu, @@ -86,11 +84,10 @@ fn flags_test() { #[test] fn quirks_test() { - let (cpu, mut bus) = setup_environment(); - bus.write(0x1feu16, 0x0104u16); + let (cpu, bus) = setup_environment(); run_screentest( SuiteTest { - program: include_bytes!("chip8-test-suite/bin/chip8-test-suite.ch8"), + test: 0x0104, screen: include_bytes!("screens/chip8-test-suite/quirks.bin"), }, cpu,