From 24c603b62de74efe1be65f7b5614928d35035fcb Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 11 Nov 2019 00:32:19 -0800 Subject: [PATCH] GBA Video: Improve mode 2 speed --- src/gba/renderers/software-bg.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gba/renderers/software-bg.c b/src/gba/renderers/software-bg.c index db4b33e71..b9cc53b23 100644 --- a/src/gba/renderers/software-bg.c +++ b/src/gba/renderers/software-bg.c @@ -36,14 +36,16 @@ pixelData = charBase[(mapData << 6) + ((localY & 0x700) >> 5) + ((localX & 0x700) >> 8)]; #define MODE_2_LOOP(MOSAIC, COORD, BLEND, OBJWIN) \ - for (outX = renderer->start, pixel = &renderer->row[outX]; outX < renderer->end; ++outX, ++pixel) { \ + int condition = renderer->end - renderer->start; \ + pixel = &renderer->row[renderer->start]; \ + for (outX = 0; outX < condition; ++outX) { \ x += background->dx; \ y += background->dy; \ \ - uint32_t current = *pixel; \ MOSAIC(COORD) \ if (pixelData) { \ - COMPOSITE_256_ ## OBJWIN (BLEND, 0); \ + uint32_t current = pixel[outX]; \ + COMPOSITE_256_ ## OBJWIN (BLEND, outX); \ } \ }