From 561aa7a9b6794c18eb1e0611854fc5edfc03a58f Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 11 Oct 2023 02:11:51 +0300 Subject: [PATCH] spu: try keyoff ignore unclear if that's what's supposed to happen notaz/pcsx_rearmed#315 --- plugins/dfsound/externals.h | 2 ++ plugins/dfsound/registers.c | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) 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 -- 2.39.5