diff options
| author | SND\shalma_cp <SND\shalma_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2010-12-27 18:37:10 +0000 |
|---|---|---|
| committer | SND\shalma_cp <SND\shalma_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2010-12-27 18:37:10 +0000 |
| commit | 2062913f19d4d8a47daab7e762bb79203fff5c22 (patch) | |
| tree | 117e340708dccce95d18cadaa1dcac529cb87d4c /plugins/dfsound/xa.c | |
| parent | b9b56cc0db2e0ac2d3366fc1b1095c0cd3798cb2 (diff) | |
| download | pcsxr-2062913f19d4d8a47daab7e762bb79203fff5c22.tar.gz | |
hopkat-dfsound-port dsound r12
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@61528 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins/dfsound/xa.c')
| -rw-r--r-- | plugins/dfsound/xa.c | 123 |
1 files changed, 87 insertions, 36 deletions
diff --git a/plugins/dfsound/xa.c b/plugins/dfsound/xa.c index 0f523934..79a59122 100644 --- a/plugins/dfsound/xa.c +++ b/plugins/dfsound/xa.c @@ -42,8 +42,8 @@ uint32_t * CDDAPlay = NULL; uint32_t * CDDAStart = NULL; uint32_t * CDDAEnd = NULL; -int iLeftXAVol = 32767; -int iRightXAVol = 32767; +int iLeftXAVol = 0x8000; +int iRightXAVol = 0x8000; static int gauss_ptr = 0; static int gauss_window[8] = {0, 0, 0, 0, 0, 0, 0, 0}; @@ -52,50 +52,101 @@ static int gauss_window[8] = {0, 0, 0, 0, 0, 0, 0, 0}; #define gvall(x) gauss_window[(gauss_ptr+x)&3] #define gvalr0 gauss_window[4+gauss_ptr] #define gvalr(x) gauss_window[4+((gauss_ptr+x)&3)] +
+long cdxa_dbuf_ptr;
//////////////////////////////////////////////////////////////////////// // MIX XA & CDDA //////////////////////////////////////////////////////////////////////// +/*
+Attenuation
+- Blade_Arma (edgbla) (PCSX-reloaded)
+- accurate (!)
+
+
+s32 lc = (spsound[i ] * attenuators.val0 + spsound[i+1] * attenuators.val3]) / 128;
+s32 rc = (spsound[i+1] * attenuators.val2 + spsound[i ] * attenuators.val1]) / 128;
+*/
+
INLINE void MixXA(void) { - int ns; - uint32_t l; - - for(ns=0;ns<NSSIZE && XAPlay!=XAFeed;ns++) - { - XALastVal=*XAPlay++; - if(XAPlay==XAEnd) XAPlay=XAStart; -#ifdef XA_HACK - SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32768; - SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32768; -#else - SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32767; - SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32767; -#endif - } - - if(XAPlay==XAFeed && XARepeat) - { - XARepeat--; - for(;ns<NSSIZE;ns++) - { -#ifdef XA_HACK - SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32768; - SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32768; -#else - SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32767; - SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32767; -#endif - } - } + int ns;
+ unsigned char val0,val1,val2,val3;
+ short l,r;
+ int lc,rc;
+ unsigned long cdda_l;
+
+ val0 = (iLeftXAVol>>8)&0xff;
+ val1 = iLeftXAVol&0xff;
+ val2 = (iRightXAVol>>8)&0xff;
+ val3 = iRightXAVol&0xff;
+
+ lc = 0;
+ rc = 0;
+
+ for(ns=0;ns<NSSIZE && XAPlay!=XAFeed;ns++)
+ {
+ XALastVal=*XAPlay++;
+ if(XAPlay==XAEnd) XAPlay=XAStart;
+
+ l = XALastVal&0xffff;
+ r = (XALastVal>>16) & 0xffff;
+
+ lc=(l * val0 + r * val3) / 128;
+ rc=(r * val2 + l * val1) / 128;
+
+ if( lc < -32768 ) lc = -32768;
+ if( rc < -32768 ) rc = -32768;
+ if( lc > 32767 ) lc = 32767;
+ if( rc > 32767 ) rc = 32767;
+
+ SSumL[ns]+=lc;
+ SSumR[ns]+=rc;
+
+
+ // Tales of Phantasia - voice meter
+ if( cdxa_dbuf_ptr >= 0x800 )
+ cdxa_dbuf_ptr = 0;
+ spuMem[ cdxa_dbuf_ptr++ ] = lc;
+ spuMem[ cdxa_dbuf_ptr++ ] = rc;
+ }
+
+ if(XAPlay==XAFeed && XARepeat)
+ {
+ XARepeat--;
+ for(;ns<NSSIZE;ns++)
+ {
+ SSumL[ns]+=lc;
+ SSumR[ns]+=rc;
+
+
+ // Tales of Phantasia - voice meter
+ if( cdxa_dbuf_ptr >= 0x800 )
+ cdxa_dbuf_ptr = 0;
+ spuMem[ cdxa_dbuf_ptr++ ] = lc;
+ spuMem[ cdxa_dbuf_ptr++ ] = rc;
+ }
+ }
for(ns=0;ns<NSSIZE && CDDAPlay!=CDDAFeed && (CDDAPlay!=CDDAEnd-1||CDDAFeed!=CDDAStart);ns++) { - l=*CDDAPlay++; - if(CDDAPlay==CDDAEnd) CDDAPlay=CDDAStart; - SSumL[ns]+=(((short)(l&0xffff)) * iLeftXAVol)/32767; - SSumR[ns]+=(((short)((l>>16)&0xffff)) * iRightXAVol)/32767; + cdda_l=*CDDAPlay++; + if(CDDAPlay==CDDAEnd) CDDAPlay=CDDAStart;
+ + l = cdda_l&0xffff;
+ r = (cdda_l>>16) & 0xffff;
+
+ lc=(l * val0 + r * val3) / 128;
+ rc=(r * val2 + l * val1) / 128;
+
+ if( lc < -32768 ) lc = -32768;
+ if( rc < -32768 ) rc = -32768;
+ if( lc > 32767 ) lc = 32767;
+ if( rc > 32767 ) rc = 32767;
+
+ SSumL[ns]+=lc;
+ SSumR[ns]+=rc;
} } |
