From 15aa862d7046a71d82e84c8bd8c750f6b630b46d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 29 Jul 2013 00:44:38 -0700 Subject: [PATCH] Small optimization for sprite drawing --- src/gba/renderers/video-software.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index bbe56c581..2272ce9fe 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -1015,7 +1015,12 @@ static const int _objSizes[32] = { #define SPRITE_NORMAL_LOOP(DEPTH, TYPE) \ SPRITE_YBASE_ ## DEPTH(inY); \ - for (int outX = x >= start ? x : start; outX < x + width && outX < end; ++outX) { \ + int outX = x >= start ? x : start; \ + int condition = x + width; \ + if (end < condition) { \ + condition = end; \ + } \ + for (; outX < condition; ++outX) { \ int inX = outX - x; \ if (sprite->hflip) { \ inX = width - inX - 1; \