Optimize palette access
Jeffrey Pfau jeffrey@endrift.com
Mon, 04 Nov 2013 22:43:20 -0800
1 files changed,
10 insertions(+),
5 deletions(-)
M
src/gba/renderers/video-software.c
→
src/gba/renderers/video-software.c
@@ -637,10 +637,10 @@ pixelData = tileData & 0xF; \
current = *pixel; \ if (pixelData && !(current & FLAG_FINALIZED)) { \ if (!objwinSlowPath) { \ - _composite(renderer, pixel, palette[pixelData | paletteData] | flags, current); \ + _composite(renderer, pixel, palette[pixelData] | flags, current); \ } else if (objwinForceEnable || !(current & FLAG_OBJWIN) == objwinOnly) { \ - color_t* currentPalette = (current & FLAG_OBJWIN) ? objwinPalette : palette; \ - _composite(renderer, pixel, currentPalette[pixelData | paletteData] | flags, current); \ + unsigned color = (current & FLAG_OBJWIN) ? objwinPalette[paletteData | pixelData] : palette[pixelData]; \ + _composite(renderer, pixel, color | flags, current); \ } \ } \ tileData >>= 4;@@ -734,10 +734,11 @@
uint32_t screenBase; uint32_t charBase; int variant = background->target1 && renderer->currentWindow.blendEnable && (renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN); - color_t* palette = renderer->normalPalette; + color_t* mainPalette = renderer->normalPalette; if (variant) { - palette = renderer->variantPalette; + mainPalette = renderer->variantPalette; } + color_t* palette = mainPalette; PREPARE_OBJWIN; int outX = renderer->start;@@ -756,6 +757,7 @@
int end = outX + 0x8 - mod8; if (!background->multipalette) { paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; + palette = &mainPalette[paletteData]; charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; tileData = ((uint32_t*)renderer->d.vram)[charBase]; if (!GBA_TEXT_MAP_HFLIP(mapData)) {@@ -804,6 +806,7 @@ if (!background->multipalette) {
charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; tileData = ((uint32_t*)renderer->d.vram)[charBase]; paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; + palette = &mainPalette[paletteData]; if (!GBA_TEXT_MAP_HFLIP(mapData)) { outX = renderer->end - mod8; if (outX < 0) {@@ -865,6 +868,7 @@ tileData = carryData;
for (x = 0; x < 8; ++x) { if (!mosaicWait) { paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; + palette = &mainPalette[paletteData]; tileData = ((uint32_t*)renderer->d.vram)[charBase]; if (!GBA_TEXT_MAP_HFLIP(mapData)) { tileData >>= x * 4;@@ -897,6 +901,7 @@ if (!background->multipalette) {
for (; tileX < tileEnd; ++tileX) { BACKGROUND_TEXT_SELECT_CHARACTER; paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; + palette = &mainPalette[paletteData]; charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; tileData = ((uint32_t*)renderer->d.vram)[charBase]; if (tileData) {