From bdac7672b779fd46ee28373c22a62df60ce22ee1 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Fri, 21 Oct 2022 10:45:20 +0100 Subject: [PATCH] SPU2: Move ADMA clear to ADMA disable. Fix bug with errantly setting data size if there isn't any. --- pcsx2/SPU2/Dma.cpp | 2 +- pcsx2/SPU2/ReadInput.cpp | 6 ------ pcsx2/SPU2/spu2sys.cpp | 10 ++++++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pcsx2/SPU2/Dma.cpp b/pcsx2/SPU2/Dma.cpp index 15adbda61a..722c6b20a9 100644 --- a/pcsx2/SPU2/Dma.cpp +++ b/pcsx2/SPU2/Dma.cpp @@ -108,7 +108,7 @@ void V_Core::AutoDMAReadBuffer(int mode) //mode: 0= split stereo; 1 = do not spl int size = std::min(InputDataLeft, (u32)0x200); if (!leftbuffer) - size = 0x100; + size = std::min(size, 0x100); LogAutoDMA(Index ? ADMA7LogFile : ADMA4LogFile); //ConLog("Refilling ADMA buffer at %x OutPos %x with %x\n", spos, OutPos, size); // HACKFIX!! DMAPtr can be invalid after a savestate load, so the savestate just forces it diff --git a/pcsx2/SPU2/ReadInput.cpp b/pcsx2/SPU2/ReadInput.cpp index 9668cfb024..9275c5f1c9 100644 --- a/pcsx2/SPU2/ReadInput.cpp +++ b/pcsx2/SPU2/ReadInput.cpp @@ -116,12 +116,6 @@ StereoOut32 V_Core::ReadInput() retval = StereoOut32( (s32)(*GetMemPtr(0x2000 + (Index << 10) + ReadIndex)), (s32)(*GetMemPtr(0x2200 + (Index << 10) + ReadIndex))); - - // Not accurate behaviour but shouldn't hurt for now, need to run some tests - // to see why Prince of Persia Warrior Within buzzes when going in to the map - // since it starts an ADMA of music, then kills ADMA, so it loops on a few ms of data. - GetMemPtr(0x2000 + (Index << 10) + ReadIndex)[0] = 0; - GetMemPtr(0x2200 + (Index << 10) + ReadIndex)[0] = 0; } #ifdef PCSX2_DEVBUILD diff --git a/pcsx2/SPU2/spu2sys.cpp b/pcsx2/SPU2/spu2sys.cpp index 334966c72c..9252348cc0 100644 --- a/pcsx2/SPU2/spu2sys.cpp +++ b/pcsx2/SPU2/spu2sys.cpp @@ -1559,6 +1559,16 @@ static void RegWrite_Core(u16 value) thiscore.InputDataLeft = 0; thiscore.DMAICounter = 0; thiscore.InputDataTransferred = 0; + + // Not accurate behaviour but shouldn't hurt for now, need to run some tests + // to see why Prince of Persia Warrior Within buzzes when going in to the map + // since it starts an ADMA of music, then kills ADMA and input DMA + // without disabling ADMA read mode or clearing the buffer. + for (int i = 0; i < 0x200; i++) + { + GetMemPtr(0x2000 + (thiscore.Index << 10))[i] = 0; + GetMemPtr(0x2200 + (thiscore.Index << 10))[i] = 0; + } } break;