spu: some cleanups
authornotaz <notasas@gmail.com>
Mon, 30 Jul 2012 13:27:32 +0000 (16:27 +0300)
committernotaz <notasas@gmail.com>
Mon, 30 Jul 2012 22:31:34 +0000 (01:31 +0300)
plugins/dfsound/dsoundoss.h
plugins/dfsound/externals.h
plugins/dfsound/gauss_i.h
plugins/dfsound/registers.c
plugins/dfsound/spu.c
plugins/dfsound/xa.c

index 3702312..543b297 100644 (file)
@@ -19,4 +19,3 @@ void SetupSound(void);
 void RemoveSound(void);
 unsigned long SoundGetBytesBuffered(void);
 void SoundFeedStreamData(unsigned char* pSound,long lBytes);
 void RemoveSound(void);
 unsigned long SoundGetBytesBuffered(void);
 void SoundFeedStreamData(unsigned char* pSound,long lBytes);
-unsigned long timeGetTime_spu();
index fbf9d18..28dab57 100644 (file)
@@ -21,7 +21,7 @@
 // generic defines\r
 /////////////////////////////////////////////////////////\r
 \r
 // generic defines\r
 /////////////////////////////////////////////////////////\r
 \r
-#if 0 //def __GNUC__\r
+#ifdef __GNUC__\r
 #define noinline __attribute__((noinline))\r
 #define unlikely(x) __builtin_expect((x), 0)\r
 #else\r
 #define noinline __attribute__((noinline))\r
 #define unlikely(x) __builtin_expect((x), 0)\r
 #else\r
index 5a3a676..4405e57 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef GAUSS_H\r
 #define GAUSS_H\r
 \r
 #ifndef GAUSS_H\r
 #define GAUSS_H\r
 \r
-const int gauss[]={\r
+static const short gauss[]={\r
        0x172, 0x519, 0x176, 0x000, 0x16E, 0x519, 0x17A, 0x000, \r
        0x16A, 0x518, 0x17D, 0x000, 0x166, 0x518, 0x181, 0x000, \r
        0x162, 0x518, 0x185, 0x000, 0x15F, 0x518, 0x189, 0x000, \r
        0x172, 0x519, 0x176, 0x000, 0x16E, 0x519, 0x17A, 0x000, \r
        0x16A, 0x518, 0x17D, 0x000, 0x166, 0x518, 0x181, 0x000, \r
        0x162, 0x518, 0x185, 0x000, 0x15F, 0x518, 0x189, 0x000, \r
index 54e4000..b9c1256 100644 (file)
 #include "externals.h"\r
 #include "registers.h"\r
 \r
 #include "externals.h"\r
 #include "registers.h"\r
 \r
-/*\r
-// adsr time values (in ms) by James Higgs ... see the end of\r
-// the adsr.c source for details\r
-\r
-#define ATTACK_MS     514L\r
-#define DECAYHALF_MS  292L\r
-#define DECAY_MS      584L\r
-#define SUSTAIN_MS    450L\r
-#define RELEASE_MS    446L\r
-*/\r
-\r
-// we have a timebase of 1.020408f ms, not 1 ms... so adjust adsr defines\r
-#define ATTACK_MS      494L\r
-#define DECAYHALF_MS   286L\r
-#define DECAY_MS       572L\r
-#define SUSTAIN_MS     441L\r
-#define RELEASE_MS     437L\r
-\r
 static void SoundOn(int start,int end,unsigned short val);\r
 static void SoundOff(int start,int end,unsigned short val);\r
 static void FModOn(int start,int end,unsigned short val);\r
 static void SoundOn(int start,int end,unsigned short val);\r
 static void SoundOff(int start,int end,unsigned short val);\r
 static void FModOn(int start,int end,unsigned short val);\r
@@ -89,35 +71,6 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val)
         s_chan[ch].ADSRX.DecayRate=(lval>>4) & 0x000f;\r
         s_chan[ch].ADSRX.SustainLevel=lval & 0x000f;\r
         //---------------------------------------------//\r
         s_chan[ch].ADSRX.DecayRate=(lval>>4) & 0x000f;\r
         s_chan[ch].ADSRX.SustainLevel=lval & 0x000f;\r
         //---------------------------------------------//\r
-#if 0\r
-        if(!iDebugMode) break;\r
-        //---------------------------------------------// stuff below is only for debug mode\r
-\r
-        s_chan[ch].ADSR.AttackModeExp=(lval&0x8000)?1:0;        //0x007f\r
-\r
-        lx=(((lval>>8) & 0x007f)>>2);                  // attack time to run from 0 to 100% volume\r
-        lx=min(31,lx);                                 // no overflow on shift!\r
-        if(lx) \r
-         { \r
-          lx = (1<<lx);\r
-          if(lx<2147483) lx=(lx*ATTACK_MS)/10000L;     // another overflow check\r
-          else           lx=(lx/10000L)*ATTACK_MS;\r
-          if(!lx) lx=1;\r
-         }\r
-        s_chan[ch].ADSR.AttackTime=lx;                \r
-\r
-        s_chan[ch].ADSR.SustainLevel=                 // our adsr vol runs from 0 to 1024, so scale the sustain level\r
-         (1024*((lval) & 0x000f))/15;\r
-\r
-        lx=(lval>>4) & 0x000f;                         // decay:\r
-        if(lx)                                         // our const decay value is time it takes from 100% to 0% of volume\r
-         {\r
-          lx = ((1<<(lx))*DECAY_MS)/10000L;\r
-          if(!lx) lx=1;\r
-         }\r
-        s_chan[ch].ADSR.DecayTime =                   // so calc how long does it take to run from 100% to the wanted sus level\r
-         (lx*(1024-s_chan[ch].ADSR.SustainLevel))/1024;\r
-#endif\r
        }\r
       break;\r
      //------------------------------------------------// adsr times with pre-calcs\r
        }\r
       break;\r
      //------------------------------------------------// adsr times with pre-calcs\r
