diff --git a/Makefile b/Makefile index 088f23a..64455d1 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ CXXFLAGS := $(CFLAGS) -std=c++20 -fno-rtti ASFLAGS := -g $(ARCH) LDFLAGS = -g $(ARCH) $(RPXSPECS) --entry=_start -Wl,-Map,$(notdir $*.map) -LIBS := -lfreetype -lpng -lbz2 -lwut -lz +LIBS := -lfreetype -lpng -lbz2 -liosuhax -lwut -lz ifeq ($(DEBUG),1) CXXFLAGS += -DDEBUG -g @@ -47,7 +47,7 @@ endif # list of directories containing libraries, this must be the top level # containing include and lib #------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(WUT_ROOT) +LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUT_ROOT)/usr #------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index 186f6f3..e4b6842 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -22,6 +22,7 @@ #include #include +#include void handleAccountSelection(); @@ -118,5 +119,41 @@ void bootvWiiMenu() { } void bootHomebrewChannel() { - launchvWiiTitle(0x00010001, 0x4f484243); // 'OHBC' + // fall back to booting the vWii system menu if anything fails + uint64_t titleId = 0; + + if (IOSUHAX_Open(nullptr) >= 0) { + int fsaFd = IOSUHAX_FSA_Open(); + if (fsaFd >= 0) { + // mount the slccmpt + if (IOSUHAX_FSA_Mount(fsaFd, "/dev/slccmpt01", "/vol/storage_slccmpt01", 2, nullptr, 0) >= 0) { + fileStat_s stat; + + // test if the OHBC or HBC is installed + if (IOSUHAX_FSA_GetStat(fsaFd, "/vol/storage_slccmpt01/title/00010001/4f484243/content/00000000.app", &stat) >= 0) { + titleId = 0x000100014f484243; // 'OHBC' + } + else if (IOSUHAX_FSA_GetStat(fsaFd, "/vol/storage_slccmpt01/title/00010001/4c554c5a/content/00000000.app", &stat) >= 0) { + titleId = 0x000100014c554c5a; // 'LULZ' + } else { + DEBUG_FUNCTION_LINE("Cannot find HBC, booting vWii System Menu"); + } + + IOSUHAX_FSA_Unmount(fsaFd, "/vol/storage_slccmpt01", 2); + } else { + DEBUG_FUNCTION_LINE("Failed to mount SLCCMPT"); + } + + IOSUHAX_FSA_Close(fsaFd); + } else { + DEBUG_FUNCTION_LINE("Failed to open FSA"); + } + + IOSUHAX_Close(); + } else { + DEBUG_FUNCTION_LINE("Failed to open IOSUHAX"); + } + + DEBUG_FUNCTION_LINE("Launching vWii title %016llx", titleId); + launchvWiiTitle((uint32_t) (titleId >> 32), (uint32_t) (titleId & 0xffffffff)); }