diff --git a/source/tegraexplorer/common/common.h b/source/tegraexplorer/common/common.h index 0361650..b971d72 100644 --- a/source/tegraexplorer/common/common.h +++ b/source/tegraexplorer/common/common.h @@ -4,6 +4,7 @@ extern const char *gfx_file_size_names[]; extern const char *menu_sd_states[]; extern const char *emmc_fs_entries[]; +extern const char *utils_err_codes[]; enum mainmenu_main_return { MAIN_SDCARD = 0, diff --git a/source/tegraexplorer/common/strings.c b/source/tegraexplorer/common/strings.c index ca4f3c7..05f1809 100644 --- a/source/tegraexplorer/common/strings.c +++ b/source/tegraexplorer/common/strings.c @@ -16,4 +16,22 @@ const char *emmc_fs_entries[] = { "SYSTEM", "USER", "SAFE" +}; + +const char *utils_err_codes[] = { + "OK", + "I/O ERROR", + "DRIVE LOOKUP FAILED", + "NOT READY", + "NO FILE", + "NO PATH", + "PATH INVALID", + "ACCESS DENIED", + "ACCESS DENIED", + "INVALID PTR", + "PROTECTED", + "INVALID DRIVE", + "NO MEM", + "NO FAT", + "MKFS ABORT" }; \ No newline at end of file diff --git a/source/tegraexplorer/fs.c b/source/tegraexplorer/fs.c index c629f2a..366fa07 100644 --- a/source/tegraexplorer/fs.c +++ b/source/tegraexplorer/fs.c @@ -9,7 +9,7 @@ #include "../gfx/gfx.h" #include "../utils/util.h" #include "io.h" -#include "script.h" +#include "utils/script.h" #include "te.h" fs_entry *fileobjects; diff --git a/source/tegraexplorer/gfx/gfxutils.c b/source/tegraexplorer/gfx/gfxutils.c index eb5e57e..7513672 100644 --- a/source/tegraexplorer/gfx/gfxutils.c +++ b/source/tegraexplorer/gfx/gfxutils.c @@ -7,6 +7,7 @@ #include "../../utils/btn.h" #include "../../utils/util.h" #include "../../mem/heap.h" +#include "../common/common.h" void gfx_clearscreen(){ @@ -41,18 +42,20 @@ int gfx_message(u32 color, const char* message, ...){ return btn_wait(); } -int gfx_errprint(u32 color, int func, int err, int add){ +int gfx_errprint(char *src_func, int err, int loc){ gfx_clearscreen(); SWAPCOLOR(COLOR_ORANGE); gfx_printf("\nAn error occured:\n\n"); - gfx_printf("Function: %s\nErrcode: %d\nDesc: %s\n"); + gfx_printf("Function: %s\nErrcode: %d\n", src_func, err); - if (add) - gfx_printf("Additional info: %d"); + if (err < 15) + gfx_printf("Desc: %s\n", utils_err_codes[err]); + + if (loc) + gfx_printf("Loc: %d\n", loc); gfx_printf("\nPress any button to return"); - RESETCOLOR; return btn_wait(); } diff --git a/source/tegraexplorer/gfx/gfxutils.h b/source/tegraexplorer/gfx/gfxutils.h index 0719582..8673cf9 100644 --- a/source/tegraexplorer/gfx/gfxutils.h +++ b/source/tegraexplorer/gfx/gfxutils.h @@ -8,7 +8,7 @@ void gfx_clearscreen(); int gfx_message(u32 color, const char* message, ...); -int gfx_errprint(u32 color, int func, int err, int add); +int gfx_errprint(char *src_func, int err, int loc); int gfx_makewaitmenu(char *hiddenmessage, int timer); void gfx_printlength(int size, char *toprint); void gfx_printandclear(char *in, int length); diff --git a/source/tegraexplorer/te.c b/source/tegraexplorer/te.c index 3401a5a..d573f97 100644 --- a/source/tegraexplorer/te.c +++ b/source/tegraexplorer/te.c @@ -3,18 +3,19 @@ #include "te.h" #include "gfx.h" #include "../utils/util.h" -#include "tools.h" +#include "utils/tools.h" #include "fs.h" #include "io.h" #include "../utils/btn.h" #include "emmc.h" #include "../storage/emummc.h" -#include "script.h" +#include "utils/script.h" #include "common/common.h" #include "gfx/menu.h" #include "utils/utils.h" +#include "gfx/gfxutils.h" extern bool sd_mount(); extern void sd_unmount(); diff --git a/source/tegraexplorer/script.c b/source/tegraexplorer/utils/script.c similarity index 94% rename from source/tegraexplorer/script.c rename to source/tegraexplorer/utils/script.c index e0dba40..d2f04cf 100644 --- a/source/tegraexplorer/script.c +++ b/source/tegraexplorer/utils/script.c @@ -1,18 +1,18 @@ #include -#include "../mem/heap.h" -#include "gfx.h" -#include "fs.h" -#include "io.h" -#include "emmc.h" -#include "../utils/types.h" -#include "../libs/fatfs/ff.h" -#include "../utils/sprintf.h" -#include "../utils/btn.h" -#include "../gfx/gfx.h" -#include "../utils/util.h" -#include "../storage/emummc.h" +#include "../../mem/heap.h" +#include "../gfx/gfxutils.h" +#include "../fs.h" +#include "../io.h" +#include "../emmc.h" +#include "../../utils/types.h" +#include "../../libs/fatfs/ff.h" +#include "../../utils/sprintf.h" +#include "../../utils/btn.h" +#include "../../gfx/gfx.h" +#include "../../utils/util.h" +#include "../../storage/emummc.h" #include "script.h" -#include "common/common.h" +#include "../common/common.h" #include @@ -182,11 +182,11 @@ void ParseScript(char* path){ forceExit = false; currentcolor = COLOR_WHITE; - clearscreen(); + gfx_clearscreen(); res = f_open(&in, path, FA_READ | FA_OPEN_EXISTING); if (res != FR_OK){ - message(COLOR_RED, "File Opening Failed\nErrcode %d", res); + gfx_errprint("ParseScript", res, 1); return; } diff --git a/source/tegraexplorer/script.h b/source/tegraexplorer/utils/script.h similarity index 100% rename from source/tegraexplorer/script.h rename to source/tegraexplorer/utils/script.h diff --git a/source/tegraexplorer/tools.c b/source/tegraexplorer/utils/tools.c similarity index 91% rename from source/tegraexplorer/tools.c rename to source/tegraexplorer/utils/tools.c index 55de07c..d570295 100644 --- a/source/tegraexplorer/tools.c +++ b/source/tegraexplorer/utils/tools.c @@ -1,26 +1,26 @@ #include "tools.h" -#include "gfx.h" -#include "../libs/fatfs/ff.h" -#include "../gfx/gfx.h" -#include "../utils/btn.h" -#include "../soc/gpio.h" -#include "../utils/util.h" -#include "../utils/types.h" -#include "../libs/fatfs/diskio.h" -#include "../storage/sdmmc.h" -#include "../utils/sprintf.h" -#include "../soc/fuse.h" -#include "emmc.h" -#include "fs.h" -#include "io.h" -#include "common/common.h" +#include "../gfx/gfxutils.h" +#include "../../libs/fatfs/ff.h" +#include "../../gfx/gfx.h" +#include "../../utils/btn.h" +#include "../../soc/gpio.h" +#include "../../utils/util.h" +#include "../../utils/types.h" +#include "../../libs/fatfs/diskio.h" +#include "../../storage/sdmmc.h" +#include "../../utils/sprintf.h" +#include "../../soc/fuse.h" +#include "../emmc.h" +#include "../fs.h" +#include "../io.h" +#include "../common/common.h" extern bool sd_mount(); extern void sd_unmount(); extern sdmmc_storage_t sd_storage; void displayinfo(){ - clearscreen(); + gfx_clearscreen(); FATFS *fs; DWORD fre_clust, fre_sect, tot_sect; @@ -68,7 +68,7 @@ void displayinfo(){ void displaygpio(){ int res; - clearscreen(); + gfx_clearscreen(); gfx_printf("Updates gpio pins every 50ms:\nPress power to exit"); msleep(200); while (1){ @@ -99,7 +99,7 @@ int dumpfirmware(int mmc){ pkg1_info pkg1 = returnpkg1info(); u32 timer = get_tmr_s(); - clearscreen(); + gfx_clearscreen(); connect_mmc(mmc); mount_mmc("SYSTEM", 2); @@ -149,7 +149,7 @@ void dumpusersaves(int mmc){ connect_mmc(mmc); mount_mmc("USER", 2); - clearscreen(); + gfx_clearscreen(); res = f_mkdir("sd:/tegraexplorer"); gfx_printf("Creating sd:/tegraexplorer, res: %d\nCopying:\n", res); @@ -173,7 +173,7 @@ void dumpusersaves(int mmc){ } int format(int mode){ - clearscreen(); + gfx_clearscreen(); int res; bool fatalerror = false; DWORD plist[] = {666, 61145088}; diff --git a/source/tegraexplorer/tools.h b/source/tegraexplorer/utils/tools.h similarity index 100% rename from source/tegraexplorer/tools.h rename to source/tegraexplorer/utils/tools.h