MemGetBankPtr(): simplify with a default arg. (#1262)
This commit is contained in:
parent
fcd216bb45
commit
529b1a8a83
|
@ -4493,7 +4493,7 @@ Update_t CmdMemoryLoad (int nArgs)
|
|||
}
|
||||
const std::string sLoadSaveFilePath = g_sCurrentDir + g_sMemoryLoadSaveFileName; // TODO: g_sDebugDir
|
||||
|
||||
BYTE * const pMemBankBase = bBankSpecified ? MemGetBankPtr(nBank, true) : mem;
|
||||
BYTE * const pMemBankBase = bBankSpecified ? MemGetBankPtr(nBank) : mem;
|
||||
if (!pMemBankBase)
|
||||
{
|
||||
ConsoleBufferPush( TEXT( "Error: Bank out of range." ) );
|
||||
|
@ -4832,7 +4832,7 @@ Update_t CmdMemorySave (int nArgs)
|
|||
}
|
||||
sLoadSaveFilePath += g_sMemoryLoadSaveFileName;
|
||||
|
||||
const BYTE * const pMemBankBase = bBankSpecified ? MemGetBankPtr(nBank, true) : mem;
|
||||
const BYTE * const pMemBankBase = bBankSpecified ? MemGetBankPtr(nBank) : mem;
|
||||
if (!pMemBankBase)
|
||||
{
|
||||
ConsoleBufferPush( TEXT( "Error: Bank out of range." ) );
|
||||
|
|
|
@ -1336,19 +1336,6 @@ bool MemCheckINTCXROM()
|
|||
|
||||
//===========================================================================
|
||||
|
||||
static void BackMainImage(void)
|
||||
{
|
||||
for (UINT loop = 0; loop < 256; loop++)
|
||||
{
|
||||
if (memshadow[loop] && ((*(memdirty+loop) & 1) || (loop <= 1)))
|
||||
memcpy(memshadow[loop], mem+(loop << 8), 256);
|
||||
|
||||
*(memdirty+loop) &= ~1;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
static LPBYTE MemGetPtrBANK1(const WORD offset, const LPBYTE pMemBase)
|
||||
{
|
||||
if ((offset & 0xF000) != 0xC000) // Requesting RAM at physical addr $Cxxx (ie. 4K RAM BANK1)
|
||||
|
@ -1434,11 +1421,24 @@ LPBYTE MemGetMainPtr(const WORD offset)
|
|||
|
||||
//===========================================================================
|
||||
|
||||
static void BackMainImage(void)
|
||||
{
|
||||
for (UINT loop = 0; loop < 256; loop++)
|
||||
{
|
||||
if (memshadow[loop] && ((*(memdirty + loop) & 1) || (loop <= 1)))
|
||||
memcpy(memshadow[loop], mem + (loop << 8), 256);
|
||||
|
||||
*(memdirty + loop) &= ~1;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
// Used by:
|
||||
// . Savestate: MemSaveSnapshotMemory(), MemLoadSnapshotAux()
|
||||
// . VidHD : SaveSnapshot(), LoadSnapshot()
|
||||
// . Debugger : CmdMemorySave(), CmdMemoryLoad()
|
||||
LPBYTE MemGetBankPtr(const UINT nBank, const bool isSaveSnapshotOrDebugging)
|
||||
LPBYTE MemGetBankPtr(const UINT nBank, const bool isSaveSnapshotOrDebugging/*=true*/)
|
||||
{
|
||||
// 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)
|
||||
|
@ -2250,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, true);
|
||||
LPBYTE pMemBase = MemGetBankPtr(bank);
|
||||
|
||||
if (bIsMainMem)
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ bool MemCheckSLOTC3ROM();
|
|||
bool MemCheckINTCXROM();
|
||||
LPBYTE MemGetAuxPtr(const WORD);
|
||||
LPBYTE MemGetMainPtr(const WORD);
|
||||
LPBYTE MemGetBankPtr(const UINT nBank, const bool isSaveSnapshotOrDebugging);
|
||||
LPBYTE MemGetBankPtr(const UINT nBank, const bool isSaveSnapshotOrDebugging = true);
|
||||
LPBYTE MemGetCxRomPeripheral();
|
||||
DWORD GetMemMode(void);
|
||||
void SetMemMode(DWORD memmode);
|
||||
|
|
|
@ -210,7 +210,7 @@ void VidHDCard::SaveSnapshot(YamlSaveHelper& yamlSaveHelper)
|
|||
// Save [$400-$9FFF]
|
||||
YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", MemGetSnapshotAuxMemStructName().c_str());
|
||||
|
||||
LPBYTE pMemBase = MemGetBankPtr(1, true);
|
||||
LPBYTE pMemBase = MemGetBankPtr(1);
|
||||
yamlSaveHelper.SaveMemory(pMemBase, (SHR_MEMORY_END + 1) - TEXT_PAGE1_BEGIN, TEXT_PAGE1_BEGIN);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue