OPM: if the LFO rate is 0, don't clock the counter

This commit is contained in:
tildearrow 2022-04-07 01:03:16 -05:00
parent 78cd99af32
commit e1b77d7e2b

View file

@ -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();
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