From: notaz Date: Tue, 10 Oct 2023 23:11:51 +0000 (+0300) Subject: spu: try keyoff ignore X-Git-Tag: r24l~138 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcb93a4fee240762b8bfbb06dc1fadc9c20f32e0;p=pcsx_rearmed.git spu: try keyoff ignore unclear if that's what's supposed to happen notaz/pcsx_rearmed#315 --- diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 4e1a40bc..fca387d1 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -225,6 +225,8 @@ typedef struct int iLeftXAVol; int iRightXAVol; + unsigned int last_keyon_cycles; + union { unsigned char *spuMemC; unsigned short *spuMem; diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index 1e3767ad..6f06ffce 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -213,20 +213,32 @@ 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); + } 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); + } SoundOff(16,24,val); break; //-------------------------------------------------// @@ -420,7 +432,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 +575,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