X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fspu.c;h=0f952fbb5e657d53a9e682352a87b876df9ed3c4;hp=ca0b97b955e38e8467e86797125972eb749063ea;hb=5238f6f8fcf43fb8506467b358ee976a8c5fdf6b;hpb=6d866bb7894b252fc430a24a97769511d5ead1ca diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index ca0b97b9..0f952fbb 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -73,7 +73,6 @@ int iDebugMode=0; int iRecordMode=0; int iUseReverb=2; int iUseInterpolation=2; -int iDisStereo=0; // MAIN infos struct for each channel @@ -107,8 +106,7 @@ static const int f[8][2] = { { 0, 0 }, { 115, -52 }, { 98, -55 }, { 122, -60 } }; -int SSumR[NSSIZE]; -int SSumL[NSSIZE]; +int SSumLR[NSSIZE*2]; int iFMod[NSSIZE]; int iCycle = 0; short * pS; @@ -588,9 +586,12 @@ static void *MAINThread(void *arg) { // We play this block out first... //if(!(flags&2)) // 1+2: do loop... otherwise: stop - if(flags!=3 || s_chan[ch].pLoop==NULL) // PETE: if we don't check exactly for 3, loop hang ups will happen (DQ4, for example) - { // and checking if pLoop is set avoids crashes, yeah + if((flags!=3 && flags!=7) // PETE: if we don't check exactly for 3, loop hang ups will happen (DQ4, for example) + || s_chan[ch].pLoop==NULL) // and checking if pLoop is set avoids crashes, yeah + { start = (unsigned char*)-1; + // Actua Soccer 2, Jungle Book, other games that check for this condition + s_chan[ch].ADSRX.EnvelopeVol = 0; } else { @@ -598,6 +599,9 @@ static void *MAINThread(void *arg) } } + if (start - spuMemC >= 0x80000) + start = (unsigned char*)-1; + s_chan[ch].pCurr=start; // store values for next cycle s_chan[ch].s_1=s_1; s_chan[ch].s_2=s_2; @@ -623,8 +627,8 @@ static void *MAINThread(void *arg) ////////////////////////////////////////////// // ok, left/right sound volume (psx volume goes from 0 ... 0x3fff) - SSumL[ns]+=(sval*s_chan[ch].iLeftVolume)/0x4000L; - SSumR[ns]+=(sval*s_chan[ch].iRightVolume)/0x4000L; + SSumLR[ns*2] +=(sval*s_chan[ch].iLeftVolume)/0x4000L; + SSumLR[ns*2+1]+=(sval*s_chan[ch].iRightVolume)/0x4000L; ////////////////////////////////////////////// // now let us store sound data for reverb @@ -670,37 +674,21 @@ ENDX: ; /////////////////////////////////////////////////////// // mix all channels (including reverb) into one buffer - if(iDisStereo) // no stereo? - { - int dl, dr; - for (ns = 0; ns < NSSIZE; ns++) - { - SSumL[ns] += MixREVERBLeft(ns); - - dl = SSumL[ns] / voldiv; SSumL[ns] = 0; - if (dl < -32767) dl = -32767; if (dl > 32767) dl = 32767; - - SSumR[ns] += MixREVERBRight(); - - dr = SSumR[ns] / voldiv; SSumR[ns] = 0; - if (dr < -32767) dr = -32767; if (dr > 32767) dr = 32767; - *pS++ = (dl + dr) / 2; - } - } - else // stereo: - for (ns = 0; ns < NSSIZE; ns++) + for (ns = 0; ns < NSSIZE*2; ) { - SSumL[ns] += MixREVERBLeft(ns); + SSumLR[ns] += MixREVERBLeft(ns/2); - d = SSumL[ns] / voldiv; SSumL[ns] = 0; + d = SSumLR[ns] / voldiv; SSumLR[ns] = 0; if (d < -32767) d = -32767; if (d > 32767) d = 32767; *pS++ = d; + ns++; - SSumR[ns] += MixREVERBRight(); + SSumLR[ns] += MixREVERBRight(); - d = SSumR[ns] / voldiv; SSumR[ns] = 0; + d = SSumLR[ns] / voldiv; SSumLR[ns] = 0; if(d < -32767) d = -32767; if(d > 32767) d = 32767; *pS++ = d; + ns++; } ////////////////////////////////////////////////////// @@ -818,8 +806,7 @@ void CALLBACK SPUplayCDDAchannel(short *pcm, int nbytes) // SETUPTIMER: init of certain buffers and threads/timers void SetupTimer(void) { - memset(SSumR,0,NSSIZE*sizeof(int)); // init some mixing buffers - memset(SSumL,0,NSSIZE*sizeof(int)); + memset(SSumLR,0,sizeof(SSumLR)); // init some mixing buffers memset(iFMod,0,NSSIZE*sizeof(int)); pS=(short *)pSpuBuffer; // setup soundbuffer pointer @@ -874,7 +861,7 @@ void SetupStreams(void) (uint32_t *)malloc(16384 * sizeof(uint32_t)); CDDAEnd = CDDAStart + 16384; CDDAPlay = CDDAStart; - CDDAFeed = CDDAStart + 1; + CDDAFeed = CDDAStart; for(i=0;i