From f257c45e68fb8eed7f3a556106fdf6645872d713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Sun, 3 Jul 2022 05:20:47 +0100 Subject: [PATCH] feat: new debug info --- src/cpu.rs | 8 ++++++-- src/mmu.rs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cpu.rs b/src/cpu.rs index 38a3d7d2..045016fc 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 0a1be916..2e1e4f67 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 { -- GitLab