X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=sound.c;h=f0eeaf87c0b7c496afd454536dcad5a67c86bd1e;hb=3ac1cc0b221c10cd9a82ba3c12d111597dc554e7;hp=0c6087152765f54828cb528edcddd5e5dbfe1b10;hpb=a384bf449483e62637ce05a60ff4b06730a19934;p=fceu.git diff --git a/sound.c b/sound.c index 0c60871..f0eeaf8 100644 --- a/sound.c +++ b/sound.c @@ -40,6 +40,7 @@ #include "sound.h" uint32 Wave[2048+512]; +int32 WaveHi[40000]; // unused int16 WaveFinalMono[2048+512]; EXPSOUND GameExpSound={0,0,0,0,0,0}; @@ -554,6 +555,31 @@ static void FASTAPASS(1) CalcRectAmp(int P) *b=V; } +void FCEU_SoundCPUHook(int cycles48) +{ + fhcnt-=cycles48; + if(fhcnt<=0) + { + FrameSoundUpdate(); + fhcnt+=fhinc; + } + + if(PCMIRQCount>0) + { + PCMIRQCount-=cycles48; + if(PCMIRQCount<=0) + { + vdis=1; + if((PSG[0x10]&0x80) && !(PSG[0x10]&0x40)) + { + extern uint8 SIRQStat; + SIRQStat|=0x80; + X6502_IRQBegin(FCEU_IQDPCM); + } + } + } +} + static void RDoPCM(int32 end) { int32 V; @@ -845,7 +871,7 @@ static void RDoNoise(int32 end) } } -static DECLFW(Write_IRQFM) +DECLFW(Write_IRQFM) { PSG[0x17]=V; V=(V&0xC0)>>6; @@ -877,6 +903,8 @@ static int32 flt_acc=0, flt_acc2=0; static void FilterSound(uint32 *in, int16 *outMono, int count) { // static int min=0, max=0; + int sh=2; + if (soundvol < 5) sh += 5 - soundvol; for(;count;count--,in++,outMono++) { @@ -888,7 +916,7 @@ static void FilterSound(uint32 *in, int16 *outMono, int count) flt_acc2+= (int32) (((int64)((diff-flt_acc2)*lowp))>>16); *in=0; - *outMono = flt_acc2*7 >> 2; // * 1.75 + *outMono = flt_acc2*7 >> sh; // * 7 >> 2 = * 1.75 // if (acc2 < min) { printf("min: %i %04x\n", acc2, acc2); min = acc2; } // if (acc2 > max) { printf("max: %i %04x\n", acc2, acc2); max = acc2; } } @@ -968,9 +996,7 @@ void ResetSound(void) nreg=1; } -void (*SetSoundVariables)(void) = 0; - -void SetSoundVariables081(void) +void SetSoundVariables(void) { int x;