improve device thread, change pref loading

This commit is contained in:
dborth 2008-12-18 23:22:32 +00:00
parent 9efd02061f
commit 6d288c1c90
8 changed files with 43 additions and 21 deletions

View File

@ -1,5 +1,3 @@
VERSION := 006
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
@ -17,7 +15,7 @@ include $(DEVKITPPC)/gamecube_rules
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := snes9xgx-$(VERSION)-gc
TARGET := snes9xgx-gc
TARGETDIR := executables
BUILD := build_gc
SOURCES := source/snes9x source/ngc source/sz

View File

@ -1,5 +1,3 @@
VERSION := 006
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
@ -17,7 +15,7 @@ include $(DEVKITPPC)/wii_rules
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := snes9xgx-$(VERSION)-wii
TARGET := snes9xgx-wii
TARGETDIR := executables
BUILD := build_wii
SOURCES := source/snes9x source/ngc source/sz
@ -110,7 +108,6 @@ $(BUILD):
@[ -d $@ ] || mkdir -p $@
@[ -d $(TARGETDIR) ] || mkdir -p $(TARGETDIR)
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.wii
@rm -fr $(OUTPUT).elf
#---------------------------------------------------------------------------------
clean:

View File

@ -176,9 +176,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;
@ -329,19 +326,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;
}
/****************************************************************************
@ -370,6 +375,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);
@ -428,6 +437,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;
}
@ -460,6 +472,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);
@ -478,6 +494,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;
}

View File

@ -35,5 +35,6 @@ u32 SaveFile(char filepath[], u32 datasize, int method, bool silent);
extern char currFATdir[MAXPATHLEN];
extern FILE * file;
extern bool unmountRequired[];
extern lwp_t devicethread;
#endif

View File

@ -976,7 +976,7 @@ PreferencesMenu ()
case -1: /*** Button B ***/
case 4:
SavePrefs(GCSettings.SaveMethod, SILENT);
SavePrefs(SILENT);
quit = 1;
break;

View File

@ -312,16 +312,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;

View File

@ -8,5 +8,5 @@
* Preferences save/load to XML file
***************************************************************************/
bool SavePrefs (int method, bool silent);
bool SavePrefs (bool silent);
bool LoadPrefs ();

View File

@ -213,6 +213,10 @@ emulate ()
if (ConfigRequested)
{
// go back to checking if devices were inserted/removed
// since we're entering the menu
LWP_ResumeThread (devicethread);
// change to menu video mode
ResetVideo_Menu ();
@ -252,7 +256,7 @@ emulate ()
MainMenu (2); // go to game menu
// save zoom level
SavePrefs(GCSettings.SaveMethod, SILENT);
SavePrefs(SILENT);
FrameTimer = 0;
setFrameTimerMethod (); // set frametimer method every time a ROM is loaded
@ -273,6 +277,10 @@ emulate ()
CheckVideo = 1; // force video update
prevRenderedFrameCount = IPPU.RenderedFramesCount;
// stop checking if devices were removed/inserted
// since we're starting emulation again
LWP_SuspendThread (devicethread);
}//if ConfigRequested
}//while