AutobootModule/source/main.cpp

80 lines
1.9 KiB
C++
Raw Permalink Normal View History

2022-02-02 19:57:14 +01:00
#include "DrawUtils.h"
#include "QuickStartUtils.h"
#include "StorageUtils.h"
#include "logger.h"
#include <coreinit/debug.h>
#include <gx2/state.h>
2021-12-28 20:17:21 +01:00
#include <malloc.h>
#include <string>
2021-12-28 20:17:21 +01:00
#include <vpad/input.h>
2022-01-01 12:09:31 +01:00
#include "BootUtils.h"
#include "MenuUtils.h"
2021-12-28 20:17:21 +01:00
void clearScreen() {
auto buffer = DrawUtils::InitOSScreen();
if (!buffer) {
OSFatal("Failed to alloc memory for screen");
2021-12-28 20:17:21 +01:00
}
DrawUtils::clear(COLOR_BACKGROUND);
2021-12-28 20:17:21 +01:00
// Call GX2Init to shut down OSScreen
GX2Init(nullptr);
2021-12-30 14:46:42 +01:00
free(buffer);
2021-12-28 20:17:21 +01:00
}
2021-12-29 17:02:08 +01:00
int32_t main(int32_t argc, char **argv) {
initLogging();
DEBUG_FUNCTION_LINE("Hello from Autoboot Module");
// Clear screen to avoid screen corruptions when loading the Wii U Menu
clearScreen();
2021-12-28 20:17:21 +01:00
initExternalStorage();
if (getQuickBoot()) {
deinitLogging();
2021-12-28 20:17:21 +01:00
return 0;
}
2022-03-30 16:35:12 +02:00
std::string configPath = "fs:/vol/external01/wiiu/autoboot.cfg";
if (argc >= 1) {
configPath = std::string(argv[0]) + "/autoboot.cfg";
}
int32_t bootSelection = readAutobootOption(configPath);
2021-12-28 23:16:34 +01:00
2021-12-28 20:17:21 +01:00
VPADStatus vpad{};
VPADRead(VPAD_CHAN_0, &vpad, 1, nullptr);
2021-12-28 20:17:21 +01:00
if ((bootSelection == -1) || (vpad.hold & VPAD_BUTTON_PLUS)) {
bootSelection = handleMenuScreen(configPath, bootSelection);
2021-12-28 20:17:21 +01:00
}
2021-12-28 23:16:34 +01:00
if (bootSelection >= 0) {
switch (bootSelection) {
2021-12-29 17:02:08 +01:00
case BOOT_OPTION_WII_U_MENU:
bootWiiUMenu();
break;
case BOOT_OPTION_HOMEBREW_LAUNCHER:
bootHomebrewLauncher();
break;
case BOOT_OPTION_VWII_SYSTEM_MENU:
bootvWiiMenu();
break;
case BOOT_OPTION_VWII_HOMEBREW_CHANNEL:
bootHomebrewChannel();
break;
default:
bootWiiUMenu();
break;
2021-12-28 23:16:34 +01:00
}
2021-12-29 17:02:08 +01:00
} else {
bootWiiUMenu();
2021-12-28 23:16:34 +01:00
}
2021-12-28 20:17:21 +01:00
deinitLogging();
2021-12-28 20:17:21 +01:00
return 0;
}