From a564d4bbae463deeed6277329a5b01b444a7f8a7 Mon Sep 17 00:00:00 2001 From: sudonim1 Date: Thu, 25 Feb 2010 07:04:28 +0000 Subject: [PATCH] Runaway voices should be faster with this. My previous ideas for optimising this were based on the principles that there's no way a game could rely on this feature other than requiring interrupts to fire when the muted voice hits the interrupt address. Well... Fatal Frame 2 proved me wrong. SPU2 interrupts aren't even enabled. I have no idea what it's doing. Rougher granularity than this probably doesn't break anything, this is the finest that should have observable effects. Not running voices when they're in a special sentinel block may also help games... but not Fatal Frame 2. It resets the loop register constantly. I really have no idea what it's playing at and it's driving me crazy. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2637 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/spu2-x/src/Mixer.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/spu2-x/src/Mixer.cpp b/plugins/spu2-x/src/Mixer.cpp index caf826eb29..a66dcedb4b 100644 --- a/plugins/spu2-x/src/Mixer.cpp +++ b/plugins/spu2-x/src/Mixer.cpp @@ -261,7 +261,8 @@ static __forceinline void __fastcall GetNextDataDummy(V_Core& thiscore, uint voi { V_Voice& vc( thiscore.Voices[voiceidx] ); - if( vc.SCurrent == 28 ) + // can also be 29 because it's left at 1 after the voice is stopped + if( vc.SCurrent >= 28 ) { if(vc.LoopFlags & XAFLAG_LOOP_END) { @@ -269,25 +270,22 @@ static __forceinline void __fastcall GetNextDataDummy(V_Core& thiscore, uint voi if( vc.LoopFlags & XAFLAG_LOOP ) vc.NextA = vc.LoopStartA; - else - vc.Stop(); + // no else, already stopped } vc.LoopFlags = *GetMemPtr(vc.NextA&0xFFFFF) >> 8; // grab loop flags from the upper byte. - vc.SCurrent = 0; if( (vc.LoopFlags & XAFLAG_LOOP_START) && !vc.LoopMode ) vc.LoopStartA = vc.NextA; - goto _Increment; + IncrementNextA(thiscore, vc); + + vc.SCurrent = 0; } - if( (vc.SCurrent&3) == 3 ) - { -_Increment: - IncrementNextA( thiscore, vc ); - } - vc.SCurrent++; + IncrementNextA(thiscore, vc); + + vc.SCurrent += 4; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -557,9 +555,10 @@ static __forceinline StereoOut32 MixVoice( uint coreidx, uint voiceidx ) { // Continue processing voice, even if it's "off". Or else we miss interrupts! (Fatal Frame engine died because of this.) UpdatePitch(coreidx, voiceidx); + while (vc.SP > 0) { GetNextDataDummy(thiscore, voiceidx); // Dummy is enough - vc.SP -= 4096; + vc.SP -= 16384; } // Write-back of raw voice data (some zeros since the voice is "dead")