aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfsound
diff options
context:
space:
mode:
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;