zapper support, button map fix, pref fixes

This commit is contained in:
dborth 2008-09-04 02:46:04 +00:00
parent f40cf39e21
commit 7f7b2c2300
11 changed files with 236 additions and 63 deletions

View File

@ -25,6 +25,7 @@ DefaultSettings ()
GCSettings.currpal = 0; GCSettings.currpal = 0;
GCSettings.timing = 0; GCSettings.timing = 0;
GCSettings.FSDisable = 1; GCSettings.FSDisable = 1;
GCSettings.zapper = 0;
GCSettings.slimit = 1; GCSettings.slimit = 1;
GCSettings.screenscaler = 2; GCSettings.screenscaler = 2;

View File

@ -52,6 +52,7 @@ struct SGCSettings{
int currpal; int currpal;
int timing; int timing;
int FSDisable; int FSDisable;
int zapper;
int slimit; int slimit;
int screenscaler; int screenscaler;
}; };

View File

@ -27,6 +27,7 @@
#include "menu.h" #include "menu.h"
#include "fceuconfig.h" #include "fceuconfig.h"
#include "preferences.h" #include "preferences.h"
#include "gcaudio.h"
#ifdef WII_DVD #ifdef WII_DVD
#include <di/di.h> #include <di/di.h>
@ -38,7 +39,6 @@ bool isWii;
/* Some timing-related variables. */ /* Some timing-related variables. */
static int fullscreen=0; static int fullscreen=0;
static int genie=0; static int genie=0;
static int palyo=0;
static volatile int nofocus=0; static volatile int nofocus=0;
static volatile int userpause=0; static volatile int userpause=0;
@ -61,8 +61,6 @@ int eoptions=EO_BGRUN | EO_FORCEISCALE;
extern int cleanSFMDATA(); extern int cleanSFMDATA();
extern void ResetNES(void); extern void ResetNES(void);
extern void InitialiseSound();
extern void PlaySound( void *Buf, int samples );
long long basetime; long long basetime;
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count);
@ -104,8 +102,7 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
palyo=0; FCEUI_SetVidSystem(0); // 0 - NTSC, 1 - PAL
FCEUI_SetVidSystem(palyo);
genie&=1; genie&=1;
FCEUI_SetGameGenie(genie); FCEUI_SetGameGenie(genie);
fullscreen&=1; fullscreen&=1;
@ -121,7 +118,8 @@ int main(int argc, char *argv[])
DefaultSettings(); DefaultSettings();
// Load preferences // Load preferences
if(!LoadPrefs(GCSettings.SaveMethod, SILENT))
if(!LoadPrefs())
{ {
WaitPrompt((char*) "Preferences reset - check settings!"); WaitPrompt((char*) "Preferences reset - check settings!");
selectedMenu = 3; // change to preferences menu selectedMenu = 3; // change to preferences menu

View File

@ -10,8 +10,9 @@
****************************************************************************/ ****************************************************************************/
#include <gccore.h> #include <gccore.h>
#define SAMPLERATE 48000 #define SAMPLERATE 48000
static unsigned char audiobuffer[2][64 * 1024] __attribute__((__aligned__(32))); unsigned char audiobuffer[2][64 * 1024] ATTRIBUTE_ALIGN(32);
/*** Allow for up to 1 full second ***/ /*** Allow for up to 1 full second ***/
/**************************************************************************** /****************************************************************************
@ -28,7 +29,7 @@ static void AudioSwitchBuffers()
if ( buffSize[whichab] ) { if ( buffSize[whichab] ) {
AUDIO_StopDMA(); AUDIO_StopDMA();
AUDIO_InitDMA((u32)audiobuffer[whichab], buffSize[whichab]); AUDIO_InitDMA((u32)audiobuffer[whichab], buffSize[whichab]);
DCFlushRange(&audiobuffer[whichab], buffSize[whichab]); DCFlushRange(audiobuffer[whichab], buffSize[whichab]);
AUDIO_StartDMA(); AUDIO_StartDMA();
isPlaying = 0; isPlaying = 0;
} }
@ -54,6 +55,7 @@ void StartAudio()
void StopAudio() void StopAudio()
{ {
AUDIO_StopDMA(); AUDIO_StopDMA();
buffSize[0] = buffSize[1] = 0;
} }
static inline unsigned short FLIP16(unsigned short b) static inline unsigned short FLIP16(unsigned short b)

14
source/ngc/gcaudio.h Normal file
View File

@ -0,0 +1,14 @@
/****************************************************************************
* FCE Ultra 0.98.12
* Nintendo Wii/Gamecube Port
*
* Tantric September 2008
*
* audio.h
*
* Audio driver
****************************************************************************/
void InitialiseSound();
void StopAudio();
void PlaySound( void *Buf, int samples );

View File

@ -68,7 +68,7 @@ bool TestCard(int slot, bool silent)
/*** Initialize Card System ***/ /*** Initialize Card System ***/
memset (SysArea, 0, CARD_WORKAREA); memset (SysArea, 0, CARD_WORKAREA);
CARD_Init ("SNES", "00"); CARD_Init ("FCEU", "00");
/*** Try to mount the card ***/ /*** Try to mount the card ***/
if (MountCard(slot, silent) == 0) if (MountCard(slot, silent) == 0)
@ -136,7 +136,7 @@ VerifyMCFile (unsigned char *buf, int slot, char *filename, int datasize)
/*** Initialize Card System ***/ /*** Initialize Card System ***/
memset (SysArea, 0, CARD_WORKAREA); memset (SysArea, 0, CARD_WORKAREA);
CARD_Init ("SNES", "00"); CARD_Init ("FCEU", "00");
/*** Try to mount the card ***/ /*** Try to mount the card ***/
CardError = MountCard(slot, NOTSILENT); CardError = MountCard(slot, NOTSILENT);
@ -216,7 +216,7 @@ LoadBufferFromMC (unsigned char *buf, int slot, char *filename, bool silent)
/*** Initialize Card System ***/ /*** Initialize Card System ***/
memset (SysArea, 0, CARD_WORKAREA); memset (SysArea, 0, CARD_WORKAREA);
CARD_Init ("SNES", "00"); CARD_Init ("FCEU", "00");
/*** Try to mount the card ***/ /*** Try to mount the card ***/
CardError = MountCard(slot, NOTSILENT); CardError = MountCard(slot, NOTSILENT);
@ -280,7 +280,7 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
/*** Initialize Card System ***/ /*** Initialize Card System ***/
memset (SysArea, 0, CARD_WORKAREA); memset (SysArea, 0, CARD_WORKAREA);
CARD_Init ("SNES", "00"); CARD_Init ("FCEU", "00");
/*** Try to mount the card ***/ /*** Try to mount the card ***/
CardError = MountCard(slot, NOTSILENT); CardError = MountCard(slot, NOTSILENT);
@ -405,7 +405,7 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
} }
else else
if ( !silent ) if ( !silent )
WaitPrompt((char*) "This game does not appear to use SRAM"); WaitPrompt((char*) "No to data to save!");
} }
else else
if (slot == CARD_SLOTA) if (slot == CARD_SLOTA)

