all repos — mgba @ 698bc0ada5ade172a618014f2054fdd597f659f7

mGBA Game Boy Advance Emulator

Re-add 256-color
Jeffrey Pfau jeffrey@endrift.com
Tue, 30 Apr 2013 01:32:48 -0700
commit

698bc0ada5ade172a618014f2054fdd597f659f7

parent

6cdfa43e970b42cfd383765272482c9110798900

1 files changed, 110 insertions(+), 40 deletions(-)

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

@@ -352,6 +352,12 @@ _composite(renderer, outX, renderer->normalPalette[tileData & 0xF | (mapData.palette << 4)], flags); \

} \ tileData >>= 4; +#define BACKGROUND_DRAW_PIXEL_256 \ + if (tileData & 0xFF && !renderer->flags[outX].finalized) { \ + _composite(renderer, outX, renderer->normalPalette[tileData & 0xFF], flags); \ + } \ + tileData >>= 8; + #define BACKGROUND_TEXT_SELECT_CHARACTER \ localX = tileX * 8 + inX; \ xBase = localX & 0xF8; \

@@ -419,49 +425,113 @@ tileX = 1;

outX = end; } - for (tileX; tileX < 30; ++tileX) { - BACKGROUND_TEXT_SELECT_CHARACTER; - charBase = ((background->charBase + (mapData.tile << 5)) >> 2) + localY; - uint32_t tileData = ((uint32_t*)renderer->d.vram)[charBase]; - if (tileData) { - if (!mapData.hflip) { - BACKGROUND_DRAW_PIXEL_16; - ++outX; - BACKGROUND_DRAW_PIXEL_16; - ++outX; - BACKGROUND_DRAW_PIXEL_16; - ++outX; - BACKGROUND_DRAW_PIXEL_16; - ++outX; - BACKGROUND_DRAW_PIXEL_16; - ++outX; - BACKGROUND_DRAW_PIXEL_16; - ++outX; - BACKGROUND_DRAW_PIXEL_16; - ++outX; - BACKGROUND_DRAW_PIXEL_16; - ++outX; + if (!background->multipalette) { + for (tileX; tileX < 30; ++tileX) { + BACKGROUND_TEXT_SELECT_CHARACTER; + charBase = ((background->charBase + (mapData.tile << 5)) >> 2) + localY; + uint32_t tileData = ((uint32_t*)renderer->d.vram)[charBase]; + if (tileData) { + if (!mapData.hflip) { + BACKGROUND_DRAW_PIXEL_16; + ++outX; + BACKGROUND_DRAW_PIXEL_16; + ++outX; + BACKGROUND_DRAW_PIXEL_16; + ++outX; + BACKGROUND_DRAW_PIXEL_16; + ++outX; + BACKGROUND_DRAW_PIXEL_16; + ++outX; + BACKGROUND_DRAW_PIXEL_16; + ++outX; + BACKGROUND_DRAW_PIXEL_16; + ++outX; + BACKGROUND_DRAW_PIXEL_16; + ++outX; + } else { + outX += 7; + BACKGROUND_DRAW_PIXEL_16; + --outX; + BACKGROUND_DRAW_PIXEL_16; + --outX; + BACKGROUND_DRAW_PIXEL_16; + --outX; + BACKGROUND_DRAW_PIXEL_16; + --outX; + BACKGROUND_DRAW_PIXEL_16; + --outX; + BACKGROUND_DRAW_PIXEL_16; + --outX; + BACKGROUND_DRAW_PIXEL_16; + --outX; + BACKGROUND_DRAW_PIXEL_16; + outX += 8; + } } else { - outX += 7; - BACKGROUND_DRAW_PIXEL_16; - --outX; - BACKGROUND_DRAW_PIXEL_16; - --outX; - BACKGROUND_DRAW_PIXEL_16; - --outX; - BACKGROUND_DRAW_PIXEL_16; - --outX; - BACKGROUND_DRAW_PIXEL_16; - --outX; - BACKGROUND_DRAW_PIXEL_16; - --outX; - BACKGROUND_DRAW_PIXEL_16; - --outX; - BACKGROUND_DRAW_PIXEL_16; outX += 8; } - } else { - outX += 8; + } + } else { + for (tileX; tileX < 30; ++tileX) { + BACKGROUND_TEXT_SELECT_CHARACTER; + charBase = ((background->charBase + (mapData.tile << 6)) >> 2) + (localY << 1); + if (!mapData.hflip) { + uint32_t tileData = ((uint32_t*)renderer->d.vram)[charBase]; + if (tileData) { + BACKGROUND_DRAW_PIXEL_256; + ++outX; + BACKGROUND_DRAW_PIXEL_256; + ++outX; + BACKGROUND_DRAW_PIXEL_256; + ++outX; + BACKGROUND_DRAW_PIXEL_256; + ++outX; + } else { + outX += 4; + } + tileData = ((uint32_t*)renderer->d.vram)[charBase + 1]; + if (tileData) { + BACKGROUND_DRAW_PIXEL_256; + ++outX; + BACKGROUND_DRAW_PIXEL_256; + ++outX; + BACKGROUND_DRAW_PIXEL_256; + ++outX; + BACKGROUND_DRAW_PIXEL_256; + ++outX; + } else { + outX += 4; + } + } else { + uint32_t tileData = ((uint32_t*)renderer->d.vram)[charBase + 1]; + if (tileData) { + outX += 3; + BACKGROUND_DRAW_PIXEL_256; + --outX; + BACKGROUND_DRAW_PIXEL_256; + --outX; + BACKGROUND_DRAW_PIXEL_256; + --outX; + BACKGROUND_DRAW_PIXEL_256; + outX += 4; + } else { + outX += 4; + } + tileData = ((uint32_t*)renderer->d.vram)[charBase]; + if (tileData) { + outX += 3; + BACKGROUND_DRAW_PIXEL_256; + --outX; + BACKGROUND_DRAW_PIXEL_256; + --outX; + BACKGROUND_DRAW_PIXEL_256; + --outX; + BACKGROUND_DRAW_PIXEL_256; + outX += 4; + } else { + outX += 4; + } + } } } }