all repos — mgba @ 2a683aaf9906fc5d03183f194e84b5ef57514e4d

mGBA Game Boy Advance Emulator

Preselect palettes for sprites
Jeffrey Pfau jeffrey@endrift.com
Tue, 05 Nov 2013 23:17:03 -0800
commit

2a683aaf9906fc5d03183f194e84b5ef57514e4d

parent

fd6e9cb3117df49bb2755cadbae7cfb161e73413

1 files changed, 8 insertions(+), 6 deletions(-)

jump to
M src/gba/renderers/video-software.csrc/gba/renderers/video-software.c

@@ -1245,7 +1245,7 @@ #define SPRITE_DRAW_PIXEL_16_NORMAL(localX) \

unsigned tileData = renderer->d.vram[(yBase + charBase + xBase) >> 1]; \ tileData = (tileData >> ((localX & 3) << 2)) & 0xF; \ if (tileData && (!(renderer->spriteLayer[outX]) || ((renderer->spriteLayer[outX] & FLAG_ORDER_MASK) > flags))) { \ - renderer->spriteLayer[outX] = palette[0x100 | tileData | (sprite->palette << 4)] | flags; \ + renderer->spriteLayer[outX] = palette[tileData] | flags; \ } #define SPRITE_DRAW_PIXEL_16_OBJWIN(localX) \

@@ -1262,7 +1262,7 @@ #define SPRITE_DRAW_PIXEL_256_NORMAL(localX) \

unsigned tileData = renderer->d.vram[(yBase + charBase + xBase) >> 1]; \ tileData = (tileData >> ((localX & 1) << 3)) & 0xFF; \ if (tileData && (!(renderer->spriteLayer[outX]) || ((renderer->spriteLayer[outX] & FLAG_ORDER_MASK) > flags))) { \ - renderer->spriteLayer[outX] = palette[0x100 | tileData] | flags; \ + renderer->spriteLayer[outX] = palette[tileData] | flags; \ } #define SPRITE_DRAW_PIXEL_256_OBJWIN(localX) \

@@ -1295,9 +1295,9 @@ if (sprite->mode == OBJ_MODE_SEMITRANSPARENT && renderer->target2Bd) {

// Hack: if a sprite is blended, then the variant palette is not used, but we don't know if it's blended in advance variant = 0; } - color_t* palette = renderer->normalPalette; + color_t* palette = &renderer->normalPalette[0x100]; if (variant) { - palette = renderer->variantPalette; + palette = &renderer->variantPalette[0x100]; } int outX = x >= start ? x : start;

@@ -1326,6 +1326,7 @@ inX = width - inX - 1;

xOffset = -1; } if (!sprite->multipalette) { + palette = &palette[sprite->palette << 4]; if (flags & FLAG_OBJWIN) { SPRITE_NORMAL_LOOP(16, OBJWIN); } else if (sprite->mosaic) {

@@ -1367,15 +1368,16 @@ if (sprite->mode == OBJ_MODE_SEMITRANSPARENT && renderer->target2Bd) {

// Hack: if a sprite is blended, then the variant palette is not used, but we don't know if it's blended in advance variant = 0; } - color_t* palette = renderer->normalPalette; + color_t* palette = &renderer->normalPalette[0x100]; if (variant) { - palette = renderer->variantPalette; + palette = &renderer->variantPalette[0x100]; } int inY = y - sprite->y; if (inY < 0) { inY += 256; } if (!sprite->multipalette) { + palette = &palette[sprite->palette << 4]; if (flags & FLAG_OBJWIN) { SPRITE_TRANSFORMED_LOOP(16, OBJWIN); } else {