View File

@ -89,14 +89,13 @@ LoadManager ()
/**************************************************************************** /****************************************************************************
* Emulator Menu * Emulator Menu
****************************************************************************/ ****************************************************************************/
static int emulatormenuCount = 7; static int emulatormenuCount = 6;
static char emulatormenu[][50] = { static char emulatormenu[][50] = {
"Screen Scaler", "Screen Scaler",
"Palette", "Palette",
"8 Sprite Limit", "8 Sprite Limit",
"Timing", "Timing",
"Four Score",
"Save Preferences", "Save Preferences",
"Back to Main Menu" "Back to Main Menu"
@ -123,9 +122,6 @@ EmulatorMenu ()
sprintf (emulatormenu[3], "Timing - %s", sprintf (emulatormenu[3], "Timing - %s",
GCSettings.timing == true ? " PAL" : "NTSC"); GCSettings.timing == true ? " PAL" : "NTSC");
sprintf (emulatormenu[4], "Four Score - %s",
GCSettings.FSDisable == true ? " ON" : "OFF");
ret = RunMenu (emulatormenu, emulatormenuCount, (char*)"Emulator Options", 16, -1); ret = RunMenu (emulatormenu, emulatormenuCount, (char*)"Emulator Options", 16, -1);
switch (ret) switch (ret)
@ -172,17 +168,12 @@ EmulatorMenu ()
FCEUI_SetVidSystem(GCSettings.timing); FCEUI_SetVidSystem(GCSettings.timing);
break; break;
case 4: // four score case 4:
GCSettings.FSDisable ^= 1;
FCEUI_DisableFourScore(GCSettings.FSDisable);
break;
case 5:
SavePrefs(GCSettings.SaveMethod, NOTSILENT); SavePrefs(GCSettings.SaveMethod, NOTSILENT);
break; break;
case -1: // Button B case -1: // Button B
case 6: case 5:
quit = 1; quit = 1;
break; break;
@ -366,9 +357,9 @@ GameMenu ()
{ {
// disable state saving/loading if AUTO is on // disable state saving/loading if AUTO is on
if (GCSettings.AutoLoad == 1) // Auto Load SRAM if (GCSettings.AutoLoad == 1) // Auto Load State
gamemenu[3][0] = '\0'; gamemenu[3][0] = '\0';
if (GCSettings.AutoSave == 1) // Auto Save SRAM if (GCSettings.AutoSave == 1) // Auto Save State
gamemenu[4][0] = '\0'; gamemenu[4][0] = '\0';
ret = RunMenu (gamemenu, gamemenuCount, (char*)"Game Menu", 20, -1); ret = RunMenu (gamemenu, gamemenuCount, (char*)"Game Menu", 20, -1);
@ -625,8 +616,10 @@ ConfigureButtons (u16 ctrlr_type)
menu = oldmenu; menu = oldmenu;
} // end configurebuttons() } // end configurebuttons()
int ctlrmenucount = 6; int ctlrmenucount = 8;
char ctlrmenu[][50] = { char ctlrmenu[][50] = {
"Four Score",
"Zapper",
"Nunchuk", "Nunchuk",
"Classic Controller", "Classic Controller",
"Wiimote", "Wiimote",
@ -645,45 +638,64 @@ ConfigureControllers ()
// disable unavailable controller options if in GC mode // disable unavailable controller options if in GC mode
#ifndef HW_RVL #ifndef HW_RVL
ctlrmenu[2][0] = '\0';
ctlrmenu[3][0] = '\0';
ctlrmenu[4][0] = '\0'; ctlrmenu[4][0] = '\0';
ctlrmenu[5][0] = '\0';
ctlrmenu[6][0] = '\0';
#endif #endif
while (quit == 0) while (quit == 0)
{ {
sprintf (ctlrmenu[0], "Four Score - %s",
GCSettings.FSDisable == true ? " ON" : "OFF");
if (GCSettings.zapper == 0) sprintf (ctlrmenu[1],"Zapper - Disabled");
else if (GCSettings.zapper == 1) sprintf (ctlrmenu[1],"Zapper - Port 1");
else if (GCSettings.zapper == 2) sprintf (ctlrmenu[1],"Zapper - Port 2");
/*** Controller Config Menu ***/ /*** Controller Config Menu ***/
ret = RunMenu (ctlrmenu, ctlrmenucount, (char*)"Configure Controllers", 20, -1); ret = RunMenu (ctlrmenu, ctlrmenucount, (char*)"Configure Controllers", 20, -1);
switch (ret) switch (ret)
{ {
case 0: case 0: // four score
GCSettings.FSDisable ^= 1;
ToggleFourScore(GCSettings.FSDisable);
break;
case 1: // zapper
GCSettings.zapper -= 1; // we do this so Port 2 is first option shown
if(GCSettings.zapper < 0)
GCSettings.zapper = 2;
ToggleZapper(GCSettings.zapper);
break;
case 2:
/*** Configure Nunchuk ***/ /*** Configure Nunchuk ***/
ConfigureButtons (CTRLR_NUNCHUK); ConfigureButtons (CTRLR_NUNCHUK);
break; break;
case 1: case 3:
/*** Configure Classic ***/ /*** Configure Classic ***/
ConfigureButtons (CTRLR_CLASSIC); ConfigureButtons (CTRLR_CLASSIC);
break; break;
case 2: case 4:
/*** Configure Wiimote ***/ /*** Configure Wiimote ***/
ConfigureButtons (CTRLR_WIIMOTE); ConfigureButtons (CTRLR_WIIMOTE);
break; break;
case 3: case 5:
/*** Configure GC Pad ***/ /*** Configure GC Pad ***/
ConfigureButtons (CTRLR_GCPAD); ConfigureButtons (CTRLR_GCPAD);
break; break;
case 4: case 6:
/*** Save Preferences Now ***/ /*** Save Preferences Now ***/
SavePrefs(GCSettings.SaveMethod, NOTSILENT); SavePrefs(GCSettings.SaveMethod, NOTSILENT);
break; break;
case -1: /*** Button B ***/ case -1: /*** Button B ***/
case 5: case 7:
/*** Return ***/ /*** Return ***/
quit = 1; quit = 1;
break; break;

View File

@ -14,9 +14,11 @@
#include <math.h> #include <math.h>
#include "driver.h" #include "driver.h"
#include "fceu.h" #include "fceu.h"
#include "input.h"
#include "fceuconfig.h" #include "fceuconfig.h"
#include "pad.h" #include "pad.h"
#include "gcaudio.h"
#include "menu.h" #include "menu.h"
#include "fceustate.h" #include "fceustate.h"
@ -24,7 +26,7 @@
// All other pads are mapped to this // All other pads are mapped to this
unsigned int nespadmap[] = { unsigned int nespadmap[] = {
JOY_B, JOY_A, JOY_B, JOY_A,
JOY_START, JOY_SELECT, JOY_SELECT, JOY_START,
JOY_UP, JOY_DOWN, JOY_UP, JOY_DOWN,
JOY_LEFT, JOY_RIGHT JOY_LEFT, JOY_RIGHT
}; };
@ -59,6 +61,12 @@ unsigned int ncpadmap[] = {
}; };
static uint32 JSReturn = 0; static uint32 JSReturn = 0;
void *InputDPR;
INPUTC *zapperdata[2];
unsigned int myzappers[2][3];
extern INPUTC *FCEU_InitZapper(int w);
/**************************************************************************** /****************************************************************************
* Initialise Pads * Initialise Pads
@ -66,13 +74,40 @@ static uint32 JSReturn = 0;
void InitialisePads() void InitialisePads()
{ {
int attrib = 0; int attrib = 0;
void *InputDPR;
FCEUI_DisableFourScore(1); FCEUI_DisableFourScore(1);
InputDPR = &JSReturn; InputDPR = &JSReturn;
FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, attrib); FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, attrib);
FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, attrib); FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, attrib);
ToggleZapper(GCSettings.zapper);
}
void ToggleFourScore(int set)
{
FCEUI_DisableFourScore(set);
}
void ToggleZapper(int set)
{
// set defaults
zapperdata[0]=NULL;
zapperdata[1]=NULL;
myzappers[0][0]=myzappers[1][0]=128;
myzappers[0][1]=myzappers[1][1]=120;
myzappers[0][2]=myzappers[1][2]=0;
// Default ports back to gamepad
FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, 0);
FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, 0);
if(set)
{
// enable Zapper
zapperdata[set-1] = FCEU_InitZapper(set-1);
FCEUI_SetInput(set-1, SI_ZAPPER, myzappers[set-1], 1);
}
} }
s8 WPAD_StickX(u8 chan,u8 right) s8 WPAD_StickX(u8 chan,u8 right)
@ -159,6 +194,70 @@ s8 WPAD_StickY(u8 chan, u8 right)
return (s8)(val * 128.0f); return (s8)(val * 128.0f);
} }
// hold zapper cursor positions
int pos_x = 0;
int pos_y = 0;
void UpdateCursorPosition (int pad)
{
#define ZAPPERPADCAL 20
// gc left joystick
signed char pad_x = PAD_StickX (pad);
signed char pad_y = PAD_StickY (pad);
if (pad_x > ZAPPERPADCAL){
pos_x += (pad_x*1.0)/ZAPPERPADCAL;
if (pos_x > 256) pos_x = 256;
}
if (pad_x < -ZAPPERPADCAL){
pos_x -= (pad_x*-1.0)/ZAPPERPADCAL;
if (pos_x < 0) pos_x = 0;
}
if (pad_y < -ZAPPERPADCAL){
pos_y += (pad_y*-1.0)/ZAPPERPADCAL;
if (pos_y > 224) pos_y = 224;
}
if (pad_y > ZAPPERPADCAL){
pos_y -= (pad_y*1.0)/ZAPPERPADCAL;
if (pos_y < 0) pos_y = 0;
}
#ifdef HW_RVL
struct ir_t ir; // wiimote ir
WPAD_IR(pad, &ir);
if (ir.valid)
{
pos_x = (ir.x * 256) / 640;
pos_y = (ir.y * 224) / 480;
}
else
{
signed char wm_ax = WPAD_StickX (pad, 0);
signed char wm_ay = WPAD_StickY (pad, 0);
if (wm_ax > ZAPPERPADCAL){
pos_x += (wm_ax*1.0)/ZAPPERPADCAL;
if (pos_x > 256) pos_x = 256;
}
if (wm_ax < -ZAPPERPADCAL){
pos_x -= (wm_ax*-1.0)/ZAPPERPADCAL;
if (pos_x < 0) pos_x = 0;
}
if (wm_ay < -ZAPPERPADCAL){
pos_y += (wm_ay*-1.0)/ZAPPERPADCAL;
if (pos_y > 224) pos_y = 224;
}
if (wm_ay > ZAPPERPADCAL){
pos_y -= (wm_ay*1.0)/ZAPPERPADCAL;
if (pos_y < 0) pos_y = 0;
}
}
#endif
}
/**************************************************************************** /****************************************************************************
* Convert GC Joystick Readings to JOY * Convert GC Joystick Readings to JOY
****************************************************************************/ ****************************************************************************/
@ -269,10 +368,38 @@ unsigned char DecodeJoy( unsigned short pad )
|| ( (exp_type == WPAD_EXP_CLASSIC) && (wp & ccpadmap[i]) ) // classic controller || ( (exp_type == WPAD_EXP_CLASSIC) && (wp & ccpadmap[i]) ) // classic controller
|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & ncpadmap[i]) ) // nunchuk + wiimote || ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & ncpadmap[i]) ) // nunchuk + wiimote
#endif #endif
) )
J |= nespadmap[i]; J |= nespadmap[i];
} }
return J;
// zapper enabled
if(GCSettings.zapper)
{
int z = GCSettings.zapper-1; // NES port # (0 or 1)
myzappers[z][2] = 0; // reset trigger to not pressed
// is trigger pressed?
if ( (jp & PAD_BUTTON_A) // gamecube controller
#ifdef HW_RVL
|| (wp & WPAD_BUTTON_A) // wiimote
#endif
)
{
// report trigger press
myzappers[z][2] |= 2;
}
// cursor position
UpdateCursorPosition(0); // update cursor for wiimote 1
myzappers[z][0] = pos_x;
myzappers[z][1] = pos_y;
// Report changes to FCE Ultra
zapperdata[z]->Update(z,myzappers[z],0);
}
return J;
} }
void GetJoy() void GetJoy()
@ -297,7 +424,7 @@ void GetJoy()
#endif #endif
) )
{ {
AUDIO_StopDMA(); StopAudio();
if (GCSettings.AutoLoad == 1) if (GCSettings.AutoLoad == 1)
SaveState(GCSettings.SaveMethod, SILENT); SaveState(GCSettings.SaveMethod, SILENT);

View File

@ -27,6 +27,9 @@ s8 WPAD_StickX(u8 chan,u8 right);
s8 WPAD_StickY(u8 chan, u8 right); s8 WPAD_StickY(u8 chan, u8 right);
void InitialisePads(); void InitialisePads();
void GetJoy(); void GetJoy();
void ToggleFourScore(int set);
void ToggleZapper(int set);
void DrawCursor();
#endif #endif

View File

@ -164,18 +164,18 @@ preparePrefsData (int method)
createXMLSetting("currpal", "Palette", toStr(GCSettings.currpal)); createXMLSetting("currpal", "Palette", toStr(GCSettings.currpal));
createXMLSetting("timing", "Timing", toStr(GCSettings.timing)); createXMLSetting("timing", "Timing", toStr(GCSettings.timing));
createXMLSetting("FSDisable", "Four Score", toStr(GCSettings.FSDisable));
createXMLSetting("slimit", "8 Sprite Limit", toStr(GCSettings.slimit)); createXMLSetting("slimit", "8 Sprite Limit", toStr(GCSettings.slimit));
createXMLSetting("screenscaler", "Screen Scaler", toStr(GCSettings.screenscaler)); createXMLSetting("screenscaler", "Screen Scaler", toStr(GCSettings.screenscaler));
createXMLSection("Controller", "Controller Settings"); createXMLSection("Controller", "Controller Settings");
createXMLSetting("FSDisable", "Four Score", toStr(GCSettings.FSDisable));
createXMLSetting("zapper", "Zapper", toStr(GCSettings.zapper));
createXMLController(gcpadmap, "gcpadmap", "GameCube Pad"); createXMLController(gcpadmap, "gcpadmap", "GameCube Pad");
createXMLController(wmpadmap, "wmpadmap", "Wiimote"); createXMLController(wmpadmap, "wmpadmap", "Wiimote");
createXMLController(ccpadmap, "ccpadmap", "Classic Controller"); createXMLController(ccpadmap, "ccpadmap", "Classic Controller");
createXMLController(ncpadmap, "ncpadmap", "Nunchuk"); createXMLController(ncpadmap, "ncpadmap", "Nunchuk");
memset (savebuffer + offset, 0, SAVEBUFFERSIZE);
int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSaveCallback); int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSaveCallback);
mxmlDelete(xml); mxmlDelete(xml);
@ -207,6 +207,7 @@ void loadXMLSettingBool(bool * var, const char * name)
} }
void loadXMLController(unsigned int controller[], const char * name) void loadXMLController(unsigned int controller[], const char * name)
{ {
item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND); item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);
@ -271,7 +272,7 @@ decodePrefsData (int method)
loadXMLSettingInt(&GCSettings.FSDisable, "FSDisable"); loadXMLSettingInt(&GCSettings.FSDisable, "FSDisable");
loadXMLSettingInt(&GCSettings.slimit, "slimit"); loadXMLSettingInt(&GCSettings.slimit, "slimit");
loadXMLSettingInt(&GCSettings.screenscaler, "screenscaler"); loadXMLSettingInt(&GCSettings.screenscaler, "screenscaler");
loadXMLSettingInt(&GCSettings.zapper, "zapper");
// Controller Settings // Controller Settings
loadXMLController(gcpadmap, "gcpadmap"); loadXMLController(gcpadmap, "gcpadmap");
@ -334,48 +335,62 @@ SavePrefs (int method, bool silent)
} }
/**************************************************************************** /****************************************************************************
* Load Preferences * Load Preferences from specified method
****************************************************************************/ ****************************************************************************/
bool
LoadPrefs (int method, bool silent)
{
if(method == METHOD_AUTO)
method = autoSaveMethod(); // we use 'Save' folder because preferences need R/W
bool
LoadPrefsFromMethod (int method)
{
bool retval = false; bool retval = false;
char filepath[1024]; char filepath[1024];
int offset = 0; int offset = 0;
if ( !silent )
ShowAction ((char*) "Loading preferences...");
if(method == METHOD_SD || method == METHOD_USB) if(method == METHOD_SD || method == METHOD_USB)
{ {
if(ChangeFATInterface(method, NOTSILENT)) if(ChangeFATInterface(method, NOTSILENT))
{ {
sprintf (filepath, "%s/%s/%s", ROOTFATDIR, GCSettings.SaveFolder, PREFS_FILE_NAME); sprintf (filepath, "%s/%s/%s", ROOTFATDIR, GCSettings.SaveFolder, PREFS_FILE_NAME);
offset = LoadBufferFromFAT (filepath, silent); offset = LoadBufferFromFAT (filepath, SILENT);
} }
} }
else if(method == METHOD_SMB) else if(method == METHOD_SMB)
{ {
sprintf (filepath, "%s/%s", GCSettings.SaveFolder, PREFS_FILE_NAME); sprintf (filepath, "%s/%s", GCSettings.SaveFolder, PREFS_FILE_NAME);
offset = LoadSaveBufferFromSMB (filepath, silent); offset = LoadSaveBufferFromSMB (filepath, SILENT);
} }
else if(method == METHOD_MC_SLOTA) else if(method == METHOD_MC_SLOTA)
{ {
offset = LoadBufferFromMC (savebuffer, CARD_SLOTA, (char *)PREFS_FILE_NAME, silent); offset = LoadBufferFromMC (savebuffer, CARD_SLOTA, (char *)PREFS_FILE_NAME, SILENT);
} }
else if(method == METHOD_MC_SLOTB) else if(method == METHOD_MC_SLOTB)
{ {
offset = LoadBufferFromMC (savebuffer, CARD_SLOTB, (char *)PREFS_FILE_NAME, silent); offset = LoadBufferFromMC (savebuffer, CARD_SLOTB, (char *)PREFS_FILE_NAME, SILENT);
} }
if (offset > 0) if (offset > 0)
{
retval = decodePrefsData (method); retval = decodePrefsData (method);
if ( !silent )
WaitPrompt((char *)"Preferences loaded");
}
return retval; return retval;
} }
/****************************************************************************
* Load Preferences
* Checks sources consecutively until we find a preference file
****************************************************************************/
bool LoadPrefs()
{
bool prefFound = false;
if(ChangeFATInterface(METHOD_SD, SILENT))
prefFound = LoadPrefsFromMethod(METHOD_SD);
if(!prefFound && ChangeFATInterface(METHOD_USB, SILENT))
prefFound = LoadPrefsFromMethod(METHOD_USB);
if(!prefFound && TestCard(CARD_SLOTA, SILENT))
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTA);
if(!prefFound && TestCard(CARD_SLOTB, SILENT))
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTB);
if(!prefFound && ConnectShare (SILENT))
prefFound = LoadPrefsFromMethod(METHOD_SMB);
return prefFound;
}

View File

@ -10,4 +10,4 @@
****************************************************************************/ ****************************************************************************/
bool SavePrefs (int method, bool silent); bool SavePrefs (int method, bool silent);
bool LoadPrefs (int method, bool silent); bool LoadPrefs ();