From eecefd634c982f76afe96120ad8bee241317ae57 Mon Sep 17 00:00:00 2001 From: "Such Meme, Many Skill" Date: Fri, 7 Feb 2020 12:19:46 +0100 Subject: [PATCH] Add $EMUMMC$ flag, add DEL and DEL-R commands to scripting --- source/tegraexplorer/emmc.c | 7 +++--- source/tegraexplorer/fs.c | 2 +- source/tegraexplorer/script.c | 42 +++++++++++++++++++++++++---------- source/tegraexplorer/script.h | 10 --------- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/source/tegraexplorer/emmc.c b/source/tegraexplorer/emmc.c index 2bee822..ba6d49b 100644 --- a/source/tegraexplorer/emmc.c +++ b/source/tegraexplorer/emmc.c @@ -89,9 +89,10 @@ void connect_mmc(short mmctype){ currentlyMounted = SYSMMC; break; case EMUMMC: - emummc_storage_init_mmc(&storage, &sdmmc); - emu_cfg.enabled = 1; - currentlyMounted = EMUMMC; + if (emummc_storage_init_mmc(&storage, &sdmmc)){ + emu_cfg.enabled = 1; + currentlyMounted = EMUMMC; + } break; } } diff --git a/source/tegraexplorer/fs.c b/source/tegraexplorer/fs.c index a753dd8..0fbf989 100644 --- a/source/tegraexplorer/fs.c +++ b/source/tegraexplorer/fs.c @@ -29,7 +29,7 @@ menu_item explfilemenu[11] = { {"Move to clipboard", COLOR_BLUE, MOVE, 1}, {"\nDelete file\n", COLOR_RED, DELETE, 1}, {"Launch Payload", COLOR_ORANGE, PAYLOAD, 1}, - {"Launch Script", COLOR_BLUE, SCRIPT, 1}, + {"Launch Script", COLOR_YELLOW, SCRIPT, 1}, {"View Hex", COLOR_GREEN, HEXVIEW, 1} }; diff --git a/source/tegraexplorer/script.c b/source/tegraexplorer/script.c index c2bcfde..59519ba 100644 --- a/source/tegraexplorer/script.c +++ b/source/tegraexplorer/script.c @@ -10,22 +10,19 @@ #include "../utils/btn.h" #include "../gfx/gfx.h" #include "../utils/util.h" +#include "../storage/emummc.h" #include "script.h" char func[11] = "", args[2][128] = {"", ""}; int res; -script_parts parts[] = { - {"COPY", Part_Copy, 2}, - {"COPY-R", Part_RecursiveCopy, 2}, - {"MKDIR", Part_MakeFolder, 1}, - {"CON_MMC", Part_ConnectMMC, 1}, - {"MNT_MMC", Part_MountMMC, 1}, - {"PRINT", Part_Print, 1}, - {"ERRPRINT", Part_ErrorPrint, 0}, - {"EXIT", Part_Exit, 0}, - {"PAUSE", Part_WaitOnUser, 0}, - {"NULL", NULL, -1} -}; + +int Part_Delete(){ + return f_unlink(args[0]); +} + +int Part_DeleteRecursive(){ + return del_recursive(args[0]); +} int Part_Copy(){ return copy(args[0], args[1], true, false); @@ -76,6 +73,21 @@ int Part_WaitOnUser(){ return (buttons_pressed & BTN_POWER); } +script_parts parts[] = { + {"COPY", Part_Copy, 2}, + {"COPY-R", Part_RecursiveCopy, 2}, + {"MKDIR", Part_MakeFolder, 1}, + {"CON_MMC", Part_ConnectMMC, 1}, + {"MNT_MMC", Part_MountMMC, 1}, + {"PRINT", Part_Print, 1}, + {"ERRPRINT", Part_ErrorPrint, 0}, + {"EXIT", Part_Exit, 0}, + {"PAUSE", Part_WaitOnUser, 0}, + {"DEL", Part_Delete, 1}, + {"DEL-R", Part_DeleteRecursive, 1}, + {"NULL", NULL, -1} +}; + int ParsePart(){ int i; for (i = 0; parts[i].arg_amount != -1; i++){ @@ -187,6 +199,12 @@ void ParseScript(char* path){ else if (strcmpcheck(func, "BTN_VOL-")){ inifstatement = (buttons_pressed & BTN_VOL_DOWN); } + else if (strcmpcheck(func, "EMUMMC")){ + inifstatement = (emu_cfg.enabled); + } + else if (strcmpcheck(func, "NOEMUMMC")){ + inifstatement = (!emu_cfg.enabled); + } if (inifstatement) while(currentchar != '{') diff --git a/source/tegraexplorer/script.h b/source/tegraexplorer/script.h index 5f12374..0bd4c47 100644 --- a/source/tegraexplorer/script.h +++ b/source/tegraexplorer/script.h @@ -9,13 +9,3 @@ typedef struct _script_parts { } script_parts; void ParseScript(char* path); -int Part_WaitOnUser(); -int Part_Exit(); -int Part_ErrorPrint(); -int Part_Print(); -int Part_MountMMC(); -int Part_ConnectMMC(); -int Part_MakeFolder(); -int Part_RecursiveCopy(); -int Testing_Part_Handler(); -int Part_Copy(); \ No newline at end of file