2016-06-28 10:43:47 +00:00
|
|
|
auto Cartridge::MMM01::readIO(uint16 addr) -> uint8 {
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0x8000) == 0x0000) { //$0000-7fff
|
2016-06-28 10:43:47 +00:00
|
|
|
if(mode == 0) return cartridge.readROM(addr);
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xc000) == 0x0000) { //$0000-3fff
|
2016-06-28 10:43:47 +00:00
|
|
|
return cartridge.readROM(0x8000 + (rom.base << 14) + (uint14)addr);
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xc000) == 0x4000) { //$4000-7fff
|
2016-06-28 10:43:47 +00:00
|
|
|
return cartridge.readROM(0x8000 + (rom.base << 14) + (rom.select<< 14) + (uint14)addr);
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0xa000) { //$a000-bfff
|
2016-06-28 10:43:47 +00:00
|
|
|
if(ram.enable) return cartridge.readRAM(ram.select << 13 | (uint13)addr);
|
2016-01-08 09:23:46 +00:00
|
|
|
return 0xff;
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|
|
|
|
|
2016-01-08 09:23:46 +00:00
|
|
|
return 0xff;
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|
|
|
|
|
2016-06-28 10:43:47 +00:00
|
|
|
auto Cartridge::MMM01::writeIO(uint16 addr, uint8 data) -> void {
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0x0000) { //$0000-1fff
|
2016-06-28 10:43:47 +00:00
|
|
|
if(mode == 0) {
|
|
|
|
mode = 1;
|
2011-01-05 09:59:22 +00:00
|
|
|
} else {
|
2016-06-28 10:43:47 +00:00
|
|
|
ram.enable= data.bits(0,3) == 0x0a;
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0x2000) { //$2000-3fff
|
2016-06-28 10:43:47 +00:00
|
|
|
if(mode == 0) {
|
|
|
|
rom.base = data.bits(0,5);
|
2011-01-05 09:59:22 +00:00
|
|
|
} else {
|
2016-06-28 10:43:47 +00:00
|
|
|
rom.select = data;
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0x4000) { //$4000-5fff
|
2016-06-28 10:43:47 +00:00
|
|
|
if(mode == 1) {
|
|
|
|
ram.select = data;
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0x6000) { //$6000-7fff
|
2011-01-05 09:59:22 +00:00
|
|
|
//unknown purpose
|
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0xa000) { //$a000-bfff
|
2016-06-28 10:43:47 +00:00
|
|
|
if(ram.enable) cartridge.writeRAM(ram.select << 13 | (uint13)addr, data);
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-21 07:36:48 +00:00
|
|
|
auto Cartridge::MMM01::power() -> void {
|
2016-06-28 10:43:47 +00:00
|
|
|
rom.base = 0x00;
|
|
|
|
rom.select = 0x01;
|
|
|
|
ram.enable = false;
|
|
|
|
ram.select = 0x00;
|
|
|
|
mode = 0;
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|