12MSXMultiMemDevice::Range::Range(
13 unsigned base_,
unsigned size_, MSXDevice& device_)
14 : base(base_),
size(size_), device(&device_)
31static constexpr bool isInside(
unsigned x,
unsigned start,
unsigned size)
33 return (x - start) < size;
36static constexpr bool overlap(
unsigned start1,
unsigned size1,
37 unsigned start2,
unsigned size2)
39 return (isInside(start1, start2, size2)) ||
40 (isInside(start1 + size1 - 1, start2, size2));
46 return overlap(base, size, rn.base, rn.size);
52 assert(
canAdd(base, size));
64 [](
auto& rn) {
return rn.device; }));
76 for (
const auto& r :
ranges) {
77 const auto& name = r.device->getName();
84const MSXMultiMemDevice::Range& MSXMultiMemDevice::searchRange(
unsigned address)
const
87 assert(it !=
ranges.end());
91MSXDevice* MSXMultiMemDevice::searchDevice(
unsigned address)
const
93 return searchRange(address).device;
98 return searchDevice(address)->
readMem(address, time);
103 return searchDevice(address)->
peekMem(address, time);
108 searchDevice(address)->
writeMem(address, value, time);
117 const auto& range = searchRange(start);
118 if (((range.base + range.size) &
CacheLine::HIGH) == start) [[unlikely]] {
123 return range.device->getReadCacheLine(start);
129 const auto& range = searchRange(start);
130 if (((range.base + range.size) &
CacheLine::HIGH) == start) [[unlikely]] {
133 return range.device->getWriteCacheLine(start);
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
virtual byte readMem(word address, EmuTime::param time)
Read a byte from a location at a certain time from this device.
virtual void writeMem(word address, byte value, EmuTime::param time)
Write a given byte to a given location at a certain time to this device.
virtual byte peekMem(word address, EmuTime::param time) const
Read a byte from a given memory location.
MSXCPUInterface & getCPUInterface() const
void add(MSXDevice &device, unsigned base, unsigned size)
~MSXMultiMemDevice() override
bool canAdd(unsigned base, unsigned size)
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
const std::string & getName() const override
Returns a human-readable name for this device.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
std::vector< MSXDevice * > getDevices() const
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.
void remove(MSXDevice &device, unsigned base, unsigned size)
void getNameList(TclObject &result) const override
Returns list of name(s) of this device.
void addListElement(const T &t)
zstring_view getString() const
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
constexpr bool none_of(InputRange &&range, UnaryPredicate pred)
auto find_if(InputRange &&range, UnaryPredicate pred)
size_t size(std::string_view utf8)
constexpr auto transform(Range &&range, UnaryOp op)
constexpr auto drop_back(Range &&range, size_t n)
auto to_vector(Range &&range) -> std::vector< detail::ToVectorType< T, decltype(std::begin(range))> >
auto rfind_unguarded(RANGE &range, const VAL &val, Proj proj={})
Similar to the find(_if)_unguarded functions above, but searches from the back to front.
constexpr auto begin(const zstring_view &x)