]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fix audio state machine stale intreq2 logic
authorhowprice <howprice@users.noreply.github.com>
Wed, 19 Nov 2025 16:15:43 +0000 (16:15 +0000)
committerhowprice <howprice@users.noreply.github.com>
Wed, 19 Nov 2025 16:15:43 +0000 (16:15 +0000)
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).

audio.cpp

index 6f4cb05b98386fde2c29c48a08ca67210daceb27..8f3b3462afec6e23ebdf2c26688117d3b8e6dd8f 100644 (file)
--- 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;