21 assert(
ranges::all_of(devices, [](
auto* dev) {
return dev ==
nullptr; }));
30 "Already have a switched device with id ",
int(
id));
34 for (
auto port :
xrange(
byte(0x40),
byte(0x50))) {
46 for (
auto port :
xrange(
byte(0x40),
byte(0x50))) {
52 devices[
id] =
nullptr;
62 if (devices[selected]) {
63 return devices[selected]->readSwitchedIO(port, time);
71 if (devices[selected]) {
72 return devices[selected]->peekSwitchedIO(port, time);
80 if ((port & 0x0F) == 0x00) {
82 }
else if (devices[selected]) {
83 devices[selected]->writeSwitchedIO(port, value, time);
90template<
typename Archive>
93 ar.template serializeBase<MSXDevice>(*
this);
94 ar.serialize(
"selected", selected);
void register_IO_Out(byte port, MSXDevice *device)
Devices can register their Out ports.
void register_IO_In(byte port, MSXDevice *device)
Devices can register their In ports.
void unregister_IO_In(byte port, MSXDevice *device)
void unregister_IO_Out(byte port, 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)
constexpr auto xrange(T e)