From 7c37e8628339f008b6ab77c9845e059b22adae8f Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sat, 23 Jan 2021 06:50:14 +0000 Subject: [PATCH] SPU2: Change input area updates for Hifi reads Remove the no longer required InputPosRead Bump Savestates --- pcsx2/SPU2/Dma.cpp | 5 +--- pcsx2/SPU2/ReadInput.cpp | 62 +++++++--------------------------------- pcsx2/SPU2/defs.h | 1 - pcsx2/SPU2/spu2sys.cpp | 1 - pcsx2/SaveState.h | 2 +- 5 files changed, 13 insertions(+), 58 deletions(-) diff --git a/pcsx2/SPU2/Dma.cpp b/pcsx2/SPU2/Dma.cpp index 39b7967a78..c120f4160e 100644 --- a/pcsx2/SPU2/Dma.cpp +++ b/pcsx2/SPU2/Dma.cpp @@ -97,7 +97,7 @@ void V_Core::LogAutoDMA(FILE* fp) void V_Core::AutoDMAReadBuffer(int mode) //mode: 0= split stereo; 1 = do not split stereo { - int spos = ActiveTSA & 0x100;// ((InputPosRead + 0xff) & 0x100); //starting position of the free buffer + int spos = ActiveTSA & 0x100; // Starting position passed by TSA if (spos == (OutPos & 0x100)) return; @@ -173,9 +173,6 @@ void V_Core::StartADMAWrite(u16* pMem, u32 sz) AutoDMAReadBuffer(Index, 0); } #else - if (((PlayMode & 4) == 4) && (Index == 0)) - Cores[0].InputPosRead = 0; - AutoDMAReadBuffer(0); #endif diff --git a/pcsx2/SPU2/ReadInput.cpp b/pcsx2/SPU2/ReadInput.cpp index bdb5b2fe62..45b6d532bc 100644 --- a/pcsx2/SPU2/ReadInput.cpp +++ b/pcsx2/SPU2/ReadInput.cpp @@ -33,23 +33,10 @@ StereoOut32 V_Core::ReadInput_HiFi() { if (psxmode) ConLog("ReadInput_HiFi!!!!!\n"); - InputPosRead &= ~1; - // - //#ifdef PCM24_S1_INTERLEAVE - // StereoOut32 retval( - // *((s32*)(ADMATempBuffer+(InputPosRead<<1))), - // *((s32*)(ADMATempBuffer+(InputPosRead<<1)+2)) - // ); - //#else - // StereoOut32 retval( - // (s32&)(ADMATempBuffer[InputPosRead]), - // (s32&)(ADMATempBuffer[InputPosRead+0x200]) - // ); - //#endif StereoOut32 retval( - (s32&)(*GetMemPtr(0x2000 + (Index << 10) + InputPosRead)), - (s32&)(*GetMemPtr(0x2200 + (Index << 10) + InputPosRead))); + (s32&)(*GetMemPtr(0x2000 + (Index << 10) + OutPos)), + (s32&)(*GetMemPtr(0x2200 + (Index << 10) + OutPos))); if (Index == 1) { @@ -61,25 +48,19 @@ StereoOut32 V_Core::ReadInput_HiFi() retval.Right >>= 4; } - InputPosRead += 2; - // Why does CDDA mode check for InputPos == 0x100? In the old code, SPDIF mode did not but CDDA did. // One of these seems wrong, they should be the same. Since standard ADMA checks too I'm assuming that as default. -- air - if ((InputPosRead == 0x100) || (InputPosRead >= 0x200)) + if ((OutPos == 0xFF || OutPos == 0x1FF)) { - AdmaInProgress = 0; if (InputDataLeft >= 0x200) { -#ifdef PCM24_S1_INTERLEAVE - AutoDMAReadBuffer(1); -#else + int oldOutPos = OutPos; + OutPos = (OutPos + 1) & 0x1FF; AutoDMAReadBuffer(0); -#endif + OutPos = oldOutPos; AdmaInProgress = 1; - ActiveTSA = (Index << 10) + InputPosRead; - TSA = ActiveTSA; if (InputDataLeft < 0x200) { FileLog("[%10d] %s AutoDMA%c block end.\n", (Index == 1) ? "CDDA" : "SPDIF", Cycles, GetDmaIndexChar()); @@ -92,26 +73,12 @@ StereoOut32 V_Core::ReadInput_HiFi() ConLog("WARNING: adma buffer didn't finish with a whole block!!\n"); } } + AdmaInProgress = 0; InputDataLeft = 0; - // Hack, kinda. We call the interrupt early here, since PCSX2 doesn't like them delayed. - //DMAICounter = 1; - if (Index == 0) - { - if (!SPU2_dummy_callback) - spu2DMA4Irq(); - else - SPU2interruptDMA4(); - } - else - { - if (!SPU2_dummy_callback) - spu2DMA7Irq(); - else - SPU2interruptDMA7(); - } + DMAICounter = 0x200 * 4; + LastClock = *cyclePtr; } } - InputPosRead &= 0x1ff; } return retval; } @@ -126,22 +93,16 @@ StereoOut32 V_Core::ReadInput() if (Cores[i].IRQEnable && 0x2000 + (Index << 10) + OutPos == (Cores[i].IRQA & 0xfffffdff)) SetIrqCall(i); - //retval = StereoOut32( - // (s32)ADMATempBuffer[InputPosRead], - // (s32)ADMATempBuffer[InputPosRead+0x200] - //); retval = StereoOut32( (s32)(*GetMemPtr(0x2000 + (Index << 10) + OutPos)), (s32)(*GetMemPtr(0x2200 + (Index << 10) + OutPos))); } #ifdef PCSX2_DEVBUILD - DebugCores[Index].admaWaveformL[InputPosRead % 0x100] = retval.Left; - DebugCores[Index].admaWaveformR[InputPosRead % 0x100] = retval.Right; + DebugCores[Index].admaWaveformL[OutPos % 0x100] = retval.Left; + DebugCores[Index].admaWaveformR[OutPos % 0x100] = retval.Right; #endif - InputPosRead++; - if ((OutPos == 0xFF || OutPos == 0x1FF)) { if (InputDataLeft >= 0x200) @@ -173,6 +134,5 @@ StereoOut32 V_Core::ReadInput() } } } - InputPosRead &= 0x1ff; return retval; } diff --git a/pcsx2/SPU2/defs.h b/pcsx2/SPU2/defs.h index df6085fd96..3f43c98a99 100644 --- a/pcsx2/SPU2/defs.h +++ b/pcsx2/SPU2/defs.h @@ -406,7 +406,6 @@ struct V_Core s32 DMAICounter; // DMA Interrupt Counter u32 LastClock; // DMA Interrupt Clock Cycle Counter u32 InputDataLeft; // Input Buffer - u32 InputPosRead; u32 InputPosWrite; u32 InputDataProgress; diff --git a/pcsx2/SPU2/spu2sys.cpp b/pcsx2/SPU2/spu2sys.cpp index 095d7fc995..3f8f326df7 100644 --- a/pcsx2/SPU2/spu2sys.cpp +++ b/pcsx2/SPU2/spu2sys.cpp @@ -134,7 +134,6 @@ void V_Core::Init(int index) NoiseOut = 0; AutoDMACtrl = 0; InputDataLeft = 0; - InputPosRead = 0; InputPosWrite = 0; InputDataProgress = 0; ReverbX = 0; diff --git a/pcsx2/SaveState.h b/pcsx2/SaveState.h index 239c6f383c..be278e0e9b 100644 --- a/pcsx2/SaveState.h +++ b/pcsx2/SaveState.h @@ -24,7 +24,7 @@ // the lower 16 bit value. IF the change is breaking of all compatibility with old // states, increment the upper 16 bit value, and clear the lower 16 bits to 0. -static const u32 g_SaveVersion = (0x9A18 << 16) | 0x0000; +static const u32 g_SaveVersion = (0x9A19 << 16) | 0x0000; // this function is meant to be used in the place of GSfreeze, and provides a safe layer // between the GS saving function and the MTGS's needs. :)