diff --git a/src/bus.rs b/src/bus.rs index 4dc2730..099957e 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -235,7 +235,7 @@ impl Bus { self.ppu.pos.ly_compare = byte; // Update Coincidence Flag - if self.ppu.stat.coincidence_intr() { + if self.ppu.stat.coincidence_int() { let are_equal = self.ppu.pos.line_y == byte; self.ppu.stat.set_coincidence(are_equal); } diff --git a/src/ppu.rs b/src/ppu.rs index c47a724..edb5e0f 100644 --- a/src/ppu.rs +++ b/src/ppu.rs @@ -56,7 +56,7 @@ impl Ppu { if self.cycles >= 172.into() { self.cycles %= 172; - if self.stat.hblank_intr() { + if self.stat.hblank_int() { self.interrupt.set_lcd_stat(true); } @@ -73,13 +73,13 @@ impl Ppu { let next_mode = if self.pos.line_y >= 144 { self.interrupt.set_vblank(true); - if self.stat.vblank_intr() { + if self.stat.vblank_int() { self.interrupt.set_lcd_stat(true); } Mode::VBlank } else { - if self.stat.oam_intr() { + if self.stat.oam_int() { self.interrupt.set_lcd_stat(true); } @@ -88,7 +88,7 @@ impl Ppu { self.stat.set_mode(next_mode); - if self.stat.coincidence_intr() { + if self.stat.coincidence_int() { let are_equal = self.pos.line_y == self.pos.ly_compare; self.stat.set_coincidence(are_equal); } @@ -106,7 +106,7 @@ impl Ppu { self.pos.line_y = 0; } - if self.stat.coincidence_intr() { + if self.stat.coincidence_int() { let are_equal = self.pos.line_y == self.pos.ly_compare; self.stat.set_coincidence(are_equal); } @@ -214,10 +214,10 @@ impl Interrupt { bitfield! { pub struct LCDStatus(u8); impl Debug; - pub coincidence_intr, set_coincidence_intr: 6; - pub oam_intr, set_oam_intr: 5; - pub vblank_intr, set_vblank_intr: 4; - pub hblank_intr, set_hblank_intr: 3; + pub coincidence_int, set_coincidence_int: 6; + pub oam_int, set_oam_int: 5; + pub vblank_int, set_vblank_int: 4; + pub hblank_int, set_hblank_int: 3; pub coincidence, set_coincidence: 2; // LYC == LY Flag from into Mode, _mode, set_mode: 1, 0; } diff --git a/src/timer.rs b/src/timer.rs index 807040b..5d3e298 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -21,23 +21,24 @@ impl Timer { self.divider = self.divider.wrapping_add(1); // Get Bit Position - let pos = match self.control.speed() { + let bit = match self.control.speed() { Hz4096 => 9, Hz262144 => 3, Hz65536 => 5, Hz16384 => 7, }; - let bit = (self.divider >> pos) as u8 & 0x01; + let bit = (self.divider >> bit) as u8 & 0x01; let timer_enable = self.control.enabled() as u8; let and_result = bit & timer_enable; if let Some(previous) = self.prev_and_result { if previous == 0x01 && and_result == 0x00 { - // Falling Edge, increase TIMA Regiser + // Falling Edge, increase TIMA Register self.increment_tima(); } } + self.prev_and_result = Some(and_result); } }