From 0b50e4eae932acf1b94567a1b5a65971e81868c9 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Thu, 17 Jun 2021 18:29:22 -0500 Subject: [PATCH] fix(ppu): implement slightly better SCX discarding --- src/ppu.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ppu.rs b/src/ppu.rs index 0332bd5..afb8af4 100644 --- a/src/ppu.rs +++ b/src/ppu.rs @@ -381,12 +381,11 @@ 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; + if self.x_pos == 0 && !self.fifo.back.is_empty() { + let to_discard = self.pos.scroll_x % 8; - for _ in 0..discarded_count { - let _ = self.fifo.back.pop_back(); + for _ in 0..to_discard { + let _ = self.fifo.back.pop_front(); } }