chip8-test-suite: Update to 4.0

This commit is contained in:
John 2023-04-17 05:04:23 -05:00
parent d54fb7eb2c
commit bafb576705
7 changed files with 32 additions and 13 deletions

View File

@ -2,7 +2,6 @@
name = "chirp" name = "chirp"
version = "0.1.1" version = "0.1.1"
edition = "2021" edition = "2021"
ignore = ["justfile", ".gitmodules", "chip8-test-suite", "chip8Archive"]
default-run = "chirp" default-run = "chirp"
authors = ["John Breaux"] authors = ["John Breaux"]
license = "MIT" license = "MIT"

@ -1 +1 @@
Subproject commit af7829841b4c9b043febbd37a4d4114e0ac948ec Subproject commit 253f5de130a6cc4c7e07c6801174717efb0ea9cb

View File

@ -7,7 +7,7 @@ fn setup_environment() -> (CPU, Bus) {
cpu.flags = Flags { cpu.flags = Flags {
debug: true, debug: true,
pause: false, pause: false,
monotonic: Some(8), monotonic: Some(10),
..Default::default() ..Default::default()
}; };
( (
@ -16,28 +16,30 @@ fn setup_environment() -> (CPU, Bus) {
// Load the charset into ROM // Load the charset into ROM
Charset [0x0050..0x00A0] = include_bytes!("../src/mem/charset.bin"), Charset [0x0050..0x00A0] = include_bytes!("../src/mem/charset.bin"),
// Load the ROM file into RAM // Load the ROM file into RAM
Program [0x0200..0x1000] = include_bytes!("../chip8-test-suite/bin/chip8-test-suite.ch8"), Program [0x0200..0x1000],
// Create a screen, and fill it with // Create a screen, and fill it with garbage
Screen [0x0F00..0x1000] = include_bytes!("chip8_test_suite.rs"), Screen [0x0F00..0x1000] = include_bytes!("chip8_test_suite.rs"),
}, },
) )
} }
struct SuiteTest { struct SuiteTest {
test: u16, test: u8,
data: &'static [u8],
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) {
// Set the test to run // 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 // The test suite always initiates a keypause on test completion
while !cpu.flags.keypause { while !(cpu.flags.keypause || cpu.flags.pause) {
cpu.multistep(&mut bus, 8).unwrap(); cpu.multistep(&mut bus, 100).unwrap();
} }
// Compare the screen to the reference screen buffer // Compare the screen to the reference screen buffer
bus.print_screen().unwrap(); 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() .print_screen()
.unwrap(); .unwrap();
assert_eq!(bus.get_region(Screen).unwrap(), test.screen); assert_eq!(bus.get_region(Screen).unwrap(), test.screen);
@ -49,6 +51,7 @@ fn splash_screen() {
run_screentest( run_screentest(
SuiteTest { SuiteTest {
test: 0, test: 0,
data: include_bytes!("../chip8-test-suite/bin/1-chip8-logo.ch8"),
screen: include_bytes!("screens/chip8-test-suite/splash.bin"), screen: include_bytes!("screens/chip8-test-suite/splash.bin"),
}, },
cpu, cpu,
@ -61,7 +64,8 @@ fn ibm_logo() {
let (cpu, bus) = setup_environment(); let (cpu, bus) = setup_environment();
run_screentest( run_screentest(
SuiteTest { 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"), screen: include_bytes!("screens/chip8-test-suite/IBM.bin"),
}, },
cpu, 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] #[test]
fn flags_test() { fn flags_test() {
let (cpu, bus) = setup_environment(); let (cpu, bus) = setup_environment();
run_screentest( run_screentest(
SuiteTest { SuiteTest {
test: 0x03, test: 0x00,
data: include_bytes!("../chip8-test-suite/bin/4-flags.ch8"),
screen: include_bytes!("screens/chip8-test-suite/flags.bin"), screen: include_bytes!("screens/chip8-test-suite/flags.bin"),
}, },
cpu, cpu,
@ -87,7 +106,8 @@ fn quirks_test() {
let (cpu, bus) = setup_environment(); let (cpu, bus) = setup_environment();
run_screentest( run_screentest(
SuiteTest { SuiteTest {
test: 0x0104, test: 0x01,
data: include_bytes!("../chip8-test-suite/bin/5-quirks.ch8"),
screen: include_bytes!("screens/chip8-test-suite/quirks.bin"), screen: include_bytes!("screens/chip8-test-suite/quirks.bin"),
}, },
cpu, cpu,

Binary file not shown.