From e6c035de7d69907af73069e33da88875e7f2a2e5 Mon Sep 17 00:00:00 2001 From: MrHuu Date: Mon, 4 Jan 2021 20:15:28 +0100 Subject: [PATCH] (3DS) Update error applet --- ctr/ctr_debug.h | 1 + ctr/ctr_system.c | 14 ++++++++++++++ ctr/exec-3dsx/exec_cia.c | 25 ++++++++----------------- frontend/drivers/platform_ctr.c | 13 ++++--------- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/ctr/ctr_debug.h b/ctr/ctr_debug.h index 7c33bafe15..3a75a432a0 100644 --- a/ctr/ctr_debug.h +++ b/ctr/ctr_debug.h @@ -8,6 +8,7 @@ extern "C" { #endif void wait_for_input(void); +void error_and_quit(const char* errorStr); void dump_result_value(Result val); #ifdef __cplusplus } diff --git a/ctr/ctr_system.c b/ctr/ctr_system.c index c15be68aac..615488777e 100644 --- a/ctr/ctr_system.c +++ b/ctr/ctr_system.c @@ -322,6 +322,20 @@ void wait_for_input(void) } } +void error_and_quit(const char* errorStr) +{ + errorConf error; + + gfxInitDefault(); + + errorInit(&error, ERROR_TEXT, CFG_LANGUAGE_EN); + errorText(&error, errorStr); + errorDisp(&error); + + gfxExit(); + exit(0); +} + long sysconf(int name) { switch (name) diff --git a/ctr/exec-3dsx/exec_cia.c b/ctr/exec-3dsx/exec_cia.c index 774fe9e147..1626993b18 100644 --- a/ctr/exec-3dsx/exec_cia.c +++ b/ctr/exec-3dsx/exec_cia.c @@ -3,6 +3,7 @@ #include #include #include <3ds.h> +#include "ctr/ctr_debug.h" #define FILE_CHUNK_SIZE 4096 @@ -14,16 +15,6 @@ typedef struct char argvHmac[0x20] = {0x1d, 0x78, 0xff, 0xb9, 0xc5, 0xbc, 0x78, 0xb7, 0xac, 0x29, 0x1d, 0x3e, 0x16, 0xd0, 0xcf, 0x53, 0xef, 0x12, 0x58, 0x83, 0xb6, 0x9e, 0x2f, 0x79, 0x47, 0xf9, 0x35, 0x61, 0xeb, 0x50, 0xd7, 0x67}; -static void errorAndQuit(const char* errorStr) -{ - errorConf error; - - errorInit(&error, ERROR_TEXT, CFG_LANGUAGE_EN); - errorText(&error, errorStr); - errorDisp(&error); - exit(0); -} - static int isCiaInstalled(u64 titleId, u16 version) { u32 titlesToRetrieve; @@ -164,30 +155,30 @@ int exec_cia(const char* path, const char** args) ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")); if (R_FAILED(res)) - errorAndQuit("Cant open SD FS archive."); + error_and_quit("Cant open SD FS archive."); res = FSUSER_OpenFile(&ciaFile, ciaArchive, fsMakePath(PATH_ASCII, path + 5/*skip "sdmc:"*/), FS_OPEN_READ, 0); if (R_FAILED(res)) - errorAndQuit("Cant open CIA file."); + error_and_quit("Cant open CIA file."); res = AM_GetCiaFileInfo(MEDIATYPE_SD, &ciaInfo, ciaFile); if (R_FAILED(res)) - errorAndQuit("Cant get CIA file info."); + error_and_quit("Cant get CIA file info."); ciaInstalled = isCiaInstalled(ciaInfo.titleID, ciaInfo.version); if (ciaInstalled == -1) { /* error */ - errorAndQuit("Could not read title ID list."); + error_and_quit("Could not read title ID list."); } else if (ciaInstalled == 0) { /* not installed */ int error = installCia(ciaFile); if (error == -1) - errorAndQuit("Cant install CIA."); + error_and_quit("Cant install CIA."); } FSFILE_Close(ciaFile); @@ -207,12 +198,12 @@ int exec_cia(const char* path, const char** args) res = APT_PrepareToDoApplicationJump(0, ciaInfo.titleID, 0x1); if (R_FAILED(res)) - errorAndQuit("CIA cant run, cant prepare."); + error_and_quit("CIA cant run, cant prepare."); res = APT_DoApplicationJump(¶m, sizeof(param.argc) + argsLength, argvHmac); if (R_FAILED(res)) - errorAndQuit("CIA cant run, cant jump."); + error_and_quit("CIA cant run, cant jump."); /* wait for application jump, for some reason its not instant */ while(1); diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 8c81a9192a..679f37614d 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -244,10 +244,7 @@ static void frontend_ctr_exec(const char* path, bool should_load_game) if (core_path[0] == '\0') { - errorInit(&error_dialog, ERROR_TEXT, CFG_LANGUAGE_EN); - errorText(&error_dialog, "There are no cores installed, install a core to continue."); - errorDisp(&error_dialog); - exit(0); + error_and_quit("There are no cores installed, install a core to continue."); } } #endif @@ -268,13 +265,11 @@ static void frontend_ctr_exec(const char* path, bool should_load_game) exec_cia(path, arg_data); } - errorInit(&error_dialog, ERROR_TEXT, CFG_LANGUAGE_EN); + /* couldnt launch new core, but context + is corrupt so we have to quit */ snprintf(error_string, sizeof(error_string), "Can't launch core:%s", path); - errorText(&error_dialog, error_string); - errorDisp(&error_dialog); - exit(0); /* couldnt launch new core, but context - is corrupt so we have to quit */ + error_and_quit(error_string); } }