From f90465c7cd86930eecd66c726b1baf8cc1b0fcd9 Mon Sep 17 00:00:00 2001 From: Sour Date: Sat, 19 Oct 2024 13:31:25 +0900 Subject: [PATCH] NES: Count partially-copied sprites towards the sprite count for the next row --- Core/NES/NesPpu.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Core/NES/NesPpu.cpp b/Core/NES/NesPpu.cpp index 93af3b61..574de7c7 100644 --- a/Core/NES/NesPpu.cpp +++ b/Core/NES/NesPpu.cpp @@ -973,7 +973,11 @@ template void NesPpu::ProcessSpriteEvaluationStart() template void NesPpu::ProcessSpriteEvaluationEnd() { _sprite0Visible = _sprite0Added; - _spriteCount = (_secondaryOamAddr >> 2); + + //Add 3 to address to count any partially-copied sprite. + //If eval is misaligned and wraps back to the start of OAM, the copy can + //be stopped mid-sprite (e.g only 1 to 3 bytes are copied to secondary OAM) + _spriteCount = ((_secondaryOamAddr + 3) >> 2); if(_settings->GetNesConfig().EnablePpuSpriteEvalBug) { //(Not entirely confirmed - but matches observed behavior)