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 
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
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:103
RomMSXDOS2(const DeviceConfig &config, Rom &&rom)
Definition: RomMSXDOS2.cc:9
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
STL namespace.
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
Definition: RomMSXDOS2.cc:29
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing...
Definition: RomMSXDOS2.cc:47
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:275
void setUnmapped(byte region)
Select &#39;unmapped&#39; memory for this region.
Definition: RomBlocks.cc:90
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomMSXDOS2.cc:21
#define UNREACHABLE
Definition: unreachable.hh:38