X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fregisters.c;h=83b9e438f95555686896d4833d532a68d4728bbb;hp=5ab519b86fa479822f06244f5e7558d3e936ec1e;hb=1775933abd26d2e282c4e0b4093778d204a0038d;hpb=b00afb7734d75d4e625db0263548fa15b9aa0af7 diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index 5ab519b8..83b9e438 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -22,7 +22,6 @@ #include "externals.h" #include "registers.h" #include "regs.h" -#include "reverb.h" /* // adsr time values (in ms) by James Higgs ... see the end of @@ -76,13 +75,14 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) //------------------------------------------------// level with pre-calcs case 8: { - const unsigned long lval=val;unsigned long lx; + 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; //---------------------------------------------// +#if 0 if(!iDebugMode) break; //---------------------------------------------// stuff below is only for debug mode @@ -110,12 +110,13 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) } s_chan[ch].ADSR.DecayTime = // so calc how long does it take to run from 100% to the wanted sus level (lx*(1024-s_chan[ch].ADSR.SustainLevel))/1024; +#endif } break; //------------------------------------------------// adsr times with pre-calcs case 10: { - const unsigned long lval=val;unsigned long lx; + const unsigned long lval=val; //----------------------------------------------// s_chan[ch].ADSRX.SustainModeExp = (lval&0x8000)?1:0; @@ -124,6 +125,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) s_chan[ch].ADSRX.ReleaseModeExp = (lval&0x0020)?1:0; s_chan[ch].ADSRX.ReleaseRate = lval & 0x001f; //----------------------------------------------// +#if 0 if(!iDebugMode) break; //----------------------------------------------// stuff below is only for debug mode @@ -155,6 +157,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) if(lval & 0x4000) // add/dec flag s_chan[ch].ADSR.SustainModeDec=-1; else s_chan[ch].ADSR.SustainModeDec=1; +#endif } break; //------------------------------------------------// adsr volume... mmm have to investigate this @@ -164,7 +167,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) case 14: // loop? //WaitForSingleObject(s_chan[ch].hMutex,2000); // -> no multithread fuckups s_chan[ch].pLoop=spuMemC+((unsigned long)((val<<3)&~0xf)); - s_chan[ch].bIgnoreLoop=1; + //s_chan[ch].bIgnoreLoop=1; //ReleaseMutex(s_chan[ch].hMutex); // -> oki, on with the thread break; //------------------------------------------------// @@ -187,6 +190,8 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) break; //-------------------------------------------------// case H_SPUctrl: + if(!(spuCtrl & CTRL_IRQ)) + spuStat&=~STAT_IRQ; spuCtrl=val; break; //-------------------------------------------------// @@ -206,11 +211,12 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) rvb.CurrAddr=rvb.StartAddr; } } + rvb.dirty = 1; break; //-------------------------------------------------// case H_SPUirqAddr: spuIrq = val; - pSpuIrq=spuMemC+((unsigned long) val<<3); + pSpuIrq=spuMemC+(((unsigned long) val<<3)&~0xf); break; //-------------------------------------------------// case H_SPUrvolL: @@ -297,19 +303,8 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) ReverbOn(16,24,val); break; //-------------------------------------------------// - case H_Reverb+0: - - rvb.FB_SRC_A=val; - - // OK, here's the fake REVERB stuff... - // depending on effect we do more or less delay and repeats... bah - // still... better than nothing :) - - SetREVERB(val); - break; - - - case H_Reverb+2 : rvb.FB_SRC_B=(short)val; break; + case H_Reverb+0 : rvb.FB_SRC_A=val*4; break; + case H_Reverb+2 : rvb.FB_SRC_B=val*4; break; case H_Reverb+4 : rvb.IIR_ALPHA=(short)val; break; case H_Reverb+6 : rvb.ACC_COEF_A=(short)val; break; case H_Reverb+8 : rvb.ACC_COEF_B=(short)val; break; @@ -318,30 +313,33 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) case H_Reverb+14 : rvb.IIR_COEF=(short)val; break; case H_Reverb+16 : rvb.FB_ALPHA=(short)val; break; case H_Reverb+18 : rvb.FB_X=(short)val; break; - case H_Reverb+20 : rvb.IIR_DEST_A0=(short)val; break; - case H_Reverb+22 : rvb.IIR_DEST_A1=(short)val; break; - case H_Reverb+24 : rvb.ACC_SRC_A0=(short)val; break; - case H_Reverb+26 : rvb.ACC_SRC_A1=(short)val; break; - case H_Reverb+28 : rvb.ACC_SRC_B0=(short)val; break; - case H_Reverb+30 : rvb.ACC_SRC_B1=(short)val; break; - case H_Reverb+32 : rvb.IIR_SRC_A0=(short)val; break; - case H_Reverb+34 : rvb.IIR_SRC_A1=(short)val; break; - case H_Reverb+36 : rvb.IIR_DEST_B0=(short)val; break; - case H_Reverb+38 : rvb.IIR_DEST_B1=(short)val; break; - case H_Reverb+40 : rvb.ACC_SRC_C0=(short)val; break; - case H_Reverb+42 : rvb.ACC_SRC_C1=(short)val; break; - case H_Reverb+44 : rvb.ACC_SRC_D0=(short)val; break; - case H_Reverb+46 : rvb.ACC_SRC_D1=(short)val; break; - case H_Reverb+48 : rvb.IIR_SRC_B1=(short)val; break; - case H_Reverb+50 : rvb.IIR_SRC_B0=(short)val; break; - case H_Reverb+52 : rvb.MIX_DEST_A0=(short)val; break; - case H_Reverb+54 : rvb.MIX_DEST_A1=(short)val; break; - case H_Reverb+56 : rvb.MIX_DEST_B0=(short)val; break; - case H_Reverb+58 : rvb.MIX_DEST_B1=(short)val; break; + case H_Reverb+20 : rvb.IIR_DEST_A0=val*4; break; + case H_Reverb+22 : rvb.IIR_DEST_A1=val*4; break; + case H_Reverb+24 : rvb.ACC_SRC_A0=val*4; break; + case H_Reverb+26 : rvb.ACC_SRC_A1=val*4; break; + case H_Reverb+28 : rvb.ACC_SRC_B0=val*4; break; + case H_Reverb+30 : rvb.ACC_SRC_B1=val*4; break; + case H_Reverb+32 : rvb.IIR_SRC_A0=val*4; break; + case H_Reverb+34 : rvb.IIR_SRC_A1=val*4; break; + case H_Reverb+36 : rvb.IIR_DEST_B0=val*4; break; + case H_Reverb+38 : rvb.IIR_DEST_B1=val*4; break; + case H_Reverb+40 : rvb.ACC_SRC_C0=val*4; break; + case H_Reverb+42 : rvb.ACC_SRC_C1=val*4; break; + case H_Reverb+44 : rvb.ACC_SRC_D0=val*4; break; + case H_Reverb+46 : rvb.ACC_SRC_D1=val*4; break; + case H_Reverb+48 : rvb.IIR_SRC_B1=val*4; break; + case H_Reverb+50 : rvb.IIR_SRC_B0=val*4; break; + case H_Reverb+52 : rvb.MIX_DEST_A0=val*4; break; + case H_Reverb+54 : rvb.MIX_DEST_A1=val*4; break; + case H_Reverb+56 : rvb.MIX_DEST_B0=val*4; break; + case H_Reverb+58 : rvb.MIX_DEST_B1=val*4; break; case H_Reverb+60 : rvb.IN_COEF_L=(short)val; break; case H_Reverb+62 : rvb.IN_COEF_R=(short)val; break; } + if ((r & ~0x3f) == H_Reverb) + rvb.dirty = 1; // recalculate on next update + iSpuAsyncWait=0; } @@ -362,9 +360,9 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg) case 12: // get adsr vol { const int ch=(r>>4)-0xc0; - if(s_chan[ch].bNew) return 1; // we are started, but not processed? return 1 - if(s_chan[ch].ADSRX.lVolume && // same here... we haven't decoded one sample yet, so no envelope yet. return 1 as well - !s_chan[ch].ADSRX.EnvelopeVol) + if(dwNewChannel&(1<>16); } @@ -372,7 +370,6 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg) case 14: // get loop address { const int ch=(r>>4)-0xc0; - if(s_chan[ch].pLoop==NULL) return 0; return (unsigned short)((s_chan[ch].pLoop-spuMemC)>>3); } } @@ -424,15 +421,14 @@ void SoundOn(int start,int end,unsigned short val) // SOUND ON PSX COMAND if((val&1) && s_chan[ch].pStart) // mmm... start has to be set before key on !?! { s_chan[ch].bIgnoreLoop=0; - s_chan[ch].bNew=1; // do this here, not in StartSound // - fixes fussy timing issues s_chan[ch].bStop=0; - s_chan[ch].bOn=1; s_chan[ch].pCurr=s_chan[ch].pStart; dwNewChannel|=(1< turn off fmod + if(ch>0&&s_chan[ch-1].bFMod==2) + s_chan[ch-1].bFMod=0; } } } @@ -493,14 +490,7 @@ void NoiseOn(int start,int end,unsigned short val) // NOISE ON PSX COMMAND for(ch=start;ch>=1) // loop channels { - if(val&1) // -> noise on/off - { - s_chan[ch].bNoise=1; - } - else - { - s_chan[ch].bNoise=0; - } + s_chan[ch].bNoise=val&1; // -> noise on/off } } @@ -513,8 +503,6 @@ void NoiseOn(int start,int end,unsigned short val) // NOISE ON PSX COMMAND void SetVolumeL(unsigned char ch,short vol) // LEFT VOLUME { - s_chan[ch].iLeftVolRaw=vol; - if(vol&0x8000) // sweep? { short sInc=1; // -> sweep up? @@ -541,8 +529,6 @@ void SetVolumeL(unsigned char ch,short vol) // LEFT VOLUME void SetVolumeR(unsigned char ch,short vol) // RIGHT VOLUME { - s_chan[ch].iRightVolRaw=vol; - if(vol&0x8000) // comments... see above :) { short sInc=1; @@ -590,13 +576,6 @@ void ReverbOn(int start,int end,unsigned short val) // REVERB ON PSX COMMAND for(ch=start;ch>=1) // loop channels { - if(val&1) // -> reverb on/off - { - s_chan[ch].bReverb=1; - } - else - { - s_chan[ch].bReverb=0; - } + s_chan[ch].bReverb=val&1; // -> reverb on/off } }