Refactor sprite code in preparation of implementing OBJ mosaic
Jeffrey Pfau jeffrey@endrift.com
Sun, 27 Oct 2013 02:39:14 -0700
1 files changed,
19 insertions(+),
16 deletions(-)
M
src/gba/renderers/video-software.c
→
src/gba/renderers/video-software.c
@@ -1172,23 +1172,14 @@ 0, 0
}; #define SPRITE_NORMAL_LOOP(DEPTH, TYPE) \ - SPRITE_YBASE_ ## DEPTH(inY); \ - int outX = x >= start ? x : start; \ - int condition = x + width; \ - if (end < condition) { \ - condition = end; \ + SPRITE_YBASE_ ## DEPTH(inY); \ + for (; outX < condition; ++outX, inX += xOffset) { \ + if (!(renderer->row[outX] & FLAG_UNWRITTEN)) { \ + continue; \ } \ - for (; outX < condition; ++outX) { \ - int inX = outX - x; \ - if (sprite->hflip) { \ - inX = width - inX - 1; \ - } \ - if (!(renderer->row[outX] & FLAG_UNWRITTEN)) { \ - continue; \ - } \ - SPRITE_XBASE_ ## DEPTH(inX); \ - SPRITE_DRAW_PIXEL_ ## DEPTH ## _ ## TYPE(inX); \ - } + SPRITE_XBASE_ ## DEPTH(inX); \ + SPRITE_DRAW_PIXEL_ ## DEPTH ## _ ## TYPE(inX); \ + } #define SPRITE_TRANSFORMED_LOOP(DEPTH, TYPE) \ int outX; \@@ -1268,6 +1259,18 @@ int variant = renderer->target1Obj && renderer->currentWindow.blendEnable && sprite->mode != OBJ_MODE_SEMITRANSPARENT && (renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN);
color_t* palette = renderer->normalPalette; if (variant) { palette = renderer->variantPalette; + } + + int outX = x >= start ? x : start; + int condition = x + width; + if (end < condition) { + condition = end; + } + int inX = outX - x; + int xOffset = 1; + if (sprite->hflip) { + inX = width - inX - 1; + xOffset = -1; } if (!sprite->multipalette) { if (flags & FLAG_OBJWIN) {