m68k savestate portability fix - pointer declobberization

This commit is contained in:
dinkc64 2014-06-22 20:19:20 +00:00
parent 38358828ab
commit 78037db60d
1 changed files with 29 additions and 4 deletions

View File

@ -1966,6 +1966,24 @@ bool SekDbgSetRegister(SekRegister nRegister, UINT32 nValue)
// ----------------------------------------------------------------------------
// Savestate support
// The following block of pointers is actually the end part of the SekM68KContext data
// We preserve these for savestate portability because the addresses/values can be
// specific to a certain system.
struct m68ki_cpu_core_pointerblock
{
UINT8* cyc_instruction;
UINT8* cyc_exception;
int (*int_ack_callback)(int int_line); /* Interrupt Acknowledge */
void (*bkpt_ack_callback)(unsigned int data); /* Breakpoint Acknowledge */
void (*reset_instr_callback)(void); /* Called when a RESET instruction is encountered */
void (*cmpild_instr_callback)(unsigned int, int); /* Called when a CMPI.L #v, Dn instruction is encountered */
void (*rte_instr_callback)(void); /* Called when a RTE instruction is encountered */
void (*pc_changed_callback)(unsigned int new_pc); /* Called when the PC changes by a large amount */
void (*set_fc_callback)(unsigned int new_fc); /* Called when the CPU function code changes */
void (*instr_hook_callback)(void); /* Called every instruction cycle prior to execution */
};
INT32 SekScan(INT32 nAction)
{
#if defined FBA_DEBUG
@ -1974,6 +1992,7 @@ INT32 SekScan(INT32 nAction)
// Scan the 68000 states
struct BurnArea ba;
struct m68ki_cpu_core_pointerblock m68kpointerblock;
if ((nAction & ACB_DRIVER_DATA) == 0) {
return 1;
@ -2037,10 +2056,16 @@ INT32 SekScan(INT32 nAction)
#ifdef EMU_M68K
if (nSekCPUType[i] != 0) {
ba.Data = SekM68KContext[i];
ba.nLen = nSekM68KContextSize[i];
ba.szName = szName;
BurnAcb(&ba);
// memmove notes: for savestate portability: preserve our cpu's pointers, they are set up in DrvInit() and can be specific to different systems.
memmove(&m68kpointerblock, SekM68KContext[i]+(nSekM68KContextSize[i]-sizeof(m68kpointerblock)), sizeof(m68kpointerblock));
ba.Data = SekM68KContext[i];
ba.nLen = nSekM68KContextSize[i];
ba.szName = szName;
BurnAcb(&ba);
// Put our saved pointers back :)
memmove(SekM68KContext[i]+(nSekM68KContextSize[i]-sizeof(m68kpointerblock)), &m68kpointerblock, sizeof(m68kpointerblock));
}
#endif