From 6ad2b673b1110329517fc540952579ab8f8cc5e2 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 31 Jan 2014 22:40:21 -0800 Subject: [PATCH] Omit sprites that are off-screen vertically from OAM calculations --- src/gba/renderers/video-software.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index b3d655bb9..bb059cb5d 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -378,10 +378,12 @@ static void _cleanOAM(struct GBAVideoSoftwareRenderer* renderer) { if (obj->transformed) { height <<= ((struct GBATransformedObj*) obj)->doublesize; } - renderer->sprites[oamMax].y = obj->y; - renderer->sprites[oamMax].endY = obj->y + height; - renderer->sprites[oamMax].obj = *obj; - ++oamMax; + if (obj->y < VIDEO_VERTICAL_PIXELS || obj->y + height >= VIDEO_VERTICAL_TOTAL_PIXELS) { + renderer->sprites[oamMax].y = obj->y; + renderer->sprites[oamMax].endY = obj->y + height; + renderer->sprites[oamMax].obj = *obj; + ++oamMax; + } } } renderer->oamMax = oamMax;