src/apu/apu.cc
/*
 * Reads from a memory mapped APU register.
 * All registers, except the status register, are write only and return 0.
 */
Reads from a memory mapped APU register.
All registers, except the status register, are write only and return 0.
Reads from a memory mapped APU register . All registers except the status register are write only and return 0 .
DataWord Apu::Read(DoubleWord reg_addr) {
  if (reg_addr == APU_STATUS_ADDR) {
    DataWord status = 0;
    if (dmc_irq_) { status |= FLAG_DMC_IRQ; }
    if (frame_irq_) {
      status |= FLAG_FRAME_IRQ;
      frame_irq_ = false;
      (*irq_line_)--;
    }
    if (dmc_->bytes_remaining > 0) { status |= FLAG_DMC_ACTIVE; }
    if (noise_->length > 0) { status |= FLAG_NOISE_ACTIVE; }
    if (triangle_->length > 0) { status |= FLAG_TRI_ACTIVE; }
    if (pulse_b_->length > 0) { status |= FLAG_PULSE_B_ACTIVE; }
    if (pulse_a_->length > 0) { status |= FLAG_PULSE_A_ACTIVE; }
    return status;
  } else {
    return 0;
  }
}
DataWord Apu :: Read ( DoubleWord reg_addr ) { if ( reg_addr == APU_STATUS_ADDR ) { DataWord status = 0 ; if ( dmc_irq_ ) { status |= FLAG_DMC_IRQ ; } if ( frame_irq_ ) { status |= FLAG_FRAME_IRQ ; frame_irq_ = false ; ( * irq_line_ ) -- ; } if ( dmc_ -> bytes_remaining > 0 ) { status |= FLAG_DMC_ACTIVE ; } if ( noise_ -> length > 0 ) { status |= FLAG_NOISE_ACTIVE ; } if ( triangle_ -> length > 0 ) { status |= FLAG_TRI_ACTIVE ; } if ( pulse_b_ -> length > 0 ) { status |= FLAG_PULSE_B_ACTIVE ; } if ( pulse_a_ -> length > 0 ) { status |= FLAG_PULSE_A_ACTIVE ; } return status ; } else { return 0 ; } }
Reads from a memory mapped APU register.
Reads from a memory mapped APU register .
// Place the status of the APU in a word, and return it. // Reading the status register clears the frame IRQ flag. // Invalid register.