dfsound: backport fixes from pcsxr
authornotaz <notasas@gmail.com>
Wed, 9 Feb 2011 12:34:15 +0000 (14:34 +0200)
committernotaz <notasas@gmail.com>
Wed, 9 Feb 2011 12:59:32 +0000 (14:59 +0200)
shalma:
- Align start addresses to 16-bytes
- (Hopkat) registers.c - External loop address align to 16 bytes
- SoundOff prevents new channel from starting
- fixes Jungle Book (buzzing loop hangs)

plugins/dfsound/registers.c
plugins/dfsound/spu.c

index b684914..5ab519b 100644 (file)
@@ -70,7 +70,8 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val)
        break;\r
      //------------------------------------------------// start\r
      case 6:      \r
-       s_chan[ch].pStart=spuMemC+((unsigned long) val<<3);\r
+       // Brain Dead 13 - align to 16 boundary\r
+       s_chan[ch].pStart= spuMemC+(unsigned long)((val<<3)&~0xf);\r
        break;\r
      //------------------------------------------------// level with pre-calcs\r
      case 8:\r
@@ -162,7 +163,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val)
      //------------------------------------------------//\r
      case 14:                                          // loop?\r
        //WaitForSingleObject(s_chan[ch].hMutex,2000);        // -> no multithread fuckups\r
-       s_chan[ch].pLoop=spuMemC+((unsigned long) val<<3);\r
+       s_chan[ch].pLoop=spuMemC+((unsigned long)((val<<3)&~0xf));\r
        s_chan[ch].bIgnoreLoop=1;\r
        //ReleaseMutex(s_chan[ch].hMutex);                    // -> oki, on with the thread\r
        break;\r
@@ -424,6 +425,13 @@ void SoundOn(int start,int end,unsigned short val)     // SOUND ON PSX COMAND
     {\r
      s_chan[ch].bIgnoreLoop=0;\r
      s_chan[ch].bNew=1;\r
+\r
+     // do this here, not in StartSound\r
+     // - fixes fussy timing issues\r
+     s_chan[ch].bStop=0;\r
+     s_chan[ch].bOn=1;\r
+     s_chan[ch].pCurr=s_chan[ch].pStart;\r
+\r
      dwNewChannel|=(1<<ch);                            // bitfield for faster testing\r
     }\r
   }\r
@@ -441,6 +449,11 @@ void SoundOff(int start,int end,unsigned short val)    // SOUND OFF PSX COMMAND
    if(val&1)                                           // && s_chan[i].bOn)  mmm...\r
     {\r
      s_chan[ch].bStop=1;\r
+\r
+     // Jungle Book - Rhythm 'n Groove\r
+     // - turns off buzzing sound (loop hangs)\r
+     s_chan[ch].bNew=0;\r
+     dwNewChannel &= ~(1<<ch);\r
     }                                                  \r
   }\r
 }\r
index 7e6cfb2..8936e45 100644 (file)
@@ -245,15 +245,16 @@ INLINE void StartSound(int ch)
  StartADSR(ch);
  StartREVERB(ch);
 
- s_chan[ch].pCurr=s_chan[ch].pStart;                   // set sample start
+ // fussy timing issues - do in VoiceOn
+ //s_chan[ch].pCurr=s_chan[ch].pStart;                   // set sample start
+ //s_chan[ch].bStop=0;
+ //s_chan[ch].bOn=1;
 
  s_chan[ch].s_1=0;                                     // init mixing vars
  s_chan[ch].s_2=0;
  s_chan[ch].iSBPos=28;
 
  s_chan[ch].bNew=0;                                    // init channel flags
- s_chan[ch].bStop=0;
- s_chan[ch].bOn=1;
 
  s_chan[ch].SB[29]=0;                                  // init our interpolation helpers
  s_chan[ch].SB[30]=0;