24static constexpr auto decryptLUT = [] {
25 std::array<byte, 256> result = {};
27 for (
int i = 0; i < 256; ++i) {
28 result[i] =
byte((((i << 4) & 0x50) |
32 ((i >> 6) & 0x02)) ^ 0x4d);
42 throw MSXException(
"Holy Quran ROM should be exactly 1MB in size");
44 reset(EmuTime::dummy());
56 if (!decrypt) [[unlikely]] {
57 if (
getCPU().isM1Cycle(address)) {
67 if ((0x4000 <= address) && (address < 0xc000)) {
68 unsigned b = (address - 0x4000) >> 13;
69 byte raw = bank[b][address & 0x1fff];
70 return decrypt ? decryptLUT[raw] : raw;
79 if ((0x5000 <= address) && (address < 0x6000)) {
80 byte region = (address >> 10) & 3;
81 bank[region] = &
rom[(value & 127) * 0x2000];
87 if ((0x4000 <= address) && (address < 0xc000)) {
96 if ((0x5000 <= address) && (address < 0x6000)) {
103template<
typename Archive>
107 ar.template serializeBase<MSXDevice>(*
this);
109 std::array<unsigned, 4> bb;
110 if constexpr (Archive::IS_LOADER) {
111 ar.serialize(
"banks", bb);
113 bank[i] = &
rom[(b & 127) * 0x2000];
117 b = narrow<unsigned>((bank[i] - &
rom[0]) / 0x2000);
119 ar.serialize(
"banks", bb);
122 ar.serialize(
"decrypt", decrypt);
133byte RomHolyQuran2::Blocks::read(
unsigned address)
135 if ((address < 0x4000) || (address >= 0xc000))
return 255;
136 unsigned page = (address - 0x4000) / 0x2000;
137 auto& device =
OUTER(RomHolyQuran2, romBlocks);
138 return narrow<byte>((device.bank[page] - &device.rom[0]) / 0x2000);
#define REGISTER_MSXDEVICE(CLASS, NAME)
static std::array< byte, 0x10000 > unmappedRead
static std::array< byte, 0x10000 > unmappedWrite
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
RomHolyQuran2(const DeviceConfig &config, Rom &&rom)
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
void serialize(Archive &ar, unsigned version)
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
void reset(EmuTime::param time) override
This method is called on reset.
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
constexpr auto enumerate(Iterable &&iterable)
Heavily inspired by Nathan Reed's blog post: Python-Like enumerate() In C++17 http://reedbeta....
This file implemented 3 utility functions:
uint8_t byte
8 bit unsigned integer
uint16_t word
16 bit unsigned integer
constexpr void fill(ForwardRange &&range, const T &value)
#define OUTER(type, member)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)