src/apu/apu.cc
/*
 * Updates the envelope counter of a pulse channel.
 *
 * Assumes the provided channel is non-null.
 */
Updates the envelope counter of a pulse channel.
Assumes the provided channel is non-null.
Updates the envelope counter of a pulse channel . Assumes the provided channel is non - null .
void Apu::UpdatePulseEnvelope(ApuPulse *pulse) {
  if ((pulse->env_clock == 0) || pulse->env_reset) {
    pulse->env_clock = pulse->control & VOLUME_MASK;
    if (((pulse->env_volume == 0) && (pulse->control & FLAG_ENV_LOOP))
                                  || pulse->env_reset) {
      pulse->env_volume = ENV_DECAY_START;
      pulse->env_reset = false;
    } else if (pulse->env_volume > 0) {
      pulse->env_volume--;
    }
  } else {
    pulse->env_clock--;
  }
  return;
}
void Apu :: UpdatePulseEnvelope ( ApuPulse * pulse ) { if ( ( pulse -> env_clock == 0 ) || pulse -> env_reset ) { pulse -> env_clock = pulse -> control & VOLUME_MASK ; if ( ( ( pulse -> env_volume == 0 ) && ( pulse -> control & FLAG_ENV_LOOP ) ) || pulse -> env_reset ) { pulse -> env_volume = ENV_DECAY_START ; pulse -> env_reset = false ; } else if ( pulse -> env_volume > 0 ) { pulse -> env_volume -- ; } } else { pulse -> env_clock -- ; } return ; }
Updates the envelope counter of a pulse channel.
Updates the envelope counter of a pulse 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.