OXYGENHUB
◆ main openmsx / src / memory / RomMSXDOS2.cc
1.3 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#include "RomMSXDOS2.hh"
2
3
#include "CacheLine.hh"
4
#include "MSXException.hh"
5
6
#include "one_of.hh"
7
#include "unreachable.hh"
8
9
namespace openmsx {
10
11
RomMSXDOS2::RomMSXDOS2(const DeviceConfig& config, Rom&& rom_)
12
	: Rom16kBBlocks(config, std::move(rom_))
13
	, range(rom[0x94])
14
{
15
	if (range != one_of(0x00, 0x60, 0x7f)) {
16
		throw MSXException(
17
			"Invalid rom with for MSXDOS2 mapper: unsupported range 0x",
18
			hex_string<2>(range));
19
	}
20
	reset(EmuTime::dummy());
21
}
22
23
void RomMSXDOS2::reset(EmuTime /*time*/)
24
{
25
	setUnmapped(0);
26
	setRom(1, 0);
27
	setUnmapped(2);
28
	setUnmapped(3);
29
}
30
31
void RomMSXDOS2::writeMem(uint16_t address, byte value, EmuTime /*time*/)
32
{
33
	switch (range) {
34
	case 0x00:
35
		if (address != 0x7ff0) return;
36
		break;
37
	case 0x60:
38
		if ((address & 0xf000) != 0x6000) return;
39
		break;
40
	case 0x7f:
41
		if (address != 0x7ffe) return;
42
		break;
43
	default:
44
		UNREACHABLE;
45
	}
46
	setRom(1, value);
47
}
48
49
byte* RomMSXDOS2::getWriteCacheLine(uint16_t address)
50
{
51
	switch (range) {
52
	case 0x00:
53
		if (address == (0x7ff0 & CacheLine::HIGH)) return nullptr;
54
		break;
55
	case 0x60:
56
		if ((address & 0xf000) == 0x6000) return nullptr;
57
		break;
58
	case 0x7f:
59
		if (address == (0x7ffe & CacheLine::HIGH)) return nullptr;
60
		break;
61
	default:
62
		UNREACHABLE;
63
	}
64
	return unmappedWrite.data();
65
}
66
67
REGISTER_MSXDEVICE(RomMSXDOS2, "RomMSXDOS2");
68
69
} // namespace openmsx