From d3f1957f64b74ba9ba9d8c2d2f1c7faa7bd86938 Mon Sep 17 00:00:00 2001 From: Jonathan Balls Date: Fri, 4 Oct 2024 11:24:04 +0100 Subject: [PATCH] fix off-by-one error when for scanline number --- src/mmu/ppu.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mmu/ppu.rs b/src/mmu/ppu.rs index 6ef3749..bae9525 100644 --- a/src/mmu/ppu.rs +++ b/src/mmu/ppu.rs @@ -85,13 +85,13 @@ impl PPU { // Full line takes 114 ticks if self.modeclock >= 456 { + self.modeclock -= 456; + self.ly = (self.ly + 1) % 154; + if self.ly < SCREEN_HEIGHT as u8 { self.render_scanline(self.ly); } - self.modeclock -= 456; - self.ly = (self.ly + 1) % 154; - // Enter mode 1 (VBLANK) if self.ly == 144 { self.vblank_irq = true