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:
parent
a8de7f2030
commit
52447ad7d9
|
@ -49,7 +49,7 @@ public:
|
||||||
_ASSERT(0);
|
_ASSERT(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
BYTE GetBusViewOfORB(void) { return m_regs.ORB & m_regs.DDRB; } // Return how the AY8913 sees ORB on the bus (ie. not CPU's view which will be OR'd with !DDRB)
|
BYTE GetBusViewOfORB(void) { return m_regs.ORB & m_regs.DDRB; } // Return how the AY8913 sees ORB on the bus (ie. not CPU's view which will be OR'd with !DDRB)
|
||||||
USHORT GetRegT1C(void) { return m_regs.TIMER1_COUNTER.w; }
|
USHORT GetRegT1C(void) { return m_regs.TIMER1_COUNTER.w; }
|
||||||
USHORT GetRegT2C(void) { return m_regs.TIMER2_COUNTER.w; }
|
USHORT GetRegT2C(void) { return m_regs.TIMER2_COUNTER.w; }
|
||||||
void GetRegs(BYTE regs[SIZE_6522_REGS]) { memcpy(®s[0], (BYTE*)&m_regs, SIZE_6522_REGS); } // For debugger
|
void GetRegs(BYTE regs[SIZE_6522_REGS]) { memcpy(®s[0], (BYTE*)&m_regs, SIZE_6522_REGS); } // For debugger
|
||||||
|
|
|
@ -4493,7 +4493,7 @@ Update_t CmdMemoryLoad (int nArgs)
|
||||||
}
|
}
|
||||||
const std::string sLoadSaveFilePath = g_sCurrentDir + g_sMemoryLoadSaveFileName; // TODO: g_sDebugDir
|
const std::string sLoadSaveFilePath = g_sCurrentDir + g_sMemoryLoadSaveFileName; // TODO: g_sDebugDir
|
||||||
|
|
||||||
BYTE * const pMemBankBase = bBankSpecified ? MemGetBankPtr(nBank) : mem;
|
BYTE * const pMemBankBase = bBankSpecified ? MemGetBankPtr(nBank, true) : mem;
|
||||||
if (!pMemBankBase)
|
if (!pMemBankBase)
|
||||||
{
|
{
|
||||||
ConsoleBufferPush( TEXT( "Error: Bank out of range." ) );
|
ConsoleBufferPush( TEXT( "Error: Bank out of range." ) );
|
||||||
|
@ -4832,7 +4832,7 @@ Update_t CmdMemorySave (int nArgs)
|
||||||
}
|
}
|
||||||
sLoadSaveFilePath += g_sMemoryLoadSaveFileName;
|
sLoadSaveFilePath += g_sMemoryLoadSaveFileName;
|
||||||
|
|
||||||
const BYTE * const pMemBankBase = bBankSpecified ? MemGetBankPtr(nBank) : mem;
|
const BYTE * const pMemBankBase = bBankSpecified ? MemGetBankPtr(nBank, true) : mem;
|
||||||
if (!pMemBankBase)
|
if (!pMemBankBase)
|
||||||
{
|
{
|
||||||
ConsoleBufferPush( TEXT( "Error: Bank out of range." ) );
|
ConsoleBufferPush( TEXT( "Error: Bank out of range." ) );
|
||||||
|
|
|
@ -1436,10 +1436,14 @@ LPBYTE MemGetMainPtr(const WORD offset)
|
||||||
|
|
||||||
// Used by:
|
// Used by:
|
||||||
// . Savestate: MemSaveSnapshotMemory(), MemLoadSnapshotAux()
|
// . Savestate: MemSaveSnapshotMemory(), MemLoadSnapshotAux()
|
||||||
|
// . VidHD : SaveSnapshot(), LoadSnapshot()
|
||||||
// . Debugger : CmdMemorySave(), CmdMemoryLoad()
|
// . 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
|
#ifdef RAMWORKS
|
||||||
if (nBank > g_uMaxExPages)
|
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)
|
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)
|
if (bIsMainMem)
|
||||||
{
|
{
|
||||||
|
@ -2447,7 +2451,7 @@ static void MemLoadSnapshotAuxCommon(YamlLoadHelper& yamlLoadHelper, const std::
|
||||||
|
|
||||||
for(UINT uBank = 1; uBank <= g_uMaxExPages; uBank++)
|
for(UINT uBank = 1; uBank <= g_uMaxExPages; uBank++)
|
||||||
{
|
{
|
||||||
LPBYTE pBank = MemGetBankPtr(uBank);
|
LPBYTE pBank = MemGetBankPtr(uBank, false);
|
||||||
if (!pBank)
|
if (!pBank)
|
||||||
{
|
{
|
||||||
pBank = RWpages[uBank-1] = ALIGNED_ALLOC(_6502_MEM_LEN);
|
pBank = RWpages[uBank-1] = ALIGNED_ALLOC(_6502_MEM_LEN);
|
||||||
|
|
|
@ -73,7 +73,7 @@ bool MemCheckSLOTC3ROM();
|
||||||
bool MemCheckINTCXROM();
|
bool MemCheckINTCXROM();
|
||||||
LPBYTE MemGetAuxPtr(const WORD);
|
LPBYTE MemGetAuxPtr(const WORD);
|
||||||
LPBYTE MemGetMainPtr(const WORD);
|
LPBYTE MemGetMainPtr(const WORD);
|
||||||
LPBYTE MemGetBankPtr(const UINT nBank);
|
LPBYTE MemGetBankPtr(const UINT nBank, const bool isSaveSnapshotOrDebugging);
|
||||||
LPBYTE MemGetCxRomPeripheral();
|
LPBYTE MemGetCxRomPeripheral();
|
||||||
DWORD GetMemMode(void);
|
DWORD GetMemMode(void);
|
||||||
void SetMemMode(DWORD memmode);
|
void SetMemMode(DWORD memmode);
|
||||||
|
|
|
@ -210,7 +210,7 @@ void VidHDCard::SaveSnapshot(YamlSaveHelper& yamlSaveHelper)
|
||||||
// Save [$400-$9FFF]
|
// Save [$400-$9FFF]
|
||||||
YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", MemGetSnapshotAuxMemStructName().c_str());
|
YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", MemGetSnapshotAuxMemStructName().c_str());
|
||||||
|
|
||||||
LPBYTE pMemBase = MemGetBankPtr(1);
|
LPBYTE pMemBase = MemGetBankPtr(1, true);
|
||||||
yamlSaveHelper.SaveMemory(pMemBase, (SHR_MEMORY_END + 1) - TEXT_PAGE1_BEGIN, TEXT_PAGE1_BEGIN);
|
yamlSaveHelper.SaveMemory(pMemBase, (SHR_MEMORY_END + 1) - TEXT_PAGE1_BEGIN, TEXT_PAGE1_BEGIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ bool VidHDCard::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version)
|
||||||
if (!yamlLoadHelper.GetSubMap(MemGetSnapshotAuxMemStructName()))
|
if (!yamlLoadHelper.GetSubMap(MemGetSnapshotAuxMemStructName()))
|
||||||
throw std::runtime_error("Memory: Missing map name: " + MemGetSnapshotAuxMemStructName());
|
throw std::runtime_error("Memory: Missing map name: " + MemGetSnapshotAuxMemStructName());
|
||||||
|
|
||||||
LPBYTE pMemBase = MemGetBankPtr(1);
|
LPBYTE pMemBase = MemGetBankPtr(1, false);
|
||||||
yamlLoadHelper.LoadMemory(pMemBase, (SHR_MEMORY_END + 1) - TEXT_PAGE1_BEGIN, TEXT_PAGE1_BEGIN);
|
yamlLoadHelper.LoadMemory(pMemBase, (SHR_MEMORY_END + 1) - TEXT_PAGE1_BEGIN, TEXT_PAGE1_BEGIN);
|
||||||
|
|
||||||
yamlLoadHelper.PopMap();
|
yamlLoadHelper.PopMap();
|
||||||
|
|
Loading…
Reference in New Issue