From 3f80693d9e42a1348bb57dbc43cab2b7fb5b4f54 Mon Sep 17 00:00:00 2001 From: suchmememanyskill Date: Sun, 10 Jan 2021 00:10:28 +0100 Subject: [PATCH] Save bytes, add screenshots into main and more - Also run script on bootup if a script called startup.te is found on the root of the sd - Saved bytes by just disabling making exfat partitions, lol --- bdk/libs/fatfs/ff.c | 1 + source/fs/fstypes.h | 4 +++- source/fs/menus/filemenu.c | 2 +- source/fs/menus/filemenu.h | 3 ++- source/hid/hid.c | 6 ++---- source/main.c | 7 +++++++ source/script/lexer.c | 2 +- source/script/lexer.h | 2 +- 8 files changed, 18 insertions(+), 9 deletions(-) diff --git a/bdk/libs/fatfs/ff.c b/bdk/libs/fatfs/ff.c index fe9a374..1d7e34b 100644 --- a/bdk/libs/fatfs/ff.c +++ b/bdk/libs/fatfs/ff.c @@ -5929,6 +5929,7 @@ FRESULT f_mkfs ( #if FF_FS_EXFAT if (fmt == FS_EXFAT) { /* Create an exFAT volume */ + LEAVE_MKFS(FR_NO_FILESYSTEM); // Muh frii bytes DWORD szb_bit, szb_case, sum, nb, cl; WCHAR ch, si; UINT j, st; diff --git a/source/fs/fstypes.h b/source/fs/fstypes.h index 9dcb250..b52333a 100644 --- a/source/fs/fstypes.h +++ b/source/fs/fstypes.h @@ -22,4 +22,6 @@ typedef struct { }; u16 sizeUnion; }; -} FSEntry_t; \ No newline at end of file +} FSEntry_t; + +#define newFSEntry(filename) (FSEntry_t) {.name = filename} \ No newline at end of file diff --git a/source/fs/menus/filemenu.c b/source/fs/menus/filemenu.c index af5582d..a2a010f 100644 --- a/source/fs/menus/filemenu.c +++ b/source/fs/menus/filemenu.c @@ -83,7 +83,7 @@ void RunScript(char *path, FSEntry_t entry){ gfx_clearscreen(); scriptCtx_t ctx = createScriptCtx(); - ctx.script = runLexar(script, size); + ctx.script = runLexer(script, size); free(script); dictVectorAdd(&ctx.varDict, newDict(CpyStr("_CWD"), (newVar(StringType, 0, .stringType = path)))); diff --git a/source/fs/menus/filemenu.h b/source/fs/menus/filemenu.h index 15554fc..debcedd 100644 --- a/source/fs/menus/filemenu.h +++ b/source/fs/menus/filemenu.h @@ -3,4 +3,5 @@ typedef void (*fileMenuPath)(char *path, FSEntry_t entry); -void FileMenu(char *path, FSEntry_t entry); \ No newline at end of file +void FileMenu(char *path, FSEntry_t entry); +void RunScript(char *path, FSEntry_t entry); \ No newline at end of file diff --git a/source/hid/hid.c b/source/hid/hid.c index 22ea151..536ac6d 100644 --- a/source/hid/hid.c +++ b/source/hid/hid.c @@ -24,10 +24,8 @@ Input_t *hidRead(){ if (controller->home) RebootToPayloadOrRcm(); - #ifdef TAKESCREENSHOT - if (controller->cap) - TakeScreenshot(); - #endif + if (controller->cap) + TakeScreenshot(); inputs.buttons = controller->buttons; diff --git a/source/main.c b/source/main.c index 359455c..0d8f87e 100644 --- a/source/main.c +++ b/source/main.c @@ -52,6 +52,9 @@ #include "keys/keys.h" #include "keys/keyfile.h" #include "storage/mountmanager.h" +#include "fs/fsutils.h" +#include "fs/fstypes.h" +#include "fs/menus/filemenu.h" hekate_config h_cfg; @@ -304,6 +307,10 @@ void ipl_main() if (res == 0) hidWait(); + + if (FileExists("sd:/startup.te")) + RunScript("sd:/", newFSEntry("startup.te")); + EnterMainMenu(); // Halt BPMP if we managed to get out of execution. diff --git a/source/script/lexer.c b/source/script/lexer.c index 3b4bf27..23be5a1 100644 --- a/source/script/lexer.c +++ b/source/script/lexer.c @@ -92,7 +92,7 @@ void lexarVectorClear(Vector_t *v){ #define ELIFC(c) else if (*in == c) -Vector_t runLexar(const char* in, u32 len) { +Vector_t runLexer(const char* in, u32 len) { const char *start = in; Vector_t vec = newVec(sizeof(lexarToken_t), 16); // store last var for re-assignment diff --git a/source/script/lexer.h b/source/script/lexer.h index b2eeb6c..a6b5d42 100644 --- a/source/script/lexer.h +++ b/source/script/lexer.h @@ -1,6 +1,6 @@ #pragma once #include "types.h" -Vector_t runLexar(const char* in, u32 len); +Vector_t runLexer(const char* in, u32 len); char lexarDebugGetTokenC(u8 tokenN); void lexarVectorClear(Vector_t *v); \ No newline at end of file