openMSX
MSXDeviceSwitch.hh
Go to the documentation of this file.
1#ifndef MSXDEVICESWITCH_HH
2#define MSXDEVICESWITCH_HH
3
4#include "MSXDevice.hh"
5#include <array>
6
7namespace openmsx {
8
54class MSXSwitchedDevice;
55
56class MSXDeviceSwitch final : public MSXDevice
57{
58public:
59 explicit MSXDeviceSwitch(const DeviceConfig& config);
60 ~MSXDeviceSwitch() override;
61
62 // (un)register methods for devices
63 void registerDevice(byte id, MSXSwitchedDevice* device);
64 void unregisterDevice(byte id);
65 [[nodiscard]] bool hasRegisteredDevices() const { return count != 0; }
66
67 void reset(EmuTime::param time) override;
68 [[nodiscard]] byte readIO(word port, EmuTime::param time) override;
69 [[nodiscard]] byte peekIO(word port, EmuTime::param time) const override;
70 void writeIO(word port, byte value, EmuTime::param time) override;
71
72 template<typename Archive>
73 void serialize(Archive& ar, unsigned version);
74
75private:
76 std::array<MSXSwitchedDevice*, 256> devices;
77 unsigned count = 0;
78 byte selected = 0;
79};
80
81} // namespace openmsx
82
83#endif
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.
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.
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.
Definition MSXDevice.hh:36
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29