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=d09a9b00ea83643bd341af249c55931f5d812bb1;hb=8e1040b6a82ee1802fda83d4de84290a02656cc0;hpb=174c454a98a71475b72958c9f76293af7d6fb502 diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index d09a9b00..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) @@ -129,16 +128,17 @@ static void save_channel(SPUCHAN_orig *d, const SPUCHAN *s, int ch) d->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->SB[27]; // yes it's reversed @@ -168,21 +168,18 @@ static void load_channel(SPUCHAN *d, const SPUCHAN_orig *s, int ch) d->spos = s->spos; d->sinc = s->sinc; memcpy(d->SB, s->SB, sizeof(d->SB)); - d->pStart = (void *)((long)s->pStart & 0x7fff0); - d->pCurr = (void *)((long)s->pCurr & 0x7fff0); - d->pLoop = (void *)((long)s->pLoop & 0x7fff0); + 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->bRVBActive = s->bRVBActive; d->bNoise = s->bNoise; d->bFMod = s->bFMod; + d->prevflags = (s->bIgnoreLoop >> 1) ^ 2; d->ADSRX.State = s->ADSRX.State; d->ADSRX.AttackModeExp = s->ADSRX.AttackModeExp; d->ADSRX.AttackRate = s->ADSRX.AttackRate; @@ -217,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); @@ -237,30 +232,24 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) pFO->spuAddr=spuAddr; if(pFO->spuAddr==0) pFO->spuAddr=0xbaadf00d; - dwChannelOn&=~dwPendingChanOff; - dwPendingChanOff=0; - 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); @@ -268,7 +257,6 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) SPUplayADPCMchannel(&pF->xaS); xapGlobal=0; - dwPendingChanOff=0; if(!strcmp(pF->szSPUName,"PBOSS") && pF->ulFreezeVersion==5) LoadStateV5(pF); @@ -291,7 +279,7 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) // fix to prevent new interpolations from crashing 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; } @@ -336,8 +323,6 @@ 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;