feat: implement window x, window y and ly compare registers

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-03-16 22:52:43 -05:00
parent 06821bf880
commit adeb6ca8a9
2 changed files with 9 additions and 0 deletions

View File

@ -130,9 +130,12 @@ impl Bus {
0xFF42 => self.ppu.pos.scroll_y, 0xFF42 => self.ppu.pos.scroll_y,
0xFF43 => self.ppu.pos.scroll_x, 0xFF43 => self.ppu.pos.scroll_x,
0xFF44 => self.ppu.pos.line_y, 0xFF44 => self.ppu.pos.line_y,
0xFF45 => self.ppu.pos.ly_compare as u8,
0xFF47 => self.ppu.monochrome.bg_palette.into(), 0xFF47 => self.ppu.monochrome.bg_palette.into(),
0xFF48 => self.ppu.monochrome.obj_palette_0.into(), 0xFF48 => self.ppu.monochrome.obj_palette_0.into(),
0xFF49 => self.ppu.monochrome.obj_palette_1.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), _ => unimplemented!("Unable to read {:#06X} in I/O Registers", addr),
} }
} }
@ -213,9 +216,12 @@ impl Bus {
0xFF42 => self.ppu.pos.scroll_y = byte, 0xFF42 => self.ppu.pos.scroll_y = byte,
0xFF43 => self.ppu.pos.scroll_x = byte, 0xFF43 => self.ppu.pos.scroll_x = byte,
0xFF44 => self.ppu.pos.line_y = 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(), 0xFF47 => self.ppu.monochrome.bg_palette = byte.into(),
0xFF48 => self.ppu.monochrome.obj_palette_0 = byte.into(), 0xFF48 => self.ppu.monochrome.obj_palette_0 = byte.into(),
0xFF49 => self.ppu.monochrome.obj_palette_1 = 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 => { 0xFF50 => {
// Disable Boot ROM // Disable Boot ROM
if byte != 0 { if byte != 0 {

View File

@ -167,6 +167,9 @@ pub struct ScreenPosition {
pub scroll_y: u8, pub scroll_y: u8,
pub scroll_x: u8, pub scroll_x: u8,
pub line_y: u8, pub line_y: u8,
pub ly_compare: bool,
pub window_y: u8,
pub window_x: u8,
} }
bitfield! { bitfield! {