71 , cassettePort(getMotherBoard().getCassettePort())
72 , i8255(*this, getCurrentTime(), config.getGlobalSettings().getInvalidPpiModeSetting())
75 config.getMotherBoard(),
76 config.getMotherBoard().getScheduler(),
77 config.getMotherBoard().getCommandController(),
78 config.getMotherBoard().getReactor().getEventDistributor(),
79 config.getMotherBoard().getMSXEventDistributor(),
80 config.getMotherBoard().getStateChangeDistributor(),
87 ports[0]->write(0, time);
88 ports[1]->write(0, time);
101 return i8255.
read(port & 0x03, time);
106 return i8255.
peek(port & 0x03, time);
111 i8255.
write(port & 0x03, value, time);
117byte SVIPPI::readA(EmuTime::param time)
119 byte triggers = ((ports[0]->read(time) & 0x10) ? 0x10 : 0) |
120 ((ports[1]->read(time) & 0x10) ? 0x20 : 0);
123 byte cassetteReady = 0;
125 byte cassetteInput = cassettePort.
cassetteIn(time) ? 0x80 : 0x00;
127 return triggers | cassetteReady | cassetteInput;
129byte SVIPPI::peekA(EmuTime::param )
const
133void SVIPPI::writeA(
byte , EmuTime::param )
137byte SVIPPI::readB(EmuTime::param time)
141byte SVIPPI::peekB(EmuTime::param )
const
143 return keyboard.
getKeys()[selectedRow];
145void SVIPPI::writeB(
byte , EmuTime::param )
149nibble SVIPPI::readC1(EmuTime::param time)
153nibble SVIPPI::peekC1(EmuTime::param )
const
157nibble SVIPPI::readC0(EmuTime::param time)
161nibble SVIPPI::peekC0(EmuTime::param )
const
165void SVIPPI::writeC1(
nibble value, EmuTime::param time)
167 if ((prevBits ^ value) & 1) {
168 cassettePort.
setMotor((value & 1) == 0, time);
170 if ((prevBits ^ value) & 2) {
176 if ((prevBits ^ value) & 8) {
177 click.
setClick((value & 8) != 0, time);
181void SVIPPI::writeC0(
nibble value, EmuTime::param )
186template<
typename Archive>
189 ar.template serializeBase<MSXDevice>(*
this);
190 ar.serialize(
"i8255", i8255);
193 auto portC =
byte((prevBits << 4) | (selectedRow << 0));
194 ar.serialize(
"portC", portC);
195 if constexpr (Archive::IS_LOADER) {
196 selectedRow = (portC >> 0) & 0xF;
197 nibble bits = (portC >> 4) & 0xF;
200 ar.serialize(
"keyboard", keyboard);
#define REGISTER_MSXDEVICE(CLASS, NAME)
virtual void cassetteOut(bool output, EmuTime::param time)=0
Writes one bit to the cassette port.
virtual void setMotor(bool status, EmuTime::param time)=0
Sets the cassette motor relay false = off true = on.
virtual bool cassetteIn(EmuTime::param time)=0
Reads one bit from the cassette port.
void reset(EmuTime::param time)
byte peek(byte port, EmuTime::param time) const
byte read(byte port, EmuTime::param time)
void write(byte port, byte value, EmuTime::param time)
void reset(EmuTime::param time)
void setClick(bool status, EmuTime::param time)
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)
void reset(EmuTime::param time) override
This method is called on reset.
void serialize(Archive &ar, unsigned version)
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 readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
SVIPPI(const DeviceConfig &config)
This file implemented 3 utility functions:
uint8_t byte
8 bit unsigned integer
uint8_t nibble
4 bit integer
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)