Refactored BlendSettings storage inside gPaletteFade.

This commit is contained in:
Ariel Antonitis 2021-04-24 01:12:04 -04:00
parent a4680ed572
commit dbc4cb8293
3 changed files with 15 additions and 30 deletions

View file

@ -26,15 +26,19 @@ enum
FAST_FADE_OUT_TO_BLACK,
};
struct BlendSettings {
u16 blendColor:15;
u16 isTint:1;
u8 coeff:5;
};
struct PaletteFadeControl
{
u32 multipurpose1; // This field needs to exist or errors will occur
u16 blendColor1:15;
u16 tint1:1;
u32 tint0:1;
u32 coeff0:5;
u32 coeff1:5;
u32 weight:9;
// These three are only used for TOD blending
struct BlendSettings *bld0;
struct BlendSettings *bld1;
u16 weight:9; // [0, 256], so must be 9 bits
u8 delayCounter:6;
u16 y:5; // blend coefficient
u16 targetY:5; // target blend coefficient
@ -52,12 +56,6 @@ struct PaletteFadeControl
u8 deltaY:4; // rate of change of blend coefficient
};
struct BlendSettings {
u16 blendColor:15;
u16 isTint:1;
u8 coeff:5;
};
extern struct PaletteFadeControl gPaletteFade;
extern u32 gPlttBufferTransferPending;
extern u8 gPaletteDecompressionBuffer[];

View file

@ -1506,7 +1506,7 @@ u8 UpdateTimeOfDay(void) {
}
}
static bool8 MapHasNaturalLight(u8 mapType) { // Weather a map type is naturally lit/outside
static bool8 MapHasNaturalLight(u8 mapType) { // Whether a map type is naturally lit/outside
return mapType == MAP_TYPE_TOWN || mapType == MAP_TYPE_CITY || mapType == MAP_TYPE_ROUTE
|| mapType == MAP_TYPE_OCEAN_ROUTE;
}

View file

@ -232,12 +232,9 @@ bool8 BeginTimeOfDayPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 ta
gPaletteFade.active = 1;
gPaletteFade.mode = TIME_OF_DAY_FADE;
gPaletteFade.blendColor = bld0->blendColor;
gPaletteFade.coeff0 = bld0->coeff;
gPaletteFade.tint0 = bld0->isTint;
gPaletteFade.blendColor1 = bld1->blendColor;
gPaletteFade.coeff1 = bld1->coeff;
gPaletteFade.tint1 = bld1->isTint;
gPaletteFade.blendColor = 0;
gPaletteFade.bld0 = bld0;
gPaletteFade.bld1 = bld1;
gPaletteFade.weight = weight;
if (startY < targetY)
@ -474,8 +471,6 @@ static u8 UpdateTimeOfDayPaletteFade(void)
u16 copyPalettes;
u16 * src;
u16 * dst;
struct BlendSettings bld0;
struct BlendSettings bld1;
if (!gPaletteFade.active)
return PALETTE_FADE_STATUS_DONE;
@ -505,14 +500,6 @@ static u8 UpdateTimeOfDayPaletteFade(void)
paletteOffset = 256;
}
// Extract blend settings from palette fade struct TODO: Embed struct within gPaletteFade
bld0.blendColor = gPaletteFade.blendColor;
bld0.coeff = gPaletteFade.coeff0;
bld0.isTint = gPaletteFade.tint0;
bld1.blendColor = gPaletteFade.blendColor1;
bld1.coeff = gPaletteFade.coeff1;
bld1.isTint = gPaletteFade.tint1;
src = gPlttBufferUnfaded + paletteOffset;
dst = gPlttBufferFaded + paletteOffset;
@ -528,7 +515,7 @@ static u8 UpdateTimeOfDayPaletteFade(void)
} else { // tile palettes, don't blend [13, 15]
timePalettes = selectedPalettes & 0x1FFF;
}
TimeMixPalettes(timePalettes, src, dst, &bld0, &bld1, gPaletteFade.weight);
TimeMixPalettes(timePalettes, src, dst, gPaletteFade.bld0, gPaletteFade.bld1, gPaletteFade.weight);
// palettes that were not blended above must be copied through
if ((copyPalettes = ~timePalettes)) {