mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Added warning screen for RTC and inacurrate emus
This commit is contained in:
parent
5ab869b581
commit
eb476f9f0c
@ -328,6 +328,8 @@ extern const u8 gText_SaveFileErased[];
|
|||||||
extern const u8 gText_SaveFileCorrupted[];
|
extern const u8 gText_SaveFileCorrupted[];
|
||||||
extern const u8 gJPText_No1MSubCircuit[];
|
extern const u8 gJPText_No1MSubCircuit[];
|
||||||
extern const u8 gText_BatteryRunDry[];
|
extern const u8 gText_BatteryRunDry[];
|
||||||
|
extern const u8 gText_EmuWarning[];
|
||||||
|
extern const u8 gText_TimeWarning[];
|
||||||
extern const u8 gText_MainMenuNewGame[];
|
extern const u8 gText_MainMenuNewGame[];
|
||||||
extern const u8 gText_MainMenuOption[];
|
extern const u8 gText_MainMenuOption[];
|
||||||
extern const u8 gText_MainMenuContinue[];
|
extern const u8 gText_MainMenuContinue[];
|
||||||
|
@ -179,6 +179,7 @@ static u8 sBirchSpeechMainTaskId;
|
|||||||
static u32 InitMainMenu(bool8);
|
static u32 InitMainMenu(bool8);
|
||||||
static void Task_MainMenuCheckSaveFile(u8);
|
static void Task_MainMenuCheckSaveFile(u8);
|
||||||
static void Task_MainMenuCheckBattery(u8);
|
static void Task_MainMenuCheckBattery(u8);
|
||||||
|
static bool8 IsAccurateGBA(void);
|
||||||
static void Task_WaitForSaveFileErrorWindow(u8);
|
static void Task_WaitForSaveFileErrorWindow(u8);
|
||||||
static void CreateMainMenuErrorWindow(const u8 *);
|
static void CreateMainMenuErrorWindow(const u8 *);
|
||||||
static void ClearMainMenuWindowTilemap(const struct WindowTemplate *);
|
static void ClearMainMenuWindowTilemap(const struct WindowTemplate *);
|
||||||
@ -702,8 +703,19 @@ static void Task_WaitForSaveFileErrorWindow(u8 taskId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool8 IsAccurateGBA(void) { // tests to see whether running on either an accurate emulator in >=2020, or real hardware
|
||||||
|
u32 code[5] = {0xFF1EE12F, 0xE1DF00B0, 0xE12FFF1E, 0xAAAABBBB, 0xCCCCDDDD}; // ARM: _;ldrh r0, [pc];bx lr
|
||||||
|
u32 func = (u32) &code[0];
|
||||||
|
if (func & 3) // not word aligned; safer to just return false here
|
||||||
|
return FALSE;
|
||||||
|
func = (func & ~3) | 0x2; // misalign PC to test PC-relative loading
|
||||||
|
return ((u32 (*)(void)) func)() == code[3] >> 16;
|
||||||
|
}
|
||||||
|
|
||||||
static void Task_MainMenuCheckBattery(u8 taskId)
|
static void Task_MainMenuCheckBattery(u8 taskId)
|
||||||
{
|
{
|
||||||
|
s16 *data = gTasks[taskId].data;
|
||||||
|
|
||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
{
|
{
|
||||||
SetGpuReg(REG_OFFSET_WIN0H, 0);
|
SetGpuReg(REG_OFFSET_WIN0H, 0);
|
||||||
@ -716,8 +728,22 @@ static void Task_MainMenuCheckBattery(u8 taskId)
|
|||||||
|
|
||||||
if (!(RtcGetErrorStatus() & RTC_ERR_FLAG_MASK))
|
if (!(RtcGetErrorStatus() & RTC_ERR_FLAG_MASK))
|
||||||
{
|
{
|
||||||
|
if (tMenuType != HAS_NO_SAVED_GAME)
|
||||||
|
RtcCalcLocalTime();
|
||||||
|
if (!IsAccurateGBA()) {
|
||||||
|
CreateMainMenuErrorWindow(gText_EmuWarning);
|
||||||
|
gTasks[taskId].func = Task_WaitForBatteryDryErrorWindow;
|
||||||
|
// save exists and stored day count is more than a day ahead of RTC
|
||||||
|
} else if (tMenuType != HAS_NO_SAVED_GAME && VarGet(VAR_DAYS) > gLocalTime.days + 1) {
|
||||||
|
// Reset days var to today + 1
|
||||||
|
// Allowing daily events to happen again in a day
|
||||||
|
VarSet(VAR_DAYS, gLocalTime.days + 1);
|
||||||
|
CreateMainMenuErrorWindow(gText_TimeWarning);
|
||||||
|
gTasks[taskId].func = Task_WaitForBatteryDryErrorWindow;
|
||||||
|
} else {
|
||||||
gTasks[taskId].func = Task_DisplayMainMenu;
|
gTasks[taskId].func = Task_DisplayMainMenu;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CreateMainMenuErrorWindow(gText_BatteryRunDry);
|
CreateMainMenuErrorWindow(gText_BatteryRunDry);
|
||||||
|
@ -36,6 +36,9 @@ const u8 gText_SaveFileCorrupted[] = _("The save file is corrupted. The\npreviou
|
|||||||
const u8 gText_SaveFileErased[] = _("The save file has been erased\ndue to corruption or damage.");
|
const u8 gText_SaveFileErased[] = _("The save file has been erased\ndue to corruption or damage.");
|
||||||
const u8 gJPText_No1MSubCircuit[] = _("1Mサブきばんが ささっていません!");
|
const u8 gJPText_No1MSubCircuit[] = _("1Mサブきばんが ささっていません!");
|
||||||
const u8 gText_BatteryRunDry[] = _("The internal battery has run dry.\nThe game can be played.\pHowever, clock-based events will\nno longer occur.");
|
const u8 gText_BatteryRunDry[] = _("The internal battery has run dry.\nThe game can be played.\pHowever, clock-based events will\nno longer occur.");
|
||||||
|
const u8 gText_EmuWarning[] = _("Inaccurate emulator detected.\nYou should use a recent emulator with\nsupport for RTC (Real Time Clock).\nThe game should still work, but\nyou may encouter errors");
|
||||||
|
const u8 gText_TimeWarning[] = _("Real Time Clock is more than 1 day\nbehind saved time.\nPlease don't tamper with the RTC, as it may\nbreak some functionnality");
|
||||||
|
|
||||||
const u8 gText_Player[] = _("PLAYER"); // Unused
|
const u8 gText_Player[] = _("PLAYER"); // Unused
|
||||||
const u8 gText_Pokedex[] = _("POKéDEX"); // Unused
|
const u8 gText_Pokedex[] = _("POKéDEX"); // Unused
|
||||||
const u8 gText_Time[] = _("TIME");
|
const u8 gText_Time[] = _("TIME");
|
||||||
|
Loading…
Reference in New Issue
Block a user