X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fspu.c;h=d6cd952bb5d95447a1fa698320ad714be8ff73a6;hp=e6c5449d3cf8f0c657f75d54d5539284a6c8fa4a;hb=1775933abd26d2e282c4e0b4093778d204a0038d;hpb=07a6dd2ce2c0c8ea2de11c30c134c877e7c7b0fb diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index e6c5449d..d6cd952b 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -38,6 +38,16 @@ #define N_(x) (x) #endif +#ifdef __arm__ + #define ssat32_to_16(v) \ + asm("ssat %0,#16,%1" : "=r" (v) : "r" (v)) +#else + #define ssat32_to_16(v) do { \ + if (v < -32768) v = -32768; \ + else if (v > 32767) v = 32767; \ + } while (0) +#endif + /* #if defined (USEMACOSX) static char * libraryName = N_("Mac OS X Sound"); @@ -730,21 +740,28 @@ static void *MAINThread(void *arg) if(s_chan[ch].bFMod==2) // fmod freq channel memcpy(iFMod, ChanBuf, sizeof(iFMod)); - else 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,sval); + if(s_chan[ch].bRVBActive) StoreREVERB(ch,ns,l,r); } } } @@ -811,19 +828,24 @@ static void *MAINThread(void *arg) /////////////////////////////////////////////////////// // mix all channels (including reverb) into one buffer + if(iUseReverb) + REVERBDo(); + + if((spuCtrl&0x4000)==0) // muted? (rare, don't optimize for this) + { + memset(pS, 0, NSSIZE * 2 * sizeof(pS[0])); + pS += NSSIZE*2; + } + else for (ns = 0; ns < NSSIZE*2; ) { - SSumLR[ns] += MixREVERBLeft(ns/2); - d = SSumLR[ns] / voldiv; SSumLR[ns] = 0; - if (d < -32767) d = -32767; if (d > 32767) d = 32767; + ssat32_to_16(d); *pS++ = d; ns++; - SSumLR[ns] += MixREVERBRight(); - d = SSumLR[ns] / voldiv; SSumLR[ns] = 0; - if(d < -32767) d = -32767; if(d > 32767) d = 32767; + ssat32_to_16(d); *pS++ = d; ns++; } @@ -1037,7 +1059,6 @@ long CALLBACK SPUinit(void) InitADSR(); iVolume = 3; - iReverbOff = -1; spuIrq = 0; spuAddr = 0xffffffff; bEndThread = 0;