src/memory/mappers/std_banked.cc
/*
 * Reads a value from the given address, accounting for MMIO and bank
 * switching. If the address given leads to an open bus, the last value
 * that was placed on the bus is returned instead.
 *
 * Assumes that Connect has been called on valid Cpu/Ppu/Apu classes for this
 * memory class.
 * Assumes that AddController has been called by the calling object on
 * a valid Input object.
 */
Reads a value from the given address, accounting for MMIO and bank
switching. If the address given leads to an open bus, the last value
that was placed on the bus is returned instead.

Assumes that Connect has been called on valid Cpu/Ppu/Apu classes for this
memory class.
Assumes that AddController has been called by the calling object on
a valid Input object.
Reads a value from the given address accounting for MMIO and bank switching . If the address given leads to an open bus the last value that was placed on the bus is returned instead . Assumes that Connect has been called on valid Cpu / Ppu / Apu classes for this memory class . Assumes that AddController has been called by the calling object on a valid Input object .
DataWord StdBanked::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 ((BAT_OFFSET <= addr) && (addr < BANK_OFFSET)) {
    bus_ = bat_[addr & BAT_MASK];
  } else if ((BANK_OFFSET <= addr) && (addr < FIXED_BANK_OFFSET)) {
    bus_ = cart_[current_bank_][addr & BANK_ADDR_MASK];
  } else if (addr >= FIXED_BANK_OFFSET) {
    bus_ = cart_[fixed_bank_][addr & BANK_ADDR_MASK];
  }
  return bus_;
}
DataWord StdBanked :: 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 ( ( BAT_OFFSET <= addr ) && ( addr < BANK_OFFSET ) ) { bus_ = bat_ [ addr & BAT_MASK ] ; } else if ( ( BANK_OFFSET <= addr ) && ( addr < FIXED_BANK_OFFSET ) ) { bus_ = cart_ [ current_bank_ ] [ addr & BANK_ADDR_MASK ] ; } else if ( addr >= FIXED_BANK_OFFSET ) { bus_ = cart_ [ fixed_bank_ ] [ addr & BANK_ADDR_MASK ] ; } return bus_ ; }
Reads a value from the given address, accounting for MMIO and bank
 switching.
Reads a value from the given address accounting for MMIO and bank switching .
// Detect where in memory we need to access and place the value on the bus. // Read from RAM. // Access PPU MMIO. // Read from IO/APU MMIO. // Read from the roms WRAM/Battery. // Read from the switchable bank. // Read from the fixed bank.