15 config.getMotherBoard(),
16 config.getMotherBoard().getScheduler(),
17 config.getMotherBoard().getCommandController(),
18 config.getMotherBoard().getReactor().getEventDistributor(),
19 config.getMotherBoard().getMSXEventDistributor(),
20 config.getMotherBoard().getStateChangeDistributor(),
29 port->
write(0xFB, time);
41 const int joyPort = (port >> 1) & 1;
42 const byte joyStatus = ports[joyPort]->read(time);
49 unsigned keypadStatus = ~(
50 keys[joyPort * 2 + 2] | (keys[joyPort * 2 + 3] << 8)
52 static constexpr std::array<byte, 13> keyEnc = {
53 0xF, 0xA, 0xD, 0x7, 0xC, 0x2, 0x3, 0xE, 0x5, 0x1, 0xB, 0x9, 0x6
57 | ((joyStatus << 1) & (keys[joyPort] >> 1) & 0x40);
62 | ((joyStatus >> 2) & 0x02)
63 | ((joyStatus << 1) & 0x04)
64 | ((joyStatus << 1) & 0x08)
66 | ((joyStatus << 2) & 0x40)
71 return value & (keys[joyPort] | ~0x4F);
82 joyMode = (port >> 6) & 1;
85template<
typename Archive>
88 ar.template serializeBase<MSXDevice>(*
this);
89 ar.serialize(
"joyMode", joyMode);
90 if (ar.versionAtLeast(version, 2)) {
91 ar.serialize(
"keyboard", keyboard);
#define REGISTER_MSXDEVICE(CLASS, NAME)
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
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.
ColecoJoystickIO(const DeviceConfig &config)
void serialize(Archive &ar, unsigned version)
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.
virtual void write(uint8_t value, EmuTime::param time)=0
std::span< const uint8_t, KeyMatrixPosition::NUM_ROWS > getKeys() const
Returns a pointer to the current KeyBoard matrix.
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
MSXMotherBoard & getMotherBoard() const
Get the mother board this device belongs to.
EmuTime::param getCurrentTime() const
JoystickPortIf & getJoystickPort(unsigned port)
constexpr auto enumerate(Iterable &&iterable)
Heavily inspired by Nathan Reed's blog post: Python-Like enumerate() In C++17 http://reedbeta....
unsigned findFirstSet(uint32_t x)
Find the least significant bit that is set.
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)