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 
6 namespace openmsx {
7 
8 RomPageNN::RomPageNN(const DeviceConfig& config, Rom&& rom_, RomType type)
9  : Rom8kBBlocks(config, std::move(rom_))
10 {
11  const byte pages = [&] {
12  switch (type) {
13  case ROM_PAGE0: return 0b0001;
14  case ROM_PAGE1: return 0b0010;
15  case ROM_PAGE01: return 0x0011;
16  case ROM_PAGE2: return 0b0100;
17  case ROM_PAGE12: return 0b0110;
18  case ROM_PAGE012: return 0b0111;
19  case ROM_PAGE3: return 0b1000;
20  case ROM_PAGE23: return 0b1100;
21  case ROM_PAGE123: return 0b1110;
22  case ROM_PAGE0123: return 0b1111;
23  default: UNREACHABLE; return 0;
24  }
25  }();
26  int bank = 0;
27  for (auto page : xrange(4)) {
28  if (pages & (1 << page)) {
29  setRom(page * 2 + 0, bank++);
30  setRom(page * 2 + 1, bank++);
31  } else {
32  setUnmapped(page * 2 + 0);
33  setUnmapped(page * 2 + 1);
34  }
35  }
36 }
37 
39 
40 } // namespace openmsx
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:105
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:92
RomPageNN(const DeviceConfig &config, Rom &&rom, RomType type)
Definition: RomPageNN.cc:8
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
@ ROM_PAGE1
Definition: RomTypes.hh:66
@ ROM_PAGE2
Definition: RomTypes.hh:68
@ ROM_PAGE01
Definition: RomTypes.hh:67
@ ROM_PAGE3
Definition: RomTypes.hh:71
@ ROM_PAGE12
Definition: RomTypes.hh:69
@ ROM_PAGE123
Definition: RomTypes.hh:73
@ ROM_PAGE23
Definition: RomTypes.hh:72
@ ROM_PAGE0123
Definition: RomTypes.hh:74
@ ROM_PAGE012
Definition: RomTypes.hh:70
@ ROM_PAGE0
Definition: RomTypes.hh:65
#define UNREACHABLE
Definition: unreachable.hh:38
constexpr auto xrange(T e)
Definition: xrange.hh:155