From 2daa7c1d0f27368d8f262b4c36e8e3294232d9ca Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 5 Sep 2022 00:40:58 +0300 Subject: [PATCH] spu: rename dwChannelOn to something more suitable --- plugins/dfsound/adsr.h | 24 ------------------------ plugins/dfsound/externals.h | 2 +- plugins/dfsound/freeze.c | 8 ++++---- plugins/dfsound/registers.c | 6 +++++- plugins/dfsound/spu.c | 20 +++++++++++--------- 5 files changed, 21 insertions(+), 39 deletions(-) delete mode 100644 plugins/dfsound/adsr.h diff --git a/plugins/dfsound/adsr.h b/plugins/dfsound/adsr.h deleted file mode 100644 index 2374f41a..00000000 --- a/plugins/dfsound/adsr.h +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** - adsr.h - description - ------------------- - begin : Wed May 15 2002 - copyright : (C) 2002 by Pete Bernert - email : BlackDove@addcom.de - ***************************************************************************/ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. See also the license.txt file for * - * additional informations. * - * * - ***************************************************************************/ - -#ifndef __P_ADER_H__ -#define __P_ADER_H__ - -INLINE void StartADSR(int ch); -INLINE int MixADSR(int ch); - -#endif /* __P_ADER_H__ */ diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 19cd9bae..5cd269e4 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -197,7 +197,7 @@ typedef struct unsigned int dwNoiseVal; // global noise generator unsigned int dwNoiseCount; unsigned int dwNewChannel; // flags for faster testing, if new channel starts - unsigned int dwChannelOn; // not silent channels + unsigned int dwChannelsAudible; // not silent channels unsigned int dwChannelDead; // silent+not useful channels unsigned char * pSpuBuffer; diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index 3bdbab1b..a9843aeb 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->iStart = (regAreaGet(ch,6)&~1)<<3; d->iCurr = 0; // set by the caller d->iLoop = 0; // set by the caller - d->bOn = !!(spu.dwChannelOn & (1<bOn = !!(spu.dwChannelsAudible & (1<bStop = s->ADSRX.State == ADSR_RELEASE; d->bReverb = s->bReverb; d->iActFreq = 1; @@ -209,7 +209,7 @@ static void load_channel(SPUCHAN *d, const SPUCHAN_orig *s, int ch) d->ADSRX.ReleaseModeExp = s->ADSRX.ReleaseModeExp; d->ADSRX.ReleaseRate = s->ADSRX.ReleaseRate; d->ADSRX.EnvelopeVol = s->ADSRX.EnvelopeVol; - if (s->bOn) spu.dwChannelOn |= 1<bOn) spu.dwChannelsAudible |= 1<ADSRX.EnvelopeVol = 0; } @@ -334,7 +334,7 @@ void LoadStateV5(SPUFreeze_t * pF) spu.decode_pos = pFO->decode_pos & 0x1ff; spu.dwNewChannel=0; - spu.dwChannelOn=0; + spu.dwChannelsAudible=0; spu.dwChannelDead=0; for(i=0;i>4)-0xc0; if(spu.dwNewChannel&(1<>16); @@ -488,6 +488,10 @@ static void SetPitch(int ch,unsigned short val) // SET PITCH spu.s_chan[ch].sinc = NP << 4; spu.s_chan[ch].sinc_inv = 0; spu.SB[ch * SB_SIZE + 32] = 1; // -> freq change in simple interpolation mode: set flag + if (val) + spu.dwChannelsAudible |= 1u << ch; + else + spu.dwChannelsAudible &= ~(1u << ch); } //////////////////////////////////////////////////////////////////////// diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 306c5f5f..e629ddba 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -250,8 +250,9 @@ static void StartSoundMain(int ch) s_chan->pCurr = spu.spuMemC+((regAreaGet(ch,6)&~1)<<3); spu.dwNewChannel&=~(1<iRawPitch) + spu.dwChannelsAudible|=1<>= 1) // loop em all... { if (!(mask & 1)) continue; // channel not playing? next @@ -800,7 +801,8 @@ static void do_channels(int ns_to) d = MixADSR(&s_chan->ADSRX, d); if (d < ns_to) { - spu.dwChannelOn &= ~(1 << ch); + spu.dwChannelsAudible &= ~(1 << ch); + s_chan->ADSRX.State = ADSR_RELEASE; s_chan->ADSRX.EnvelopeVol = 0; memset(&ChanBuf[d], 0, (ns_to - d) * sizeof(ChanBuf[0])); } @@ -937,7 +939,7 @@ static void queue_channel_work(int ns_to, unsigned int silentch) StartSoundMain(ch); } - mask = work->channels_on = spu.dwChannelOn & 0xffffff; + mask = work->channels_on = spu.dwChannelsAudible & 0xffffff; spu.decode_dirty_ch |= mask & 0x0a; for (ch = 0; mask != 0; ch++, mask >>= 1) @@ -962,7 +964,7 @@ static void queue_channel_work(int ns_to, unsigned int silentch) // note: d is not accurate on skip d = SkipADSR(&s_chan->ADSRX, d); if (d < ns_to) { - spu.dwChannelOn &= ~(1 << ch); + spu.dwChannelsAudible &= ~(1 << ch); s_chan->ADSRX.EnvelopeVol = 0; } } @@ -1105,7 +1107,7 @@ void do_samples(unsigned int cycles_to, int do_direct) return; } - silentch = ~(spu.dwChannelOn | spu.dwNewChannel) & 0xffffff; + silentch = ~(spu.dwChannelsAudible | spu.dwNewChannel) & 0xffffff; do_direct |= (silentch == 0xffffff); if (worker != NULL) @@ -1623,7 +1625,7 @@ void spu_get_debug_info(int *chans_out, int *run_chans, int *fmod_chans_out, int for(;ch