temporal backup
This commit is contained in:
+29
@@ -8,6 +8,35 @@ use crate::cartridge::Cartridge;
|
||||
use crate::cpu::Cpu;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
if args.len() > 1 {
|
||||
run_blargg(&args[1]);
|
||||
} else {
|
||||
run_nestest();
|
||||
}
|
||||
}
|
||||
|
||||
fn run_blargg(path: &str) {
|
||||
let cart = Cartridge::from_file(path).unwrap();
|
||||
let mut bus = NesBus::new(cart);
|
||||
let mut cpu = Cpu::new();
|
||||
cpu.reset(&mut bus); // boots from $FFFC-$FFFD via MMC1 PRG banking
|
||||
|
||||
let cycle_cap: u64 = 5_000_000; // blargg tests complete well under this; tune if needed
|
||||
while cpu.cycles < cycle_cap {
|
||||
cpu.step(&mut bus);
|
||||
}
|
||||
|
||||
let r0 = bus.read(0x6000);
|
||||
let r1 = bus.read(0x6001);
|
||||
let r2 = bus.read(0x6002);
|
||||
let r3 = bus.read(0x6003);
|
||||
println!("result: $6000={:02X} $6001={:02X} $6002={:02X} $6003={:02X}", r0, r1, r2, r3);
|
||||
if r0 == 0 { println!("PASS"); } else { println!("FAIL (error {:#04X})", r0); }
|
||||
}
|
||||
|
||||
fn run_nestest() {
|
||||
let cart: Cartridge = Cartridge::from_file("roms/test/cpu/nestest/nestest.nes").unwrap();
|
||||
let mut bus: NesBus = NesBus::new(cart);
|
||||
let mut cpu = Cpu::new();
|
||||
|
||||
Reference in New Issue
Block a user