21 assert(
ranges::all_of(devices, [](
auto* dev) {
return dev ==
nullptr; }));
30 "Already have a switched device with id ",
int(
id));
46 devices[
id] =
nullptr;
56 if (devices[selected]) {
57 return devices[selected]->readSwitchedIO(port, time);
65 if (devices[selected]) {
66 return devices[selected]->peekSwitchedIO(port, time);
74 if ((port & 0x0F) == 0x00) {
76 }
else if (devices[selected]) {
77 devices[selected]->writeSwitchedIO(port, value, time);
84template<
typename Archive>
87 ar.template serializeBase<MSXDevice>(*
this);
88 ar.serialize(
"selected", selected);
void unregister_IO_InOut_range(byte port, unsigned num, MSXDevice *device)
void register_IO_InOut_range(byte port, unsigned num, MSXDevice *device)
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
void unregisterDevice(byte id)
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
void reset(EmuTime::param time) override
This method is called on reset.
~MSXDeviceSwitch() override
MSXDeviceSwitch(const DeviceConfig &config)
void registerDevice(byte id, MSXSwitchedDevice *device)
void serialize(Archive &ar, unsigned version)
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
MSXCPUInterface & getCPUInterface() const
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
constexpr bool all_of(InputRange &&range, UnaryPredicate pred)
constexpr void fill(ForwardRange &&range, const T &value)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)