From f05d6ca255c80170e4e5fc61cc48d87e013b8807 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 30 Jul 2012 16:27:32 +0300 Subject: [PATCH] spu: some cleanups --- plugins/dfsound/dsoundoss.h | 1 - plugins/dfsound/externals.h | 2 +- plugins/dfsound/gauss_i.h | 2 +- plugins/dfsound/registers.c | 80 ------------------------------------- plugins/dfsound/spu.c | 4 +- plugins/dfsound/xa.c | 2 +- 6 files changed, 5 insertions(+), 86 deletions(-) diff --git a/plugins/dfsound/dsoundoss.h b/plugins/dfsound/dsoundoss.h index 3702312f..543b297f 100644 --- a/plugins/dfsound/dsoundoss.h +++ b/plugins/dfsound/dsoundoss.h @@ -19,4 +19,3 @@ void SetupSound(void); void RemoveSound(void); unsigned long SoundGetBytesBuffered(void); void SoundFeedStreamData(unsigned char* pSound,long lBytes); -unsigned long timeGetTime_spu(); diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index fbf9d181..28dab573 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -21,7 +21,7 @@ // generic defines ///////////////////////////////////////////////////////// -#if 0 //def __GNUC__ +#ifdef __GNUC__ #define noinline __attribute__((noinline)) #define unlikely(x) __builtin_expect((x), 0) #else diff --git a/plugins/dfsound/gauss_i.h b/plugins/dfsound/gauss_i.h index 5a3a676d..4405e57a 100644 --- a/plugins/dfsound/gauss_i.h +++ b/plugins/dfsound/gauss_i.h @@ -18,7 +18,7 @@ #ifndef GAUSS_H #define GAUSS_H -const int gauss[]={ +static const short gauss[]={ 0x172, 0x519, 0x176, 0x000, 0x16E, 0x519, 0x17A, 0x000, 0x16A, 0x518, 0x17D, 0x000, 0x166, 0x518, 0x181, 0x000, 0x162, 0x518, 0x185, 0x000, 0x15F, 0x518, 0x189, 0x000, diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index 54e4000f..b9c1256a 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -22,24 +22,6 @@ #include "externals.h" #include "registers.h" -/* -// adsr time values (in ms) by James Higgs ... see the end of -// the adsr.c source for details - -#define ATTACK_MS 514L -#define DECAYHALF_MS 292L -#define DECAY_MS 584L -#define SUSTAIN_MS 450L -#define RELEASE_MS 446L -*/ - -// we have a timebase of 1.020408f ms, not 1 ms... so adjust adsr defines -#define ATTACK_MS 494L -#define DECAYHALF_MS 286L -#define DECAY_MS 572L -#define SUSTAIN_MS 441L -#define RELEASE_MS 437L - static void SoundOn(int start,int end,unsigned short val); static void SoundOff(int start,int end,unsigned short val); static void FModOn(int start,int end,unsigned short val); @@ -89,35 +71,6 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) 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 - - s_chan[ch].ADSR.AttackModeExp=(lval&0x8000)?1:0; //0x007f - - lx=(((lval>>8) & 0x007f)>>2); // attack time to run from 0 to 100% volume - lx=min(31,lx); // no overflow on shift! - if(lx) - { - lx = (1<>4) & 0x000f; // decay: - if(lx) // our const decay value is time it takes from 100% to 0% of volume - { - lx = ((1<<(lx))*DECAY_MS)/10000L; - if(!lx) lx=1; - } - 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 @@ -132,39 +85,6 @@ 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 - - s_chan[ch].ADSR.SustainModeExp = (lval&0x8000)?1:0; - s_chan[ch].ADSR.ReleaseModeExp = (lval&0x0020)?1:0; - - lx=((((lval>>6) & 0x007f)>>2)); // sustain time... often very high - lx=min(31,lx); // values are used to hold the volume - if(lx) // until a sound stop occurs - { // the highest value we reach (due to - lx = (1<> 6) & ~3; gpos = s_chan[ch].SB[28]; - vr=(gauss[vl]*gval0)&~2047; + vr=(gauss[vl]*(int)gval0)&~2047; vr+=(gauss[vl+1]*gval(1))&~2047; vr+=(gauss[vl+2]*gval(2))&~2047; vr+=(gauss[vl+3]*gval(3))&~2047; diff --git a/plugins/dfsound/xa.c b/plugins/dfsound/xa.c index af78acbe..1c5425ea 100644 --- a/plugins/dfsound/xa.c +++ b/plugins/dfsound/xa.c @@ -104,7 +104,7 @@ INLINE void MixXA(void) // small linux time helper... only used for watchdog //////////////////////////////////////////////////////////////////////// -unsigned long timeGetTime_spu() +static unsigned long timeGetTime_spu() { struct timeval tv; gettimeofday(&tv, 0); // well, maybe there are better ways -- 2.39.5