openMSX
RomPageNN.cc
Go to the documentation of this file.
1#include "RomPageNN.hh"
2#include "serialize.hh"
3#include "unreachable.hh"
4#include "xrange.hh"
5
6namespace openmsx {
7
8RomPageNN::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
40
41} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
void setUnmapped(unsigned region)
Select 'unmapped' memory for this region.
Definition RomBlocks.cc:92
void setRom(unsigned region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition RomBlocks.cc:104
RomPageNN(const DeviceConfig &config, Rom &&rom, RomType type)
Definition RomPageNN.cc:8
This file implemented 3 utility functions:
Definition Autofire.cc:11
STL namespace.
#define UNREACHABLE
constexpr auto xrange(T e)
Definition xrange.hh:132