X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fxa.c;h=380d1388cee04ef9e7e7b3b62511d25922fbe6e0;hp=397ed592f7dd2b61043bb3ddffbc526c4cf6a5e7;hb=refs%2Fremotes%2Fgithub%2Fmaster;hpb=4d66d894c6563cbfb78fe8ccc0b374809fc44b0d diff --git a/plugins/dfsound/xa.c b/plugins/dfsound/xa.c index 397ed592..380d1388 100644 --- a/plugins/dfsound/xa.c +++ b/plugins/dfsound/xa.c @@ -39,27 +39,81 @@ static int gauss_window[8] = {0, 0, 0, 0, 0, 0, 0, 0}; // MIX XA & CDDA //////////////////////////////////////////////////////////////////////// -INLINE void MixXA(int *SSumLR, int ns_to, int decode_pos) +INLINE void SkipCD(int ns_to, int decode_pos) { int cursor = decode_pos; int ns; - short l, r; + + if(spu.XAPlay != spu.XAFeed) + { + for(ns = 0; ns < ns_to*2; ns += 2) + { + if(spu.XAPlay != spu.XAFeed) spu.XAPlay++; + if(spu.XAPlay == spu.XAEnd) spu.XAPlay=spu.XAStart; + + spu.spuMem[cursor] = 0; + spu.spuMem[cursor + 0x400/2] = 0; + cursor = (cursor + 1) & 0x1ff; + } + } + else if(spu.CDDAPlay != spu.CDDAFeed) + { + for(ns = 0; ns < ns_to*2; ns += 2) + { + if(spu.CDDAPlay != spu.CDDAFeed) spu.CDDAPlay++; + if(spu.CDDAPlay == spu.CDDAEnd) spu.CDDAPlay=spu.CDDAStart; + + spu.spuMem[cursor] = 0; + spu.spuMem[cursor + 0x400/2] = 0; + cursor = (cursor + 1) & 0x1ff; + } + } + spu.XALastVal = 0; +} + +INLINE void MixCD(int *SSumLR, int *RVB, int ns_to, int decode_pos) +{ + int vll = spu.iLeftXAVol * spu.cdv.ll >> 7; + int vrl = spu.iLeftXAVol * spu.cdv.rl >> 7; + int vlr = spu.iRightXAVol * spu.cdv.lr >> 7; + int vrr = spu.iRightXAVol * spu.cdv.rr >> 7; + int cursor = decode_pos; + int l1, r1, l, r; + int ns; uint32_t v = spu.XALastVal; + // note: spu volume doesn't affect cd capture + if ((spu.cdv.ll | spu.cdv.lr | spu.cdv.rl | spu.cdv.rr) == 0) + { + SkipCD(ns_to, decode_pos); + return; + } + if(spu.XAPlay != spu.XAFeed || spu.XARepeat > 0) { if(spu.XAPlay == spu.XAFeed) spu.XARepeat--; - for(ns = 0; ns < ns_to*2; ) + for(ns = 0; ns < ns_to*2; ns += 2) { if(spu.XAPlay != spu.XAFeed) v=*spu.XAPlay++; if(spu.XAPlay == spu.XAEnd) spu.XAPlay=spu.XAStart; - l = ((int)(short)v * spu.iLeftXAVol) >> 15; - r = ((int)(short)(v >> 16) * spu.iLeftXAVol) >> 15; - SSumLR[ns++] += l; - SSumLR[ns++] += r; + l1 = (short)v, r1 = (short)(v >> 16); + l = (l1 * vll + r1 * vrl) >> 15; + r = (r1 * vrr + l1 * vlr) >> 15; + ssat32_to_16(l); + ssat32_to_16(r); + if (spu.spuCtrl & CTRL_CD) + { + SSumLR[ns+0] += l; + SSumLR[ns+1] += r; + } + if (unlikely(spu.spuCtrl & CTRL_CDREVERB)) + { + RVB[ns+0] += l; + RVB[ns+1] += r; + } spu.spuMem[cursor] = HTOLE16(v); spu.spuMem[cursor + 0x400/2] = HTOLE16(v >> 16); @@ -71,15 +125,26 @@ INLINE void MixXA(int *SSumLR, int ns_to, int decode_pos) // hence this 'ns_to < 8' else if(spu.CDDAPlay != spu.CDDAFeed || ns_to < 8) { - for(ns = 0; ns < ns_to*2; ) + for(ns = 0; ns < ns_to*2; ns += 2) { if(spu.CDDAPlay != spu.CDDAFeed) v=*spu.CDDAPlay++; if(spu.CDDAPlay == spu.CDDAEnd) spu.CDDAPlay=spu.CDDAStart; - l = ((int)(short)v * spu.iLeftXAVol) >> 15; - r = ((int)(short)(v >> 16) * spu.iLeftXAVol) >> 15; - SSumLR[ns++] += l; - SSumLR[ns++] += r; + l1 = (short)v, r1 = (short)(v >> 16); + l = (l1 * vll + r1 * vrl) >> 15; + r = (r1 * vrr + l1 * vlr) >> 15; + ssat32_to_16(l); + ssat32_to_16(r); + if (spu.spuCtrl & CTRL_CD) + { + SSumLR[ns+0] += l; + SSumLR[ns+1] += r; + } + if (unlikely(spu.spuCtrl & CTRL_CDREVERB)) + { + RVB[ns+0] += l; + RVB[ns+1] += r; + } spu.spuMem[cursor] = HTOLE16(v); spu.spuMem[cursor + 0x400/2] = HTOLE16(v >> 16); @@ -87,8 +152,16 @@ INLINE void MixXA(int *SSumLR, int ns_to, int decode_pos) } spu.XALastVal = v; } - else + else if (spu.cdClearSamples > 0) + { + for(ns = 0; ns < ns_to; ns++) + { + spu.spuMem[cursor] = spu.spuMem[cursor + 0x400/2] = 0; + cursor = (cursor + 1) & 0x1ff; + } + spu.cdClearSamples -= ns_to; spu.XALastVal = 0; + } } //////////////////////////////////////////////////////////////////////// @@ -114,13 +187,12 @@ static unsigned long timeGetTime_spu() // FEED XA //////////////////////////////////////////////////////////////////////// -INLINE void FeedXA(xa_decode_t *xap) +void FeedXA(const xa_decode_t *xap) { int sinc,spos,i,iSize,iPlace,vl,vr; if(!spu.bSPUIsOpen) return; - spu.xapGlobal = xap; // store info for save states spu.XARepeat = 3; // set up repeat #if 0//def XA_HACK @@ -394,12 +466,14 @@ INLINE void FeedXA(xa_decode_t *xap) // FEED CDDA //////////////////////////////////////////////////////////////////////// -INLINE int FeedCDDA(unsigned char *pcm, int nBytes) +void FeedCDDA(unsigned char *pcm, int nBytes) { int space; space=(spu.CDDAPlay-spu.CDDAFeed-1)*4 & (CDDA_BUFFER_SIZE - 1); - if(space0) { @@ -415,8 +489,7 @@ INLINE int FeedCDDA(unsigned char *pcm, int nBytes) nBytes-=space; pcm+=space; } - - return 0x676f; // rearmed_go } #endif +// vim:shiftwidth=1:expandtab