Save-state: Better MB init for loading save-state

This commit is contained in:
tomcw 2019-02-24 10:49:09 +00:00
parent 1f1bcfd374
commit de3f0d877e
3 changed files with 16 additions and 10 deletions

View File

@ -1376,7 +1376,7 @@ static void MB_DSUninit()
//=============================================================================
void MB_InitSoundcardType(void) // GH#609
static void InitSoundcardType(void)
{
g_SoundcardType = CT_Empty; // Use CT_Empty to mean: no soundcard
g_bPhasorEnable = false;
@ -1384,7 +1384,7 @@ void MB_InitSoundcardType(void) // GH#609
void MB_Initialize()
{
MB_InitSoundcardType();
InitSoundcardType();
LogFileOutput("MB_Initialize: g_bDisableDirectSound=%d, g_bDisableDirectSoundMockingboard=%d\n", g_bDisableDirectSound, g_bDisableDirectSoundMockingboard);
if (g_bDisableDirectSound || g_bDisableDirectSoundMockingboard)
@ -1418,6 +1418,12 @@ void MB_Initialize()
g_bCritSectionValid = true;
}
void MB_InitializeForLoadingSnapshot() // GH#609
{
MB_Reset();
InitSoundcardType();
}
//-----------------------------------------------------------------------------
// NB. Called when /g_fCurrentCLK6502/ changes
@ -1460,15 +1466,16 @@ static void ResetState()
g_bMB_RegAccessedFlag = false;
g_bMB_Active = false;
//g_bMBAvailable = false;
// g_SoundcardType = CT_Empty; // Don't uncomment, else _ASSERT will fire in MB_Read() after an F2->MB_Reset()
// g_bPhasorEnable = false;
g_nPhasorMode = 0;
g_PhasorClockScaleFactor = 1;
// Not these, as they don't change on a CTRL+RESET or power-cycle:
// g_bMBAvailable = false;
// g_SoundcardType = CT_Empty; // Don't uncomment, else _ASSERT will fire in MB_Read() after an F2->MB_Reset()
// g_bPhasorEnable = false;
}
void MB_Reset()
void MB_Reset() // CTRL+RESET or power-cycle
{
if(!g_bDSAvailable)
return;

View File

@ -4,7 +4,7 @@ void MB_Initialize();
void MB_Reinitialize();
void MB_Destroy();
void MB_Reset();
void MB_InitSoundcardType(void);
void MB_InitializeForLoadingSnapshot(void);
void MB_InitializeIO(LPBYTE pCxRomPeripheral, UINT uSlot4, UINT uSlot5);
void MB_Mute();
void MB_Demute();

View File

@ -391,8 +391,7 @@ static void Snapshot_LoadState_v2(void)
HD_Reset();
KeybReset();
VideoResetState();
MB_Reset();
MB_InitSoundcardType(); // GH#609
MB_InitializeForLoadingSnapshot(); // GH#609
sg_SSC.CommReset();
#ifdef USE_SPEECH_API
g_Speech.Reset();