src/apu/apu.cc
/*
 * Updates the output of a pulse channel.
 *
 * Assumes the pulse channel is non-null.
 */
Updates the output of a pulse channel.
Assumes the pulse channel is non-null.
Updates the output of a pulse channel . Assumes the pulse channel is non - null .
void Apu::UpdatePulse(ApuPulse *pulse) {
  DataWord sequence = (pulse_waves[(pulse->control & PULSE_DUTY_MASK)
                    >> PULSE_DUTY_SHIFT] << pulse->pos) & PULSE_SEQUENCE_MASK;
  DoubleWord target_period = GetPulseTarget(pulse);
  if (sequence && (pulse->length > 0) && (pulse->timer >= 8)
               && (target_period <= PULSE_TIMER_MASK)) {
    pulse->output = (pulse->control & FLAG_CONST_VOL)
                  ? pulse->control & VOLUME_MASK
                  : pulse->env_volume;
  } else {
    pulse->output = 0;
  }
  if (pulse->clock > 0) {
    pulse->clock--;
  } else {
    pulse->clock = pulse->timer;
    pulse->pos = (pulse->pos + 1) & 0x07U;
  }
  return;
}
void Apu :: UpdatePulse ( ApuPulse * pulse ) { DataWord sequence = ( pulse_waves [ ( pulse -> control & PULSE_DUTY_MASK ) >> PULSE_DUTY_SHIFT ] << pulse -> pos ) & PULSE_SEQUENCE_MASK ; DoubleWord target_period = GetPulseTarget ( pulse ) ; if ( sequence && ( pulse -> length > 0 ) && ( pulse -> timer >= 8 ) && ( target_period <= PULSE_TIMER_MASK ) ) { pulse -> output = ( pulse -> control & FLAG_CONST_VOL ) ? pulse -> control & VOLUME_MASK : pulse -> env_volume ; } else { pulse -> output = 0 ; } if ( pulse -> clock > 0 ) { pulse -> clock -- ; } else { pulse -> clock = pulse -> timer ; pulse -> pos = ( pulse -> pos + 1 ) & 0x07U ; } return ; }
Updates the output of a pulse channel.
Updates the output of a pulse channel .
// Determine what the pulse channel is outputting audio on this cycle. // Check if it is time to update the pulse channel. // Increment the pulse sequence position.