some random improvements
[pcsx_rearmed.git] / plugins / dfsound / reverb.c
index 0a94ff4..7e32b8e 100644 (file)
 // will be included from spu.c\r
 #ifdef _IN_SPU\r
 \r
-////////////////////////////////////////////////////////////////////////\r
-// globals\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-// REVERB info and timing vars...\r
-\r
-int *          sRVBPlay      = 0;\r
-int *          sRVBEnd       = 0;\r
-int *          sRVBStart     = 0;\r
-\r
 ////////////////////////////////////////////////////////////////////////\r
 // START REVERB\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
 INLINE void StartREVERB(int ch)\r
 {\r
- if(s_chan[ch].bReverb && (spuCtrl&0x80))              // reverb possible?\r
+ if(spu.s_chan[ch].bReverb && (spu.spuCtrl&0x80))      // reverb possible?\r
   {\r
-   s_chan[ch].bRVBActive=!!iUseReverb;\r
+   spu.s_chan[ch].bRVBActive=!!spu_config.iUseReverb;\r
   }\r
- else s_chan[ch].bRVBActive=0;                         // else -> no reverb\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// HELPER FOR NEILL'S REVERB: re-inits our reverb mixing buf\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-INLINE void InitREVERB(int ns_to)\r
-{\r
- memset(sRVBStart,0,ns_to*sizeof(sRVBStart[0])*2);\r
+ else spu.s_chan[ch].bRVBActive=0;                     // else -> no reverb\r
 }\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
@@ -69,21 +50,21 @@ INLINE int rvb2ram_offs(int curr, int space, int iOff)
 \r
 // get_buffer content helper: takes care about wraps\r
 #define g_buffer(var) \\r
- ((int)(signed short)spuMem[rvb2ram_offs(curr_addr, space, rvb.n##var)])\r
+ ((int)(signed short)spu.spuMem[rvb2ram_offs(curr_addr, space, rvb.n##var)])\r
 \r
 // saturate iVal and store it as var\r
 #define s_buffer(var, iVal) \\r
  ssat32_to_16(iVal); \\r
- spuMem[rvb2ram_offs(curr_addr, space, rvb.n##var)] = iVal\r
+ spu.spuMem[rvb2ram_offs(curr_addr, space, rvb.n##var)] = iVal\r
 \r
 #define s_buffer1(var, iVal) \\r
  ssat32_to_16(iVal); \\r
- spuMem[rvb2ram_offs(curr_addr, space, rvb.n##var + 1)] = iVal\r
+ spu.spuMem[rvb2ram_offs(curr_addr, space, rvb.n##var + 1)] = iVal\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
 \r
 // portions based on spu2-x from PCSX2\r
-static void MixREVERB(int ns_to)\r
+static void MixREVERB(int *SSumLR, int *RVB, int ns_to)\r
 {\r
  int l_old = rvb.iRVBLeft;\r
  int r_old = rvb.iRVBRight;\r
@@ -97,8 +78,8 @@ static void MixREVERB(int ns_to)
    int ACC0, ACC1, FB_A0, FB_A1, FB_B0, FB_B1;\r
    int mix_dest_a0, mix_dest_a1, mix_dest_b0, mix_dest_b1;\r
 \r
-   int input_L = sRVBStart[ns]   * rvb.IN_COEF_L;\r
-   int input_R = sRVBStart[ns+1] * rvb.IN_COEF_R;\r
+   int input_L = RVB[ns]   * rvb.IN_COEF_L;\r
+   int input_R = RVB[ns+1] * rvb.IN_COEF_R;\r
 \r
    int IIR_INPUT_A0 = ((g_buffer(IIR_SRC_A0) * rvb.IIR_COEF) + input_L) >> 15;\r
    int IIR_INPUT_A1 = ((g_buffer(IIR_SRC_A1) * rvb.IIR_COEF) + input_R) >> 15;\r
@@ -168,7 +149,7 @@ static void MixREVERB(int ns_to)
  rvb.CurrAddr = curr_addr;\r
 }\r
 \r
-static void MixREVERB_off(int ns_to)\r
+static void MixREVERB_off(int *SSumLR, int ns_to)\r
 {\r
  int l_old = rvb.iRVBLeft;\r
  int r_old = rvb.iRVBRight;\r
@@ -246,7 +227,7 @@ static void prepare_offsets(void)
  rvb.dirty = 0;\r
 }\r
 \r
-INLINE void REVERBDo(int ns_to)\r
+INLINE void REVERBDo(int *SSumLR, int *RVB, int ns_to)\r
 {\r
  if (!rvb.StartAddr)                                   // reverb is off\r
  {\r
@@ -254,19 +235,19 @@ INLINE void REVERBDo(int ns_to)
   return;\r
  }\r
 \r
- if (spuCtrl & 0x80)                                   // -> reverb on? oki\r
+ if (spu.spuCtrl & 0x80)                               // -> reverb on? oki\r
  {\r
   if (unlikely(rvb.dirty))\r
    prepare_offsets();\r
 \r
-  MixREVERB(ns_to);\r
+  MixREVERB(SSumLR, RVB, ns_to);\r
  }\r
  else if (rvb.VolLeft || rvb.VolRight)\r
  {\r
   if (unlikely(rvb.dirty))\r
    prepare_offsets();\r
 \r
-  MixREVERB_off(ns_to);\r
+  MixREVERB_off(SSumLR, ns_to);\r
  }\r
  else                                                  // -> reverb off\r
  {\r