openMSX
MSXMirrorDevice.cc
Go to the documentation of this file.
1 #include "MSXMirrorDevice.hh"
2 #include "MSXCPUInterface.hh"
3 #include "MSXException.hh"
4 #include "serialize.hh"
5 
6 namespace openmsx {
7 
8 static unsigned getAddressHigh(const DeviceConfig& config)
9 {
10  unsigned prim = config.getChildDataAsInt("ps");
11  unsigned sec = config.getChildDataAsInt("ss", 0);
12  if ((prim >= 4) || (sec >= 4)) {
13  throw MSXException("Invalid slot in mirror device.");
14  }
15  return (prim << 18) | (sec << 16);
16 }
17 
19  : MSXDevice(config)
20  , interface(getCPUInterface()) // frequently used, so cache
21  , addressHigh(getAddressHigh(config))
22 {
23 }
24 
25 byte MSXMirrorDevice::peekMem(word address, EmuTime::param time) const
26 {
27  return interface.peekSlottedMem(addressHigh | address, time);
28 }
29 
30 byte MSXMirrorDevice::readMem(word address, EmuTime::param time)
31 {
32  return interface.readSlottedMem(addressHigh | address, time);
33 }
34 
35 void MSXMirrorDevice::writeMem(word address, byte value, EmuTime::param time)
36 {
37  interface.writeSlottedMem(addressHigh | address, value, time);
38 }
39 
41 {
42  return nullptr;
43 }
44 
46 {
47  return nullptr;
48 }
49 
50 template<typename Archive>
51 void MSXMirrorDevice::serialize(Archive& ar, unsigned /*version*/)
52 {
53  ar.template serializeBase<MSXDevice>(*this);
54 }
57 
58 } // namespace openmsx
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading...
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.
void serialize(Archive &ar, unsigned version)
byte readSlottedMem(unsigned address, EmuTime::param time)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX...
Definition: MSXDevice.hh:31
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing...
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:1006
void writeSlottedMem(unsigned address, byte value, EmuTime::param time)
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
byte peekSlottedMem(unsigned address, EmuTime::param time) const
MSXMirrorDevice(const DeviceConfig &config)