This commit is contained in:
tomcw 2023-04-12 17:58:08 +01:00
parent 990a1c1531
commit 40bbc9d6aa
2 changed files with 6 additions and 5 deletions

View File

@ -110,8 +110,8 @@ USHORT SY6522::SetTimerSyncEvent(BYTE reg, USHORT timerLatch)
if (syncEvent->m_active)
g_SynchronousEventMgr.Remove(syncEvent->m_id);
if (m_isMegaAudio && reg == rT1CH && timerLatch == 0x0000) timerLatch = 0xFFFF; // Probably should be 0x10000, but 0xFFFF is good enough
const UINT kMegaAudioAdjust = m_isMegaAudio ? 1 : 0; // MegaAudio asserts IRQ 1 cycle late!
if (m_isMegaAudio && reg == rT1CH && timerLatch == 0x0000) timerLatch = 0xFFFF; // MegaAudio && T1.LATCH=0: use 0xFFFF (or maybe 0x10000?)
const UINT kMegaAudioAdjust = m_isMegaAudio ? kExtraMegaAudioTimerCycles : 0; // MegaAudio asserts IRQ 1 cycle late!
syncEvent->SetCycles(timerLatch + kExtraTimerCycles + opcodeCycleAdjust + kMegaAudioAdjust);
g_SynchronousEventMgr.Insert(syncEvent);
@ -287,10 +287,9 @@ int SY6522::OnTimer1Underflow(USHORT& counter)
int timer = (int)(short)(counter);
if (m_isMegaAudio)
{
const UINT kMegaAudioAdjust = 1; // MegaAudio asserts IRQ 1 cycle late!
const UINT timerLatch = m_regs.TIMER1_LATCH.w ? m_regs.TIMER1_LATCH.w : 0x10000; // MegaAudio: for a latch of 0x0000 use 0x10000!
const UINT timerLatch = m_regs.TIMER1_LATCH.w ? m_regs.TIMER1_LATCH.w : 0xFFFF; // MegaAudio && T1.LATCH=0: use 0xFFFF (or maybe 0x10000?)
while (timer < -2)
timer += (timerLatch + kExtraTimerCycles + kMegaAudioAdjust);
timer += (timerLatch + kExtraTimerCycles + kExtraMegaAudioTimerCycles); // MegaAudio asserts IRQ 1 cycle late!
}
else
{

View File

@ -144,4 +144,6 @@ private:
class SyncEvent* m_syncEvent[kNumTimersPer6522];
UINT m_slot;
bool m_isMegaAudio;
static const UINT kExtraMegaAudioTimerCycles = 1;
};