From 2b7958f5f36feb6bf68c65bc29617bf3a272a610 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Wed, 9 Jun 2021 20:48:31 -0500 Subject: [PATCH] chore(bus): add a select few read/write guards --- src/bus.rs | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/src/bus.rs b/src/bus.rs index 70789b0..bd8180c 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -158,14 +158,10 @@ impl BusIo for Bus { } 0x8000..=0x9FFF => { // 8KB Video RAM - - // TODO: Fix Timing issues in PPU - // match self.ppu.stat.mode() { - // PpuMode::VBlank => 0xFF, - // _ => self.ppu.read_byte(addr), - // } - - self.ppu.read_byte(addr) + match self.ppu.stat.mode() { + PpuMode::VBlank => 0xFF, + _ => self.ppu.read_byte(addr), + } } 0xA000..=0xBFFF => match self.cartridge.as_ref() { // 8KB External RAM @@ -195,16 +191,12 @@ impl BusIo for Bus { } 0xFE00..=0xFE9F => { // Sprite Attribute Table + use PpuMode::{HBlank, VBlank}; - // TODO: Fix timing issues in the PPU - // use PpuMode::{HBlank, VBlank}; - - // match self.ppu.stat.mode() { - // HBlank | VBlank => self.ppu.oam.read_byte(addr), - // _ => 0xFF, - // } - - self.ppu.oam.read_byte(addr) + match self.ppu.stat.mode() { + HBlank | VBlank => self.ppu.oam.read_byte(addr), + _ => 0xFF, + } } 0xFEA0..=0xFEFF => { // Prohibited Memory @@ -313,15 +305,12 @@ impl BusIo for Bus { } 0xFE00..=0xFE9F => { // Sprite Attribute Table - // use PpuMode::{HBlank, VBlank}; + use PpuMode::{HBlank, VBlank}; - // TODO: Fix Timing issues in the PPU - // match self.ppu.stat.mode() { - // HBlank | VBlank => self.ppu.oam.write_byte(addr, byte), - // _ => {} - // } - - self.ppu.oam.write_byte(addr, byte) + match self.ppu.stat.mode() { + HBlank | VBlank => self.ppu.oam.write_byte(addr, byte), + _ => {} + } } 0xFEA0..=0xFEFF => {} // TODO: As far as I know, writes to here do nothing. 0xFF00..=0xFF7F => { @@ -376,7 +365,7 @@ impl BusIo for Bus { self.boot = None; } } - _ => unimplemented!("Unable to write to {:#06X} in I/O Registers", addr), + _ => {} // unimplemented!("Unable to write to {:#06X} in I/O Registers", addr), }; } 0xFF80..=0xFFFE => {