Add options to autoboot from disc

This commit is contained in:
jdfr228 2023-04-15 17:24:38 -04:00
parent e25c4e9643
commit 81228858bd
7 changed files with 120 additions and 6 deletions

View File

@ -22,12 +22,15 @@
#include "usbloader/MountGamePartition.h" #include "usbloader/MountGamePartition.h"
#include "usbloader/GameBooter.hpp" #include "usbloader/GameBooter.hpp"
#include "usbloader/GameList.h" #include "usbloader/GameList.h"
#include "usbloader/wdvd.h"
#include "utils/tools.h" #include "utils/tools.h"
#include "utils/ShowError.h"
#include "sys.h" #include "sys.h"
#include "svnrev.h" #include "svnrev.h"
#include "gitver.h" #include "gitver.h"
#include "usbloader/sdhc.h" #include "usbloader/sdhc.h"
#include "settings/meta.h" #include "settings/meta.h"
#include "language/gettext.h"
extern bool isWiiVC; // in sys.cpp extern bool isWiiVC; // in sys.cpp
extern u8 sdhc_mode_sd; extern u8 sdhc_mode_sd;
@ -69,6 +72,10 @@ StartUpProcess::StartUpProcess()
cancelTxt->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE); cancelTxt->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
cancelTxt->SetPosition(screenwidth / 2, screenheight / 2 + 90); cancelTxt->SetPosition(screenwidth / 2, screenheight / 2 + 90);
discCancelTxt = new GuiText("Press B to cancel", 22, (GXColor){255, 255, 255, 255});
discCancelTxt->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
discCancelTxt->SetPosition(screenwidth / 2, screenheight / 2 + 90);
trigB = new GuiTrigger; trigB = new GuiTrigger;
trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
@ -83,6 +90,7 @@ StartUpProcess::StartUpProcess()
sdmodeBtn->SetTrigger(trigA); sdmodeBtn->SetTrigger(trigA);
drawCancel = false; drawCancel = false;
drawDiscCancel = false;
} }
StartUpProcess::~StartUpProcess() StartUpProcess::~StartUpProcess()
@ -94,6 +102,7 @@ StartUpProcess::~StartUpProcess()
delete messageTxt; delete messageTxt;
delete versionTxt; delete versionTxt;
delete cancelTxt; delete cancelTxt;
delete discCancelTxt;
delete cancelBtn; delete cancelBtn;
delete sdmodeBtn; delete sdmodeBtn;
delete trigB; delete trigB;
@ -427,6 +436,41 @@ int StartUpProcess::Execute(bool quickGameBoot)
SetTextf("Checking installed MIOS\n"); SetTextf("Checking installed MIOS\n");
IosLoader::GetMIOSInfo(); IosLoader::GetMIOSInfo();
if (Settings.AutobootDiscs == ON) {
drawDiscCancel = true;
Timer countDown;
bool skipDiscAutoboot = false;
do
{
UpdatePads();
for (int i = 0; i < 4; ++i)
{
cancelBtn->Update(&userInput[i]);
}
if (cancelBtn->GetState() == STATE_CLICKED) {
skipDiscAutoboot = true;
break;
}
messageTxt->SetTextf("Autobooting from Disc in: %i sec\n", Settings.AutobootDiscsDelay - (int)countDown.elapsed());
Draw();
usleep(50000);
} while (countDown.elapsed() < (float)Settings.AutobootDiscsDelay);
drawDiscCancel = false;
if (skipDiscAutoboot == false) {
messageTxt->SetTextf("Autobooting from Disc\n");
Draw();
return this->AutobootDisc();
}
}
return FinalizeExecute();
}
int StartUpProcess::FinalizeExecute()
{
SetTextf("Loading resources\n"); SetTextf("Loading resources\n");
// Do not allow banner grid mode without AHBPROT // Do not allow banner grid mode without AHBPROT
// this function does nothing if it was already initiated before // this function does nothing if it was already initiated before
@ -459,6 +503,8 @@ void StartUpProcess::Draw()
versionTxt->Draw(); versionTxt->Draw();
if (drawCancel) if (drawCancel)
cancelTxt->Draw(); cancelTxt->Draw();
if (drawDiscCancel)
discCancelTxt->Draw();
Menu_Render(); Menu_Render();
} }
@ -481,3 +527,33 @@ int StartUpProcess::QuickGameBoot(const char *gameID)
return GameBooter::BootGame(header); return GameBooter::BootGame(header);
} }
int StartUpProcess::AutobootDisc()
{
Disc_Init();
u32 DiscDriveCover = 0;
WDVD_GetCoverStatus(&DiscDriveCover);
if (DiscDriveCover & 0x02) {
struct discHdr* header = new struct discHdr;
if (Disc_Mount(header) < 0)
{
delete header;
header = NULL;
SetTextf("Error Mounting Disc\n");
usleep(3000000); //~3 seconds in Dolphin
return FinalizeExecute();
}
else
{
GameStatistics.SetPlayCount(header->id, GameStatistics.GetPlayCount(header->id) + 1);
GameStatistics.Save();
return GameBooter::BootGame(header);
}
}
else {
return FinalizeExecute();
}
}

