src/apu/apu.cc
/*
 * Determines the number of APU cycles until the next interrupt.
 * Returns UINT_MAX if no interrupts will occur within the current state.
 */
Determines the number of APU cycles until the next interrupt.
Returns UINT_MAX if no interrupts will occur within the current state.
Determines the number of APU cycles until the next interrupt . Returns UINT_MAX if no interrupts will occur within the current state .
size_t Apu::Schedule(void) {
  size_t dmc_cycles;
  if ((dmc_->control & (FLAG_DMC_IRQ | FLAG_DMC_LOOP)) || dmc_irq_
                                                       || dmc_->silent) {
    dmc_cycles = ~(0UL);
  } else {
    dmc_cycles = ((((static_cast<size_t>(dmc_->bytes_remaining)) << 3)
               | (dmc_->bits_remaining + 1)) << 1);
  }
  size_t frame_cycles;
  if ((frame_control_ & (FLAG_MODE | FLAG_IRQ_DISABLE)) || frame_irq_) {
    frame_cycles = ~(0UL);
  } else if (frame_step_ == 3) {
    frame_cycles = ((FRAME_STEP_LENGTH << 2) - frame_clock_) << 1;
  } else {
    frame_cycles = (((3 - frame_step_) * FRAME_STEP_LENGTH)
                 - frame_clock_) << 1;
  }
  return MIN(dmc_cycles, frame_cycles);
}
size_t Apu :: Schedule ( void ) { size_t dmc_cycles ; if ( ( dmc_ -> control & ( FLAG_DMC_IRQ | FLAG_DMC_LOOP ) ) || dmc_irq_ || dmc_ -> silent ) { dmc_cycles = ~ ( 0UL ) ; } else { dmc_cycles = ( ( ( ( static_cast < size_t > ( dmc_ -> bytes_remaining ) ) << 3 ) | ( dmc_ -> bits_remaining + 1 ) ) << 1 ) ; } size_t frame_cycles ; if ( ( frame_control_ & ( FLAG_MODE | FLAG_IRQ_DISABLE ) ) || frame_irq_ ) { frame_cycles = ~ ( 0UL ) ; } else if ( frame_step_ == 3 ) { frame_cycles = ( ( FRAME_STEP_LENGTH << 2 ) - frame_clock_ ) << 1 ; } else { frame_cycles = ( ( ( 3 - frame_step_ ) * FRAME_STEP_LENGTH ) - frame_clock_ ) << 1 ; } return MIN ( dmc_cycles , frame_cycles ) ; }
Determines the number of APU cycles until the next interrupt.
Determines the number of APU cycles until the next interrupt .
// Calculate how many cycles until the DMC raises an IRQ. // Calculate the number of cycles until the next frame IRQ.