From: howprice Date: Wed, 19 Nov 2025 16:15:43 +0000 (+0000) Subject: Fix audio state machine stale intreq2 logic X-Git-Tag: 6020~54^2^2~1 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=ea57e57282a1b350ba1684d0aced793f2d734ad3;p=francis%2Fwinuae.git Fix audio state machine stale intreq2 logic As discussed in the "Undocumented Amiga hardware stuff" thread https://eab.abime.net/showpost.php?p=1679952&postcount=337 The audio state machine intreq2 signal should only be cleared when used to request an interrupt (AUDxIR). Previously, intreq2 was cleared (and no interrupt requested) on the transition from state 5 to state 1. Now, intreq2 is checked on transition from state 0 to state 1. If it is set, then an interrupt is requested and intreq2 is cleared. Logically this is the same for the internal state machine, but the interrupts have been shown to be present on silicon using test case https://github.com/dirkwhoffmann/vAmigaTS/blob/master/Paula/Audio/timing/dmatim2/ and with this change, three missing interrupts are now generated in this test case (I'll add some images to the associated pull request). --- diff --git a/audio.cpp b/audio.cpp index 6f4cb05b..8f3b3462 100644 --- a/audio.cpp +++ b/audio.cpp @@ -1812,6 +1812,10 @@ static bool audio_state_channel2 (int nr, bool perfin) if (cdp->wlen > 2) cdp->ptx_tofetch = true; cdp->dsr = true; + if (cdp->intreq2) { + setirq(nr, 00); + cdp->intreq2 = false; + } #if TEST_AUDIO > 0 cdp->have_dat = false; #endif @@ -1822,7 +1826,7 @@ static bool audio_state_channel2 (int nr, bool perfin) #endif } else if (cdp->dat_written && !isirq (nr)) { cdp->state = 2; - setirq(nr, 0); + setirq(nr, 01); loaddat(nr); if (usehacks() && cdp->per < 10 * CYCLE_UNIT) { static int warned = 100; @@ -1885,7 +1889,6 @@ static bool audio_state_channel2 (int nr, bool perfin) cdp->state = 2; loadper(nr); cdp->pbufldl = true; - cdp->intreq2 = false; cdp->volcnt = 0; audio_state_channel2(nr, false); break;