Some functions were used outside, now clean and working.

This commit is contained in:
grinvader
2005-01-31 03:54:41 +00:00
parent 423007ec13
commit 912e43e66a
3 changed files with 149 additions and 155 deletions

View File

@@ -46,8 +46,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define stim() #define stim()
#endif #endif
//static unsigned char save_state_buffer[0x80000]; //Save state should never exceed half a megabyte
extern unsigned int CBackupPos, PBackupPos, cycpbl, PH65816regsize; extern unsigned int CBackupPos, PBackupPos, cycpbl, PH65816regsize;
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;
@@ -68,7 +66,6 @@ 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;
static void copy_snes_data(unsigned char **buffer, void (*copy_func)(unsigned char **, void *, size_t)) static void copy_snes_data(unsigned char **buffer, void (*copy_func)(unsigned char **, void *, size_t))
{ {
//65816 status, etc. //65816 status, etc.
@@ -200,7 +197,6 @@ void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **,
} }
} }
static void memcpyinc(unsigned char **dest, void *src, size_t len) static void memcpyinc(unsigned char **dest, void *src, size_t len)
{ {
memcpy(*dest, src, len); memcpy(*dest, src, len);
@@ -275,7 +271,6 @@ void SA1UpdateDPageC()
SA1DPageW16 = Bank0datw16[(SA1xd >> 8) & 0xFF]; SA1DPageW16 = Bank0datw16[(SA1xd >> 8) & 0xFF];
} }
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;
@@ -299,11 +294,8 @@ extern unsigned int Curtableaddr, tableA[256], spcPCRam, spcRamDP;
void PrepareSaveState() void PrepareSaveState()
{ {
unsigned int offst; unsigned int offst = (unsigned int)spcRam;
offst = (unsigned int)tableA;
Curtableaddr -= offst;
offst = (unsigned int)spcRam;
spcPCRam -= offst; spcPCRam -= offst;
spcRamDP -= offst; spcRamDP -= offst;
@@ -315,8 +307,6 @@ void PrepareSaveState()
Voice5BufPtr -= spcBuffera; Voice5BufPtr -= spcBuffera;
Voice6BufPtr -= spcBuffera; Voice6BufPtr -= spcBuffera;
Voice7BufPtr -= spcBuffera; Voice7BufPtr -= spcBuffera;
unpackfunct();
} }
#define byteset(byte, checkbit) (byte & (1 << checkbit)) ? 1 : 0 #define byteset(byte, checkbit) (byte & (1 << checkbit)) ? 1 : 0
@@ -517,11 +507,8 @@ void RestoreSA1()
void ResetState() void ResetState()
{ {
unsigned int offst; unsigned int offst = (unsigned int)spcRam;
offst = (unsigned int)tableA;
Curtableaddr += offst;
offst = (unsigned int)spcRam;
spcPCRam += offst; spcPCRam += offst;
spcRamDP += offst; spcRamDP += offst;
@@ -538,11 +525,9 @@ void ResetState()
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;
extern unsigned char AutoIncSaveSlot, firstsaveinc, fnamest[512]; extern unsigned char AutoIncSaveSlot, firstsaveinc, fnamest[512];
extern unsigned char 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];
static FILE *fhandle; static FILE *fhandle;
@@ -559,6 +544,8 @@ static const char zst_header_cur[] = "ZSNES Save State File V143\x1a\x3c";
void statesaver() void statesaver()
{ {
unsigned int offst;
//'Auto increment savestate slot' code //'Auto increment savestate slot' code
if (AutoIncSaveSlot) if (AutoIncSaveSlot)
{ {
@@ -594,7 +581,11 @@ void statesaver()
{ {
fwrite(zst_header_cur, 1, sizeof(zst_header_cur)-1, fhandle); //-1 for null fwrite(zst_header_cur, 1, sizeof(zst_header_cur)-1, fhandle); //-1 for null
offst = (unsigned int)tableA;
Curtableaddr -= offst;
PrepareSaveState(); PrepareSaveState();
unpackfunct();
if (SFXEnable) if (SFXEnable)
{ {
@@ -628,7 +619,7 @@ void statesaver()
fclose (fhandle); fclose (fhandle);
//Display message on the screen, State X Saved //Display message on the screen, 'STATE X SAVED.'
if (fnamest[statefileloc] == 't') if (fnamest[statefileloc] == 't')
{ {
txtsavemsg[6]='0'; txtsavemsg[6]='0';
@@ -641,10 +632,14 @@ void statesaver()
Msgptr = txtsavemsg; Msgptr = txtsavemsg;
MessageOn = MsgCount; MessageOn = MsgCount;
offst = (unsigned int)tableA;
Curtableaddr += offst;
ResetState(); ResetState();
} }
else else
{ {
//Display message on the screen, 'UNABLE TO SAVE.'
Msgptr = txtsavemsgfail; Msgptr = txtsavemsgfail;
MessageOn = MsgCount; MessageOn = MsgCount;
} }
@@ -774,6 +769,7 @@ static void read_save_state_data(unsigned char **dest, void *data, size_t len)
void stateloader (unsigned char *statename, unsigned char keycheck, unsigned char xfercheck) void stateloader (unsigned char *statename, unsigned char keycheck, unsigned char xfercheck)
{ {
char zst_header_check[sizeof(zst_header_cur)-1]; char zst_header_check[sizeof(zst_header_cur)-1];
unsigned int offst;
if (keycheck) if (keycheck)
{ {
@@ -869,21 +865,25 @@ void stateloader (unsigned char *statename, unsigned char keycheck, unsigned cha
//headerhack(); //Was in the asm, but why is this needed? //headerhack(); //Was in the asm, but why is this needed?
initpitch(); initpitch();
offst = (unsigned int)tableA;
Curtableaddr += offst;
ResetState(); ResetState();
procexecloop(); procexecloop();
Msgptr = txtloadmsg; Msgptr = txtloadmsg; // 'STATE X LOADED.'
} }
else else
{ {
Msgptr = txtconvmsg; Msgptr = txtconvmsg; // 'STATE X TOO OLD.'
} }
fclose(fhandle); fclose(fhandle);
} }
else else
{ {
Msgptr = txtnfndmsg; Msgptr = txtnfndmsg; // 'UNABLE TO LOAD STATE X.'
} }
stim(); stim();

View File

@@ -172,8 +172,6 @@ NEWSYM loadtempstuff
mov edx,DSPMem mov edx,DSPMem
call Read_File call Read_File
call Close_File call Close_File
add dword[spcPCRam],spcRam
add dword[spcRamDP],spcRam
pushad pushad
call ResetState call ResetState
popad popad

View File

@@ -855,8 +855,6 @@ NEWSYM savespcdata
add dword[spcPCRam],spcRam add dword[spcPCRam],spcRam
.savestuff .savestuff
ChangeDir SPCPath ChangeDir SPCPath
sub dword[spcPCRam],spcRam
sub dword[spcRamDP],spcRam
pushad pushad
call PrepareSaveState call PrepareSaveState
popad popad
@@ -1009,8 +1007,6 @@ NEWSYM savespcdata
call Close_File call Close_File
%endif %endif
add dword[spcPCRam],spcRam
add dword[spcRamDP],spcRam
pushad pushad
call ResetState call ResetState
popad popad