14 MSXMultiMemDevice::Range::Range(
15 unsigned base_,
unsigned size_,
MSXDevice& device_)
16 : base(base_),
size(size_), device(&device_)
22 return (base == other.base) &&
23 (
size == other.size) &&
24 (device == other.device);
40 static constexpr
bool isInside(
unsigned x,
unsigned start,
unsigned size)
42 return (
x - start) <
size;
45 static constexpr
bool overlap(
unsigned start1,
unsigned size1,
46 unsigned start2,
unsigned size2)
48 return (isInside(start1, start2, size2)) ||
49 (isInside(start1 + size1 - 1, start2, size2));
55 return overlap(base,
size, rn.base, rn.size);
73 [](
auto& rn) {
return rn.device; }));
85 for (
const auto& r :
ranges) {
86 const auto& name = r.device->getName();
93 const MSXMultiMemDevice::Range& MSXMultiMemDevice::searchRange(
unsigned address)
const
95 for (
const auto& r :
ranges) {
96 if (isInside(address, r.base, r.size)) {
103 MSXDevice* MSXMultiMemDevice::searchDevice(
unsigned address)
const
105 return searchRange(address).device;
110 return searchDevice(address)->
readMem(address, time);
115 return searchDevice(address)->
peekMem(address, time);
120 searchDevice(address)->
writeMem(address, value, time);
129 const auto& range = searchRange(start);
135 return range.device->getReadCacheLine(start);
141 const auto& range = searchRange(start);
145 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
~MSXMultiMemDevice() override
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
void add(MSXDevice &device, int base, int size)
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
const std::string & getName() const override
Returns a human-readable name for this device.
bool canAdd(int base, int size)
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
void remove(MSXDevice &device, int base, int size)
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 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:
bool operator==(const Event &x, const Event &y)
uint16_t word
16 bit unsigned integer
constexpr KeyMatrixPosition x
Keyboard bindings.
bool none_of(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 rfind_unguarded(RANGE &range, const VAL &val, Proj proj={})
Similar to the find(_if)_unguarded functions above, but searches from the back to front.
auto to_vector(Range &&range) -> std::vector< detail::ToVectorType< T, decltype(std::begin(range))>>
constexpr auto begin(const zstring_view &x)