Mercurial > repos > blastem
comparison ym2612.c @ 929:0ee8cfcc06d1
Change where decay to sustain transition happens to match hardware when decay rate is slow or 0
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 10 Feb 2016 20:05:39 -0800 |
parents | 252dfd29831d |
children | f33e8d88ab6f |
comparison
equal
deleted
inserted
replaced
928:8bd82aead087 | 929:0ee8cfcc06d1 |
---|---|
296 uint32_t env_cyc = context->env_counter; | 296 uint32_t env_cyc = context->env_counter; |
297 uint32_t op = context->current_env_op; | 297 uint32_t op = context->current_env_op; |
298 ym_operator * operator = context->operators + op; | 298 ym_operator * operator = context->operators + op; |
299 ym_channel * channel = context->channels + op/4; | 299 ym_channel * channel = context->channels + op/4; |
300 uint8_t rate; | 300 uint8_t rate; |
301 if (operator->env_phase == PHASE_DECAY && operator->envelope >= operator->sustain_level) { | |
302 //operator->envelope = operator->sustain_level; | |
303 operator->env_phase = PHASE_SUSTAIN; | |
304 } | |
301 for(;;) { | 305 for(;;) { |
302 rate = operator->rates[operator->env_phase]; | 306 rate = operator->rates[operator->env_phase]; |
303 if (rate) { | 307 if (rate) { |
304 uint8_t ks = channel->keycode >> operator->key_scaling;; | 308 uint8_t ks = channel->keycode >> operator->key_scaling;; |
305 rate = rate*2 + ks; | 309 rate = rate*2 + ks; |
345 //envelope value is 10-bits, but it will be used as a 4.8 value | 349 //envelope value is 10-bits, but it will be used as a 4.8 value |
346 operator->envelope += envelope_inc << 2; | 350 operator->envelope += envelope_inc << 2; |
347 //clamp to max attenuation value | 351 //clamp to max attenuation value |
348 if (operator->envelope > MAX_ENVELOPE) { | 352 if (operator->envelope > MAX_ENVELOPE) { |
349 operator->envelope = MAX_ENVELOPE; | 353 operator->envelope = MAX_ENVELOPE; |
350 } | |
351 if (operator->env_phase == PHASE_DECAY && operator->envelope >= operator->sustain_level) { | |
352 //operator->envelope = operator->sustain_level; | |
353 operator->env_phase = PHASE_SUSTAIN; | |
354 } | 354 } |
355 } | 355 } |
356 } | 356 } |
357 context->current_env_op++; | 357 context->current_env_op++; |
358 if (context->current_env_op == NUM_OPERATORS) { | 358 if (context->current_env_op == NUM_OPERATORS) { |