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(),
89 ports[0]->
write(0, time);
90 ports[1]->
write(0, time);
103 return i8255.
read(port & 0x03, time);
108 return i8255.
peek(port & 0x03, time);
113 i8255.
write(port & 0x03, value, time);
119 byte SVIPPI::readA(EmuTime::param time)
121 byte triggers = ((ports[0]->
read(time) & 0x10) ? 0x10 : 0) |
122 ((ports[1]->
read(time) & 0x10) ? 0x20 : 0);
125 byte cassetteReady = 0;
127 byte cassetteInput = cassettePort.
cassetteIn(time) ? 0x80 : 0x00;
129 return triggers | cassetteReady | cassetteInput;
131 byte SVIPPI::peekA(EmuTime::param )
const
135 void SVIPPI::writeA(
byte , EmuTime::param )
139 byte SVIPPI::readB(EmuTime::param time)
143 byte SVIPPI::peekB(EmuTime::param )
const
145 auto& keyb =
const_cast<Keyboard&
>(keyboard);
146 return keyb.getKeys()[selectedRow];
148 void SVIPPI::writeB(
byte , EmuTime::param )
152 nibble SVIPPI::readC1(EmuTime::param time)
156 nibble SVIPPI::peekC1(EmuTime::param )
const
160 nibble SVIPPI::readC0(EmuTime::param time)
164 nibble SVIPPI::peekC0(EmuTime::param )
const
168 void SVIPPI::writeC1(
nibble value, EmuTime::param time)
170 if ((prevBits ^ value) & 1) {
171 cassettePort.
setMotor((value & 1) == 0, time);
173 if ((prevBits ^ value) & 2) {
179 if ((prevBits ^ value) & 8) {
180 click.
setClick((value & 8) != 0, time);
184 void SVIPPI::writeC0(
nibble value, EmuTime::param )
189 template<
typename Archive>
192 ar.template serializeBase<MSXDevice>(*
this);
193 ar.serialize(
"i8255", i8255);
196 byte portC = (prevBits << 4) | (selectedRow << 0);
197 ar.serialize(
"portC", portC);
198 if constexpr (Archive::IS_LOADER) {
199 selectedRow = (portC >> 0) & 0xF;
200 nibble bits = (portC >> 4) & 0xF;
203 ar.serialize(
"keyboard", keyboard);
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)
virtual void write(byte value, EmuTime::param time)=0
virtual byte read(EmuTime::param time)=0
void reset(EmuTime::param time)
void setClick(bool status, EmuTime::param time)
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 nibble
4 bit integer
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)