30 static byte decryptLUT[256];
33 :
MSXRom(config, std::move(rom_))
39 for (
int i = 0; i < 256; ++i) {
40 decryptLUT[i] = (((i << 4) & 0x50) |
44 ((i >> 6) & 0x02)) ^ 0x4d;
47 if (
rom->getSize() != 0x100000) {
48 throw MSXException(
"Holy Quaran ROM should be exactly 1MB in size");
59 for (
int i = 0; i < 4; ++i) {
69 if (
getCPU().isM1Cycle(address)) {
79 if ((0x4000 <= address) && (address < 0xc000)) {
80 unsigned b = (address - 0x4000) >> 13;
81 byte raw = bank[b][address & 0x1fff];
82 return decrypt ? decryptLUT[raw] : raw;
91 if ((0x5000 <= address) && (address < 0x6000)) {
92 byte region = (address >> 10) & 3;
93 bank[region] = &(*rom)[(value & 127) * 0x2000];
99 if ((0x4000 <= address) && (address < 0xc000)) {
108 if ((0x5000 <= address) && (address < 0x6000)) {
115 template<
typename Archive>
119 ar.template serializeBase<MSXDevice>(*this);
123 ar.serialize(
"banks", b);
124 for (
unsigned i = 0; i < 4; ++i) {
125 bank[i] = &(*rom)[(b[i] & 127) * 0x2000];
128 for (
unsigned i = 0; i < 4; ++i) {
129 b[i] = (bank[i] - &(*rom)[0]) / 0x2000;
131 ar.serialize(
"banks", b);
134 ar.serialize(
"decrypt", decrypt);
148 if ((address < 0x4000) || (address >= 0xc000))
return 255;
149 unsigned page = (address - 0x4000) / 0x2000;
150 return (device.bank[page] - &(*device.
rom)[0]) / 0x2000;