From 6d866bb7894b252fc430a24a97769511d5ead1ca Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 28 Feb 2011 00:19:48 +0200 Subject: [PATCH] spu: compact chan structure a bit --- Makefile | 6 +- plugins/dfsound/adsr.c | 15 ++-- plugins/dfsound/externals.h | 59 ++++++------- plugins/dfsound/freeze.c | 164 +++++++++++++++++++++++++++++++++--- plugins/dfsound/registers.c | 40 +++------ plugins/dfsound/reverb.c | 10 +-- plugins/dfsound/reverb.h | 2 - plugins/dfsound/spu.c | 42 ++++----- plugins/dfsound/stdafx.h | 2 +- 9 files changed, 224 insertions(+), 116 deletions(-) diff --git a/Makefile b/Makefile index 95bc0f29..f6d3470e 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,9 @@ endif # spu OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \ plugins/dfsound/registers.o plugins/dfsound/spu.o -plugins/dfsound/spu.o: plugins/dfsound/xa.c +plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \ + plugins/dfsound/xa.c +plugins/dfsound/%.o: CFLAGS += -Wall ifeq "$(USE_OSS)" "1" plugins/dfsound/%.o: CFLAGS += -DUSEOSS OBJS += plugins/dfsound/oss.o @@ -66,6 +68,8 @@ endif # gpu plugins/dfxvideo/%.o: CFLAGS += -Wall OBJS += plugins/dfxvideo/gpu.o +plugins/dfxvideo/gpu.o: plugins/dfxvideo/fps.c plugins/dfxvideo/prim.c \ + plugins/dfxvideo/gpu.c plugins/dfxvideo/soft.c ifdef X11 LDFLAGS += -lX11 -lXv OBJS += plugins/dfxvideo/draw.o diff --git a/plugins/dfsound/adsr.c b/plugins/dfsound/adsr.c index 387a83b2..1e397af7 100644 --- a/plugins/dfsound/adsr.c +++ b/plugins/dfsound/adsr.c @@ -53,8 +53,7 @@ void InitADSR(void) // INIT ADSR INLINE void StartADSR(int ch) // MIX ADSR { - s_chan[ch].ADSRX.lVolume=1; // and init some adsr vars - s_chan[ch].ADSRX.State=0; + s_chan[ch].ADSRX.State=0; // and init some adsr vars s_chan[ch].ADSRX.EnvelopeVol=0; } @@ -94,8 +93,7 @@ INLINE int MixADSR(int ch) // MIX ADSR //s_chan[ch].bNoise=0; } - s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21; - return s_chan[ch].ADSRX.lVolume; + return s_chan[ch].ADSRX.EnvelopeVol>>21; } else // not stopped yet? { @@ -119,8 +117,7 @@ INLINE int MixADSR(int ch) // MIX ADSR s_chan[ch].ADSRX.State=1; } - s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21; - return s_chan[ch].ADSRX.lVolume; + return s_chan[ch].ADSRX.EnvelopeVol>>21; } //--------------------------------------------------// if(s_chan[ch].ADSRX.State==1) // -> decay @@ -143,8 +140,7 @@ INLINE int MixADSR(int ch) // MIX ADSR s_chan[ch].ADSRX.State=2; } - s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21; - return s_chan[ch].ADSRX.lVolume; + return s_chan[ch].ADSRX.EnvelopeVol>>21; } //--------------------------------------------------// if(s_chan[ch].ADSRX.State==2) // -> sustain @@ -194,8 +190,7 @@ INLINE int MixADSR(int ch) // MIX ADSR s_chan[ch].ADSRX.EnvelopeVol=0; } } - s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21; - return s_chan[ch].ADSRX.lVolume; + return s_chan[ch].ADSRX.EnvelopeVol>>21; } } return 0; diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index f8562046..92683a95 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -72,20 +72,17 @@ typedef struct typedef struct { - int State; - int AttackModeExp; - int AttackRate; - int DecayRate; - int SustainLevel; - int SustainModeExp; - int SustainIncrease; - int SustainRate; - int ReleaseModeExp; - int ReleaseRate; + unsigned char State:2; + unsigned char AttackModeExp:1; + unsigned char SustainModeExp:1; + unsigned char SustainIncrease:1; + unsigned char ReleaseModeExp:1; + unsigned char AttackRate; + unsigned char DecayRate; + unsigned char SustainLevel; + unsigned char SustainRate; + unsigned char ReleaseRate; int EnvelopeVol; - long lVolume; - long lDummy1; - long lDummy2; } ADSRInfoEx; /////////////////////////////////////////////////////////// @@ -104,45 +101,36 @@ typedef struct // MAIN CHANNEL STRUCT typedef struct { - // no mutexes used anymore... don't need them to sync access - //HANDLE hMutex; - - int bNew; // start flag - int iSBPos; // mixing stuff int spos; int sinc; - int SB[32+32]; // Pete added another 32 dwords in 1.6 ... prevents overflow issues with gaussian/cubic interpolation (thanx xodnizel!), and can be used for even better interpolations, eh? :) - int sval; unsigned char * pStart; // start ptr into sound mem unsigned char * pCurr; // current pos in sound mem unsigned char * pLoop; // loop ptr in sound mem - int bOn; // is channel active (sample playing?) - int bStop; // is channel stopped (sample _can_ still be playing, ADSR Release phase) - int bReverb; // can we do reverb on this channel? must have ctrl register bit, to get active + 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 bIgnoreLoop:1; // ignore loop bit, if an external loop address is used + unsigned int bRVBActive:1; // reverb active flag + unsigned int bNoise:1; // noise active flag + unsigned int bFMod:2; // freq mod (0=off, 1=sound channel, 2=freq channel) + int iActFreq; // current psx pitch int iUsedFreq; // current pc pitch int iLeftVolume; // left volume - int iLeftVolRaw; // left psx volume value - int bIgnoreLoop; // ignore loop bit, if an external loop address is used - int iMute; // mute mode int iRightVolume; // right volume - int iRightVolRaw; // right psx volume value - int iRawPitch; // raw pitch (0...3fff) - int iIrqDone; // debug irq done flag int s_1; // last decoding infos int s_2; - int bRVBActive; // reverb active flag + ADSRInfoEx ADSRX; + int iRawPitch; // raw pitch (0...3fff) + int iRVBOffset; // reverb offset int iRVBRepeat; // reverb repeat - int bNoise; // noise active flag - int bFMod; // freq mod (0=off, 1=sound channel, 2=freq channel) int iRVBNum; // another reverb helper int iOldNoise; // old noise val for this channel - ADSRInfo ADSR; // active ADSR settings - ADSRInfoEx ADSRX; // next ADSR settings (will be moved to active on sample start) + + int SB[32+32]; } SPUCHAN; /////////////////////////////////////////////////////////// @@ -233,7 +221,8 @@ extern unsigned long spuAddr; extern int bEndThread; extern int bThreadEnded; extern int bSpuInit; -extern unsigned long dwNewChannel; +extern unsigned int dwNewChannel; +extern unsigned int dwChannelOn; extern int SSumR[]; extern int SSumL[]; diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index 12fdc1fd..cb0d75ec 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -28,6 +28,67 @@ // freeze structs //////////////////////////////////////////////////////////////////////// +typedef struct +{ + int State; + int AttackModeExp; + int AttackRate; + int DecayRate; + int SustainLevel; + int SustainModeExp; + int SustainIncrease; + int SustainRate; + int ReleaseModeExp; + int ReleaseRate; + int EnvelopeVol; + long lVolume; + long lDummy1; + long lDummy2; +} ADSRInfoEx_orig; + +typedef struct +{ + // no mutexes used anymore... don't need them to sync access + //HANDLE hMutex; + + int bNew; // start flag + + int iSBPos; // mixing stuff + int spos; + int sinc; + int SB[32+32]; // Pete added another 32 dwords in 1.6 ... prevents overflow issues with gaussian/cubic interpolation (thanx xodnizel!), and can be used for even better interpolations, eh? :) + int sval; + + unsigned char * pStart; // start ptr into sound mem + unsigned char * pCurr; // current pos in sound mem + unsigned char * pLoop; // loop ptr in sound mem + + int bOn; // is channel active (sample playing?) + int bStop; // is channel stopped (sample _can_ still be playing, ADSR Release phase) + int bReverb; // can we do reverb on this channel? must have ctrl register bit, to get active + int iActFreq; // current psx pitch + int iUsedFreq; // current pc pitch + int iLeftVolume; // left volume + int iLeftVolRaw; // left psx volume value + int bIgnoreLoop; // ignore loop bit, if an external loop address is used + int iMute; // mute mode + int iRightVolume; // right volume + int iRightVolRaw; // right psx volume value + int iRawPitch; // raw pitch (0...3fff) + int iIrqDone; // debug irq done flag + int s_1; // last decoding infos + int s_2; + int bRVBActive; // reverb active flag + int iRVBOffset; // reverb offset + int iRVBRepeat; // reverb repeat + int bNoise; // noise active flag + int bFMod; // freq mod (0=off, 1=sound channel, 2=freq channel) + int iRVBNum; // another reverb helper + int iOldNoise; // old noise val for this channel + ADSRInfo ADSR; // active ADSR settings + ADSRInfoEx_orig ADSRX; // next ADSR settings (will be moved to active on sample start) +} SPUCHAN_orig; + typedef struct { char szSPUName[8]; @@ -47,7 +108,7 @@ typedef struct uint32_t dummy2; uint32_t dummy3; - SPUCHAN s_chan[MAXCHAN]; + SPUCHAN_orig s_chan[MAXCHAN]; } SPUOSSFreeze_t; @@ -58,6 +119,93 @@ void LoadStateUnknown(SPUFreeze_t * pF); // unknown format extern int lastch; +// we want to retain compatibility between versions, +// so use original channel struct +static void save_channel(SPUCHAN_orig *d, SPUCHAN *s, int ch) +{ + memset(d, 0, sizeof(*d)); + d->bNew = !!(dwNewChannel & (1<iSBPos = s->iSBPos; + d->spos = s->spos; + d->sinc = s->sinc; + memcpy(d->SB, s->SB, sizeof(d->SB)); + d->pStart = s->pStart; + d->pCurr = s->pCurr; + d->pLoop = s->pLoop; + d->bOn = !!(dwChannelOn & (1<bStop = s->bStop; + d->bReverb = s->bReverb; + d->iActFreq = s->iActFreq; + d->iUsedFreq = s->iUsedFreq; + d->iLeftVolume = s->iLeftVolume; + d->bIgnoreLoop = s->bIgnoreLoop; + d->iRightVolume = s->iRightVolume; + d->iRawPitch = s->iRawPitch; + d->s_1 = s->s_1; + d->s_2 = s->s_2; + d->bRVBActive = s->bRVBActive; + d->iRVBOffset = s->iRVBOffset; + d->iRVBRepeat = s->iRVBRepeat; + d->bNoise = s->bNoise; + d->bFMod = s->bFMod; + d->iRVBNum = s->iRVBNum; + d->iOldNoise = s->iOldNoise; + d->ADSRX.State = s->ADSRX.State; + d->ADSRX.AttackModeExp = s->ADSRX.AttackModeExp; + d->ADSRX.AttackRate = s->ADSRX.AttackRate; + d->ADSRX.DecayRate = s->ADSRX.DecayRate; + d->ADSRX.SustainLevel = s->ADSRX.SustainLevel; + d->ADSRX.SustainModeExp = s->ADSRX.SustainModeExp; + d->ADSRX.SustainIncrease = s->ADSRX.SustainIncrease; + d->ADSRX.SustainRate = s->ADSRX.SustainRate; + d->ADSRX.ReleaseModeExp = s->ADSRX.ReleaseModeExp; + d->ADSRX.ReleaseRate = s->ADSRX.ReleaseRate; + d->ADSRX.EnvelopeVol = s->ADSRX.EnvelopeVol; + d->ADSRX.lVolume = d->bOn; // hmh +} + +static void load_channel(SPUCHAN *d, SPUCHAN_orig *s, int ch) +{ + memset(d, 0, sizeof(*d)); + if (s->bNew) dwNewChannel |= 1<iSBPos = s->iSBPos; + d->spos = s->spos; + d->sinc = s->sinc; + memcpy(d->SB, s->SB, sizeof(d->SB)); + d->pStart = s->pStart; + d->pCurr = s->pCurr; + d->pLoop = s->pLoop; + if (s->bOn) dwChannelOn |= 1<bStop = s->bStop; + d->bReverb = s->bReverb; + d->iActFreq = s->iActFreq; + d->iUsedFreq = s->iUsedFreq; + d->iLeftVolume = s->iLeftVolume; + d->bIgnoreLoop = s->bIgnoreLoop; + d->iRightVolume = s->iRightVolume; + d->iRawPitch = s->iRawPitch; + d->s_1 = s->s_1; + d->s_2 = s->s_2; + d->bRVBActive = s->bRVBActive; + d->iRVBOffset = s->iRVBOffset; + d->iRVBRepeat = s->iRVBRepeat; + d->bNoise = s->bNoise; + d->bFMod = s->bFMod; + d->iRVBNum = s->iRVBNum; + d->iOldNoise = s->iOldNoise; + d->ADSRX.State = s->ADSRX.State; + d->ADSRX.AttackModeExp = s->ADSRX.AttackModeExp; + d->ADSRX.AttackRate = s->ADSRX.AttackRate; + d->ADSRX.DecayRate = s->ADSRX.DecayRate; + d->ADSRX.SustainLevel = s->ADSRX.SustainLevel; + d->ADSRX.SustainModeExp = s->ADSRX.SustainModeExp; + d->ADSRX.SustainIncrease = s->ADSRX.SustainIncrease; + d->ADSRX.SustainRate = s->ADSRX.SustainRate; + d->ADSRX.ReleaseModeExp = s->ADSRX.ReleaseModeExp; + d->ADSRX.ReleaseRate = s->ADSRX.ReleaseRate; + d->ADSRX.EnvelopeVol = s->ADSRX.EnvelopeVol; +} + //////////////////////////////////////////////////////////////////////// // SPUFREEZE: called by main emu on savestate load/save //////////////////////////////////////////////////////////////////////// @@ -101,7 +249,7 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) for(i=0;is_chan[i],(void *)&s_chan[i],sizeof(SPUCHAN)); + save_channel(&pFO->s_chan[i],&s_chan[i],i); if(pFO->s_chan[i].pStart) pFO->s_chan[i].pStart-=(unsigned long)spuMemC; if(pFO->s_chan[i].pCurr) @@ -171,15 +319,15 @@ void LoadStateV5(SPUFreeze_t * pF) if (spuAddr == 0xbaadf00d) spuAddr = 0; } + dwNewChannel=0; + dwChannelOn=0; for(i=0;is_chan[i],sizeof(SPUCHAN)); + load_channel(&s_chan[i],&pFO->s_chan[i],i); s_chan[i].pStart+=(unsigned long)spuMemC; s_chan[i].pCurr+=(unsigned long)spuMemC; s_chan[i].pLoop+=(unsigned long)spuMemC; - s_chan[i].iMute=0; - s_chan[i].iIrqDone=0; } } @@ -191,18 +339,14 @@ void LoadStateUnknown(SPUFreeze_t * pF) for(i=0;i>8) & 0x007f; s_chan[ch].ADSRX.DecayRate=(lval>>4) & 0x000f; s_chan[ch].ADSRX.SustainLevel=lval & 0x000f; //---------------------------------------------// +#if 0 if(!iDebugMode) break; //---------------------------------------------// stuff below is only for debug mode @@ -110,12 +111,13 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) } s_chan[ch].ADSR.DecayTime = // so calc how long does it take to run from 100% to the wanted sus level (lx*(1024-s_chan[ch].ADSR.SustainLevel))/1024; +#endif } break; //------------------------------------------------// adsr times with pre-calcs case 10: { - const unsigned long lval=val;unsigned long lx; + const unsigned long lval=val; //----------------------------------------------// s_chan[ch].ADSRX.SustainModeExp = (lval&0x8000)?1:0; @@ -124,6 +126,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) s_chan[ch].ADSRX.ReleaseModeExp = (lval&0x0020)?1:0; s_chan[ch].ADSRX.ReleaseRate = lval & 0x001f; //----------------------------------------------// +#if 0 if(!iDebugMode) break; //----------------------------------------------// stuff below is only for debug mode @@ -155,6 +158,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) if(lval & 0x4000) // add/dec flag s_chan[ch].ADSR.SustainModeDec=-1; else s_chan[ch].ADSR.SustainModeDec=1; +#endif } break; //------------------------------------------------// adsr volume... mmm have to investigate this @@ -362,9 +366,9 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg) case 12: // get adsr vol { const int ch=(r>>4)-0xc0; - if(s_chan[ch].bNew) return 1; // we are started, but not processed? return 1 - if(s_chan[ch].ADSRX.lVolume && // same here... we haven't decoded one sample yet, so no envelope yet. return 1 as well - !s_chan[ch].ADSRX.EnvelopeVol) + if(dwNewChannel&(1<>16); } @@ -424,15 +428,14 @@ void SoundOn(int start,int end,unsigned short val) // SOUND ON PSX COMAND if((val&1) && s_chan[ch].pStart) // mmm... start has to be set before key on !?! { s_chan[ch].bIgnoreLoop=0; - s_chan[ch].bNew=1; // do this here, not in StartSound // - fixes fussy timing issues s_chan[ch].bStop=0; - s_chan[ch].bOn=1; s_chan[ch].pCurr=s_chan[ch].pStart; dwNewChannel|=(1<>=1) // loop channels { - if(val&1) // -> noise on/off - { - s_chan[ch].bNoise=1; - } - else - { - s_chan[ch].bNoise=0; - } + s_chan[ch].bNoise=val&1; // -> noise on/off } } @@ -513,8 +508,6 @@ void NoiseOn(int start,int end,unsigned short val) // NOISE ON PSX COMMAND void SetVolumeL(unsigned char ch,short vol) // LEFT VOLUME { - s_chan[ch].iLeftVolRaw=vol; - if(vol&0x8000) // sweep? { short sInc=1; // -> sweep up? @@ -541,8 +534,6 @@ void SetVolumeL(unsigned char ch,short vol) // LEFT VOLUME void SetVolumeR(unsigned char ch,short vol) // RIGHT VOLUME { - s_chan[ch].iRightVolRaw=vol; - if(vol&0x8000) // comments... see above :) { short sInc=1; @@ -590,13 +581,6 @@ void ReverbOn(int start,int end,unsigned short val) // REVERB ON PSX COMMAND for(ch=start;ch>=1) // loop channels { - if(val&1) // -> reverb on/off - { - s_chan[ch].bReverb=1; - } - else - { - s_chan[ch].bReverb=0; - } + s_chan[ch].bReverb=val&1; // -> reverb on/off } } diff --git a/plugins/dfsound/reverb.c b/plugins/dfsound/reverb.c index 92e31fcb..343c979d 100644 --- a/plugins/dfsound/reverb.c +++ b/plugins/dfsound/reverb.c @@ -93,14 +93,14 @@ INLINE void InitREVERB(void) // STORE REVERB //////////////////////////////////////////////////////////////////////// -INLINE void StoreREVERB(int ch,int ns) +INLINE void StoreREVERB(int ch,int ns,int sval) { if(iUseReverb==0) return; else if(iUseReverb==2) // -------------------------------- // Neil's reverb { - const int iRxl=(s_chan[ch].sval*s_chan[ch].iLeftVolume)/0x4000; - const int iRxr=(s_chan[ch].sval*s_chan[ch].iRightVolume)/0x4000; + const int iRxl=(sval*s_chan[ch].iLeftVolume)/0x4000; + const int iRxr=(sval*s_chan[ch].iRightVolume)/0x4000; ns<<=1; @@ -113,8 +113,8 @@ INLINE void StoreREVERB(int ch,int ns) // we use the half channel volume (/0x8000) for the first reverb effects, quarter for next and so on - int iRxl=(s_chan[ch].sval*s_chan[ch].iLeftVolume)/0x8000; - int iRxr=(s_chan[ch].sval*s_chan[ch].iRightVolume)/0x8000; + int iRxl=(sval*s_chan[ch].iLeftVolume)/0x8000; + int iRxr=(sval*s_chan[ch].iRightVolume)/0x8000; for(iRn=1;iRn<=s_chan[ch].iRVBNum;iRn++,iRr+=s_chan[ch].iRVBRepeat,iRxl/=2,iRxr/=2) { diff --git a/plugins/dfsound/reverb.h b/plugins/dfsound/reverb.h index ce618187..f7e9aa27 100644 --- a/plugins/dfsound/reverb.h +++ b/plugins/dfsound/reverb.h @@ -16,6 +16,4 @@ ***************************************************************************/ void SetREVERB(unsigned short val); -INLINE void StartREVERB(int ch); -INLINE void StoreREVERB(int ch,int ns); diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index afd5fd6c..ca0b97b9 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -34,6 +34,7 @@ #define N_(x) (x) #endif +/* #if defined (USEMACOSX) static char * libraryName = N_("Mac OS X Sound"); #elif defined (USEALSA) @@ -49,6 +50,7 @@ static char * libraryName = N_("NULL Sound"); #endif static char * libraryInfo = N_("P.E.Op.S. Sound Driver V1.7\nCoded by Pete Bernert and the P.E.Op.S. team\n"); +*/ // globals @@ -93,13 +95,14 @@ int bSPUIsOpen=0; static pthread_t thread = (pthread_t)-1; // thread id (linux) unsigned long dwNewChannel=0; // flags for faster testing, if new channel starts +unsigned long dwChannelOn=0; void (CALLBACK *irqCallback)(void)=0; // func of main emu, called on spu irq void (CALLBACK *cddavCallback)(unsigned short,unsigned short)=0; // certain globals (were local before, but with the new timeproc I need em global) -static const int f[5][2] = { { 0, 0 }, +static const int f[8][2] = { { 0, 0 }, { 60, 0 }, { 115, -52 }, { 98, -55 }, @@ -254,8 +257,6 @@ INLINE void StartSound(int ch) s_chan[ch].s_2=0; s_chan[ch].iSBPos=28; - s_chan[ch].bNew=0; // init channel flags - s_chan[ch].SB[29]=0; // init our interpolation helpers s_chan[ch].SB[30]=0; @@ -494,14 +495,16 @@ static void *MAINThread(void *arg) { for(;ch turn everything off - s_chan[ch].ADSRX.lVolume=0; + dwChannelOn&=~(1< turn everything off s_chan[ch].ADSRX.EnvelopeVol=0; goto ENDX; // -> and done for this channel } @@ -564,7 +566,6 @@ static void *MAINThread(void *arg) (pSpuIrq > s_chan[ch].pLoop-16 && pSpuIrq <= s_chan[ch].pLoop))) { - s_chan[ch].iIrqDone=1; // -> debug flag irqCallback(); // -> call main emu if(iSPUIRQWait) // -> option: wait after irq for main emu @@ -600,8 +601,6 @@ static void *MAINThread(void *arg) s_chan[ch].pCurr=start; // store values for next cycle s_chan[ch].s_1=s_1; s_chan[ch].s_2=s_2; - -GOON: ; } fa=s_chan[ch].SB[s_chan[ch].iSBPos++]; // get sample data @@ -615,27 +614,22 @@ GOON: ; fa=iGetNoiseVal(ch); // get noise val else fa=iGetInterpolationVal(ch); // get sample val - s_chan[ch].sval = (MixADSR(ch) * fa) / 1023; // mix adsr + sval = (MixADSR(ch) * fa) / 1023; // mix adsr if(s_chan[ch].bFMod==2) // fmod freq channel - iFMod[ns]=s_chan[ch].sval; // -> store 1T sample data, use that to do fmod on next channel + iFMod[ns]=sval; // -> store 1T sample data, use that to do fmod on next channel else // no fmod freq channel { ////////////////////////////////////////////// // ok, left/right sound volume (psx volume goes from 0 ... 0x3fff) - if(s_chan[ch].iMute) - s_chan[ch].sval=0; // debug mute - else - { - SSumL[ns]+=(s_chan[ch].sval*s_chan[ch].iLeftVolume)/0x4000L; - SSumR[ns]+=(s_chan[ch].sval*s_chan[ch].iRightVolume)/0x4000L; - } + SSumL[ns]+=(sval*s_chan[ch].iLeftVolume)/0x4000L; + SSumR[ns]+=(sval*s_chan[ch].iRightVolume)/0x4000L; ////////////////////////////////////////////// // now let us store sound data for reverb - if(s_chan[ch].bRVBActive) StoreREVERB(ch,ns); + if(s_chan[ch].bRVBActive) StoreREVERB(ch,ns,sval); } //////////////////////////////////////////////// @@ -736,7 +730,7 @@ ENDX: ; for(ch=0;ch<4;ch++) { if(pSpuIrq>=pMixIrq+(ch*0x400) && pSpuIrqspuMemC+0x3ff) pMixIrq=spuMemC; @@ -887,9 +881,7 @@ void SetupStreams(void) // we don't use mutex sync... not needed, would only // slow us down: // s_chan[i].hMutex=CreateMutex(NULL,FALSE,NULL); - s_chan[i].ADSRX.SustainLevel = 1024; // -> init sustain - s_chan[i].iMute=0; - s_chan[i].iIrqDone=0; + s_chan[i].ADSRX.SustainLevel = 0xf; // -> init sustain s_chan[i].pLoop=spuMemC; s_chan[i].pStart=spuMemC; s_chan[i].pCurr=spuMemC; @@ -1036,3 +1028,5 @@ char * SPUgetLibInfos(void) return _(libraryInfo); } */ + +// vim:shiftwidth=1:expandtab diff --git a/plugins/dfsound/stdafx.h b/plugins/dfsound/stdafx.h index 8be88489..45b366b1 100644 --- a/plugins/dfsound/stdafx.h +++ b/plugins/dfsound/stdafx.h @@ -40,7 +40,7 @@ #define HIWORD(l) ((unsigned short)(((unsigned long)(l) >> 16) & 0xFFFF)) #ifndef INLINE -#define INLINE inline +#define INLINE static inline #endif #include "psemuxa.h" -- 2.39.5