diff --git a/include/arm9/firm.h b/include/arm9/firm.h index 252f056..141cbfd 100644 --- a/include/arm9/firm.h +++ b/include/arm9/firm.h @@ -49,4 +49,4 @@ bool firm_size(size_t *size); s32 loadVerifyFirm(const char *const path, bool skipHashCheck, bool installMode); -noreturn void firmLaunch(int argc, const char **argv); +noreturn void firmLaunch(void); diff --git a/source/arm11/menu/menu_func.c b/source/arm11/menu/menu_func.c index 8097328..b4e3739 100644 --- a/source/arm11/menu/menu_func.c +++ b/source/arm11/menu/menu_func.c @@ -300,7 +300,7 @@ // try load and verify ee_printf("\nLoading %s...\n", path); s32 res = loadVerifyFirm(path, false); - if (res != 0) + if (res < 0) { ee_printf("Firm %s error code %li!\n", (res > -8) ? "load" : "verify", res); goto fail; @@ -663,7 +663,7 @@ updateScreens(); s32 res = loadVerifyFirm(firm_path, false); - if (res != 0) + if (res < 0) { ee_printf(ESC_SCHEME_BAD "failed!\n" ESC_RESET); ee_printf("Firm %s error code %li!\n", (res > -8) ? "load" : "verify", res); diff --git a/source/arm9/firm.c b/source/arm9/firm.c index a88d1b8..6902db4 100644 --- a/source/arm9/firm.c +++ b/source/arm9/firm.c @@ -31,6 +31,7 @@ #include "arm9/partitions.h" #include "arm9/dev.h" #include "fs.h" +#include "hardware/gfx.h" typedef struct @@ -78,6 +79,8 @@ } }; +static int firmLaunchArgc = 1; + /* Calculates the actual firm partition size by using its header */ @@ -287,18 +290,44 @@ } } - ((const char**)(ITCM_KERNEL_MIRROR + 0x7470))[0] = ((const char*)(ITCM_KERNEL_MIRROR + 0x7474)); - strncpy_s((void*)(ITCM_KERNEL_MIRROR + 0x7474), path, 256, 256); + ((const char**)(ITCM_KERNEL_MIRROR + 0x7470))[0] = ((const char*)(ITCM_KERNEL_MIRROR + 0x7490)); + strncpy_s((void*)(ITCM_KERNEL_MIRROR + 0x7490), path, 256, 256); - return 0; + if(!installMode && firmHdr->reserved2[0] & 1) // Adjust argc/v if screen init flag is set. + { + static const struct + { + u8 *fb1TopLeft; + u8 *fb1TopRight; + u8 *fb1Bottom; + u8 *fb2TopLeft; + u8 *fb2TopRight; + u8 *fb2Bottom; + } fbs = + { + (u8*)FRAMEBUF_TOP_A_1, + (u8*)FRAMEBUF_TOP_A_1, + (u8*)FRAMEBUF_SUB_A_1 + 0x17700, + (u8*)FRAMEBUF_TOP_A_2, + (u8*)FRAMEBUF_TOP_A_2, + (u8*)FRAMEBUF_SUB_A_2 + 0x17700 + }; + + memcpy((void*)(ITCM_KERNEL_MIRROR + 0x7478), &fbs, sizeof(fbs)); + ((const char**)(ITCM_KERNEL_MIRROR + 0x7470))[1] = ((const char*)(ITCM_KERNEL_MIRROR + 0x7478)); + firmLaunchArgc++; + + return 1; + } + else return 0; } -noreturn void firmLaunch(int argc, const char **argv) +noreturn void firmLaunch(void) { memcpy((void*)A9_STUB_ENTRY, (const void*)firmLaunchStub, A9_STUB_SIZE); deinitCpu(); - ((void (*)(int, const char**))A9_STUB_ENTRY)(argc, argv); + ((void (*)(int, const char**))A9_STUB_ENTRY)(firmLaunchArgc, (const char**)(ITCM_KERNEL_MIRROR + 0x7470)); while(1); } diff --git a/source/arm9/main.c b/source/arm9/main.c index 2ca1526..bf34d9d 100644 --- a/source/arm9/main.c +++ b/source/arm9/main.c @@ -37,7 +37,7 @@ hardwareDeinit(); // TODO: Proper argc/v passing needs to be implemented. - firmLaunch(1, (const char**)(ITCM_KERNEL_MIRROR + 0x7470)); + firmLaunch(); return 0; }