From bafb576705b492a0d9bc03d2a0bebeb18433763a Mon Sep 17 00:00:00 2001 From: John Breaux Date: Mon, 17 Apr 2023 05:04:23 -0500 Subject: [PATCH] chip8-test-suite: Update to 4.0 --- Cargo.toml | 1 - chip8-test-suite | 2 +- tests/chip8_test_suite.rs | 42 ++++++++++++++++------ tests/screens/chip8-test-suite/IBM.bin | Bin 256 -> 256 bytes tests/screens/chip8-test-suite/corax+.bin | Bin 0 -> 256 bytes tests/screens/chip8-test-suite/flags.bin | Bin 256 -> 256 bytes tests/screens/chip8-test-suite/splash.bin | Bin 256 -> 256 bytes 7 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 tests/screens/chip8-test-suite/corax+.bin 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 30bcf0f1de8db12eb6d35042144303ba166867ae..2a3627c29b23130889509985f15d9c90f96eb635 100644 GIT binary patch literal 256 zcmZQzpb+qX|5L;GsR3dNQv(D4_y2Xw9}$K!A3QG4eh4bh+`zzm@Q?ic15iE#m@oVH j08~9A15p0B%ug5}s2*ruO(BZ;e`*vz!}LS-kxu~tXP_We literal 256 zcmZQzpb+qX|5L;G0bvOL_y2XwNPOml$K}}%Amo`3{*k|r%9s6%!apwa6NwKruci>m OJdk~gNPL9JWU&C`IU7I# diff --git a/tests/screens/chip8-test-suite/corax+.bin b/tests/screens/chip8-test-suite/corax+.bin new file mode 100644 index 0000000000000000000000000000000000000000..759d91a0d0342a0eef3f3d07e545cb5c34d5d98c GIT binary patch literal 256 zcmZ9HF%H5o3`MPO%~YyCgb}i|$pU3*lFMc8fIMXIDL5lBP$cjlEK5&M-$d_8MU%@B zJ#uw0vdAPCNt}3PH+(SijnPB|WSpuIZFMp|aYq!$f4~X@Qu#N4Dn@n43l;h#C_uKaq DWTG~9 literal 0 HcmV?d00001 diff --git a/tests/screens/chip8-test-suite/flags.bin b/tests/screens/chip8-test-suite/flags.bin index 465b334916e9e1734fc62e5507ff770e212433a4..cbeec31266a85887fadaa6904aeb58d70f9a7d66 100644 GIT binary patch literal 256 zcmZ2-W-$W;9|OayRSQK!m_h^AopF?$!IPG-s>6Ar0H2Ek0~9=9U}^xVOATe78tM}o zs+Ptub7oUo+7lOsiGn;XE(mqZV0Epb3?Ov@&p_%r(h|Vxkj#Ure{yCKSbf*3#b9&$ y&NzV0eYMJgB6HuZJG_H|fvIoFn?;5p4BA~wRvcEG!JyIgWZfc50S19}F#7?{@kHYQ literal 256 zcmZ2-X7L6Fz6T7iRxO?w>ZcmI?u^sKnO(=yR&_Y<6y$s2!T<&D7?@Xp)IAFg-Wlq5 zG;~o~Qs>MrwX}CG&YgmMN08O+0I7Qs8r%s|w+^hX4XO@d9?aY)XBLCa?OL@MY;NBf oC$PD%R#9f|yLE?mfb3ZEW|4sih+c76K>|oWS+~eS03-ng0IR}MTL1t6 diff --git a/tests/screens/chip8-test-suite/splash.bin b/tests/screens/chip8-test-suite/splash.bin index 1d6794a5280352542352b74f1e77746fe204f974..9f75b09136b34d43c668bd7a8f092c3286788f7f 100644 GIT binary patch delta 43 ycmZo*YG9f$SCO5Wf#HG0-7Dolx^TzcJK^mN4E8(j9tr-(z#wmN_h{k7eNF&Xlo3P# delta 43 xcmZo*YG9f$SMfMA1H%K0y9d;Pbm5M>r`+2a80>+x@;?R!d5gP84o=+X1OQ?m5u*SA