From 960af9bda0e7202ebdcb4979c80288e9c69cb501 Mon Sep 17 00:00:00 2001 From: tomcw Date: Tue, 24 Dec 2019 13:58:20 +0000 Subject: [PATCH] MB: Moved MB_StartOfCpuExecute() to Snapshot_LoadState_v2(), since it's only needed there --- source/CPU.cpp | 4 +++- source/Mockingboard.cpp | 17 ++++++++++++++--- source/Mockingboard.h | 5 ++++- source/SaveState.cpp | 1 + 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/source/CPU.cpp b/source/CPU.cpp index 3fd31232..09b13ddd 100644 --- a/source/CPU.cpp +++ b/source/CPU.cpp @@ -556,7 +556,9 @@ DWORD CpuExecute(const DWORD uCycles, const bool bVideoUpdate) { g_nCyclesExecuted = 0; - MB_StartOfCpuExecute(); +#ifdef _DEBUG + MB_CheckCumulativeCycles(); +#endif // uCycles: // =0 : Do single step diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index b24b1e50..546ea85a 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -1494,7 +1494,7 @@ void MB_Destroy() static void ResetState() { g_nMBTimerDevice = kTIMERDEVICE_INVALID; - g_uLastCumulativeCycles = 0; + MB_SetCumulativeCycles(); g_nSSI263Device = 0; g_nCurrentActivePhoneme = -1; @@ -1761,8 +1761,19 @@ void MB_Demute() //----------------------------------------------------------------------------- -// Called by CpuExecute() before doing CPU emulation -void MB_StartOfCpuExecute() +#ifdef _DEBUG +void MB_CheckCumulativeCycles() +{ + if (g_SoundcardType == CT_Empty) + return; + + _ASSERT(g_uLastCumulativeCycles == g_nCumulativeCycles); + g_uLastCumulativeCycles = g_nCumulativeCycles; +} +#endif + +// Called by: ResetState() and Snapshot_LoadState_v2() +void MB_SetCumulativeCycles() { g_uLastCumulativeCycles = g_nCumulativeCycles; } diff --git a/source/Mockingboard.h b/source/Mockingboard.h index 740e3efa..49859f58 100644 --- a/source/Mockingboard.h +++ b/source/Mockingboard.h @@ -10,7 +10,10 @@ void MB_InitializeForLoadingSnapshot(void); void MB_InitializeIO(LPBYTE pCxRomPeripheral, UINT uSlot4, UINT uSlot5); void MB_Mute(); void MB_Demute(); -void MB_StartOfCpuExecute(); +#ifdef _DEBUG +void MB_CheckCumulativeCycles(); // DEBUG +#endif +void MB_SetCumulativeCycles(); void MB_PeriodicUpdate(UINT executedCycles); void MB_CheckIRQ(); bool MB_UpdateCycles(ULONG uExecutedCycles); diff --git a/source/SaveState.cpp b/source/SaveState.cpp index e279f77b..62815380 100644 --- a/source/SaveState.cpp +++ b/source/SaveState.cpp @@ -437,6 +437,7 @@ static void Snapshot_LoadState_v2(void) throw std::string("Unknown top-level scalar: " + scalar); } + MB_SetCumulativeCycles(); SetLoadedSaveStateFlag(true); // NB. The following disparity should be resolved: