summaryrefslogtreecommitdiff
path: root/ym2612.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2019-03-26 22:27:23 -0700
committerMichael Pavone <pavone@retrodev.com>2019-03-26 22:27:23 -0700
commit214af23bafaa8c40fd98c117904703fc47a9aaa3 (patch)
tree4f8cd9ee7d1cca299f6baf319bf41223e266711a /ym2612.c
parent7193ef551b23dce5206acfb44a81e19a6b968f89 (diff)
Fix a couple of minor cases of extra precision in LFO implementation
Diffstat (limited to 'ym2612.c')
-rw-r--r--ym2612.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ym2612.c b/ym2612.c
index 71ee0d0..e7301d9 100644
--- a/ym2612.c
+++ b/ym2612.c
@@ -519,7 +519,7 @@ void ym_run(ym2612_context * context, uint32_t to_cycle)
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 @@ static uint32_t ym_calc_phase_inc(ym2612_context * context, ym_operator * operat
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 @@ void ym_data_write(ym2612_context * context, uint8_t value)
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;