2016-01-27 11:31:39 +00:00
|
|
|
//20000-fffff
|
2016-03-02 11:19:33 +00:00
|
|
|
auto Cartridge::romRead(uint20 addr) -> uint8 {
|
2016-01-28 11:39:49 +00:00
|
|
|
if(!rom.data) return 0x00;
|
2016-03-02 11:19:33 +00:00
|
|
|
uint28 offset;
|
|
|
|
switch(addr.byte(2)) {
|
|
|
|
case 2: offset = r.bank_rom0 << 16 | addr.bits(0,15); break; //20000-2ffff
|
|
|
|
case 3: offset = r.bank_rom1 << 16 | addr.bits(0,15); break; //30000-3ffff
|
|
|
|
default: offset = r.bank_rom2 << 20 | addr.bits(0,19); break; //40000-fffff
|
|
|
|
}
|
|
|
|
return rom.data[offset & rom.mask];
|
2016-01-27 11:31:39 +00:00
|
|
|
}
|
|
|
|
|
2016-03-02 11:19:33 +00:00
|
|
|
auto Cartridge::romWrite(uint20 addr, uint8 data) -> void {
|
2016-01-27 11:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//10000-1ffff
|
2016-03-02 11:19:33 +00:00
|
|
|
auto Cartridge::ramRead(uint20 addr) -> uint8 {
|
2016-01-28 11:39:49 +00:00
|
|
|
if(!ram.data) return 0x00;
|
2016-03-02 11:19:33 +00:00
|
|
|
uint24 offset = r.bank_sram << 16 | addr.bits(0,15);
|
|
|
|
return ram.data[offset & ram.mask];
|
2016-01-27 11:31:39 +00:00
|
|
|
}
|
|
|
|
|
2016-03-02 11:19:33 +00:00
|
|
|
auto Cartridge::ramWrite(uint20 addr, uint8 data) -> void {
|
2016-01-28 11:39:49 +00:00
|
|
|
if(!ram.data) return;
|
2016-03-02 11:19:33 +00:00
|
|
|
uint24 offset = r.bank_sram << 16 | addr.bits(0,15);
|
|
|
|
ram.data[offset & ram.mask] = data;
|
2016-01-27 11:31:39 +00:00
|
|
|
}
|