X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fregisters.c;h=20a7c140ca338c81f0916dd8d2bb04b82dd2148e;hp=b9c1256a11d1a6ff8f6e6fc356026eee68769b2b;hb=54933c929d2e418e925ae823e3fa7607b2d5ac85;hpb=f05d6ca255c80170e4e5fc61cc48d87e013b8807 diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index b9c1256a..20a7c140 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -35,10 +35,28 @@ static void ReverbOn(int start,int end,unsigned short val); // WRITE REGISTERS: called by main emu //////////////////////////////////////////////////////////////////////// -void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) +static const uint32_t ignore_dupe[8] = { + // ch 0-15 c40 c80 cc0 + 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, + // ch 16-24 d40 control reverb + 0x7f7f7f7f, 0x7f7f7f7f, 0xff05ff0f, 0xffffffff +}; + +void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, + unsigned int cycles) { - const unsigned long r=reg&0xfff; - regArea[(r-0xc00)>>1] = val; + int r = reg & 0xfff; + int rofs = (r - 0xc00) >> 1; + int changed = regArea[rofs] != val; + regArea[rofs] = val; + + if (!changed && (ignore_dupe[rofs >> 5] & (1 << (rofs & 0x1f)))) + return; + // zero keyon/keyoff? + if (val == 0 && (r & 0xff8) == 0xd88) + return; + + do_samples_if_needed(cycles); if(r>=0x0c00 && r<0x0d80) // some channel info? { @@ -56,7 +74,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) //------------------------------------------------// pitch case 4: SetPitch(ch,val); - break; + goto upd_irq; //------------------------------------------------// start case 6: // taken from regArea later @@ -93,7 +111,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) //------------------------------------------------// case 14: // loop? s_chan[ch].pLoop=spuMemC+((val&~1)<<3); - break; + goto upd_irq; //------------------------------------------------// } return; @@ -113,8 +131,11 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) break; //-------------------------------------------------// case H_SPUctrl: - if(!(spuCtrl & CTRL_IRQ)) + if (!(spuCtrl & CTRL_IRQ)) { spuStat&=~STAT_IRQ; + if (val & CTRL_IRQ) + schedule_next_irq(); + } spuCtrl=val; break; //-------------------------------------------------// @@ -132,18 +153,14 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) { rvb.StartAddr=(unsigned long)val<<2; rvb.CurrAddr=rvb.StartAddr; - // sync-with-decode-buffers hack.. - if(rvb.StartAddr==0x3ff00) - rvb.CurrAddr+=decode_pos/2; } } - rvb.dirty = 1; - break; + goto rvbd; //-------------------------------------------------// case H_SPUirqAddr: spuIrq = val; pSpuIrq=spuMemC+(((unsigned long) val<<3)&~0xf); - break; + goto upd_irq; //-------------------------------------------------// case H_SPUrvolL: rvb.VolLeft=val; @@ -229,42 +246,48 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) ReverbOn(16,24,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; - case H_Reverb+10 : rvb.ACC_COEF_C=(short)val; break; - case H_Reverb+12 : rvb.ACC_COEF_D=(short)val; break; - 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=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; + 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; } + return; + +upd_irq: + if (spuCtrl & CTRL_IRQ) + schedule_next_irq(); + return; - if ((r & ~0x3f) == H_Reverb) - rvb.dirty = 1; // recalculate on next update +rvbd: + rvb.dirty = 1; // recalculate on next update } //////////////////////////////////////////////////////////////////////// @@ -484,6 +507,7 @@ static void SetPitch(int ch,unsigned short val) // SET PITCH s_chan[ch].iRawPitch=NP; s_chan[ch].sinc=(NP<<4)|8; + s_chan[ch].sinc_inv=0; if(iUseInterpolation==1) s_chan[ch].SB[32]=1; // -> freq change in simple interpolation mode: set flag }