mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Allow building standalone script runners
... just include autorun.gm9 in the data folder
This commit is contained in:
parent
c094c6c192
commit
c32908e4cf
20
Makefile
20
Makefile
@ -60,10 +60,14 @@ ifeq ($(SWITCH_SCREENS),1)
|
||||
CFLAGS += -DSWITCH_SCREENS
|
||||
endif
|
||||
|
||||
ifneq ("$(wildcard $(CURDIR)/data/aeskeydb.bin)","")
|
||||
ifneq ("$(wildcard $(CURDIR)/../$(DATA)/aeskeydb.bin)","")
|
||||
CFLAGS += -DHARDCODE_KEYS
|
||||
endif
|
||||
|
||||
ifneq ("$(wildcard $(CURDIR)/../$(DATA)/autorun.gm9)","")
|
||||
CFLAGS += -DAUTORUN_SCRIPT
|
||||
endif
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
||||
|
||||
LDFLAGS = -T../link.ld -nostartfiles -g $(ARCH) -Wl,-Map,$(TARGET).map
|
||||
@ -95,11 +99,12 @@ export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/gm9*.*))) \
|
||||
$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/aeskeydb.bin)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/aeskeydb.bin))) \
|
||||
$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/autorun.gm9)))
|
||||
ifeq ($(SAFEMODE),1)
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/sm9*.*))) \
|
||||
$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/aeskeydb.bin)))
|
||||
BINFILES += $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/sm9*.*)))
|
||||
else
|
||||
BINFILES += $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/gm9*.*)))
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
@ -198,6 +203,11 @@ $(OUTPUT).elf : $(OFILES)
|
||||
@$(bin2o)
|
||||
#---------------------------------------------------------------------------------
|
||||
%_bin.h %.bin.o: %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
#---------------------------------------------------------------------------------
|
||||
%_gm9.h %.gm9.o: %.gm9
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
@ -27,6 +27,9 @@
|
||||
#include "rtc.h"
|
||||
#include "sysinfo.h"
|
||||
#include QLZ_SPLASH_H
|
||||
#ifdef AUTORUN_SCRIPT
|
||||
#include "autorun_gm9.h"
|
||||
#endif
|
||||
|
||||
#define N_PANES 2
|
||||
|
||||
@ -1907,3 +1910,32 @@ u32 GodMode(bool is_b9s) {
|
||||
|
||||
return exit_mode;
|
||||
}
|
||||
|
||||
#ifdef AUTORUN_SCRIPT
|
||||
u32 ScriptRunner(bool is_b9s) {
|
||||
// show splash and initialize
|
||||
ClearScreenF(true, true, COLOR_STD_BG);
|
||||
SplashInit();
|
||||
u64 timer = timer_start();
|
||||
|
||||
InitSDCardFS();
|
||||
AutoEmuNandBase(true);
|
||||
InitNandCrypto(!is_b9s);
|
||||
InitExtFS();
|
||||
|
||||
while (CheckButton(BUTTON_A)); // don't continue while A is held
|
||||
while (timer_msec( timer ) < 500); // show splash for at least 0.5 sec
|
||||
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);
|
||||
|
||||
// deinit
|
||||
DeinitExtFS();
|
||||
DeinitSDCardFS();
|
||||
|
||||
return GODMODE_EXIT_REBOOT;
|
||||
}
|
||||
#endif
|
||||
|
@ -6,3 +6,4 @@
|
||||
#define GODMODE_EXIT_POWEROFF 1
|
||||
|
||||
u32 GodMode(bool is_b9s);
|
||||
u32 ScriptRunner(bool is_b9s);
|
||||
|
@ -8,8 +8,14 @@ void main(int argc, char** argv)
|
||||
|
||||
// Wait for ARM11
|
||||
PXI_WaitRemote(PXI_READY);
|
||||
|
||||
|
||||
#ifdef AUTORUN_SCRIPT
|
||||
// Run the script runner
|
||||
if (ScriptRunner(argc) == GODMODE_EXIT_REBOOT) Reboot();
|
||||
else PowerOff();
|
||||
#else
|
||||
// Run the main program
|
||||
if (GodMode(argc) == GODMODE_EXIT_REBOOT) Reboot();
|
||||
else PowerOff();
|
||||
#endif
|
||||
}
|
||||
|
@ -851,13 +851,12 @@ bool FileTextViewer(const char* path, bool as_script) {
|
||||
}
|
||||
|
||||
bool ExecuteGM9Script(const char* path_script) {
|
||||
// revert mount state?
|
||||
char* script = (char*) SCRIPT_BUFFER;
|
||||
char* ptr = script;
|
||||
|
||||
// fetch script
|
||||
u32 script_size;
|
||||
if (!(script_size = FileGetData(path_script, (u8*) script, SCRIPT_MAX_SIZE, 0)))
|
||||
// fetch script - if no path is given, assume script already in script buffer
|
||||
u32 script_size = (path_script) ? FileGetData(path_script, (u8*) script, SCRIPT_MAX_SIZE, 0) : strnlen(script, SCRIPT_BUFFER_SIZE);
|
||||
if (!script_size || (script_size >= SCRIPT_BUFFER_SIZE))
|
||||
return false;
|
||||
char* end = script + script_size;
|
||||
*end = '\0';
|
||||
|
Loading…
x
Reference in New Issue
Block a user