2008-08-06 03:09:59 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Snes9x 1.50
|
|
|
|
*
|
|
|
|
* Nintendo Gamecube Port
|
|
|
|
* crunchy2 April 2007-July 2007
|
|
|
|
*
|
|
|
|
* preferences.cpp
|
|
|
|
*
|
|
|
|
* Preferences save/load preferences utilities
|
|
|
|
****************************************************************************/
|
|
|
|
#include <gccore.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ogcsys.h>
|
2008-08-22 22:23:32 +02:00
|
|
|
#include <mxml.h>
|
2008-08-06 03:09:59 +02:00
|
|
|
|
|
|
|
#include "snes9x.h"
|
|
|
|
#include "memmap.h"
|
|
|
|
#include "srtc.h"
|
2008-08-12 05:25:16 +02:00
|
|
|
|
2008-08-22 04:47:08 +02:00
|
|
|
#include "snes9xGX.h"
|
2008-08-12 05:25:16 +02:00
|
|
|
#include "images/saveicon.h"
|
2008-08-07 07:19:17 +02:00
|
|
|
#include "menudraw.h"
|
2008-08-12 05:25:16 +02:00
|
|
|
#include "memcardop.h"
|
2008-08-07 07:19:17 +02:00
|
|
|
#include "fileop.h"
|
2008-08-10 05:14:39 +02:00
|
|
|
#include "smbop.h"
|
2008-08-07 05:25:02 +02:00
|
|
|
#include "filesel.h"
|
2008-08-06 03:09:59 +02:00
|
|
|
|
|
|
|
extern unsigned char savebuffer[];
|
|
|
|
extern int currconfig[4];
|
|
|
|
|
2008-08-06 03:45:56 +02:00
|
|
|
// button map configurations
|
|
|
|
extern unsigned int gcpadmap[];
|
|
|
|
extern unsigned int wmpadmap[];
|
|
|
|
extern unsigned int ccpadmap[];
|
|
|
|
extern unsigned int ncpadmap[];
|
|
|
|
|
2008-08-20 09:58:55 +02:00
|
|
|
#define PREFS_FILE_NAME "SNES9xGX.xml"
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-22 04:47:08 +02:00
|
|
|
char prefscomment[2][32];
|
2008-08-06 03:09:59 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Prepare Preferences Data
|
|
|
|
*
|
2008-08-07 05:25:02 +02:00
|
|
|
* This sets up the save buffer for saving.
|
2008-08-06 03:09:59 +02:00
|
|
|
****************************************************************************/
|
2008-08-20 09:58:55 +02:00
|
|
|
mxml_node_t *xml;
|
|
|
|
mxml_node_t *data;
|
|
|
|
mxml_node_t *section;
|
|
|
|
mxml_node_t *item;
|
|
|
|
mxml_node_t *elem;
|
|
|
|
|
|
|
|
char temp[200];
|
|
|
|
|
|
|
|
const char * toStr(int i)
|
|
|
|
{
|
|
|
|
sprintf(temp, "%d", i);
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void createXMLSection(const char * name, const char * description)
|
|
|
|
{
|
|
|
|
section = mxmlNewElement(data, "section");
|
|
|
|
mxmlElementSetAttr(section, "name", name);
|
|
|
|
mxmlElementSetAttr(section, "description", description);
|
|
|
|
}
|
|
|
|
|
|
|
|
void createXMLSetting(const char * name, const char * description, const char * value)
|
|
|
|
{
|
|
|
|
item = mxmlNewElement(section, "setting");
|
|
|
|
mxmlElementSetAttr(item, "name", name);
|
|
|
|
mxmlElementSetAttr(item, "value", value);
|
|
|
|
mxmlElementSetAttr(item, "description", description);
|
|
|
|
}
|
|
|
|
|
|
|
|
void createXMLController(unsigned int controller[], const char * name, const char * description)
|
|
|
|
{
|
|
|
|
item = mxmlNewElement(section, "controller");
|
|
|
|
mxmlElementSetAttr(item, "name", name);
|
|
|
|
mxmlElementSetAttr(item, "description", description);
|
|
|
|
|
|
|
|
// create buttons
|
|
|
|
for(int i=0; i < 12; i++)
|
|
|
|
{
|
|
|
|
elem = mxmlNewElement(item, "button");
|
|
|
|
mxmlElementSetAttr(elem, "number", toStr(i));
|
|
|
|
mxmlElementSetAttr(elem, "assignment", toStr(controller[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-22 04:47:08 +02:00
|
|
|
const char * XMLSaveCallback(mxml_node_t *node, int where)
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
name = node->value.element.name;
|
|
|
|
|
|
|
|
if(where == MXML_WS_BEFORE_CLOSE)
|
|
|
|
{
|
|
|
|
if(!strcmp(name, "file") || !strcmp(name, "section"))
|
|
|
|
return ("\n");
|
|
|
|
else if(!strcmp(name, "controller"))
|
|
|
|
return ("\n\t");
|
|
|
|
}
|
|
|
|
if (where == MXML_WS_BEFORE_OPEN)
|
|
|
|
{
|
|
|
|
if(!strcmp(name, "file"))
|
|
|
|
return ("\n");
|
|
|
|
else if(!strcmp(name, "section"))
|
|
|
|
return ("\n\n");
|
|
|
|
else if(!strcmp(name, "setting") || !strcmp(name, "controller"))
|
|
|
|
return ("\n\t");
|
|
|
|
else if(!strcmp(name, "button"))
|
|
|
|
return ("\n\t\t");
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
int
|
2008-08-20 09:58:55 +02:00
|
|
|
preparePrefsData (int method)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-20 09:58:55 +02:00
|
|
|
int offset = 0;
|
|
|
|
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
|
|
|
|
|
|
|
// add save icon and comments for Memory Card saves
|
|
|
|
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
|
|
|
{
|
|
|
|
offset = sizeof (saveicon);
|
|
|
|
|
|
|
|
// Copy in save icon
|
|
|
|
memcpy (savebuffer, saveicon, offset);
|
|
|
|
|
|
|
|
// And the comments
|
2008-08-22 04:47:08 +02:00
|
|
|
sprintf (prefscomment[0], "%s Prefs", VERSIONSTR);
|
|
|
|
sprintf (prefscomment[1], "Preferences");
|
2008-08-20 09:58:55 +02:00
|
|
|
memcpy (savebuffer + offset, prefscomment, 64);
|
|
|
|
offset += 64;
|
|
|
|
}
|
|
|
|
|
|
|
|
xml = mxmlNewXML("1.0");
|
2008-08-22 04:47:08 +02:00
|
|
|
mxmlSetWrapMargin(0); // disable line wrapping
|
2008-08-20 09:58:55 +02:00
|
|
|
|
|
|
|
data = mxmlNewElement(xml, "file");
|
2008-08-22 04:47:08 +02:00
|
|
|
mxmlElementSetAttr(data, "version",VERSIONSTR);
|
2008-08-20 09:58:55 +02:00
|
|
|
|
|
|
|
createXMLSection("File", "File Settings");
|
|
|
|
|
|
|
|
createXMLSetting("AutoLoad", "Auto Load", toStr(GCSettings.AutoLoad));
|
|
|
|
createXMLSetting("AutoSave", "Auto Save", toStr(GCSettings.AutoSave));
|
|
|
|
createXMLSetting("LoadMethod", "Load Method", toStr(GCSettings.LoadMethod));
|
|
|
|
createXMLSetting("SaveMethod", "Save Method", toStr(GCSettings.SaveMethod));
|
|
|
|
createXMLSetting("LoadFolder", "Load Folder", GCSettings.LoadFolder);
|
|
|
|
createXMLSetting("SaveFolder", "Save Folder", GCSettings.SaveFolder);
|
|
|
|
createXMLSetting("CheatFolder", "Cheats Folder", GCSettings.CheatFolder);
|
|
|
|
createXMLSetting("VerifySaves", "Verify Memory Card Saves", toStr(GCSettings.VerifySaves));
|
|
|
|
|
|
|
|
createXMLSection("Network", "Network Settings");
|
|
|
|
|
|
|
|
createXMLSetting("smbip", "Share Computer IP", GCSettings.smbip);
|
|
|
|
createXMLSetting("smbshare", "Share Name", GCSettings.smbshare);
|
|
|
|
createXMLSetting("smbuser", "Share Username", GCSettings.smbuser);
|
|
|
|
createXMLSetting("smbpwd", "Share Password", GCSettings.smbpwd);
|
|
|
|
|
|
|
|
createXMLSection("Emulation", "Emulation Settings");
|
|
|
|
|
|
|
|
createXMLSetting("ReverseStereo", "Reverse Stereo", toStr(Settings.ReverseStereo));
|
|
|
|
createXMLSetting("InterpolatedSound", "Interpolated Sound", toStr(Settings.InterpolatedSound));
|
|
|
|
createXMLSetting("Transparency", "Transparency", toStr(Settings.Transparency));
|
|
|
|
createXMLSetting("DisplayFrameRate", "Display Frame Rate", toStr(Settings.DisplayFrameRate));
|
|
|
|
createXMLSetting("NGCZoom", "C-Stick Zoom", toStr(GCSettings.NGCZoom));
|
|
|
|
createXMLSetting("render", "Video Filtering", toStr(GCSettings.render));
|
|
|
|
|
|
|
|
createXMLSection("Controller", "Controller Settings");
|
|
|
|
|
|
|
|
createXMLSetting("MultiTap", "MultiTap", toStr(Settings.MultiPlayer5Master));
|
|
|
|
createXMLSetting("Superscope", "Superscope", toStr(GCSettings.Superscope));
|
|
|
|
createXMLSetting("Mice", "Mice", toStr(GCSettings.Mouse));
|
|
|
|
createXMLSetting("Justifiers", "Justifiers", toStr(GCSettings.Justifier));
|
|
|
|
|
|
|
|
createXMLController(gcpadmap, "gcpadmap", "GameCube Pad");
|
|
|
|
createXMLController(wmpadmap, "wmpadmap", "Wiimote");
|
|
|
|
createXMLController(ccpadmap, "ccpadmap", "Classic Controller");
|
|
|
|
createXMLController(ncpadmap, "ncpadmap", "Nunchuk");
|
|
|
|
|
|
|
|
memset (savebuffer + offset, 0, SAVEBUFFERSIZE);
|
2008-08-22 04:47:08 +02:00
|
|
|
int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSaveCallback);
|
2008-08-20 09:58:55 +02:00
|
|
|
|
|
|
|
mxmlDelete(xml);
|
|
|
|
|
|
|
|
return datasize;
|
|
|
|
|
|
|
|
/*
|
2008-08-08 09:57:01 +02:00
|
|
|
int offset = sizeof (saveicon);
|
|
|
|
int size;
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-08 09:57:01 +02:00
|
|
|
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-20 09:58:55 +02:00
|
|
|
// Copy in save icon
|
2008-08-08 09:57:01 +02:00
|
|
|
memcpy (savebuffer, saveicon, offset);
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-20 09:58:55 +02:00
|
|
|
// And the prefscomments
|
2008-08-08 09:57:01 +02:00
|
|
|
memcpy (savebuffer + offset, prefscomment, 64);
|
|
|
|
offset += 64;
|
|
|
|
|
2008-08-20 09:58:55 +02:00
|
|
|
// Save all settings
|
2008-08-08 09:57:01 +02:00
|
|
|
size = sizeof (Settings);
|
|
|
|
memcpy (savebuffer + offset, &Settings, size);
|
|
|
|
offset += size;
|
|
|
|
|
2008-08-20 09:58:55 +02:00
|
|
|
// Save GC specific settings
|
2008-08-08 09:57:01 +02:00
|
|
|
size = sizeof (GCSettings);
|
|
|
|
memcpy (savebuffer + offset, &GCSettings, size);
|
|
|
|
offset += size;
|
|
|
|
|
2008-08-20 09:58:55 +02:00
|
|
|
// Save buttonmaps
|
2008-08-08 09:57:01 +02:00
|
|
|
size = sizeof (unsigned int) *12; // this size applies to all padmaps
|
|
|
|
memcpy (savebuffer + offset, &gcpadmap, size);
|
|
|
|
offset += size;
|
|
|
|
memcpy (savebuffer + offset, &wmpadmap, size);
|
|
|
|
offset += size;
|
|
|
|
memcpy (savebuffer + offset, &ccpadmap, size);
|
|
|
|
offset += size;
|
|
|
|
memcpy (savebuffer + offset, &ncpadmap, size);
|
|
|
|
offset += size;
|
|
|
|
|
|
|
|
return offset;
|
2008-08-20 09:58:55 +02:00
|
|
|
*/
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Decode Preferences Data
|
|
|
|
****************************************************************************/
|
2008-08-20 09:58:55 +02:00
|
|
|
void loadXMLSetting(char * var, const char * name)
|
|
|
|
{
|
|
|
|
item = mxmlFindElement(xml, xml, "setting", "name", name, MXML_DESCEND);
|
|
|
|
if(item)
|
|
|
|
sprintf(var, "%s", mxmlElementGetAttr(item, "value"));
|
|
|
|
}
|
|
|
|
void loadXMLSetting(int * var, const char * name)
|
|
|
|
{
|
|
|
|
item = mxmlFindElement(xml, xml, "setting", "name", name, MXML_DESCEND);
|
|
|
|
if(item)
|
|
|
|
*var = atoi(mxmlElementGetAttr(item, "value"));
|
|
|
|
}
|
|
|
|
void loadXMLSetting(bool8 * var, const char * name)
|
|
|
|
{
|
|
|
|
item = mxmlFindElement(xml, xml, "setting", "name", name, MXML_DESCEND);
|
|
|
|
if(item)
|
|
|
|
*var = atoi(mxmlElementGetAttr(item, "value"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadXMLController(unsigned int controller[], const char * name)
|
|
|
|
{
|
|
|
|
item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);
|
|
|
|
|
|
|
|
if(item)
|
|
|
|
{
|
|
|
|
// populate buttons
|
|
|
|
for(int i=0; i < 12; i++)
|
|
|
|
{
|
|
|
|
elem = mxmlFindElement(item, xml, "button", "number", toStr(i), MXML_DESCEND);
|
|
|
|
if(elem)
|
|
|
|
controller[i] = atoi(mxmlElementGetAttr(elem, "assignment"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
bool
|
2008-08-20 09:58:55 +02:00
|
|
|
decodePrefsData (int method)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-20 09:58:55 +02:00
|
|
|
int offset = 0;
|
|
|
|
|
|
|
|
// skip save icon and comments for Memory Card saves
|
|
|
|
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
|
|
|
{
|
|
|
|
offset = sizeof (saveicon);
|
|
|
|
offset += 64; // sizeof prefscomment
|
|
|
|
}
|
|
|
|
|
|
|
|
xml = mxmlLoadString(NULL, (char *)savebuffer+offset, MXML_TEXT_CALLBACK);
|
|
|
|
|
|
|
|
// check settings version
|
|
|
|
// we don't do anything with the version #, but we'll store it anyway
|
|
|
|
char * version;
|
|
|
|
item = mxmlFindElement(xml, xml, "file", "version", NULL, MXML_DESCEND);
|
|
|
|
if(item) // a version entry exists
|
|
|
|
version = (char *)mxmlElementGetAttr(item, "version");
|
|
|
|
else // version # not found, must be invalid
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// File Settings
|
|
|
|
|
|
|
|
loadXMLSetting(&GCSettings.AutoLoad, "AutoLoad");
|
|
|
|
loadXMLSetting(&GCSettings.AutoSave, "AutoSave");
|
|
|
|
loadXMLSetting(&GCSettings.LoadMethod, "LoadMethod");
|
|
|
|
loadXMLSetting(&GCSettings.SaveMethod, "SaveMethod");
|
|
|
|
loadXMLSetting(GCSettings.LoadFolder, "LoadFolder");
|
|
|
|
loadXMLSetting(GCSettings.SaveFolder, "SaveFolder");
|
|
|
|
loadXMLSetting(GCSettings.CheatFolder, "CheatFolder");
|
|
|
|
loadXMLSetting(&GCSettings.VerifySaves, "VerifySaves");
|
|
|
|
|
|
|
|
// Network Settings
|
|
|
|
|
|
|
|
loadXMLSetting(GCSettings.smbip, "smbip");
|
|
|
|
loadXMLSetting(GCSettings.smbshare, "smbshare");
|
|
|
|
loadXMLSetting(GCSettings.smbuser, "smbuser");
|
|
|
|
loadXMLSetting(GCSettings.smbpwd, "smbpwd");
|
|
|
|
|
|
|
|
// Emulation Settings
|
|
|
|
|
|
|
|
loadXMLSetting(&Settings.ReverseStereo, "ReverseStereo");
|
|
|
|
loadXMLSetting(&Settings.InterpolatedSound, "InterpolatedSound");
|
|
|
|
loadXMLSetting(&Settings.Transparency, "Transparency");
|
|
|
|
loadXMLSetting(&Settings.DisplayFrameRate, "DisplayFrameRate");
|
|
|
|
loadXMLSetting(&GCSettings.NGCZoom, "NGCZoom");
|
|
|
|
loadXMLSetting(&GCSettings.render, "render");
|
|
|
|
|
|
|
|
// Controller Settings
|
|
|
|
|
|
|
|
loadXMLSetting(&Settings.MultiPlayer5Master, "MultiTap");
|
|
|
|
loadXMLSetting(&GCSettings.Superscope, "Superscope");
|
|
|
|
loadXMLSetting(&GCSettings.Mouse, "Mice");
|
|
|
|
loadXMLSetting(&GCSettings.Justifier, "Justifiers");
|
|
|
|
|
|
|
|
loadXMLController(gcpadmap, "gcpadmap");
|
|
|
|
loadXMLController(wmpadmap, "wmpadmap");
|
|
|
|
loadXMLController(ccpadmap, "ccpadmap");
|
|
|
|
loadXMLController(ncpadmap, "ncpadmap");
|
|
|
|
|
|
|
|
mxmlDelete(xml);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
/*
|
2008-08-07 05:25:02 +02:00
|
|
|
int offset;
|
|
|
|
char prefscomment[32];
|
|
|
|
int size;
|
|
|
|
|
|
|
|
offset = sizeof (saveicon);
|
|
|
|
memcpy (prefscomment, savebuffer + offset, 32);
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
if ( strcmp (prefscomment, PREFSVERSTRING) == 0 )
|
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
offset += 64;
|
|
|
|
memcpy (&Settings, savebuffer + offset, sizeof (Settings));
|
|
|
|
offset += sizeof (Settings);
|
|
|
|
memcpy (&GCSettings, savebuffer + offset, sizeof (GCSettings));
|
|
|
|
offset += sizeof (GCSettings);
|
|
|
|
// load padmaps (order important)
|
|
|
|
size = sizeof (unsigned int) *12;
|
|
|
|
memcpy (&gcpadmap, savebuffer + offset, size);
|
|
|
|
offset += size;
|
|
|
|
memcpy (&wmpadmap, savebuffer + offset, size);
|
|
|
|
offset += size;
|
|
|
|
memcpy (&ccpadmap, savebuffer + offset, size);
|
|
|
|
offset += size;
|
|
|
|
memcpy (&ncpadmap, savebuffer + offset, size);
|
|
|
|
|
|
|
|
return true;
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
else
|
|
|
|
return false;
|
2008-08-20 09:58:55 +02:00
|
|
|
*/
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Save Preferences
|
|
|
|
****************************************************************************/
|
|
|
|
bool
|
|
|
|
SavePrefs (int method, bool silent)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
if(method == METHOD_AUTO)
|
|
|
|
method = autoSaveMethod();
|
|
|
|
|
|
|
|
char filepath[1024];
|
|
|
|
int datasize;
|
|
|
|
int offset = 0;
|
|
|
|
|
2008-08-20 09:58:55 +02:00
|
|
|
datasize = preparePrefsData (method);
|
2008-08-07 05:25:02 +02:00
|
|
|
|
|
|
|
if (!silent)
|
|
|
|
ShowAction ((char*) "Saving preferences...");
|
|
|
|
|
|
|
|
if(method == METHOD_SD || method == METHOD_USB)
|
|
|
|
{
|
2008-08-12 05:25:16 +02:00
|
|
|
if(ChangeFATInterface(method, NOTSILENT))
|
|
|
|
{
|
|
|
|
sprintf (filepath, "%s/%s/%s", ROOTFATDIR, GCSettings.SaveFolder, PREFS_FILE_NAME);
|
|
|
|
offset = SaveBufferToFAT (filepath, datasize, silent);
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
|
|
|
else if(method == METHOD_SMB)
|
|
|
|
{
|
2008-08-10 05:14:39 +02:00
|
|
|
sprintf (filepath, "%s/%s", GCSettings.SaveFolder, PREFS_FILE_NAME);
|
2008-08-07 05:25:02 +02:00
|
|
|
offset = SaveBufferToSMB (filepath, datasize, silent);
|
|
|
|
}
|
|
|
|
else if(method == METHOD_MC_SLOTA)
|
|
|
|
{
|
2008-08-12 05:25:16 +02:00
|
|
|
offset = SaveBufferToMC (savebuffer, CARD_SLOTA, (char *)PREFS_FILE_NAME, datasize, silent);
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
|
|
|
else if(method == METHOD_MC_SLOTB)
|
|
|
|
{
|
2008-08-12 05:25:16 +02:00
|
|
|
offset = SaveBufferToMC (savebuffer, CARD_SLOTB, (char *)PREFS_FILE_NAME, datasize, silent);
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (offset > 0)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-20 09:58:55 +02:00
|
|
|
if (!silent)
|
2008-08-12 05:25:16 +02:00
|
|
|
WaitPrompt ((char *)"Preferences saved");
|
2008-08-20 09:58:55 +02:00
|
|
|
return true;
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
2008-08-20 09:58:55 +02:00
|
|
|
return false;
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Load Preferences
|
|
|
|
****************************************************************************/
|
|
|
|
bool
|
|
|
|
LoadPrefs (int method, bool silent)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
if(method == METHOD_AUTO)
|
|
|
|
method = autoSaveMethod(); // we use 'Save' folder because preferences need R/W
|
|
|
|
|
|
|
|
bool retval = false;
|
|
|
|
char filepath[1024];
|
|
|
|
int offset = 0;
|
|
|
|
|
|
|
|
if ( !silent )
|
|
|
|
ShowAction ((char*) "Loading preferences...");
|
|
|
|
|
|
|
|
if(method == METHOD_SD || method == METHOD_USB)
|
|
|
|
{
|
2008-08-12 05:25:16 +02:00
|
|
|
if(ChangeFATInterface(method, NOTSILENT))
|
|
|
|
{
|
|
|
|
sprintf (filepath, "%s/%s/%s", ROOTFATDIR, GCSettings.SaveFolder, PREFS_FILE_NAME);
|
|
|
|
offset = LoadBufferFromFAT (filepath, silent);
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
|
|
|
else if(method == METHOD_SMB)
|
|
|
|
{
|
2008-08-10 05:14:39 +02:00
|
|
|
sprintf (filepath, "%s/%s", GCSettings.SaveFolder, PREFS_FILE_NAME);
|
2008-08-12 05:25:16 +02:00
|
|
|
offset = LoadBufferFromSMB (filepath, silent);
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
|
|
|
else if(method == METHOD_MC_SLOTA)
|
|
|
|
{
|
2008-08-12 05:25:16 +02:00
|
|
|
offset = LoadBufferFromMC (savebuffer, CARD_SLOTA, (char *)PREFS_FILE_NAME, silent);
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
|
|
|
else if(method == METHOD_MC_SLOTB)
|
|
|
|
{
|
2008-08-12 05:25:16 +02:00
|
|
|
offset = LoadBufferFromMC (savebuffer, CARD_SLOTB, (char *)PREFS_FILE_NAME, silent);
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (offset > 0)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-20 09:58:55 +02:00
|
|
|
retval = decodePrefsData (method);
|
2008-08-07 05:25:02 +02:00
|
|
|
if ( !silent )
|
2008-08-12 05:25:16 +02:00
|
|
|
WaitPrompt((char *)"Preferences loaded");
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
return retval;
|
|
|
|
}
|