From 03db2fcf4e82ace156577fbb7bf242357a7ee645 Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Sun, 1 Apr 2012 14:09:24 +0000 Subject: [PATCH] SPU2-X: Some games use volume slides combined with reversed phase. Gigaherz tweaked the code to handle this nicer (fixes Mashed Drive to Survive noises). git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5139 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/spu2-x/src/ADSR.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/plugins/spu2-x/src/ADSR.cpp b/plugins/spu2-x/src/ADSR.cpp index c4eb4b00da..0e902bd531 100644 --- a/plugins/spu2-x/src/ADSR.cpp +++ b/plugins/spu2-x/src/ADSR.cpp @@ -196,21 +196,23 @@ void V_VolumeSlide::Update() if( Increment == 0x7f ) return; + s32 value = abs(Value); + if (Mode & VOLFLAG_DECREMENT) { // Decrement if(Mode & VOLFLAG_EXPONENTIAL) { - u32 off = InvExpOffsets[(Value>>28)&7]; - Value -= PsxRates[(Increment^0x7f)-0x1b+off+32]; + u32 off = InvExpOffsets[(value>>28)&7]; + value -= PsxRates[(Increment^0x7f)-0x1b+off+32]; } else - Value -= PsxRates[(Increment^0x7f)-0xf+32]; + value -= PsxRates[(Increment^0x7f)-0xf+32]; - if (Value < 0) + if (value < 0) { - Value = 0; + value = 0; Mode = 0; // disable slide } } @@ -220,16 +222,18 @@ void V_VolumeSlide::Update() // Pseudo-exponential increments, as done by the SPU2 (really!) // Above 75% slides slow, below 75% slides fast. It's exponential, pseudo'ly speaking. - if( (Mode & VOLFLAG_EXPONENTIAL) && (Value>=0x60000000)) - Value += PsxRates[(Increment^0x7f)-0x18+32]; + if( (Mode & VOLFLAG_EXPONENTIAL) && (value>=0x60000000)) + value += PsxRates[(Increment^0x7f)-0x18+32]; else // linear / Pseudo below 75% (they're the same) - Value += PsxRates[(Increment^0x7f)-0x10+32]; + value += PsxRates[(Increment^0x7f)-0x10+32]; - if( Value < 0 ) // wrapped around the "top"? + if( value < 0 ) // wrapped around the "top"? { - Value = 0x7fffffff; + value = 0x7fffffff; Mode = 0; // disable slide } } + + Value = (Value < 0) ? -value : value; }