mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-01 00:15:10 +01:00
improve device thread, change pref loading
This commit is contained in:
parent
18e267b1f0
commit
e03dd275f7
@ -174,9 +174,6 @@ bool MountFAT(int method)
|
||||
|
||||
sprintf(rootdir, "%s:/", name);
|
||||
|
||||
// isInserted doesn't work properly for USB - so we will force a shutdown
|
||||
//unmountRequired[METHOD_USB] = true;
|
||||
|
||||
if(unmountRequired[method])
|
||||
{
|
||||
unmountRequired[method] = false;
|
||||
@ -327,19 +324,27 @@ ParseDirectory()
|
||||
u32
|
||||
LoadSzFile(char * filepath, unsigned char * rbuffer)
|
||||
{
|
||||
u32 size;
|
||||
u32 size = 0;
|
||||
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're loading a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
|
||||
file = fopen (filepath, "rb");
|
||||
if (file > 0)
|
||||
{
|
||||
size = SzExtractFile(filelist[selection].offset, rbuffer);
|
||||
fclose (file);
|
||||
return size;
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt("Error opening file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
LWP_ResumeThread (devicethread);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -368,6 +373,10 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
break;
|
||||
}
|
||||
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're loading a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
|
||||
// add device to filepath
|
||||
char fullpath[1024];
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath);
|
||||
@ -426,6 +435,9 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
WaitPrompt("Error loading file!");
|
||||
}
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
LWP_ResumeThread (devicethread);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -458,6 +470,10 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
|
||||
if (datasize)
|
||||
{
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're saving a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
|
||||
// add device to filepath
|
||||
char fullpath[1024];
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath);
|
||||
@ -476,6 +492,9 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
unmountRequired[method] = true;
|
||||
WaitPrompt ("Error saving file!");
|
||||
}
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
LWP_ResumeThread (devicethread);
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
@ -32,5 +32,6 @@ u32 SaveFile(char filepath[], u32 datasize, int method, bool silent);
|
||||
extern char currdir[MAXPATHLEN];
|
||||
extern FILE * file;
|
||||
extern bool unmountRequired[];
|
||||
extern lwp_t devicethread;
|
||||
|
||||
#endif
|
||||
|
@ -251,7 +251,7 @@ PreferencesMenu ()
|
||||
|
||||
case 11:
|
||||
case -1: /*** Button B ***/
|
||||
SavePrefs(GCSettings.SaveMethod, SILENT);
|
||||
SavePrefs(SILENT);
|
||||
quit = 1;
|
||||
break;
|
||||
|
||||
@ -612,7 +612,7 @@ ConfigureControllers ()
|
||||
|
||||
case 4:
|
||||
/*** Save Preferences Now ***/
|
||||
SavePrefs(GCSettings.SaveMethod, NOTSILENT);
|
||||
SavePrefs(NOTSILENT);
|
||||
break;
|
||||
|
||||
case -1: /*** Button B ***/
|
||||
|
@ -308,16 +308,15 @@ decodePrefsData (int method)
|
||||
* Save Preferences
|
||||
***************************************************************************/
|
||||
bool
|
||||
SavePrefs (int method, bool silent)
|
||||
SavePrefs (bool silent)
|
||||
{
|
||||
char filepath[1024];
|
||||
int datasize;
|
||||
int offset = 0;
|
||||
|
||||
// there's no point in saving SMB settings TO SMB, because then we'll have no way to load them the next time!
|
||||
// so instead we'll save using whatever other method is available (eg: SD)
|
||||
if(method == METHOD_AUTO || method == METHOD_SMB)
|
||||
method = autoSaveMethod();
|
||||
// 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();
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_PREF, method))
|
||||
return false;
|
||||
|
@ -8,5 +8,5 @@
|
||||
* Preferences save/load to XML file
|
||||
***************************************************************************/
|
||||
|
||||
bool SavePrefs (int method, bool silent);
|
||||
bool SavePrefs (bool silent);
|
||||
bool LoadPrefs ();
|
||||
|
@ -233,9 +233,17 @@ int main(int argc, char *argv[])
|
||||
ShutdownWii();
|
||||
#endif
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
// since we're entering the menu
|
||||
LWP_ResumeThread (devicethread);
|
||||
|
||||
MainMenu(selectedMenu);
|
||||
selectedMenu = 3; // return to game menu from now on
|
||||
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're starting emulation again
|
||||
LWP_SuspendThread (devicethread);
|
||||
|
||||
ResetVideo_Emu();
|
||||
|
||||
while (emulating) // emulation loop
|
||||
@ -267,7 +275,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// save zoom level
|
||||
SavePrefs(GCSettings.SaveMethod, SILENT);
|
||||
SavePrefs(SILENT);
|
||||
|
||||
ConfigRequested = 0;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user