src/apu/apu.cc
/*
 * Updates the envelope counter of the noise channel.
 */
Updates the envelope counter of the noise channel.
Updates the envelope counter of the noise channel .
void Apu::UpdateNoiseEnvelope(void) {
  if ((noise_->env_clock == 0) || noise_->env_reset) {
    noise_->env_clock = noise_->control & VOLUME_MASK;
    if (((noise_->env_volume == 0) && (noise_->control & FLAG_ENV_LOOP))
                                   || noise_->env_reset) {
      noise_->env_volume = ENV_DECAY_START;
      noise_->env_reset = false;
    } else if (noise_->env_volume > 0) {
      noise_->env_volume--;
    }
  } else {
    noise_->env_clock--;
  }
  return;
}
void Apu :: UpdateNoiseEnvelope ( void ) { if ( ( noise_ -> env_clock == 0 ) || noise_ -> env_reset ) { noise_ -> env_clock = noise_ -> control & VOLUME_MASK ; if ( ( ( noise_ -> env_volume == 0 ) && ( noise_ -> control & FLAG_ENV_LOOP ) ) || noise_ -> env_reset ) { noise_ -> env_volume = ENV_DECAY_START ; noise_ -> env_reset = false ; } else if ( noise_ -> env_volume > 0 ) { noise_ -> env_volume -- ; } } else { noise_ -> env_clock -- ; } return ; }
Updates the envelope counter of the noise channel.
Updates the envelope counter of the noise channel .
// Check if it is time to update the envelope. // Reset the envelope clock. // If the envelope has ended and should be looped, reset the volume. // Otherwise, decay the volume.