diff options
author | notaz | 2015-01-02 04:12:35 +0200 |
---|---|---|
committer | notaz | 2015-01-03 02:25:30 +0200 |
commit | 9ad8abfa940cd5c13eb0653639ea86736b65a2c4 (patch) | |
tree | 1dc8d9e0ceecf1087567839781cc2a06d4fa9e34 | |
parent | 4ccd0fb2874dab39c9db8ab973d4db9b8d54fa0d (diff) | |
download | pcsx_rearmed-9ad8abfa940cd5c13eb0653639ea86736b65a2c4.tar.gz pcsx_rearmed-9ad8abfa940cd5c13eb0653639ea86736b65a2c4.tar.bz2 pcsx_rearmed-9ad8abfa940cd5c13eb0653639ea86736b65a2c4.zip |
spu: get rid of bStop, clean up
-rw-r--r-- | plugins/dfsound/adsr.c | 46 | ||||
-rw-r--r-- | plugins/dfsound/externals.h | 10 | ||||
-rw-r--r-- | plugins/dfsound/freeze.c | 5 | ||||
-rw-r--r-- | plugins/dfsound/registers.c | 4 | ||||
-rw-r--r-- | plugins/dfsound/spu.c | 4 |
5 files changed, 36 insertions, 33 deletions
diff --git a/plugins/dfsound/adsr.c b/plugins/dfsound/adsr.c index 976315d..a86f461 100644 --- a/plugins/dfsound/adsr.c +++ b/plugins/dfsound/adsr.c @@ -57,22 +57,22 @@ void InitADSR(void) // INIT ADSR INLINE void StartADSR(int ch) // MIX ADSR
{
- s_chan[ch].ADSRX.State=0; // and init some adsr vars
+ s_chan[ch].ADSRX.State=ADSR_ATTACK; // and init some adsr vars
s_chan[ch].ADSRX.EnvelopeVol=0;
}
////////////////////////////////////////////////////////////////////////
-static int MixADSR(int ch, int ns_to) // MIX ADSR
+static int MixADSR(ADSRInfoEx *adsr, int ns_to)
{
- int EnvelopeVol = s_chan[ch].ADSRX.EnvelopeVol;
+ int EnvelopeVol = adsr->EnvelopeVol;
int ns = 0, val, rto, level;
- if (s_chan[ch].bStop) // should be stopped:
- { // do release
- val = RateTableSub[s_chan[ch].ADSRX.ReleaseRate * 4];
+ if (adsr->State == ADSR_RELEASE)
+ {
+ val = RateTableSub[adsr->ReleaseRate * 4];
- if (s_chan[ch].ADSRX.ReleaseModeExp)
+ if (adsr->ReleaseModeExp)
{
for (; ns < ns_to; ns++)
{
@@ -100,13 +100,13 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR goto done;
}
- switch (s_chan[ch].ADSRX.State)
+ switch (adsr->State)
{
- case 0: // -> attack
+ case ADSR_ATTACK: // -> attack
rto = 0;
- if (s_chan[ch].ADSRX.AttackModeExp && EnvelopeVol >= 0x60000000)
+ if (adsr->AttackModeExp && EnvelopeVol >= 0x60000000)
rto = 8;
- val = RateTableAdd[s_chan[ch].ADSRX.AttackRate + rto];
+ val = RateTableAdd[adsr->AttackRate + rto];
for (; ns < ns_to; ns++)
{
@@ -121,7 +121,7 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR if (EnvelopeVol < 0) // overflow
{
EnvelopeVol = 0x7fffffff;
- s_chan[ch].ADSRX.State = 1;
+ adsr->State = ADSR_DECAY;
ns++; // sample is good already
goto decay;
}
@@ -129,9 +129,9 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR //--------------------------------------------------//
decay:
- case 1: // -> decay
- val = RateTableSub[s_chan[ch].ADSRX.DecayRate * 4];
- level = s_chan[ch].ADSRX.SustainLevel;
+ case ADSR_DECAY: // -> decay
+ val = RateTableSub[adsr->DecayRate * 4];
+ level = adsr->SustainLevel;
for (; ns < ns_to; )
{
@@ -145,7 +145,7 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR if (((EnvelopeVol >> 27) & 0xf) <= level)
{
- s_chan[ch].ADSRX.State = 2;
+ adsr->State = ADSR_SUSTAIN;
goto sustain;
}
}
@@ -153,8 +153,8 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR //--------------------------------------------------//
sustain:
- case 2: // -> sustain
- if (s_chan[ch].ADSRX.SustainIncrease)
+ case ADSR_SUSTAIN: // -> sustain
+ if (adsr->SustainIncrease)
{
if (EnvelopeVol >= 0x7fff0000)
{
@@ -163,9 +163,9 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR }
rto = 0;
- if (s_chan[ch].ADSRX.SustainModeExp && EnvelopeVol >= 0x60000000)
+ if (adsr->SustainModeExp && EnvelopeVol >= 0x60000000)
rto = 8;
- val = RateTableAdd[s_chan[ch].ADSRX.SustainRate + rto];
+ val = RateTableAdd[adsr->SustainRate + rto];
for (; ns < ns_to; ns++)
{
@@ -183,8 +183,8 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR }
else
{
- val = RateTableSub[s_chan[ch].ADSRX.SustainRate];
- if (s_chan[ch].ADSRX.SustainModeExp)
+ val = RateTableSub[adsr->SustainRate];
+ if (adsr->SustainModeExp)
{
for (; ns < ns_to; ns++)
{
@@ -213,7 +213,7 @@ static int MixADSR(int ch, int ns_to) // MIX ADSR }
done:
- s_chan[ch].ADSRX.EnvelopeVol = EnvelopeVol;
+ adsr->EnvelopeVol = EnvelopeVol;
return ns;
}
diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 7935cb9..d1d081a 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -53,10 +53,17 @@ // struct defines
///////////////////////////////////////////////////////////
+enum ADSR_State {
+ ADSR_ATTACK = 0,
+ ADSR_DECAY = 1,
+ ADSR_SUSTAIN = 2,
+ ADSR_RELEASE = 3,
+};
+
// ADSR INFOS PER CHANNEL
typedef struct
{
- unsigned char State:2;
+ unsigned char State:2; // ADSR_State
unsigned char AttackModeExp:1;
unsigned char SustainModeExp:1;
unsigned char SustainIncrease:1;
@@ -93,7 +100,6 @@ typedef struct unsigned char * pCurr; // current pos in sound mem
unsigned char * pLoop; // loop ptr in sound mem
- unsigned int bStop:1; // is channel stopped (sample _can_ still be playing, ADSR Release phase)
unsigned int bReverb:1; // can we do reverb on this channel? must have ctrl register bit, to get active
unsigned int bRVBActive:1; // reverb active flag
unsigned int bNoise:1; // noise active flag
diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index d38faa6..be344ce 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -148,7 +148,7 @@ static void save_channel(SPUCHAN_orig *d, const SPUCHAN *s, int ch) d->iCurr = 0; // set by the caller
d->iLoop = 0; // set by the caller
d->bOn = !!(spu.dwChannelOn & (1<<ch));
- d->bStop = s->bStop;
+ d->bStop = s->ADSRX.State == ADSR_RELEASE;
d->bReverb = s->bReverb;
d->iActFreq = 1;
d->iUsedFreq = 2;
@@ -188,7 +188,6 @@ static void load_channel(SPUCHAN *d, const SPUCHAN_orig *s, int ch) memcpy(d->SB, s->SB, sizeof(d->SB));
d->pCurr = (void *)((long)s->iCurr & 0x7fff0);
d->pLoop = (void *)((long)s->iLoop & 0x7fff0);
- d->bStop = s->bStop;
d->bReverb = s->bReverb;
d->iLeftVolume = s->iLeftVolume;
d->iRightVolume = s->iRightVolume;
@@ -198,6 +197,7 @@ static void load_channel(SPUCHAN *d, const SPUCHAN_orig *s, int ch) d->bFMod = s->bFMod;
d->prevflags = (s->bIgnoreLoop >> 1) ^ 2;
d->ADSRX.State = s->ADSRX.State;
+ if (s->bStop) d->ADSRX.State = ADSR_RELEASE;
d->ADSRX.AttackModeExp = s->ADSRX.AttackModeExp;
d->ADSRX.AttackRate = s->ADSRX.AttackRate;
d->ADSRX.DecayRate = s->ADSRX.DecayRate;
@@ -349,7 +349,6 @@ void LoadStateUnknown(SPUFreeze_t * pF, uint32_t cycles) for(i=0;i<MAXCHAN;i++)
{
- s_chan[i].bStop=0;
s_chan[i].pLoop=spu.spuMemC;
}
diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index 8e4956e..bc99d9a 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -378,9 +378,9 @@ static void SoundOff(int start,int end,unsigned short val) int ch;
for(ch=start;ch<end;ch++,val>>=1) // loop channels
{
- if(val&1) // && s_chan[i].bOn) mmm...
+ if(val&1)
{
- s_chan[ch].bStop=1;
+ s_chan[ch].ADSRX.State = ADSR_RELEASE;
// Jungle Book - Rhythm 'n Groove
// - turns off buzzing sound (loop hangs)
diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 147db94..66ab150 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -238,7 +238,6 @@ INLINE void StartSound(int ch) StartADSR(ch); StartREVERB(ch); - s_chan[ch].bStop=0; s_chan[ch].prevflags=2; s_chan[ch].SB[26]=0; // init mixing vars @@ -765,10 +764,9 @@ static void do_channels(int ns_to) else d = do_samples_default(ch, ns_to); - d = MixADSR(ch, d); + d = MixADSR(&s_chan[ch].ADSRX, d); if (d < ns_to) { spu.dwChannelOn &= ~(1 << ch); - s_chan[ch].bStop = 1; s_chan[ch].ADSRX.EnvelopeVol = 0; memset(&ChanBuf[d], 0, (ns_to - d) * sizeof(ChanBuf[0])); } |