From f42befadf10493a8ccb5a021de416cc1efeb5e03 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sat, 27 Feb 2021 04:10:32 +0000 Subject: [PATCH] SPU: Try to recover DMA pointer after savestate load --- pcsx2/SPU2/Dma.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pcsx2/SPU2/Dma.cpp b/pcsx2/SPU2/Dma.cpp index 1b4a1f5caa..9bd33c6fd9 100644 --- a/pcsx2/SPU2/Dma.cpp +++ b/pcsx2/SPU2/Dma.cpp @@ -113,6 +113,11 @@ void V_Core::AutoDMAReadBuffer(int mode) //mode: 0= split stereo; 1 = do not spl // HACKFIX!! DMAPtr can be invalid after a savestate load, so the savestate just forces it // to nullptr and we ignore it here. (used to work in old VM editions of PCSX2 with fixed // addressing, but new PCSX2s have dynamic memory addressing). + if (DMAPtr == nullptr) + { + DMAPtr = (u16*)iopPhysMem(MADR); + InputDataProgress = 0; + } if (mode) { @@ -233,6 +238,11 @@ void V_Core::PlainDMAWrite(u16* pMem, u32 size) void V_Core::FinishDMAwrite() { + if (DMAPtr == nullptr) + { + DMAPtr = (u16*)iopPhysMem(MADR); + } + if (Index == 0) DMA4LogWrite(DMAPtr, ReadSize << 1); else @@ -365,6 +375,11 @@ void V_Core::FinishDMAread() buff1end = 0x100000; } + if (DMAPtr == nullptr) + { + DMAPtr = (u16*)iopPhysMem(MADR); + } + const u32 buff1size = (buff1end - ActiveTSA); memcpy(DMARPtr, GetMemPtr(ActiveTSA), buff1size * 2); // Note on TSA's position after our copy finishes: @@ -418,7 +433,6 @@ void V_Core::FinishDMAread() } } - DMARPtr += TDA - ActiveTSA; ReadSize -= TDA - ActiveTSA; if (ReadSize == 0)