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("Invalid rom for MSXDOS2 mapper");
15  }
17 }
18 
20 {
21  setUnmapped(0);
22  setRom(1, 0);
23  setUnmapped(2);
24  setUnmapped(3);
25 }
26 
27 void RomMSXDOS2::writeMem(word address, byte value, EmuTime::param /*time*/)
28 {
29  switch (range) {
30  case 0x00:
31  if (address != 0x7ff0) return;
32  break;
33  case 0x60:
34  if ((address & 0xf000) != 0x6000) return;
35  break;
36  case 0x7f:
37  if (address != 0x7ffe) return;
38  break;
39  default:
41  }
42  setRom(1, value);
43 }
44 
46 {
47  switch (range) {
48  case 0x00:
49  if (address == (0x7ff0 & CacheLine::HIGH)) return nullptr;
50  break;
51  case 0x60:
52  if ((address & 0xf000) == 0x6000) return nullptr;
53  break;
54  case 0x7f:
55  if (address == (0x7ffe & CacheLine::HIGH)) return nullptr;
56  break;
57  default:
59  }
60  return unmappedWrite;
61 }
62 
63 REGISTER_MSXDEVICE(RomMSXDOS2, "RomMSXDOS2");
64 
65 } // namespace openmsx
void setRom(byte region, int block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:86
REGISTER_MSXDEVICE(DebugDevice,"DebugDevice")
static param dummy()
Definition: EmuTime.hh:21
RomMSXDOS2(const DeviceConfig &config, Rom &&rom)
Definition: RomMSXDOS2.cc:9
STL namespace.
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:27
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing...
Definition: RomMSXDOS2.cc:45
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
unsigned char byte
8 bit unsigned integer
Definition: openmsx.hh:25
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:267
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:73
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomMSXDOS2.cc:19
unsigned short word
16 bit unsigned integer
Definition: openmsx.hh:28
#define UNREACHABLE
Definition: unreachable.hh:35