SPU2: Adjust DMA timings for IRQ's and small packets

This also gets rid of a little kinda hack thing that was in there.
This commit is contained in:
refractionpcsx2 2021-08-31 11:45:46 +01:00
parent c93692a779
commit 4dc0db6ee6
2 changed files with 45 additions and 49 deletions

View File

@ -229,9 +229,6 @@ void V_Core::PlainDMAWrite(u16* pMem, u32 size)
Cores[Index].IRQEnable, Cores[Index].IRQA);
FinishDMAwrite();
if (ReadSize == 0) //DMA Finished right away so we need a DMAICounter size to trigger the interrupt
DMAICounter = size * 4;
}
void V_Core::FinishDMAwrite()
@ -241,6 +238,8 @@ void V_Core::FinishDMAwrite()
DMAPtr = (u16*)iopPhysMem(MADR);
}
DMAICounter = ReadSize;
if (Index == 0)
DMA4LogWrite(DMAPtr, ReadSize << 1);
else
@ -340,11 +339,8 @@ void V_Core::FinishDMAwrite()
DMAPtr += TDA - ActiveTSA;
ReadSize -= TDA - ActiveTSA;
if (ReadSize == 0)
DMAICounter = 0;
else
{
DMAICounter = std::min(ReadSize, (u32)0x100) * 4;
DMAICounter = (DMAICounter - ReadSize) * 4;
if (((psxCounters[6].sCycleT + psxCounters[6].CycleT) - psxRegs.cycle) > (u32)DMAICounter)
{
@ -356,7 +352,7 @@ void V_Core::FinishDMAwrite()
if (psxCounters[6].CycleT < psxNextCounter)
psxNextCounter = psxCounters[6].CycleT;
}
}
ActiveTSA = TDA;
ActiveTSA &= 0xfffff;
TSA = ActiveTSA;
@ -367,6 +363,7 @@ void V_Core::FinishDMAread()
u32 buff1end = ActiveTSA + std::min(ReadSize, (u32)0x100 + std::abs(DMAICounter / 4));
u32 start = ActiveTSA;
u32 buff2end = 0;
if (buff1end > 0x100000)
{
buff2end = buff1end - 0x100000;
@ -433,14 +430,12 @@ void V_Core::FinishDMAread()
DMARPtr += TDA - ActiveTSA;
ReadSize -= TDA - ActiveTSA;
if (ReadSize == 0)
{
IsDMARead = false;
DMAICounter = 0;
}
else
{
// DMA Reads are done AFTER the delay, so to get the timing right we need to scheule one last DMA to catch IRQ's
if (ReadSize)
DMAICounter = std::min(ReadSize, (u32)0x100) * 4;
else
DMAICounter = 4;
if (((psxCounters[6].sCycleT + psxCounters[6].CycleT) - psxRegs.cycle) > (u32)DMAICounter)
{
@ -452,7 +447,7 @@ void V_Core::FinishDMAread()
if (psxCounters[6].CycleT < psxNextCounter)
psxNextCounter = psxCounters[6].CycleT;
}
}
ActiveTSA = TDA;
ActiveTSA &= 0xfffff;
TSA = ActiveTSA;

View File

@ -463,14 +463,6 @@ __forceinline void TimeUpdate(u32 cClocks)
if (Cores[0].DMAICounter <= 0)
{
if (((Cores[0].AutoDMACtrl & 1) != 1) && Cores[0].ReadSize)
{
if (Cores[0].IsDMARead)
Cores[0].FinishDMAread();
else
Cores[0].FinishDMAwrite();
}
for (int i = 0; i < 2; i++)
{
if (has_to_call_irq_dma[i])
@ -484,6 +476,15 @@ __forceinline void TimeUpdate(u32 cClocks)
}
}
}
if (((Cores[0].AutoDMACtrl & 1) != 1) && Cores[0].ReadSize)
{
if (Cores[0].IsDMARead)
Cores[0].FinishDMAread();
else
Cores[0].FinishDMAwrite();
}
if (Cores[0].DMAICounter <= 0)
{
HW_DMA4_MADR = HW_DMA4_TADR;
@ -515,14 +516,6 @@ __forceinline void TimeUpdate(u32 cClocks)
HW_DMA7_MADR += amt / 2;
if (Cores[1].DMAICounter <= 0)
{
if (((Cores[1].AutoDMACtrl & 2) != 2) && Cores[1].ReadSize)
{
if (Cores[1].IsDMARead)
Cores[1].FinishDMAread();
else
Cores[1].FinishDMAwrite();
}
for (int i = 0; i < 2; i++)
{
if (has_to_call_irq_dma[i])
@ -537,6 +530,14 @@ __forceinline void TimeUpdate(u32 cClocks)
}
}
if (((Cores[1].AutoDMACtrl & 2) != 2) && Cores[1].ReadSize)
{
if (Cores[1].IsDMARead)
Cores[1].FinishDMAread();
else
Cores[1].FinishDMAwrite();
}
if (Cores[1].DMAICounter <= 0)
{
HW_DMA7_MADR = HW_DMA7_TADR;