diff --git a/src/ppu.rs b/src/ppu.rs index c2073b2fde7864f4103b46f4840f55cf6669964f..2c08177413f1e4f8a73456ef7e7bca50de8c5b9f 100644 --- a/src/ppu.rs +++ b/src/ppu.rs @@ -503,7 +503,7 @@ impl Ppu { } pub fn ack_vblank(&mut self) { - self.int_vblank = false; + self.set_int_vblank(false); } /// Fills the frame buffer with pixels of the provided color, diff --git a/src/timer.rs b/src/timer.rs index 0169e9e8ceec2700463b66134338174179ef1c15..c2f5883aee8fb753b0d837dbabc288577a3a163a 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -27,21 +27,22 @@ impl Timer { pub fn clock(&mut self, cycles: u8) { self.div_clock += cycles as u16; - self.tima_clock += cycles as u16; - if self.div_clock >= 256 { self.div = self.div.wrapping_add(1); self.div_clock = self.div_clock - 256; } - if self.tima_enabled && self.tima_clock >= self.tima_ratio { - if self.tima == 0xff { - self.int_tima = true; - self.tima = self.tma; - } + if self.tima_enabled { + self.tima_clock += cycles as u16; + if self.tima_clock >= self.tima_ratio { + if self.tima == 0xff { + self.int_tima = true; + self.tima = self.tma; + } - self.tima = self.tima.wrapping_add(1); - self.tima_clock = self.tima_clock - self.tima_ratio; + self.tima = self.tima.wrapping_add(1); + self.tima_clock = self.tima_clock - self.tima_ratio; + } } } @@ -84,6 +85,6 @@ impl Timer { } pub fn ack_tima(&mut self) { - self.int_tima = false; + self.set_int_tima(false); } }