mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-27 21:14:21 +01:00
optimize boot sequence, more intelligent device auto-detect, network error message improvements
This commit is contained in:
parent
2f21a6cb78
commit
2794edef50
@ -69,7 +69,7 @@ SetupCheats()
|
||||
int method = GCSettings.SaveMethod;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod();
|
||||
method = autoSaveMethod(SILENT);
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_CHEAT, method))
|
||||
return;
|
||||
|
@ -236,15 +236,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;
|
||||
|
@ -95,19 +95,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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -115,25 +117,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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -44,7 +44,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);
|
||||
|
||||
|
@ -120,7 +120,7 @@ NGCFreezeMemBuffer ()
|
||||
* Do freeze game for Nintendo Gamecube
|
||||
***************************************************************************/
|
||||
int
|
||||
NGCFreezeGame (int method, bool8 silent)
|
||||
NGCFreezeGame (int method, bool silent)
|
||||
{
|
||||
char filepath[1024];
|
||||
int offset = 0; // bytes written (actual)
|
||||
@ -130,7 +130,7 @@ NGCFreezeGame (int method, bool8 silent)
|
||||
ShowAction ("Saving...");
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod();
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_SNAPSHOT, method))
|
||||
return 0;
|
||||
@ -152,6 +152,8 @@ NGCFreezeGame (int method, bool8 silent)
|
||||
memcpy (savebuffer, saveicon, woffset);
|
||||
|
||||
// And the freezecomment
|
||||
memset(freezecomment, 0, 64);
|
||||
|
||||
sprintf (freezecomment[0], "%s Freeze", VERSIONSTR);
|
||||
sprintf (freezecomment[1], Memory.ROMName);
|
||||
memcpy (savebuffer + woffset, freezecomment, 64);
|
||||
@ -234,7 +236,7 @@ NGCUnFreezeBlock (char *name, uint8 * block, int size)
|
||||
* NGCUnfreezeGame
|
||||
***************************************************************************/
|
||||
int
|
||||
NGCUnfreezeGame (int method, bool8 silent)
|
||||
NGCUnfreezeGame (int method, bool silent)
|
||||
{
|
||||
char filepath[1024];
|
||||
int offset = 0;
|
||||
@ -246,7 +248,7 @@ NGCUnfreezeGame (int method, bool8 silent)
|
||||
ShowAction ("Loading...");
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(); // we use 'Save' because snapshot needs R/W
|
||||
method = autoSaveMethod(silent); // we use 'Save' because snapshot needs R/W
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_SNAPSHOT, method))
|
||||
return 0;
|
||||
|
@ -28,7 +28,7 @@ typedef struct
|
||||
}
|
||||
MEMFILE;
|
||||
|
||||
int NGCFreezeGame (int method, bool8 silent);
|
||||
int NGCUnfreezeGame (int method, bool8 silent);
|
||||
int NGCFreezeGame (int method, bool silent);
|
||||
int NGCUnfreezeGame (int method, bool silent);
|
||||
|
||||
#endif
|
||||
|
@ -122,6 +122,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);
|
||||
@ -319,7 +320,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;
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include "filesel.h"
|
||||
|
||||
bool networkInit = false;
|
||||
bool autoNetworkInit = true;
|
||||
bool networkShareInit = false;
|
||||
bool networkInitHalt = false;
|
||||
|
||||
/****************************************************************************
|
||||
* InitializeNetwork
|
||||
@ -38,36 +38,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,14 +86,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;
|
||||
}
|
||||
|
||||
|
@ -337,37 +337,34 @@ main(int argc, char *argv[])
|
||||
|
||||
int selectedMenu = -1;
|
||||
|
||||
InitDeviceThread();
|
||||
|
||||
// Initialise video
|
||||
InitGCVideo ();
|
||||
InitGCVideo();
|
||||
|
||||
// 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);
|
||||
#endif
|
||||
|
||||
// Audio
|
||||
AUDIO_Init (NULL);
|
||||
|
||||
// GC Audio RAM (for ROM and backdrop storage)
|
||||
AR_Init (NULL, 0);
|
||||
|
||||
// GameCube only - Injected ROM
|
||||
// Before going any further, let's copy any injected ROM image
|
||||
// We'll put it in ARAM for safe storage
|
||||
|
||||
#ifdef HW_DOL
|
||||
// GC Audio RAM (for ROM and backdrop storage)
|
||||
AR_Init (NULL, 0);
|
||||
|
||||
int *romptr = (int *) 0x81000000; // location of injected rom
|
||||
|
||||
if (memcmp ((char *) romptr, "SNESROM0", 8) == 0)
|
||||
@ -386,6 +383,8 @@ main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
unpackbackdrop();
|
||||
|
||||
// Initialise freetype font system
|
||||
if (FT_Init ())
|
||||
{
|
||||
@ -393,7 +392,8 @@ main(int argc, char *argv[])
|
||||
while (1);
|
||||
}
|
||||
|
||||
unpackbackdrop ();
|
||||
// Audio
|
||||
AUDIO_Init (NULL);
|
||||
|
||||
// Set defaults
|
||||
DefaultSettings ();
|
||||
@ -427,7 +427,6 @@ main(int argc, char *argv[])
|
||||
|
||||
// Initialize libFAT for SD and USB
|
||||
MountAllFAT();
|
||||
InitDeviceThread();
|
||||
|
||||
// Initialize DVD subsystem (GameCube only)
|
||||
#ifdef HW_DOL
|
||||
|
@ -49,6 +49,7 @@ preparesavedata (int method)
|
||||
}
|
||||
|
||||
// Copy in the sramcomments
|
||||
memset(sramcomment, 0, 64);
|
||||
sprintf (sramcomment[0], "%s SRAM", VERSIONSTR);
|
||||
sprintf (sramcomment[1], Memory.ROMName);
|
||||
memcpy (savebuffer + offset, sramcomment, 64);
|
||||
@ -145,7 +146,7 @@ LoadSRAM (int method, bool silent)
|
||||
int offset = 0;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(); // we use 'Save' because SRAM needs R/W
|
||||
method = autoSaveMethod(silent); // we use 'Save' because SRAM needs R/W
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_SRAM, method))
|
||||
return 0;
|
||||
@ -187,7 +188,7 @@ SaveSRAM (int method, bool silent)
|
||||
int offset = 0;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod();
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_SRAM, method))
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user