Musashi savestate fix

This commit is contained in:
dinkc64 2014-11-16 19:55:45 +00:00
parent 6f63bf0bc1
commit c34a8b3249
4 changed files with 14 additions and 22 deletions

View File

@ -1987,26 +1987,6 @@ 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
{
const UINT8* cyc_instruction;
const 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 */
int (*tas_instr_callback)(void); /* Called when a TAS 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)(unsigned int pc); /* Called every instruction cycle prior to execution */
};
INT32 SekScan(INT32 nAction)
{
#if defined FBA_DEBUG
@ -2015,7 +1995,6 @@ 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;
@ -2081,7 +2060,8 @@ INT32 SekScan(INT32 nAction)
if (nSekCPUType[i] != 0) {
ba.Data = SekM68KContext[i];
// for savestate portability: preserve our cpu's pointers, they are set up in DrvInit() and can be specific to different systems.
ba.nLen = nSekM68KContextSize[i] - sizeof(m68kpointerblock);
// Therefore we scan the cpu context structure up until right before the pointers
ba.nLen = m68k_context_size_no_pointers();
ba.szName = szName;
BurnAcb(&ba);
}

View File

@ -336,6 +336,9 @@ void m68k_pulse_halt(void);
/* Get the size of the cpu context in bytes */
unsigned int m68k_context_size(void);
/* Get the size of the cpu context without the pointer-block, for savestates */
unsigned int m68k_context_size_no_pointers(void);
/* Get a cpu context */
unsigned int m68k_get_context(void* dst);

View File

@ -965,6 +965,12 @@ unsigned int m68k_context_size()
return sizeof(m68ki_cpu_core);
}
/* Used to calculate the context size minus the system-specific pointers, for savestates */
unsigned int m68k_context_size_no_pointers()
{
return (int)&m68ki_cpu.pointer_block_divider - (int)&m68ki_cpu;
}
unsigned int m68k_get_context(void* dst)
{
if(dst) *(m68ki_cpu_core*)dst = m68ki_cpu;

View File

@ -898,6 +898,9 @@ struct _m68ki_cpu_core
uint virq_state;
uint nmi_pending;
/* Designates the end of the CPU context variables and beginning of system-specific pointers */
uint8 pointer_block_divider; /* Used to calculate the context-size for savestates */
const uint8* cyc_instruction;
const uint8* cyc_exception;