From 12bd090daf4cc63a5974f30d6feea56af865597b Mon Sep 17 00:00:00 2001 From: Sour Date: Sun, 3 Mar 2019 00:31:28 -0500 Subject: [PATCH] PPU: Fixed sprite wrapping behavior at the bottom/top of the screen --- Core/Ppu.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Core/Ppu.cpp b/Core/Ppu.cpp index 8a67299..aeb04a4 100644 --- a/Core/Ppu.cpp +++ b/Core/Ppu.cpp @@ -115,8 +115,10 @@ void Ppu::Exec() _cycle++; if(_cycle == 278 && _scanline <= (_overscanMode ? 239 : 224)) { - if(_scanline > 0) { + if(_scanline != 0) { RenderScanline(); + } else { + EvaluateNextLineSprites(); } _console->GetDmaController()->ProcessHdmaChannels(); } else if(_cycle == 134) { @@ -147,7 +149,10 @@ void Ppu::EvaluateNextLineSprites() height /= 2; } - if(y > screenY || y + height <= screenY) { + uint8_t startY = y + 16; + uint8_t endY = y + height + 16; + + if(startY > screenY + 16 || endY <= screenY + 16) { //Not visible on this scanline continue; }