Fixed gamma shift not blending the right palettes.
Refactored/improved some lighting code.
This commit is contained in:
parent
891b432669
commit
4654913cb6
@ -547,15 +547,11 @@ static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex)
|
||||
else
|
||||
{
|
||||
if (MapHasNaturalLight(gMapHeader.mapType)) { // Time-blend
|
||||
// Create the palette mask
|
||||
u32 palettes = PALETTES_ALL;
|
||||
numPalettes += startPalIndex;
|
||||
palettes = (palettes >> startPalIndex) << startPalIndex;
|
||||
palettes = (palettes << (32-numPalettes)) >> (32-numPalettes);
|
||||
UpdateAltBgPalettes(palettes & PALETTES_BG);
|
||||
UpdatePalettesWithTime(palettes);
|
||||
u32 palettes = ((1 << numPalettes) - 1) << startPalIndex;
|
||||
UpdateAltBgPalettes(palettes & PALETTES_BG);
|
||||
UpdatePalettesWithTime(palettes);
|
||||
} else { // copy
|
||||
CpuFastCopy(gPlttBufferUnfaded + startPalIndex * 16, gPlttBufferFaded + startPalIndex * 16, numPalettes * 16 * sizeof(u16));
|
||||
CpuFastCopy(gPlttBufferUnfaded + startPalIndex * 16, gPlttBufferFaded + startPalIndex * 16, numPalettes * 16 * sizeof(u16));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -819,7 +819,7 @@ void LoadMapFromCameraTransition(u8 mapGroup, u8 mapNum)
|
||||
CopySecondaryTilesetToVramUsingHeap(gMapHeader.mapLayout);
|
||||
LoadSecondaryTilesetPalette(gMapHeader.mapLayout, TRUE); // skip copying to Faded, gamma shift will take care of it
|
||||
|
||||
ApplyWeatherGammaShiftToPals(6, 6); // palettes [6,12]
|
||||
ApplyWeatherGammaShiftToPals(NUM_PALS_IN_PRIMARY, NUM_PALS_TOTAL - NUM_PALS_IN_PRIMARY); // palettes [6,12]
|
||||
|
||||
InitSecondaryTilesetAnimation();
|
||||
UpdateLocationHistoryForRoamer();
|
||||
@ -1468,46 +1468,47 @@ const struct BlendSettings gTimeOfDayBlend[] =
|
||||
};
|
||||
|
||||
u8 UpdateTimeOfDay(void) {
|
||||
s32 hours, minutes;
|
||||
RtcCalcLocalTime();
|
||||
hours = gLocalTime.hours;
|
||||
minutes = gLocalTime.minutes;
|
||||
if (hours < 4) { // night
|
||||
currentTimeBlend.weight = 256;
|
||||
currentTimeBlend.altWeight = 0;
|
||||
return gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_NIGHT;
|
||||
} else if (hours < 7) { // night->twilight
|
||||
currentTimeBlend.time0 = TIME_OF_DAY_NIGHT;
|
||||
currentTimeBlend.time1 = TIME_OF_DAY_TWILIGHT;
|
||||
currentTimeBlend.weight = 256 - 256 * ((hours - 4) * 60 + minutes) / ((7-4)*60);
|
||||
currentTimeBlend.altWeight = (256 - currentTimeBlend.weight) / 2;
|
||||
return gTimeOfDay = TIME_OF_DAY_DAY;
|
||||
} else if (hours < 10) { // twilight->day
|
||||
currentTimeBlend.time0 = TIME_OF_DAY_TWILIGHT;
|
||||
currentTimeBlend.time1 = TIME_OF_DAY_DAY;
|
||||
currentTimeBlend.weight = 256 - 256 * ((hours - 7) * 60 + minutes) / ((10-7)*60);
|
||||
currentTimeBlend.altWeight = (256 - currentTimeBlend.weight) / 2 + 128;
|
||||
return gTimeOfDay = TIME_OF_DAY_DAY;
|
||||
} else if (hours < 18) { // day
|
||||
currentTimeBlend.weight = currentTimeBlend.altWeight = 256;
|
||||
return gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_DAY;
|
||||
} else if (hours < 20) { // day->twilight
|
||||
currentTimeBlend.time0 = TIME_OF_DAY_DAY;
|
||||
currentTimeBlend.time1 = TIME_OF_DAY_TWILIGHT;
|
||||
currentTimeBlend.weight = 256 - 256 * ((hours - 18) * 60 + minutes) / ((20-18)*60);
|
||||
currentTimeBlend.altWeight = currentTimeBlend.weight / 2 + 128;
|
||||
return gTimeOfDay = TIME_OF_DAY_TWILIGHT;
|
||||
} else if (hours < 22) { // twilight->night
|
||||
currentTimeBlend.time0 = TIME_OF_DAY_TWILIGHT;
|
||||
currentTimeBlend.time1 = TIME_OF_DAY_NIGHT;
|
||||
currentTimeBlend.weight = 256 - 256 * ((hours - 20) * 60 + minutes) / ((22-20)*60);
|
||||
currentTimeBlend.altWeight = currentTimeBlend.weight / 2;
|
||||
return gTimeOfDay = TIME_OF_DAY_NIGHT;
|
||||
} else { // 22-24, night
|
||||
currentTimeBlend.weight = 256;
|
||||
currentTimeBlend.altWeight = 0;
|
||||
return gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_NIGHT;
|
||||
}
|
||||
s32 hours, minutes;
|
||||
RtcCalcLocalTime();
|
||||
hours = gLocalTime.hours;
|
||||
minutes = gLocalTime.minutes;
|
||||
if (hours < 4) { // night
|
||||
currentTimeBlend.weight = 256;
|
||||
currentTimeBlend.altWeight = 0;
|
||||
gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_NIGHT;
|
||||
} else if (hours < 7) { // night->twilight
|
||||
currentTimeBlend.time0 = TIME_OF_DAY_NIGHT;
|
||||
currentTimeBlend.time1 = TIME_OF_DAY_TWILIGHT;
|
||||
currentTimeBlend.weight = 256 - 256 * ((hours - 4) * 60 + minutes) / ((7-4)*60);
|
||||
currentTimeBlend.altWeight = (256 - currentTimeBlend.weight) / 2;
|
||||
gTimeOfDay = TIME_OF_DAY_DAY;
|
||||
} else if (hours < 10) { // twilight->day
|
||||
currentTimeBlend.time0 = TIME_OF_DAY_TWILIGHT;
|
||||
currentTimeBlend.time1 = TIME_OF_DAY_DAY;
|
||||
currentTimeBlend.weight = 256 - 256 * ((hours - 7) * 60 + minutes) / ((10-7)*60);
|
||||
currentTimeBlend.altWeight = (256 - currentTimeBlend.weight) / 2 + 128;
|
||||
gTimeOfDay = TIME_OF_DAY_DAY;
|
||||
} else if (hours < 18) { // day
|
||||
currentTimeBlend.weight = currentTimeBlend.altWeight = 256;
|
||||
gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_DAY;
|
||||
} else if (hours < 20) { // day->twilight
|
||||
currentTimeBlend.time0 = TIME_OF_DAY_DAY;
|
||||
currentTimeBlend.time1 = TIME_OF_DAY_TWILIGHT;
|
||||
currentTimeBlend.weight = 256 - 256 * ((hours - 18) * 60 + minutes) / ((20-18)*60);
|
||||
currentTimeBlend.altWeight = currentTimeBlend.weight / 2 + 128;
|
||||
gTimeOfDay = TIME_OF_DAY_TWILIGHT;
|
||||
} else if (hours < 22) { // twilight->night
|
||||
currentTimeBlend.time0 = TIME_OF_DAY_TWILIGHT;
|
||||
currentTimeBlend.time1 = TIME_OF_DAY_NIGHT;
|
||||
currentTimeBlend.weight = 256 - 256 * ((hours - 20) * 60 + minutes) / ((22-20)*60);
|
||||
currentTimeBlend.altWeight = currentTimeBlend.weight / 2;
|
||||
gTimeOfDay = TIME_OF_DAY_NIGHT;
|
||||
} else { // 22-24, night
|
||||
currentTimeBlend.weight = 256;
|
||||
currentTimeBlend.altWeight = 0;
|
||||
gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_NIGHT;
|
||||
}
|
||||
return gTimeOfDay;
|
||||
}
|
||||
|
||||
bool8 MapHasNaturalLight(u8 mapType) { // Whether a map type is naturally lit/outside
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user