Reverted 42d5fe07f and fixed rain/thunder gamma.

This commit is contained in:
Ariel Antonitis 2021-04-25 23:50:29 -04:00
parent 74a90889ac
commit 7d8e63a44b
2 changed files with 17 additions and 15 deletions

View file

@ -468,19 +468,23 @@ static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex)
{ {
gammaIndex--; gammaIndex--;
palOffset = startPalIndex * 16; palOffset = startPalIndex * 16;
CpuFastCopy(gPlttBufferUnfaded + palOffset, gPlttBufferFaded + palOffset, 32 * numPalettes);
numPalettes += startPalIndex; numPalettes += startPalIndex;
// Thunder gamma-shift looks bad on night-blended palettes, so ignore time blending in some situations
if (!(gammaIndex > 3 && gWeatherPtr->currWeather == WEATHER_RAIN_THUNDERSTORM)) {
// Create the palette mask
u32 palettes = PALETTES_ALL;
palettes = (palettes >> startPalIndex) << startPalIndex;
palettes = (palettes << (32-numPalettes)) >> (32-numPalettes);
UpdatePalettesWithTime(palettes);
}
curPalIndex = startPalIndex; curPalIndex = startPalIndex;
// Loop through the speficied palette range and apply necessary gamma shifts to the colors. // Loop through the speficied palette range and apply necessary gamma shifts to the colors.
// TODO: Optimize this to work with time blending
while (curPalIndex < numPalettes) while (curPalIndex < numPalettes)
{ {
CpuFastCopy(gPlttBufferUnfaded + palOffset, gPlttBufferFaded + palOffset, 16 * sizeof(u16));
UpdatePalettesWithTime(1 << (palOffset >> 4));
if (sPaletteGammaTypes[curPalIndex] == GAMMA_NONE) if (sPaletteGammaTypes[curPalIndex] == GAMMA_NONE)
{ {
// No palette change. // No palette change.
// CpuFastCopy(gPlttBufferUnfaded + palOffset, gPlttBufferFaded + palOffset, 16 * sizeof(u16));
palOffset += 16; palOffset += 16;
} }
else else
@ -537,11 +541,11 @@ static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex)
else else
{ {
if (MapHasNaturalLight(gMapHeader.mapType)) { // Time-blend if (MapHasNaturalLight(gMapHeader.mapType)) { // Time-blend
u32 palettes = 0; // Create the palette mask
u32 mask = 1 << startPalIndex; u32 palettes = PALETTES_ALL;
u8 i; numPalettes += startPalIndex;
for (i = 0; i < numPalettes; i++, mask <<= 1) palettes = (palettes >> startPalIndex) << startPalIndex;
palettes |= mask; palettes = (palettes << (32-numPalettes)) >> (32-numPalettes);
UpdatePalettesWithTime(palettes); UpdatePalettesWithTime(palettes);
} else { // copy } else { // copy
CpuFastCopy(gPlttBufferUnfaded + startPalIndex * 16, gPlttBufferFaded + startPalIndex * 16, numPalettes * 16 * sizeof(u16)); CpuFastCopy(gPlttBufferUnfaded + startPalIndex * 16, gPlttBufferFaded + startPalIndex * 16, numPalettes * 16 * sizeof(u16));

View file

@ -483,7 +483,7 @@ void Rain_InitVars(void)
gWeatherPtr->rainSpriteVisibleDelay = 8; gWeatherPtr->rainSpriteVisibleDelay = 8;
gWeatherPtr->isDownpour = FALSE; gWeatherPtr->isDownpour = FALSE;
gWeatherPtr->targetRainSpriteCount = 10; gWeatherPtr->targetRainSpriteCount = 10;
gWeatherPtr->gammaTargetIndex = gTimeOfDay == TIME_OF_DAY_DAY ? 3 : 0; gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20; gWeatherPtr->gammaStepDelay = 20;
SetRainStrengthFromSoundEffect(SE_RAIN); SetRainStrengthFromSoundEffect(SE_RAIN);
Weather_SetBlendCoeffs(8, 12); // preserve shadow darkness Weather_SetBlendCoeffs(8, 12); // preserve shadow darkness
@ -1053,7 +1053,7 @@ void Thunderstorm_InitVars(void)
gWeatherPtr->rainSpriteVisibleDelay = 4; gWeatherPtr->rainSpriteVisibleDelay = 4;
gWeatherPtr->isDownpour = FALSE; gWeatherPtr->isDownpour = FALSE;
gWeatherPtr->targetRainSpriteCount = 16; gWeatherPtr->targetRainSpriteCount = 16;
gWeatherPtr->gammaTargetIndex = gTimeOfDay == TIME_OF_DAY_DAY ? 3 : 0; gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20; gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->weatherGfxLoaded = FALSE; // duplicate assignment gWeatherPtr->weatherGfxLoaded = FALSE; // duplicate assignment
gWeatherPtr->thunderTriggered = FALSE; gWeatherPtr->thunderTriggered = FALSE;
@ -1154,8 +1154,6 @@ void Thunderstorm_Main(void)
if (--gWeatherPtr->thunderDelay == 0) if (--gWeatherPtr->thunderDelay == 0)
{ {
ApplyWeatherGammaShiftIfIdle(3); ApplyWeatherGammaShiftIfIdle(3);
if (gTimeOfDay != TIME_OF_DAY_DAY)
UpdatePalettesWithTime(0xFFFFFFFF);
gWeatherPtr->thunderAllowEnd = TRUE; gWeatherPtr->thunderAllowEnd = TRUE;
if (--gWeatherPtr->thunderShortRetries != 0) if (--gWeatherPtr->thunderShortRetries != 0)
{ {
@ -1196,7 +1194,7 @@ void Thunderstorm_Main(void)
case TSTORM_STATE_FADE_THUNDER_LONG: case TSTORM_STATE_FADE_THUNDER_LONG:
if (--gWeatherPtr->thunderDelay == 0) if (--gWeatherPtr->thunderDelay == 0)
{ {
gTimeOfDay == TIME_OF_DAY_DAY ? sub_80ABC7C(19, 3, 5) : UpdatePalettesWithTime(0xFFFFFFFF); sub_80ABC7C(19, 3, 5);
gWeatherPtr->initStep++; gWeatherPtr->initStep++;
} }
break; break;