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