#include Bank::Bank() : banks(), current_bank(nullptr) {} void Bank::addBank(u8 idx, Mem_device* dev) { banks[idx] = dev; } void Bank::setBank(u8 idx) { auto it = banks.find(idx); if(it == banks.end()) current_bank = nullptr; else current_bank = it->second; } void Bank::write8(u16 addr, u8 data) { if(current_bank == nullptr) return; current_bank->write8(addr, data); } u8 Bank::read8(u16 addr) { if(current_bank == nullptr) return 0xFFu; return current_bank->read8(addr); } void Bank::write16(u16 addr, u16 data) { if(current_bank == nullptr) return; current_bank->write16(addr, data); } u16 Bank::read16(u16 addr) { if(current_bank == nullptr) return 0xFFu; return current_bank->read16(addr); }