X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fdfsound%2Fregisters.c;h=e00939e6a9434d9a52b16ace4f5f802721526f74;hb=HEAD;hp=2796f9c3f5b5bc1b189ca205f78724ba9e3836e4;hpb=38e4048faeaccf7fdc6084f64866f2ea52bb97f1;p=pcsx_rearmed.git diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index 2796f9c3..5565317d 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -54,7 +54,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, int changed = spu.regArea[rofs] != val; spu.regArea[rofs] = val; - if (!changed && (ignore_dupe[rofs >> 5] & (1 << (rofs & 0x1f)))) + if (!changed && (ignore_dupe[rofs >> 5] & (1u << (rofs & 0x1f)))) return; // zero keyon/keyoff? if (val == 0 && (r & 0xff8) == 0xd88) @@ -132,7 +132,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, { //-------------------------------------------------// case H_SPUaddr: - spu.spuAddr = (unsigned long) val<<3; + spu.spuAddr = (unsigned int)val << 3; //check_irq_io(spu.spuAddr); break; //-------------------------------------------------// @@ -144,8 +144,9 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, break; //-------------------------------------------------// case H_SPUctrl: + spu.spuStat = (spu.spuStat & ~0xbf) | (val & 0x3f) | ((val << 2) & 0x80); + spu.spuStat &= ~STAT_IRQ | val; if (!(spu.spuCtrl & CTRL_IRQ)) { - spu.spuStat&=~STAT_IRQ; if (val & CTRL_IRQ) schedule_next_irq(); } @@ -153,7 +154,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, break; //-------------------------------------------------// case H_SPUstat: - spu.spuStat=val&0xf800; + //spu.spuStat=val&0xf800; break; //-------------------------------------------------// case H_SPUReverbAddr: @@ -167,19 +168,30 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, goto upd_irq; //-------------------------------------------------// case H_SPUrvolL: - spu.rvb->VolLeft=val; + spu.rvb->VolLeft = (int16_t)val; break; //-------------------------------------------------// case H_SPUrvolR: - spu.rvb->VolRight=val; + spu.rvb->VolRight = (int16_t)val; break; //-------------------------------------------------// case H_SPUmvolL: - case H_SPUmvolR: - if (val & 0x8000) + case H_SPUmvolR: { + int ofs = H_SPUcmvolL - H_SPUmvolL; + unsigned short *cur = ®AreaGet(r + ofs); + if (val & 0x8000) { + // this (for now?) lacks an update mechanism, so is instant log_unhandled("w master sweep: %08lx %04x\n", reg, val); + int was_neg = (*cur >> 14) & 1; + int dec = (val >> 13) & 1; + int inv = (val >> 12) & 1; + *cur = (was_neg ^ dec ^ inv) ? 0x7fff : 0; + } + else + *cur = val << 1; break; + } case 0x0dac: if (val != 4) @@ -195,14 +207,6 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, //auxprintf("ER %d\n",val); break; //-------------------------------------------------// - case H_SPUmvolL: - //auxprintf("ML %d\n",val); - break; - //-------------------------------------------------// - case H_SPUmvolR: - //auxprintf("MR %d\n",val); - break; - //-------------------------------------------------// case H_SPUMute1: //auxprintf("M0 %04x\n",val); break; @@ -213,30 +217,44 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, */ //-------------------------------------------------// case H_SPUon1: + spu.last_keyon_cycles = cycles; do_samples_if_needed(cycles, 0, 2); SoundOn(0,16,val); break; //-------------------------------------------------// case H_SPUon2: + spu.last_keyon_cycles = cycles; do_samples_if_needed(cycles, 0, 2); SoundOn(16,24,val); break; //-------------------------------------------------// case H_SPUoff1: + if (cycles - spu.last_keyon_cycles < 786u) { + if (val & regAreaGet(H_SPUon1)) + log_unhandled("koff1 %04x %d\n", val, cycles - spu.last_keyon_cycles); + val &= ~regAreaGet(H_SPUon1); + } + do_samples_if_needed(cycles, 0, 2); SoundOff(0,16,val); break; //-------------------------------------------------// case H_SPUoff2: + if (cycles - spu.last_keyon_cycles < 786u) { + if (val & regAreaGet(H_SPUon1)) + log_unhandled("koff2 %04x %d\n", val, cycles - spu.last_keyon_cycles); + val &= ~regAreaGet(H_SPUon2); + } + do_samples_if_needed(cycles, 0, 2); SoundOff(16,24,val); break; //-------------------------------------------------// case H_CDLeft: spu.iLeftXAVol=(int16_t)val; - if(spu.cddavCallback) spu.cddavCallback(0,(int16_t)val); + //if(spu.cddavCallback) spu.cddavCallback(0,(int16_t)val); break; case H_CDRight: spu.iRightXAVol=(int16_t)val; - if(spu.cddavCallback) spu.cddavCallback(1,(int16_t)val); + //if(spu.cddavCallback) spu.cddavCallback(1,(int16_t)val); break; //-------------------------------------------------// case H_FMod1: @@ -263,38 +281,38 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, ReverbOn(16,24,val); break; //-------------------------------------------------// - 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; + case H_Reverb + 0x00 : goto rvbd; + case H_Reverb + 0x02 : goto rvbd; + case H_Reverb + 0x04 : spu.rvb->vIIR = (signed short)val; break; + case H_Reverb + 0x06 : spu.rvb->vCOMB1 = (signed short)val; break; + case H_Reverb + 0x08 : spu.rvb->vCOMB2 = (signed short)val; break; + case H_Reverb + 0x0a : spu.rvb->vCOMB3 = (signed short)val; break; + case H_Reverb + 0x0c : spu.rvb->vCOMB4 = (signed short)val; break; + case H_Reverb + 0x0e : spu.rvb->vWALL = (signed short)val; break; + case H_Reverb + 0x10 : spu.rvb->vAPF1 = (signed short)val; break; + case H_Reverb + 0x12 : spu.rvb->vAPF2 = (signed short)val; break; + case H_Reverb + 0x14 : goto rvbd; + case H_Reverb + 0x16 : goto rvbd; + case H_Reverb + 0x18 : goto rvbd; + case H_Reverb + 0x1a : goto rvbd; + case H_Reverb + 0x1c : goto rvbd; + case H_Reverb + 0x1e : goto rvbd; + case H_Reverb + 0x20 : goto rvbd; + case H_Reverb + 0x22 : goto rvbd; + case H_Reverb + 0x24 : goto rvbd; + case H_Reverb + 0x26 : goto rvbd; + case H_Reverb + 0x28 : goto rvbd; + case H_Reverb + 0x2a : goto rvbd; + case H_Reverb + 0x2c : goto rvbd; + case H_Reverb + 0x2e : goto rvbd; + case H_Reverb + 0x30 : goto rvbd; + case H_Reverb + 0x32 : goto rvbd; + case H_Reverb + 0x34 : goto rvbd; + case H_Reverb + 0x36 : goto rvbd; + case H_Reverb + 0x38 : goto rvbd; + case H_Reverb + 0x3a : goto rvbd; + case H_Reverb + 0x3c : spu.rvb->vLIN = (signed short)val; break; + case H_Reverb + 0x3e : spu.rvb->vRIN = (signed short)val; break; } return; @@ -351,7 +369,7 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg, unsigned int cycles) return spu.spuCtrl; case H_SPUstat: - return (spu.spuStat & ~0x3F) | (spu.spuCtrl & 0x3F); + return spu.spuStat; case H_SPUaddr: return (unsigned short)(spu.spuAddr>>3); @@ -374,7 +392,12 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg, unsigned int cycles) case H_SPUMute1: case H_SPUMute2: - log_unhandled("r isOn: %08lx\n", reg); + log_unhandled("spu r isOn: %08lx %04x\n", reg, regAreaGet(r)); + break; + + case H_SPUmvolL: + case H_SPUmvolR: + log_unhandled("spu r mvol: %08lx %04x\n", reg, regAreaGet(r)); break; case 0x0dac: @@ -387,7 +410,7 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg, unsigned int cycles) default: if (r >= 0xda0) - log_unhandled("spu r %08lx\n", reg); + log_unhandled("spu r %08lx %04x\n", reg, regAreaGet(r)); break; } @@ -420,7 +443,7 @@ static void SoundOn(int start,int end,unsigned short val) static void SoundOff(int start,int end,unsigned short val) { int ch; - for(ch=start;ch>=1) // loop channels + for (ch = start; val && ch < end; ch++, val >>= 1) // loop channels { if(val&1) { @@ -563,3 +586,5 @@ static void ReverbOn(int start,int end,unsigned short val) spu.s_chan[ch].bReverb=val&1; // -> reverb on/off } } + +// vim:shiftwidth=1:expandtab