From: notaz Date: Wed, 26 Mar 2025 23:43:02 +0000 (+0200) Subject: spu: partially implement current vol regs X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d06f3e5362c203cdc6e5ad0be70a4f798f24e1e;p=pcsx_rearmed.git spu: partially implement current vol regs libretro/pcsx_rearmed#885 --- diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 7fd41b83..1ccd6052 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -263,8 +263,10 @@ typedef struct #endif } SPUInfo; -#define regAreaGet(offset) \ +#define regAreaRef(offset) \ spu.regArea[((offset) - 0xc00) >> 1] +#define regAreaGet(offset) \ + regAreaRef(offset) #define regAreaGetCh(ch, offset) \ spu.regArea[(((ch) << 4) | (offset)) >> 1] diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index b1ab2b53..2b50c1fd 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -383,6 +383,9 @@ long DoFreeze(unsigned int ulFreezeMode, SPUFreeze_t * pF, memcpy(&sb_rvb->SB_rvb[i][j*4], pFO->rvb_sb[i], 4 * sizeof(sb_rvb->SB_rvb[i][0])); spu.interpolation = pFO->interpolation; } + for (i = 0; i <= 2; i += 2) + if (!regAreaGet(H_SPUcmvolL+i) && regAreaGet(H_SPUmvolL+i) < 0x8000u) + regAreaRef(H_SPUcmvolL+i) = regAreaGet(H_SPUmvolL+i) << 1; // repair some globals for(i=0;i<=62;i+=2) diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index ee2107c9..5565317d 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -177,10 +177,21 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, //-------------------------------------------------// 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) @@ -196,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; @@ -389,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: @@ -402,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; } diff --git a/plugins/dfsound/registers.h b/plugins/dfsound/registers.h index 4acfe6f2..f31f4e3e 100644 --- a/plugins/dfsound/registers.h +++ b/plugins/dfsound/registers.h @@ -44,6 +44,8 @@ #define H_CDRight 0x0db2 #define H_ExtLeft 0x0db4 #define H_ExtRight 0x0db6 +#define H_SPUcmvolL 0x0db8 +#define H_SPUcmvolR 0x0dba #define H_Reverb 0x0dc0 #define H_SPUPitch0 0x0c04 #define H_SPUPitch1 0x0c14 diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 563146da..0954be5d 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -1256,8 +1256,8 @@ void do_samples(unsigned int cycles_to, int force_no_thread) static void do_samples_finish(int *SSumLR, int ns_to, int silentch, int decode_pos) { - int vol_l = ((int)regAreaGet(H_SPUmvolL) << 17) >> 17; - int vol_r = ((int)regAreaGet(H_SPUmvolR) << 17) >> 17; + int vol_l = ((int)regAreaGet(H_SPUcmvolL) << 16) >> 17; + int vol_r = ((int)regAreaGet(H_SPUcmvolR) << 16) >> 17; int ns; int d;