From c23c046249bbcd0a6b9ecf795ccc5ad937641a87 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 4 Aug 2020 04:05:33 +0200 Subject: [PATCH] OPL3 timers now behave according to the YMF 262 datasheet. --- src/sound/snd_opl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sound/snd_opl.c b/src/sound/snd_opl.c index bab1a8c3f..01d95fce2 100644 --- a/src/sound/snd_opl.c +++ b/src/sound/snd_opl.c @@ -102,7 +102,10 @@ timer_control(opl_t *dev, int tmr, int start) if (start) { opl_log("Loading timer %i count: %02X = %02X\n", tmr, dev->timer_cur_count[tmr], dev->timer_count[tmr]); dev->timer_cur_count[tmr] = dev->timer_count[tmr]; - timer_on_auto(&dev->timers[tmr], (tmr == 1) ? 320.0 : 80.0); + if (dev->flags & FLAG_OPL3) + timer_tick(dev, tmr); /* Per the YMF262 datasheet, OPL3 starts counting immediately, unlike OPL2. */ + else + timer_on_auto(&dev->timers[tmr], (tmr == 1) ? 320.0 : 80.0); } else opl_log("Timer %i stopped\n", tmr); } @@ -163,9 +166,9 @@ opl_write(opl_t *dev, uint16_t port, uint8_t val) opl_log("Resetting timer status...\n"); dev->status &= ~STAT_TMR_OVER; } else { + dev->timer_ctrl = val; timer_control(dev, 0, val & CTRL_TMR1_START); timer_control(dev, 1, val & CTRL_TMR2_START); - dev->timer_ctrl = val; opl_log("Status mask now %02X (val = %02X)\n", (val & ~CTRL_TMR_MASK) & CTRL_TMR_MASK, val); } break;