openMSX
RomMSXDOS2.cc
Go to the documentation of this file.
1 #include "RomMSXDOS2.hh"
2 #include "Rom.hh"
3 #include "CacheLine.hh"
4 #include "MSXException.hh"
5 #include "serialize.hh"
6 #include "unreachable.hh"
7 
8 namespace openmsx {
9 
10 RomMSXDOS2::RomMSXDOS2(const DeviceConfig& config, std::unique_ptr<Rom> rom_)
11  : Rom16kBBlocks(config, std::move(rom_))
12  , range((*rom)[0x94])
13 {
14  if ((range != 0x00) && (range != 0x60) && (range != 0x7f)) {
15  throw MSXException("Invalid rom for MSXDOS2 mapper");
16  }
18 }
19 
21 {
22  setUnmapped(0);
23  setRom(1, 0);
24  setUnmapped(2);
25  setUnmapped(3);
26 }
27 
28 void RomMSXDOS2::writeMem(word address, byte value, EmuTime::param /*time*/)
29 {
30  switch (range) {
31  case 0x00:
32  if (address != 0x7ff0) return;
33  break;
34  case 0x60:
35  if ((address & 0xf000) != 0x6000) return;
36  break;
37  case 0x7f:
38  if (address != 0x7ffe) return;
39  break;
40  default:
42  }
43  setRom(1, value);
44 }
45 
47 {
48  switch (range) {
49  case 0x00:
50  if (address == (0x7ff0 & CacheLine::HIGH)) return nullptr;
51  break;
52  case 0x60:
53  if ((address & 0xf000) == 0x6000) return nullptr;
54  break;
55  case 0x7f:
56  if (address == (0x7ffe & CacheLine::HIGH)) return nullptr;
57  break;
58  default:
60  }
61  return unmappedWrite;
62 }
63 
64 REGISTER_MSXDEVICE(RomMSXDOS2, "RomMSXDOS2");
65 
66 } // namespace openmsx