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
6namespace openmsx {
7
8[[nodiscard]] static unsigned getAddressHigh(const DeviceConfig& config)
9{
10 unsigned prim = config.getChildDataAsInt("ps", 0);
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
25byte MSXMirrorDevice::peekMem(word address, EmuTime::param time) const
26{
27 return interface.peekSlottedMem(addressHigh | address, time);
28}
29
30byte MSXMirrorDevice::readMem(word address, EmuTime::param time)
31{
32 return interface.readSlottedMem(addressHigh | address, time);
33}
34
35void MSXMirrorDevice::writeMem(word address, byte value, EmuTime::param time)
36{
37 interface.writeSlottedMem(addressHigh | address, value, time);
38}
39
40const 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
56template<typename Archive>
57void MSXMirrorDevice::serialize(Archive& ar, unsigned /*version*/)
58{
59 ar.template serializeBase<MSXDevice>(*this);
60}
63
64} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
void writeSlottedMem(unsigned address, byte value, EmuTime::param time)
byte peekSlottedMem(unsigned address, EmuTime::param time) const
byte readSlottedMem(unsigned address, EmuTime::param time)
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition MSXDevice.hh:36
MSXMirrorDevice(const DeviceConfig &config)
byte * getWriteCacheLine(word start) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
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.
bool allowUnaligned() const override
By default we don't allow unaligned <mem> specifications in the config file.
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
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.
void serialize(Archive &ar, unsigned version)
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)