aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfsound
diff options
context:
space:
mode:
authornotaz2015-01-12 03:00:12 +0200
committernotaz2015-01-12 03:01:01 +0200
commitc632283d5c48d7731ec5704c3d5eef54951fec20 (patch)
tree10914a28dd37160b36cbe76d6efd7825ecb18150 /plugins/dfsound
parente541b8e06ff03a7fe7bd75b1bc0ad53f60b2d0de (diff)
downloadpcsx_rearmed-c632283d5c48d7731ec5704c3d5eef54951fec20.tar.gz
pcsx_rearmed-c632283d5c48d7731ec5704c3d5eef54951fec20.tar.bz2
pcsx_rearmed-c632283d5c48d7731ec5704c3d5eef54951fec20.zip
spu: fix some skip accuracy issues
Diffstat (limited to 'plugins/dfsound')
-rw-r--r--plugins/dfsound/adsr.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/plugins/dfsound/adsr.c b/plugins/dfsound/adsr.c
index 69e55bd..9e32862 100644
--- a/plugins/dfsound/adsr.c
+++ b/plugins/dfsound/adsr.c
@@ -221,6 +221,7 @@ static int SkipADSR(ADSRInfoEx *adsr, int ns_to)
{
int EnvelopeVol = adsr->EnvelopeVol;
int ns = 0, val, rto, level;
+ int64_t v64;
if (adsr->State == ADSR_RELEASE)
{
@@ -236,8 +237,10 @@ static int SkipADSR(ADSRInfoEx *adsr, int ns_to)
}
else
{
- EnvelopeVol += val * ns_to;
- if (EnvelopeVol > 0)
+ v64 = EnvelopeVol;
+ v64 += (int64_t)val * ns_to;
+ EnvelopeVol = (int)v64;
+ if (v64 > 0)
ns = ns_to;
}
goto done;
@@ -293,24 +296,21 @@ static int SkipADSR(ADSRInfoEx *adsr, int ns_to)
case ADSR_SUSTAIN: // -> sustain
if (adsr->SustainIncrease)
{
+ ns = ns_to;
+
if (EnvelopeVol >= 0x7fff0000)
- {
- ns = ns_to;
break;
- }
rto = 0;
if (adsr->SustainModeExp && EnvelopeVol >= 0x60000000)
rto = 8;
val = RateTableAdd[adsr->SustainRate + rto];
- EnvelopeVol += val * (ns_to - ns);
- if ((unsigned int)EnvelopeVol >= 0x7fe00000)
- {
+ v64 = EnvelopeVol;
+ v64 += (int64_t)val * (ns_to - ns);
+ EnvelopeVol = (int)v64;
+ if (v64 >= 0x7fe00000ll)
EnvelopeVol = 0x7fffffff;
- ns = ns_to;
- break;
- }
}
else
{
@@ -326,8 +326,10 @@ static int SkipADSR(ADSRInfoEx *adsr, int ns_to)
}
else
{
- EnvelopeVol += val * (ns_to - ns);
- if (EnvelopeVol > 0)
+ v64 = EnvelopeVol;
+ v64 += (int64_t)val * (ns_to - ns);
+ EnvelopeVol = (int)v64;
+ if (v64 > 0)
{
ns = ns_to;
break;