Functionized offset altering, correct loading of old save states.

This commit is contained in:
n-a-c-h
2005-01-31 04:08:22 +00:00
parent 912e43e66a
commit 53af83f6d0

View File

@@ -145,8 +145,6 @@ void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **,
if (DSP1Type && !loading_old_state) if (DSP1Type && !loading_old_state)
{ {
copy_func(&buffer, &DSP1COp, 70+128); copy_func(&buffer, &DSP1COp, 70+128);
copy_func(&buffer, &C4WFXVal, 7*4+7*8+128);
copy_func(&buffer, &C41FXVal, 5*4+128);
copy_func(&buffer, &Op00Multiplicand, 3*4+128); copy_func(&buffer, &Op00Multiplicand, 3*4+128);
copy_func(&buffer, &Op10Coefficient, 4*4+128); copy_func(&buffer, &Op10Coefficient, 4*4+128);
copy_func(&buffer, &Op04Angle, 4*4+128); copy_func(&buffer, &Op04Angle, 4*4+128);
@@ -195,6 +193,11 @@ void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **,
copy_func(&buffer, &tempebp, 4); copy_func(&buffer, &tempebp, 4);
} }
} }
else
{
spcnumread = 0;
spchalted = 0xFFFFFFFF;
}
} }
static void memcpyinc(unsigned char **dest, void *src, size_t len) static void memcpyinc(unsigned char **dest, void *src, size_t len)
@@ -542,10 +545,18 @@ static void write_save_state_data(unsigned char **dest, void *data, size_t len)
static const char zst_header_old[] = "ZSNES Save State File V0.6\x1a\x3c"; static const char zst_header_old[] = "ZSNES Save State File V0.6\x1a\x3c";
static const char zst_header_cur[] = "ZSNES Save State File V143\x1a\x3c"; static const char zst_header_cur[] = "ZSNES Save State File V143\x1a\x3c";
void PrepareOffset()
{
Curtableaddr -= (unsigned int)tableA;
}
void ResetOffset()
{
Curtableaddr += (unsigned int)tableA;
}
void statesaver() void statesaver()
{ {
unsigned int offst;
//'Auto increment savestate slot' code //'Auto increment savestate slot' code
if (AutoIncSaveSlot) if (AutoIncSaveSlot)
{ {
@@ -581,9 +592,7 @@ 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; PrepareOffset();
Curtableaddr -= offst;
PrepareSaveState(); PrepareSaveState();
unpackfunct(); unpackfunct();
@@ -632,9 +641,7 @@ void statesaver()
Msgptr = txtsavemsg; Msgptr = txtsavemsg;
MessageOn = MsgCount; MessageOn = MsgCount;
offst = (unsigned int)tableA; ResetOffset();
Curtableaddr += offst;
ResetState(); ResetState();
} }
else else
@@ -769,7 +776,6 @@ 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)
{ {
@@ -853,22 +859,13 @@ void stateloader (unsigned char *statename, unsigned char keycheck, unsigned cha
memset(vidmemch8, 1, sizeof(vidmemch8)); memset(vidmemch8, 1, sizeof(vidmemch8));
MovieProcessing = 0; MovieProcessing = 0;
prevoamptr = 0xFF;
ioportval = 0xFF;
repackfunct(); repackfunct();
spcnumread = 0;
spchalted = 0xFFFFFFFF;
nexthdma = 0;
//headerhack(); //Was in the asm, but why is this needed? //headerhack(); //Was in the asm, but why is this needed?
initpitch(); initpitch();
ResetOffset();
offst = (unsigned int)tableA;
Curtableaddr += offst;
ResetState(); ResetState();
procexecloop(); procexecloop();