chip8-test-suite: Update to 4.0
This commit is contained in:
parent
d54fb7eb2c
commit
bafb576705
@ -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"
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit af7829841b4c9b043febbd37a4d4114e0ac948ec
|
||||
Subproject commit 253f5de130a6cc4c7e07c6801174717efb0ea9cb
|
@ -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,
|
||||
|
Binary file not shown.
BIN
tests/screens/chip8-test-suite/corax+.bin
Normal file
BIN
tests/screens/chip8-test-suite/corax+.bin
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user