| 1 |
#ifndef MSXDEVICESWITCH_HH |
| 2 |
#define MSXDEVICESWITCH_HH |
| 3 |
|
| 4 |
#include "MSXDevice.hh" |
| 5 |
#include <array> |
| 6 |
|
| 7 |
namespace openmsx { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
class MSXSwitchedDevice; |
| 55 |
|
| 56 |
class MSXDeviceSwitch final : public MSXDevice |
| 57 |
{ |
| 58 |
public: |
| 59 |
explicit MSXDeviceSwitch(const DeviceConfig& config); |
| 60 |
~MSXDeviceSwitch() override; |
| 61 |
|
| 62 |
|
| 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 time) override; |
| 68 |
[[nodiscard]] byte readIO(uint16_t port, EmuTime time) override; |
| 69 |
[[nodiscard]] byte peekIO(uint16_t port, EmuTime time) const override; |
| 70 |
void writeIO(uint16_t port, byte value, EmuTime time) override; |
| 71 |
|
| 72 |
template<typename Archive> |
| 73 |
void serialize(Archive& ar, unsigned version); |
| 74 |
|
| 75 |
private: |
| 76 |
std::array<MSXSwitchedDevice*, 256> devices; |
| 77 |
unsigned count = 0; |
| 78 |
byte selected = 0; |
| 79 |
}; |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
#endif |