From d5efdd60849604c72939c0fb95cf0a6e5015f1f7 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Thu, 9 Feb 2023 10:05:13 +1100 Subject: [PATCH] derives + set stat properly + joypad improvements --- src/processor/memory.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/processor/memory.rs b/src/processor/memory.rs index bee19e7..a2f8c92 100644 --- a/src/processor/memory.rs +++ b/src/processor/memory.rs @@ -10,11 +10,13 @@ pub(crate) mod rom; pub(crate) type Address = u16; +#[derive(Debug)] enum JoypadBank { Action, Direction, } +#[derive(Debug)] struct Joypad { bank_sel: JoypadBank, down: bool, @@ -32,6 +34,7 @@ impl Joypad { let mut reg = 0xFF; match self.bank_sel { JoypadBank::Action => { + reg = clear_bit(reg, 5); if self.start { reg = clear_bit(reg, 3); } @@ -46,6 +49,7 @@ impl Joypad { } } JoypadBank::Direction => { + reg = clear_bit(reg, 4); if self.down { reg = clear_bit(reg, 3); } @@ -242,14 +246,15 @@ impl Memory { } 0xFF11 | 0xFF14 | 0xFF16 | 0xFF19 | 0xFF1E | 0xFF23 | 0xFF26 => { // sound + self.io[addr_l] = data; } 0xFF41 => { - // mixed read/write addresses... - // need to fill these out more... - // just seeing what breaks... + // mixed read/write + self.io[addr_l] = self.io[addr_l] | (data & 0b1111000) } 0xFF4D | 0xFF56 => { // cgb only + self.io[addr_l] = data; } 0xFF44 | 0xFF76 | 0xFF77 => { // read-only addresses