diff --git a/src/palette_util.c b/src/palette_util.c index 5364ff6d98..4f6416ea01 100755 --- a/src/palette_util.c +++ b/src/palette_util.c @@ -2,6 +2,7 @@ #include "palette.h" #include "palette_util.h" #include "util.h" +#include "overworld.h" // "RouletteFlash" is more accurately a general flashing/fading util // this file handles fading the palettes for the color/icon selections on the Roulette wheel @@ -247,7 +248,7 @@ int InitPulseBlendPaletteSettings(struct PulseBlend *pulseBlend, const struct Pu if (pulseBlendPalette == NULL) return 0xFF; - + pulseBlendPalette->blendCoeff = 0; pulseBlendPalette->fadeDirection = 0; pulseBlendPalette->available = 1; @@ -322,7 +323,7 @@ void MarkUsedPulseBlendPalettes(struct PulseBlend *pulseBlend, u16 pulseBlendPal pulseBlend->usedPulseBlendPalettes |= 1 << i; } } - } + } } void UnmarkUsedPulseBlendPalettes(struct PulseBlend *pulseBlend, u16 pulseBlendPaletteSelector, u8 multiSelection) @@ -385,7 +386,12 @@ void UpdatePulseBlend(struct PulseBlend *pulseBlend) if (--pulseBlendPalette->delayCounter == 0xFF) { pulseBlendPalette->delayCounter = pulseBlendPalette->pulseBlendSettings.delay; - BlendPalette(pulseBlendPalette->pulseBlendSettings.paletteOffset, pulseBlendPalette->pulseBlendSettings.numColors, pulseBlendPalette->blendCoeff, pulseBlendPalette->pulseBlendSettings.blendColor); + // TODO: Optimize pulse blending + CpuFastCopy(gPlttBufferUnfaded + pulseBlendPalette->pulseBlendSettings.paletteOffset, gPlttBufferFaded + pulseBlendPalette->pulseBlendSettings.paletteOffset, 32); + UpdatePalettesWithTime(1 << (pulseBlendPalette->pulseBlendSettings.paletteOffset >> 4)); + // pulseBlendSettings has a numColors field, but it is only ever set to 16 (for mirage tower) + // So, it's ok to use the fine blending here which blends the entire palette + BlendPalettesFine(1, gPlttBufferFaded + pulseBlendPalette->pulseBlendSettings.paletteOffset, gPlttBufferFaded + pulseBlendPalette->pulseBlendSettings.paletteOffset, pulseBlendPalette->blendCoeff, pulseBlendPalette->pulseBlendSettings.blendColor); switch (pulseBlendPalette->pulseBlendSettings.fadeType) { case 0: // Fade all the way to the max blend amount, then wrap around @@ -423,7 +429,7 @@ void UpdatePulseBlend(struct PulseBlend *pulseBlend) pulseBlendPalette->blendCoeff = 0; else pulseBlendPalette->blendCoeff = pulseBlendPalette->pulseBlendSettings.maxBlendCoeff & 0xF; - + pulseBlendPalette->fadeDirection ^= 1; pulseBlendPalette->fadeCycleCounter++; break;