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
8namespace openmsx {
9
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
22void RomMSXDOS2::reset(EmuTime::param /*time*/)
23{
24 setUnmapped(0);
25 setRom(1, 0);
26 setUnmapped(2);
27 setUnmapped(3);
28}
29
30void 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
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.data();
64}
65
67
68} // namespace openmsx
Definition: one_of.hh:7
static std::array< byte, 0x10000 > unmappedWrite
Definition: MSXDevice.hh:303
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:103
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:91
RomMSXDOS2(const DeviceConfig &config, Rom &&rom)
Definition: RomMSXDOS2.cc:10
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
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomMSXDOS2.cc:22
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
constexpr unsigned HIGH
Definition: CacheLine.hh:10
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
STL namespace.
#define UNREACHABLE
Definition: unreachable.hh:38