mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-01-22 14:17:03 +00:00
Load save-state: fix page 0 & 1 corruption when loading save-state with a RAMWorks card with 2 or more aux 64K banks (#1262)
This commit is contained in:
@@ -1436,10 +1436,14 @@ LPBYTE MemGetMainPtr(const WORD offset)
|
||||
|
||||
// Used by:
|
||||
// . Savestate: MemSaveSnapshotMemory(), MemLoadSnapshotAux()
|
||||
// . VidHD : SaveSnapshot(), LoadSnapshot()
|
||||
// . Debugger : CmdMemorySave(), CmdMemoryLoad()
|
||||
LPBYTE MemGetBankPtr(const UINT nBank)
|
||||
LPBYTE MemGetBankPtr(const UINT nBank, const bool isSaveSnapshotOrDebugging)
|
||||
{
|
||||
BackMainImage(); // Flush any dirty pages to back-buffer
|
||||
// Only call BackMainImage() when a consistent 64K bank is needed, eg. for saving snapshot or debugging
|
||||
// - for snapshot loads it's pointless, and worse it can corrupt pages 0 & 1 for aux banks (GH#1262)
|
||||
if (isSaveSnapshotOrDebugging)
|
||||
BackMainImage(); // Flush any dirty pages to back-buffer
|
||||
|
||||
#ifdef RAMWORKS
|
||||
if (nBank > g_uMaxExPages)
|
||||
@@ -2246,7 +2250,7 @@ static const std::string& MemGetSnapshotAuxMemStructName(void)
|
||||
|
||||
static void MemSaveSnapshotMemory(YamlSaveHelper& yamlSaveHelper, bool bIsMainMem, UINT bank=0, UINT size=64*1024)
|
||||
{
|
||||
LPBYTE pMemBase = MemGetBankPtr(bank);
|
||||
LPBYTE pMemBase = MemGetBankPtr(bank, true);
|
||||
|
||||
if (bIsMainMem)
|
||||
{
|
||||
@@ -2447,7 +2451,7 @@ static void MemLoadSnapshotAuxCommon(YamlLoadHelper& yamlLoadHelper, const std::
|
||||
|
||||
for(UINT uBank = 1; uBank <= g_uMaxExPages; uBank++)
|
||||
{
|
||||
LPBYTE pBank = MemGetBankPtr(uBank);
|
||||
LPBYTE pBank = MemGetBankPtr(uBank, false);
|
||||
if (!pBank)
|
||||
{
|
||||
pBank = RWpages[uBank-1] = ALIGNED_ALLOC(_6502_MEM_LEN);
|
||||
|
||||
Reference in New Issue
Block a user