optimize boot sequence, more intelligent device auto-detect, network error message improvements

This commit is contained in:
dborth 2008-12-22 09:23:48 +00:00
parent 5b4ea2b8b5
commit ed93edc51d
7 changed files with 79 additions and 58 deletions

View File

@ -234,15 +234,15 @@ bool ChangeInterface(int method, bool silent)
WaitPrompt ("USB drive not found!"); WaitPrompt ("USB drive not found!");
#endif #endif
} }
else if(method == METHOD_SMB)
{
sprintf(rootdir, "smb:/");
mounted = ConnectShare(NOTSILENT);
}
else if(method == METHOD_DVD) else if(method == METHOD_DVD)
{ {
sprintf(rootdir, "/"); sprintf(rootdir, "/");
mounted = MountDVD(NOTSILENT); mounted = MountDVD(silent);
}
else if(method == METHOD_SMB)
{
sprintf(rootdir, "smb:/");
mounted = ConnectShare(silent);
} }
return mounted; return mounted;

View File

@ -93,19 +93,21 @@ int autoLoadMethod()
{ {
ShowAction ("Attempting to determine load method..."); ShowAction ("Attempting to determine load method...");
int method = 0;
if(ChangeInterface(METHOD_SD, SILENT)) if(ChangeInterface(METHOD_SD, SILENT))
return METHOD_SD; method = METHOD_SD;
else if(ChangeInterface(METHOD_USB, SILENT)) else if(ChangeInterface(METHOD_USB, SILENT))
return METHOD_USB; method = METHOD_USB;
else if(ChangeInterface(METHOD_DVD, SILENT)) else if(ChangeInterface(METHOD_DVD, SILENT))
return METHOD_DVD; method = METHOD_DVD;
else if(ChangeInterface(METHOD_SMB, SILENT)) else if(ChangeInterface(METHOD_SMB, SILENT))
return METHOD_SMB; method = METHOD_SMB;
else else
{
WaitPrompt("Unable to auto-determine load method!"); 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 * Auto-determines and sets the save method
* Returns method set * Returns method set
****************************************************************************/ ****************************************************************************/
int autoSaveMethod() int autoSaveMethod(bool silent)
{ {
ShowAction ("Attempting to determine save method..."); if(!silent)
ShowAction ("Attempting to determine save method...");
int method = 0;
if(ChangeInterface(METHOD_SD, SILENT)) if(ChangeInterface(METHOD_SD, SILENT))
return METHOD_SD; method = METHOD_SD;
else if(ChangeInterface(METHOD_USB, SILENT)) else if(ChangeInterface(METHOD_USB, SILENT))
return METHOD_USB; method = METHOD_USB;
else if(TestCard(CARD_SLOTA, SILENT)) else if(TestCard(CARD_SLOTA, SILENT))
return METHOD_MC_SLOTA; method = METHOD_MC_SLOTA;
else if(TestCard(CARD_SLOTB, SILENT)) else if(TestCard(CARD_SLOTB, SILENT))
return METHOD_MC_SLOTB; method = METHOD_MC_SLOTB;
else if(ChangeInterface(METHOD_SMB, SILENT)) else if(ChangeInterface(METHOD_SMB, SILENT))
return METHOD_SMB; method = METHOD_SMB;
else else if(!silent)
{
WaitPrompt("Unable to auto-determine save method!"); WaitPrompt("Unable to auto-determine save method!");
return 0; // no method found
} GCSettings.SaveMethod = method; // save method found for later use
return method;
} }
/**************************************************************************** /****************************************************************************

View File

@ -43,7 +43,7 @@ void FreeSaveBuffer();
bool MakeFilePath(char filepath[], int type, int method); bool MakeFilePath(char filepath[], int type, int method);
int OpenROM (int method); int OpenROM (int method);
int autoLoadMethod(); int autoLoadMethod();
int autoSaveMethod(); int autoSaveMethod(bool silent);
int FileSortCallback(const void *f1, const void *f2); int FileSortCallback(const void *f1, const void *f2);
void StripExt(char* returnstring, char * inputstring); void StripExt(char* returnstring, char * inputstring);

View File

@ -123,6 +123,7 @@ preparePrefsData (int method)
memcpy (savebuffer, saveicon, offset); memcpy (savebuffer, saveicon, offset);
// And the comments // And the comments
memset(prefscomment, 0, 64);
sprintf (prefscomment[0], "%s Prefs", VERSIONSTR); sprintf (prefscomment[0], "%s Prefs", VERSIONSTR);
sprintf (prefscomment[1], "Preferences"); sprintf (prefscomment[1], "Preferences");
memcpy (savebuffer + offset, prefscomment, 64); memcpy (savebuffer + offset, prefscomment, 64);
@ -316,7 +317,7 @@ SavePrefs (bool silent)
// We'll save using the first available method (probably SD) since this // We'll save using the first available method (probably SD) since this
// is the method preferences will be loaded from by default // is the method preferences will be loaded from by default
int method = autoSaveMethod(); int method = autoSaveMethod(silent);
if(!MakeFilePath(filepath, FILE_PREF, method)) if(!MakeFilePath(filepath, FILE_PREF, method))
return false; return false;

View File

@ -26,8 +26,8 @@
#include "filesel.h" #include "filesel.h"
bool networkInit = false; bool networkInit = false;
bool autoNetworkInit = true;
bool networkShareInit = false; bool networkShareInit = false;
bool networkInitHalt = false;
/**************************************************************************** /****************************************************************************
* InitializeNetwork * InitializeNetwork
@ -36,36 +36,32 @@ bool networkInitHalt = false;
void InitializeNetwork(bool silent) 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; return;
if(!silent) if(!silent)
ShowAction ("Initializing network..."); ShowAction ("Initializing network...");
s32 result; char ip[16];
s32 initResult = if_config(ip, NULL, NULL, true);
while ((result = net_init()) == -EAGAIN); if(initResult == 0)
if (result >= 0)
{ {
char myIP[16]; networkInit = true;
if (if_config(myIP, NULL, NULL, true) < 0)
{
networkInitHalt = true; // do not attempt a reconnection again
if(!silent)
WaitPrompt("Error reading IP address.");
}
else
{
networkInit = true;
}
} }
else else
{ {
// do not automatically attempt a reconnection
autoNetworkInit = false;
if(!silent) 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; return false;
#endif #endif
// check that all parameter have been set int chkU = (strlen(GCSettings.smbuser) > 0) ? 0:1;
if(strlen(GCSettings.smbuser) == 0 || int chkP = (strlen(GCSettings.smbpwd) > 0) ? 0:1;
strlen(GCSettings.smbpwd) == 0 || int chkS = (strlen(GCSettings.smbshare) > 0) ? 0:1;
strlen(GCSettings.smbshare) == 0 || int chkI = (strlen(GCSettings.smbip) > 0) ? 0:1;
strlen(GCSettings.smbip) == 0)
// check that all parameters have been set
if(chkU + chkP + chkS + chkI > 0)
{ {
if(!silent) 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; return false;
} }

View File

@ -167,17 +167,18 @@ int main(int argc, char *argv[])
DI_Init(); // first DI_Init(); // first
#endif #endif
InitDeviceThread();
// Initialise controllers // Initialise controllers
PAD_Init ();
#ifdef HW_RVL #ifdef HW_RVL
WPAD_Init(); WPAD_Init();
// read wiimote accelerometer and IR data // read wiimote accelerometer and IR data
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL,640,480); WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
#endif
PAD_Init ();
// Wii Power/Reset buttons // Wii Power/Reset buttons
#ifdef HW_RVL
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
SYS_SetPowerCallback(ShutdownCB); SYS_SetPowerCallback(ShutdownCB);
SYS_SetResetCallback(ResetCB); SYS_SetResetCallback(ResetCB);
@ -197,7 +198,6 @@ int main(int argc, char *argv[])
// Initialize libFAT for SD and USB // Initialize libFAT for SD and USB
MountAllFAT(); MountAllFAT();
InitDeviceThread();
// Initialize DVD subsystem (GameCube only) // Initialize DVD subsystem (GameCube only)
#ifdef HW_DOL #ifdef HW_DOL

View File

@ -261,7 +261,7 @@ bool LoadBatteryOrState(int method, int action, bool silent)
int offset = 0; int offset = 0;
if(method == METHOD_AUTO) 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)) if(!MakeFilePath(filepath, action, method))
return false; 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 int datasize = 0; // we need the actual size of the data written
if(method == METHOD_AUTO) if(method == METHOD_AUTO)
method = autoSaveMethod(); method = autoSaveMethod(silent);
if(!MakeFilePath(filepath, action, method)) if(!MakeFilePath(filepath, action, method))
return false; return false;
@ -349,6 +349,7 @@ bool SaveBatteryOrState(int method, int action, bool silent)
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
{ {
char savecomment[2][32]; char savecomment[2][32];
memset(savecomment, 0, 64);
char savetype[10]; char savetype[10];
offset = sizeof (saveicon); offset = sizeof (saveicon);