From b35add1999eb91a09eba969827616cd96a26bad8 Mon Sep 17 00:00:00 2001 From: Theron Spiegl Date: Tue, 12 Nov 2019 17:57:23 -0600 Subject: [PATCH] fixed sprite bug thanks to /u/dwedit --- README.md | 2 -- src/ppu/rendering.rs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index f7a76de..d27f038 100644 --- a/README.md +++ b/README.md @@ -33,5 +33,3 @@ Thanks to Michael Fogleman's https://github.com/fogleman/nes for getting me unst - Audio - Player 2 controller? - -- Sprite bug when Goomba smashed in Mario diff --git a/src/ppu/rendering.rs b/src/ppu/rendering.rs index a52969d..1774ba0 100644 --- a/src/ppu/rendering.rs +++ b/src/ppu/rendering.rs @@ -216,7 +216,7 @@ impl super::Ppu { if sprite_attributes & (1<<7) == 0 { // if vertical flip bit not set fine_y = self.scanline - sprite_y_position; // row-within-sprite offset is difference between current scanline and top of sprite } else { // if flipped vertically - fine_y = self.sprite_size as usize - (self.scanline - sprite_y_position); + fine_y = self.sprite_size as usize - 1 - (self.scanline - sprite_y_position); } address += fine_y; let low_pattern_table_byte = self.read(address);