MB/6522: better reset support - only ACR,IFR,IER affected
This commit is contained in:
parent
84a705d20d
commit
4e88163430
5 changed files with 23 additions and 16 deletions
|
@ -701,7 +701,6 @@ void CpuIrqAssert(eIRQSRC Device)
|
||||||
|
|
||||||
void CpuIrqDeassert(eIRQSRC Device)
|
void CpuIrqDeassert(eIRQSRC Device)
|
||||||
{
|
{
|
||||||
_ASSERT(g_bCritSectionValid);
|
|
||||||
if (g_bCritSectionValid) EnterCriticalSection(&g_CriticalSection);
|
if (g_bCritSectionValid) EnterCriticalSection(&g_CriticalSection);
|
||||||
g_bmIRQ &= ~(1<<Device);
|
g_bmIRQ &= ~(1<<Device);
|
||||||
if (g_bCritSectionValid) LeaveCriticalSection(&g_CriticalSection);
|
if (g_bCritSectionValid) LeaveCriticalSection(&g_CriticalSection);
|
||||||
|
|
|
@ -272,11 +272,20 @@ static void StopTimer2(SY6522_AY8910* pMB)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static void ResetSY6522(SY6522_AY8910* pMB)
|
static void SY6522_Write(BYTE nDevice, BYTE nReg, BYTE nValue);
|
||||||
|
|
||||||
|
static void ResetSY6522(SY6522_AY8910* pMB, const bool powerCycle)
|
||||||
{
|
{
|
||||||
memset(&pMB->sy6522,0,sizeof(SY6522));
|
if (powerCycle)
|
||||||
pMB->sy6522.TIMER1_LATCH.w = 0xffff; // Some random value (but pick $ffff so it's deterministic)
|
{
|
||||||
// . NB. if it's too small (< ~$0007) then MB detection routines will fail!
|
memset(&pMB->sy6522,0,sizeof(SY6522));
|
||||||
|
pMB->sy6522.TIMER1_LATCH.w = 0xffff; // Some random value (but pick $ffff so it's deterministic)
|
||||||
|
// . NB. if it's too small (< ~$0007) then MB detection routines will fail!
|
||||||
|
}
|
||||||
|
|
||||||
|
SY6522_Write(pMB->nAY8910Number, 0x0b, 0x00); // ACR = 0x00: T1 one-shot mode
|
||||||
|
SY6522_Write(pMB->nAY8910Number, 0x0d, 0x7f); // IFR = 0x7F: de-assert any IRQs
|
||||||
|
SY6522_Write(pMB->nAY8910Number, 0x0e, 0x7f); // IFE = 0x7F: disable all IRQs
|
||||||
|
|
||||||
StopTimer1(pMB);
|
StopTimer1(pMB);
|
||||||
StopTimer2(pMB);
|
StopTimer2(pMB);
|
||||||
|
@ -556,7 +565,6 @@ static void UpdateIFR(SY6522_AY8910* pMB, BYTE clr_ifr, BYTE set_ifr=0)
|
||||||
{
|
{
|
||||||
// Need critical section to avoid data-race: main thread & SSI263Thread can both access IFR
|
// Need critical section to avoid data-race: main thread & SSI263Thread can both access IFR
|
||||||
// . NB. Loading a save-state just directly writes into 6522.IFR (which is fine)
|
// . NB. Loading a save-state just directly writes into 6522.IFR (which is fine)
|
||||||
_ASSERT(g_bCritSectionValid);
|
|
||||||
if (g_bCritSectionValid) EnterCriticalSection(&g_CriticalSection);
|
if (g_bCritSectionValid) EnterCriticalSection(&g_CriticalSection);
|
||||||
{
|
{
|
||||||
pMB->sy6522.IFR &= ~clr_ifr;
|
pMB->sy6522.IFR &= ~clr_ifr;
|
||||||
|
@ -1726,7 +1734,7 @@ void MB_Initialize()
|
||||||
g_bMBAvailable = MB_DSInit();
|
g_bMBAvailable = MB_DSInit();
|
||||||
LogFileOutput("MB_Initialize: MB_DSInit(), g_bMBAvailable=%d\n", g_bMBAvailable);
|
LogFileOutput("MB_Initialize: MB_DSInit(), g_bMBAvailable=%d\n", g_bMBAvailable);
|
||||||
|
|
||||||
MB_Reset();
|
MB_Reset(true);
|
||||||
LogFileOutput("MB_Initialize: MB_Reset()\n");
|
LogFileOutput("MB_Initialize: MB_Reset()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1745,7 +1753,7 @@ static void MB_SetSoundcardType(SS_CARDTYPE NewSoundcardType);
|
||||||
// . and voice will be demuted when dialog is closed
|
// . and voice will be demuted when dialog is closed
|
||||||
void MB_InitializeForLoadingSnapshot() // GH#609
|
void MB_InitializeForLoadingSnapshot() // GH#609
|
||||||
{
|
{
|
||||||
MB_Reset();
|
MB_Reset(true);
|
||||||
InitSoundcardType();
|
InitSoundcardType();
|
||||||
|
|
||||||
if (g_bDisableDirectSound || g_bDisableDirectSoundMockingboard)
|
if (g_bDisableDirectSound || g_bDisableDirectSoundMockingboard)
|
||||||
|
@ -1823,14 +1831,14 @@ static void ResetState()
|
||||||
// g_bPhasorEnable = false;
|
// g_bPhasorEnable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MB_Reset() // CTRL+RESET or power-cycle
|
void MB_Reset(const bool powerCycle) // CTRL+RESET or power-cycle
|
||||||
{
|
{
|
||||||
if(!g_bDSAvailable)
|
if (!g_bDSAvailable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(int i=0; i<NUM_AY8910; i++)
|
for (int i=0; i<NUM_AY8910; i++)
|
||||||
{
|
{
|
||||||
ResetSY6522(&g_MB[i]);
|
ResetSY6522(&g_MB[i], powerCycle);
|
||||||
AY8910_reset(i);
|
AY8910_reset(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
void MB_Initialize();
|
void MB_Initialize();
|
||||||
void MB_Reinitialize();
|
void MB_Reinitialize();
|
||||||
void MB_Destroy();
|
void MB_Destroy();
|
||||||
void MB_Reset();
|
void MB_Reset(const bool powerCycle);
|
||||||
void MB_InitializeForLoadingSnapshot(void);
|
void MB_InitializeForLoadingSnapshot(void);
|
||||||
void MB_InitializeIO(LPBYTE pCxRomPeripheral, UINT uSlot4, UINT uSlot5);
|
void MB_InitializeIO(LPBYTE pCxRomPeripheral, UINT uSlot4, UINT uSlot5);
|
||||||
void MB_Mute();
|
void MB_Mute();
|
||||||
|
|
|
@ -538,7 +538,7 @@ void ResetMachineState()
|
||||||
GetCardMgr().GetSSC()->CommReset();
|
GetCardMgr().GetSSC()->CommReset();
|
||||||
PrintReset();
|
PrintReset();
|
||||||
JoyReset();
|
JoyReset();
|
||||||
MB_Reset();
|
MB_Reset(true);
|
||||||
SpkrReset();
|
SpkrReset();
|
||||||
if (GetCardMgr().IsMouseCardInstalled())
|
if (GetCardMgr().IsMouseCardInstalled())
|
||||||
GetCardMgr().GetMouseCard()->Reset();
|
GetCardMgr().GetMouseCard()->Reset();
|
||||||
|
@ -583,7 +583,7 @@ void CtrlReset()
|
||||||
KeybReset();
|
KeybReset();
|
||||||
if (GetCardMgr().IsSSCInstalled())
|
if (GetCardMgr().IsSSCInstalled())
|
||||||
GetCardMgr().GetSSC()->CommReset();
|
GetCardMgr().GetSSC()->CommReset();
|
||||||
MB_Reset();
|
MB_Reset(false);
|
||||||
if (GetCardMgr().IsMouseCardInstalled())
|
if (GetCardMgr().IsMouseCardInstalled())
|
||||||
GetCardMgr().GetMouseCard()->Reset(); // Deassert any pending IRQs - GH#514
|
GetCardMgr().GetMouseCard()->Reset(); // Deassert any pending IRQs - GH#514
|
||||||
#ifdef USE_SPEECH_API
|
#ifdef USE_SPEECH_API
|
||||||
|
|
|
@ -647,7 +647,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
|
||||||
g_bRestartFullScreen = false;
|
g_bRestartFullScreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MB_Reset();
|
MB_Reset(true);
|
||||||
LogFileOutput("Main: MB_Reset()\n");
|
LogFileOutput("Main: MB_Reset()\n");
|
||||||
|
|
||||||
if (g_bRestart)
|
if (g_bRestart)
|
||||||
|
|
Loading…
Add table
Reference in a new issue