X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fspu.c;h=bea8414e80e8e11f7c4bb023c5bd31d53af082e4;hp=791b27eb7bff176189f176124b34c31841708160;hb=587fa7de9b496a0b7fa1d52d393733886602ca83;hpb=b1094d0ef5dce90b6c344e7616ca0acd10050c7e diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 791b27eb..bea8414e 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -122,8 +122,8 @@ static const int f[8][2] = { { 0, 0 }, { 115, -52 }, { 98, -55 }, { 122, -60 } }; -int ChanBuf[NSSIZE]; -int SSumLR[NSSIZE*2]; +int ChanBuf[NSSIZE+3]; +int SSumLR[(NSSIZE+3)*2]; int iFMod[NSSIZE]; int iCycle = 0; short * pS; @@ -635,6 +635,49 @@ static int do_samples_noise(int ch, int ns, int ns_to) return -1; } +#ifdef __arm__ +// asm code +extern void mix_chan(int start, int count, int lv, int rv); +extern void mix_chan_rvb(int start, int count, int lv, int rv); +#else +static void mix_chan(int start, int count, int lv, int rv) +{ + int *dst = SSumLR + start * 2; + const int *src = ChanBuf + start; + int l, r; + + while (count--) + { + int sval = *src++; + + l = (sval * lv) >> 14; + r = (sval * rv) >> 14; + *dst++ += l; + *dst++ += r; + } +} + +static void mix_chan_rvb(int start, int count, int lv, int rv) +{ + int *dst = SSumLR + start * 2; + int *drvb = sRVBStart + start * 2; + const int *src = ChanBuf + start; + int l, r; + + while (count--) + { + int sval = *src++; + + l = (sval * lv) >> 14; + r = (sval * rv) >> 14; + *dst++ += l; + *dst++ += r; + *drvb++ += l; + *drvb++ += r; + } +} +#endif + //////////////////////////////////////////////////////////////////////// // MAIN SPU FUNCTION // here is the main job handler... thread, timer or direct func call @@ -719,36 +762,18 @@ static void *MAINThread(void *arg) bIRQReturn=1; lastch=ch; lastns=ns_to=d; + if(d==0) + break; } MixADSR(ch, ns_from, ns_to); if(s_chan[ch].bFMod==2) // fmod freq channel memcpy(iFMod, ChanBuf, sizeof(iFMod)); + else if(s_chan[ch].bRVBActive) + mix_chan_rvb(ns_from,ns_to-ns_from,s_chan[ch].iLeftVolume,s_chan[ch].iRightVolume); else - { - int lv=s_chan[ch].iLeftVolume; - int rv=s_chan[ch].iRightVolume; - - for(ns=ns_from;ns>14; - r=(sval*rv)>>14; - SSumLR[ns*2] +=l; - SSumLR[ns*2+1]+=r; - - ////////////////////////////////////////////// - // now let us store sound data for reverb - - if(s_chan[ch].bRVBActive) StoreREVERB(ch,ns,l,r); - } - } + mix_chan(ns_from,ns_to-ns_from,s_chan[ch].iLeftVolume,s_chan[ch].iRightVolume); } } @@ -771,7 +796,8 @@ static void *MAINThread(void *arg) { unsigned char *start=s_chan[ch].pCurr; - bIRQReturn |= skip_block(ch); + // no need for bIRQReturn since the channel is silent + iSpuAsyncWait |= skip_block(ch); if(start == s_chan[ch].pCurr) { // looping on self