Scripting: Detect 'ntrboot' via $[HAX]

This commit is contained in:
d0k3 2018-01-03 02:21:56 +01:00
parent 64b5c3d2ad
commit 9bdd6a516f

View File

@ -171,6 +171,16 @@ static u32 skip_state = 0; // zero, _SKIP_BLOCK, _SKIP_TILL_END
static u32 ifcnt = 0; // current # of 'if' nesting 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) { static inline bool strntohex(const char* str, u8* hex, u32 len) {
if (!len) { if (!len) {
len = strlen(str); 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("NULL", ""); // this one is special and should not be changed later
set_var("CURRDIR", curr_dir); // script path, never changes set_var("CURRDIR", curr_dir); // script path, never changes
set_var("GM9OUT", OUTPUT_PATH); // output 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("ONTYPE", IS_O3DS ? "O3DS" : "N3DS"); // type of the console
set_var("RDTYPE", IS_DEVKIT ? "devkit" : "retail"); // devkit / retail set_var("RDTYPE", IS_DEVKIT ? "devkit" : "retail"); // devkit / retail
upd_var(NULL); // set all dynamic environment vars upd_var(NULL); // set all dynamic environment vars