From fa5c356f25794bd37240197f719ceca239927a8d Mon Sep 17 00:00:00 2001 From: "SND\\shalma_cp" Date: Thu, 9 Dec 2010 14:53:29 +0000 Subject: dfsound - Final Fantasy 7 = adsr.c - use newer PEOPS DSound Sustain level - PEOPS 1.09a win32 = fix FF7 cursor - freeze.c - add emu crash check (spu not init yet) - spu.c - improve spu async timing - set latency = 20 ms - smoother, less pops, cracks - spu.c, registers.c - VAG silence flag (keeps playing channel for IRQs) - new save states needed git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@60906 e17a0e51-4ae3-4d35-97c3-1a29b211df97 --- plugins/dfsound/adsr.c | 5 ++++- plugins/dfsound/externals.h | 3 ++- plugins/dfsound/freeze.c | 2 ++ plugins/dfsound/registers.c | 6 +++++ plugins/dfsound/spu.c | 54 ++++++++++++++++++++++++++++++--------------- 5 files changed, 50 insertions(+), 20 deletions(-) (limited to 'plugins') diff --git a/plugins/dfsound/adsr.c b/plugins/dfsound/adsr.c index 2496e461..3c88e321 100644 --- a/plugins/dfsound/adsr.c +++ b/plugins/dfsound/adsr.c @@ -135,7 +135,10 @@ INLINE int MixADSR(int ch) // MIX ADSR } if(s_chan[ch].ADSRX.EnvelopeVol<0) s_chan[ch].ADSRX.EnvelopeVol=0; - if(((s_chan[ch].ADSRX.EnvelopeVol>>27)&0xF) <= s_chan[ch].ADSRX.SustainLevel) + //if(((s_chan[ch].ADSRX.EnvelopeVol>>27)&0xF) <= s_chan[ch].ADSRX.SustainLevel) + + // PEOPS DSound FF7 cursor fix (dfsound too?) + if(s_chan[ch].ADSRX.EnvelopeVol <= s_chan[ch].ADSRX.SustainLevel * (0x7fffffff / 0xf) ) { s_chan[ch].ADSRX.State=2; } diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 30ac977d..6fe7c9d2 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -127,7 +127,8 @@ typedef struct int iLeftVolume; // left volume int iLeftVolRaw; // left psx volume value int bIgnoreLoop; // ignore loop bit, if an external loop address is used - int iMute; // mute mode + int iMute; // mute mode (debug) + int iSilent; // voice on - sound on/off int iRightVolume; // right volume int iRightVolRaw; // right psx volume value int iRawPitch; // raw pitch (0...3fff) diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index e4283595..9a5f142f 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -68,6 +68,8 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) if(!pF) return 0; // first check + if(!bSpuInit) return 0; + if(ulFreezeMode) // info or save? {//--------------------------------------------------// if(ulFreezeMode==1) diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index a6d2869f..94b7d3e8 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -430,9 +430,15 @@ void SoundOn(int start,int end,unsigned short val) // SOUND ON PSX COMAND s_chan[ch].bNew=1; // ..? + s_chan[ch].iSilent=0; //s_chan[ch].bStop=0; //s_chan[ch].pLoop=0; + // Final Fantasy 7 - don't do any of these + //s_chan[ch].pLoop = spuMemC; + //s_chan[ch].pLoop = 0; + //s_chan[ch].pLoop = s_chan[ch].pStart; + dwNewChannel|=(1<= spuMemC + 0x80000 ) + start = spuMemC - 0x80000; +#endif s_chan[ch].pCurr=start; // store values for next cycle s_chan[ch].s_1=s_1; @@ -695,7 +700,7 @@ GOON: ; ////////////////////////////////////////////// // ok, left/right sound volume (psx volume goes from 0 ... 0x3fff) - if(s_chan[ch].iMute) + if(s_chan[ch].iMute || s_chan[ch].iSilent) s_chan[ch].sval=0; // debug mute else { @@ -799,15 +804,21 @@ ENDX: ; InitREVERB(); + ////////////////////////////////////////////////////// // feed the sound - // wanna have around 1/60 sec (16.666 ms) updates - if (iCycle++ > 16) + // latency = 20 ms (less pops, crackles, smoother) + + if(iCycle++>=20) { SoundFeedStreamData((unsigned char *)pSpuBuffer, ((unsigned char *)pS) - ((unsigned char *)pSpuBuffer)); pS = (short *)pSpuBuffer; iCycle = 0; } + + + if( iUseTimer == 2 ) + bEndThread = 1; } // end of big main loop... @@ -836,6 +847,7 @@ DWORD WINAPI MAINThreadEx(LPVOID lpParameter) // SPU ASYNC... even newer epsxe func // 1 time every 'cycle' cycles... harhar +long cpu_cycles; void CALLBACK SPUasync(unsigned long cycle) { if(iSpuAsyncWait) @@ -862,11 +874,17 @@ void CALLBACK SPUasync(unsigned long cycle) { if(!bSpuInit) return; // -> no init, no call -#ifdef _WINDOWS - MAINProc(0,0,0,0,0); // -> experimental win mode... not really tested... don't like the drawbacks -#else - MAINThread(0); // -> linux high-compat mode -#endif + // 1 ms updates + while( cpu_cycles >= 33868800 / 1000 ) + { + #ifdef _WINDOWS + MAINProc(0,0,0,0,0); // -> experimental win mode... not really tested... don't like the drawbacks + #else + MAINThread(0); // -> linux high-compat mode + #endif + + cpu_cycles -= 33868800 / 1000; + } } } -- cgit v1.2.3