diff --git a/asm/macros/field_effect_script.inc b/asm/macros/field_effect_script.inc index 38f7e31750..3e00bc734d 100644 --- a/asm/macros/field_effect_script.inc +++ b/asm/macros/field_effect_script.inc @@ -5,9 +5,11 @@ .4byte \address .endm - .macro field_eff_loadfadedpal address:req + @ 1 = COLOR_MAP_DARK_CONTRAST + .macro field_eff_loadfadedpal address:req, color_map_type=1 .byte 1 .4byte \address + .byte \color_map_type .endm .macro field_eff_loadpal address:req @@ -24,10 +26,12 @@ .byte 4 .endm - .macro field_eff_loadgfx_callnative tiles_address:req, palette_address:req, function_address:req + @ 1 = COLOR_MAP_DARK_CONTRAST + .macro field_eff_loadgfx_callnative tiles_address:req, palette_address:req, function_address:req, color_map_type=1 .byte 5 .4byte \tiles_address .4byte \palette_address + .byte \color_map_type .4byte \function_address .endm @@ -37,8 +41,10 @@ .4byte \function_address .endm - .macro field_eff_loadfadedpal_callnative palette_address:req, function_address:req + @ 1 = COLOR_MAP_DARK_CONTRAST + .macro field_eff_loadfadedpal_callnative palette_address:req, function_address:req, color_map_type=1 .byte 7 .4byte \palette_address + .byte \color_map_type .4byte \function_address .endm diff --git a/include/field_weather.h b/include/field_weather.h index fbd90f2405..d741bdd2b0 100644 --- a/include/field_weather.h +++ b/include/field_weather.h @@ -170,7 +170,9 @@ void PlayRainStoppingSoundEffect(void); u8 IsWeatherChangeComplete(void); void SetWeatherScreenFadeOut(void); void SetWeatherPalStateIdle(void); +const u8* SetPaletteColorMapType(u8 paletteIndex, u8 colorMapType); void PreservePaletteInWeather(u8 preservedPalIndex); +void ResetPaletteColorMapType(u8 paletteIndex); void ResetPreservedPalettesInWeather(void); // field_weather_effect.c diff --git a/src/field_effect.c b/src/field_effect.c index 6ae2d509a4..5df664908d 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -781,9 +781,11 @@ void FieldEffectScript_LoadTiles(u8 **script) void FieldEffectScript_LoadFadedPalette(u8 **script) { struct SpritePalette *palette = (struct SpritePalette *)FieldEffectScript_ReadWord(script); - LoadSpritePalette(palette); - UpdateSpritePaletteWithWeather(IndexOfSpritePaletteTag(palette->tag), TRUE); + u32 paletteSlot = LoadSpritePalette(palette); (*script) += 4; + SetPaletteColorMapType(paletteSlot + 16, T1_READ_8(*script)); + UpdateSpritePaletteWithWeather(paletteSlot, TRUE); + (*script)++; } void FieldEffectScript_LoadPalette(u8 **script) @@ -839,6 +841,7 @@ void FieldEffectFreePaletteIfUnused(u8 paletteNum) for (i = 0; i < MAX_SPRITES; i++) if (gSprites[i].inUse && gSprites[i].oam.paletteNum == paletteNum) return; + ResetPaletteColorMapType(paletteNum + 16); FreeSpritePaletteByTag(tag); } } diff --git a/src/field_weather.c b/src/field_weather.c index 1a3a150c4c..e2fb1e77e6 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -1136,11 +1136,27 @@ void SetWeatherPalStateIdle(void) gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } +const u8* SetPaletteColorMapType(u8 paletteIndex, u8 colorMapType) { + if (sPaletteColorMapTypes[paletteIndex] == colorMapType) + return sPaletteColorMapTypes; + // setup field effect color map + if (sPaletteColorMapTypes != sFieldEffectPaletteColorMapTypes) { + CpuFastCopy(sBasePaletteColorMapTypes, sFieldEffectPaletteColorMapTypes, 32); + sPaletteColorMapTypes = sFieldEffectPaletteColorMapTypes; + } + sFieldEffectPaletteColorMapTypes[paletteIndex] = colorMapType; + return sPaletteColorMapTypes; +} + void PreservePaletteInWeather(u8 preservedPalIndex) { - CpuCopy16(sBasePaletteColorMapTypes, sFieldEffectPaletteColorMapTypes, 32); - sFieldEffectPaletteColorMapTypes[preservedPalIndex] = COLOR_MAP_NONE; - sPaletteColorMapTypes = sFieldEffectPaletteColorMapTypes; + SetPaletteColorMapType(preservedPalIndex, COLOR_MAP_NONE); +} + +void ResetPaletteColorMapType(u8 paletteIndex) { + if (sPaletteColorMapTypes == sBasePaletteColorMapTypes) + return; + sFieldEffectPaletteColorMapTypes[paletteIndex] = sBasePaletteColorMapTypes[paletteIndex]; } void ResetPreservedPalettesInWeather(void)