From: kub Date: Tue, 11 Jul 2023 21:43:00 +0000 (+0000) Subject: 32x, improve pwm volume accuracy X-Git-Tag: v2.00~189 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=adffea8dae3230cc43da194bf0a108462c6ca80e;p=picodrive.git 32x, improve pwm volume accuracy --- diff --git a/pico/32x/pwm.c b/pico/32x/pwm.c index 1b10103a..e08ff026 100644 --- a/pico/32x/pwm.c +++ b/pico/32x/pwm.c @@ -34,7 +34,7 @@ void p32x_pwm_ctl_changed(void) // but mars test disagrees pwm.mult = 0; if ((control & 0x0f) != 0) - pwm.mult = 0x10000 / cycles; + pwm.mult = (0x10000<<8) / (cycles+1); pwm.irq_timer = (control & 0x0f00) >> 8; pwm.irq_timer = ((pwm.irq_timer - 1) & 0x0f) + 1; @@ -60,9 +60,7 @@ static int convert_sample(unsigned int v) { if (v > pwm.cycles) v = pwm.cycles; - if (v == 0) - return 0; - return v * pwm.mult - 0x10000/2; + return (v * pwm.mult >> 8) - 0x10000/2; } #define consume_fifo(sh2, m68k_cycles) { \