mirror of https://github.com/mgba-emu/mgba.git
Refactor sprite code in preparation of implementing OBJ mosaic
This commit is contained in:
parent
72ef1643c7
commit
3b0ee473d3
|
@ -1172,23 +1172,14 @@ static const int _objSizes[32] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SPRITE_NORMAL_LOOP(DEPTH, TYPE) \
|
#define SPRITE_NORMAL_LOOP(DEPTH, TYPE) \
|
||||||
SPRITE_YBASE_ ## DEPTH(inY); \
|
SPRITE_YBASE_ ## DEPTH(inY); \
|
||||||
int outX = x >= start ? x : start; \
|
for (; outX < condition; ++outX, inX += xOffset) { \
|
||||||
int condition = x + width; \
|
if (!(renderer->row[outX] & FLAG_UNWRITTEN)) { \
|
||||||
if (end < condition) { \
|
continue; \
|
||||||
condition = end; \
|
|
||||||
} \
|
} \
|
||||||
for (; outX < condition; ++outX) { \
|
SPRITE_XBASE_ ## DEPTH(inX); \
|
||||||
int inX = outX - x; \
|
SPRITE_DRAW_PIXEL_ ## DEPTH ## _ ## TYPE(inX); \
|
||||||
if (sprite->hflip) { \
|
}
|
||||||
inX = width - inX - 1; \
|
|
||||||
} \
|
|
||||||
if (!(renderer->row[outX] & FLAG_UNWRITTEN)) { \
|
|
||||||
continue; \
|
|
||||||
} \
|
|
||||||
SPRITE_XBASE_ ## DEPTH(inX); \
|
|
||||||
SPRITE_DRAW_PIXEL_ ## DEPTH ## _ ## TYPE(inX); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SPRITE_TRANSFORMED_LOOP(DEPTH, TYPE) \
|
#define SPRITE_TRANSFORMED_LOOP(DEPTH, TYPE) \
|
||||||
int outX; \
|
int outX; \
|
||||||
|
@ -1269,6 +1260,18 @@ static int _preprocessSprite(struct GBAVideoSoftwareRenderer* renderer, struct G
|
||||||
if (variant) {
|
if (variant) {
|
||||||
palette = renderer->variantPalette;
|
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 (!sprite->multipalette) {
|
||||||
if (flags & FLAG_OBJWIN) {
|
if (flags & FLAG_OBJWIN) {
|
||||||
SPRITE_NORMAL_LOOP(16, OBJWIN);
|
SPRITE_NORMAL_LOOP(16, OBJWIN);
|
||||||
|
|
Loading…
Reference in New Issue