From e1b77d7e2b1b390a149f40d516b091dd3e38ad63 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 7 Apr 2022 01:03:16 -0500 Subject: [PATCH] OPM: if the LFO rate is 0, don't clock the counter --- src/engine/platform/sound/ymfm/ymfm_opm.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/engine/platform/sound/ymfm/ymfm_opm.cpp b/src/engine/platform/sound/ymfm/ymfm_opm.cpp index 544bbe89a..31d0a7467 100644 --- a/src/engine/platform/sound/ymfm/ymfm_opm.cpp +++ b/src/engine/platform/sound/ymfm/ymfm_opm.cpp @@ -87,6 +87,8 @@ void opm_registers::reset() { std::fill_n(&m_regdata[0], REGISTERS, 0); + m_lfo_counter = 0; + // enable output on both channels by default m_regdata[0x20] = m_regdata[0x21] = m_regdata[0x22] = m_regdata[0x23] = 0xc0; m_regdata[0x24] = m_regdata[0x25] = m_regdata[0x26] = m_regdata[0x27] = 0xc0; @@ -195,8 +197,13 @@ int32_t opm_registers::clock_noise_and_lfo() // treat the rate as a 4.4 floating-point step value with implied // leading 1; this matches exactly the frequencies in the application // manual, though it might not be implemented exactly this way on chip + // note from tildearrow: + // - in fact it doesn't. the strings in Scherzo Di Notte totally go out + // tune after a bit (and this doesn't happen in Nuked-OPM). uint32_t rate = lfo_rate(); - m_lfo_counter += (0x10 | bitfield(rate, 0, 4)) << bitfield(rate, 4, 4); + if (rate != 0) { + m_lfo_counter += (0x10 | bitfield(rate, 0, 4)) << bitfield(rate, 4, 4); + } // bit 1 of the test register is officially undocumented but has been // discovered to hold the LFO in reset while active