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 
40 const byte* MSXMirrorDevice::getReadCacheLine(word /*start*/) const
41 {
42  return nullptr;
43 }
44 
46 {
47  return nullptr;
48 }
49 
51 {
52  // OK, because this device doesn't call any 'fillDeviceXXXCache()'functions.
53  return true;
54 }
55 
56 template<typename Archive>
57 void MSXMirrorDevice::serialize(Archive& ar, unsigned /*version*/)
58 {
59  ar.template serializeBase<MSXDevice>(*this);
60 }
63 
64 } // namespace openmsx
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:32
openmsx::MSXMirrorDevice
Definition: MSXMirrorDevice.hh:11
serialize.hh
openmsx::MSXMirrorDevice::getWriteCacheLine
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: MSXMirrorDevice.cc:45
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
MSXException.hh
openmsx::MSXCPUInterface::peekSlottedMem
byte peekSlottedMem(unsigned address, EmuTime::param time) const
Definition: MSXCPUInterface.cc:731
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
INSTANTIATE_SERIALIZE_METHODS
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
openmsx::MSXCPUInterface::writeSlottedMem
void writeSlottedMem(unsigned address, byte value, EmuTime::param time)
Definition: MSXCPUInterface.cc:765
openmsx::MSXMirrorDevice::allowUnaligned
bool allowUnaligned() const override
By default we don't allow unaligned <mem> specifications in the config file.
Definition: MSXMirrorDevice.cc:50
MSXMirrorDevice.hh
openmsx::MSXMirrorDevice::getReadCacheLine
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
Definition: MSXMirrorDevice.cc:40
openmsx::MSXMirrorDevice::serialize
void serialize(Archive &ar, unsigned version)
Definition: MSXMirrorDevice.cc:57
openmsx::MSXMirrorDevice::MSXMirrorDevice
MSXMirrorDevice(const DeviceConfig &config)
Definition: MSXMirrorDevice.cc:18
openmsx::MSXMirrorDevice::readMem
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: MSXMirrorDevice.cc:30
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
MSXCPUInterface.hh
openmsx::MSXCPUInterface::readSlottedMem
byte readSlottedMem(unsigned address, EmuTime::param time)
Definition: MSXCPUInterface.cc:748
openmsx::MSXMirrorDevice::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: MSXMirrorDevice.cc:35
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::MSXMirrorDevice::peekMem
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition: MSXMirrorDevice.cc:25