fix: Uninitialized value used in LightenSpritePaletteInFog
This commit is contained in:
parent
e899218dfb
commit
0745eaf2e0
@ -14,6 +14,8 @@
|
||||
#define PALETTE_FADE_STATUS_LOADING 0xFF
|
||||
|
||||
#define PALETTES_BG 0x0000FFFF
|
||||
// like PALETTES_BG but excludes UI pals [13, 15]
|
||||
#define PALETTES_MAP 0x00001FFF
|
||||
#define PALETTES_OBJECTS 0xFFFF0000
|
||||
#define PALETTES_ALL (PALETTES_BG | PALETTES_OBJECTS)
|
||||
|
||||
@ -24,6 +26,11 @@
|
||||
#define OBJ_PLTT_ID(n) (OBJ_PLTT_OFFSET + PLTT_ID(n))
|
||||
#define OBJ_PLTT_ID2(n) (PLTT_ID((n) + 16))
|
||||
|
||||
// Used to determine whether a sprite palette tag
|
||||
// should be excluded from time (and weather) blending
|
||||
#define BLEND_IMMUNE_FLAG (1 << 15)
|
||||
#define IS_BLEND_IMMUNE_TAG(tag) ((tag) & BLEND_IMMUNE_FLAG)
|
||||
|
||||
enum
|
||||
{
|
||||
FAST_FADE_IN_FROM_WHITE,
|
||||
|
||||
@ -495,7 +495,7 @@ static void ApplyColorMap(u8 startPalIndex, u8 numPalettes, s8 colorMapIndex)
|
||||
{
|
||||
// don't blend special palettes immune to blending
|
||||
if (sPaletteColorMapTypes[curPalIndex] == COLOR_MAP_NONE ||
|
||||
(curPalIndex >= 16 && GetSpritePaletteTagByPaletteNum(curPalIndex - 16) >> 15))
|
||||
(curPalIndex >= 16 && IS_BLEND_IMMUNE_TAG(GetSpritePaletteTagByPaletteNum(curPalIndex - 16))))
|
||||
{
|
||||
// No palette change.
|
||||
palOffset += 16;
|
||||
@ -684,7 +684,7 @@ static void ApplyFogBlend(u8 blendCoeff, u16 blendColor)
|
||||
CpuFastCopy(gPlttBufferUnfaded, gPlttBufferFaded, PLTT_BUFFER_SIZE * 2);
|
||||
UpdatePalettesWithTime(PALETTES_ALL);
|
||||
// Then blend tile palettes [0, 12] faded->faded with fadeIn color
|
||||
BlendPalettesFine(0x1FFF, gPlttBufferFaded, gPlttBufferFaded, blendCoeff, blendColor);
|
||||
BlendPalettesFine(PALETTES_MAP, gPlttBufferFaded, gPlttBufferFaded, blendCoeff, blendColor);
|
||||
|
||||
// Do fog blending on marked sprite palettes
|
||||
for (curPalIndex = 16; curPalIndex < 32; curPalIndex++) {
|
||||
@ -708,7 +708,7 @@ static bool8 LightenSpritePaletteInFog(u8 paletteIndex)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
if (paletteIndex >= 16 && (GetSpritePaletteTagByPaletteNum(i - 16) >> 15)) // don't blend specialpalette tags
|
||||
if (paletteIndex >= 16 && IS_BLEND_IMMUNE_TAG(GetSpritePaletteTagByPaletteNum(paletteIndex - 16)))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < gWeatherPtr->lightenedFogSpritePalsCount; i++)
|
||||
|
||||
@ -1536,7 +1536,7 @@ void UpdateAltBgPalettes(u16 palettes) {
|
||||
return;
|
||||
palettes &= ~((1 << NUM_PALS_IN_PRIMARY) - 1) | primary->swapPalettes;
|
||||
palettes &= ((1 << NUM_PALS_IN_PRIMARY) - 1) | (secondary->swapPalettes << NUM_PALS_IN_PRIMARY);
|
||||
palettes &= 0x1FFE; // don't blend palette 0, [13,15]
|
||||
palettes &= PALETTES_MAP ^ (1 << 0); // don't blend palette 0, [13,15]
|
||||
palettes >>= 1; // start at palette 1
|
||||
if (!palettes)
|
||||
return;
|
||||
@ -1558,10 +1558,10 @@ void UpdatePalettesWithTime(u32 palettes) {
|
||||
u32 mask = 1 << 16;
|
||||
if (palettes >= 0x10000)
|
||||
for (i = 0; i < 16; i++, mask <<= 1)
|
||||
if (GetSpritePaletteTagByPaletteNum(i) >> 15) // Don't blend special sprite palette tags
|
||||
if (IS_BLEND_IMMUNE_TAG(GetSpritePaletteTagByPaletteNum(i)))
|
||||
palettes &= ~(mask);
|
||||
|
||||
palettes &= 0xFFFF1FFF; // Don't blend UI BG palettes [13,15]
|
||||
palettes &= PALETTES_MAP | PALETTES_OBJECTS; // Don't blend UI pals
|
||||
if (!palettes)
|
||||
return;
|
||||
TimeMixPalettes(palettes,
|
||||
@ -1575,13 +1575,11 @@ void UpdatePalettesWithTime(u32 palettes) {
|
||||
|
||||
u8 UpdateSpritePaletteWithTime(u8 paletteNum) {
|
||||
if (MapHasNaturalLight(gMapHeader.mapType)) {
|
||||
u16 offset;
|
||||
if (GetSpritePaletteTagByPaletteNum(paletteNum) >> 15)
|
||||
if (IS_BLEND_IMMUNE_TAG(GetSpritePaletteTagByPaletteNum(paletteNum)))
|
||||
return paletteNum;
|
||||
offset = (paletteNum + 16) << 4;
|
||||
TimeMixPalettes(1,
|
||||
gPlttBufferUnfaded + offset,
|
||||
gPlttBufferFaded + offset,
|
||||
&gPlttBufferUnfaded[OBJ_PLTT_ID(paletteNum)],
|
||||
&gPlttBufferFaded[OBJ_PLTT_ID(paletteNum)],
|
||||
(struct BlendSettings *)&gTimeOfDayBlend[currentTimeBlend.time0],
|
||||
(struct BlendSettings *)&gTimeOfDayBlend[currentTimeBlend.time1],
|
||||
currentTimeBlend.weight);
|
||||
|
||||
@ -515,11 +515,11 @@ static u8 UpdateTimeOfDayPaletteFade(void)
|
||||
u32 i;
|
||||
u32 j = 1;
|
||||
for (i = 0; i < 16; i++, j <<= 1) { // Mask out palettes that should not be light blended
|
||||
if ((selectedPalettes & j) && !(GetSpritePaletteTagByPaletteNum(i) >> 15))
|
||||
timePalettes |= j;
|
||||
if ((selectedPalettes & j) && !IS_BLEND_IMMUNE_TAG(GetSpritePaletteTagByPaletteNum(i)))
|
||||
timePalettes |= j;
|
||||
}
|
||||
} else { // tile palettes, don't blend [13, 15]
|
||||
timePalettes = selectedPalettes & 0x1FFF;
|
||||
timePalettes = selectedPalettes & PALETTES_MAP;
|
||||
}
|
||||
TimeMixPalettes(timePalettes, src, dst, gPaletteFade.bld0, gPaletteFade.bld1, gPaletteFade.weight);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user