16 , cassettePort(getMotherBoard().getCassettePort())
17 , i8255(*this, getCurrentTime(), config.getGlobalSettings().getInvalidPpiModeSetting())
19 config.getMotherBoard(),
20 config.getMotherBoard().getScheduler(),
21 config.getMotherBoard().getCommandController(),
22 config.getMotherBoard().getReactor().getEventDistributor(),
23 config.getMotherBoard().getMSXEventDistributor(),
24 config.getMotherBoard().getStateChangeDistributor(),
32 for (
unsigned i = 0; i < 2; i++) {
35 ports[i]->
write(0xFB, time);
48 return i8255.
read(port & 0x03, time);
53 return i8255.
peek(port & 0x03, time);
58 i8255.
write(port & 0x03, value, time);
64 byte SC3000PPI::readA(EmuTime::param time)
68 byte SC3000PPI::peekA(EmuTime::param time)
const
70 if (selectedRow == 7) {
73 byte joy1 = ports[0]->
read(time) & 0x3F;
74 byte joy2 = ports[1]->
read(time) & 0x3F;
75 return joy1 | (joy2 << 6);
77 return keyboard.
getKeys()[selectedRow];
80 void SC3000PPI::writeA(
byte , EmuTime::param )
84 byte SC3000PPI::readB(EmuTime::param time)
88 byte SC3000PPI::peekB(EmuTime::param time)
const
92 if (selectedRow == 7) {
95 byte joy2 = ports[1]->
read(time) & 0x3F;
96 return 0xF0 | (joy2 >> 2);
110 auto& keyb =
const_cast<Keyboard&
>(keyboard);
111 auto keys = keyb.getKeys()[selectedRow + 7];
115 void SC3000PPI::writeB(
byte , EmuTime::param )
119 nibble SC3000PPI::readC1(EmuTime::param time)
123 nibble SC3000PPI::peekC1(EmuTime::param )
const
128 nibble SC3000PPI::readC0(EmuTime::param time)
132 nibble SC3000PPI::peekC0(EmuTime::param )
const
138 void SC3000PPI::writeC1(
nibble value, EmuTime::param time)
140 if ((prevBits ^ value) & 1) {
141 cassettePort.
setMotor((value & 1) == 0, time);
143 if ((prevBits ^ value) & 2) {
154 void SC3000PPI::writeC0(
nibble value, EmuTime::param )
156 selectedRow = value & 7;
160 template<
typename Archive>
163 ar.template serializeBase<MSXDevice>(*
this);
164 ar.serialize(
"i8255", i8255);
167 byte portC = (prevBits << 4) | (selectedRow << 0);
168 ar.serialize(
"portC", portC);
169 if constexpr (Archive::IS_LOADER) {
170 selectedRow = (portC >> 0) & 0xF;
171 nibble bits = (portC >> 4) & 0xF;
174 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.
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
const byte * 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)
Connects SC-3000 peripherals to the PPI (8255).
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
SC3000PPI(const DeviceConfig &config)
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO 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.
This file implemented 3 utility functions:
uint8_t nibble
4 bit integer
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
constexpr auto keys(Map &&map)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)