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/GameBooter.hpp"
#include "usbloader/GameList.h"
#include "usbloader/wdvd.h"
#include "utils/tools.h"
#include "utils/ShowError.h"
#include "sys.h"
#include "svnrev.h"
#include "gitver.h"
#include "usbloader/sdhc.h"
#include "settings/meta.h"
#include "language/gettext.h"
extern bool isWiiVC; // in sys.cpp
extern u8 sdhc_mode_sd;
@ -69,6 +72,10 @@ StartUpProcess::StartUpProcess()
cancelTxt->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
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->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
@ -83,6 +90,7 @@ StartUpProcess::StartUpProcess()
sdmodeBtn->SetTrigger(trigA);
drawCancel = false;
drawDiscCancel = false;
}
StartUpProcess::~StartUpProcess()
@ -94,6 +102,7 @@ StartUpProcess::~StartUpProcess()
delete messageTxt;
delete versionTxt;
delete cancelTxt;
delete discCancelTxt;
delete cancelBtn;
delete sdmodeBtn;
delete trigB;
@ -427,6 +436,41 @@ int StartUpProcess::Execute(bool quickGameBoot)
SetTextf("Checking installed MIOS\n");
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");
// Do not allow banner grid mode without AHBPROT
// this function does nothing if it was already initiated before
@ -459,6 +503,8 @@ void StartUpProcess::Draw()
versionTxt->Draw();
if (drawCancel)
cancelTxt->Draw();
if (drawDiscCancel)
discCancelTxt->Draw();
Menu_Render();
}
@ -481,3 +527,33 @@ int StartUpProcess::QuickGameBoot(const char *gameID)
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();
void LoadIOS(u8 ios, bool boot);
int Execute(bool quickGameBoot);
int FinalizeExecute();
bool USBSpinUp();
void TextFade(int direction);
void SetTextf(const char *format, ...);
void Draw();
static int ParseArguments(int argc, char *argv[]);
static int QuickGameBoot(const char *gameID);
int AutobootDisc();
bool drawCancel;
bool drawDiscCancel;
GuiImageData *GXImageData;
GuiImage *background;
@ -29,6 +32,7 @@ private:
GuiText *messageTxt;
GuiText *versionTxt;
GuiText *cancelTxt;
GuiText *discCancelTxt;
GuiButton *cancelBtn;
GuiButton *sdmodeBtn;
GuiTrigger *trigB;

View File

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

View File

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

View File

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

View File

@ -159,6 +159,8 @@ GuiSettingsMenu::GuiSettingsMenu()
Options->SetName(Idx++, "%s", tr( "Show Game Count" ));
Options->SetName(Idx++, "%s", tr( "HOME Menu" ));
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( "Adjust Overscan X" ));
Options->SetName(Idx++, "%s", tr( "Adjust Overscan Y" ));
@ -254,6 +256,12 @@ void GuiSettingsMenu::SetOptionValues()
//! Settings: Use System Font
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
Options->SetValue(Idx++, "%g", Settings.PointerSpeed);
@ -484,6 +492,18 @@ int GuiSettingsMenu::GetMenuInternal()
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
else if (ret == ++Idx)
{

View File

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