SPU: Try to recover DMA pointer after savestate load

This commit is contained in:
refractionpcsx2 2021-02-27 04:10:32 +00:00
parent e42d506a64
commit f42befadf1
1 changed files with 15 additions and 1 deletions

View File

@ -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 // 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 // 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). // addressing, but new PCSX2s have dynamic memory addressing).
if (DMAPtr == nullptr)
{
DMAPtr = (u16*)iopPhysMem(MADR);
InputDataProgress = 0;
}
if (mode) if (mode)
{ {
@ -233,6 +238,11 @@ void V_Core::PlainDMAWrite(u16* pMem, u32 size)
void V_Core::FinishDMAwrite() void V_Core::FinishDMAwrite()
{ {
if (DMAPtr == nullptr)
{
DMAPtr = (u16*)iopPhysMem(MADR);
}
if (Index == 0) if (Index == 0)
DMA4LogWrite(DMAPtr, ReadSize << 1); DMA4LogWrite(DMAPtr, ReadSize << 1);
else else
@ -365,6 +375,11 @@ void V_Core::FinishDMAread()
buff1end = 0x100000; buff1end = 0x100000;
} }
if (DMAPtr == nullptr)
{
DMAPtr = (u16*)iopPhysMem(MADR);
}
const u32 buff1size = (buff1end - ActiveTSA); const u32 buff1size = (buff1end - ActiveTSA);
memcpy(DMARPtr, GetMemPtr(ActiveTSA), buff1size * 2); memcpy(DMARPtr, GetMemPtr(ActiveTSA), buff1size * 2);
// Note on TSA's position after our copy finishes: // Note on TSA's position after our copy finishes:
@ -418,7 +433,6 @@ void V_Core::FinishDMAread()
} }
} }
DMARPtr += TDA - ActiveTSA; DMARPtr += TDA - ActiveTSA;
ReadSize -= TDA - ActiveTSA; ReadSize -= TDA - ActiveTSA;
if (ReadSize == 0) if (ReadSize == 0)