X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Ffreeze.c;h=58a8347674c059921f86e5f9fedcb82ab6f843ea;hp=cb0d75ecd9d03b0b873b47d198c2fc18a8a227a3;hb=8e1040b6a82ee1802fda83d4de84290a02656cc0;hpb=6d866bb7894b252fc430a24a97769511d5ead1ca diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index cb0d75ec..58a83476 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -22,7 +22,6 @@ #include "externals.h" #include "registers.h" #include "spu.h" -#include "regs.h" //////////////////////////////////////////////////////////////////////// // freeze structs @@ -59,9 +58,9 @@ typedef struct int SB[32+32]; // Pete added another 32 dwords in 1.6 ... prevents overflow issues with gaussian/cubic interpolation (thanx xodnizel!), and can be used for even better interpolations, eh? :) int sval; - unsigned char * pStart; // start ptr into sound mem - unsigned char * pCurr; // current pos in sound mem - unsigned char * pLoop; // loop ptr in sound mem + int iStart; // start ptr into sound mem + int iCurr; // current pos in sound mem + int iLoop; // loop ptr in sound mem int bOn; // is channel active (sample playing?) int bStop; // is channel stopped (sample _can_ still be playing, ADSR Release phase) @@ -121,7 +120,7 @@ extern int lastch; // we want to retain compatibility between versions, // so use original channel struct -static void save_channel(SPUCHAN_orig *d, SPUCHAN *s, int ch) +static void save_channel(SPUCHAN_orig *d, const SPUCHAN *s, int ch) { memset(d, 0, sizeof(*d)); d->bNew = !!(dwNewChannel & (1<spos = s->spos; d->sinc = s->sinc; memcpy(d->SB, s->SB, sizeof(d->SB)); - d->pStart = s->pStart; - d->pCurr = s->pCurr; - d->pLoop = s->pLoop; + d->iStart = (regAreaGet(ch,6)&~1)<<3; + d->iCurr = 0; // set by the caller + d->iLoop = 0; // set by the caller d->bOn = !!(dwChannelOn & (1<bStop = s->bStop; d->bReverb = s->bReverb; - d->iActFreq = s->iActFreq; - d->iUsedFreq = s->iUsedFreq; + d->iActFreq = 1; + d->iUsedFreq = 2; d->iLeftVolume = s->iLeftVolume; - d->bIgnoreLoop = s->bIgnoreLoop; + // this one is nasty but safe, save compat is important + d->bIgnoreLoop = (s->prevflags ^ 2) << 1; d->iRightVolume = s->iRightVolume; d->iRawPitch = s->iRawPitch; - d->s_1 = s->s_1; - d->s_2 = s->s_2; + d->s_1 = s->SB[27]; // yes it's reversed + d->s_2 = s->SB[26]; d->bRVBActive = s->bRVBActive; - d->iRVBOffset = s->iRVBOffset; - d->iRVBRepeat = s->iRVBRepeat; d->bNoise = s->bNoise; d->bFMod = s->bFMod; - d->iRVBNum = s->iRVBNum; - d->iOldNoise = s->iOldNoise; d->ADSRX.State = s->ADSRX.State; d->ADSRX.AttackModeExp = s->ADSRX.AttackModeExp; d->ADSRX.AttackRate = s->ADSRX.AttackRate; @@ -164,7 +160,7 @@ static void save_channel(SPUCHAN_orig *d, SPUCHAN *s, int ch) d->ADSRX.lVolume = d->bOn; // hmh } -static void load_channel(SPUCHAN *d, SPUCHAN_orig *s, int ch) +static void load_channel(SPUCHAN *d, const SPUCHAN_orig *s, int ch) { memset(d, 0, sizeof(*d)); if (s->bNew) dwNewChannel |= 1<spos = s->spos; d->sinc = s->sinc; memcpy(d->SB, s->SB, sizeof(d->SB)); - d->pStart = s->pStart; - d->pCurr = s->pCurr; - d->pLoop = s->pLoop; + d->pCurr = (void *)((long)s->iCurr & 0x7fff0); + d->pLoop = (void *)((long)s->iLoop & 0x7fff0); if (s->bOn) dwChannelOn |= 1<bStop = s->bStop; d->bReverb = s->bReverb; - d->iActFreq = s->iActFreq; - d->iUsedFreq = s->iUsedFreq; d->iLeftVolume = s->iLeftVolume; - d->bIgnoreLoop = s->bIgnoreLoop; d->iRightVolume = s->iRightVolume; d->iRawPitch = s->iRawPitch; - d->s_1 = s->s_1; - d->s_2 = s->s_2; d->bRVBActive = s->bRVBActive; - d->iRVBOffset = s->iRVBOffset; - d->iRVBRepeat = s->iRVBRepeat; d->bNoise = s->bNoise; d->bFMod = s->bFMod; - d->iRVBNum = s->iRVBNum; - d->iOldNoise = s->iOldNoise; + d->prevflags = (s->bIgnoreLoop >> 1) ^ 2; d->ADSRX.State = s->ADSRX.State; d->ADSRX.AttackModeExp = s->ADSRX.AttackModeExp; d->ADSRX.AttackRate = s->ADSRX.AttackRate; @@ -227,8 +214,6 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) if(ulFreezeMode==2) return 1; // info mode? ok, bye // save mode: - RemoveTimer(); // stop timer - memcpy(pF->cSPURam,spuMem,0x80000); // copy common infos memcpy(pF->cSPUPort,regArea,0x200); @@ -249,25 +234,22 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) for(i=0;is_chan[i],&s_chan[i],i); - if(pFO->s_chan[i].pStart) - pFO->s_chan[i].pStart-=(unsigned long)spuMemC; - if(pFO->s_chan[i].pCurr) - pFO->s_chan[i].pCurr-=(unsigned long)spuMemC; - if(pFO->s_chan[i].pLoop) - pFO->s_chan[i].pLoop-=(unsigned long)spuMemC; + if(s_chan[i].pCurr) + pFO->s_chan[i].iCurr=s_chan[i].pCurr-spuMemC; + if(s_chan[i].pLoop) + pFO->s_chan[i].iLoop=s_chan[i].pLoop-spuMemC; } - SetupTimer(); // sound processing on again - return 1; //--------------------------------------------------// } if(ulFreezeMode!=0) return 0; // bad mode? bye - RemoveTimer(); // we stop processing while doing the save! - memcpy(spuMem,pF->cSPURam,0x80000); // get ram memcpy(regArea,pF->cSPUPort,0x200); @@ -297,7 +279,7 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) // fix to prevent new interpolations from crashing for(i=0;ispuIrq; - if(pFO->pSpuIrq) pSpuIrq = pFO->pSpuIrq+spuMemC; else pSpuIrq=NULL; + if(pFO->pSpuIrq) pSpuIrq = spuMemC+((long)pFO->pSpuIrq&0x7fff0); else pSpuIrq=NULL; if(pFO->spuAddr) { @@ -321,11 +303,11 @@ void LoadStateV5(SPUFreeze_t * pF) dwNewChannel=0; dwChannelOn=0; + dwChannelDead=0; for(i=0;is_chan[i],i); - s_chan[i].pStart+=(unsigned long)spuMemC; s_chan[i].pCurr+=(unsigned long)spuMemC; s_chan[i].pLoop+=(unsigned long)spuMemC; } @@ -341,12 +323,11 @@ void LoadStateUnknown(SPUFreeze_t * pF) { s_chan[i].bStop=0; s_chan[i].pLoop=spuMemC; - s_chan[i].pStart=spuMemC; - s_chan[i].pLoop=spuMemC; } dwNewChannel=0; dwChannelOn=0; + dwChannelDead=0; pSpuIrq=0; for(i=0;i<0xc0;i++)