Restructre some state date.
This commit is contained in:
@@ -62,7 +62,7 @@ EXTSYM deinitipx
|
|||||||
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,unpackfunct,vram,wramdata
|
||||||
EXTSYM zsmesg,PHnum2writesfxreg,SfxR0,PHnum2writecpureg,PHspcsave
|
EXTSYM PHnum2writesfxreg,SfxR0,PHspcsave
|
||||||
EXTSYM C4Ram
|
EXTSYM C4Ram
|
||||||
EXTSYM SPC7110Enable
|
EXTSYM SPC7110Enable
|
||||||
EXTSYM SA1Mode,PHnum2writesa1reg,SaveSA1,RestoreSA1,UpdateBanksSDD1
|
EXTSYM SA1Mode,PHnum2writesa1reg,SaveSA1,RestoreSA1,UpdateBanksSDD1
|
||||||
@@ -486,7 +486,6 @@ NEWSYM UpdateRewind
|
|||||||
NEWSYM BackupSystemVars
|
NEWSYM BackupSystemVars
|
||||||
pushad
|
pushad
|
||||||
mov ebx,BackupArray
|
mov ebx,BackupArray
|
||||||
BackupCVMacB zsmesg,[PHnum2writecpureg]
|
|
||||||
BackupCVMac cycpbl,2
|
BackupCVMac cycpbl,2
|
||||||
BackupCVMacB sndrot,3019
|
BackupCVMacB sndrot,3019
|
||||||
BackupCVMacB soundcycleft,33
|
BackupCVMacB soundcycleft,33
|
||||||
@@ -513,7 +512,6 @@ NEWSYM RestoreSystemVars
|
|||||||
pushad
|
pushad
|
||||||
call InitRewindVars
|
call InitRewindVars
|
||||||
mov ebx,BackupArray
|
mov ebx,BackupArray
|
||||||
BackupCVRMacB zsmesg,[PHnum2writecpureg]
|
|
||||||
BackupCVRMac cycpbl,2
|
BackupCVRMac cycpbl,2
|
||||||
BackupCVRMacB sndrot,3019
|
BackupCVRMacB sndrot,3019
|
||||||
BackupCVRMacB soundcycleft,33
|
BackupCVRMacB soundcycleft,33
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|||||||
#define DIR_SLASH "\\"
|
#define DIR_SLASH "\\"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//C++ style code in C
|
||||||
|
#define bool unsigned char
|
||||||
|
#define true 1
|
||||||
|
#define false 0
|
||||||
|
|
||||||
#ifdef __MSDOS__
|
#ifdef __MSDOS__
|
||||||
#define clim() __asm__ __volatile__ ("cli");
|
#define clim() __asm__ __volatile__ ("cli");
|
||||||
#define stim() __asm__ __volatile__ ("sti");
|
#define stim() __asm__ __volatile__ ("sti");
|
||||||
@@ -43,18 +48,20 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|||||||
/*Let's start converting stuff from execute.asm ^_^;
|
/*Let's start converting stuff from execute.asm ^_^;
|
||||||
Big thanks to Nach, TRAC and anomie for helping me out on porting !!*/
|
Big thanks to Nach, TRAC and anomie for helping me out on porting !!*/
|
||||||
|
|
||||||
extern unsigned int CBackupPos, PBackupPos, PHnum2writecpureg, 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;
|
||||||
extern unsigned int PHnum2writesa1reg, SA1Mode, prevedi, SA1xpc, sa1dmaptr;
|
extern unsigned int PHnum2writesa1reg, SA1Mode, prevedi, SA1xpc, sa1dmaptr;
|
||||||
extern unsigned int soundcycleft, spc700read, timer2upd, xa, PHnum2writesfxreg;
|
extern unsigned int soundcycleft, spc700read, timer2upd, xa, PHnum2writesfxreg;
|
||||||
extern unsigned int spcnumread, spchalted, opcd, HIRQCycNext, oamaddr;
|
extern unsigned int spcnumread, spchalted, opcd, HIRQCycNext, oamaddr;
|
||||||
extern unsigned int SfxR0, ReadHead, *setaramdata, ramsize, *sram;
|
extern unsigned int SfxR0, ReadHead, *setaramdata, ramsize, *sram;
|
||||||
extern unsigned int tempesi, tempedi, tempedx, tempebp;
|
extern unsigned int tempesi, tempedi, tempedx, tempebp;
|
||||||
|
extern unsigned int SPCMultA, PHnum2writespc7110reg;
|
||||||
|
|
||||||
extern unsigned char *StateBackup, zsmesg[26], sndrot, spcon, spcRam[65472];
|
extern unsigned char *StateBackup, sndrot, spcRam[65472];
|
||||||
extern unsigned char DSPMem[256], C4Enable, SFXEnable, SA1Enable, SA1Status;
|
extern unsigned char DSPMem[256], SA1Status, *SA1RAMArea, DSP1Type, DSP1COp;
|
||||||
extern unsigned char *SA1RAMArea, DSP1Type, DSP1COp, prevoamptr, SETAEnable;
|
extern unsigned char prevoamptr, BRRBuffer[32], *romdata;
|
||||||
extern unsigned char BRRBuffer[32];
|
|
||||||
|
extern bool C4Enable, SFXEnable, SA1Enable, SPC7110Enable, SETAEnable, spcon;
|
||||||
|
|
||||||
extern short C4WFXVal, C41FXVal, Op00Multiplicand, Op04Angle, Op08X, Op18X;
|
extern short C4WFXVal, C41FXVal, Op00Multiplicand, Op04Angle, Op08X, Op18X;
|
||||||
extern short Op28X, Op0CA, Op02FX, Op0AVS, Op06X, Op01m, Op0DX, Op03F, Op14Zr;
|
extern short Op28X, Op0CA, Op02FX, Op0AVS, Op06X, Op01m, Op0DX, Op03F, Op14Zr;
|
||||||
@@ -73,9 +80,15 @@ void memcpyrinc(unsigned char **src, void *dest, size_t len)
|
|||||||
*src += len;
|
*src += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **, void *, size_t))
|
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)
|
||||||
{
|
{
|
||||||
copy_func(&buffer, zsmesg, PHnum2writecpureg);
|
if (file)
|
||||||
|
{
|
||||||
|
copy_func(&buffer, zsmesg, sizeof(zsmesg)-1);
|
||||||
|
}
|
||||||
|
|
||||||
copy_func(&buffer, &cycpbl, 2*4);
|
copy_func(&buffer, &cycpbl, 2*4);
|
||||||
copy_func(&buffer, &sndrot, 3019);
|
copy_func(&buffer, &sndrot, 3019);
|
||||||
copy_func(&buffer, wramdata, 8192*16);
|
copy_func(&buffer, wramdata, 8192*16);
|
||||||
@@ -85,7 +98,7 @@ void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **,
|
|||||||
{
|
{
|
||||||
copy_func(&buffer, spcRam, PHspcsave);
|
copy_func(&buffer, spcRam, PHspcsave);
|
||||||
copy_func(&buffer, BRRBuffer, PHdspsave);
|
copy_func(&buffer, BRRBuffer, PHdspsave);
|
||||||
copy_func(&buffer, DSPMem, 16*16);
|
copy_func(&buffer, DSPMem, sizeof(DSPMem));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (C4Enable)
|
if (C4Enable)
|
||||||
@@ -104,7 +117,6 @@ void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **,
|
|||||||
copy_func(&buffer, &SA1Mode, PHnum2writesa1reg);
|
copy_func(&buffer, &SA1Mode, PHnum2writesa1reg);
|
||||||
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, &prevedi, 1*4);
|
|
||||||
copy_func(&buffer, &SA1xpc, 1*4);
|
copy_func(&buffer, &SA1xpc, 1*4);
|
||||||
copy_func(&buffer, &SA1RAMArea, 6*4);
|
copy_func(&buffer, &SA1RAMArea, 6*4);
|
||||||
copy_func(&buffer, &sa1dmaptr, 2*4);
|
copy_func(&buffer, &sa1dmaptr, 2*4);
|
||||||
@@ -132,6 +144,17 @@ void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **,
|
|||||||
copy_func(&buffer, &Op0EH, 4*4+128);
|
copy_func(&buffer, &Op0EH, 4*4+128);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SETAEnable)
|
||||||
|
{
|
||||||
|
copy_func(&buffer, setaramdata, 256*16);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SPC7110Enable)
|
||||||
|
{
|
||||||
|
copy_func(&buffer, romdata+0x510000, 65536);
|
||||||
|
copy_func(&buffer, &SPCMultA, PHnum2writespc7110reg);
|
||||||
|
}
|
||||||
|
|
||||||
copy_func(&buffer, &soundcycleft, 33);
|
copy_func(&buffer, &soundcycleft, 33);
|
||||||
copy_func(&buffer, &spc700read, 10*4);
|
copy_func(&buffer, &spc700read, 10*4);
|
||||||
copy_func(&buffer, &timer2upd, 1*4);
|
copy_func(&buffer, &timer2upd, 1*4);
|
||||||
@@ -144,27 +167,27 @@ void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **,
|
|||||||
copy_func(&buffer, &prevoamptr, 1);
|
copy_func(&buffer, &prevoamptr, 1);
|
||||||
copy_func(&buffer, &ReadHead, 1*4);
|
copy_func(&buffer, &ReadHead, 1*4);
|
||||||
|
|
||||||
if (SETAEnable)
|
|
||||||
{
|
|
||||||
copy_func(&buffer, setaramdata, 256*16);
|
|
||||||
}
|
|
||||||
copy_func(&buffer, sram, ramsize);
|
copy_func(&buffer, sram, ramsize);
|
||||||
|
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
copy_func(&buffer, &tempesi, 4);
|
copy_func(&buffer, &tempesi, 4);
|
||||||
copy_func(&buffer, &tempedi, 4);
|
copy_func(&buffer, &tempedi, 4);
|
||||||
copy_func(&buffer, &tempedx, 4);
|
copy_func(&buffer, &tempedx, 4);
|
||||||
copy_func(&buffer, &tempebp, 4);
|
copy_func(&buffer, &tempebp, 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackupCVFrame()
|
void BackupCVFrame()
|
||||||
{
|
{
|
||||||
unsigned char *curpos = StateBackup + (CBackupPos << 19) + 1024;
|
unsigned char *curpos = StateBackup + (CBackupPos << 19) + 1024;
|
||||||
copy_state_data(curpos, memcpyinc);
|
copy_state_data(curpos, memcpyinc, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestoreCVFrame()
|
void RestoreCVFrame()
|
||||||
{
|
{
|
||||||
unsigned char *curpos = StateBackup + (PBackupPos << 19) + 1024;
|
unsigned char *curpos = StateBackup + (PBackupPos << 19) + 1024;
|
||||||
copy_state_data(curpos, memcpyrinc);
|
copy_state_data(curpos, memcpyrinc, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern unsigned int Bank0datr8[256], Bank0datr16[256], Bank0datw8[256];
|
extern unsigned int Bank0datr8[256], Bank0datr16[256], Bank0datw8[256];
|
||||||
@@ -361,7 +384,7 @@ void repackfunct()
|
|||||||
|
|
||||||
extern unsigned int SA1Stat;
|
extern unsigned int SA1Stat;
|
||||||
extern unsigned char IRAM[2049], *SA1Ptr, *SA1RegPCS, *CurBWPtr, *SA1BWPtr;
|
extern unsigned char IRAM[2049], *SA1Ptr, *SA1RegPCS, *CurBWPtr, *SA1BWPtr;
|
||||||
extern unsigned char *SNSBWPtr, *romdata;
|
extern unsigned char *SNSBWPtr;
|
||||||
|
|
||||||
void SaveSA1()
|
void SaveSA1()
|
||||||
{
|
{
|
||||||
@@ -433,11 +456,10 @@ void ResetState()
|
|||||||
extern unsigned int Curtableaddr, tableA[256], spcPCRam, spcRamDP;
|
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 SPCMultA, PHnum2writespc7110reg;
|
|
||||||
extern unsigned int MsgCount, MessageOn;
|
extern unsigned int MsgCount, MessageOn;
|
||||||
|
|
||||||
extern unsigned char AutoIncSaveSlot, firstsaveinc, fnamest[512];
|
extern unsigned char AutoIncSaveSlot, firstsaveinc, fnamest[512];
|
||||||
extern unsigned char SPC7110Enable, cbitmode, NoPictureSave, txtsavemsg[14];
|
extern unsigned char cbitmode, NoPictureSave, txtsavemsg[14];
|
||||||
extern unsigned char *Msgptr, txtsavemsgfail[15];
|
extern unsigned char *Msgptr, txtsavemsgfail[15];
|
||||||
|
|
||||||
extern unsigned short PrevPicture[64*56];
|
extern unsigned short PrevPicture[64*56];
|
||||||
@@ -494,8 +516,7 @@ void statesaver()
|
|||||||
if ((fhandle = fopen(fnamest+1,"wb")) != NULL)
|
if ((fhandle = fopen(fnamest+1,"wb")) != NULL)
|
||||||
{
|
{
|
||||||
// Save 65816 status, etc.
|
// Save 65816 status, etc.
|
||||||
|
fwrite (zsmesg, 1, sizeof(zsmesg)-1, fhandle);
|
||||||
fwrite (zsmesg, 1, PHnum2writecpureg, fhandle);
|
|
||||||
fwrite (&cycpbl, 1, 2*4, fhandle);
|
fwrite (&cycpbl, 1, 2*4, fhandle);
|
||||||
fwrite (&sndrot, 1, 3019, fhandle); // Save SNES PPU Register status
|
fwrite (&sndrot, 1, 3019, fhandle); // Save SNES PPU Register status
|
||||||
fwrite (wramdata, 1, 8192*16, fhandle);
|
fwrite (wramdata, 1, 8192*16, fhandle);
|
||||||
@@ -695,7 +716,7 @@ void stateloader (unsigned char *statename, unsigned char keycheck, unsigned cha
|
|||||||
{
|
{
|
||||||
unsigned int offst;
|
unsigned int offst;
|
||||||
unsigned char statevalue;
|
unsigned char statevalue;
|
||||||
|
char zsmesgcheck[sizeof(zsmesg)-1];
|
||||||
if (keycheck)
|
if (keycheck)
|
||||||
{
|
{
|
||||||
pressed[1] = 0;
|
pressed[1] = 0;
|
||||||
@@ -731,8 +752,8 @@ void stateloader (unsigned char *statename, unsigned char keycheck, unsigned cha
|
|||||||
prevoamptr = 0xFF;
|
prevoamptr = 0xFF;
|
||||||
|
|
||||||
// Load 65816 status, etc.
|
// Load 65816 status, etc.
|
||||||
Totalbyteloaded += fread (zsmesg, 1, PHnum2writecpureg, fhandle);
|
Totalbyteloaded += fread (zsmesgcheck, 1, sizeof(zsmesgcheck), fhandle);
|
||||||
if (zsmesg[25] >= '6') // just drop older states
|
if (!memcmp(zsmesgcheck, zsmesg, sizeof(zsmesgcheck))) // just drop older states
|
||||||
{
|
{
|
||||||
// Load SPC timers
|
// Load SPC timers
|
||||||
Totalbyteloaded += fread (&cycpbl, 1, 2*4, fhandle);
|
Totalbyteloaded += fread (&cycpbl, 1, 2*4, fhandle);
|
||||||
@@ -821,7 +842,7 @@ void stateloader (unsigned char *statename, unsigned char keycheck, unsigned cha
|
|||||||
{
|
{
|
||||||
if (!xfercheck)
|
if (!xfercheck)
|
||||||
{
|
{
|
||||||
if (zsmesg[25] < '6') { Msgptr = txtconvmsg; }
|
if (!memcmp(zsmesgcheck, zsmesg, sizeof(zsmesgcheck))) { Msgptr = txtconvmsg; }
|
||||||
else { Msgptr = txtloadmsg; }
|
else { Msgptr = txtloadmsg; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -434,7 +434,6 @@ NEWSYM cycpblt2, db 149 ; percentage of CPU/SPC to run
|
|||||||
NEWSYM writeon, db 0 ; Write enable/disable on snes rom memory
|
NEWSYM writeon, db 0 ; Write enable/disable on snes rom memory
|
||||||
NEWSYM totlines, dw 263 ; total # of lines
|
NEWSYM totlines, dw 263 ; total # of lines
|
||||||
NEWSYM soundon, db 0 ; Current sound enabled (1=enabled)
|
NEWSYM soundon, db 0 ; Current sound enabled (1=enabled)
|
||||||
NEWSYM zsmesg, db 'ZSNES Save State File V0.6',26
|
|
||||||
NEWSYM versn, db 60 ; version #/100
|
NEWSYM versn, db 60 ; version #/100
|
||||||
NEWSYM curcyc, db 0 ; cycles left in scanline
|
NEWSYM curcyc, db 0 ; cycles left in scanline
|
||||||
NEWSYM curypos, dw 0 ; current y position
|
NEWSYM curypos, dw 0 ; current y position
|
||||||
@@ -463,15 +462,10 @@ NEWSYM xirqb, db 0 ; which bank the irqs start at
|
|||||||
NEWSYM debugger, db 0 ; Start with debugger (1=yes,0=no)
|
NEWSYM debugger, db 0 ; Start with debugger (1=yes,0=no)
|
||||||
NEWSYM Curtableaddr, dd 0 ; Current table address
|
NEWSYM Curtableaddr, dd 0 ; Current table address
|
||||||
NEWSYM curnmi, db 0 ; if in NMI(1) or not(0)
|
NEWSYM curnmi, db 0 ; if in NMI(1) or not(0)
|
||||||
; pharos - equ hack *sigh*
|
|
||||||
num2writecpureg equ $-zsmesg
|
|
||||||
ALIGN32
|
ALIGN32
|
||||||
NEWSYM cycpbl, dd 110 ; percentage left of CPU/SPC to run (3.58 = 175)
|
NEWSYM cycpbl, dd 110 ; percentage left of CPU/SPC to run (3.58 = 175)
|
||||||
NEWSYM cycpblt, dd 110 ; percentage of CPU/SPC to run
|
NEWSYM cycpblt, dd 110 ; percentage of CPU/SPC to run
|
||||||
|
|
||||||
NEWSYM PHnum2writecpureg, dd num2writecpureg
|
|
||||||
|
|
||||||
|
|
||||||
; SNES memory map ROM locations
|
; SNES memory map ROM locations
|
||||||
|
|
||||||
NEWSYM cpuoverptr, dd 0 ; pointer to cpuover
|
NEWSYM cpuoverptr, dd 0 ; pointer to cpuover
|
||||||
|
|||||||
Reference in New Issue
Block a user