summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2021-04-21 02:34:15 -0700
committer Aaron Giles <aaron@aarongiles.com>2021-04-21 02:34:15 -0700
commit782d8276708eedae93374967dbef05f20d4a9bb3 (patch)
tree820056914559883c39c45d341ec63430fe5a6090
parentc4460d6939813e270253dc736bd1530a5620703b (diff)
ymfm: Check for decay->sustain transitions even if we just transitioned from attack->decay. Affects the cymbal sounds in shinobi.
-rw-r--r--src/devices/sound/ymfm.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/devices/sound/ymfm.cpp b/src/devices/sound/ymfm.cpp
index df9d87584ab..abea6fa365a 100644
--- a/src/devices/sound/ymfm.cpp
+++ b/src/devices/sound/ymfm.cpp
@@ -2406,10 +2406,16 @@ void ymfm_operator<RegisterType>::clock_ssg_eg_state()
template<class RegisterType>
void ymfm_operator<RegisterType>::clock_envelope(u32 env_counter)
{
- // handle attack->decay and decay->sustain transitions
+ // handle attack->decay transitions
if (m_env_state == YMFM_ENV_ATTACK && m_env_attenuation == 0)
m_env_state = YMFM_ENV_DECAY;
- else if (m_env_state == YMFM_ENV_DECAY && m_env_attenuation >= m_cache.eg_sustain)
+
+ // handle decay->sustain transitions; it is important to do this immediately
+ // after the attack->decay transition above in the event that the sustain level
+ // is set to 0 (in which case we will skip right to sustain without doing any
+ // decay); as an example where this can be heard, check the cymbals sound
+ // in channel 0 of shinobi's test mode sound #5
+ if (m_env_state == YMFM_ENV_DECAY && m_env_attenuation >= m_cache.eg_sustain)
m_env_state = YMFM_ENV_SUSTAIN;
// fetch the appropriate 6-bit rate value from the cache