X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fspu.c;h=791b27eb7bff176189f176124b34c31841708160;hp=7b435ac695bbf12c62ac1fb7db3e85921f14e83b;hb=b1094d0ef5dce90b6c344e7616ca0acd10050c7e;hpb=381ea10346ab85b2f2d46f33d28461211e239c0a diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 7b435ac6..791b27eb 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -79,7 +79,7 @@ unsigned char * pMixIrq=0; // user settings -int iVolume=3; +int iVolume=768; // 1024 is 1.0 int iXAPitch=1; int iUseTimer=2; int iSPUIRQWait=1; @@ -93,7 +93,8 @@ int iUseInterpolation=2; SPUCHAN s_chan[MAXCHAN+1]; // channel + 1 infos (1 is security for fmod handling) REVERBInfo rvb; -unsigned long dwNoiseVal=1; // global noise generator +unsigned int dwNoiseVal; // global noise generator +unsigned int dwNoiseCount; int iSpuAsyncWait=0; unsigned short spuCtrl=0; // some vars to store psx reg infos @@ -320,35 +321,6 @@ INLINE int FModChangeFrequency(int ch,int ns) //////////////////////////////////////////////////////////////////////// -// noise handler... just produces some noise data -// surely wrong... and no noise frequency (spuCtrl&0x3f00) will be used... -// and sometimes the noise will be used as fmod modulation... pfff - -INLINE int iGetNoiseVal(int ch) -{ - int fa; - - if((dwNoiseVal<<=1)&0x80000000L) - { - dwNoiseVal^=0x0040001L; - fa=((dwNoiseVal>>2)&0x7fff); - fa=-fa; - } - else fa=(dwNoiseVal>>2)&0x7fff; - - // mmm... depending on the noise freq we allow bigger/smaller changes to the previous val - fa=s_chan[ch].iOldNoise+((fa-s_chan[ch].iOldNoise)/((0x001f-((spuCtrl&0x3f00)>>9))+1)); - if(fa>32767L) fa=32767L; - if(fa<-32767L) fa=-32767L; - s_chan[ch].iOldNoise=fa; - - if(iUseInterpolation<2) // no gauss/cubic interpolation? - s_chan[ch].SB[29] = fa; // -> store noise val in "current sample" slot - return fa; -} - -//////////////////////////////////////////////////////////////////////// - INLINE void StoreInterpolationVal(int ch,int fa) { if(s_chan[ch].bFMod==2) // fmod freq channel @@ -631,6 +603,8 @@ make_do_samples(simple, , , static int do_samples_noise(int ch, int ns, int ns_to) { + int level, shift, bit; + s_chan[ch].spos += s_chan[ch].sinc * (ns_to - ns); while (s_chan[ch].spos >= 28*0x10000) { @@ -638,8 +612,25 @@ static int do_samples_noise(int ch, int ns, int ns_to) s_chan[ch].spos -= 28*0x10000; } + // modified from DrHell/shalma, no fraction + level = (spuCtrl >> 10) & 0x0f; + level = 0x8000 >> level; + for (; ns < ns_to; ns++) - ChanBuf[ns] = iGetNoiseVal(ch); + { + dwNoiseCount += 2; + if (dwNoiseCount >= level) + { + dwNoiseCount -= level; + shift = (dwNoiseVal >> 10) & 0x1f; + bit = (0x69696969 >> shift) & 1; + if (dwNoiseVal & 0x8000) + bit ^= 1; + dwNoiseVal = (dwNoiseVal << 1) | bit; + } + + ChanBuf[ns] = (signed short)dwNoiseVal; + } return -1; } @@ -661,12 +652,8 @@ static int do_samples_noise(int ch, int ns, int ns_to) static void *MAINThread(void *arg) { + int volmult = iVolume; int ns,ns_from,ns_to; -#if !defined(_MACOSX) && !defined(__arm__) - int voldiv = iVolume; -#else - const int voldiv = 2; -#endif int ch,d; int bIRQReturn=0; @@ -837,12 +824,14 @@ static void *MAINThread(void *arg) else for (ns = 0; ns < NSSIZE*2; ) { - d = SSumLR[ns] / voldiv; SSumLR[ns] = 0; + d = SSumLR[ns]; SSumLR[ns] = 0; + d = d * volmult >> 10; ssat32_to_16(d); *pS++ = d; ns++; - d = SSumLR[ns] / voldiv; SSumLR[ns] = 0; + d = SSumLR[ns]; SSumLR[ns] = 0; + d = d * volmult >> 10; ssat32_to_16(d); *pS++ = d; ns++; @@ -1056,7 +1045,6 @@ long CALLBACK SPUinit(void) memset((void *)&rvb, 0, sizeof(REVERBInfo)); InitADSR(); - iVolume = 3; spuIrq = 0; spuAddr = 0xffffffff; bEndThread = 0;