Skip to content
Snippets Groups Projects
Commit 1f55a0bc authored by Vivian Roest's avatar Vivian Roest :gay_pride_flag:
Browse files
parent 46115579
No related branches found
No related tags found
No related merge requests found
......@@ -1031,7 +1031,7 @@ dependencies = [
[[package]]
name = "tudelft-nes-test"
version = "1.0.0"
version = "1.1.0"
dependencies = [
"bitflags",
"log",
......
[package]
name = "tudelft-nes-test"
version = "1.0.0"
version = "1.1.0"
edition = "2021"
authors = [
"Victor Roest <victor@xirion.net>",
......
......@@ -23,8 +23,9 @@ bitflags! {
const NESTEST = 0b00000001;
const ALL_INSTRS = 0b00000010;
const OFFICIAL_INSTRS = 0b00000100;
const ALL = Self::NESTEST.bits | Self::ALL_INSTRS.bits;
const DEFAULT = Self::OFFICIAL_INSTRS.bits;
const NROM_TEST = 0b00001000;
const ALL = Self::NESTEST.bits | Self::ALL_INSTRS.bits | Self::NROM_TEST.bits;
const DEFAULT = Self::OFFICIAL_INSTRS.bits | Self::NROM_TEST.bits;
}
}
......@@ -47,6 +48,10 @@ pub fn run_tests<T: TestableCpu>(selector: TestSelector) -> Result<(), String> {
nestest::<T>()?;
}
if selector.contains(TestSelector::NROM_TEST) {
nrom_test::<T>()?;
}
Ok(())
}
......@@ -147,6 +152,29 @@ fn nestest<T: TestableCpu + 'static>() -> Result<(), String> {
process_handle("nestest", handle)
}
/// runs our own nrom test rom
/// https://gitlab.ewi.tudelft.nl/software-fundamentals/nes-nrom-test
fn nrom_test<T: TestableCpu + 'static>() -> Result<(), String> {
let rom = include_bytes!("roms/nrom-test.nes");
let handle = thread::spawn(|| {
let mut cpu = T::get_cpu(rom).map_err(|i| TestError::Custom(i.to_string()))?;
run_cpu_headless_for(&mut cpu, Mirroring::Horizontal, 10)
.map_err(|i| TestError::Custom(i.to_string()))?;
if cpu.memory_read(0x42) != 0x43 {
Err(TestError::String("memory location 0x42 is wrong after executing nrom_test".to_owned()))
} else if cpu.memory_read(0x43) != 0x6A {
Err(TestError::String("memory location 0x43 is wrong after executing nrom_test".to_owned()))
} else {
Ok(())
}
});
process_handle("nrom_test", handle)
}
#[derive(Debug, Error)]
enum TestError {
#[error("{0}")]
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment