Merged rewind with ZST. Todo: fix snapshot display, old state compatibility, sram options.
This commit is contained in:
@@ -61,7 +61,7 @@ EXTSYM deinitipx
|
|||||||
%endif
|
%endif
|
||||||
EXTSYM deinitvideo
|
EXTSYM deinitvideo
|
||||||
EXTSYM BRRBuffer,DSPMem,PrepareSaveState,ResetState,SFXEnable,PHdspsave
|
EXTSYM BRRBuffer,DSPMem,PrepareSaveState,ResetState,SFXEnable,PHdspsave
|
||||||
EXTSYM fnamest,sndrot,spcRam,spcRamDP,tableA,unpackfunct,vram,wramdata
|
EXTSYM fnamest,sndrot,spcRam,spcRamDP,tableA,vram,wramdata
|
||||||
EXTSYM PHnum2writesfxreg,SfxR0,PHspcsave
|
EXTSYM PHnum2writesfxreg,SfxR0,PHspcsave
|
||||||
EXTSYM C4Ram
|
EXTSYM C4Ram
|
||||||
EXTSYM SPC7110Enable
|
EXTSYM SPC7110Enable
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|||||||
#define stim()
|
#define stim()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*Let's start converting stuff from execute.asm ^_^;
|
//static unsigned char save_state_buffer[0x80000]; //Save state should never exceed half a megabyte
|
||||||
Big thanks to Nach, TRAC and anomie for helping me out on porting !!*/
|
|
||||||
|
|
||||||
extern unsigned int CBackupPos, PBackupPos, cycpbl;
|
extern unsigned int CBackupPos, PBackupPos, cycpbl;
|
||||||
extern unsigned int *wramdata, *vram, PHspcsave, PHdspsave, *C4Ram, *sfxramdata;
|
extern unsigned int *wramdata, *vram, PHspcsave, PHdspsave, *C4Ram, *sfxramdata;
|
||||||
@@ -68,33 +67,19 @@ extern short Op28X, Op0CA, Op02FX, Op0AVS, Op06X, Op01m, Op0DX, Op03F, Op14Zr;
|
|||||||
extern short Op0EH;
|
extern short Op0EH;
|
||||||
extern signed short Op10Coefficient;
|
extern signed short Op10Coefficient;
|
||||||
|
|
||||||
void memcpyinc(unsigned char **dest, void *src, size_t len)
|
|
||||||
{
|
|
||||||
memcpy(*dest, src, len);
|
|
||||||
*dest += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
void memcpyrinc(unsigned char **src, void *dest, size_t len)
|
|
||||||
{
|
|
||||||
memcpy(*src, dest, len);
|
|
||||||
*src += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
char zsmesg[] = "ZSNES Save State File V0.6";
|
|
||||||
|
|
||||||
void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **, void *, size_t), bool file)
|
void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **, void *, size_t), bool file)
|
||||||
{
|
{
|
||||||
if (file)
|
//65816 status, etc.
|
||||||
{
|
|
||||||
copy_func(&buffer, zsmesg, sizeof(zsmesg)-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//SPC Timers
|
||||||
copy_func(&buffer, &cycpbl, 2*4);
|
copy_func(&buffer, &cycpbl, 2*4);
|
||||||
|
//SNES PPU Register status
|
||||||
copy_func(&buffer, &sndrot, 3019);
|
copy_func(&buffer, &sndrot, 3019);
|
||||||
|
//WRAM (128k), VRAM (64k)
|
||||||
copy_func(&buffer, wramdata, 8192*16);
|
copy_func(&buffer, wramdata, 8192*16);
|
||||||
copy_func(&buffer, vram, 4096*16);
|
copy_func(&buffer, vram, 4096*16);
|
||||||
|
|
||||||
if (spcon)
|
if (spcon) //SPC stuff, DSP stuff
|
||||||
{
|
{
|
||||||
copy_func(&buffer, spcRam, PHspcsave);
|
copy_func(&buffer, spcRam, PHspcsave);
|
||||||
copy_func(&buffer, BRRBuffer, PHdspsave);
|
copy_func(&buffer, BRRBuffer, PHdspsave);
|
||||||
@@ -118,7 +103,6 @@ void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **,
|
|||||||
copy_func(&buffer, SA1RAMArea, 8192*16);
|
copy_func(&buffer, SA1RAMArea, 8192*16);
|
||||||
copy_func(&buffer, &SA1Status, 3);
|
copy_func(&buffer, &SA1Status, 3);
|
||||||
copy_func(&buffer, &SA1xpc, 1*4);
|
copy_func(&buffer, &SA1xpc, 1*4);
|
||||||
copy_func(&buffer, &SA1RAMArea, 6*4);
|
|
||||||
copy_func(&buffer, &sa1dmaptr, 2*4);
|
copy_func(&buffer, &sa1dmaptr, 2*4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +131,9 @@ void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **,
|
|||||||
if (SETAEnable)
|
if (SETAEnable)
|
||||||
{
|
{
|
||||||
copy_func(&buffer, setaramdata, 256*16);
|
copy_func(&buffer, setaramdata, 256*16);
|
||||||
|
|
||||||
|
//Todo: save the SetaCmdEnable? For completeness we should do it
|
||||||
|
//but currently we ignore it anyway.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SPC7110Enable)
|
if (SPC7110Enable)
|
||||||
@@ -178,12 +165,25 @@ void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void memcpyinc(unsigned char **dest, void *src, size_t len)
|
||||||
|
{
|
||||||
|
memcpy(*dest, src, len);
|
||||||
|
*dest += len;
|
||||||
|
}
|
||||||
|
|
||||||
void BackupCVFrame()
|
void BackupCVFrame()
|
||||||
{
|
{
|
||||||
unsigned char *curpos = StateBackup + (CBackupPos << 19) + 1024;
|
unsigned char *curpos = StateBackup + (CBackupPos << 19) + 1024;
|
||||||
copy_state_data(curpos, memcpyinc, false);
|
copy_state_data(curpos, memcpyinc, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void memcpyrinc(unsigned char **src, void *dest, size_t len)
|
||||||
|
{
|
||||||
|
memcpy(dest, *src, len);
|
||||||
|
*src += len;
|
||||||
|
}
|
||||||
|
|
||||||
void RestoreCVFrame()
|
void RestoreCVFrame()
|
||||||
{
|
{
|
||||||
unsigned char *curpos = StateBackup + (PBackupPos << 19) + 1024;
|
unsigned char *curpos = StateBackup + (PBackupPos << 19) + 1024;
|
||||||
@@ -213,22 +213,6 @@ void SA1UpdateDPageC()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern unsigned int spcBuffera;
|
|
||||||
extern unsigned int Voice0BufPtr, Voice1BufPtr, Voice2BufPtr, Voice3BufPtr;
|
|
||||||
extern unsigned int Voice4BufPtr, Voice5BufPtr, Voice6BufPtr, Voice7BufPtr;
|
|
||||||
|
|
||||||
void PrepareSaveState()
|
|
||||||
{
|
|
||||||
Voice0BufPtr -= spcBuffera;
|
|
||||||
Voice1BufPtr -= spcBuffera;
|
|
||||||
Voice2BufPtr -= spcBuffera;
|
|
||||||
Voice3BufPtr -= spcBuffera;
|
|
||||||
Voice4BufPtr -= spcBuffera;
|
|
||||||
Voice5BufPtr -= spcBuffera;
|
|
||||||
Voice6BufPtr -= spcBuffera;
|
|
||||||
Voice7BufPtr -= spcBuffera;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern unsigned int xdb, xpb, xs, xx, xy;
|
extern unsigned int xdb, xpb, xs, xx, xy;
|
||||||
extern unsigned short oamaddrt, xat, xst, xdt, xxt, xyt;
|
extern unsigned short oamaddrt, xat, xst, xdt, xxt, xyt;
|
||||||
extern unsigned char xdbt, xpbt;
|
extern unsigned char xdbt, xpbt;
|
||||||
@@ -245,6 +229,33 @@ void unpackfunct()
|
|||||||
xyt = (xy & 0xFFFF);
|
xyt = (xy & 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern unsigned int spcBuffera;
|
||||||
|
extern unsigned int Voice0BufPtr, Voice1BufPtr, Voice2BufPtr, Voice3BufPtr;
|
||||||
|
extern unsigned int Voice4BufPtr, Voice5BufPtr, Voice6BufPtr, Voice7BufPtr;
|
||||||
|
extern unsigned int Curtableaddr, tableA[256], spcPCRam, spcRamDP;
|
||||||
|
|
||||||
|
void PrepareSaveState()
|
||||||
|
{
|
||||||
|
unsigned int offst;
|
||||||
|
|
||||||
|
offst = (unsigned int)tableA;
|
||||||
|
Curtableaddr -= offst;
|
||||||
|
offst = (unsigned int)spcRam;
|
||||||
|
spcPCRam -= offst;
|
||||||
|
spcRamDP -= offst;
|
||||||
|
|
||||||
|
Voice0BufPtr -= spcBuffera;
|
||||||
|
Voice1BufPtr -= spcBuffera;
|
||||||
|
Voice2BufPtr -= spcBuffera;
|
||||||
|
Voice3BufPtr -= spcBuffera;
|
||||||
|
Voice4BufPtr -= spcBuffera;
|
||||||
|
Voice5BufPtr -= spcBuffera;
|
||||||
|
Voice6BufPtr -= spcBuffera;
|
||||||
|
Voice7BufPtr -= spcBuffera;
|
||||||
|
|
||||||
|
unpackfunct();
|
||||||
|
}
|
||||||
|
|
||||||
#define byteset(byte, checkbit) (byte & (1 << checkbit)) ? 1 : 0
|
#define byteset(byte, checkbit) (byte & (1 << checkbit)) ? 1 : 0
|
||||||
|
|
||||||
extern unsigned int GlobalVL, GlobalVR, EchoVL, EchoVR, EchoRate[16], MaxEcho;
|
extern unsigned int GlobalVL, GlobalVR, EchoVL, EchoVR, EchoRate[16], MaxEcho;
|
||||||
@@ -443,6 +454,14 @@ void RestoreSA1()
|
|||||||
|
|
||||||
void ResetState()
|
void ResetState()
|
||||||
{
|
{
|
||||||
|
unsigned int offst;
|
||||||
|
|
||||||
|
offst = (unsigned int)tableA;
|
||||||
|
Curtableaddr += offst;
|
||||||
|
offst = (unsigned int)spcRam;
|
||||||
|
spcPCRam += offst;
|
||||||
|
spcRamDP += offst;
|
||||||
|
|
||||||
ResState(Voice0BufPtr);
|
ResState(Voice0BufPtr);
|
||||||
ResState(Voice1BufPtr);
|
ResState(Voice1BufPtr);
|
||||||
ResState(Voice2BufPtr);
|
ResState(Voice2BufPtr);
|
||||||
@@ -453,7 +472,6 @@ void ResetState()
|
|||||||
ResState(Voice7BufPtr);
|
ResState(Voice7BufPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern unsigned int Curtableaddr, tableA[256], spcPCRam, spcRamDP;
|
|
||||||
extern unsigned int statefileloc, CurrentHandle, SfxRomBuffer;
|
extern unsigned int statefileloc, CurrentHandle, SfxRomBuffer;
|
||||||
extern unsigned int SfxCROM, SfxLastRamAdr, SfxRAMMem;
|
extern unsigned int SfxCROM, SfxLastRamAdr, SfxRAMMem;
|
||||||
extern unsigned int MsgCount, MessageOn;
|
extern unsigned int MsgCount, MessageOn;
|
||||||
@@ -464,27 +482,20 @@ extern unsigned char *Msgptr, txtsavemsgfail[15];
|
|||||||
|
|
||||||
extern unsigned short PrevPicture[64*56];
|
extern unsigned short PrevPicture[64*56];
|
||||||
|
|
||||||
FILE *fhandle;
|
static FILE *fhandle;
|
||||||
void SRAMChdir();
|
void SRAMChdir();
|
||||||
void CapturePicture();
|
void CapturePicture();
|
||||||
|
|
||||||
|
static void write_save_state_data(unsigned char **dest, void *data, size_t len)
|
||||||
|
{
|
||||||
|
fwrite(data, 1, len, fhandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char zsmesg[] = "ZSNES Save State File V0.6";
|
||||||
|
|
||||||
void statesaver()
|
void statesaver()
|
||||||
{
|
{
|
||||||
unsigned int offst;
|
|
||||||
|
|
||||||
clim();
|
|
||||||
|
|
||||||
offst = (unsigned int)tableA;
|
|
||||||
Curtableaddr -= offst;
|
|
||||||
offst = (unsigned int)spcRam;
|
|
||||||
spcPCRam -= offst;
|
|
||||||
spcRamDP -= offst;
|
|
||||||
|
|
||||||
PrepareSaveState();
|
|
||||||
unpackfunct();
|
|
||||||
|
|
||||||
//'Auto increment savestate slot' code
|
//'Auto increment savestate slot' code
|
||||||
|
|
||||||
if (AutoIncSaveSlot)
|
if (AutoIncSaveSlot)
|
||||||
{
|
{
|
||||||
if (firstsaveinc)
|
if (firstsaveinc)
|
||||||
@@ -513,63 +524,47 @@ void statesaver()
|
|||||||
SRAMChdir();
|
SRAMChdir();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((fhandle = fopen(fnamest+1,"wb")) != NULL)
|
clim ()
|
||||||
|
|
||||||
|
if ((fhandle = fopen(fnamest+1,"wb")))
|
||||||
{
|
{
|
||||||
// Save 65816 status, etc.
|
|
||||||
fwrite(zsmesg, 1, sizeof(zsmesg)-1, fhandle);
|
fwrite(zsmesg, 1, sizeof(zsmesg)-1, fhandle);
|
||||||
fwrite (&cycpbl, 1, 2*4, fhandle);
|
|
||||||
fwrite (&sndrot, 1, 3019, fhandle); // Save SNES PPU Register status
|
|
||||||
fwrite (wramdata, 1, 8192*16, fhandle);
|
|
||||||
fwrite (vram, 1, 4096*16, fhandle);
|
|
||||||
|
|
||||||
if (spcon) // SPC stuff, DSP stuff
|
PrepareSaveState();
|
||||||
{
|
|
||||||
fwrite (spcRam, 1, PHspcsave, fhandle);
|
|
||||||
fwrite (BRRBuffer, 1, PHdspsave, fhandle);
|
|
||||||
fwrite (DSPMem, 1, 16*16, fhandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (C4Enable) { fwrite (C4Ram, 1, 2048*4, fhandle); }
|
|
||||||
|
|
||||||
if (SFXEnable)
|
if (SFXEnable)
|
||||||
{
|
{
|
||||||
SfxRomBuffer -= SfxCROM;
|
SfxRomBuffer -= SfxCROM;
|
||||||
SfxLastRamAdr -= SfxRAMMem;
|
SfxLastRamAdr -= SfxRAMMem;
|
||||||
fwrite (sfxramdata, 1, 8192*16, fhandle);
|
|
||||||
fwrite (&SfxR0, 1, PHnum2writesfxreg, fhandle);
|
|
||||||
SfxRomBuffer += SfxCROM;
|
|
||||||
SfxLastRamAdr += SfxRAMMem;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SETAEnable) { fwrite (setaramdata, 1, 256*16, fhandle); }
|
|
||||||
// TODO: save the SetaCmdEnable? For completeness we should do it
|
|
||||||
// but currently we ignore it anyway.
|
|
||||||
|
|
||||||
if (SPC7110Enable)
|
|
||||||
{
|
|
||||||
fwrite (romdata+0x510000, 1, 65536, fhandle);
|
|
||||||
fwrite (&SPCMultA, 1, PHnum2writespc7110reg, fhandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SA1Enable)
|
if (SA1Enable)
|
||||||
{
|
{
|
||||||
SaveSA1(); //Convert SA-1 stuff to standard, non displacement format
|
SaveSA1(); //Convert SA-1 stuff to standard, non displacement format
|
||||||
|
}
|
||||||
|
|
||||||
fwrite (&SA1Mode, 1, PHnum2writesa1reg, fhandle);
|
copy_state_data(0, write_save_state_data, true);
|
||||||
fwrite (SA1RAMArea, 1, 8192*16, fhandle);
|
|
||||||
|
|
||||||
|
if (SFXEnable)
|
||||||
|
{
|
||||||
|
SfxRomBuffer += SfxCROM;
|
||||||
|
SfxLastRamAdr += SfxRAMMem;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SA1Enable)
|
||||||
|
{
|
||||||
RestoreSA1(); //Convert back SA-1 stuff
|
RestoreSA1(); //Convert back SA-1 stuff
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cbitmode && !NoPictureSave)
|
if (cbitmode && !NoPictureSave)
|
||||||
{
|
{
|
||||||
CapturePicture();
|
CapturePicture();
|
||||||
|
|
||||||
fwrite (PrevPicture, 1, 64*56*2, fhandle);
|
fwrite (PrevPicture, 1, 64*56*2, fhandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fhandle);
|
fclose (fhandle);
|
||||||
|
|
||||||
|
//Display message on the screen, State X Saved
|
||||||
if (fnamest[statefileloc] == 't')
|
if (fnamest[statefileloc] == 't')
|
||||||
{
|
{
|
||||||
txtsavemsg[6]='0';
|
txtsavemsg[6]='0';
|
||||||
@@ -581,6 +576,8 @@ void statesaver()
|
|||||||
|
|
||||||
Msgptr = txtsavemsg;
|
Msgptr = txtsavemsg;
|
||||||
MessageOn = MsgCount;
|
MessageOn = MsgCount;
|
||||||
|
|
||||||
|
ResetState();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -588,13 +585,6 @@ void statesaver()
|
|||||||
MessageOn = MsgCount;
|
MessageOn = MsgCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
offst = (unsigned int)tableA;
|
|
||||||
Curtableaddr += offst;
|
|
||||||
offst = (unsigned int)spcRam;
|
|
||||||
spcPCRam += offst;
|
|
||||||
spcRamDP += offst;
|
|
||||||
|
|
||||||
ResetState();
|
|
||||||
stim();
|
stim();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -712,22 +702,24 @@ extern unsigned char ioportval, SDD1Enable, nexthdma;
|
|||||||
|
|
||||||
void procexecloop();
|
void procexecloop();
|
||||||
|
|
||||||
|
size_t load_save_size;
|
||||||
|
static void read_save_state_data(unsigned char **dest, void *data, size_t len)
|
||||||
|
{
|
||||||
|
load_save_size += fread(data, 1, len, fhandle);
|
||||||
|
}
|
||||||
|
|
||||||
void stateloader (unsigned char *statename, unsigned char keycheck, unsigned char xfercheck)
|
void stateloader (unsigned char *statename, unsigned char keycheck, unsigned char xfercheck)
|
||||||
{
|
{
|
||||||
unsigned int offst;
|
|
||||||
unsigned char statevalue;
|
|
||||||
char zsmesgcheck[sizeof(zsmesg)-1];
|
char zsmesgcheck[sizeof(zsmesg)-1];
|
||||||
|
|
||||||
if (keycheck)
|
if (keycheck)
|
||||||
{
|
{
|
||||||
|
unsigned char statevalue;
|
||||||
|
|
||||||
pressed[1] = 0;
|
pressed[1] = 0;
|
||||||
pressed[KeyLoadState] = 2;
|
pressed[KeyLoadState] = 2;
|
||||||
multchange = 1;
|
multchange = 1;
|
||||||
|
|
||||||
clim();
|
|
||||||
#ifdef __LINUX__
|
|
||||||
SRAMChdir();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//Get the state number
|
//Get the state number
|
||||||
if (fnamest[statefileloc] == 't')
|
if (fnamest[statefileloc] == 't')
|
||||||
{
|
{
|
||||||
@@ -743,40 +735,26 @@ void stateloader (unsigned char *statename, unsigned char keycheck, unsigned cha
|
|||||||
txtnfndmsg[21] = statevalue;
|
txtnfndmsg[21] = statevalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __LINUX__
|
||||||
|
SRAMChdir();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
clim();
|
||||||
|
|
||||||
//Actual state loading code
|
//Actual state loading code
|
||||||
if ((fhandle = fopen(statename,"rb")) != NULL)
|
if ((fhandle = fopen(statename,"rb")) != NULL)
|
||||||
{
|
{
|
||||||
if (xfercheck) { Totalbyteloaded = 0; }
|
if (xfercheck) { Totalbyteloaded = 0; }
|
||||||
|
|
||||||
MovieProcessing = 0;
|
|
||||||
prevoamptr = 0xFF;
|
|
||||||
|
|
||||||
// Load 65816 status, etc.
|
|
||||||
Totalbyteloaded += fread(zsmesgcheck, 1, sizeof(zsmesgcheck), fhandle);
|
Totalbyteloaded += fread(zsmesgcheck, 1, sizeof(zsmesgcheck), fhandle);
|
||||||
if (!memcmp(zsmesgcheck, zsmesg, sizeof(zsmesgcheck))) // just drop older states
|
if (!memcmp(zsmesgcheck, zsmesg, sizeof(zsmesgcheck))) //Just drop older states
|
||||||
{
|
{
|
||||||
// Load SPC timers
|
load_save_size = 0;
|
||||||
Totalbyteloaded += fread (&cycpbl, 1, 2*4, fhandle);
|
copy_state_data(0, read_save_state_data, true);
|
||||||
// Load SNES PPU Register status
|
Totalbyteloaded += load_save_size;
|
||||||
Totalbyteloaded += fread (&sndrot, 1, 3019, fhandle);
|
|
||||||
ioportval = 0xFF;
|
|
||||||
// Load WRAM (128k), VRAM (64k)
|
|
||||||
Totalbyteloaded += fread (wramdata, 1, 8192*16, fhandle);
|
|
||||||
Totalbyteloaded += fread (vram, 1, 4096*16, fhandle);
|
|
||||||
|
|
||||||
if (spcon) // SPC stuff, DSP stuff
|
|
||||||
{
|
|
||||||
Totalbyteloaded += fread (spcRam, 1, PHspcsave, fhandle);
|
|
||||||
Totalbyteloaded += fread (BRRBuffer, 1, PHdspsave, fhandle);
|
|
||||||
Totalbyteloaded += fread (DSPMem, 1, 16*16, fhandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (C4Enable) { Totalbyteloaded += fread (C4Ram, 1, 2048*4, fhandle); }
|
|
||||||
|
|
||||||
if (SFXEnable)
|
if (SFXEnable)
|
||||||
{
|
{
|
||||||
Totalbyteloaded += fread (sfxramdata, 1, 8192*16, fhandle);
|
|
||||||
Totalbyteloaded += fread (&SfxR0, 1, PHnum2writesfxreg, fhandle);
|
|
||||||
SfxCPB = SfxMemTable[(SfxPBR & 0xFF)];
|
SfxCPB = SfxMemTable[(SfxPBR & 0xFF)];
|
||||||
SfxCROM = SfxMemTable[(SfxROMBR & 0xFF)];
|
SfxCROM = SfxMemTable[(SfxROMBR & 0xFF)];
|
||||||
SfxRAMMem = (unsigned int)sfxramdata + ((SfxRAMBR & 0xFF) << 16);
|
SfxRAMMem = (unsigned int)sfxramdata + ((SfxRAMBR & 0xFF) << 16);
|
||||||
@@ -784,25 +762,14 @@ void stateloader (unsigned char *statename, unsigned char keycheck, unsigned cha
|
|||||||
SfxLastRamAdr += SfxRAMMem;
|
SfxLastRamAdr += SfxRAMMem;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SETAEnable) { Totalbyteloaded += fread (setaramdata, 1, 256*16, fhandle); }
|
|
||||||
// TODO: load the SetaCmdEnable? For completeness we should do it
|
|
||||||
// but currently we ignore it anyway.
|
|
||||||
|
|
||||||
if (SPC7110Enable)
|
|
||||||
{
|
|
||||||
Totalbyteloaded += fread (romdata+0x510000, 1, 65536, fhandle);
|
|
||||||
Totalbyteloaded += fread (&SPCMultA, 1, PHnum2writespc7110reg, fhandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SA1Enable)
|
if (SA1Enable)
|
||||||
{
|
{
|
||||||
Totalbyteloaded += fread (&SA1Mode, 1, PHnum2writesa1reg, fhandle);
|
|
||||||
Totalbyteloaded += fread (SA1RAMArea, 1, 8192*16, fhandle);
|
|
||||||
|
|
||||||
RestoreSA1(); //Convert back SA-1 stuff
|
RestoreSA1(); //Convert back SA-1 stuff
|
||||||
|
/*
|
||||||
|
All UpdateBanks() seems to do is break Oshaberi Parodius...
|
||||||
|
The C port is still present, just commented out
|
||||||
|
*/
|
||||||
//UpdateBanks();
|
//UpdateBanks();
|
||||||
// It was in the asm, but the only thing it does is break Oshaberi Parodius...
|
|
||||||
// The C port is still present, just commented out.
|
|
||||||
SA1UpdateDPageC();
|
SA1UpdateDPageC();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -811,52 +778,46 @@ void stateloader (unsigned char *statename, unsigned char keycheck, unsigned cha
|
|||||||
UpdateBanksSDD1();
|
UpdateBanksSDD1();
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fhandle);
|
//Clear cache check if state loaded
|
||||||
|
memset(vidmemch2, 1, sizeof(vidmemch2));
|
||||||
|
memset(vidmemch4, 1, sizeof(vidmemch4));
|
||||||
|
memset(vidmemch8, 1, sizeof(vidmemch8));
|
||||||
|
|
||||||
|
MovieProcessing = 0;
|
||||||
|
prevoamptr = 0xFF;
|
||||||
|
ioportval = 0xFF;
|
||||||
|
|
||||||
repackfunct();
|
repackfunct();
|
||||||
|
|
||||||
spcnumread = 0;
|
spcnumread = 0;
|
||||||
spchalted = 0xFFFFFFFF;
|
spchalted = 0xFFFFFFFF;
|
||||||
nexthdma = 0;
|
nexthdma = 0;
|
||||||
|
|
||||||
// ;call headerhack ; ASM ONLY ! I'm not porting hacks ever.
|
//headerhack(); //Was in the asm, but why is this needed?
|
||||||
|
|
||||||
initpitch();
|
initpitch();
|
||||||
|
|
||||||
// Clear cache check if state loaded
|
|
||||||
memset (vidmemch2, 1, 4096);
|
|
||||||
memset (vidmemch4, 1, 4096);
|
|
||||||
memset (vidmemch8, 1, 4096);
|
|
||||||
|
|
||||||
offst = (unsigned int)tableA;
|
|
||||||
Curtableaddr += offst;
|
|
||||||
offst = (unsigned int)spcRam;
|
|
||||||
spcPCRam += offst;
|
|
||||||
spcRamDP += offst;
|
|
||||||
|
|
||||||
ResetState();
|
ResetState();
|
||||||
procexecloop();
|
procexecloop();
|
||||||
|
|
||||||
if (keycheck) { stim(); }
|
Msgptr = txtloadmsg;
|
||||||
}
|
|
||||||
|
|
||||||
if (keycheck)
|
|
||||||
{
|
|
||||||
if (!xfercheck)
|
|
||||||
{
|
|
||||||
if (!memcmp(zsmesgcheck, zsmesg, sizeof(zsmesgcheck))) { Msgptr = txtconvmsg; }
|
|
||||||
else { Msgptr = txtloadmsg; }
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageOn = MsgCount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (keycheck)
|
Msgptr = txtconvmsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fhandle);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Msgptr = txtnfndmsg;
|
Msgptr = txtnfndmsg;
|
||||||
MessageOn = MsgCount;
|
|
||||||
stim();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stim();
|
||||||
|
|
||||||
|
if (keycheck)
|
||||||
|
{
|
||||||
|
MessageOn = MsgCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user