View File

@ -13,14 +13,17 @@ private:
~StartUpProcess(); ~StartUpProcess();
void LoadIOS(u8 ios, bool boot); void LoadIOS(u8 ios, bool boot);
int Execute(bool quickGameBoot); int Execute(bool quickGameBoot);
int FinalizeExecute();
bool USBSpinUp(); bool USBSpinUp();
void TextFade(int direction); void TextFade(int direction);
void SetTextf(const char *format, ...); void SetTextf(const char *format, ...);
void Draw(); void Draw();
static int ParseArguments(int argc, char *argv[]); static int ParseArguments(int argc, char *argv[]);
static int QuickGameBoot(const char *gameID); static int QuickGameBoot(const char *gameID);
int AutobootDisc();
bool drawCancel; bool drawCancel;
bool drawDiscCancel;
GuiImageData *GXImageData; GuiImageData *GXImageData;
GuiImage *background; GuiImage *background;
@ -29,6 +32,7 @@ private:
GuiText *messageTxt; GuiText *messageTxt;
GuiText *versionTxt; GuiText *versionTxt;
GuiText *cancelTxt; GuiText *cancelTxt;
GuiText *discCancelTxt;
GuiButton *cancelBtn; GuiButton *cancelBtn;
GuiButton *sdmodeBtn; GuiButton *sdmodeBtn;
GuiTrigger *trigB; GuiTrigger *trigB;

View File

