Skip to content

Commit

Permalink
add sys.check_raw_rtc
Browse files Browse the repository at this point in the history
  • Loading branch information
ihaveamac committed Dec 12, 2024
1 parent ff2cb91 commit f355844
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions arm9/source/godmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,7 @@ u32 GodMode(int entrypoint) {
}
}

// note: this is kinda duplicated in arm9/source/lua/gm9internalsys.c as well
// check internal clock
if (IS_UNLOCKED) { // we could actually do this on any entrypoint
DsTime dstime;
Expand Down
26 changes: 26 additions & 0 deletions arm9/source/lua/gm9internalsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "nand.h"
#include "utils.h"
#include "ui.h"
#include "rtc.h"
#include "godmode.h"

#define UNUSED(x) ((void)(x))

Expand Down Expand Up @@ -123,6 +125,29 @@ static int internalsys_check_embedded_backup(lua_State* L) {
return 1;
}

static int internalsys_check_raw_rtc(lua_State* L) {
CheckLuaArgCount(L, 0, "_sys.check_raw_rtc");

bool result = false;

DsTime dstime;
get_dstime(&dstime);
if (DSTIMEGET(&dstime, bcd_Y) >= 18) {
result = true;
} else if (ShowPrompt(true, "%s", STR_RTC_DATE_TIME_SEEMS_TO_BE_WRONG_SET_NOW) &&
ShowRtcSetterPrompt(&dstime, "%s", STR_TITLE_SET_RTC_DATE_TIME)) {
//char timestr[UTF_BUFFER_BYTESIZE(32)];
set_dstime(&dstime);
// this is only in godmode.h
//GetTimeString(timestr, true, true);
// ShowPrompt(false, STR_NEW_RTC_DATE_TIME_IS_TIME, timestr);
result = true;
}

lua_pushboolean(L, result);
return 1;
}

static int internalsys_global_bkpt(lua_State* L) {
UNUSED(L);
bkpt;
Expand All @@ -137,6 +162,7 @@ static const luaL_Reg internalsys_lib[] = {
{"next_emu", internalsys_next_emu},
{"get_emu_base", internalsys_get_emu_base},
{"check_embedded_backup", internalsys_check_embedded_backup},
{"check_raw_rtc", internalsys_check_raw_rtc},
{NULL, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions data/luapackages/sys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sys.boot = _sys.boot
sys.reboot = _sys.reboot
sys.power_off = _sys.power_off
sys.check_embedded_backup = _sys.check_embedded_backup
sys.check_raw_rtc = _sys.check_raw_rtc

sys.secureinfo_letter = nil
sys.region = nil
Expand Down

0 comments on commit f355844

Please sign in to comment.