27static constexpr auto decryptLUT = [] {
28 std::array<byte, 256> result = {};
30 for (
int i = 0; i < 256; ++i) {
31 result[i] =
byte((((i << 4) & 0x50) |
35 ((i >> 6) & 0x02)) ^ 0x4d);
45 throw MSXException(
"Holy Quran ROM should be exactly 1MB in size");
47 reset(EmuTime::dummy());
59 if (!decrypt) [[unlikely]] {
60 if (
getCPU().isM1Cycle(address)) {
70 if ((0x4000 <= address) && (address < 0xc000)) {
71 unsigned b = (address - 0x4000) >> 13;
72 byte raw = bank[b][address & 0x1fff];
73 return decrypt ? decryptLUT[raw] : raw;
82 if ((0x5000 <= address) && (address < 0x6000)) {
83 byte region = (address >> 10) & 3;
84 bank[region] = &
rom[(value & 127) * 0x2000];
90 if ((0x4000 <= address) && (address < 0xc000)) {
99 if ((0x5000 <= address) && (address < 0x6000)) {
106template<
typename Archive>
110 ar.template serializeBase<MSXDevice>(*
this);
112 std::array<unsigned, 4> bb;
113 if constexpr (Archive::IS_LOADER) {
114 ar.serialize(
"banks", bb);
116 bank[i] = &
rom[(b & 127) * 0x2000];
120 b = narrow<unsigned>((bank[i] - &
rom[0]) / 0x2000);
122 ar.serialize(
"banks", bb);
125 ar.serialize(
"decrypt", decrypt);
136unsigned RomHolyQuran2::Blocks::readExt(
unsigned address)
138 if ((address < 0x4000) || (address >= 0xc000))
return unsigned(-1);
139 unsigned page = (address - 0x4000) / 0x2000;
140 auto& device =
OUTER(RomHolyQuran2, romBlocks);
141 return narrow<unsigned>(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)