X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fregisters.c;h=bb64658d7f96f4a68ed426bebc8ad969f0046b3d;hp=e65d112af6e6aff9d8fdd65478258527510730da;hb=c2502333b2e56e520bb9ecc2f931a639eee415d7;hpb=63a4f6b6a3b0315590cd3009df2c92480ed2d98b diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index e65d112a..bb64658d 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -85,10 +85,10 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, { const unsigned long lval=val; //---------------------------------------------// - s_chan[ch].ADSRX.AttackModeExp=(lval&0x8000)?1:0; - s_chan[ch].ADSRX.AttackRate=(lval>>8) & 0x007f; - s_chan[ch].ADSRX.DecayRate=(lval>>4) & 0x000f; - s_chan[ch].ADSRX.SustainLevel=lval & 0x000f; + spu.s_chan[ch].ADSRX.AttackModeExp=(lval&0x8000)?1:0; + spu.s_chan[ch].ADSRX.AttackRate=(lval>>8) & 0x007f; + spu.s_chan[ch].ADSRX.DecayRate=(lval>>4) & 0x000f; + spu.s_chan[ch].ADSRX.SustainLevel=lval & 0x000f; //---------------------------------------------// } break; @@ -98,11 +98,11 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, const unsigned long lval=val; //----------------------------------------------// - s_chan[ch].ADSRX.SustainModeExp = (lval&0x8000)?1:0; - s_chan[ch].ADSRX.SustainIncrease= (lval&0x4000)?0:1; - s_chan[ch].ADSRX.SustainRate = (lval>>6) & 0x007f; - s_chan[ch].ADSRX.ReleaseModeExp = (lval&0x0020)?1:0; - s_chan[ch].ADSRX.ReleaseRate = lval & 0x001f; + spu.s_chan[ch].ADSRX.SustainModeExp = (lval&0x8000)?1:0; + spu.s_chan[ch].ADSRX.SustainIncrease= (lval&0x4000)?0:1; + spu.s_chan[ch].ADSRX.SustainRate = (lval>>6) & 0x007f; + spu.s_chan[ch].ADSRX.ReleaseModeExp = (lval&0x0020)?1:0; + spu.s_chan[ch].ADSRX.ReleaseRate = lval & 0x001f; //----------------------------------------------// } break; @@ -111,7 +111,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, break; //------------------------------------------------// case 14: // loop? - s_chan[ch].pLoop=spu.spuMemC+((val&~1)<<3); + spu.s_chan[ch].pLoop=spu.spuMemC+((val&~1)<<3); goto upd_irq; //------------------------------------------------// } @@ -126,9 +126,9 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, break; //-------------------------------------------------// case H_SPUdata: - spu.spuMem[spu.spuAddr>>1] = val; - spu.spuAddr+=2; - if(spu.spuAddr>0x7ffff) spu.spuAddr=0; + *(unsigned short *)(spu.spuMemC + spu.spuAddr) = val; + spu.spuAddr += 2; + spu.spuAddr &= 0x7fffe; break; //-------------------------------------------------// case H_SPUctrl: @@ -145,17 +145,6 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, break; //-------------------------------------------------// case H_SPUReverbAddr: - if(val==0xFFFF || val<=0x200) - {rvb.StartAddr=rvb.CurrAddr=0;} - else - { - const long iv=(unsigned long)val<<2; - if(rvb.StartAddr!=iv) - { - rvb.StartAddr=(unsigned long)val<<2; - rvb.CurrAddr=rvb.StartAddr; - } - } goto rvbd; //-------------------------------------------------// case H_SPUirqAddr: @@ -163,11 +152,11 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, goto upd_irq; //-------------------------------------------------// case H_SPUrvolL: - rvb.VolLeft=val; + spu.rvb->VolLeft=val; break; //-------------------------------------------------// case H_SPUrvolR: - rvb.VolRight=val; + spu.rvb->VolRight=val; break; //-------------------------------------------------// @@ -246,38 +235,38 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, ReverbOn(16,24,val); break; //-------------------------------------------------// - case H_Reverb+0 : rvb.FB_SRC_A=val*4; goto rvbd; - case H_Reverb+2 : rvb.FB_SRC_B=val*4; goto rvbd; - case H_Reverb+4 : rvb.IIR_ALPHA=(short)val; goto rvbd; - case H_Reverb+6 : rvb.ACC_COEF_A=(short)val; goto rvbd; - case H_Reverb+8 : rvb.ACC_COEF_B=(short)val; goto rvbd; - case H_Reverb+10 : rvb.ACC_COEF_C=(short)val; goto rvbd; - case H_Reverb+12 : rvb.ACC_COEF_D=(short)val; goto rvbd; - case H_Reverb+14 : rvb.IIR_COEF=(short)val; goto rvbd; - case H_Reverb+16 : rvb.FB_ALPHA=(short)val; goto rvbd; - case H_Reverb+18 : rvb.FB_X=(short)val; goto rvbd; - case H_Reverb+20 : rvb.IIR_DEST_A0=val*4; goto rvbd; - case H_Reverb+22 : rvb.IIR_DEST_A1=val*4; goto rvbd; - case H_Reverb+24 : rvb.ACC_SRC_A0=val*4; goto rvbd; - case H_Reverb+26 : rvb.ACC_SRC_A1=val*4; goto rvbd; - case H_Reverb+28 : rvb.ACC_SRC_B0=val*4; goto rvbd; - case H_Reverb+30 : rvb.ACC_SRC_B1=val*4; goto rvbd; - case H_Reverb+32 : rvb.IIR_SRC_A0=val*4; goto rvbd; - case H_Reverb+34 : rvb.IIR_SRC_A1=val*4; goto rvbd; - case H_Reverb+36 : rvb.IIR_DEST_B0=val*4; goto rvbd; - case H_Reverb+38 : rvb.IIR_DEST_B1=val*4; goto rvbd; - case H_Reverb+40 : rvb.ACC_SRC_C0=val*4; goto rvbd; - case H_Reverb+42 : rvb.ACC_SRC_C1=val*4; goto rvbd; - case H_Reverb+44 : rvb.ACC_SRC_D0=val*4; goto rvbd; - case H_Reverb+46 : rvb.ACC_SRC_D1=val*4; goto rvbd; - case H_Reverb+48 : rvb.IIR_SRC_B1=val*4; goto rvbd; - case H_Reverb+50 : rvb.IIR_SRC_B0=val*4; goto rvbd; - case H_Reverb+52 : rvb.MIX_DEST_A0=val*4; goto rvbd; - case H_Reverb+54 : rvb.MIX_DEST_A1=val*4; goto rvbd; - case H_Reverb+56 : rvb.MIX_DEST_B0=val*4; goto rvbd; - case H_Reverb+58 : rvb.MIX_DEST_B1=val*4; goto rvbd; - case H_Reverb+60 : rvb.IN_COEF_L=(short)val; goto rvbd; - case H_Reverb+62 : rvb.IN_COEF_R=(short)val; goto rvbd; + case H_Reverb+0 : goto rvbd; + case H_Reverb+2 : goto rvbd; + case H_Reverb+4 : spu.rvb->IIR_ALPHA=(short)val; break; + case H_Reverb+6 : spu.rvb->ACC_COEF_A=(short)val; break; + case H_Reverb+8 : spu.rvb->ACC_COEF_B=(short)val; break; + case H_Reverb+10 : spu.rvb->ACC_COEF_C=(short)val; break; + case H_Reverb+12 : spu.rvb->ACC_COEF_D=(short)val; break; + case H_Reverb+14 : spu.rvb->IIR_COEF=(short)val; break; + case H_Reverb+16 : spu.rvb->FB_ALPHA=(short)val; break; + case H_Reverb+18 : spu.rvb->FB_X=(short)val; break; + case H_Reverb+20 : goto rvbd; + case H_Reverb+22 : goto rvbd; + case H_Reverb+24 : goto rvbd; + case H_Reverb+26 : goto rvbd; + case H_Reverb+28 : goto rvbd; + case H_Reverb+30 : goto rvbd; + case H_Reverb+32 : goto rvbd; + case H_Reverb+34 : goto rvbd; + case H_Reverb+36 : goto rvbd; + case H_Reverb+38 : goto rvbd; + case H_Reverb+40 : goto rvbd; + case H_Reverb+42 : goto rvbd; + case H_Reverb+44 : goto rvbd; + case H_Reverb+46 : goto rvbd; + case H_Reverb+48 : goto rvbd; + case H_Reverb+50 : goto rvbd; + case H_Reverb+52 : goto rvbd; + case H_Reverb+54 : goto rvbd; + case H_Reverb+56 : goto rvbd; + case H_Reverb+58 : goto rvbd; + case H_Reverb+60 : spu.rvb->IN_COEF_L=(short)val; break; + case H_Reverb+62 : spu.rvb->IN_COEF_R=(short)val; break; } return; @@ -287,7 +276,7 @@ upd_irq: return; rvbd: - rvb.dirty = 1; // recalculate on next update + spu.rvb->dirty = 1; // recalculate on next update } //////////////////////////////////////////////////////////////////////// @@ -307,15 +296,15 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg) const int ch=(r>>4)-0xc0; if(spu.dwNewChannel&(1<>16); + return (unsigned short)(spu.s_chan[ch].ADSRX.EnvelopeVol>>16); } case 14: // get loop address { const int ch=(r>>4)-0xc0; - return (unsigned short)((s_chan[ch].pLoop-spu.spuMemC)>>3); + return (unsigned short)((spu.s_chan[ch].pLoop-spu.spuMemC)>>3); } } } @@ -333,9 +322,9 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg) case H_SPUdata: { - unsigned short s=spu.spuMem[spu.spuAddr>>1]; - spu.spuAddr+=2; - if(spu.spuAddr>0x7ffff) spu.spuAddr=0; + unsigned short s = *(unsigned short *)(spu.spuMemC + spu.spuAddr); + spu.spuAddr += 2; + spu.spuAddr &= 0x7fffe; return s; } @@ -362,8 +351,8 @@ static void SoundOn(int start,int end,unsigned short val) { if((val&1) && regAreaGet(ch,6)) // mmm... start has to be set before key on !?! { - s_chan[ch].pCurr=spu.spuMemC+((regAreaGet(ch,6)&~1)<<3); // must be block aligned - s_chan[ch].pLoop=spu.spuMemC+((regAreaGet(ch,14)&~1)<<3); + spu.s_chan[ch].pCurr=spu.spuMemC+((regAreaGet(ch,6)&~1)<<3); // must be block aligned + if (spu_config.idiablofix == 0) spu.s_chan[ch].pLoop=spu.spuMemC+((regAreaGet(ch,14)&~1)<<3); spu.dwNewChannel|=(1<0) { - s_chan[ch].bFMod=1; // --> sound channel - s_chan[ch-1].bFMod=2; // --> freq channel + spu.s_chan[ch].bFMod=1; // --> sound channel + spu.s_chan[ch-1].bFMod=2; // --> freq channel } } else { - s_chan[ch].bFMod=0; // --> turn off fmod - if(ch>0&&s_chan[ch-1].bFMod==2) - s_chan[ch-1].bFMod=0; + spu.s_chan[ch].bFMod=0; // --> turn off fmod + if(ch>0&&spu.s_chan[ch-1].bFMod==2) + spu.s_chan[ch-1].bFMod=0; } } } @@ -426,7 +415,7 @@ static void NoiseOn(int start,int end,unsigned short val) for(ch=start;ch>=1) // loop channels { - s_chan[ch].bNoise=val&1; // -> noise on/off + spu.s_chan[ch].bNoise=val&1; // -> noise on/off } } @@ -456,7 +445,7 @@ static void SetVolumeL(unsigned char ch,short vol) // LEFT VOLUME } vol&=0x3fff; - s_chan[ch].iLeftVolume=vol; // store volume + spu.s_chan[ch].iLeftVolume=vol; // store volume } //////////////////////////////////////////////////////////////////////// @@ -482,7 +471,7 @@ static void SetVolumeR(unsigned char ch,short vol) // RIGHT VOLUME vol&=0x3fff; - s_chan[ch].iRightVolume=vol; + spu.s_chan[ch].iRightVolume=vol; } //////////////////////////////////////////////////////////////////////// @@ -495,10 +484,11 @@ static void SetPitch(int ch,unsigned short val) // SET PITCH if(val>0x3fff) NP=0x3fff; // get pitch val else NP=val; - s_chan[ch].iRawPitch=NP; - s_chan[ch].sinc=(NP<<4)|8; - s_chan[ch].sinc_inv=0; - if(spu_config.iUseInterpolation==1) s_chan[ch].SB[32]=1; // -> freq change in simple interpolation mode: set flag + spu.s_chan[ch].iRawPitch=NP; + spu.s_chan[ch].sinc=(NP<<4)|8; + spu.s_chan[ch].sinc_inv=0; + if (spu_config.iUseInterpolation == 1) + spu.SB[ch * SB_SIZE + 32] = 1; // -> freq change in simple interpolation mode: set flag } //////////////////////////////////////////////////////////////////////// @@ -511,6 +501,6 @@ static void ReverbOn(int start,int end,unsigned short val) for(ch=start;ch>=1) // loop channels { - s_chan[ch].bReverb=val&1; // -> reverb on/off + spu.s_chan[ch].bReverb=val&1; // -> reverb on/off } }