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
void setRom(byte region, int block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:89
REGISTER_MSXDEVICE(DebugDevice,"DebugDevice")
static param dummy()
Definition: EmuTime.hh:21
unsigned char byte
8 bit unsigned integer
Definition: openmsx.hh:33
STL namespace.
RomMSXDOS2(const DeviceConfig &config, std::unique_ptr< Rom > rom)
Definition: RomMSXDOS2.cc:10
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:28
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing...
Definition: RomMSXDOS2.cc:46
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:7
unsigned short word
16 bit unsigned integer
Definition: openmsx.hh:38
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:267
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:76
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomMSXDOS2.cc:20
#define UNREACHABLE
Definition: unreachable.hh:56