diff --git a/Cargo.toml b/Cargo.toml index 038b6f7..3f6591d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,6 @@ name = "chirp" version = "0.1.1" edition = "2021" -ignore = ["justfile", ".gitmodules", "chip8-test-suite", "chip8Archive"] default-run = "chirp" authors = ["John Breaux"] license = "MIT" diff --git a/chip8-test-suite b/chip8-test-suite index af78298..253f5de 160000 --- a/chip8-test-suite +++ b/chip8-test-suite @@ -1 +1 @@ -Subproject commit af7829841b4c9b043febbd37a4d4114e0ac948ec +Subproject commit 253f5de130a6cc4c7e07c6801174717efb0ea9cb diff --git a/tests/chip8_test_suite.rs b/tests/chip8_test_suite.rs index 5cd8fe3..72738f6 100644 --- a/tests/chip8_test_suite.rs +++ b/tests/chip8_test_suite.rs @@ -7,7 +7,7 @@ fn setup_environment() -> (CPU, Bus) { cpu.flags = Flags { debug: true, pause: false, - monotonic: Some(8), + monotonic: Some(10), ..Default::default() }; ( @@ -16,28 +16,30 @@ fn setup_environment() -> (CPU, Bus) { // Load the charset into ROM Charset [0x0050..0x00A0] = include_bytes!("../src/mem/charset.bin"), // Load the ROM file into RAM - Program [0x0200..0x1000] = include_bytes!("../chip8-test-suite/bin/chip8-test-suite.ch8"), - // Create a screen, and fill it with + Program [0x0200..0x1000], + // Create a screen, and fill it with garbage Screen [0x0F00..0x1000] = include_bytes!("chip8_test_suite.rs"), }, ) } struct SuiteTest { - test: u16, + test: u8, + data: &'static [u8], screen: &'static [u8], } fn run_screentest(test: SuiteTest, mut cpu: CPU, mut bus: Bus) { // Set the test to run - bus.write(0x1feu16, test.test); + bus.write(0x1ffu16, test.test); + bus.load_region(Program, test.data).unwrap(); // The test suite always initiates a keypause on test completion - while !cpu.flags.keypause { - cpu.multistep(&mut bus, 8).unwrap(); + while !(cpu.flags.keypause || cpu.flags.pause) { + cpu.multistep(&mut bus, 100).unwrap(); } // Compare the screen to the reference screen buffer bus.print_screen().unwrap(); - bus! {crate::bus::Region::Screen [0..256] = test.screen} + bus! {crate::cpu::bus::Region::Screen [0..256] = test.screen} .print_screen() .unwrap(); assert_eq!(bus.get_region(Screen).unwrap(), test.screen); @@ -49,6 +51,7 @@ fn splash_screen() { run_screentest( SuiteTest { test: 0, + data: include_bytes!("../chip8-test-suite/bin/1-chip8-logo.ch8"), screen: include_bytes!("screens/chip8-test-suite/splash.bin"), }, cpu, @@ -61,7 +64,8 @@ fn ibm_logo() { let (cpu, bus) = setup_environment(); run_screentest( SuiteTest { - test: 0x01, + test: 0x00, + data: include_bytes!("../chip8-test-suite/bin/2-ibm-logo.ch8"), screen: include_bytes!("screens/chip8-test-suite/IBM.bin"), }, cpu, @@ -69,12 +73,27 @@ fn ibm_logo() { ) } +#[test] +fn corax_test() { + let (cpu, bus) = setup_environment(); + run_screentest( + SuiteTest { + test: 0x00, + data: include_bytes!("../chip8-test-suite/bin/3-corax+.ch8"), + screen: include_bytes!("screens/chip8-test-suite/corax+.bin"), + }, + cpu, + bus, + ) +} + #[test] fn flags_test() { let (cpu, bus) = setup_environment(); run_screentest( SuiteTest { - test: 0x03, + test: 0x00, + data: include_bytes!("../chip8-test-suite/bin/4-flags.ch8"), screen: include_bytes!("screens/chip8-test-suite/flags.bin"), }, cpu, @@ -87,7 +106,8 @@ fn quirks_test() { let (cpu, bus) = setup_environment(); run_screentest( SuiteTest { - test: 0x0104, + test: 0x01, + data: include_bytes!("../chip8-test-suite/bin/5-quirks.ch8"), screen: include_bytes!("screens/chip8-test-suite/quirks.bin"), }, cpu, diff --git a/tests/screens/chip8-test-suite/IBM.bin b/tests/screens/chip8-test-suite/IBM.bin index 30bcf0f..2a3627c 100644 Binary files a/tests/screens/chip8-test-suite/IBM.bin and b/tests/screens/chip8-test-suite/IBM.bin differ diff --git a/tests/screens/chip8-test-suite/corax+.bin b/tests/screens/chip8-test-suite/corax+.bin new file mode 100644 index 0000000..759d91a Binary files /dev/null and b/tests/screens/chip8-test-suite/corax+.bin differ diff --git a/tests/screens/chip8-test-suite/flags.bin b/tests/screens/chip8-test-suite/flags.bin index 465b334..cbeec31 100644 Binary files a/tests/screens/chip8-test-suite/flags.bin and b/tests/screens/chip8-test-suite/flags.bin differ diff --git a/tests/screens/chip8-test-suite/splash.bin b/tests/screens/chip8-test-suite/splash.bin index 1d6794a..9f75b09 100644 Binary files a/tests/screens/chip8-test-suite/splash.bin and b/tests/screens/chip8-test-suite/splash.bin differ