From f5d89062e02933b5dc4e090ff7c7f4dc5368ef26 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Fri, 15 Jan 2021 20:53:04 +0000 Subject: [PATCH] SPU2: Update voices before DMA reads, reset OutPos on reset. Improves the booting reliability of GTA VC, especially on consecutive boots without closing the emulator. --- pcsx2/SPU2/spu2sys.cpp | 57 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/pcsx2/SPU2/spu2sys.cpp b/pcsx2/SPU2/spu2sys.cpp index 0b064fd6e0..1f8d91b211 100644 --- a/pcsx2/SPU2/spu2sys.cpp +++ b/pcsx2/SPU2/spu2sys.cpp @@ -145,6 +145,7 @@ void V_Core::Init(int index) MADR = 0; TADR = 0; KeyOn = 0; + OutPos = 0; psxmode = false; psxSoundDataTransferControl = 0; @@ -402,6 +403,34 @@ __forceinline void TimeUpdate(u32 cClocks) else TickInterval = 768; // Reset to default, in case the user hotswitched from async to something else. + //Update Mixing Progress + while (dClocks >= TickInterval) + { + for (int i = 0; i < 2; i++) + { + if (has_to_call_irq[i]) + { + //ConLog("* SPU2: Irq Called (%04x) at cycle %d.\n", Spdif.Info, Cycles); + has_to_call_irq[i] = false; + if (!(Spdif.Info & (4 << i)) && Cores[i].IRQEnable) + { + Spdif.Info |= (4 << i); + if (!SPU2_dummy_callback) + spu2Irq(); + } + } + } + + dClocks -= TickInterval; + lClocks += TickInterval; + Cycles++; + + // Note: IOP does not use MMX regs, so no need to save them. + //SaveMMXRegs(); + Mix(); + //RestoreMMXRegs(); + } + //Update DMA4 interrupt delay counter if (Cores[0].DMAICounter > 0 && (*cyclePtr - Cores[0].LastClock) > 0) { @@ -512,34 +541,6 @@ __forceinline void TimeUpdate(u32 cClocks) } } } - - //Update Mixing Progress - while (dClocks >= TickInterval) - { - for (int i = 0; i < 2; i++) - { - if (has_to_call_irq[i]) - { - //ConLog("* SPU2: Irq Called (%04x) at cycle %d.\n", Spdif.Info, Cycles); - has_to_call_irq[i] = false; - if (!(Spdif.Info & (4 << i)) && Cores[i].IRQEnable) - { - Spdif.Info |= (4 << i); - if (!SPU2_dummy_callback) - spu2Irq(); - } - } - } - - dClocks -= TickInterval; - lClocks += TickInterval; - Cycles++; - - // Note: IOP does not use MMX regs, so no need to save them. - //SaveMMXRegs(); - Mix(); - //RestoreMMXRegs(); - } } __forceinline void UpdateSpdifMode()