Mercurial > repos > blastem
comparison ym2612.c @ 1802:1d1198f16279
Fix a couple of minor cases of extra precision in LFO implementation
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 26 Mar 2019 22:27:23 -0700 |
parents | 5278b6e44fc1 |
children | a851d36e24bb |
comparison
equal
deleted
inserted
replaced
1801:2efdace4fb8a | 1802:1d1198f16279 |
---|---|
517 } | 517 } |
518 env += operator->total_level; | 518 env += operator->total_level; |
519 if (operator->am) { | 519 if (operator->am) { |
520 uint16_t base_am = (context->lfo_am_step & 0x80 ? context->lfo_am_step : ~context->lfo_am_step) & 0x7E; | 520 uint16_t base_am = (context->lfo_am_step & 0x80 ? context->lfo_am_step : ~context->lfo_am_step) & 0x7E; |
521 if (ams_shift[chan->ams] >= 0) { | 521 if (ams_shift[chan->ams] >= 0) { |
522 env += base_am >> ams_shift[chan->ams]; | 522 env += (base_am >> ams_shift[chan->ams]) & MAX_ENVELOPE; |
523 } else { | 523 } else { |
524 env += base_am << (-ams_shift[chan->ams]); | 524 env += base_am << (-ams_shift[chan->ams]); |
525 } | 525 } |
526 } | 526 } |
527 if (env > MAX_ENVELOPE) { | 527 if (env > MAX_ENVELOPE) { |
685 index ^= 1; | 685 index ^= 1; |
686 } | 686 } |
687 inc = context->ch3_supp[index].fnum; | 687 inc = context->ch3_supp[index].fnum; |
688 if (channel->pms) { | 688 if (channel->pms) { |
689 inc = inc * 2 + lfo_pm_table[(inc & 0x7F0) * 16 + channel->pms + context->lfo_pm_step]; | 689 inc = inc * 2 + lfo_pm_table[(inc & 0x7F0) * 16 + channel->pms + context->lfo_pm_step]; |
690 inc &= 0xFFF; | |
690 } | 691 } |
691 if (!context->ch3_supp[index].block) { | 692 if (!context->ch3_supp[index].block) { |
692 inc >>= 1; | 693 inc >>= 1; |
693 } else { | 694 } else { |
694 inc <<= (context->ch3_supp[index].block-1); | 695 inc <<= (context->ch3_supp[index].block-1); |
853 case REG_ATTACK_KS: | 854 case REG_ATTACK_KS: |
854 operator->key_scaling = 3 - (value >> 6); | 855 operator->key_scaling = 3 - (value >> 6); |
855 operator->rates[PHASE_ATTACK] = value & 0x1F; | 856 operator->rates[PHASE_ATTACK] = value & 0x1F; |
856 break; | 857 break; |
857 case REG_DECAY_AM: | 858 case REG_DECAY_AM: |
858 //TODO: AM flag for LFO | |
859 operator->am = value & 0x80; | 859 operator->am = value & 0x80; |
860 operator->rates[PHASE_DECAY] = value & 0x1F; | 860 operator->rates[PHASE_DECAY] = value & 0x1F; |
861 break; | 861 break; |
862 case REG_SUSTAIN_RATE: | 862 case REG_SUSTAIN_RATE: |
863 operator->rates[PHASE_SUSTAIN] = value & 0x1F; | 863 operator->rates[PHASE_SUSTAIN] = value & 0x1F; |