From c7b4ad88ffd18c3048be95f41db0fc71f3291d4c 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:51:19 +0100 Subject: [PATCH] feat: new debug info --- src/cpu.rs | 4 ++-- src/mmu.rs | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cpu.rs b/src/cpu.rs index 045016fc..de5346c7 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -96,12 +96,12 @@ impl Cpu { let (instruction_fn, instruction_time, instruction_str) = instruction; - //if *instruction_str == "! UNIMP !" { + if !self.mmu.boot_active() || *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 2e1e4f67..07b12d51 100644 --- a/src/mmu.rs +++ b/src/mmu.rs @@ -30,6 +30,10 @@ impl Mmu { &mut self.ppu } + pub fn boot_active(&self) -> bool { + self.boot_active + } + pub fn read(&mut self, addr: u16) -> u8 { match addr & 0xf000 { // BOOT (256 B) + ROM0 (4 KB/16 KB) @@ -74,9 +78,9 @@ impl Mmu { match addr & 0x00f0 { 0x40 | 0x50 | 0x60 | 0x70 => self.ppu.read(addr), 0x00 => { - //@todo implement the gamepad as a controller + println!("Reading from Game Pad control 0x{:04x}", addr); 0x00 - } + }, _ => { println!("Reading from unknown IO control 0x{:04x}", addr); 0x00 @@ -141,6 +145,9 @@ impl Mmu { 0x40 | 0x60 | 0x70 => { self.ppu.write(addr, value); } + 0x00 => { + println!("Writing to Game Pad, timer, etc. control 0x{:04x} := 0x{:02x}", addr, value); + }, 0x50 => match addr & 0x00ff { 0x50 => self.boot_active = false, _ => { -- GitLab