25 std::unique_ptr<Rom> rom_,
SubType subType)
27 , sramEnableBit((subType == WIZARDRY) ? 0x80
28 : rom->getSize() / 0x2000)
29 , sramPages(((subType == KOEI_8) || (subType == KOEI_32))
32 sram = make_unique<SRAM>(
34 (subType ==
KOEI_32) ? 0x8000 : 0x2000, config);
46 for (
int i = 2; i < 6; i++) {
57 if ((0x6000 <= address) && (address < 0x8000)) {
59 byte region = ((address >> 11) & 3) + 2;
60 if (value & sramEnableBit) {
61 sramEnabled |= (1 << region) & sramPages;
62 sramBlock[region] = value & ((
sram->getSize() / 0x2000) - 1);
63 setBank(region, &(*
sram)[sramBlock[region] * 0x2000], value);
65 sramEnabled &= ~(1 << region);
70 if ((1 << bank) & sramEnabled) {
72 word addr = (sramBlock[
bank] * 0x2000) + (address & 0x1FFF);
73 sram->write(addr, value);
80 if ((0x6000 <= address) && (address < 0x8000)) {
83 }
else if ((1 << (address >> 13)) & sramEnabled) {
91 template<
typename Archive>
94 ar.template serializeBase<Rom8kBBlocks>(*this);
95 ar.serialize(
"sramEnabled", sramEnabled);
96 ar.serialize(
"sramBlock", sramBlock);