@@ -132,39 +85,6 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val)
        s_chan[ch].ADSRX.ReleaseModeExp = (lval&0x0020)?1:0;\r
        s_chan[ch].ADSRX.ReleaseRate = lval & 0x001f;\r
        //----------------------------------------------//\r
        s_chan[ch].ADSRX.ReleaseModeExp = (lval&0x0020)?1:0;\r
        s_chan[ch].ADSRX.ReleaseRate = lval & 0x001f;\r
        //----------------------------------------------//\r
-#if 0\r
-       if(!iDebugMode) break;\r
-       //----------------------------------------------// stuff below is only for debug mode\r
-\r
-       s_chan[ch].ADSR.SustainModeExp = (lval&0x8000)?1:0;\r
-       s_chan[ch].ADSR.ReleaseModeExp = (lval&0x0020)?1:0;\r
-                   \r
-       lx=((((lval>>6) & 0x007f)>>2));                 // sustain time... often very high\r
-       lx=min(31,lx);                                  // values are used to hold the volume\r
-       if(lx)                                          // until a sound stop occurs\r
-        {                                              // the highest value we reach (due to \r
-         lx = (1<<lx);                                 // overflow checking) is: \r
-         if(lx<2147483) lx=(lx*SUSTAIN_MS)/10000L;     // 94704 seconds = 1578 minutes = 26 hours... \r
-         else           lx=(lx/10000L)*SUSTAIN_MS;     // should be enuff... if the stop doesn't \r
-         if(!lx) lx=1;                                 // come in this time span, I don't care :)\r
-        }\r
-       s_chan[ch].ADSR.SustainTime = lx;\r
-\r
-       lx=(lval & 0x001f);\r
-       s_chan[ch].ADSR.ReleaseVal     =lx;\r
-       if(lx)                                          // release time from 100% to 0%\r
-        {                                              // note: the release time will be\r
-         lx = (1<<lx);                                 // adjusted when a stop is coming,\r
-         if(lx<2147483) lx=(lx*RELEASE_MS)/10000L;     // so at this time the adsr vol will \r
-         else           lx=(lx/10000L)*RELEASE_MS;     // run from (current volume) to 0%\r
-         if(!lx) lx=1;\r
-        }\r
-       s_chan[ch].ADSR.ReleaseTime=lx;\r
-\r
-       if(lval & 0x4000)                               // add/dec flag\r
-            s_chan[ch].ADSR.SustainModeDec=-1;\r
-       else s_chan[ch].ADSR.SustainModeDec=1;\r
-#endif\r
       }\r
      break;\r
      //------------------------------------------------// adsr volume... mmm have to investigate this\r
       }\r
      break;\r
      //------------------------------------------------// adsr volume... mmm have to investigate this\r
index 69d6217..bbbe1e3 100644 (file)
@@ -243,7 +243,7 @@ INLINE void InterpolateDown(int ch)
 // helpers for gauss interpolation
 
 #define gval0 (((short*)(&s_chan[ch].SB[29]))[gpos])
 // helpers for gauss interpolation
 
 #define gval0 (((short*)(&s_chan[ch].SB[29]))[gpos])
-#define gval(x) (((short*)(&s_chan[ch].SB[29]))[(gpos+x)&3])
+#define gval(x) ((int)((short*)(&s_chan[ch].SB[29]))[(gpos+x)&3])
 
 #include "gauss_i.h"
 
 
 #include "gauss_i.h"
 
@@ -386,7 +386,7 @@ INLINE int iGetInterpolationVal(int ch, int spos)
      int vl, vr;int gpos;
      vl = (spos >> 6) & ~3;
      gpos = s_chan[ch].SB[28];
      int vl, vr;int gpos;
      vl = (spos >> 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;
      vr+=(gauss[vl+1]*gval(1))&~2047;
      vr+=(gauss[vl+2]*gval(2))&~2047;
      vr+=(gauss[vl+3]*gval(3))&~2047;
index af78acb..1c5425e 100644 (file)
@@ -104,7 +104,7 @@ INLINE void MixXA(void)
 // small linux time helper... only used for watchdog
 ////////////////////////////////////////////////////////////////////////
 
 // 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
 {
  struct timeval tv;
  gettimeofday(&tv, 0);                                 // well, maybe there are better ways