diff --git a/arm9/source/utils/scripting.c b/arm9/source/utils/scripting.c index 24d1273..ddd9d5e 100644 --- a/arm9/source/utils/scripting.c +++ b/arm9/source/utils/scripting.c @@ -171,6 +171,16 @@ static u32 skip_state = 0; // zero, _SKIP_BLOCK, _SKIP_TILL_END static u32 ifcnt = 0; // current # of 'if' nesting +static inline bool isntrboot(void) { + // taken over from Luma 3DS: + // https://github.com/AuroraWright/Luma3DS/blob/bb5518b0f68d89bcd8efaf326355a770d5e57856/source/main.c#L58-L62 + const vu8 *bootMediaStatus = (const vu8 *) 0x1FFFE00C; + const vu32 *bootPartitionsStatus = (const vu32 *) 0x1FFFE010; + + // shell closed, no error booting NTRCARD, NAND partitions not even considered + return (bootMediaStatus[3] == 2) && !bootMediaStatus[1] && !bootPartitionsStatus[0] && !bootPartitionsStatus[1]; +} + static inline bool strntohex(const char* str, u8* hex, u32 len) { if (!len) { len = strlen(str); @@ -411,7 +421,7 @@ bool init_vars(const char* path_script) { set_var("NULL", ""); // this one is special and should not be changed later set_var("CURRDIR", curr_dir); // script path, never changes set_var("GM9OUT", OUTPUT_PATH); // output path, never changes - set_var("HAX", IS_SIGHAX ? "sighax" : IS_A9LH ? "a9lh" : ""); // type of hax running from + set_var("HAX", IS_SIGHAX ? (isntrboot() ? "ntrboot" : "sighax") : IS_A9LH ? "a9lh" : ""); // type of hax running from set_var("ONTYPE", IS_O3DS ? "O3DS" : "N3DS"); // type of the console set_var("RDTYPE", IS_DEVKIT ? "devkit" : "retail"); // devkit / retail upd_var(NULL); // set all dynamic environment vars