From cce32a34da6b18ead5e0808471f666196ea53513 Mon Sep 17 00:00:00 2001 From: kub Date: Thu, 3 Jun 2021 21:51:47 +0200 Subject: [PATCH] mcd, fix pcm output level --- pico/cd/pcm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pico/cd/pcm.c b/pico/cd/pcm.c index b77196a4..795ec3b7 100644 --- a/pico/cd/pcm.c +++ b/pico/cd/pcm.c @@ -89,10 +89,10 @@ void pcd_pcm_sync(unsigned int to) addr = ch->addr; inc = ch->regs[2] + (ch->regs[3]<<8); - mul_l = ((int)ch->regs[0] * (ch->regs[1] & 0xf)) >> (5+1); - mul_r = ((int)ch->regs[0] * (ch->regs[1] >> 4)) >> (5+1); + mul_l = (int)ch->regs[0] * (ch->regs[1] & 0xf); + mul_r = (int)ch->regs[0] * (ch->regs[1] >> 4); - for (s = 0; s < steps; s++, addr = (addr + inc) & 0x7FFFFFF) + for (s = 0; s < steps; s++, addr = (addr + inc) & 0x07FFFFFF) { smp = Pico_mcd->pcm_ram[addr >> PCM_STEP_SHIFT]; @@ -109,8 +109,8 @@ void pcd_pcm_sync(unsigned int to) if (smp & 0x80) smp = -(smp & 0x7f); - out[s*2 ] += smp * mul_l; // max 128 * 119 = 15232 - out[s*2+1] += smp * mul_r; + out[s*2 ] += (smp * mul_l) >> 5; // max 127 * 255 * 15 / 32 = 15180 + out[s*2+1] += (smp * mul_r) >> 5; } ch->addr = addr; } -- 2.39.5