-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Get Rid of Battery Run Dry Error Message
voloved edited this page Apr 1, 2023
·
3 revisions
By devolov
Goal: Make battery run dry message not appear when starting the game.
In main_menu.c
:
static void Task_MainMenuCheckBattery(u8 taskId)
{
if (!gPaletteFade.active)
{
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | WININ_WIN0_OBJ);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_DARKEN | BLDCNT_TGT1_BG0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 7);
+ gTasks[taskId].func = Task_DisplayMainMenu;
- if (!(RtcGetErrorStatus() & RTC_ERR_FLAG_MASK))
- {
- gTasks[taskId].func = Task_DisplayMainMenu;
- }
- else
- {
- gTasks[taskId].func = Task_WaitForBatteryDryErrorWindow;
- }
}
}
Goal: Make it so we grow the berries and update daily events by a set amountevery time we load the game if there is an RTC failure.
In clock.c
add the folowing function at the bottom.:
void FastForwardTime(s16 daysToUpdateDay, s16 hoursToGrowBerries){
// Runs the UpdatePerDay function as if daysToUpdateDay days have passed and grows the berries by hoursToGrowBerries
s16 daysBerry = hoursToGrowBerries / 24;
s8 hoursBerry = hoursToGrowBerries % 24;
struct Time localTimeOffset;
localTimeOffset.days = *GetVarPointer(VAR_DAYS) + daysToUpdateDay;
UpdatePerDay(&localTimeOffset);
localTimeOffset = gSaveBlock2Ptr->lastBerryTreeUpdate;
localTimeOffset.days += daysBerry;
localTimeOffset.hours += hoursBerry;
UpdatePerMinute(&localTimeOffset);
}
In clock.h
:
void DoTimeBasedEvents(void);
+void FastForwardTime(s16, s16);
Finally, back in main_menu.c
:
static void Task_MainMenuCheckBattery(u8 taskId)
{
if (!gPaletteFade.active)
{
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | WININ_WIN0_OBJ);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_DARKEN | BLDCNT_TGT1_BG0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 7);
+ if (RtcGetErrorStatus() & RTC_ERR_FLAG_MASK)
+ FastForwardTime(2, 4);
gTasks[taskId].func = Task_DisplayMainMenu;
}
}
In the example above, we'll grow the berries by 4 hours and update daily events as if 2 days have passed every time we load the game.