openMSX
RomMSXDOS2.cc
Go to the documentation of this file.
1 #include "RomMSXDOS2.hh"
2 #include "CacheLine.hh"
3 #include "MSXException.hh"
4 #include "one_of.hh"
5 #include "serialize.hh"
6 #include "unreachable.hh"
7 
8 namespace openmsx {
9 
10 RomMSXDOS2::RomMSXDOS2(const DeviceConfig& config, Rom&& rom_)
11  : Rom16kBBlocks(config, std::move(rom_))
12  , range(rom[0x94])
13 {
14  if (range != one_of(0x00, 0x60, 0x7f)) {
15  throw MSXException(
16  "Invalid rom with for MSXDOS2 mapper: unsupported range 0x",
17  hex_string<2>(range));
18  }
19  reset(EmuTime::dummy());
20 }
21 
22 void RomMSXDOS2::reset(EmuTime::param /*time*/)
23 {
24  setUnmapped(0);
25  setRom(1, 0);
26  setUnmapped(2);
27  setUnmapped(3);
28 }
29 
30 void RomMSXDOS2::writeMem(word address, byte value, EmuTime::param /*time*/)
31 {
32  switch (range) {
33  case 0x00:
34  if (address != 0x7ff0) return;
35  break;
36  case 0x60:
37  if ((address & 0xf000) != 0x6000) return;
38  break;
39  case 0x7f:
40  if (address != 0x7ffe) return;
41  break;
42  default:
44  }
45  setRom(1, value);
46 }
47 
48 byte* RomMSXDOS2::getWriteCacheLine(word address) const
49 {
50  switch (range) {
51  case 0x00:
52  if (address == (0x7ff0 & CacheLine::HIGH)) return nullptr;
53  break;
54  case 0x60:
55  if ((address & 0xf000) == 0x6000) return nullptr;
56  break;
57  case 0x7f:
58  if (address == (0x7ffe & CacheLine::HIGH)) return nullptr;
59  break;
60  default:
62  }
63  return unmappedWrite;
64 }
65 
67 
68 } // namespace openmsx
one_of.hh
openmsx::RomMSXDOS2::getWriteCacheLine
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: RomMSXDOS2.cc:48
serialize.hh
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
openmsx::MSXDevice::unmappedWrite
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:301
openmsx::RomMSXDOS2::writeMem
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:30
MSXException.hh
openmsx::MSXException
Definition: MSXException.hh:10
openmsx::CacheLine::HIGH
constexpr unsigned HIGH
Definition: CacheLine.hh:10
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
UNREACHABLE
#define UNREACHABLE
Definition: unreachable.hh:38
openmsx::RomBlocks::setRom
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:104
one_of
Definition: one_of.hh:7
openmsx::RomBlocks::setUnmapped
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:91
RomMSXDOS2.hh
openmsx::RomBlocks
Definition: RomBlocks.hh:14
CacheLine.hh
openmsx::Rom
Definition: Rom.hh:21
openmsx::RomMSXDOS2
Definition: RomMSXDOS2.hh:9
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
unreachable.hh
openmsx::RomMSXDOS2::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomMSXDOS2.cc:22
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::RomMSXDOS2::RomMSXDOS2
RomMSXDOS2(const DeviceConfig &config, Rom &&rom)
Definition: RomMSXDOS2.cc:10