This commit is contained in:
SDarkrai
2023-06-28 00:27:09 +00:00
committed by GitHub
parent a17b2a4b5b
commit 76e9ca8208
5 changed files with 12 additions and 45 deletions

View File

@@ -4,6 +4,5 @@
// TODO: time of day and seconds in a day defines
void DoTimeBasedEvents(void);
void FastForwardTime(s16, s16);
#endif // GUARD_CLOCK_H

View File

@@ -416,9 +416,6 @@ SoftReset:
ldr r1, =0x3007f00
mov sp, r1
svc #1
ldr r0, =gSoftResetFlag
movs r1, #1
strb r1, [r0]
svc #0
.pool
thumb_func_end SoftReset

View File

@@ -84,16 +84,3 @@ void StartWallClock(void)
SetMainCallback2(CB2_StartWallClock);
gMain.savedCallback = ReturnFromStartWallClock;
}
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);
}

View File

@@ -24,12 +24,6 @@
#include "main.h"
#include "trainer_hill.h"
#include "constants/rgb.h"
#include "main_menu.h"
#include "save.h"
#include "new_game.h"
EWRAM_DATA u8 gSoftResetFlag;
static void CB2_PostSoftResetInit(void);
static void VBlankIntr(void);
static void HBlankIntr(void);
@@ -95,7 +89,7 @@ void AgbMain()
// Modern compilers are liberal with the stack on entry to this function,
// so RegisterRamReset may crash if it resets IWRAM.
#if !MODERN
//RegisterRamReset(RESET_ALL);
RegisterRamReset(RESET_ALL);
#endif //MODERN
*(vu16 *)BG_PLTT = RGB_WHITE; // Set the backdrop to white on startup
InitGpuRegManager();
@@ -182,11 +176,7 @@ static void InitMainCallbacks(void)
gTrainerHillVBlankCounter = NULL;
gMain.vblankCounter2 = 0;
gMain.callback1 = NULL;
if(gSoftResetFlag){
SetMainCallback2(CB2_PostSoftResetInit);
}else{
SetMainCallback2(CB2_InitCopyrightScreenAfterBootup);
}
SetMainCallback2(CB2_InitCopyrightScreenAfterBootup);
gSaveBlock2Ptr = &gSaveblock2.block;
gPokemonStoragePtr = &gPokemonStorage.block;
}
@@ -453,14 +443,3 @@ bool8 IsAccurateGBA(void) { // tests to see whether running on either an accurat
func = (func & ~3) | 0x2; // misalign PC to test PC-relative loading
return ((u32 (*)(void)) func)() == code[3] >> 16;
}
static void CB2_PostSoftResetInit(void){
SetSaveBlocksPointers(GetSaveBlocksPointersBaseOffset());
ResetMenuAndMonGlobals();
Save_ResetSaveCounters();
LoadGameSave(SAVE_NORMAL);
if (gSaveFileStatus == SAVE_STATUS_EMPTY || gSaveFileStatus == SAVE_STATUS_CORRUPT)
Sav2_ClearSetDefault();
SetPokemonCryStereo(gSaveBlock2Ptr->optionsSound);
SetMainCallback2(CB2_InitMainMenu);
}

View File

@@ -40,8 +40,6 @@
#include "tx_randomizer_and_challenges.h"
#include "constants/flags.h"
extern u8 gSoftResetFlag;
/*
* Main menu state machine
* -----------------------
@@ -750,9 +748,16 @@ static void Task_MainMenuCheckBattery(u8 taskId)
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_DARKEN | BLDCNT_TGT1_BG0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 7);
if (gSoftResetFlag || !(RtcGetErrorStatus() & RTC_ERR_FLAG_MASK))
FastForwardTime(2, 4);
gTasks[taskId].func = Task_DisplayMainMenu;
if (!(RtcGetErrorStatus() & RTC_ERR_FLAG_MASK))
{
gTasks[taskId].func = Task_DisplayMainMenu;
}
else
{
CreateMainMenuErrorWindow(gText_BatteryRunDry);
gTasks[taskId].func = Task_WaitForBatteryDryErrorWindow;
}
}
}