FDS saving works now!

This commit is contained in:
dborth 2008-10-09 04:25:35 +00:00
parent 219e471f83
commit 6ee208a9c3
4 changed files with 37 additions and 32 deletions

View File

@ -41,8 +41,8 @@
#include "video.h" #include "video.h"
static void (*SPreSave)(void); void (*SPreSave)(void);
static void (*SPostSave)(void); void (*SPostSave)(void);
static int SaveStateStatus[10]; static int SaveStateStatus[10];
static int StateShow; static int StateShow;
@ -113,15 +113,15 @@ static int SubWrite(FILE *st, SFORMAT *sf)
if(sf->s&RLSB) if(sf->s&RLSB)
FlipByteOrder(sf->v,sf->s&(~RLSB)); FlipByteOrder(sf->v,sf->s&(~RLSB));
#endif #endif
fwrite((uint8 *)sf->v,1,sf->s&(~RLSB),st); fwrite((uint8 *)sf->v,1,sf->s&(~RLSB),st);
/* Now restore the original byte order. */ /* Now restore the original byte order. */
#ifndef LSB_FIRST #ifndef LSB_FIRST
if(sf->s&RLSB) if(sf->s&RLSB)
FlipByteOrder(sf->v,sf->s&(~RLSB)); FlipByteOrder(sf->v,sf->s&(~RLSB));
#endif #endif
} }
sf++; sf++;
} }
return(acc); return(acc);
@ -132,9 +132,9 @@ static int WriteStateChunk(FILE *st, int type, SFORMAT *sf)
int bsize; int bsize;
fputc(type,st); fputc(type,st);
bsize=SubWrite(0,sf); bsize=SubWrite(0,sf);
write32le(bsize,st); write32le(bsize,st);
if(!SubWrite(st,sf)) return(0); if(!SubWrite(st,sf)) return(0);
return (bsize+5); return (bsize+5);
@ -235,11 +235,11 @@ int FCEUSS_SaveFP(FILE *st)
{ {
static uint32 totalsize; static uint32 totalsize;
static uint8 header[16]="FCS"; static uint8 header[16]="FCS";
memset(header+4,0,13); memset(header+4,0,13);
header[3]=0xFF; header[3]=0xFF;
FCEU_en32lsb(header + 8, FCEU_VERSION_NUMERIC); FCEU_en32lsb(header + 8, FCEU_VERSION_NUMERIC);
fwrite(header,1,16,st); fwrite(header,1,16,st);
FCEUPPU_SaveState(); FCEUPPU_SaveState();
FCEUSND_SaveState(); FCEUSND_SaveState();
totalsize=WriteStateChunk(st,1,SFCPU); totalsize=WriteStateChunk(st,1,SFCPU);
@ -305,12 +305,12 @@ int FCEUSS_LoadFP(FILE *st)
x=ReadStateChunks(st,*(uint32*)(header+4)); x=ReadStateChunks(st,*(uint32*)(header+4));
if(stateversion<9500) X.IRQlow=0; if(stateversion<9500) X.IRQlow=0;
if(GameStateRestore) GameStateRestore(stateversion); if(GameStateRestore) GameStateRestore(stateversion);
if(x) if(x)
{ {
FCEUPPU_LoadState(stateversion); FCEUPPU_LoadState(stateversion);
FCEUSND_LoadState(stateversion); FCEUSND_LoadState(stateversion);
} }
return(x); return(x);
} }
@ -348,7 +348,7 @@ int FCEUSS_Load(char *fname)
SaveStateStatus[CurrentState]=1; SaveStateStatus[CurrentState]=1;
fclose(st); fclose(st);
return(1); return(1);
} }
else else
{ {
SaveStateStatus[CurrentState]=1; SaveStateStatus[CurrentState]=1;
@ -418,7 +418,7 @@ void FCEUI_SelectState(int w)
CurrentState=w; CurrentState=w;
StateShow=180; StateShow=180;
FCEU_DispMessage("-select state-"); FCEU_DispMessage("-select state-");
} }
void FCEUI_SaveState(char *fname) void FCEUI_SaveState(char *fname)
{ {
@ -448,7 +448,7 @@ void FCEUI_LoadState(char *fname)
if(FCEUSS_SaveFP(fp)) if(FCEUSS_SaveFP(fp))
{ {
fclose(fp); fclose(fp);
FCEUNET_SendFile(FCEUNPCMD_LOADSTATE, fn); FCEUNET_SendFile(FCEUNPCMD_LOADSTATE, fn);
} }
else fclose(fp); else fclose(fp);
/*** REMOVED GC V1.0 /*** REMOVED GC V1.0

View File

@ -221,6 +221,9 @@ int GCSaveChunk(int chunkid, SFORMAT *sf) {
* It uses memory for it's I/O and has an added CHNK block. * It uses memory for it's I/O and has an added CHNK block.
* The file is terminated with CHNK length of 0. * The file is terminated with CHNK length of 0.
****************************************************************************/ ****************************************************************************/
extern void (*SPreSave)(void);
extern void (*SPostSave)(void);
int GCFCEUSS_Save() int GCFCEUSS_Save()
{ {
int totalsize = 0; int totalsize = 0;
@ -244,6 +247,7 @@ int GCFCEUSS_Save()
/*** And Comments ***/ /*** And Comments ***/
strncpy (Comment[1],romFilename,31); // we only have 32 chars to work with! strncpy (Comment[1],romFilename,31); // we only have 32 chars to work with!
Comment[1][31] = 0;
memfwrite(&Comment[0], 64); memfwrite(&Comment[0], 64);
totalsize += 64; totalsize += 64;
@ -255,8 +259,15 @@ int GCFCEUSS_Save()
totalsize += GCSaveChunk(3, FCEUPPU_STATEINFO); totalsize += GCSaveChunk(3, FCEUPPU_STATEINFO);
totalsize += GCSaveChunk(4, FCEUCTRL_STATEINFO); totalsize += GCSaveChunk(4, FCEUCTRL_STATEINFO);
totalsize += GCSaveChunk(5, FCEUSND_STATEINFO); totalsize += GCSaveChunk(5, FCEUSND_STATEINFO);
if(nesGameType == 4) // FDS
SPreSave();
totalsize += GCSaveChunk(0x10, SFMDATA); totalsize += GCSaveChunk(0x10, SFMDATA);
if(nesGameType == 4) // FDS
SPostSave();
/*** Add terminating CHNK ***/ /*** Add terminating CHNK ***/
memfwrite(&chunk,4); memfwrite(&chunk,4);
memfwrite(&zero,4); memfwrite(&zero,4);
@ -270,13 +281,6 @@ int GCFCEUSS_Save()
bool SaveState (int method, bool silent) bool SaveState (int method, bool silent)
{ {
if(nesGameType == 4)
{
if(!silent)
WaitPrompt((char *)"Saving is not available for FDS games!");
return false;
}
ShowAction ((char*) "Saving..."); ShowAction ((char*) "Saving...");
if(method == METHOD_AUTO) if(method == METHOD_AUTO)
@ -326,13 +330,6 @@ bool SaveState (int method, bool silent)
bool LoadState (int method, bool silent) bool LoadState (int method, bool silent)
{ {
if(nesGameType == 4)
{
if(!silent)
WaitPrompt((char *)"Saving is not available for FDS games!");
return false;
}
ShowAction ((char*) "Loading..."); ShowAction ((char*) "Loading...");
if(method == METHOD_AUTO) if(method == METHOD_AUTO)

View File

@ -14,7 +14,7 @@
#include <unistd.h> #include <unistd.h>
#define SAVEBUFFERSIZE (64 * 1024) #define SAVEBUFFERSIZE (512 * 1024)
#define MAXJOLIET 255 #define MAXJOLIET 255
#define MAXDISPLAY 54 #define MAXDISPLAY 54

View File

@ -241,6 +241,10 @@ PreferencesMenu ()
GCSettings.SaveMethod++; GCSettings.SaveMethod++;
if(GCSettings.SaveMethod == METHOD_MC_SLOTB) if(GCSettings.SaveMethod == METHOD_MC_SLOTB)
GCSettings.SaveMethod++; GCSettings.SaveMethod++;
prefmenu[6][0] = '\0';
#else
sprintf (prefmenu[6], "Verify MC Saves %s",
GCSettings.VerifySaves == true ? " ON" : "OFF");
#endif #endif
// correct load/save methods out of bounds // correct load/save methods out of bounds
@ -279,9 +283,6 @@ PreferencesMenu ()
else if (GCSettings.AutoSave == 2) sprintf (prefmenu[5],"Auto Save STATE"); else if (GCSettings.AutoSave == 2) sprintf (prefmenu[5],"Auto Save STATE");
else if (GCSettings.AutoSave == 3) sprintf (prefmenu[5],"Auto Save BOTH"); else if (GCSettings.AutoSave == 3) sprintf (prefmenu[5],"Auto Save BOTH");
sprintf (prefmenu[6], "Verify MC Saves %s",
GCSettings.VerifySaves == true ? " ON" : "OFF");
ret = RunMenu (prefmenu, prefmenuCount, (char*)"Preferences", 16, -1); ret = RunMenu (prefmenu, prefmenuCount, (char*)"Preferences", 16, -1);
switch (ret) switch (ret)
@ -354,6 +355,13 @@ GameMenu ()
while (quit == 0) while (quit == 0)
{ {
// disable RAM saving/loading for FDS games
if(nesGameType == 4)
{
gamemenu[3][0] = '\0';
gamemenu[4][0] = '\0';
}
// disable RAM/STATE saving/loading if AUTO is on // disable RAM/STATE saving/loading if AUTO is on
if (GCSettings.AutoLoad == 1) // Auto Load RAM if (GCSettings.AutoLoad == 1) // Auto Load RAM
gamemenu[3][0] = '\0'; gamemenu[3][0] = '\0';