OXYGENHUB
◆ main openmsx / src / memory / RomPageNN.cc
934 B · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#include "RomPageNN.hh"
2
3
#include "unreachable.hh"
4
#include "xrange.hh"
5
6
namespace openmsx {
7
8
RomPageNN::RomPageNN(const DeviceConfig& config, Rom&& rom_, RomType type)
9
	: Rom8kBBlocks(config, std::move(rom_))
10
{
11
	const auto pages = [&] {
12
		switch (type) {
13
			using enum RomType;
14
			case PAGE0:    return 0b0001;
15
			case PAGE1:    return 0b0010;
16
			case PAGE01:   return 0x0011;
17
			case PAGE2:    return 0b0100;
18
			case PAGE12:   return 0b0110;
19
			case PAGE012:  return 0b0111;
20
			case PAGE3:    return 0b1000;
21
			case PAGE23:   return 0b1100;
22
			case PAGE123:  return 0b1110;
23
			case PAGE0123: return 0b1111;
24
			default: UNREACHABLE;
25
		}
26
	}();
27
	int bank = 0;
28
	for (auto page : xrange(4)) {
29
		if (pages & (1 << page)) {
30
			setRom(page * 2 + 0, bank++);
31
			setRom(page * 2 + 1, bank++);
32
		} else {
33
			setUnmapped(page * 2 + 0);
34
			setUnmapped(page * 2 + 1);
35
		}
36
	}
37
}
38
39
REGISTER_MSXDEVICE(RomPageNN, "RomPageNN");
40
41
} // namespace openmsx