17 , cassettePort(getMotherBoard().getCassettePort())
18 , i8255(*this, getCurrentTime(), config.getGlobalSettings().getInvalidPpiModeSetting())
20 config.getMotherBoard(),
21 config.getMotherBoard().getScheduler(),
22 config.getMotherBoard().getCommandController(),
23 config.getMotherBoard().getReactor().getEventDistributor(),
24 config.getMotherBoard().getMSXEventDistributor(),
25 config.getMotherBoard().getStateChangeDistributor(),
31 for (
unsigned i = 0; i < 2; i++) {
34 ports[i]->write(0xFB, time);
47 return i8255.
read(port & 0x03, time);
52 return i8255.
peek(port & 0x03, time);
57 i8255.
write(port & 0x03, value, time);
63byte SC3000PPI::readA(EmuTime::param time)
67byte SC3000PPI::peekA(EmuTime::param time)
const
69 if (selectedRow == 7) {
72 byte joy1 = ports[0]->read(time) & 0x3F;
73 byte joy2 = ports[1]->read(time) & 0x3F;
74 return narrow_cast<byte>(joy1 | (joy2 << 6));
76 return keyboard.
getKeys()[selectedRow];
79void SC3000PPI::writeA(
byte , EmuTime::param )
83byte SC3000PPI::readB(EmuTime::param time)
87byte SC3000PPI::peekB(EmuTime::param time)
const
91 if (selectedRow == 7) {
94 byte joy2 = ports[1]->read(time) & 0x3F;
95 return 0xF0 | (joy2 >> 2);
113void SC3000PPI::writeB(
byte , EmuTime::param )
117nibble SC3000PPI::readC1(EmuTime::param time)
121nibble SC3000PPI::peekC1(EmuTime::param )
const
126nibble SC3000PPI::readC0(EmuTime::param time)
130nibble SC3000PPI::peekC0(EmuTime::param )
const
136void SC3000PPI::writeC1(
nibble value, EmuTime::param time)
138 if ((prevBits ^ value) & 1) {
139 cassettePort.
setMotor((value & 1) == 0, time);
141 if ((prevBits ^ value) & 2) {
152void SC3000PPI::writeC0(
nibble value, EmuTime::param )
154 selectedRow = value & 7;
158template<
typename Archive>
161 ar.template serializeBase<MSXDevice>(*
this);
162 ar.serialize(
"i8255", i8255);
165 auto portC =
byte((prevBits << 4) | (selectedRow << 0));
166 ar.serialize(
"portC", portC);
167 if constexpr (Archive::IS_LOADER) {
168 selectedRow = (portC >> 0) & 0xF;
169 nibble bits = (portC >> 4) & 0xF;
172 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.
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)
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)
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 byte
8 bit unsigned integer
uint8_t nibble
4 bit integer
uint16_t word
16 bit unsigned integer
constexpr auto keys(Map &&map)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)