From 0d8467c2a922d3df0256a9019b4f7ff531e46716 Mon Sep 17 00:00:00 2001 From: Ariel Antonitis Date: Mon, 19 Apr 2021 23:17:13 -0400 Subject: [PATCH] Slight palette update optimization. --- src/overworld.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/overworld.c b/src/overworld.c index 8b07124366..aa66280fc2 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -1526,32 +1526,31 @@ static bool8 FadePalettesWithTime(void) { // Only used to fade back in void UpdatePalettesWithTime(u32 palettes) { if (MapHasNaturalLight(gMapHeader.mapType)) { - u8 i, j; + u16 i; u16 tempPaletteBuffer[16]; for (i = 0; i < 16; i++) { - if (GetSpritePaletteTagByPaletteNum(i) & 0x8000) // Don't blend special sprite palette tags + if (GetSpritePaletteTagByPaletteNum(i) >> 15) // Don't blend special sprite palette tags palettes &= ~(1 << (i + 16)); } palettes &= ~0xE000; // Don't blend tile palettes [13,15] - gTimeOfDay = min(TIME_OF_DAY_MAX, gTimeOfDay); if (!palettes) return; - for (i = 0; palettes; i++) { + for (i = 0; palettes; i+=16) { if (palettes & 1) { if (sTimeOfDayBlendVars[currentTimeBlend.time0].isTint) - TintPalette_RGB_Copy(i*16, sTimeOfDayBlendVars[currentTimeBlend.time0].blendColor); + TintPalette_RGB_Copy(i, sTimeOfDayBlendVars[currentTimeBlend.time0].blendColor); else - TimeBlendPalette(i*16, sTimeOfDayBlendVars[currentTimeBlend.time0].coeff, sTimeOfDayBlendVars[currentTimeBlend.time0].blendColor); + TimeBlendPalette(i, sTimeOfDayBlendVars[currentTimeBlend.time0].coeff, sTimeOfDayBlendVars[currentTimeBlend.time0].blendColor); if (currentTimeBlend.weight == 256) { palettes >>= 1; continue; } - CpuFastCopy(&gPlttBufferFaded[i*16], tempPaletteBuffer, 32); + CpuFastCopy(&gPlttBufferFaded[i], tempPaletteBuffer, 32); if (sTimeOfDayBlendVars[currentTimeBlend.time1].isTint) - TintPalette_RGB_Copy(i*16, sTimeOfDayBlendVars[currentTimeBlend.time1].blendColor); + TintPalette_RGB_Copy(i, sTimeOfDayBlendVars[currentTimeBlend.time1].blendColor); else - TimeBlendPalette(i*16, sTimeOfDayBlendVars[currentTimeBlend.time1].coeff, sTimeOfDayBlendVars[currentTimeBlend.time1].blendColor); - AveragePalettes(tempPaletteBuffer, &gPlttBufferFaded[i*16], &gPlttBufferFaded[i*16], currentTimeBlend.weight); + TimeBlendPalette(i, sTimeOfDayBlendVars[currentTimeBlend.time1].coeff, sTimeOfDayBlendVars[currentTimeBlend.time1].blendColor); + AveragePalettes(tempPaletteBuffer, &gPlttBufferFaded[i], &gPlttBufferFaded[i], currentTimeBlend.weight); } palettes >>= 1; }