MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / MB_SyncEventCallbackInternal

Method MB_SyncEventCallbackInternal

source/Mockingboard.cpp:988–1026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

986}
987
988int MockingboardCard::MB_SyncEventCallbackInternal(int id, int /*cycles*/, ULONG uExecutedCycles)
989{
990 //UpdateCycles(uExecutedCycles); // Underflow: so keep TIMER1/2 counters in sync
991 // Update all MBs, so that m_lastCumulativeCycle remains in sync for all
992 GetCardMgr().GetMockingboardCardMgr().UpdateCycles(uExecutedCycles); // Underflow: so keep TIMER1/2 counters in sync
993
994 MB_SUBUNIT* pMB = &m_MBSubUnit[(id & 0xf) / SY6522::kNumTimersPer6522];
995
996 if ((id & 1) == 0)
997 {
998 _ASSERT(pMB->sy6522.IsTimer1Active());
999 UpdateIFRandIRQ(pMB, 0, SY6522::IxR_TIMER1);
1000 GetCardMgr().GetMockingboardCardMgr().UpdateSoundBuffer();
1001
1002 if ((pMB->sy6522.GetReg(SY6522::rACR) & SY6522::ACR_RUNMODE) == SY6522::ACR_RM_FREERUNNING)
1003 {
1004 pMB->sy6522.StartTimer1();
1005 if (pMB->sy6522.IsTimer1IrqDelay())
1006 return 0x0001; // T1C=0xFFFF, which is really -1, as there's 1 cycle until underflow occurs
1007 // TODO: can also be 0x0002 for MegaAudio
1008 return pMB->sy6522.GetRegT1C() + SY6522::kExtraTimerCycles;
1009 }
1010
1011 // One-shot mode
1012 // - Phasor's playback code uses one-shot mode
1013
1014 pMB->sy6522.StopTimer1();
1015 return 0; // Don't repeat event
1016 }
1017 else
1018 {
1019 // NB. Since not calling UpdateSoundBuffer(), then AppleWin doesn't (accurately?) support AY-playback using T2 (which is one-shot only)
1020 _ASSERT(pMB->sy6522.IsTimer2Active());
1021 UpdateIFRandIRQ(pMB, 0, SY6522::IxR_TIMER2);
1022
1023 pMB->sy6522.StopTimer2(); // TIMER2 only runs in one-shot mode
1024 return 0; // Don't repeat event
1025 }
1026}
1027
1028//-----------------------------------------------------------------------------
1029

Callers 1

MB_SyncEventCallbackMethod · 0.80

Calls 10

IsTimer1ActiveMethod · 0.80
UpdateSoundBufferMethod · 0.80
GetRegMethod · 0.80
StartTimer1Method · 0.80
IsTimer1IrqDelayMethod · 0.80
GetRegT1CMethod · 0.80
StopTimer1Method · 0.80
IsTimer2ActiveMethod · 0.80
StopTimer2Method · 0.80
UpdateCyclesMethod · 0.45

Tested by

no test coverage detected