feat: Allowed custom COLOR_MAP_* in field_effect_scripts. Credit: SDH

This commit is contained in:
Ariel A 2024-09-01 16:17:51 -04:00
parent 29b2a7512f
commit 8795c15ab9
4 changed files with 35 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}
}

View File

@ -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)