@ -6,6 +6,7 @@
#include "usbloader/wbfs.h" #include "usbloader/wbfs.h"
#include "usbloader/disc.h" #include "usbloader/disc.h"
#include "usbloader/GameList.h" #include "usbloader/GameList.h"
#include "usbloader/wdvd.h"
#include "prompts/ProgressWindow.h" #include "prompts/ProgressWindow.h"
#include "prompts/GCMultiDiscMenu.h" #include "prompts/GCMultiDiscMenu.h"
#include "themes/CTheme.h" #include "themes/CTheme.h"
@ -218,6 +219,11 @@ int MenuInstall()
WindowPrompt(tr( "Error reading Disc" ), 0, tr( "Back" )); WindowPrompt(tr( "Error reading Disc" ), 0, tr( "Back" ));
return MENU_DISCLIST; return MENU_DISCLIST;
} }
ret = WDVD_Reset();
if (ret < 0) {
WindowPrompt(tr( "Error resetting disc drive" ), 0, tr( "Back" ));
return MENU_DISCLIST;
}
ret = Disc_Open(); ret = Disc_Open();
if (ret < 0) if (ret < 0)
{ {

View File

@ -169,6 +169,8 @@ void CSettings::SetDefault()
NandEmuMode = OFF; NandEmuMode = OFF;
NandEmuChanMode = 2; NandEmuChanMode = 2;
UseSystemFont = ON; UseSystemFont = ON;
AutobootDiscs = OFF;
AutobootDiscsDelay = 3;
Hooktype = 0; Hooktype = 0;
WiirdDebugger = OFF; WiirdDebugger = OFF;
WiirdDebuggerPause = OFF; WiirdDebuggerPause = OFF;
@ -439,6 +441,8 @@ bool CSettings::Save()
fprintf(file, "NandEmuPath = %s\n", NandEmuPath); fprintf(file, "NandEmuPath = %s\n", NandEmuPath);
fprintf(file, "NandEmuChanPath = %s\n", NandEmuChanPath); fprintf(file, "NandEmuChanPath = %s\n", NandEmuChanPath);
fprintf(file, "UseSystemFont = %d\n", UseSystemFont); fprintf(file, "UseSystemFont = %d\n", UseSystemFont);
fprintf(file, "AutobootDiscs = %d\n", AutobootDiscs);
fprintf(file, "AutobootDiscsDelay = %d\n", AutobootDiscsDelay);
fprintf(file, "Hooktype = %d\n", Hooktype); fprintf(file, "Hooktype = %d\n", Hooktype);
fprintf(file, "WiirdDebugger = %d\n", WiirdDebugger); fprintf(file, "WiirdDebugger = %d\n", WiirdDebugger);
fprintf(file, "WiirdDebuggerPause = %d\n", WiirdDebuggerPause); fprintf(file, "WiirdDebuggerPause = %d\n", WiirdDebuggerPause);
@ -867,6 +871,14 @@ bool CSettings::SetSetting(char *name, char *value)
{ {
UseSystemFont = atoi(value); UseSystemFont = atoi(value);
} }
else if (strcmp(name, "AutobootDiscs") == 0)
{
AutobootDiscs = atoi(value);
}
else if (strcmp(name, "AutobootDiscsDelay") == 0)
{
AutobootDiscsDelay = atoi(value);
}
else if(strcmp(name, "Hooktype") == 0) else if(strcmp(name, "Hooktype") == 0)
{ {
Hooktype = atoi(value); Hooktype = atoi(value);

View File

@ -175,6 +175,8 @@ class CSettings
short NandEmuMode; short NandEmuMode;
short NandEmuChanMode; short NandEmuChanMode;
short UseSystemFont; short UseSystemFont;
short AutobootDiscs;
short AutobootDiscsDelay;
short Hooktype; short Hooktype;
short WiirdDebugger; short WiirdDebugger;
short WiirdDebuggerPause; short WiirdDebuggerPause;

View File

@ -159,6 +159,8 @@ GuiSettingsMenu::GuiSettingsMenu()
Options->SetName(Idx++, "%s", tr( "Show Game Count" )); Options->SetName(Idx++, "%s", tr( "Show Game Count" ));
Options->SetName(Idx++, "%s", tr( "HOME Menu" )); Options->SetName(Idx++, "%s", tr( "HOME Menu" ));
Options->SetName(Idx++, "%s", tr( "Use System Font" )); Options->SetName(Idx++, "%s", tr( "Use System Font" ));
Options->SetName(Idx++, "%s", tr( "Autoboot Discs" ));
Options->SetName(Idx++, "%s", tr( "Autoboot Discs Delay" ));
Options->SetName(Idx++, "%s", tr( "Virtual Pointer Speed" )); Options->SetName(Idx++, "%s", tr( "Virtual Pointer Speed" ));
Options->SetName(Idx++, "%s", tr( "Adjust Overscan X" )); Options->SetName(Idx++, "%s", tr( "Adjust Overscan X" ));
Options->SetName(Idx++, "%s", tr( "Adjust Overscan Y" )); Options->SetName(Idx++, "%s", tr( "Adjust Overscan Y" ));
@ -254,6 +256,12 @@ void GuiSettingsMenu::SetOptionValues()
//! Settings: Use System Font //! Settings: Use System Font
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.UseSystemFont] )); Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.UseSystemFont] ));
//! Settings: Autoboot Discs
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.AutobootDiscs] ));
//! Settings: Autoboot Discs Delay
Options->SetValue(Idx++, "%i", Settings.AutobootDiscsDelay);
//! Settings: Virtual Pointer Speed //! Settings: Virtual Pointer Speed
Options->SetValue(Idx++, "%g", Settings.PointerSpeed); Options->SetValue(Idx++, "%g", Settings.PointerSpeed);
@ -484,6 +492,18 @@ int GuiSettingsMenu::GetMenuInternal()
Settings.FontScaleFactor = 1.0f; Settings.FontScaleFactor = 1.0f;
} }
//! Settings: Autoboot Discs
else if (ret == ++Idx)
{
if (++Settings.AutobootDiscs >= MAX_ON_OFF) Settings.AutobootDiscs = 0;
}
//! Settings: Autoboot Discs Delay
else if (ret == ++Idx)
{
if (++Settings.AutobootDiscsDelay >= 6) Settings.AutobootDiscsDelay = 0;
}
//! Settings: Virtual Pointer Speed //! Settings: Virtual Pointer Speed
else if (ret == ++Idx) else if (ret == ++Idx)
{ {

View File

@ -263,12 +263,6 @@ s32 Disc_Init(void)
s32 Disc_Open(void) s32 Disc_Open(void)
{ {
s32 ret;
/* Reset drive */
ret = WDVD_Reset();
if (ret < 0) return ret;
/* Read disc ID */ /* Read disc ID */
return WDVD_ReadDiskId(diskid); return WDVD_ReadDiskId(diskid);
} }