From c34a8b3249720ad254bbc4c9b70fe74380b77859 Mon Sep 17 00:00:00 2001 From: dinkc64 <12570148+dinkc64@users.noreply.github.com> Date: Sun, 16 Nov 2014 19:55:45 +0000 Subject: [PATCH] Musashi savestate fix --- src/cpu/m68000_intf.cpp | 24 ++---------------------- src/cpu/m68k/m68k.h | 3 +++ src/cpu/m68k/m68kcpu.c | 6 ++++++ src/cpu/m68k/m68kcpu.h | 3 +++ 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/cpu/m68000_intf.cpp b/src/cpu/m68000_intf.cpp index 9b7634453..8af1f3433 100644 --- a/src/cpu/m68000_intf.cpp +++ b/src/cpu/m68000_intf.cpp @@ -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); } diff --git a/src/cpu/m68k/m68k.h b/src/cpu/m68k/m68k.h index 3ffe19cf5..bd89f6209 100644 --- a/src/cpu/m68k/m68k.h +++ b/src/cpu/m68k/m68k.h @@ -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); diff --git a/src/cpu/m68k/m68kcpu.c b/src/cpu/m68k/m68kcpu.c index b9a927175..d2faf7022 100644 --- a/src/cpu/m68k/m68kcpu.c +++ b/src/cpu/m68k/m68kcpu.c @@ -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; diff --git a/src/cpu/m68k/m68kcpu.h b/src/cpu/m68k/m68kcpu.h index aed8fdaaf..97c174502 100644 --- a/src/cpu/m68k/m68kcpu.h +++ b/src/cpu/m68k/m68kcpu.h @@ -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;