23 assert(
ranges::all_of(devices, [](
auto* dev) {
return dev ==
nullptr; }));
32 "Already have a switched device with id ",
int(
id));
36 for (
auto port :
xrange(0x40, 0x50)) {
48 for (
auto port :
xrange(0x40, 0x50)) {
54 devices[
id] =
nullptr;
64 if (devices[selected]) {
73 if (devices[selected]) {
82 if ((port & 0x0F) == 0x00) {
84 }
else if (devices[selected]) {
92 template<
typename Archive>
95 ar.template serializeBase<MSXDevice>(*
this);
96 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
virtual byte peekSwitchedIO(word port, EmuTime::param time) const =0
virtual void writeSwitchedIO(word port, byte value, EmuTime::param time)=0
virtual byte readSwitchedIO(word port, EmuTime::param time)=0
ALWAYS_INLINE unsigned count(const uint8_t *pIn, const uint8_t *pMatch, const uint8_t *pInLimit)
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
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)