diff --git a/src/cpu.rs b/src/cpu.rs index 38a3d7d2ec55b5dd1079fdfe6d45e0f94fb2d569..045016fcbdc493d6d3ea0ef173115a9100b978b5 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -74,6 +74,10 @@ impl Cpu { pub fn clock(&mut self) -> u8 { let pc = self.pc; + if pc >= 0x8000 && pc < 0x9fff { + panic!("Invalid PC area at 0x{:04x}", pc); + } + // fetches the current instruction and increments // the PC (program counter) accordingly let mut opcode = self.mmu.read(self.pc); @@ -92,12 +96,12 @@ impl Cpu { let (instruction_fn, instruction_time, instruction_str) = instruction; - if *instruction_str == "! UNIMP !" { + //if *instruction_str == "! UNIMP !" { println!( "{}\t(0x{:02x})\t${:04x} {}", instruction_str, opcode, pc, is_prefix ); - } + //} // calls the current instruction and increments the number of // cycles executed by the instruction time of the instruction diff --git a/src/mmu.rs b/src/mmu.rs index 0a1be916b6c2d5246d80ae0383075345308913f8..2e1e4f67c720acb2666fb9253fb1a4b6ebf3980b 100644 --- a/src/mmu.rs +++ b/src/mmu.rs @@ -131,7 +131,7 @@ impl Mmu { self.ram[(addr & 0x1fff) as usize] = value; } 0xe00 => { - println!("Writing to PPU OAM"); + println!("Writing to PPU OAM at 0x{:04x}", addr); } 0xf00 => { if addr >= 0xff80 {