src/memory/mappers/sxrom.cc
/*
 * Reads the word at the specified address from memory, accounting
 * for MMIO and bank switching. If the address leads to an open bus,
 * the last value read is returned.
 *
 * Assumes that the connect function has been called on this object
 * with valid Cpu/Ppu/Apu objects.
 * Assumes that AddController has been called by the calling object on
 * a valid Input object.
 */
Reads the word at the specified address from memory, accounting
for MMIO and bank switching. If the address leads to an open bus,
the last value read is returned.

Assumes that the connect function has been called on this object
with valid Cpu/Ppu/Apu objects.
Assumes that AddController has been called by the calling object on
a valid Input object.
Reads the word at the specified address from memory accounting for MMIO and bank switching . If the address leads to an open bus the last value read is returned . Assumes that the connect function has been called on this object with valid Cpu / Ppu / Apu objects . Assumes that AddController has been called by the calling object on a valid Input object .
DataWord Sxrom::Read(DoubleWord addr) {
  if (addr < PPU_OFFSET) {
    bus_ = ram_[addr & RAM_MASK];
  } else if ((PPU_OFFSET <= addr) && (addr < IO_OFFSET)) {
    bus_ = ppu_->Read(addr);
  } else if ((IO_OFFSET <= addr) && (addr < MAPPER_OFFSET)) {
    if ((addr == IO_JOY1_ADDR) || (addr == IO_JOY2_ADDR)) {
      bus_ = controller_->Read(addr);
    } else {
      bus_ = apu_->Read(addr);
    }
  } else if ((PRG_RAM_OFFSET <= addr) && (addr < PRG_ROM_A_OFFSET)
                                      && (num_prg_ram_banks_ > 0)
                                      && !(prg_reg_ & FLAG_PRG_RAM_DISABLE)) {
    bus_ = prg_ram_[prg_ram_bank_][addr & PRG_RAM_MASK];
  } else if ((PRG_ROM_A_OFFSET <= addr) && (addr < PRG_ROM_B_OFFSET)) {
    bus_ = prg_rom_[prg_rom_bank_a_][addr & PRG_ROM_MASK];
  } else if (addr >= PRG_ROM_B_OFFSET) {
    bus_ = prg_rom_[prg_rom_bank_b_][addr & PRG_ROM_MASK];
  }
  return bus_;
}
DataWord Sxrom :: Read ( DoubleWord addr ) { if ( addr < PPU_OFFSET ) { bus_ = ram_ [ addr & RAM_MASK ] ; } else if ( ( PPU_OFFSET <= addr ) && ( addr < IO_OFFSET ) ) { bus_ = ppu_ -> Read ( addr ) ; } else if ( ( IO_OFFSET <= addr ) && ( addr < MAPPER_OFFSET ) ) { if ( ( addr == IO_JOY1_ADDR ) || ( addr == IO_JOY2_ADDR ) ) { bus_ = controller_ -> Read ( addr ) ; } else { bus_ = apu_ -> Read ( addr ) ; } } else if ( ( PRG_RAM_OFFSET <= addr ) && ( addr < PRG_ROM_A_OFFSET ) && ( num_prg_ram_banks_ > 0 ) && ! ( prg_reg_ & FLAG_PRG_RAM_DISABLE ) ) { bus_ = prg_ram_ [ prg_ram_bank_ ] [ addr & PRG_RAM_MASK ] ; } else if ( ( PRG_ROM_A_OFFSET <= addr ) && ( addr < PRG_ROM_B_OFFSET ) ) { bus_ = prg_rom_ [ prg_rom_bank_a_ ] [ addr & PRG_ROM_MASK ] ; } else if ( addr >= PRG_ROM_B_OFFSET ) { bus_ = prg_rom_ [ prg_rom_bank_b_ ] [ addr & PRG_ROM_MASK ] ; } return bus_ ; }
Reads the word at the specified address from memory, accounting
 for MMIO and bank switching.
Reads the word at the specified address from memory accounting for MMIO and bank switching .
// Determine which part of memory is being accessed, read the value, // and place it on the bus. // Read from RAM. // Access PPU MMIO. // Read from IO/APU MMIO. // Read from PRG-RAM. // Read from the low half of PRG-ROM. // Read from the high half of PRG-ROM.