Optimized UpdateTimeOfDay.
This commit is contained in:
parent
6e621d80a1
commit
ea6c1a9e40
1 changed files with 10 additions and 9 deletions
|
@ -1474,44 +1474,45 @@ const struct BlendSettings gTimeOfDayBlend[] =
|
|||
};
|
||||
|
||||
u8 UpdateTimeOfDay(void) {
|
||||
s8 hours, minutes;
|
||||
s32 hours, minutes;
|
||||
RtcCalcLocalTime();
|
||||
hours = gLocalTime.hours;
|
||||
minutes = gLocalTime.minutes;
|
||||
if (hours >= 22 || hours < 4) { // night
|
||||
if (hours < 4) { // night
|
||||
currentTimeBlend.weight = 256;
|
||||
currentTimeBlend.altWeight = 0;
|
||||
return gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_NIGHT;
|
||||
} else if (hours >= 4 && hours < 7) { // night->twilight
|
||||
} 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 >= 7 && hours < 10) { // twilight->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 >= 10 && hours < 18) { // day
|
||||
} else if (hours < 18) { // day
|
||||
currentTimeBlend.weight = currentTimeBlend.altWeight = 256;
|
||||
return gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_DAY;
|
||||
} else if (hours >= 18 && hours < 20) { // day->twilight
|
||||
} 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 >= 20 && hours < 22) { // twilight->night
|
||||
} 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 { // This should never occur
|
||||
} else { // 22-24, night
|
||||
currentTimeBlend.weight = 256;
|
||||
return gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_DAY;
|
||||
currentTimeBlend.altWeight = 0;
|
||||
return gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_NIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue