From e0394921e98136547176f9a224a9bb9084fbda47 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sat, 30 Jan 2021 04:55:28 +0000 Subject: [PATCH] SPU2: Tighten AutoDMA IRQ timing. Fixes games which monitor the MADR while transferring. Tom & Jerry War of the Whiskers was one game that suffered (Jumpy music) --- pcsx2/SPU2/Dma.cpp | 8 -------- pcsx2/SPU2/ReadInput.cpp | 24 +++++++++++++++++++++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/pcsx2/SPU2/Dma.cpp b/pcsx2/SPU2/Dma.cpp index 1149eb5d03..2121ead453 100644 --- a/pcsx2/SPU2/Dma.cpp +++ b/pcsx2/SPU2/Dma.cpp @@ -181,14 +181,6 @@ void V_Core::StartADMAWrite(u16* pMem, u32 sz) #else AutoDMAReadBuffer(0); #endif - - - if (!InputDataLeft) - { - DMAICounter = size * 4; - LastClock = *cyclePtr; - AutoDMACtrl |= ~3; - } } AdmaInProgress = 1; } diff --git a/pcsx2/SPU2/ReadInput.cpp b/pcsx2/SPU2/ReadInput.cpp index c7489d9796..f77e81a9c5 100644 --- a/pcsx2/SPU2/ReadInput.cpp +++ b/pcsx2/SPU2/ReadInput.cpp @@ -110,8 +110,28 @@ StereoOut32 V_Core::ReadInput() if (InputDataTransferred) { u32 amount = std::min(InputDataTransferred, (u32)0x180); - MADR += amount; + InputDataTransferred -= amount; + MADR += amount; + // Because some games watch the MADR to see when it reaches the end we need to end the DMA here + // Tom & Jerry War of the Whiskers is one such game, the music will skip + if (!InputDataTransferred && !InputDataLeft) + { + if (Index == 0) + { + if (!SPU2_dummy_callback) + spu2DMA4Irq(); + else + SPU2interruptDMA4(); + } + else + { + if (!SPU2_dummy_callback) + spu2DMA7Irq(); + else + SPU2interruptDMA7(); + } + } } if (PlayMode == 2 && Index == 0) //Bitstream bypass refills twice as quickly (GTA VC) @@ -141,8 +161,6 @@ StereoOut32 V_Core::ReadInput() } InputDataLeft = 0; - DMAICounter = InputDataTransferred * 4; - LastClock = *cyclePtr; } } else if ((AutoDMACtrl & (Index + 1)))