X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fxa.c;h=1c5425eaf78112698dae1313946d136b7513af67;hp=fdae4f9efe6cdabf210b7fc75179756a5ba40351;hb=fa56d36096cd4ab2b227ce2aa61c8404b8874689;hpb=ef79bbde537d6b9c745a7d86cb9df1d04c35590d diff --git a/plugins/dfsound/xa.c b/plugins/dfsound/xa.c index fdae4f9e..1c5425ea 100644 --- a/plugins/dfsound/xa.c +++ b/plugins/dfsound/xa.c @@ -59,42 +59,44 @@ static int gauss_window[8] = {0, 0, 0, 0, 0, 0, 0, 0}; INLINE void MixXA(void) { int ns; - uint32_t l; + short l, r; + uint32_t v; + int cursor = decode_pos; - for(ns=0;ns>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) - { + if(XAPlay != XAFeed || XARepeat > 0) + { + if(XAPlay == XAFeed) XARepeat--; - for(;ns>16)&0xffff)) * iRightXAVol)/32768; -#else - SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32767; - SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32767; -#endif - } - } - for(ns=0;ns> 15; + r = ((int)(short)(v >> 16) * iLeftXAVol) >> 15; + SSumLR[ns++] += l; + SSumLR[ns++] += r; + spuMem[cursor] = l; + spuMem[cursor + 0x400/2] = r; + cursor = (cursor + 1) & 0x1ff; + } + XALastVal = v; + } + + for(ns=0;ns>16)&0xffff)) * iRightXAVol)/32767; + + l = ((int)(short)v * iLeftXAVol) >> 15; + r = ((int)(short)(v >> 16) * iLeftXAVol) >> 15; + SSumLR[ns++] += l; + SSumLR[ns++] += r; + spuMem[cursor] = l; + spuMem[cursor + 0x400/2] = r; + cursor = (cursor + 1) & 0x1ff; } } @@ -102,7 +104,7 @@ INLINE void MixXA(void) // 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 @@ -122,7 +124,7 @@ INLINE void FeedXA(xa_decode_t *xap) xapGlobal = xap; // store info for save states XARepeat = 100; // set up repeat -#ifdef XA_HACK +#if 0//def XA_HACK iSize=((45500*xap->nsamples)/xap->freq); // get size #else iSize=((44100*xap->nsamples)/xap->freq); // get size @@ -220,13 +222,11 @@ INLINE void FeedXA(xa_decode_t *xap) s=(short)LOWORD(l); l1=s; l1=(l1*iPlace)/iSize; - if(l1<-32767) l1=-32767; - if(l1> 32767) l1=32767; + ssat32_to_16(l1); s=(short)HIWORD(l); l2=s; l2=(l2*iPlace)/iSize; - if(l2<-32767) l2=-32767; - if(l2> 32767) l2=32767; + ssat32_to_16(l2); l=(l1&0xffff)|(l2<<16); *XAFeed++=l; @@ -326,8 +326,7 @@ INLINE void FeedXA(xa_decode_t *xap) } l1=(l1*iPlace)/iSize; - if(l1<-32767) l1=-32767; - if(l1> 32767) l1=32767; + ssat32_to_16(l1); l=(l1&0xffff)|(l1<<16); *XAFeed++=l; @@ -359,7 +358,6 @@ INLINE void FeedXA(xa_decode_t *xap) vr+=(gauss[vl+2]*gvall(2))&~2047; vr+=(gauss[vl+3]*gvall(3))&~2047; l=s= vr >> 11; - l &= 0xffff; } else { @@ -371,6 +369,7 @@ INLINE void FeedXA(xa_decode_t *xap) l=s; } + l &= 0xffff; *XAFeed++=(l|(l<<16)); if(XAFeed==XAEnd) XAFeed=XAStart; @@ -390,21 +389,29 @@ INLINE void FeedXA(xa_decode_t *xap) // FEED CDDA //////////////////////////////////////////////////////////////////////// -INLINE void FeedCDDA(unsigned char *pcm, int nBytes) +INLINE int FeedCDDA(unsigned char *pcm, int nBytes) { + int space; + space=(CDDAPlay-CDDAFeed-1)*4 & (CDDA_BUFFER_SIZE - 1); + if(space0) { if(CDDAFeed==CDDAEnd) CDDAFeed=CDDAStart; - while(CDDAFeed==CDDAPlay-1|| - (CDDAFeed==CDDAEnd-1&&CDDAPlay==CDDAStart)) - { - if (!iUseTimer) usleep(1000); - else return; - } - *CDDAFeed++=(*pcm | (*(pcm+1)<<8) | (*(pcm+2)<<16) | (*(pcm+3)<<24)); - nBytes-=4; - pcm+=4; + space=(CDDAPlay-CDDAFeed-1)*4 & (CDDA_BUFFER_SIZE - 1); + if(CDDAFeed+space/4>CDDAEnd) + space=(CDDAEnd-CDDAFeed)*4; + if(space>nBytes) + space=nBytes; + + memcpy(CDDAFeed,pcm,space); + CDDAFeed+=space/4; + nBytes-=space; + pcm+=space; } + + return 0x676f; // rearmed_go } #endif