From adeb6ca8a9668e12cd04f864dd7914e94bc67883 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Tue, 16 Mar 2021 22:52:43 -0500 Subject: [PATCH] feat: implement window x, window y and ly compare registers --- src/bus.rs | 6 ++++++ src/ppu.rs | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/bus.rs b/src/bus.rs index 3101199..b243803 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -130,9 +130,12 @@ impl Bus { 0xFF42 => self.ppu.pos.scroll_y, 0xFF43 => self.ppu.pos.scroll_x, 0xFF44 => self.ppu.pos.line_y, + 0xFF45 => self.ppu.pos.ly_compare as u8, 0xFF47 => self.ppu.monochrome.bg_palette.into(), 0xFF48 => self.ppu.monochrome.obj_palette_0.into(), 0xFF49 => self.ppu.monochrome.obj_palette_1.into(), + 0xFF4A => self.ppu.pos.window_y, + 0xFF4B => self.ppu.pos.window_x, _ => unimplemented!("Unable to read {:#06X} in I/O Registers", addr), } } @@ -213,9 +216,12 @@ impl Bus { 0xFF42 => self.ppu.pos.scroll_y = byte, 0xFF43 => self.ppu.pos.scroll_x = byte, 0xFF44 => self.ppu.pos.line_y = byte, + 0xFF45 => self.ppu.pos.ly_compare = byte == 0x01, // FIXME: We don't consider the possibility of a byte being different form 0x00 or 0x01 0xFF47 => self.ppu.monochrome.bg_palette = byte.into(), 0xFF48 => self.ppu.monochrome.obj_palette_0 = byte.into(), 0xFF49 => self.ppu.monochrome.obj_palette_1 = byte.into(), + 0xFF4A => self.ppu.pos.window_y = byte, + 0xFF4B => self.ppu.pos.window_x = byte, 0xFF50 => { // Disable Boot ROM if byte != 0 { diff --git a/src/ppu.rs b/src/ppu.rs index 223c47e..ac34d29 100644 --- a/src/ppu.rs +++ b/src/ppu.rs @@ -167,6 +167,9 @@ pub struct ScreenPosition { pub scroll_y: u8, pub scroll_x: u8, pub line_y: u8, + pub ly_compare: bool, + pub window_y: u8, + pub window_x: u8, } bitfield! {