X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Ffreeze.c;h=0601bf5c0c0353c491b83e5d6b91948512603f77;hp=ec097c5be8139ed60fbdcbbba9dc6fe66777e425;hb=6f6fe96900374d8744473ce240279e66d1260191;hpb=e4f075af4e4ba79332c72809d3bb4ba6e2895253 diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index ec097c5b..0601bf5c 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -27,6 +27,24 @@ // freeze structs //////////////////////////////////////////////////////////////////////// +typedef struct +{ + int AttackModeExp; + int AttackTime; + int DecayTime; + int SustainLevel; + int SustainModeExp; + int SustainModeDec; + int SustainTime; + int ReleaseModeExp; + unsigned int ReleaseVal; + int ReleaseTime; + int ReleaseStartTime; + int ReleaseVol; + int lTime; + int lVolume; +} ADSRInfo; + typedef struct { int State; @@ -40,9 +58,9 @@ typedef struct int ReleaseModeExp; int ReleaseRate; int EnvelopeVol; - long lVolume; - long lDummy1; - long lDummy2; + int lVolume; + int lDummy1; + int lDummy2; } ADSRInfoEx_orig; typedef struct @@ -58,9 +76,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) @@ -128,9 +146,9 @@ 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 = (unsigned char *)((regAreaGet(ch,6)&~1)<<3); - 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; @@ -168,9 +186,8 @@ 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->pCurr = (void *)((long)s->pCurr & 0x7fff0); - d->pLoop = (void *)((long)s->pLoop & 0x7fff0); - if (s->bOn) dwChannelOn |= 1<pCurr = (void *)((long)s->iCurr & 0x7fff0); + d->pLoop = (void *)((long)s->iLoop & 0x7fff0); d->bStop = s->bStop; d->bReverb = s->bReverb; d->iLeftVolume = s->iLeftVolume; @@ -191,6 +208,8 @@ static void load_channel(SPUCHAN *d, const SPUCHAN_orig *s, int ch) d->ADSRX.ReleaseModeExp = s->ADSRX.ReleaseModeExp; d->ADSRX.ReleaseRate = s->ADSRX.ReleaseRate; d->ADSRX.EnvelopeVol = s->ADSRX.EnvelopeVol; + if (s->bOn) dwChannelOn |= 1<ADSRX.EnvelopeVol = 0; } //////////////////////////////////////////////////////////////////////// @@ -234,14 +253,11 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) for(i=0;is_chan[i],&s_chan[i],i); - 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; } return 1;