mirror of
https://github.com/dborth/fceugx.git
synced 2024-11-01 06:55:05 +01:00
fix typo; add save/load settings; auto-loads from WiiSD (or SDGecko slot A in GC mode) at start... for now
This commit is contained in:
parent
ee9e70a4c6
commit
b3365acc4b
@ -55,17 +55,13 @@ extern unsigned char *nesromptr;
|
|||||||
extern int IsXenoGCImage( char *buffer );
|
extern int IsXenoGCImage( char *buffer );
|
||||||
|
|
||||||
void GetSDInfo ();
|
void GetSDInfo ();
|
||||||
extern int ChosenSlot;
|
extern u8 ChosenSlot;
|
||||||
/*extern void ClearScreen();
|
|
||||||
int LoadDVDFile( unsigned char *buffer );
|
|
||||||
extern int unzipDVDFile( unsigned char *outbuffer, unsigned int discoffset, unsigned int length);
|
|
||||||
extern int CentreTextPosition( char *text );*/
|
|
||||||
|
|
||||||
/** true if we the emulator is running on a wii **/
|
/** true if we the emulator is running on a wii **/
|
||||||
extern bool isWii;
|
extern bool isWii;
|
||||||
|
extern int WiiSD_Available;
|
||||||
int UseSDCARD = 0;
|
u8 UseSDCARD = 0;
|
||||||
int UseWiiSDCARD = 0;
|
u8 UseWiiSDCARD = 0;
|
||||||
sd_file * filehandle = NULL;
|
sd_file * filehandle = NULL;
|
||||||
char rootSDdir[SDCARD_MAX_PATH_LEN];
|
char rootSDdir[SDCARD_MAX_PATH_LEN];
|
||||||
char rootWiiSDdir[SDCARD_MAX_PATH_LEN];
|
char rootWiiSDdir[SDCARD_MAX_PATH_LEN];
|
||||||
@ -635,7 +631,7 @@ void ShowFiles( int offset, int selection ) {
|
|||||||
* Let user select another ROM to load
|
* Let user select another ROM to load
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
bool inSz = false;
|
bool inSz = false;
|
||||||
extern int PADCAL;
|
extern u8 PADCAL;
|
||||||
|
|
||||||
void FileSelector() {
|
void FileSelector() {
|
||||||
short p;
|
short p;
|
||||||
@ -900,6 +896,12 @@ int OpenWiiSD () {
|
|||||||
haveSDdir = 0;
|
haveSDdir = 0;
|
||||||
char msg[128];
|
char msg[128];
|
||||||
|
|
||||||
|
/*if (WiiSD_Available == 0) {
|
||||||
|
sprintf(msg, "Insert SD card: %d\n", WiiSD_Available);
|
||||||
|
WaitPrompt(msg);
|
||||||
|
//return 0;
|
||||||
|
}*/
|
||||||
|
|
||||||
memset(&vfs, 0, sizeof(VFATFS));
|
memset(&vfs, 0, sizeof(VFATFS));
|
||||||
if (haveWiiSDdir == 0) {
|
if (haveWiiSDdir == 0) {
|
||||||
/* don't mess with DVD entries */
|
/* don't mess with DVD entries */
|
||||||
@ -926,7 +928,8 @@ int OpenWiiSD () {
|
|||||||
FileSelector ();
|
FileSelector ();
|
||||||
|
|
||||||
/* memorize last entries list, actual root directory and selection for next access */
|
/* memorize last entries list, actual root directory and selection for next access */
|
||||||
haveWiiSDdir = 1;
|
/* TODO: Bugged, do not activate cached dir listing
|
||||||
|
haveWiiSDdir = 1;*/
|
||||||
} else {
|
} else {
|
||||||
/* no entries found */
|
/* no entries found */
|
||||||
sprintf (msg, "Error reading %s", rootWiiSDdir);
|
sprintf (msg, "Error reading %s", rootWiiSDdir);
|
||||||
|
@ -18,14 +18,14 @@
|
|||||||
#include <sdcard.h>
|
#include <sdcard.h>
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
#include "wiisd/tff.h"
|
#include "wiisd/vfat.h"
|
||||||
|
|
||||||
extern VFATFS vfs;
|
extern VFATFS vfs;
|
||||||
extern FSDIRENTRY vfsfile;
|
extern FSDIRENTRY vfsfile;
|
||||||
extern int UseWiiSDCARD;
|
extern u8 UseWiiSDCARD;
|
||||||
#endif
|
#endif
|
||||||
extern sd_file *filehandle;
|
extern sd_file *filehandle;
|
||||||
extern int UseSDCARD;
|
extern u8 UseSDCARD;
|
||||||
|
|
||||||
extern void ShowAction( char *msg );
|
extern void ShowAction( char *msg );
|
||||||
extern void WaitPrompt( char *msg );
|
extern void WaitPrompt( char *msg );
|
||||||
|
@ -16,46 +16,35 @@
|
|||||||
#define JOY_UP 0x10
|
#define JOY_UP 0x10
|
||||||
#define JOY_DOWN 0x20
|
#define JOY_DOWN 0x20
|
||||||
|
|
||||||
static int currpal = 0;
|
u8 currpal = 0;
|
||||||
static int timing = 0;
|
u8 timing = 0;
|
||||||
|
u8 FSDisable = 1;
|
||||||
static int FSDisable = 1;
|
u8 slimit = 1;
|
||||||
|
|
||||||
static int slimit = 1;
|
|
||||||
|
|
||||||
extern int scrollerx;
|
|
||||||
|
|
||||||
extern void FCEUI_DisableSpriteLimitation( int a );
|
extern void FCEUI_DisableSpriteLimitation( int a );
|
||||||
|
|
||||||
extern void FCEUD_SetPalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b);
|
extern void FCEUD_SetPalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b);
|
||||||
extern void FCEU_ResetPalette(void);
|
extern void FCEU_ResetPalette(void);
|
||||||
extern void WaitPrompt( char *text );
|
extern void WaitPrompt( char *text );
|
||||||
//extern void MCManage( int mode );
|
|
||||||
extern void ManageState(int mode, int slot, int device);
|
extern void ManageState(int mode, int slot, int device);
|
||||||
|
extern void ManageSettings(int mode, int slot, int device, int quiet);
|
||||||
extern void StartGX();
|
extern void StartGX();
|
||||||
|
|
||||||
extern signed int CARDSLOT;
|
|
||||||
extern int PADCAL;
|
|
||||||
extern int PADTUR;
|
|
||||||
|
|
||||||
extern void scroller(int y, unsigned char text[][512], int nlines);
|
extern void scroller(int y, unsigned char text[][512], int nlines);
|
||||||
|
|
||||||
extern void FCEUI_DisableFourScore(int a);
|
extern void FCEUI_DisableFourScore(int a);
|
||||||
|
|
||||||
extern int line;
|
|
||||||
|
|
||||||
extern char backdrop[640 * 480 * 2];
|
|
||||||
|
|
||||||
extern int UseSDCARD;
|
|
||||||
|
|
||||||
extern unsigned char DecodeJoy( unsigned short pp );
|
extern unsigned char DecodeJoy( unsigned short pp );
|
||||||
extern unsigned char GetAnalog(int Joy);
|
extern unsigned char GetAnalog(int Joy);
|
||||||
|
|
||||||
|
extern signed int CARDSLOT;
|
||||||
|
extern u8 PADCAL;
|
||||||
|
extern u8 PADTUR;
|
||||||
|
extern int line;
|
||||||
|
extern char backdrop[640 * 480 * 2];
|
||||||
|
extern u8 UseSDCARD;
|
||||||
|
extern int scrollerx;
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
void (*PSOReload)() = (void(*)())0x90000020;
|
void (*Reload)() = (void(*)())0x90000020;
|
||||||
#else
|
#else
|
||||||
void (*PSOReload)() = (void(*)())0x80001800;
|
void (*Reload)() = (void(*)())0x80001800;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Reboot() {
|
void Reboot() {
|
||||||
@ -72,7 +61,7 @@ void Reboot() {
|
|||||||
#define SCROLLY 395
|
#define SCROLLY 395
|
||||||
|
|
||||||
/* color palettes */
|
/* color palettes */
|
||||||
struct {
|
struct st_palettes {
|
||||||
char *name, *desc;
|
char *name, *desc;
|
||||||
unsigned int data[64];
|
unsigned int data[64];
|
||||||
} palettes[] = {
|
} palettes[] = {
|
||||||
@ -301,7 +290,7 @@ extern unsigned int *xfb[2];
|
|||||||
extern GXRModeObj *vmode;
|
extern GXRModeObj *vmode;
|
||||||
extern int font_size[256];
|
extern int font_size[256];
|
||||||
extern int font_height;
|
extern int font_height;
|
||||||
extern int screenscaler;
|
extern u8 screenscaler;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* SetScreen
|
* SetScreen
|
||||||
@ -391,9 +380,7 @@ char PADMap( int padvalue, int padnum ) {
|
|||||||
*
|
*
|
||||||
* This screen simply let's the user swap A/B/X/Y around.
|
* This screen simply let's the user swap A/B/X/Y around.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
char mpads[6] = { 0, 1, 2, 3, 4, 5 };
|
u8 mpads[6] = { 0, 1, 4, 5, 2, 3 };
|
||||||
int PADCON = 0;
|
|
||||||
|
|
||||||
void ConfigPAD() {
|
void ConfigPAD() {
|
||||||
int PadMenuCount = 10;
|
int PadMenuCount = 10;
|
||||||
char PadMenu[10][MENU_STRING_LENGTH] = {
|
char PadMenu[10][MENU_STRING_LENGTH] = {
|
||||||
@ -510,8 +497,16 @@ char SdSlots[3][10] = {
|
|||||||
enum SLOTS {
|
enum SLOTS {
|
||||||
SLOT_A, SLOT_B, SLOT_WIISD
|
SLOT_A, SLOT_B, SLOT_WIISD
|
||||||
};
|
};
|
||||||
int ChosenSlot = 0;
|
enum DEVICES {
|
||||||
int ChosenDevice = 1;
|
MEMCARD, SDCARD
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
u8 ChosenSlot = SLOT_WIISD;
|
||||||
|
#else
|
||||||
|
u8 ChosenSlot = SLOT_A;
|
||||||
|
#endif
|
||||||
|
u8 ChosenDevice = SDCARD;
|
||||||
|
|
||||||
int StateManager() {
|
int StateManager() {
|
||||||
int SaveMenuCount = 5;
|
int SaveMenuCount = 5;
|
||||||
@ -542,9 +537,9 @@ int StateManager() {
|
|||||||
|
|
||||||
while ( quit == 0 ) {
|
while ( quit == 0 ) {
|
||||||
if ( redraw ) {
|
if ( redraw ) {
|
||||||
sprintf(SaveMenu[SAVE_SLOT], "%s: %s", ChosenDevice ? "SDCard" : "MemCard",
|
sprintf(SaveMenu[SAVE_SLOT], "%s: %s", (ChosenDevice == SDCARD) ? "SDCard" : "MemCard",
|
||||||
SdSlots[ChosenSlot]);
|
SdSlots[ChosenSlot]);
|
||||||
sprintf(SaveMenu[SAVE_DEVICE], MENU_SAVE_DEVICE ": %s", ChosenDevice ? "SDCard" : "MemCard");
|
sprintf(SaveMenu[SAVE_DEVICE], MENU_SAVE_DEVICE ": %s", (ChosenDevice == SDCARD) ? "SDCard" : "MemCard");
|
||||||
DrawMenu(MENU_SAVE_TITLE, SaveMenu, SaveMenuCount, ChosenMenu);
|
DrawMenu(MENU_SAVE_TITLE, SaveMenu, SaveMenuCount, ChosenMenu);
|
||||||
redraw = 0;
|
redraw = 0;
|
||||||
}
|
}
|
||||||
@ -629,15 +624,17 @@ int StateManager() {
|
|||||||
* Video Enhancement Screen
|
* Video Enhancement Screen
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int VideoEnhancements() {
|
int VideoEnhancements() {
|
||||||
int VideoMenuCount = 5;
|
int VideoMenuCount = 7;
|
||||||
char VideoMenu[5][MENU_STRING_LENGTH] = {
|
char VideoMenu[7][MENU_STRING_LENGTH] = {
|
||||||
{ MENU_VIDEO_SCALER }, { MENU_VIDEO_PALETTE },
|
{ MENU_VIDEO_SCALER }, { MENU_VIDEO_PALETTE },
|
||||||
{ MENU_VIDEO_SPRITE }, { MENU_VIDEO_TIMING },
|
{ MENU_VIDEO_SPRITE }, { MENU_VIDEO_TIMING },
|
||||||
|
{ MENU_VIDEO_SAVE }, { MENU_VIDEO_LOAD },
|
||||||
{ MENU_EXIT }
|
{ MENU_EXIT }
|
||||||
};
|
};
|
||||||
enum VIDEO_MENU {
|
enum VIDEO_MENU {
|
||||||
VIDEO_SCALER, VIDEO_PALETTE,
|
VIDEO_SCALER, VIDEO_PALETTE,
|
||||||
VIDEO_SPRITE, VIDEO_TIMING,
|
VIDEO_SPRITE, VIDEO_TIMING,
|
||||||
|
VIDEO_SAVE, VIDEO_LOAD,
|
||||||
VIDEO_EXIT
|
VIDEO_EXIT
|
||||||
};
|
};
|
||||||
unsigned char VideoMenuText[][512] = {
|
unsigned char VideoMenuText[][512] = {
|
||||||
@ -704,7 +701,6 @@ int VideoEnhancements() {
|
|||||||
FCEUD_SetPalette( i+64, r, g, b);
|
FCEUD_SetPalette( i+64, r, g, b);
|
||||||
FCEUD_SetPalette( i+128, r, g, b);
|
FCEUD_SetPalette( i+128, r, g, b);
|
||||||
FCEUD_SetPalette( i+192, r, g, b);
|
FCEUD_SetPalette( i+192, r, g, b);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -719,6 +715,14 @@ int VideoEnhancements() {
|
|||||||
FCEUI_SetVidSystem( timing );
|
FCEUI_SetVidSystem( timing );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIDEO_SAVE:
|
||||||
|
ManageSettings(0, ChosenSlot, ChosenDevice, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIDEO_LOAD:
|
||||||
|
ManageSettings(1, ChosenSlot, ChosenDevice, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
case VIDEO_EXIT:
|
case VIDEO_EXIT:
|
||||||
quit = 1;
|
quit = 1;
|
||||||
break;
|
break;
|
||||||
@ -828,7 +832,6 @@ int MediaSelect() {
|
|||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
strcpy(MediaMenu[MEDIA_DVD], MediaMenu[MEDIA_EXIT]);
|
strcpy(MediaMenu[MEDIA_DVD], MediaMenu[MEDIA_EXIT]);
|
||||||
MediaMenuCount = 3;
|
MediaMenuCount = 3;
|
||||||
ChosenSlot = SLOT_WIISD; // default to WiiSD
|
|
||||||
#else
|
#else
|
||||||
SdSlotCount = 2;
|
SdSlotCount = 2;
|
||||||
#endif
|
#endif
|
||||||
@ -876,6 +879,7 @@ int MediaSelect() {
|
|||||||
#else
|
#else
|
||||||
UseSDCARD = 0; //DVD
|
UseSDCARD = 0; //DVD
|
||||||
OpenDVD();
|
OpenDVD();
|
||||||
|
ChosenDevice = 1; // Memcard
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@ -1075,7 +1079,7 @@ int MainMenu() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MAIN_RELOAD:
|
case MAIN_RELOAD:
|
||||||
PSOReload();
|
Reload();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MAIN_REBOOT:
|
case MAIN_REBOOT:
|
||||||
@ -1101,7 +1105,6 @@ int MainMenu() {
|
|||||||
|
|
||||||
scroller(SCROLLY, MainMenuText, 7);
|
scroller(SCROLLY, MainMenuText, 7);
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Remove any still held buttons ***/
|
/*** Remove any still held buttons ***/
|
||||||
|
@ -80,6 +80,8 @@
|
|||||||
#define MENU_VIDEO_PALETTE "Palette"
|
#define MENU_VIDEO_PALETTE "Palette"
|
||||||
#define MENU_VIDEO_SPRITE "8 Sprite Maximum"
|
#define MENU_VIDEO_SPRITE "8 Sprite Maximum"
|
||||||
#define MENU_VIDEO_TIMING "Timing"
|
#define MENU_VIDEO_TIMING "Timing"
|
||||||
|
#define MENU_VIDEO_SAVE "Save Settings"
|
||||||
|
#define MENU_VIDEO_LOAD "Load Settings"
|
||||||
#define MENU_VIDEO_DEFAULT "Normaal"
|
#define MENU_VIDEO_DEFAULT "Normaal"
|
||||||
#define MENU_VIDEO_TEXT1 "Wow, deze kleuren en vormen zijn zeker mooi, Brengt terug de herideringen."
|
#define MENU_VIDEO_TEXT1 "Wow, deze kleuren en vormen zijn zeker mooi, Brengt terug de herideringen."
|
||||||
#define MENU_VIDEO_TEXT2 "Wees zeker niet met deze instellingen kloten, Je wilt niet deze ervaringen verkloten! :D"
|
#define MENU_VIDEO_TEXT2 "Wees zeker niet met deze instellingen kloten, Je wilt niet deze ervaringen verkloten! :D"
|
||||||
|
@ -80,6 +80,8 @@
|
|||||||
#define MENU_VIDEO_PALETTE "Palette"
|
#define MENU_VIDEO_PALETTE "Palette"
|
||||||
#define MENU_VIDEO_SPRITE "8 Sprite Limit"
|
#define MENU_VIDEO_SPRITE "8 Sprite Limit"
|
||||||
#define MENU_VIDEO_TIMING "Timing"
|
#define MENU_VIDEO_TIMING "Timing"
|
||||||
|
#define MENU_VIDEO_SAVE "Save Settings"
|
||||||
|
#define MENU_VIDEO_LOAD "Load Settings"
|
||||||
#define MENU_VIDEO_DEFAULT "Default"
|
#define MENU_VIDEO_DEFAULT "Default"
|
||||||
#define MENU_VIDEO_TEXT1 "Wow, these colors and shapes sure are beautiful, brings back the memories."
|
#define MENU_VIDEO_TEXT1 "Wow, these colors and shapes sure are beautiful, brings back the memories."
|
||||||
#define MENU_VIDEO_TEXT2 "Be sure not to mess these settings up, You don't want to ruin the experience! :D"
|
#define MENU_VIDEO_TEXT2 "Be sure not to mess these settings up, You don't want to ruin the experience! :D"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <gctypes.h>
|
#include <gctypes.h>
|
||||||
|
#include <ogc/system.h>
|
||||||
#include "../../types.h"
|
#include "../../types.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
@ -25,8 +26,7 @@ static volatile int userpause=0;
|
|||||||
static int soundvolume=100;
|
static int soundvolume=100;
|
||||||
static int soundquality=0;
|
static int soundquality=0;
|
||||||
static int soundo;
|
static int soundo;
|
||||||
|
u8 screenscaler = 2;
|
||||||
int screenscaler = 2;
|
|
||||||
|
|
||||||
uint8 *xbsave=NULL;
|
uint8 *xbsave=NULL;
|
||||||
int eoptions=EO_BGRUN | EO_FORCEISCALE;
|
int eoptions=EO_BGRUN | EO_FORCEISCALE;
|
||||||
@ -44,12 +44,23 @@ 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);
|
||||||
|
extern void ManageSettings(int mode, int slot, int device, int quiet);
|
||||||
|
extern u8 ChosenSlot;
|
||||||
|
extern u8 ChosenDevice;
|
||||||
|
|
||||||
extern void *PSOReload();
|
extern void *Reload();
|
||||||
|
extern void Reboot();
|
||||||
static void reset_cb() {
|
static void reset_cb() {
|
||||||
PSOReload();
|
Reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*static int power_hit = 0;
|
||||||
|
static void power_cb() {
|
||||||
|
//Reboot();
|
||||||
|
//SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||||
|
power_hit = 1;
|
||||||
|
}*/
|
||||||
|
|
||||||
extern int WaitPromptChoice (char *msg, char *bmsg, char *amsg);
|
extern int WaitPromptChoice (char *msg, char *bmsg, char *amsg);
|
||||||
bool isWii = false;
|
bool isWii = false;
|
||||||
static unsigned char *inquiry=(unsigned char *)0x80000004;
|
static unsigned char *inquiry=(unsigned char *)0x80000004;
|
||||||
@ -57,6 +68,7 @@ static unsigned char *inquiry=(unsigned char *)0x80000004;
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
initDisplay();
|
initDisplay();
|
||||||
SYS_SetResetCallback(reset_cb);
|
SYS_SetResetCallback(reset_cb);
|
||||||
|
//SYS_SetPowerCallback(power_cb);
|
||||||
InitialiseSound();
|
InitialiseSound();
|
||||||
SDCARD_Init ();
|
SDCARD_Init ();
|
||||||
|
|
||||||
@ -88,6 +100,8 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
cleanSFMDATA();
|
cleanSFMDATA();
|
||||||
GCMemROM();
|
GCMemROM();
|
||||||
|
// Load settings
|
||||||
|
ManageSettings(1, ChosenSlot, ChosenDevice, 1);
|
||||||
MainMenu();
|
MainMenu();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -98,6 +112,9 @@ int main(int argc, char *argv[]) {
|
|||||||
FCEUI_Emulate(&gfx, &sound, &ssize, 0);
|
FCEUI_Emulate(&gfx, &sound, &ssize, 0);
|
||||||
xbsave = gfx;
|
xbsave = gfx;
|
||||||
FCEUD_Update(gfx, sound, ssize);
|
FCEUD_Update(gfx, sound, ssize);
|
||||||
|
/*if (power_hit)
|
||||||
|
//SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||||
|
Reboot();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -8,12 +8,17 @@
|
|||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sdcard.h>
|
#include <sdcard.h>
|
||||||
|
#include <malloc.h>
|
||||||
#include "../../types.h"
|
#include "../../types.h"
|
||||||
#include "../../state.h"
|
#include "../../state.h"
|
||||||
#include "saveicon.h"
|
#include "saveicon.h"
|
||||||
|
#include "intl.h"
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
#include "wiisd/tff.h"
|
#include "wiisd/tff.h"
|
||||||
#include "wiisd/integer.h"
|
#include "wiisd/integer.h"
|
||||||
|
FATFS frontfs;
|
||||||
|
FILINFO finfo;
|
||||||
#endif
|
#endif
|
||||||
#define FCEUDIR "fceu"
|
#define FCEUDIR "fceu"
|
||||||
#define SAVEDIR "saves"
|
#define SAVEDIR "saves"
|
||||||
@ -24,6 +29,9 @@ extern void FCEUSND_SaveState(void);
|
|||||||
extern void WaitPrompt( char *text );
|
extern void WaitPrompt( char *text );
|
||||||
extern void FlipByteOrder(uint8 *src, uint32 count);
|
extern void FlipByteOrder(uint8 *src, uint32 count);
|
||||||
extern void ShowAction( char *text );
|
extern void ShowAction( char *text );
|
||||||
|
extern void FCEUD_SetPalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b);
|
||||||
|
extern void FCEU_ResetPalette(void);
|
||||||
|
extern void FCEUI_DisableSpriteLimitation( int a );
|
||||||
|
|
||||||
/*** External save structures ***/
|
/*** External save structures ***/
|
||||||
extern SFORMAT SFCPU[];
|
extern SFORMAT SFCPU[];
|
||||||
@ -43,12 +51,23 @@ int sboffset; /*** Used as a basic fileptr ***/
|
|||||||
int mcversion = 0x981211;
|
int mcversion = 0x981211;
|
||||||
|
|
||||||
static u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN(32);
|
static u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN(32);
|
||||||
#ifdef HW_RVL
|
extern u8 ChosenSlot;
|
||||||
FATFS frontfs;
|
extern u8 ChosenDevice;
|
||||||
FILINFO finfo;
|
extern u8 screenscaler;
|
||||||
#endif
|
extern u8 currpal;
|
||||||
extern int ChosenSlot;
|
extern u8 slimit;
|
||||||
extern int ChosenDevice;
|
extern u8 timing;
|
||||||
|
extern u8 mpads[6];
|
||||||
|
extern u8 FSDisable;
|
||||||
|
extern u8 PADCAL;
|
||||||
|
extern u8 PADTUR;
|
||||||
|
extern u8 UseSDCARD;
|
||||||
|
extern u8 UseWiiSDCARD;
|
||||||
|
|
||||||
|
extern struct st_palettes {
|
||||||
|
char *name, *desc;
|
||||||
|
unsigned int data[64];
|
||||||
|
} *palettes;
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Memory based file functions
|
* Memory based file functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -248,7 +267,7 @@ int GCFCEUSS_Save()
|
|||||||
static unsigned char header[16] = "FCS\xff";
|
static unsigned char header[16] = "FCS\xff";
|
||||||
char chunk[] = "CHKE";
|
char chunk[] = "CHKE";
|
||||||
int zero = 0;
|
int zero = 0;
|
||||||
char Comment[2][32] = { { "FCEU GC Version 1.0.9" }, { "A GAME" } };
|
char Comment[2][100] = { { MENU_CREDITS_TITLE }, { "A GAME" } };
|
||||||
|
|
||||||
memopen(); /*** Reset Memory File ***/
|
memopen(); /*** Reset Memory File ***/
|
||||||
|
|
||||||
@ -347,8 +366,7 @@ int MountTheCard()
|
|||||||
*
|
*
|
||||||
* This is based on the code from libogc
|
* This is based on the code from libogc
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
void MC_ManageState(int mode, int slot) {
|
||||||
void MCManage(int mode, int slot) {
|
|
||||||
char mcFilename[80];
|
char mcFilename[80];
|
||||||
int CardError;
|
int CardError;
|
||||||
card_dir CardDir;
|
card_dir CardDir;
|
||||||
@ -370,22 +388,18 @@ void MCManage(int mode, int slot) {
|
|||||||
/*** Try for memory card in slot A ***/
|
/*** Try for memory card in slot A ***/
|
||||||
CardError = MountTheCard();
|
CardError = MountTheCard();
|
||||||
|
|
||||||
if ( CardError >= 0 )
|
if ( CardError >= 0 ) {
|
||||||
{
|
|
||||||
/*** Get card sector size ***/
|
/*** Get card sector size ***/
|
||||||
CardError = CARD_GetSectorSize(CARDSLOT, &SectorSize);
|
CardError = CARD_GetSectorSize(CARDSLOT, &SectorSize);
|
||||||
|
|
||||||
switch ( mode ) {
|
switch ( mode ) {
|
||||||
|
|
||||||
case 0 : { /*** Save Game ***/
|
case 0 : { /*** Save Game ***/
|
||||||
/*** Look for this file ***/
|
/*** Look for this file ***/
|
||||||
CardError = CARD_FindFirst(CARDSLOT, &CardDir, true);
|
CardError = CARD_FindFirst(CARDSLOT, &CardDir, true);
|
||||||
|
|
||||||
found = 0;
|
found = 0;
|
||||||
|
|
||||||
card_stat CardStatus;
|
card_stat CardStatus;
|
||||||
while ( CardError != CARD_ERROR_NOFILE )
|
while ( CardError != CARD_ERROR_NOFILE ) {
|
||||||
{
|
|
||||||
CardError = CARD_FindNext(&CardDir);
|
CardError = CARD_FindNext(&CardDir);
|
||||||
if ( strcmp(CardDir.filename, mcFilename) == 0 )
|
if ( strcmp(CardDir.filename, mcFilename) == 0 )
|
||||||
found = 1;
|
found = 1;
|
||||||
@ -414,11 +428,9 @@ void MCManage(int mode, int slot) {
|
|||||||
CARD_SetStatus( CARDSLOT, CardFile.filenum, &CardStatus);
|
CARD_SetStatus( CARDSLOT, CardFile.filenum, &CardStatus);
|
||||||
|
|
||||||
/*** Haha! libogc only write one block at a time! ***/
|
/*** Haha! libogc only write one block at a time! ***/
|
||||||
if ( CardError == 0 )
|
if ( CardError == 0 ) {
|
||||||
{
|
|
||||||
int sbo = 0;
|
int sbo = 0;
|
||||||
while ( actualSize > 0 )
|
while ( actualSize > 0 ) {
|
||||||
{
|
|
||||||
CardError = CARD_Write(&CardFile, &statebuffer[sbo], SectorSize, sbo );
|
CardError = CARD_Write(&CardFile, &statebuffer[sbo], SectorSize, sbo );
|
||||||
actualSize -= SectorSize;
|
actualSize -= SectorSize;
|
||||||
sbo += SectorSize;
|
sbo += SectorSize;
|
||||||
@ -428,10 +440,11 @@ void MCManage(int mode, int slot) {
|
|||||||
sprintf(debug, "Saved %d bytes successfully!", savedBytes);
|
sprintf(debug, "Saved %d bytes successfully!", savedBytes);
|
||||||
ShowAction(debug);
|
ShowAction(debug);
|
||||||
}
|
}
|
||||||
else WaitPrompt("Save Failed!");
|
else {
|
||||||
|
WaitPrompt("Save Failed");
|
||||||
|
}
|
||||||
|
|
||||||
CARD_Unmount(CARDSLOT);
|
CARD_Unmount(CARDSLOT);
|
||||||
|
|
||||||
}
|
}
|
||||||
break; /*** End save ***/
|
break; /*** End save ***/
|
||||||
|
|
||||||
@ -440,7 +453,6 @@ void MCManage(int mode, int slot) {
|
|||||||
CardError = CARD_FindFirst(CARDSLOT, &CardDir, true);
|
CardError = CARD_FindFirst(CARDSLOT, &CardDir, true);
|
||||||
memopen(); /*** Clear the buffer ***/
|
memopen(); /*** Clear the buffer ***/
|
||||||
found = 0;
|
found = 0;
|
||||||
|
|
||||||
while ( CardError != CARD_ERROR_NOFILE ) {
|
while ( CardError != CARD_ERROR_NOFILE ) {
|
||||||
CardError = CARD_FindNext(&CardDir);
|
CardError = CARD_FindNext(&CardDir);
|
||||||
if ( strcmp(CardDir.filename, mcFilename) == 0 )
|
if ( strcmp(CardDir.filename, mcFilename) == 0 )
|
||||||
@ -476,7 +488,6 @@ void MCManage(int mode, int slot) {
|
|||||||
CARD_Unmount(CARDSLOT);
|
CARD_Unmount(CARDSLOT);
|
||||||
sprintf(debug, "Loaded %d bytes successfully!", savedBytes);
|
sprintf(debug, "Loaded %d bytes successfully!", savedBytes);
|
||||||
ShowAction(debug);
|
ShowAction(debug);
|
||||||
|
|
||||||
}
|
}
|
||||||
break; /*** End load ***/
|
break; /*** End load ***/
|
||||||
|
|
||||||
@ -487,7 +498,7 @@ void MCManage(int mode, int slot) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SD_Manage(int mode, int slot) {
|
void SD_ManageState(int mode, int slot) {
|
||||||
char path[1024];
|
char path[1024];
|
||||||
char msg[128];
|
char msg[128];
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@ -650,9 +661,356 @@ void SD_Manage(int mode, int slot) {
|
|||||||
|
|
||||||
void ManageState(int mode, int slot, int device) {
|
void ManageState(int mode, int slot, int device) {
|
||||||
if (device == 0) {
|
if (device == 0) {
|
||||||
MCManage(mode, slot);
|
MC_ManageState(mode, slot);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SD_Manage(mode, slot);
|
SD_ManageState(mode, slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* u8 screenscaler
|
||||||
|
* u8 currpal
|
||||||
|
* u8 slimit
|
||||||
|
* u8 timing
|
||||||
|
* u8 mpads[6]
|
||||||
|
* int FSDisable (int is u32, 4 bytes)
|
||||||
|
* u8 PADCAL
|
||||||
|
* u8 PADTUR
|
||||||
|
* u8 ChosenSlot
|
||||||
|
* u8 ChosenDevice
|
||||||
|
* u8 UseSDCARD
|
||||||
|
* u8 UseWiiSDCARD
|
||||||
|
*/
|
||||||
|
int SaveSettings(u8 *buffer) {
|
||||||
|
int filesize = 0;
|
||||||
|
buffer[filesize++] = screenscaler;
|
||||||
|
buffer[filesize++] = currpal;
|
||||||
|
buffer[filesize++] = slimit;
|
||||||
|
buffer[filesize++] = timing;
|
||||||
|
buffer[filesize++] = mpads[0];
|
||||||
|
buffer[filesize++] = mpads[1];
|
||||||
|
buffer[filesize++] = mpads[2];
|
||||||
|
buffer[filesize++] = mpads[3];
|
||||||
|
buffer[filesize++] = mpads[4];
|
||||||
|
buffer[filesize++] = mpads[5];
|
||||||
|
buffer[filesize++] = FSDisable;
|
||||||
|
buffer[filesize++] = PADCAL;
|
||||||
|
buffer[filesize++] = PADTUR;
|
||||||
|
buffer[filesize++] = ChosenSlot;
|
||||||
|
buffer[filesize++] = ChosenDevice;
|
||||||
|
buffer[filesize++] = UseSDCARD;
|
||||||
|
buffer[filesize++] = UseWiiSDCARD;
|
||||||
|
return filesize+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LoadSettings(u8 *buffer) {
|
||||||
|
int filesize = 0;
|
||||||
|
screenscaler = buffer[filesize++];
|
||||||
|
currpal = buffer[filesize++];
|
||||||
|
if (currpal == 0)
|
||||||
|
FCEU_ResetPalette();
|
||||||
|
else {
|
||||||
|
u8 r, g, b, i;
|
||||||
|
/*** Now setup this palette ***/
|
||||||
|
for ( i = 0; i < 64; i++ ) {
|
||||||
|
r = palettes[currpal-1].data[i] >> 16;
|
||||||
|
g = ( palettes[currpal-1].data[i] & 0xff00 ) >> 8;
|
||||||
|
b = ( palettes[currpal-1].data[i] & 0xff );
|
||||||
|
FCEUD_SetPalette( i, r, g, b);
|
||||||
|
FCEUD_SetPalette( i+64, r, g, b);
|
||||||
|
FCEUD_SetPalette( i+128, r, g, b);
|
||||||
|
FCEUD_SetPalette( i+192, r, g, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
slimit = buffer[filesize++];
|
||||||
|
FCEUI_DisableSpriteLimitation(slimit);
|
||||||
|
timing = buffer[filesize++];
|
||||||
|
FCEUI_SetVidSystem(timing);
|
||||||
|
mpads[0] = buffer[filesize++];
|
||||||
|
mpads[1] = buffer[filesize++];
|
||||||
|
mpads[2] = buffer[filesize++];
|
||||||
|
mpads[3] = buffer[filesize++];
|
||||||
|
mpads[4] = buffer[filesize++];
|
||||||
|
mpads[5] = buffer[filesize++];
|
||||||
|
FSDisable = buffer[filesize++];
|
||||||
|
FCEUI_DisableFourScore(FSDisable);
|
||||||
|
PADCAL = buffer[filesize++];
|
||||||
|
PADTUR = buffer[filesize++];
|
||||||
|
ChosenSlot = buffer[filesize++];
|
||||||
|
ChosenDevice = buffer[filesize++];
|
||||||
|
UseSDCARD = buffer[filesize++];
|
||||||
|
UseWiiSDCARD = buffer[filesize++];
|
||||||
|
return filesize+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Save Settings to MemCard
|
||||||
|
****************************************************************************/
|
||||||
|
void MC_ManageSettings(int mode, int slot, int quiet) {
|
||||||
|
char mcFilename[80];
|
||||||
|
int CardError;
|
||||||
|
card_dir CardDir;
|
||||||
|
card_file CardFile;
|
||||||
|
int SectorSize;
|
||||||
|
int found = 0;
|
||||||
|
int FileSize;
|
||||||
|
int actualSize;
|
||||||
|
int savedBytes=0;
|
||||||
|
char msg[128];
|
||||||
|
|
||||||
|
/*** Build the file name ***/
|
||||||
|
strcpy(mcFilename, "FCEU-Settings.fcs");
|
||||||
|
|
||||||
|
/*** Mount the Card ***/
|
||||||
|
CARD_Init("FCEU", "00");
|
||||||
|
|
||||||
|
/*** Try for memory card in slot A ***/
|
||||||
|
CardError = MountTheCard();
|
||||||
|
|
||||||
|
if ( CardError >= 0 ) {
|
||||||
|
/*** Get card sector size ***/
|
||||||
|
CardError = CARD_GetSectorSize(slot, &SectorSize);
|
||||||
|
|
||||||
|
switch ( mode ) {
|
||||||
|
case 0 : { /*** Save Game ***/
|
||||||
|
/*** Look for this file ***/
|
||||||
|
CardError = CARD_FindFirst(slot, &CardDir, true);
|
||||||
|
|
||||||
|
found = 0;
|
||||||
|
card_stat CardStatus;
|
||||||
|
while ( CardError != CARD_ERROR_NOFILE ) {
|
||||||
|
CardError = CARD_FindNext(&CardDir);
|
||||||
|
if ( strcmp(CardDir.filename, mcFilename) == 0 )
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** Determine number of bytes required ***/
|
||||||
|
u8 buffer[SectorSize];
|
||||||
|
memset(buffer, 0, SectorSize);
|
||||||
|
actualSize = SaveSettings(buffer);
|
||||||
|
savedBytes = actualSize;
|
||||||
|
|
||||||
|
sprintf(msg, "Saving Settings to MC ...");
|
||||||
|
ShowAction(msg);
|
||||||
|
|
||||||
|
FileSize = ( actualSize / SectorSize ) * SectorSize;
|
||||||
|
if ( (actualSize % SectorSize) || (FileSize == 0) )
|
||||||
|
FileSize += SectorSize;
|
||||||
|
|
||||||
|
/*** Now write the file out ***/
|
||||||
|
if ( !found )
|
||||||
|
CardError = CARD_Create(CARDSLOT, mcFilename, FileSize, &CardFile);
|
||||||
|
else
|
||||||
|
CardError = CARD_Open(CARDSLOT, mcFilename, &CardFile);
|
||||||
|
|
||||||
|
CARD_GetStatus( CARDSLOT, CardFile.filenum, &CardStatus);
|
||||||
|
CardStatus.icon_addr = 0;
|
||||||
|
CardStatus.icon_fmt = 2;
|
||||||
|
CardStatus.icon_speed = 1;
|
||||||
|
CardStatus.comment_addr = sizeof(saveicon);
|
||||||
|
CARD_SetStatus( CARDSLOT, CardFile.filenum, &CardStatus);
|
||||||
|
|
||||||
|
/*** Haha! libogc only write one block at a time! ***/
|
||||||
|
if ( CardError == 0 ) {
|
||||||
|
int sbo = 0;
|
||||||
|
while ( actualSize > 0 ) {
|
||||||
|
CardError = CARD_Write(&CardFile, &buffer[sbo], SectorSize, sbo );
|
||||||
|
actualSize -= SectorSize;
|
||||||
|
sbo += SectorSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
CardError = CARD_Close(&CardFile);
|
||||||
|
strcpy(msg, "Saved settings successfully");
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
strcpy(msg, "Save Settings Failed!");
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
CARD_Unmount(CARDSLOT);
|
||||||
|
}
|
||||||
|
break; /*** End save ***/
|
||||||
|
|
||||||
|
case 1: { /*** Load state ***/
|
||||||
|
/*** Look for this file ***/
|
||||||
|
CardError = CARD_FindFirst(CARDSLOT, &CardDir, true);
|
||||||
|
found = 0;
|
||||||
|
|
||||||
|
while ( CardError != CARD_ERROR_NOFILE ) {
|
||||||
|
CardError = CARD_FindNext(&CardDir);
|
||||||
|
if ( strcmp(CardDir.filename, mcFilename) == 0 )
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( found == 0 ) {
|
||||||
|
strcpy(msg, "No Settings Found");
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
CARD_Unmount(CARDSLOT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 buffer[SectorSize];
|
||||||
|
/*** Load the file into memory ***/
|
||||||
|
CardError = CARD_Open(CARDSLOT, mcFilename, &CardFile);
|
||||||
|
CardError = CARD_Read(&CardFile, &buffer, SectorSize, 0);
|
||||||
|
|
||||||
|
CARD_Close(&CardFile);
|
||||||
|
|
||||||
|
/*** Finally, do load ***/
|
||||||
|
savedBytes = LoadSettings(buffer);
|
||||||
|
sprintf(msg, "Loaded settings successfully!");
|
||||||
|
ShowAction(msg);
|
||||||
|
CARD_Unmount(CARDSLOT);
|
||||||
|
}
|
||||||
|
break; /*** End load ***/
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
strcpy(msg, "Cannot mount Memory Card!");
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SD_ManageSettings(int mode, int slot, int quiet) {
|
||||||
|
char path[1024];
|
||||||
|
char msg[128];
|
||||||
|
int filesize = 0;
|
||||||
|
int len = 0;
|
||||||
|
u8 buffer[128];
|
||||||
|
|
||||||
|
if (slot < 2) {
|
||||||
|
sd_file *handle;
|
||||||
|
sprintf (path, "dev%d:\\%s\\%s\\Settings.fcs", ChosenSlot, FCEUDIR, SAVEDIR);
|
||||||
|
|
||||||
|
if (mode == 0) ShowAction ("Saving Settings to SD...");
|
||||||
|
else ShowAction ("Loading Settings from SD...");
|
||||||
|
|
||||||
|
handle = SDCARD_OpenFile(path, (mode == 0) ? "wb" : "rb");
|
||||||
|
|
||||||
|
if (handle == NULL) {
|
||||||
|
sprintf(msg, "Couldn't open %s", path);
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == 0) { // Save
|
||||||
|
filesize = SaveSettings(buffer);
|
||||||
|
|
||||||
|
len = SDCARD_WriteFile(handle, buffer, filesize);
|
||||||
|
SDCARD_CloseFile(handle);
|
||||||
|
|
||||||
|
if (len != filesize) {
|
||||||
|
sprintf (msg, "Error writing %s", path);
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(msg, "Saved settings successfully");
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
} else { // Load
|
||||||
|
len = SDCARD_ReadFile(handle, buffer, 128);
|
||||||
|
SDCARD_CloseFile (handle);
|
||||||
|
|
||||||
|
/*** Finally, do load ***/
|
||||||
|
filesize = LoadSettings(buffer);
|
||||||
|
|
||||||
|
sprintf (msg, "Loaded settings successfully");
|
||||||
|
ShowAction(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else { // WiiSD
|
||||||
|
#ifdef HW_RVL
|
||||||
|
if (mode == 0) ShowAction ("Saving Settings to WiiSD...");
|
||||||
|
else ShowAction ("Loading Settings from WiiSD...");
|
||||||
|
|
||||||
|
sprintf(path, "/%s/%s/Settings.fcs", FCEUDIR, SAVEDIR);
|
||||||
|
FIL fp;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
/* Mount WiiSD with TinyFatFS*/
|
||||||
|
if(f_mount(0, &frontfs) != FR_OK) {
|
||||||
|
strcpy(msg, "f_mount failed");
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (mode == 0)
|
||||||
|
res = f_open(&fp, path, FA_CREATE_ALWAYS | FA_WRITE);
|
||||||
|
else {
|
||||||
|
if ((res=f_stat(path, &finfo)) != FR_OK) {
|
||||||
|
if (res == FR_NO_FILE) {
|
||||||
|
sprintf(msg, "Unable to find %s.", path);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sprintf(msg, "f_stat failed, error %d", res);
|
||||||
|
}
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
res = f_open(&fp, path, FA_READ);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res != FR_OK) {
|
||||||
|
sprintf(msg, "Failed to open %s, error %d.", path, res);
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == 0) { // Save
|
||||||
|
u32 written = 0;
|
||||||
|
filesize = SaveSettings(buffer);
|
||||||
|
|
||||||
|
if ((res = f_write(&fp, buffer, filesize, &written)) != FR_OK) {
|
||||||
|
sprintf(msg, "f_write failed, error %d", res);
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
f_close(&fp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sprintf(msg, "Wrote %d bytes.", filesize);
|
||||||
|
ShowAction(msg);
|
||||||
|
f_close(&fp);
|
||||||
|
return;
|
||||||
|
} else { // Load
|
||||||
|
u32 bytes_read = 0;
|
||||||
|
filesize = 0;
|
||||||
|
|
||||||
|
if (f_read(&fp, &buffer, 128, &bytes_read) != FR_OK) {
|
||||||
|
strcpy(msg, "f_read failed");
|
||||||
|
if (quiet) ShowAction(msg);
|
||||||
|
else WaitPrompt(msg);
|
||||||
|
f_close(&fp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** Finally, do load ***/
|
||||||
|
filesize = LoadSettings(buffer);
|
||||||
|
|
||||||
|
sprintf(msg, "Read %d bytes.", bytes_read);
|
||||||
|
ShowAction(msg);
|
||||||
|
f_close(&fp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ManageSettings(int mode, int slot, int device, int quiet) {
|
||||||
|
if (device == 0) {
|
||||||
|
MC_ManageSettings(mode, slot, quiet);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SD_ManageSettings(mode, slot, quiet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ unsigned int nespadmap[] = { JOY_A, JOY_B, JOY_START, JOY_SELECT, JOY_A, JOY_B,
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Convert GC Joystick Readings to JOY
|
* Convert GC Joystick Readings to JOY
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int PADTUR = 2;
|
u8 PADTUR = 2;
|
||||||
|
|
||||||
unsigned char DecodeJoy( unsigned short pp )
|
unsigned char DecodeJoy( unsigned short pp )
|
||||||
{
|
{
|
||||||
@ -86,7 +86,7 @@ unsigned char DecodeJoy( unsigned short pp )
|
|||||||
*
|
*
|
||||||
* Additional check for Analog X/Y
|
* Additional check for Analog X/Y
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int PADCAL = 40;
|
u8 PADCAL = 40;
|
||||||
|
|
||||||
unsigned char GetAnalog(int Joy)
|
unsigned char GetAnalog(int Joy)
|
||||||
{
|
{
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include "gcdvd.h"
|
#include "gcdvd.h"
|
||||||
#include "sz.h"
|
#include "sz.h"
|
||||||
|
|
||||||
extern int UseSDCARD;
|
extern u8 UseSDCARD;
|
||||||
extern int UseWiiSDCARD;
|
extern u8 UseWiiSDCARD;
|
||||||
extern sd_file *filehandle;
|
extern sd_file *filehandle;
|
||||||
|
|
||||||
// 7zip error list
|
// 7zip error list
|
||||||
|
Loading…
Reference in New Issue
Block a user