From 4a5dbcb52ba695376986363a03808f4b42a6c8d2 Mon Sep 17 00:00:00 2001 From: Ariel Antonitis Date: Sun, 25 Apr 2021 00:56:23 -0400 Subject: [PATCH] Testing updating sprite palettes with weather + time. --- src/field_effect.c | 2 +- src/field_effect_helpers.c | 2 -- src/field_weather.c | 15 +++++++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/field_effect.c b/src/field_effect.c index 967e3d2398..ad6bdd747a 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -770,8 +770,8 @@ void FieldEffectScript_LoadFadedPalette(u8 **script) { struct SpritePalette *palette = (struct SpritePalette *)FieldEffectScript_ReadWord(script); LoadSpritePalette(palette); - UpdateSpritePaletteWithWeather(IndexOfSpritePaletteTag(palette->tag)); UpdateSpritePaletteWithTime(IndexOfSpritePaletteTag(palette->tag)); // Ensure field effects are blended + UpdateSpritePaletteWithWeather(IndexOfSpritePaletteTag(palette->tag)); (*script) += 4; } diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index 4304230391..8c3cf5bb1c 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -152,7 +152,6 @@ static void LoadObjectRegularReflectionPalette(struct ObjectEvent *objectEvent, } paletteNum = LoadSpritePalette(&filteredPalette); UpdateSpritePaletteWithWeather(paletteNum); - UpdateSpritePaletteWithTime(paletteNum); } sprite->oam.paletteNum = paletteNum; sprite->oam.objMode = 1; // Alpha blending @@ -205,7 +204,6 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite) } paletteNum = LoadSpritePalette(&filteredPalette); UpdateSpritePaletteWithWeather(paletteNum); - UpdateSpritePaletteWithTime(paletteNum); } reflectionSprite->oam.paletteNum = paletteNum; } diff --git a/src/field_weather.c b/src/field_weather.c index bbc7506e32..d4444a098d 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -536,8 +536,13 @@ static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex) } else { - // No palette blending. + u32 palettes = 0; + u32 mask = 1 << startPalIndex; + u8 i; CpuFastCopy(gPlttBufferUnfaded + startPalIndex * 16, gPlttBufferFaded + startPalIndex * 16, numPalettes * 16 * sizeof(u16)); + for (i = 0; i < numPalettes; i++, mask <<= 1) + palettes |= mask; + UpdatePalettesWithTime(palettes); } } @@ -825,7 +830,6 @@ void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex) { u16 paletteIndex = 16 + spritePaletteIndex; u16 i; - switch (gWeatherPtr->palProcessingState) { case WEATHER_PAL_STATE_SCREEN_FADING_IN: @@ -853,7 +857,10 @@ void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex) else { paletteIndex *= 16; - BlendPalette(paletteIndex, 16, 12, RGB(28, 31, 28)); + // First blend with time + CpuFastCopy(gPlttBufferUnfaded + paletteIndex, gPlttBufferFaded + paletteIndex, 32); + UpdateSpritePaletteWithTime(spritePaletteIndex); + BlendPalettesFine(1 << (spritePaletteIndex + 16), gPlttBufferFaded + paletteIndex, gPlttBufferFaded + paletteIndex, 12, RGB(28, 31, 28)); } break; } @@ -876,8 +883,8 @@ static bool8 IsFirstFrameOfWeatherFadeIn(void) void LoadCustomWeatherSpritePalette(const u16 *palette) { LoadPalette(palette, 0x100 + gWeatherPtr->weatherPicSpritePalIndex * 16, 32); - UpdateSpritePaletteWithWeather(gWeatherPtr->weatherPicSpritePalIndex); UpdateSpritePaletteWithTime(gWeatherPtr->weatherPicSpritePalIndex); + UpdateSpritePaletteWithWeather(gWeatherPtr->weatherPicSpritePalIndex); } static void LoadDroughtWeatherPalette(u8 *gammaIndexPtr, u8 *a1)