17 , debuggable(getMotherBoard(),
MSXDevice::getName())
18 , writePortMask(config.getChildDataAsBool(
"bidirectional", false) ? 0x03 : 0x01)
19 , readPortMask(config.getChildDataAsBool(
"status_readable_on_all_ports", false) ? 0 : writePortMask)
20 , unusedBits(uint8_t(config.getChildDataAsInt(
"unused_bits", 0xFF)))
28 setStrobe(
true, time);
38 bool showStatus = (port & readPortMask) == 0;
39 if (!showStatus)
return 0xFF;
42 return getPluggedPrintDev().
getStatus(time)
43 ? (unusedBits | 0b10) : (unusedBits & ~0b10);
48 switch (port & writePortMask) {
50 setStrobe(value & 1, time);
53 writeData(value, time);
64void MSXPrinterPort::setStrobe(
bool newStrobe, EmuTime::param time)
66 if (newStrobe != strobe) {
68 getPluggedPrintDev().
setStrobe(strobe, time);
71void MSXPrinterPort::writeData(uint8_t newData, EmuTime::param time)
73 if (newData != data) {
75 getPluggedPrintDev().
writeData(data, time);
81 return "MSX Printer port";
86 return "Printer Port";
92 getPluggedPrintDev().
writeData(data, time);
93 getPluggedPrintDev().
setStrobe(strobe, time);
98 return *checked_cast<PrinterPortDevice*>(&
getPlugged());
103 : SimpleDebuggable(motherBoard_, name_,
"Printer Port", 2)
107uint8_t MSXPrinterPort::Debuggable::read(
unsigned address)
109 const auto& pPort =
OUTER(MSXPrinterPort, debuggable);
110 return (address == 0) ? pPort.strobe : pPort.data;
113void MSXPrinterPort::Debuggable::write(
unsigned address, uint8_t value)
115 auto& pPort =
OUTER(MSXPrinterPort, debuggable);
116 pPort.writeIO(narrow<uint16_t>(address), value, pPort.getCurrentTime());
120template<
typename Archive>
123 ar.template serializeBase<MSXDevice>(*
this);
124 ar.template serializeBase<Connector>(*
this);
125 ar.serialize(
"strobe", strobe,
#define REGISTER_MSXDEVICE(CLASS, NAME)
Represents something you can plug devices into.
Pluggable & getPlugged() const
Returns the Pluggable currently plugged in.
virtual void plug(Pluggable &device, EmuTime::param time)
This plugs a Pluggable in this Connector.
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
EmuTime::param getCurrentTime() const
void serialize(Archive &ar, unsigned version)
std::string_view getDescription() const override
Get a description for this connector.
uint8_t readIO(uint16_t port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
MSXPrinterPort(const DeviceConfig &config)
void reset(EmuTime::param time) override
This method is called on reset.
uint8_t peekIO(uint16_t port, EmuTime::param time) const override
Read a byte from a given IO port.
void writeIO(uint16_t port, uint8_t value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
std::string_view getClass() const override
A Connector belong to a certain class.
void plug(Pluggable &dev, EmuTime::param time) override
This plugs a Pluggable in this Connector.
virtual bool getStatus(EmuTime::param time)=0
Returns the STATUS signal: false = low = ready, true = high = not ready.
virtual void writeData(uint8_t data, EmuTime::param time)=0
Sets the data signals.
virtual void setStrobe(bool strobe, EmuTime::param time)=0
Sets the strobe signal: false = low, true = high.
This file implemented 3 utility functions:
#define OUTER(type, member)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)