SPU2: Change input area updates for Hifi reads

Remove the no longer required InputPosRead
Bump Savestates
This commit is contained in:
refractionpcsx2 2021-01-23 06:50:14 +00:00
parent 4497532edb
commit 7c37e86283
5 changed files with 13 additions and 58 deletions

View File

@ -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 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)) if (spos == (OutPos & 0x100))
return; return;
@ -173,9 +173,6 @@ void V_Core::StartADMAWrite(u16* pMem, u32 sz)
AutoDMAReadBuffer(Index, 0); AutoDMAReadBuffer(Index, 0);
} }
#else #else
if (((PlayMode & 4) == 4) && (Index == 0))
Cores[0].InputPosRead = 0;
AutoDMAReadBuffer(0); AutoDMAReadBuffer(0);
#endif #endif

View File

@ -33,23 +33,10 @@ StereoOut32 V_Core::ReadInput_HiFi()
{ {
if (psxmode) if (psxmode)
ConLog("ReadInput_HiFi!!!!!\n"); 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( StereoOut32 retval(
(s32&)(*GetMemPtr(0x2000 + (Index << 10) + InputPosRead)), (s32&)(*GetMemPtr(0x2000 + (Index << 10) + OutPos)),
(s32&)(*GetMemPtr(0x2200 + (Index << 10) + InputPosRead))); (s32&)(*GetMemPtr(0x2200 + (Index << 10) + OutPos)));
if (Index == 1) if (Index == 1)
{ {
@ -61,25 +48,19 @@ StereoOut32 V_Core::ReadInput_HiFi()
retval.Right >>= 4; retval.Right >>= 4;
} }
InputPosRead += 2;
// Why does CDDA mode check for InputPos == 0x100? In the old code, SPDIF mode did not but CDDA did. // 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 // 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) if (InputDataLeft >= 0x200)
{ {
#ifdef PCM24_S1_INTERLEAVE int oldOutPos = OutPos;
AutoDMAReadBuffer(1); OutPos = (OutPos + 1) & 0x1FF;
#else
AutoDMAReadBuffer(0); AutoDMAReadBuffer(0);
#endif OutPos = oldOutPos;
AdmaInProgress = 1; AdmaInProgress = 1;
ActiveTSA = (Index << 10) + InputPosRead;
TSA = ActiveTSA;
if (InputDataLeft < 0x200) if (InputDataLeft < 0x200)
{ {
FileLog("[%10d] %s AutoDMA%c block end.\n", (Index == 1) ? "CDDA" : "SPDIF", Cycles, GetDmaIndexChar()); 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"); ConLog("WARNING: adma buffer didn't finish with a whole block!!\n");
} }
} }
AdmaInProgress = 0;
InputDataLeft = 0; InputDataLeft = 0;
// Hack, kinda. We call the interrupt early here, since PCSX2 doesn't like them delayed. DMAICounter = 0x200 * 4;
//DMAICounter = 1; LastClock = *cyclePtr;
if (Index == 0)
{
if (!SPU2_dummy_callback)
spu2DMA4Irq();
else
SPU2interruptDMA4();
}
else
{
if (!SPU2_dummy_callback)
spu2DMA7Irq();
else
SPU2interruptDMA7();
}
} }
} }
InputPosRead &= 0x1ff;
} }
return retval; return retval;
} }
@ -126,22 +93,16 @@ StereoOut32 V_Core::ReadInput()
if (Cores[i].IRQEnable && 0x2000 + (Index << 10) + OutPos == (Cores[i].IRQA & 0xfffffdff)) if (Cores[i].IRQEnable && 0x2000 + (Index << 10) + OutPos == (Cores[i].IRQA & 0xfffffdff))
SetIrqCall(i); SetIrqCall(i);
//retval = StereoOut32(
// (s32)ADMATempBuffer[InputPosRead],
// (s32)ADMATempBuffer[InputPosRead+0x200]
//);
retval = StereoOut32( retval = StereoOut32(
(s32)(*GetMemPtr(0x2000 + (Index << 10) + OutPos)), (s32)(*GetMemPtr(0x2000 + (Index << 10) + OutPos)),
(s32)(*GetMemPtr(0x2200 + (Index << 10) + OutPos))); (s32)(*GetMemPtr(0x2200 + (Index << 10) + OutPos)));
} }
#ifdef PCSX2_DEVBUILD #ifdef PCSX2_DEVBUILD
DebugCores[Index].admaWaveformL[InputPosRead % 0x100] = retval.Left; DebugCores[Index].admaWaveformL[OutPos % 0x100] = retval.Left;
DebugCores[Index].admaWaveformR[InputPosRead % 0x100] = retval.Right; DebugCores[Index].admaWaveformR[OutPos % 0x100] = retval.Right;
#endif #endif
InputPosRead++;
if ((OutPos == 0xFF || OutPos == 0x1FF)) if ((OutPos == 0xFF || OutPos == 0x1FF))
{ {
if (InputDataLeft >= 0x200) if (InputDataLeft >= 0x200)
@ -173,6 +134,5 @@ StereoOut32 V_Core::ReadInput()
} }
} }
} }
InputPosRead &= 0x1ff;
return retval; return retval;
} }

View File

@ -406,7 +406,6 @@ struct V_Core
s32 DMAICounter; // DMA Interrupt Counter s32 DMAICounter; // DMA Interrupt Counter
u32 LastClock; // DMA Interrupt Clock Cycle Counter u32 LastClock; // DMA Interrupt Clock Cycle Counter
u32 InputDataLeft; // Input Buffer u32 InputDataLeft; // Input Buffer
u32 InputPosRead;
u32 InputPosWrite; u32 InputPosWrite;
u32 InputDataProgress; u32 InputDataProgress;

View File

@ -134,7 +134,6 @@ void V_Core::Init(int index)
NoiseOut = 0; NoiseOut = 0;
AutoDMACtrl = 0; AutoDMACtrl = 0;
InputDataLeft = 0; InputDataLeft = 0;
InputPosRead = 0;
InputPosWrite = 0; InputPosWrite = 0;
InputDataProgress = 0; InputDataProgress = 0;
ReverbX = 0; ReverbX = 0;

View File

@ -24,7 +24,7 @@
// the lower 16 bit value. IF the change is breaking of all compatibility with old // 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. // 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 // 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. :) // between the GS saving function and the MTGS's needs. :)