mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-26 04:24:16 +01:00
optimize boot sequence, more intelligent device auto-detect, network error message improvements
This commit is contained in:
parent
5b4ea2b8b5
commit
ed93edc51d
@ -234,15 +234,15 @@ bool ChangeInterface(int method, bool silent)
|
||||
WaitPrompt ("USB drive not found!");
|
||||
#endif
|
||||
}
|
||||
else if(method == METHOD_SMB)
|
||||
{
|
||||
sprintf(rootdir, "smb:/");
|
||||
mounted = ConnectShare(NOTSILENT);
|
||||
}
|
||||
else if(method == METHOD_DVD)
|
||||
{
|
||||
sprintf(rootdir, "/");
|
||||
mounted = MountDVD(NOTSILENT);
|
||||
mounted = MountDVD(silent);
|
||||
}
|
||||
else if(method == METHOD_SMB)
|
||||
{
|
||||
sprintf(rootdir, "smb:/");
|
||||
mounted = ConnectShare(silent);
|
||||
}
|
||||
|
||||
return mounted;
|
||||
|
@ -93,19 +93,21 @@ int autoLoadMethod()
|
||||
{
|
||||
ShowAction ("Attempting to determine load method...");
|
||||
|
||||
int method = 0;
|
||||
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
return METHOD_SD;
|
||||
method = METHOD_SD;
|
||||
else if(ChangeInterface(METHOD_USB, SILENT))
|
||||
return METHOD_USB;
|
||||
method = METHOD_USB;
|
||||
else if(ChangeInterface(METHOD_DVD, SILENT))
|
||||
return METHOD_DVD;
|
||||
method = METHOD_DVD;
|
||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||
return METHOD_SMB;
|
||||
method = METHOD_SMB;
|
||||
else
|
||||
{
|
||||
WaitPrompt("Unable to auto-determine load method!");
|
||||
return 0; // no method found
|
||||
}
|
||||
|
||||
GCSettings.LoadMethod = method; // save method found for later use
|
||||
return method;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -113,25 +115,28 @@ int autoLoadMethod()
|
||||
* Auto-determines and sets the save method
|
||||
* Returns method set
|
||||
****************************************************************************/
|
||||
int autoSaveMethod()
|
||||
int autoSaveMethod(bool silent)
|
||||
{
|
||||
if(!silent)
|
||||
ShowAction ("Attempting to determine save method...");
|
||||
|
||||
int method = 0;
|
||||
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
return METHOD_SD;
|
||||
method = METHOD_SD;
|
||||
else if(ChangeInterface(METHOD_USB, SILENT))
|
||||
return METHOD_USB;
|
||||
method = METHOD_USB;
|
||||
else if(TestCard(CARD_SLOTA, SILENT))
|
||||
return METHOD_MC_SLOTA;
|
||||
method = METHOD_MC_SLOTA;
|
||||
else if(TestCard(CARD_SLOTB, SILENT))
|
||||
return METHOD_MC_SLOTB;
|
||||
method = METHOD_MC_SLOTB;
|
||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||
return METHOD_SMB;
|
||||
else
|
||||
{
|
||||
method = METHOD_SMB;
|
||||
else if(!silent)
|
||||
WaitPrompt("Unable to auto-determine save method!");
|
||||
return 0; // no method found
|
||||
}
|
||||
|
||||
GCSettings.SaveMethod = method; // save method found for later use
|
||||
return method;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -43,7 +43,7 @@ void FreeSaveBuffer();
|
||||
bool MakeFilePath(char filepath[], int type, int method);
|
||||
int OpenROM (int method);
|
||||
int autoLoadMethod();
|
||||
int autoSaveMethod();
|
||||
int autoSaveMethod(bool silent);
|
||||
int FileSortCallback(const void *f1, const void *f2);
|
||||
void StripExt(char* returnstring, char * inputstring);
|
||||
|
||||
|
@ -123,6 +123,7 @@ preparePrefsData (int method)
|
||||
memcpy (savebuffer, saveicon, offset);
|
||||
|
||||
// And the comments
|
||||
memset(prefscomment, 0, 64);
|
||||
sprintf (prefscomment[0], "%s Prefs", VERSIONSTR);
|
||||
sprintf (prefscomment[1], "Preferences");
|
||||
memcpy (savebuffer + offset, prefscomment, 64);
|
||||
@ -316,7 +317,7 @@ SavePrefs (bool silent)
|
||||
|
||||
// We'll save using the first available method (probably SD) since this
|
||||
// is the method preferences will be loaded from by default
|
||||
int method = autoSaveMethod();
|
||||
int method = autoSaveMethod(silent);
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_PREF, method))
|
||||
return false;
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include "filesel.h"
|
||||
|
||||
bool networkInit = false;
|
||||
bool autoNetworkInit = true;
|
||||
bool networkShareInit = false;
|
||||
bool networkInitHalt = false;
|
||||
|
||||
/****************************************************************************
|
||||
* InitializeNetwork
|
||||
@ -36,36 +36,32 @@ bool networkInitHalt = false;
|
||||
|
||||
void InitializeNetwork(bool silent)
|
||||
{
|
||||
if(networkInit || networkInitHalt)
|
||||
// stop if we're already initialized, or if auto-init has failed before
|
||||
// in which case, manual initialization is required
|
||||
if(networkInit || !autoNetworkInit)
|
||||
return;
|
||||
|
||||
if(!silent)
|
||||
ShowAction ("Initializing network...");
|
||||
|
||||
s32 result;
|
||||
char ip[16];
|
||||
s32 initResult = if_config(ip, NULL, NULL, true);
|
||||
|
||||
while ((result = net_init()) == -EAGAIN);
|
||||
|
||||
if (result >= 0)
|
||||
{
|
||||
char myIP[16];
|
||||
|
||||
if (if_config(myIP, NULL, NULL, true) < 0)
|
||||
{
|
||||
networkInitHalt = true; // do not attempt a reconnection again
|
||||
|
||||
if(!silent)
|
||||
WaitPrompt("Error reading IP address.");
|
||||
}
|
||||
else
|
||||
if(initResult == 0)
|
||||
{
|
||||
networkInit = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// do not automatically attempt a reconnection
|
||||
autoNetworkInit = false;
|
||||
|
||||
if(!silent)
|
||||
WaitPrompt("Unable to initialize network.");
|
||||
{
|
||||
char msg[150];
|
||||
sprintf(msg, "Unable to initialize network (Error #: %i)", initResult);
|
||||
WaitPrompt(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,14 +84,32 @@ ConnectShare (bool silent)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
// check that all parameter have been set
|
||||
if(strlen(GCSettings.smbuser) == 0 ||
|
||||
strlen(GCSettings.smbpwd) == 0 ||
|
||||
strlen(GCSettings.smbshare) == 0 ||
|
||||
strlen(GCSettings.smbip) == 0)
|
||||
int chkU = (strlen(GCSettings.smbuser) > 0) ? 0:1;
|
||||
int chkP = (strlen(GCSettings.smbpwd) > 0) ? 0:1;
|
||||
int chkS = (strlen(GCSettings.smbshare) > 0) ? 0:1;
|
||||
int chkI = (strlen(GCSettings.smbip) > 0) ? 0:1;
|
||||
|
||||
// check that all parameters have been set
|
||||
if(chkU + chkP + chkS + chkI > 0)
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt("Invalid network settings. Check settings.xml.");
|
||||
{
|
||||
char msg[50];
|
||||
char msg2[100];
|
||||
if(chkU + chkP + chkS + chkI > 1) // more than one thing is wrong
|
||||
sprintf(msg, "Check settings.xml.");
|
||||
else if(chkU)
|
||||
sprintf(msg, "Username is blank.");
|
||||
else if(chkP)
|
||||
sprintf(msg, "Password is blank.");
|
||||
else if(chkS)
|
||||
sprintf(msg, "Share name is blank.");
|
||||
else if(chkI)
|
||||
sprintf(msg, "Share IP is blank.");
|
||||
|
||||
sprintf(msg2, "Invalid network settings - %s", msg);
|
||||
WaitPrompt(msg2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -167,17 +167,18 @@ int main(int argc, char *argv[])
|
||||
DI_Init(); // first
|
||||
#endif
|
||||
|
||||
InitDeviceThread();
|
||||
|
||||
// Initialise controllers
|
||||
PAD_Init ();
|
||||
|
||||
#ifdef HW_RVL
|
||||
WPAD_Init();
|
||||
// read wiimote accelerometer and IR data
|
||||
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
||||
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
|
||||
#endif
|
||||
PAD_Init ();
|
||||
|
||||
// Wii Power/Reset buttons
|
||||
#ifdef HW_RVL
|
||||
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
|
||||
SYS_SetPowerCallback(ShutdownCB);
|
||||
SYS_SetResetCallback(ResetCB);
|
||||
@ -197,7 +198,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Initialize libFAT for SD and USB
|
||||
MountAllFAT();
|
||||
InitDeviceThread();
|
||||
|
||||
// Initialize DVD subsystem (GameCube only)
|
||||
#ifdef HW_DOL
|
||||
|
@ -261,7 +261,7 @@ bool LoadBatteryOrState(int method, int action, bool silent)
|
||||
int offset = 0;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(); // we use 'Save' because we need R/W
|
||||
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
||||
|
||||
if(!MakeFilePath(filepath, action, method))
|
||||
return false;
|
||||
@ -336,7 +336,7 @@ bool SaveBatteryOrState(int method, int action, bool silent)
|
||||
int datasize = 0; // we need the actual size of the data written
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod();
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(!MakeFilePath(filepath, action, method))
|
||||
return false;
|
||||
@ -349,6 +349,7 @@ bool SaveBatteryOrState(int method, int action, bool silent)
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
{
|
||||
char savecomment[2][32];
|
||||
memset(savecomment, 0, 64);
|
||||
char savetype[10];
|
||||
|
||||
offset = sizeof (saveicon);
|
||||
|
Loading…
Reference in New Issue
Block a user