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