gen5 seasons

This commit is contained in:
cawtds
2024-06-22 14:34:07 +02:00
parent bd28bd914a
commit bf3ff137d5
3 changed files with 98 additions and 20 deletions

View File

@@ -43,8 +43,20 @@
#define NIGHT_HOUR_BEGIN 20
#define NIGHT_HOUR_END 4
//Gen 5 currently not included as the seasons change the times of day
#elif OW_TIMES_OF_DAY <= GEN_6
//Gen 5 seasons change the times of day
#elif OW_TIMES_OF_DAY == GEN_5
#define MORNING_HOUR_BEGIN GetGen5MorningBegin()
#define MORNING_HOUR_END GetGen5DayBegin()
#define DAY_HOUR_BEGIN GetGen5DayBegin()
#define DAY_HOUR_END GetGen5EveningBegin()
#define EVENING_HOUR_BEGIN GetGen5EveningBegin()
#define EVENING_HOUR_END GetGen5NightBegin()
#define NIGHT_HOUR_BEGIN GetGen5NightBegin()
#define NIGHT_HOUR_END GetGen5MorningBegin()
#elif OW_TIMES_OF_DAY == GEN_6
#define MORNING_HOUR_BEGIN 4
#define MORNING_HOUR_END 11
@@ -92,8 +104,6 @@
#define SEASON_SUMMER 1
#define SEASON_AUTUMN 2
#define SEASON_WINTER 3
#define NUM_SEASONS 4
#define DAYS_PER_SEASON 5
extern struct Time gLocalTime;
@@ -130,4 +140,68 @@ u8 GetCurrentMinute(void);
u8 GetSeason(void);
u8 GetSeasonDay(void);
static inline s32 GetGen5MorningBegin()
{
switch (GetSeason())
{
case SEASON_SPRING:
default:
return 5;
case SEASON_SUMMER:
return 4;
case SEASON_AUTUMN:
return 6;
case SEASON_WINTER:
return 7;
}
}
static inline s32 GetGen5DayBegin()
{
switch (GetSeason())
{
case SEASON_SPRING:
default:
return 10;
case SEASON_SUMMER:
return 9;
case SEASON_AUTUMN:
return 10;
case SEASON_WINTER:
return 11;
}
}
static inline s32 GetGen5EveningBegin()
{
switch (GetSeason())
{
case SEASON_SPRING:
default:
return 17;
case SEASON_SUMMER:
return 19;
case SEASON_AUTUMN:
return 18;
case SEASON_WINTER:
return 17;
}
}
static inline s32 GetGen5NightBegin()
{
switch (GetSeason())
{
case SEASON_SPRING:
default:
return 20;
case SEASON_SUMMER:
return 21;
case SEASON_AUTUMN:
return 20;
case SEASON_WINTER:
return 19;
}
}
#endif // GUARD_RTC_UTIL_H

View File

@@ -321,30 +321,34 @@ u8 GetCurrentMinute(void)
u8 GetSeason(void)
{
u8 seasonIndex;
RtcCalcLocalTime();
seasonIndex = (gLocalTime.days / DAYS_PER_SEASON) % NUM_SEASONS;
switch (seasonIndex)
RtcGetInfo(&sRtc);
switch(ConvertBcdToBinary(sRtc.month))
{
case 0:
return SEASON_SPRING;
case 1:
return SEASON_SUMMER;
case 2:
return SEASON_AUTUMN;
case 3:
return SEASON_WINTER;
case MONTH_JAN:
case MONTH_MAY:
case MONTH_SEP:
default:
return SEASON_SPRING;
case MONTH_FEB:
case MONTH_JUN:
case MONTH_OCT:
return SEASON_SUMMER;
case MONTH_MAR:
case MONTH_JUL:
case MONTH_NOV:
return SEASON_AUTUMN;
case MONTH_APR:
case MONTH_AUG:
case MONTH_DEC:
return SEASON_WINTER;
}
}
u8 GetSeasonDay(void)
{
RtcCalcLocalTime();
RtcGetInfo(&sRtc);
return (gLocalTime.days % DAYS_PER_SEASON) + 1;
return ConvertBcdToBinary(sRtc.day);
}
void RtcCalcLocalTime(void)

View File

@@ -333,7 +333,7 @@ static void DrawTimeWindow(void)
StringCopy(gStringVar1, gText_SeasonWinter);
break;
}
ConvertIntToDecimalStringN(gStringVar2, GetSeasonDay(), STR_CONV_MODE_RIGHT_ALIGN, 1);
ConvertIntToDecimalStringN(gStringVar2, GetSeasonDay(), STR_CONV_MODE_RIGHT_ALIGN, 2);
StringExpandPlaceholders(gStringVar4, gText_MenuDay);
AddTextPrinterParameterized(sTimeWindowId, FONT_NORMAL, gStringVar4, 4, 18, 0xFF, NULL);