From 745b1c76b5df01d5e081bbe95045511200a6243e Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 22 Jan 2022 04:27:19 -0800 Subject: [PATCH] GBA Video: Ignore horizontally off-screen sprite timing (fixes #2391) --- CHANGES | 1 + src/gba/renderers/common.c | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 9a9d50e0a..75bf259ba 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ 0.9.4: (Future) Emulation fixes: - GBA I/O: Disable open bus behavior on invalid register 06A + - GBA Video: Ignore horizontally off-screen sprite timing (fixes mgba.io/i/2391) Other fixes: - FFmpeg: Fix crash when encoding audio with some containers - FFmpeg: Fix GIF recording (fixes mgba.io/i/2393) diff --git a/src/gba/renderers/common.c b/src/gba/renderers/common.c index 4c35706ca..c8a329fbe 100644 --- a/src/gba/renderers/common.c +++ b/src/gba/renderers/common.c @@ -24,16 +24,20 @@ int GBAVideoRendererCleanOAM(struct GBAObj* oam, struct GBAVideoRendererSprite* width <<= GBAObjAttributesAGetDoubleSize(obj.a); cycles = 10 + width * 2; } - if (GBAObjAttributesAGetY(obj.a) < GBA_VIDEO_VERTICAL_PIXELS || GBAObjAttributesAGetY(obj.a) + height >= VIDEO_VERTICAL_TOTAL_PIXELS) { - int y = GBAObjAttributesAGetY(obj.a) + offsetY; - sprites[oamMax].y = y; - sprites[oamMax].endY = y + height; - sprites[oamMax].cycles = cycles; - sprites[oamMax].obj = obj; - sprites[oamMax].index = i; - ++oamMax; + if (GBAObjAttributesAGetY(obj.a) >= GBA_VIDEO_VERTICAL_PIXELS && GBAObjAttributesAGetY(obj.a) + height < VIDEO_VERTICAL_TOTAL_PIXELS) { + continue; } + if (GBAObjAttributesBGetX(obj.b) >= GBA_VIDEO_HORIZONTAL_PIXELS && GBAObjAttributesBGetX(obj.b) + width < 512) { + continue; + } + int y = GBAObjAttributesAGetY(obj.a) + offsetY; + sprites[oamMax].y = y; + sprites[oamMax].endY = y + height; + sprites[oamMax].cycles = cycles; + sprites[oamMax].obj = obj; + sprites[oamMax].index = i; + ++oamMax; } } return oamMax; -} \ No newline at end of file +}