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