diff options
Diffstat (limited to 'plugins/dfsound/xa.c')
| -rw-r--r-- | plugins/dfsound/xa.c | 246 |
1 files changed, 125 insertions, 121 deletions
diff --git a/plugins/dfsound/xa.c b/plugins/dfsound/xa.c index 32614a29..a0ba86e8 100644 --- a/plugins/dfsound/xa.c +++ b/plugins/dfsound/xa.c @@ -15,7 +15,9 @@ * * ***************************************************************************/ -#include "stdafx.h"
+#include "stdafx.h" + +#include "xa.h" #define _IN_XA #include <stdint.h> @@ -45,6 +47,7 @@ uint32_t * CDDAEnd = NULL; int iLeftXAVol = 0x8000; int iRightXAVol = 0x8000; +#if 0 static int gauss_ptr = 0; static int gauss_window[8] = {0, 0, 0, 0, 0, 0, 0, 0}; @@ -52,132 +55,133 @@ 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;
+#endif + +long cdxa_dbuf_ptr; //////////////////////////////////////////////////////////////////////// // MIX XA & CDDA //////////////////////////////////////////////////////////////////////// -static int lastxa_lc, lastxa_rc;
-static int lastcd_lc, lastcd_rc;
-
+static int lastxa_lc, lastxa_rc; +static int lastcd_lc, lastcd_rc; + INLINE void MixXA(void) { - int ns;
- int lc,rc;
- unsigned long cdda_l;
-
- lc = 0;
- rc = 0;
-
- for(ns=0;ns<NSSIZE && XAPlay!=XAFeed;ns++)
- {
- XALastVal=*XAPlay++;
- if(XAPlay==XAEnd) XAPlay=XAStart;
-
- lc = (short)(XALastVal&0xffff);
- rc = (short)((XALastVal>>16) & 0xffff);
-
- 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;
-
- // improve crackle - buffer under
- // - not update fast enough
- lastxa_lc = lc;
- lastxa_rc = rc;
-
-
-#if 0
- if( cdxa_dbuf_ptr >= 0x400 )
- cdxa_dbuf_ptr = 0;
- spuMem[ (cdxa_dbuf_ptr + 0)/2 ] = lc;
- spuMem[ (cdxa_dbuf_ptr + 0x400)/2 ] = rc;
- cdxa_dbuf_ptr += 2;
-#endif
- }
-
- if(XAPlay==XAFeed && XARepeat)
- {
- //XARepeat--;
- for(;ns<NSSIZE;ns++)
- {
- SSumL[ns]+=lastxa_rc;
- SSumR[ns]+=lastxa_rc;
-
-#if 0
- // Tales of Phantasia - voice meter
- if( cdxa_dbuf_ptr >= 0x400 )
- cdxa_dbuf_ptr = 0;
- spuMem[ (cdxa_dbuf_ptr + 0)/2 ] = lastxa_rc;
- spuMem[ (cdxa_dbuf_ptr + 0x400)/2 ] = lastxa_rc;
- cdxa_dbuf_ptr += 2;
-#endif
- }
- }
+ int ns; + int lc,rc; + unsigned long cdda_l; + + lc = 0; + rc = 0; + + for(ns=0;ns<NSSIZE && XAPlay!=XAFeed;ns++) + { + XALastVal=*XAPlay++; + if(XAPlay==XAEnd) XAPlay=XAStart; + + lc = (short)(XALastVal&0xffff); + rc = (short)((XALastVal>>16) & 0xffff); + + 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; + + // improve crackle - buffer under + // - not update fast enough + lastxa_lc = lc; + lastxa_rc = rc; + + +#if 0 + if( cdxa_dbuf_ptr >= 0x400 ) + cdxa_dbuf_ptr = 0; + spuMem[ (cdxa_dbuf_ptr + 0)/2 ] = lc; + spuMem[ (cdxa_dbuf_ptr + 0x400)/2 ] = rc; + cdxa_dbuf_ptr += 2; +#endif + } + + if(XAPlay==XAFeed && XARepeat) + { + //XARepeat--; + for(;ns<NSSIZE;ns++) + { + SSumL[ns]+=lastxa_rc; + SSumR[ns]+=lastxa_rc; + +#if 0 + // Tales of Phantasia - voice meter + if( cdxa_dbuf_ptr >= 0x400 ) + cdxa_dbuf_ptr = 0; + spuMem[ (cdxa_dbuf_ptr + 0)/2 ] = lastxa_rc; + spuMem[ (cdxa_dbuf_ptr + 0x400)/2 ] = lastxa_rc; + cdxa_dbuf_ptr += 2; +#endif + } + } for(ns=0;ns<NSSIZE && CDDAPlay!=CDDAFeed && (CDDAPlay!=CDDAEnd-1||CDDAFeed!=CDDAStart);ns++) { cdda_l=*CDDAPlay++; - if(CDDAPlay==CDDAEnd) CDDAPlay=CDDAStart;
- - lc = (short)(cdda_l&0xffff);
- rc = (short)((cdda_l>>16) & 0xffff);
-
- 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;
-
-#if 0
- // Vib Ribbon - playback
- if( cdxa_dbuf_ptr >= 0x400 )
- cdxa_dbuf_ptr = 0;
- spuMem[ (cdxa_dbuf_ptr + 0)/2 ] = lc;
- spuMem[ (cdxa_dbuf_ptr + 0x400)/2 ] = rc;
- cdxa_dbuf_ptr += 2;
-#endif
-
- // improve crackle - buffer under
- // - not update fast enough
- lastcd_lc = lc;
- lastcd_rc = rc;
- }
-
-
- if(CDDAPlay==CDDAFeed && XARepeat)
- {
- //XARepeat--;
- for(;ns<NSSIZE;ns++)
- {
-#if 0
- // Vib Ribbon - playback
- if( cdxa_dbuf_ptr >= 0x400 )
- cdxa_dbuf_ptr = 0;
- spuMem[ (cdxa_dbuf_ptr + 0)/2 ] = lastcd_lc;
- spuMem[ (cdxa_dbuf_ptr + 0x400)/2 ] = lastcd_rc;
- cdxa_dbuf_ptr += 2;
-#endif
-
- SSumL[ns]+=lastcd_lc;
- SSumR[ns]+=lastcd_rc;
- }
- }
+ if(CDDAPlay==CDDAEnd) CDDAPlay=CDDAStart; + + lc = (short)(cdda_l&0xffff); + rc = (short)((cdda_l>>16) & 0xffff); + + 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; + +#if 0 + // Vib Ribbon - playback + if( cdxa_dbuf_ptr >= 0x400 ) + cdxa_dbuf_ptr = 0; + spuMem[ (cdxa_dbuf_ptr + 0)/2 ] = lc; + spuMem[ (cdxa_dbuf_ptr + 0x400)/2 ] = rc; + cdxa_dbuf_ptr += 2; +#endif + + // improve crackle - buffer under + // - not update fast enough + lastcd_lc = lc; + lastcd_rc = rc; + } + + + if(CDDAPlay==CDDAFeed && XARepeat) + { + //XARepeat--; + for(;ns<NSSIZE;ns++) + { +#if 0 + // Vib Ribbon - playback + if( cdxa_dbuf_ptr >= 0x400 ) + cdxa_dbuf_ptr = 0; + spuMem[ (cdxa_dbuf_ptr + 0)/2 ] = lastcd_lc; + spuMem[ (cdxa_dbuf_ptr + 0x400)/2 ] = lastcd_rc; + cdxa_dbuf_ptr += 2; +#endif + + SSumL[ns]+=lastcd_lc; + SSumR[ns]+=lastcd_rc; + } + } } //////////////////////////////////////////////////////////////////////// // small linux time helper... only used for watchdog //////////////////////////////////////////////////////////////////////// -
-#ifndef _WINDOWS
+ +#ifndef _WINDOWS unsigned long timeGetTime_spu() { @@ -185,8 +189,8 @@ unsigned long timeGetTime_spu() gettimeofday(&tv, 0); // well, maybe there are better ways return tv.tv_sec * 1000 + tv.tv_usec/1000; // to do that, but at least it works } -
-#endif
+ +#endif //////////////////////////////////////////////////////////////////////// // FEED XA @@ -194,7 +198,7 @@ unsigned long timeGetTime_spu() INLINE void FeedXA(xa_decode_t *xap) { - int sinc,spos,i,iSize,iPlace,vl,vr; + int sinc,spos,i,iSize,iPlace; if(!bSPUIsOpen) return; @@ -381,8 +385,8 @@ INLINE void FeedXA(xa_decode_t *xap) // FEED CDDA //////////////////////////////////////////////////////////////////////// -unsigned int cdda_ptr;
-
+unsigned int cdda_ptr; + INLINE void FeedCDDA(unsigned char *pcm, int nBytes) { while(nBytes>0) @@ -390,13 +394,13 @@ INLINE void FeedCDDA(unsigned char *pcm, int nBytes) if(CDDAFeed==CDDAEnd) CDDAFeed=CDDAStart; while(CDDAFeed==CDDAPlay-1|| (CDDAFeed==CDDAEnd-1&&CDDAPlay==CDDAStart)) - {
-#ifdef _WINDOWS
- if (!iUseTimer) Sleep(1);
- else return;
+ { +#ifdef _WINDOWS + if (!iUseTimer) Sleep(1); + else return; #else if (!iUseTimer) usleep(1000); - else return;
+ else return; #endif } *CDDAFeed++=(*pcm | (*(pcm+1)<<8) | (*(pcm+2)<<16) | (*(pcm+3)<<24)); |
