# HG changeset patch # User Michael Pavone # Date 1553664443 25200 # Node ID 1d1198f162794e20744548b7040ce18fb145770b # Parent 2efdace4fb8a8212dd0a3e6171b4a716c484512a Fix a couple of minor cases of extra precision in LFO implementation diff -r 2efdace4fb8a -r 1d1198f16279 ym2612.c --- a/ym2612.c Mon Mar 25 23:34:52 2019 -0700 +++ b/ym2612.c Tue Mar 26 22:27:23 2019 -0700 @@ -519,7 +519,7 @@ if (operator->am) { uint16_t base_am = (context->lfo_am_step & 0x80 ? context->lfo_am_step : ~context->lfo_am_step) & 0x7E; if (ams_shift[chan->ams] >= 0) { - env += base_am >> ams_shift[chan->ams]; + env += (base_am >> ams_shift[chan->ams]) & MAX_ENVELOPE; } else { env += base_am << (-ams_shift[chan->ams]); } @@ -687,6 +687,7 @@ inc = context->ch3_supp[index].fnum; if (channel->pms) { inc = inc * 2 + lfo_pm_table[(inc & 0x7F0) * 16 + channel->pms + context->lfo_pm_step]; + inc &= 0xFFF; } if (!context->ch3_supp[index].block) { inc >>= 1; @@ -855,7 +856,6 @@ operator->rates[PHASE_ATTACK] = value & 0x1F; break; case REG_DECAY_AM: - //TODO: AM flag for LFO operator->am = value & 0x80; operator->rates[PHASE_DECAY] = value & 0x1F; break;