more validation tests for gemma video rendering
Adds 'doom like' 3dviprmaze-vip for demo (VERY VERY SLOW) updates egui interface to let user select from files in resources/roms updates cargo to centralize dependencies 95 passing tests
This commit is contained in:
@@ -4,22 +4,12 @@ use gemma::constants::CHIP8_VIDEO_MEMORY;
|
||||
#[test]
|
||||
fn smoke() { assert!(true) }
|
||||
|
||||
#[test]
|
||||
fn test_rom_1_works() {
|
||||
let mut x = Chip8Computer::new();
|
||||
// Load the IBM rom and run it.
|
||||
// it takes 39 cycles to get to the end so lets run it 40.
|
||||
|
||||
let test_rom_to_run = std::fs::read("../resources/roms/2-ibm-logo.ch8").unwrap();
|
||||
x.load_bytes_to_memory(0x200, (&test_rom_to_run).into());
|
||||
fn load_result(to_load: &str) -> String {
|
||||
std::fs::read_to_string(format!("../resources/test/{}", to_load)).unwrap()
|
||||
}
|
||||
|
||||
for i in 0..40 {
|
||||
x.step_system();
|
||||
}
|
||||
// ...then verify that the current video memory of the chip-8
|
||||
// simulator matches what we expect it to be
|
||||
|
||||
assert_eq!(x.dump_video_to_string(), std::fs::read_to_string("../resources/test/gemma_integration_ibm_rom_output.asc").unwrap());
|
||||
fn load_rom(to_load: &str) -> Vec<u8> {
|
||||
std::fs::read(format!("../resources/roms/{}", to_load)).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -39,3 +29,75 @@ fn reset_clears_video() {
|
||||
assert!(!x.video_memory.peek(i as u16));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn level1_test() {
|
||||
let mut x = Chip8Computer::new();
|
||||
let level_1_rom = load_rom("1-chip8-logo.ch8");
|
||||
x.load_bytes_to_memory(0x200, (&level_1_rom).into());
|
||||
|
||||
// run for 0x40 cycles
|
||||
while x.num_cycles < 0x40 {
|
||||
x.step_system();
|
||||
}
|
||||
assert_eq!(x.dump_video_to_string(), load_result("gemma_integration_level_1_test.asc"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn level2_test() {
|
||||
let mut x = Chip8Computer::new();
|
||||
// Load the IBM rom and run it.
|
||||
// it takes 39 cycles to get to the end so lets run it 40.
|
||||
|
||||
let test_rom_to_run = load_rom("2-ibm-logo.ch8");
|
||||
x.load_bytes_to_memory(0x200, (&test_rom_to_run).into());
|
||||
|
||||
for i in 0..40 {
|
||||
x.step_system();
|
||||
}
|
||||
// ...then verify that the current video memory of the chip-8
|
||||
// simulator matches what we expect it to be
|
||||
|
||||
assert_eq!(x.dump_video_to_string(), load_result("gemma_integration_ibm_rom_output.asc"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn level3_test() {
|
||||
let mut x = Chip8Computer::new();
|
||||
|
||||
x.load_bytes_to_memory(
|
||||
0x200, (&load_rom("3-corax+.ch8")).into()
|
||||
);
|
||||
for i in 0..0x180 {
|
||||
x.step_system();
|
||||
}
|
||||
|
||||
assert_eq!(x.dump_video_to_string(), load_result("gemma_integration_corax_plus.asc"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rps_test() {
|
||||
let mut x = Chip8Computer::new();
|
||||
x.load_bytes_to_memory(0x200, &load_rom("RPS.ch8").into());
|
||||
for i in 0..0xF0 {
|
||||
x.step_system();
|
||||
}
|
||||
assert_eq!(x.dump_video_to_string(), load_result("gemma_integration_rps_stage1.asc"));
|
||||
x.keypad.push_key(0x01);
|
||||
for i in 0..0x200 {
|
||||
x.step_system();
|
||||
}
|
||||
assert_eq!(x.dump_video_to_string(), load_result("gemma_integration_rps_stage2.asc"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn level4_test() {
|
||||
// flags
|
||||
let mut x = Chip8Computer::new();
|
||||
x.load_bytes_to_memory(0x200, &load_rom("4-flags.ch8").into());
|
||||
for i in 0..0x400 {
|
||||
x.step_system();
|
||||
}
|
||||
|
||||
assert_eq!(x.dump_video_to_string(), load_result("gemma_integration_flags.asc"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user