X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fdfsound%2Fregisters.c;h=2796f9c3f5b5bc1b189ca205f78724ba9e3836e4;hb=38e4048faeaccf7fdc6084f64866f2ea52bb97f1;hp=ae7ed24e776c8028ac7af7c745b292ef2c3d4766;hpb=4b22d9501e7de7b7991e5cf3163e4b48806a0913;p=pcsx_rearmed.git diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index ae7ed24e..2796f9c3 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -60,7 +60,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, if (val == 0 && (r & 0xff8) == 0xd88) return; - do_samples_if_needed(cycles, 0); + do_samples_if_needed(cycles, 0, 16); if(r>=0x0c00 && r<0x0d80) // some channel info? { @@ -133,12 +133,14 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, //-------------------------------------------------// case H_SPUaddr: spu.spuAddr = (unsigned long) val<<3; + //check_irq_io(spu.spuAddr); break; //-------------------------------------------------// case H_SPUdata: *(unsigned short *)(spu.spuMemC + spu.spuAddr) = HTOLE16(val); spu.spuAddr += 2; spu.spuAddr &= 0x7fffe; + check_irq_io(spu.spuAddr); break; //-------------------------------------------------// case H_SPUctrl: @@ -160,7 +162,8 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, case H_SPUirqAddr: //if (val & 1) // log_unhandled("w irq with lsb: %08lx %04x\n", reg, val); - spu.pSpuIrq=spu.spuMemC+(((unsigned long) val<<3)&~0xf); + spu.pSpuIrq = spu.spuMemC + (((int)val << 3) & ~0xf); + //check_irq_io(spu.spuAddr); goto upd_irq; //-------------------------------------------------// case H_SPUrvolL: @@ -210,10 +213,12 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, */ //-------------------------------------------------// case H_SPUon1: + do_samples_if_needed(cycles, 0, 2); SoundOn(0,16,val); break; //-------------------------------------------------// - case H_SPUon2: + case H_SPUon2: + do_samples_if_needed(cycles, 0, 2); SoundOn(16,24,val); break; //-------------------------------------------------// @@ -306,7 +311,7 @@ rvbd: // READ REGISTER: called by main emu //////////////////////////////////////////////////////////////////////// -unsigned short CALLBACK SPUreadRegister(unsigned long reg) +unsigned short CALLBACK SPUreadRegister(unsigned long reg, unsigned int cycles) { const unsigned long r = reg & 0xffe; @@ -316,12 +321,13 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg) { case 12: // get adsr vol { - const int ch=(r>>4)-0xc0; - if(spu.dwNewChannel&(1<>16); + // this used to return 1 immediately after keyon to deal with + // some poor timing, but that causes Rayman 2 to lose track of + // it's channels on busy scenes and start looping some of them forever + const int ch = (r>>4) - 0xc0; + if (spu.s_chan[ch].bStarting) + do_samples_if_needed(cycles, 0, 2); + return (unsigned short)(spu.s_chan[ch].ADSRX.EnvelopeVol >> 16); } case 14: // get loop address @@ -350,11 +356,13 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg) case H_SPUaddr: return (unsigned short)(spu.spuAddr>>3); + // this reportedly doesn't work on real hw case H_SPUdata: { unsigned short s = LE16TOH(*(unsigned short *)(spu.spuMemC + spu.spuAddr)); spu.spuAddr += 2; spu.spuAddr &= 0x7fffe; + //check_irq_io(spu.spuAddr); return s; } @@ -399,6 +407,7 @@ static void SoundOn(int start,int end,unsigned short val) if((val&1) && regAreaGetCh(ch, 6)) // mmm... start has to be set before key on !?! { spu.s_chan[ch].bIgnoreLoop = 0; + spu.s_chan[ch].bStarting = 1; spu.dwNewChannel|=(1<