From 3dd8a4764ea85fda1a1dd3f14cecec09bdc2ed5f Mon Sep 17 00:00:00 2001 From: d0k3 Date: Thu, 7 Dec 2017 02:01:15 +0100 Subject: [PATCH] Allow compiling multi-script autorunners --- Makefile.common | 2 +- README.md | 2 +- arm9/source/godmode.c | 10 +++++++--- arm9/source/main.c | 2 +- arm9/source/system/vram0.h | 7 ++++--- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Makefile.common b/Makefile.common index 894140b..43b589e 100644 --- a/Makefile.common +++ b/Makefile.common @@ -33,7 +33,7 @@ ifeq ($(SWITCH_SCREENS),1) CFLAGS += -DSWITCH_SCREENS endif -ifeq ($(AUTORUN_SCRIPT),1) +ifeq ($(SCRIPT_RUNNER),1) CFLAGS += -DAUTORUN_SCRIPT README := endif diff --git a/README.md b/README.md index 4394cf1..3605f29 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Build `GodMode9.firm` via `make firm` (requires [firmtool](https://github.com/Tu You may run `make release` to get a nice, release-ready package of all required files. To build __SafeMode9__ (a bricksafe variant of GodMode9, with limited write permissions) instead of GodMode9, compile with `make FLAVOR=SafeMode9`. To switch screens, compile with `make SWITCH_SCREENS=1`. For additional customization, you may choose the internal font via `make FONT=6X10`, `make FONT=ACORN`, `make FONT=GB` or `make FONT=ORIG`. You may also hardcode the brightness via `make FIXED_BRIGHTNESS=x`, whereas `x` is a value between 0...15. -Further customization is possible by hardcoding `aeskeydb.bin` (just put the file into the `data` folder when compiling). All files put into the `data` folder will turn up in the `V:` drive, but keep in mind there's a hard 3MB limit for all files inside, including overhead. A standalone script runner is compiled by providing `autorun.gm9` (again, in the `data` folder) and building with `make AUTORUN_SCRIPT=1`. +Further customization is possible by hardcoding `aeskeydb.bin` (just put the file into the `data` folder when compiling). All files put into the `data` folder will turn up in the `V:` drive, but keep in mind there's a hard 3MB limit for all files inside, including overhead. A standalone script runner is compiled by providing `autorun.gm9` (again, in the `data` folder) and building with `make SCRIPT_RUNNER=1`. To build a .firm signed with SPI boot keys (for ntrboot and the like), run `make NTRBOOT=1`. You may need to rename the output files if the ntrboot installer you use uses hardcoded filenames. Some features such as boot9 / boot11 access are not currently available from the ntrboot environment. diff --git a/arm9/source/godmode.c b/arm9/source/godmode.c index fa1ade9..e92fb74 100644 --- a/arm9/source/godmode.c +++ b/arm9/source/godmode.c @@ -77,7 +77,7 @@ u32 SplashInit(const char* modestr) { return 0; } -#ifndef AUTORUN_SCRIPT +#ifndef SCRIPT_RUNNER void GetTimeString(char* timestr, bool forced_update, bool full_year) { static DsTime dstime; static u64 timer = (u64) -1; // this ensures we don't check the time too often @@ -2303,18 +2303,22 @@ u32 ScriptRunner(int entrypoint) { while (HID_STATE); // wait until no buttons are pressed while (timer_msec( timer ) < 500); // show splash for at least 0.5 sec - ClearScreenF(true, true, COLOR_STD_BG); // clear splash // get script from VRAM0 TAR u64 autorun_gm9_size = 0; void* autorun_gm9 = FindVTarFileInfo(VRAM0_AUTORUN_GM9, &autorun_gm9_size); if (autorun_gm9 && autorun_gm9_size) { + ClearScreenF(true, true, COLOR_STD_BG); // clear splash // copy script to script buffer and run it memset(SCRIPT_BUFFER, 0, SCRIPT_BUFFER_SIZE); memcpy(SCRIPT_BUFFER, autorun_gm9, autorun_gm9_size); ExecuteGM9Script(NULL); - } else ShowPrompt(false, "Compiled as script autorunner\nbut no autorun.gm9 provided.\n \nDerp!"); + } else if (PathExist("V:/" VRAM0_SCRIPTS)) { + char loadpath[256]; + if (FileSelector(loadpath, FLAVOR " scripts menu.\nSelect script:", "V:/" VRAM0_SCRIPTS, "*.gm9", true, false)) + ExecuteGM9Script(loadpath); + } else ShowPrompt(false, "Compiled as script autorunner\nbut no script provided.\n \nDerp!"); // deinit DeinitExtFS(); diff --git a/arm9/source/main.c b/arm9/source/main.c index d4ecc53..4f97473 100644 --- a/arm9/source/main.c +++ b/arm9/source/main.c @@ -17,7 +17,7 @@ void main(int argc, char** argv, int entrypoint) PXI_DoCMD(PXI_SCREENINIT, NULL, 0); I2C_writeReg(I2C_DEV_MCU, 0x22, 0x2A); - #ifdef AUTORUN_SCRIPT + #ifdef SCRIPT_RUNNER // Run the script runner if (ScriptRunner(entrypoint) == GODMODE_EXIT_REBOOT) #else diff --git a/arm9/source/system/vram0.h b/arm9/source/system/vram0.h index 67e5885..bbb35e0 100644 --- a/arm9/source/system/vram0.h +++ b/arm9/source/system/vram0.h @@ -5,9 +5,10 @@ // known file names inside VRAM0 TAR -#define VRAM0_AUTORUN_GM9 "autorun.gm9" -#define VRAM0_README_MD "README.md" -#define VRAM0_SPLASH_PCX FLAVOR "_splash.pcx" +#define VRAM0_AUTORUN_GM9 "autorun.gm9" +#define VRAM0_SCRIPTS "scripts" +#define VRAM0_README_MD "README.md" +#define VRAM0_SPLASH_PCX FLAVOR "_splash.pcx" #define VRAM0_OFFSET 0x18000000