OXYGENHUB
◆ main openmsx / src / memory / RomHolyQuran.cc
1003 B · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
// Holy Qu'ran  cartridge
2
//  It is like an ASCII 8KB, but using the 5000h, 5400h, 5800h and 5C00h
3
//  addresses.
4
5
#include "RomHolyQuran.hh"
6
#include "serialize.hh"
7
#include "xrange.hh"
8
9
namespace openmsx {
10
11
RomHolyQuran::RomHolyQuran(const DeviceConfig& config, Rom&& rom_)
12
	: Rom8kBBlocks(config, std::move(rom_))
13
{
14
	reset(EmuTime::dummy());
15
}
16
17
void RomHolyQuran::reset(EmuTime /*time*/)
18
{
19
	setUnmapped(0);
20
	setUnmapped(1);
21
	for (auto i : xrange(2, 6)) {
22
		setRom(i, 0);
23
	}
24
	setUnmapped(6);
25
	setUnmapped(7);
26
}
27
28
void RomHolyQuran::writeMem(uint16_t address, byte value, EmuTime /*time*/)
29
{
30
	// TODO are switch addresses mirrored?
31
	if ((0x5000 <= address) && (address < 0x6000)) {
32
		byte region = ((address >> 10) & 3) + 2;
33
		setRom(region, value);
34
	}
35
}
36
37
byte* RomHolyQuran::getWriteCacheLine(uint16_t address)
38
{
39
	if ((0x5000 <= address) && (address < 0x6000)) {
40
		return nullptr;
41
	} else {
42
		return unmappedWrite.data();
43
	}
44
}
45
46
REGISTER_MSXDEVICE(RomHolyQuran, "RomHolyQuran");
47
48
} // namespace openmsx