2010-12-31 00:49:22 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
#include "StartUpProcess.h"
|
2011-06-14 19:53:19 +02:00
|
|
|
#include "GUI/gui.h"
|
2010-12-31 00:49:22 +01:00
|
|
|
#include "video.h"
|
|
|
|
#include "audio.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "themes/CTheme.h"
|
|
|
|
#include "gecko.h"
|
2019-11-11 21:00:00 +01:00
|
|
|
#include "wpad.h"
|
2010-12-31 00:49:22 +01:00
|
|
|
#include "Controls/DeviceHandler.hpp"
|
|
|
|
#include "wad/nandtitle.h"
|
2012-05-06 12:59:58 +02:00
|
|
|
#include "SystemMenu/SystemMenuResources.h"
|
2010-12-31 00:49:22 +01:00
|
|
|
#include "system/IosLoader.h"
|
2019-08-26 19:53:21 +02:00
|
|
|
#include "libs/libruntimeiospatch/runtimeiospatch.h"
|
2011-05-28 21:52:00 +02:00
|
|
|
#include "utils/timer.h"
|
2010-12-31 00:49:22 +01:00
|
|
|
#include "settings/CSettings.h"
|
|
|
|
#include "settings/CGameSettings.h"
|
|
|
|
#include "settings/CGameStatistics.h"
|
2011-06-03 22:31:09 +02:00
|
|
|
#include "settings/CGameCategories.hpp"
|
2012-01-08 19:24:46 +01:00
|
|
|
#include "settings/GameTitles.h"
|
2010-12-31 00:49:22 +01:00
|
|
|
#include "usbloader/usbstorage2.h"
|
2011-06-14 19:53:19 +02:00
|
|
|
#include "usbloader/MountGamePartition.h"
|
|
|
|
#include "usbloader/GameBooter.hpp"
|
|
|
|
#include "usbloader/GameList.h"
|
|
|
|
#include "utils/tools.h"
|
2010-12-31 00:49:22 +01:00
|
|
|
#include "sys.h"
|
2015-04-04 18:04:30 +02:00
|
|
|
#include "svnrev.h"
|
2020-07-09 03:12:46 +02:00
|
|
|
#include "gitver.h"
|
2010-12-31 00:49:22 +01:00
|
|
|
|
2019-08-26 19:53:21 +02:00
|
|
|
extern bool isWiiVC; // in sys.cpp
|
|
|
|
|
2010-12-31 00:49:22 +01:00
|
|
|
StartUpProcess::StartUpProcess()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
//! Load default font for the next text outputs
|
|
|
|
Theme::LoadFont("");
|
2010-12-31 00:49:22 +01:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
background = new GuiImage(screenwidth, screenheight, (GXColor){0, 0, 0, 255});
|
2010-12-31 00:49:22 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
GXImageData = Resources::GetImageData("gxlogo.png");
|
|
|
|
GXImage = new GuiImage(GXImageData);
|
|
|
|
GXImage->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
|
2021-08-01 19:00:42 +02:00
|
|
|
GXImage->SetPosition(screenwidth / 2, screenheight / 2 - 50);
|
2010-12-31 00:49:22 +01:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
titleTxt = new GuiText("Loading...", 24, (GXColor){255, 255, 255, 255});
|
2011-07-26 00:28:22 +02:00
|
|
|
titleTxt->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
|
2021-08-01 19:00:42 +02:00
|
|
|
titleTxt->SetPosition(screenwidth / 2, screenheight / 2 + 30);
|
2010-12-31 00:49:22 +01:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
messageTxt = new GuiText(" ", 22, (GXColor){255, 255, 255, 255});
|
2011-07-26 00:28:22 +02:00
|
|
|
messageTxt->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
|
2021-08-01 19:00:42 +02:00
|
|
|
messageTxt->SetPosition(screenwidth / 2, screenheight / 2 + 60);
|
2011-11-20 11:46:07 +01:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
versionTxt = new GuiText(" ", 18, (GXColor){255, 255, 255, 255});
|
2015-04-04 18:04:30 +02:00
|
|
|
versionTxt->SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
|
2021-08-01 19:00:42 +02:00
|
|
|
versionTxt->SetPosition(20, screenheight - 20);
|
2015-04-04 18:04:30 +02:00
|
|
|
|
|
|
|
#ifdef FULLCHANNEL
|
2020-07-09 03:12:46 +02:00
|
|
|
versionTxt->SetTextf("v3.0c Rev. %s (%s)", GetRev(), commitID());
|
2015-04-04 18:04:30 +02:00
|
|
|
#else
|
2020-07-09 03:12:46 +02:00
|
|
|
versionTxt->SetTextf("v3.0 Rev. %s (%s)", GetRev(), commitID());
|
2015-04-04 18:04:30 +02:00
|
|
|
#endif
|
|
|
|
|
2019-08-26 19:53:21 +02:00
|
|
|
#if 1 // enable if you release a modded version - enabled by default to differentiate official releases
|
2020-07-09 03:12:46 +02:00
|
|
|
versionTxt->SetTextf("v3.0 Rev. %s mod (%s)", GetRev(), commitID());
|
2015-04-04 18:04:30 +02:00
|
|
|
#endif
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
cancelTxt = new GuiText("Press B to cancel", 18, (GXColor){255, 255, 255, 255});
|
2011-11-20 11:46:07 +01:00
|
|
|
cancelTxt->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
|
2021-08-01 19:00:42 +02:00
|
|
|
cancelTxt->SetPosition(screenwidth / 2, screenheight / 2 + 90);
|
2011-11-20 11:46:07 +01:00
|
|
|
|
|
|
|
trigB = new GuiTrigger;
|
|
|
|
trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
|
|
|
|
|
|
|
|
cancelBtn = new GuiButton(0, 0);
|
|
|
|
cancelBtn->SetTrigger(trigB);
|
|
|
|
|
|
|
|
drawCancel = false;
|
2010-12-31 00:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
StartUpProcess::~StartUpProcess()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
delete background;
|
|
|
|
delete GXImageData;
|
|
|
|
delete GXImage;
|
|
|
|
delete titleTxt;
|
2011-12-28 10:55:00 +01:00
|
|
|
delete messageTxt;
|
2015-04-04 18:04:30 +02:00
|
|
|
delete versionTxt;
|
2011-11-20 11:46:07 +01:00
|
|
|
delete cancelTxt;
|
|
|
|
delete cancelBtn;
|
|
|
|
delete trigB;
|
2010-12-31 00:49:22 +01:00
|
|
|
}
|
|
|
|
|
2011-06-14 19:53:19 +02:00
|
|
|
int StartUpProcess::ParseArguments(int argc, char *argv[])
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
int quickBoot = -1;
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
//! The arguments override
|
2021-08-01 19:00:42 +02:00
|
|
|
for (int i = 0; i < argc; ++i)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
if (!argv[i])
|
|
|
|
continue;
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
gprintf("Boot argument %i: %s\n", i + 1, argv[i]);
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
char *ptr = strcasestr(argv[i], "-bootios=");
|
|
|
|
if (ptr)
|
2013-10-01 23:13:08 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
if (atoi(ptr + strlen("-bootios=")) == 58)
|
2013-10-01 23:13:08 +02:00
|
|
|
Settings.LoaderIOS = 58;
|
|
|
|
else
|
2021-08-01 19:00:42 +02:00
|
|
|
Settings.LoaderIOS = LIMIT(atoi(ptr + strlen("-bootios=")), 200, 255);
|
2013-10-01 23:13:08 +02:00
|
|
|
Settings.UseArgumentIOS = ON;
|
2021-08-01 19:00:42 +02:00
|
|
|
Settings.BootIOS = Settings.LoaderIOS;
|
2013-10-01 23:13:08 +02:00
|
|
|
}
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
ptr = strcasestr(argv[i], "-usbport=");
|
2021-08-01 19:00:42 +02:00
|
|
|
if (ptr)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
Settings.USBPort = LIMIT(atoi(ptr + strlen("-usbport=")), 0, 2);
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2014-05-04 16:42:52 +02:00
|
|
|
ptr = strcasestr(argv[i], "-mountusb=");
|
2021-08-01 19:00:42 +02:00
|
|
|
if (ptr)
|
2014-05-04 16:42:52 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
Settings.USBAutoMount = LIMIT(atoi(ptr + strlen("-mountusb=")), 0, 1);
|
2014-05-04 16:42:52 +02:00
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
if (strlen(argv[i]) == 6 && strchr(argv[i], '=') == 0 && strchr(argv[i], '-') == 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
quickBoot = i;
|
|
|
|
}
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return quickBoot;
|
2011-06-14 19:53:19 +02:00
|
|
|
}
|
|
|
|
|
2010-12-31 00:49:22 +01:00
|
|
|
void StartUpProcess::TextFade(int direction)
|
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
if (direction > 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
for (int i = 0; i < 255; i += direction)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
|
|
|
messageTxt->SetAlpha(i);
|
|
|
|
Draw();
|
|
|
|
}
|
|
|
|
messageTxt->SetAlpha(255);
|
|
|
|
Draw();
|
|
|
|
}
|
2021-08-01 19:00:42 +02:00
|
|
|
else if (direction < 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
for (int i = 255; i > 0; i += direction)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
|
|
|
messageTxt->SetAlpha(i);
|
|
|
|
Draw();
|
|
|
|
}
|
|
|
|
messageTxt->SetAlpha(0);
|
|
|
|
Draw();
|
|
|
|
}
|
2010-12-31 00:49:22 +01:00
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
void StartUpProcess::SetTextf(const char *format, ...)
|
2010-12-31 00:49:22 +01:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
char *tmp = NULL;
|
2010-12-31 00:49:22 +01:00
|
|
|
va_list va;
|
|
|
|
va_start(va, format);
|
2021-08-01 19:00:42 +02:00
|
|
|
if ((vasprintf(&tmp, format, va) >= 0) && tmp)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
|
|
|
TextFade(-40);
|
|
|
|
gprintf(tmp);
|
|
|
|
messageTxt->SetText(tmp);
|
|
|
|
TextFade(40);
|
2010-12-31 00:49:22 +01:00
|
|
|
}
|
|
|
|
va_end(va);
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
if (tmp)
|
2011-07-26 00:28:22 +02:00
|
|
|
free(tmp);
|
2010-12-31 00:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool StartUpProcess::USBSpinUp()
|
|
|
|
{
|
2011-11-20 11:46:07 +01:00
|
|
|
drawCancel = true;
|
2011-07-26 00:28:22 +02:00
|
|
|
Timer countDown;
|
2013-03-17 14:48:15 +01:00
|
|
|
bool started0 = false;
|
|
|
|
bool started1 = false;
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
const DISC_INTERFACE *handle0 = NULL;
|
|
|
|
const DISC_INTERFACE *handle1 = NULL;
|
|
|
|
if (Settings.USBPort == 0 || Settings.USBPort == 2)
|
2013-03-17 14:48:15 +01:00
|
|
|
handle0 = DeviceHandler::GetUSB0Interface();
|
2021-08-01 19:00:42 +02:00
|
|
|
if (Settings.USBPort == 1 || Settings.USBPort == 2)
|
2013-03-17 14:48:15 +01:00
|
|
|
handle1 = DeviceHandler::GetUSB1Interface();
|
2021-08-01 19:00:42 +02:00
|
|
|
|
2011-11-20 11:46:07 +01:00
|
|
|
// wait 20 sec for the USB to spin up...stupid slow ass HDD
|
2011-07-26 00:28:22 +02:00
|
|
|
do
|
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
if (handle0)
|
2013-03-17 14:48:15 +01:00
|
|
|
started0 = (handle0->startup() && handle0->isInserted());
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
if (handle1)
|
2013-03-17 14:48:15 +01:00
|
|
|
started1 = (handle1->startup() && handle1->isInserted());
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
if ((!handle0 || started0) && (!handle1 || started1))
|
2011-07-26 00:28:22 +02:00
|
|
|
break;
|
2011-11-20 11:46:07 +01:00
|
|
|
|
|
|
|
UpdatePads();
|
2021-08-01 19:00:42 +02:00
|
|
|
for (int i = 0; i < 4; ++i)
|
2011-11-20 11:46:07 +01:00
|
|
|
cancelBtn->Update(&userInput[i]);
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
if (cancelBtn->GetState() == STATE_CLICKED)
|
2011-11-20 11:46:07 +01:00
|
|
|
break;
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
messageTxt->SetTextf("Waiting for HDD: %i sec left\n", 20 - (int)countDown.elapsed());
|
2011-07-26 00:28:22 +02:00
|
|
|
Draw();
|
|
|
|
usleep(50000);
|
2021-08-01 19:00:42 +02:00
|
|
|
} while (countDown.elapsed() < 20.f);
|
2011-07-26 00:28:22 +02:00
|
|
|
|
2011-11-20 11:46:07 +01:00
|
|
|
drawCancel = false;
|
|
|
|
|
2013-03-17 14:48:15 +01:00
|
|
|
return (started0 || started1);
|
2010-12-31 00:49:22 +01:00
|
|
|
}
|
|
|
|
|
2011-06-14 19:53:19 +02:00
|
|
|
int StartUpProcess::Run(int argc, char *argv[])
|
2010-12-31 00:49:22 +01:00
|
|
|
{
|
2023-01-01 18:00:30 +01:00
|
|
|
// A normal launch should always have the first arg be the path
|
|
|
|
char *ptr = strrchr(argv[0], '/');
|
|
|
|
if (ptr && (argv[0][2] == ':' || argv[0][3] == ':'))
|
|
|
|
{
|
|
|
|
*ptr = 0;
|
|
|
|
// HBC doesn't specify the USB port
|
|
|
|
if (strncmp(argv[0], "usb", 3) == 0)
|
|
|
|
{
|
|
|
|
snprintf(Settings.BootDevice, sizeof(Settings.BootDevice), "usb1");
|
|
|
|
snprintf(Settings.ConfigPath, sizeof(Settings.ConfigPath), "usb1:%s/", argv[0] + 4);
|
|
|
|
}
|
|
|
|
else if (strncmp(argv[0], "sd", 2) == 0)
|
|
|
|
snprintf(Settings.ConfigPath, sizeof(Settings.ConfigPath), "%s/", argv[0]);
|
|
|
|
gprintf("Loader path: %s\n", Settings.ConfigPath);
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
int quickGameBoot = ParseArguments(argc, argv);
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
StartUpProcess Process;
|
2010-12-31 00:49:22 +01:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
int ret = Process.Execute(quickGameBoot != -1);
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
if (quickGameBoot != -1)
|
2011-07-26 00:28:22 +02:00
|
|
|
return QuickGameBoot(argv[quickGameBoot]);
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return ret;
|
2010-12-31 00:49:22 +01:00
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
int StartUpProcess::Execute(bool quickGameBoot)
|
2010-12-31 00:49:22 +01:00
|
|
|
{
|
2011-07-23 21:49:51 +02:00
|
|
|
Settings.EntryIOS = IOS_GetVersion();
|
2021-08-01 19:00:42 +02:00
|
|
|
// Disable AHBPROT
|
|
|
|
IosLoader::PatchAHB();
|
|
|
|
gprintf("Current IOS: %d - have AHB access: %s\n", Settings.EntryIOS, AHBPROT_DISABLED ? "yes" : "no");
|
|
|
|
// Reload to a cIOS if required (old forwarder?) or requested
|
|
|
|
if (!AHBPROT_DISABLED || (Settings.EntryIOS != Settings.BootIOS))
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
SetTextf("Reloading to cIOS %d%s\n", Settings.LoaderIOS, Settings.UseArgumentIOS ? "requested in meta.xml" : "");
|
|
|
|
if (IosLoader::LoadAppCios(Settings.LoaderIOS) < 0)
|
2013-10-01 23:13:08 +02:00
|
|
|
{
|
2021-02-04 17:23:14 +01:00
|
|
|
SetTextf("Failed to load an IOS. USB Loader GX requires a cIOS or IOS58 with AHB access. Exiting...\n");
|
2014-04-25 17:34:53 +02:00
|
|
|
sleep(5);
|
|
|
|
Sys_BackToLoader();
|
|
|
|
}
|
2021-08-01 19:00:42 +02:00
|
|
|
SetTextf("Reloaded to cIOS %d\n", Settings.LoaderIOS);
|
|
|
|
gprintf("Current IOS: %d - have AHB access: %s\n", IOS_GetVersion(), AHBPROT_DISABLED ? "yes" : "no");
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2019-11-11 21:00:00 +01:00
|
|
|
|
2011-11-20 11:46:07 +01:00
|
|
|
SetupPads();
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
SetTextf("Initializing SD card\n");
|
2011-07-26 00:28:22 +02:00
|
|
|
DeviceHandler::Instance()->MountSD();
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
// Do not mount USB if not needed. USB is not available with WiiU WiiVC injected channel
|
|
|
|
if (Settings.USBAutoMount == ON && !isWiiVC)
|
2014-04-25 17:34:53 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
SetTextf("Initializing USB devices\n");
|
2014-04-25 17:34:53 +02:00
|
|
|
USBSpinUp();
|
|
|
|
DeviceHandler::Instance()->MountAllUSB(false);
|
2021-08-01 19:00:42 +02:00
|
|
|
gprintf("Completed initialization of USB devices\n");
|
2014-04-25 17:34:53 +02:00
|
|
|
}
|
2020-12-12 22:34:07 +01:00
|
|
|
|
2014-05-04 16:42:52 +02:00
|
|
|
SetTextf("Loading config files\n");
|
|
|
|
gprintf("\tLoading config...%s\n", Settings.Load() ? "done" : "failed");
|
2011-07-26 00:28:22 +02:00
|
|
|
gprintf("\tLoading language...%s\n", Settings.LoadLanguage(Settings.language_path, CONSOLE_DEFAULT) ? "done" : "failed");
|
|
|
|
gprintf("\tLoading game settings...%s\n", GameSettings.Load(Settings.ConfigPath) ? "done" : "failed");
|
|
|
|
gprintf("\tLoading game statistics...%s\n", GameStatistics.Load(Settings.ConfigPath) ? "done" : "failed");
|
2013-10-01 23:13:08 +02:00
|
|
|
gprintf("\tLoading game categories...%s\n", GameCategories.Load(Settings.ConfigPath) ? "done" : "failed");
|
2023-01-01 18:00:14 +01:00
|
|
|
gprintf("\tLoading cached titles...%s\n", GameTitles.ReadCachedTitles(Settings.titlestxt_path) ? "done" : "failed (using default)");
|
2020-12-12 22:34:07 +01:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
// Some settings need to be enabled to boot directly into games
|
|
|
|
gprintf("Quick game boot: %s\n", quickGameBoot ? "yes" : "no");
|
|
|
|
if (quickGameBoot)
|
|
|
|
{
|
|
|
|
Settings.USBAutoMount = ON;
|
|
|
|
Settings.LoaderMode = MODE_ALL;
|
|
|
|
Settings.skipSaving = true;
|
|
|
|
}
|
|
|
|
|
2020-12-12 22:34:07 +01:00
|
|
|
// Reload to users settings if different than current IOS, and if not using an injected WiiU WiiVC IOS255 (fw.img)
|
2021-08-01 19:00:42 +02:00
|
|
|
if (Settings.LoaderIOS != IOS_GetVersion() && !isWiiVC)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
// Shutdown pads
|
|
|
|
sleep(1); // Some Wiimotes won't reconnect as player 1 without this
|
|
|
|
Wpad_Disconnect();
|
|
|
|
|
2011-11-20 11:46:07 +01:00
|
|
|
// Unmount devices
|
2011-07-26 00:28:22 +02:00
|
|
|
DeviceHandler::DestroyInstance();
|
2021-08-01 19:00:42 +02:00
|
|
|
if (Settings.USBAutoMount == ON)
|
2014-04-25 17:34:53 +02:00
|
|
|
USBStorage2_Deinit();
|
2011-07-26 00:28:22 +02:00
|
|
|
|
2021-02-04 17:23:14 +01:00
|
|
|
// Now load the cIOS that was set in the settings menu
|
2021-08-01 19:00:42 +02:00
|
|
|
if (IosLoader::LoadAppCios(Settings.LoaderIOS) > -1)
|
2020-12-20 21:30:02 +01:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
SetTextf("Reloaded to %s%d r%d\n", IOS_GetVersion() >= 200 ? "cIOS " : "IOS", Settings.LoaderIOS, IOS_GetRevision());
|
2020-12-20 21:30:02 +01:00
|
|
|
// Re-Mount devices
|
|
|
|
SetTextf("Reinitializing devices\n");
|
|
|
|
}
|
2021-08-01 19:00:42 +02:00
|
|
|
gprintf("Current IOS: %d - have AHB access: %s\n", IOS_GetVersion(), AHBPROT_DISABLED ? "yes" : "no");
|
2021-04-04 20:00:03 +02:00
|
|
|
|
|
|
|
// Start pads again
|
|
|
|
SetupPads();
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
DeviceHandler::Instance()->MountSD();
|
2021-08-01 19:00:42 +02:00
|
|
|
if (Settings.USBAutoMount == ON)
|
2014-04-25 17:34:53 +02:00
|
|
|
{
|
|
|
|
USBSpinUp();
|
|
|
|
DeviceHandler::Instance()->MountAllUSB(false);
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
if (!IosLoader::IsHermesIOS() && !IosLoader::IsD2X())
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
|
|
|
Settings.USBPort = 0;
|
|
|
|
}
|
2021-08-01 19:00:42 +02:00
|
|
|
else if (Settings.USBPort == 1 && USBStorage2_GetPort() != Settings.USBPort)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
if (Settings.USBAutoMount == ON && !isWiiVC)
|
2014-04-25 17:34:53 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
SetTextf("Changing USB port to %i\n", Settings.USBPort);
|
2014-04-25 17:34:53 +02:00
|
|
|
DeviceHandler::Instance()->UnMountAllUSB();
|
|
|
|
DeviceHandler::Instance()->MountAllUSB();
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2021-08-01 19:00:42 +02:00
|
|
|
else if (Settings.USBPort == 2)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
if (Settings.USBAutoMount == ON && !isWiiVC)
|
2014-04-25 17:34:53 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
SetTextf("Mounting USB port to 1\n");
|
2014-04-25 17:34:53 +02:00
|
|
|
DeviceHandler::Instance()->MountUSBPort1();
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2020-12-12 22:34:07 +01:00
|
|
|
|
|
|
|
// Enable isfs permission if using Hermes v4 without AHB, or WiiU WiiVC (IOS255 fw.img)
|
2021-08-01 19:00:42 +02:00
|
|
|
if (IOS_GetVersion() < 200 || (IosLoader::IsHermesIOS() && IOS_GetRevision() == 4) || isWiiVC)
|
2013-10-01 23:13:08 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
SetTextf("Patching %s%d\n", IOS_GetVersion() >= 200 ? "cIOS " : "IOS", IOS_GetVersion());
|
2019-08-26 19:53:21 +02:00
|
|
|
if (IosPatch_RUNTIME(!isWiiVC, false, false, isWiiVC, false) == ERROR_PATCH)
|
2021-08-01 19:00:42 +02:00
|
|
|
gprintf("Patching %sIOS%d failed!\n", IOS_GetVersion() >= 200 ? "c" : "", IOS_GetVersion());
|
2013-10-01 23:13:08 +02:00
|
|
|
else
|
|
|
|
NandTitles.Get(); // get NAND channel's titles
|
2011-07-26 00:28:22 +02:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
gprintf("Current IOS: %d - have AHB access: %s\n", IOS_GetVersion(), AHBPROT_DISABLED ? "yes" : "no");
|
|
|
|
}
|
2021-02-04 17:23:14 +01:00
|
|
|
|
2011-12-22 23:44:48 +01:00
|
|
|
// We only initialize once for the whole session
|
|
|
|
ISFS_Initialize();
|
|
|
|
|
2013-10-01 23:13:08 +02:00
|
|
|
// Check MIOS version
|
2020-12-12 22:34:07 +01:00
|
|
|
SetTextf("Checking installed MIOS\n");
|
2013-10-01 23:13:08 +02:00
|
|
|
IosLoader::GetMIOSInfo();
|
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
SetTextf("Loading resources\n");
|
|
|
|
// Do not allow banner grid mode without AHBPROT
|
|
|
|
// this function does nothing if it was already initiated before
|
2021-08-01 19:00:42 +02:00
|
|
|
if (!SystemMenuResources::Instance()->IsLoaded() && !SystemMenuResources::Instance()->Init()
|
2012-05-06 12:59:58 +02:00
|
|
|
&& Settings.gameDisplay == BANNERGRID_MODE)
|
|
|
|
{
|
|
|
|
Settings.gameDisplay = LIST_MODE;
|
|
|
|
Settings.GameWindowMode = GAMEWINDOW_DISC;
|
|
|
|
}
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
gprintf("\tLoading font...%s\n", Theme::LoadFont(Settings.ConfigPath) ? "done" : "failed (using default)");
|
|
|
|
gprintf("\tLoading theme...%s\n", Theme::Load(Settings.theme) ? "done" : "failed (using default)");
|
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
//! Init the rest of the system
|
2011-07-26 00:28:22 +02:00
|
|
|
Sys_Init();
|
|
|
|
InitAudio();
|
2021-08-01 19:00:18 +02:00
|
|
|
setlocale(LC_CTYPE, "en_US.UTF-8");
|
|
|
|
setlocale(LC_MESSAGES, "en_US.UTF-8");
|
2012-02-05 19:38:26 +01:00
|
|
|
AdjustOverscan(Settings.AdjustOverscanX, Settings.AdjustOverscanY);
|
2011-07-26 00:28:22 +02:00
|
|
|
|
|
|
|
return 0;
|
2010-12-31 00:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void StartUpProcess::Draw()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
background->Draw();
|
|
|
|
GXImage->Draw();
|
|
|
|
titleTxt->Draw();
|
|
|
|
messageTxt->Draw();
|
2015-04-04 18:04:30 +02:00
|
|
|
versionTxt->Draw();
|
2021-08-01 19:00:42 +02:00
|
|
|
if (drawCancel)
|
2011-11-20 11:46:07 +01:00
|
|
|
cancelTxt->Draw();
|
2011-07-26 00:28:22 +02:00
|
|
|
Menu_Render();
|
2010-12-31 00:49:22 +01:00
|
|
|
}
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
int StartUpProcess::QuickGameBoot(const char *gameID)
|
2011-06-14 19:53:19 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
MountGamePartition(false);
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
struct discHdr *header = NULL;
|
2021-08-01 19:00:42 +02:00
|
|
|
for (int i = 0; i < gameList.size(); ++i)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2021-08-01 19:00:42 +02:00
|
|
|
if (strncasecmp((char *)gameList[i]->id, gameID, 6) == 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
header = gameList[i];
|
|
|
|
}
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
if (!header)
|
2011-07-26 00:28:22 +02:00
|
|
|
return -1;
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2021-08-01 19:00:42 +02:00
|
|
|
GameStatistics.SetPlayCount(header->id, GameStatistics.GetPlayCount(header->id) + 1);
|
2011-07-26 00:28:22 +02:00
|
|
|
GameStatistics.Save();
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2011-12-22 23:44:48 +01:00
|
|
|
return GameBooter::BootGame(header);
|
2011-06-14 19:53:19 +02:00
|
|
|
}
|