From 8149352e6346b98ad639e453a4f32826220c4499 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sat, 12 Jun 2021 13:41:51 -0500 Subject: [PATCH] fix(ppu): Discard SCX mod 8 pixels from fifo As of right now, the implementation of this is rudimentary. There are currently some visual bugs that still need to get worked out --- src/ppu.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ppu.rs b/src/ppu.rs index 6490f2e..0705daa 100644 --- a/src/ppu.rs +++ b/src/ppu.rs @@ -381,6 +381,15 @@ impl Ppu { if self.fifo.is_enabled() { use RenderPriority::*; + if self.x_pos == 0 { + // Start of a Scanline + let discarded_count = self.pos.scroll_x % 8; + + for _ in 0..discarded_count { + let _ = self.fifo.back.pop_back(); + } + } + // Handle Background Pixel and Sprite FIFO let bg_enabled = self.ctrl.bg_win_enabled(); let obj_enabled = self.ctrl.obj_enabled();