2008-08-06 03:09:59 +02:00
|
|
|
/****************************************************************************
|
2008-10-16 03:48:08 +02:00
|
|
|
* Snes9x 1.50
|
2008-08-06 03:09:59 +02:00
|
|
|
*
|
2008-10-16 03:48:08 +02:00
|
|
|
* Nintendo Gamecube Port
|
|
|
|
* crunchy2 April 2007-July 2007
|
2008-08-06 03:09:59 +02:00
|
|
|
*
|
|
|
|
* preferences.cpp
|
|
|
|
*
|
2008-10-16 03:48:08 +02:00
|
|
|
* Preferences save/load preferences utilities
|
|
|
|
****************************************************************************/
|
2008-08-06 03:09:59 +02:00
|
|
|
#include <gccore.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ogcsys.h>
|
|
|
|
|
2008-10-16 03:48:08 +02:00
|
|
|
#include "snes9x.h"
|
|
|
|
#include "snes9xGx.h"
|
|
|
|
#include "memmap.h"
|
|
|
|
#include "srtc.h"
|
|
|
|
#include "ftfont.h"
|
|
|
|
#include "mcsave.h"
|
|
|
|
#include "sdload.h"
|
|
|
|
#include "smbload.h"
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-10-16 03:48:08 +02:00
|
|
|
extern unsigned char savebuffer[];
|
2008-08-06 03:09:59 +02:00
|
|
|
extern int currconfig[4];
|
|
|
|
|
2008-10-16 03:48:08 +02:00
|
|
|
#define PREFSVERSTRING "Snes9x GX 2.0.1b8 Prefs"
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-10-16 03:48:08 +02:00
|
|
|
char prefscomment[2][32] = { {PREFSVERSTRING}, {"Preferences"} };
|
2008-08-06 03:09:59 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Prepare Preferences Data
|
|
|
|
*
|
2008-10-16 03:48:08 +02:00
|
|
|
* This sets up the save buffer for saving to a memory card.
|
|
|
|
****************************************************************************/
|
2008-08-06 03:09:59 +02:00
|
|
|
int
|
2008-10-16 03:48:08 +02:00
|
|
|
preparePrefsData ()
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-10-16 03:48:08 +02:00
|
|
|
int offset = sizeof (saveicon);
|
|
|
|
int size;
|
2008-08-20 09:58:55 +02:00
|
|
|
|
2008-10-16 03:48:08 +02:00
|
|
|
memset (savebuffer, 0, 0x22000);
|
2008-08-20 09:58:55 +02:00
|
|
|
|
2008-10-16 03:48:08 +02:00
|
|
|
/*** Copy in save icon ***/
|
|
|
|
memcpy (savebuffer, saveicon, offset);
|
2008-08-20 09:58:55 +02:00
|
|
|
|
2008-10-16 03:48:08 +02:00
|
|
|
/*** And the prefscomments ***/
|
|
|
|
memcpy (savebuffer + offset, prefscomment, 64);
|
|
|
|
offset += 64;
|
2008-08-20 09:58:55 +02:00
|
|
|
|
2008-10-16 03:48:08 +02:00
|
|
|
/*** Save all settings ***/
|
|
|
|
size = sizeof (Settings);
|
|
|
|
memcpy (savebuffer + offset, &Settings, size);
|
|
|
|
offset += size;
|
2008-08-20 09:58:55 +02:00
|
|
|
|
2008-10-16 03:48:08 +02:00
|
|
|
/*** Save GC specific settings ***/
|
|
|
|
size = sizeof (GCSettings);
|
|
|
|
memcpy (savebuffer + offset, &GCSettings, size);
|
|
|
|
offset += size;
|
|
|
|
|
|
|
|
return offset;
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
2008-10-16 03:48:08 +02:00
|
|
|
* Decode Preferences Data
|
|
|
|
****************************************************************************/
|
|
|
|
void
|
|
|
|
decodePrefsData ()
|
2008-08-20 09:58:55 +02:00
|
|
|
{
|
2008-10-16 03:48:08 +02:00
|
|
|
int offset;
|
|
|
|
char prefscomment[32];
|
|
|
|
|
|
|
|
offset = sizeof (saveicon);
|
|
|
|
memcpy (prefscomment, savebuffer + offset, 32);
|
|
|
|
|
|
|
|
if ( strcmp (prefscomment, PREFSVERSTRING) == 0 )
|
2008-08-20 09:58:55 +02:00
|
|
|
{
|
2008-10-16 03:48:08 +02:00
|
|
|
offset += 64;
|
|
|
|
memcpy (&Settings, savebuffer + offset, sizeof (Settings));
|
|
|
|
offset += sizeof (Settings);
|
|
|
|
memcpy (&GCSettings, savebuffer + offset, sizeof (GCSettings));
|
2008-08-20 09:58:55 +02:00
|
|
|
}
|
2008-10-16 03:48:08 +02:00
|
|
|
else
|
|
|
|
WaitPrompt("Preferences reset - check settings!");
|
2008-08-20 09:58:55 +02:00
|
|
|
}
|
|
|
|
|
2008-10-16 03:48:08 +02:00
|
|
|
void quickLoadPrefs (bool8 silent)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-10-16 03:48:08 +02:00
|
|
|
switch ( QUICK_SAVE_SLOT )
|
2008-08-07 05:25:02 +02:00
|
|
|
{
|
2008-10-16 03:48:08 +02:00
|
|
|
case CARD_SLOTA:
|
|
|
|
case CARD_SLOTB:
|
|
|
|
LoadPrefsFromMC(QUICK_SAVE_SLOT, silent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CARD_SLOTA+2:
|
|
|
|
case CARD_SLOTB+2:
|
|
|
|
LoadPrefsFromSD(QUICK_SAVE_SLOT-2, silent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CARD_SLOTA+4:
|
|
|
|
LoadPrefsFromSMB(silent);
|
|
|
|
break;
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2008-10-16 03:48:08 +02:00
|
|
|
void quickSavePrefs (bool8 silent)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-10-16 03:48:08 +02:00
|
|
|
switch ( QUICK_SAVE_SLOT )
|
2008-08-07 05:25:02 +02:00
|
|
|
{
|
2008-10-16 03:48:08 +02:00
|
|
|
case CARD_SLOTA:
|
|
|
|
case CARD_SLOTB:
|
|
|
|
SavePrefsToMC(QUICK_SAVE_SLOT, silent);
|
|
|
|
break;
|
|
|
|
case CARD_SLOTA+2:
|
|
|
|
case CARD_SLOTB+2:
|
|
|
|
SavePrefsToSD(QUICK_SAVE_SLOT-2, silent);
|
|
|
|
break;
|
|
|
|
case CARD_SLOTA+4:
|
|
|
|
SavePrefsToSMB(silent);
|
|
|
|
break;
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
2008-09-04 04:42:27 +02:00
|
|
|
}
|