2015-11-21 07:36:48 +00:00
|
|
|
auto Cartridge::HuC1::mmio_read(uint16 addr) -> uint8 {
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xc000) == 0x0000) { //$0000-3fff
|
2011-01-05 09:59:22 +00:00
|
|
|
return cartridge.rom_read(addr);
|
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xc000) == 0x4000) { //$4000-7fff
|
2011-01-05 09:59:22 +00:00
|
|
|
return cartridge.rom_read((rom_select << 14) | (addr & 0x3fff));
|
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0xa000) { //$a000-bfff
|
|
|
|
return cartridge.ram_read((ram_select << 13) | (addr & 0x1fff));
|
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
|
|
|
}
|
|
|
|
|
2015-11-21 07:36:48 +00:00
|
|
|
auto Cartridge::HuC1::mmio_write(uint16 addr, uint8 data) -> void {
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0x0000) { //$0000-1fff
|
|
|
|
ram_writable = (data & 0x0f) == 0x0a;
|
2011-01-05 09:59:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0x2000) { //$2000-3fff
|
2011-01-05 09:59:22 +00:00
|
|
|
rom_select = data;
|
2011-12-26 10:49:48 +00:00
|
|
|
if(rom_select == 0) rom_select = 1;
|
2011-01-05 09:59:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0x4000) { //$4000-5fff
|
2011-01-05 09:59:22 +00:00
|
|
|
ram_select = data;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0x6000) { //$6000-7fff
|
|
|
|
model = data & 0x01;
|
2011-01-05 09:59:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-26 10:49:48 +00:00
|
|
|
if((addr & 0xe000) == 0xa000) { //$a000-bfff
|
|
|
|
if(ram_writable == false) return;
|
|
|
|
return cartridge.ram_write((ram_select << 13) | (addr & 0x1fff), data);
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-21 07:36:48 +00:00
|
|
|
auto Cartridge::HuC1::power() -> void {
|
2011-12-26 10:49:48 +00:00
|
|
|
ram_writable = false;
|
2011-01-05 09:59:22 +00:00
|
|
|
rom_select = 0x01;
|
|
|
|
ram_select = 0x00;
|
2011-12-26 10:49:48 +00:00
|
|
|
model = 0;
|
2011-01-05 09:59:22 +00:00
|
|
|
}
|