From 8d895cf359a81634ae293dfff849a6403e422e4f Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 25 Apr 2024 17:19:53 +0200 Subject: [PATCH] Add support for quick starting into homebrew titles --- Dockerfile | 1 + Makefile | 6 ++++-- source/QuickStartUtils.cpp | 15 +++++++++++++++ source/main.cpp | 7 +++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7397c5d..774f5ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM ghcr.io/wiiu-env/devkitppc:20230621 COPY --from=ghcr.io/wiiu-env/libmocha:20230621 /artifacts $DEVKITPRO +COPY --from=ghcr.io/wiiu-env/librpxloader:20240425 /artifacts $DEVKITPRO WORKDIR project diff --git a/Makefile b/Makefile index 7abe15a..17f9555 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ TOPDIR ?= $(CURDIR) include $(DEVKITPRO)/wut/share/wut_rules +WUMS_ROOT := $(DEVKITPRO)/wums + #------------------------------------------------------------------------------- # TARGET is the name of the output # BUILD is the directory where object files & intermediate files will be placed @@ -36,7 +38,7 @@ CXXFLAGS := $(CFLAGS) -std=c++20 -fno-rtti ASFLAGS := -g $(ARCH) LDFLAGS = -g $(ARCH) $(RPXSPECS) --entry=_start -Wl,-Map,$(notdir $*.map) -LIBS := -lpng -lmocha -lwut -lz +LIBS := -lrpxloader -lpng -lmocha -lwut -lz ifeq ($(DEBUG),1) CXXFLAGS += -DDEBUG -g @@ -52,7 +54,7 @@ endif # list of directories containing libraries, this must be the top level # containing include and lib #------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUT_ROOT)/usr +LIBDIRS := $(PORTLIBS) $(WUMS_ROOT) $(WUT_ROOT) $(WUT_ROOT)/usr #------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional diff --git a/source/QuickStartUtils.cpp b/source/QuickStartUtils.cpp index b4160ce..d1325f9 100644 --- a/source/QuickStartUtils.cpp +++ b/source/QuickStartUtils.cpp @@ -14,11 +14,15 @@ #include #include #include +#include #include #include extern "C" void __fini_wut(); +#define UPPER_TITLE_ID_HOMEBREW 0x0005000F +#define TITLE_ID_HOMEBREW_MASK (((uint64_t) UPPER_TITLE_ID_HOMEBREW) << 32) + static void StartAppletAndExit() { DEBUG_FUNCTION_LINE("Wait for applet"); ProcUIInit(OSSavesDone_ReadyToRelease); @@ -125,6 +129,17 @@ bool getQuickBoot() { return false; } + if ((info.titleId & TITLE_ID_HOMEBREW_MASK) == TITLE_ID_HOMEBREW_MASK) { + std::string homebrewPath = info.parameter; + DEBUG_FUNCTION_LINE("Trying to launch homebrew title: \"%s\"", homebrewPath.c_str()); + + if (auto err = RPXLoader_LaunchHomebrew(homebrewPath.c_str()); err != RPX_LOADER_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE_WARN("Failed to launch homebrew title: %s (%d)", RPXLoader_GetStatusStr(err), err); + return false; + } + return true; + } + if (info.titleId == 0x0005001010040000L || info.titleId == 0x0005001010040100L || info.titleId == 0x0005001010040200L) { diff --git a/source/main.cpp b/source/main.cpp index c9d03de..91ae2fc 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,12 @@ int32_t main(int32_t argc, char **argv) { OSFatal("AutobootModule: Mocha_InitLibrary failed"); } + // Use librpxloader. + RPXLoaderStatus error3; + if ((error3 = RPXLoader_InitLibrary()) != RPX_LOADER_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE("AutobootModule: Failed to init RPXLoader. This can be ignored when not running Aroma. Error %s [%d]", RPXLoader_GetStatusStr(error3), error3); + } + InputUtils::InputData buttons = InputUtils::getControllerInput(); FSAInit();