| 1 |
#ifndef MSXPRINTERPORT_HH |
| 2 |
#define MSXPRINTERPORT_HH |
| 3 |
|
| 4 |
#include "Connector.hh" |
| 5 |
#include "MSXDevice.hh" |
| 6 |
#include "SimpleDebuggable.hh" |
| 7 |
|
| 8 |
#include <cstdint> |
| 9 |
|
| 10 |
namespace openmsx { |
| 11 |
|
| 12 |
class PrinterPortDevice; |
| 13 |
|
| 14 |
class MSXPrinterPort final : public MSXDevice, public Connector |
| 15 |
{ |
| 16 |
public: |
| 17 |
explicit MSXPrinterPort(const DeviceConfig& config); |
| 18 |
|
| 19 |
|
| 20 |
void reset(EmuTime time) override; |
| 21 |
[[nodiscard]] uint8_t readIO(uint16_t port, EmuTime time) override; |
| 22 |
[[nodiscard]] uint8_t peekIO(uint16_t port, EmuTime time) const override; |
| 23 |
void writeIO(uint16_t port, uint8_t value, EmuTime time) override; |
| 24 |
|
| 25 |
|
| 26 |
[[nodiscard]] zstring_view getDescription() const override; |
| 27 |
[[nodiscard]] zstring_view getClass() const override; |
| 28 |
void plug(Pluggable& dev, EmuTime time) override; |
| 29 |
|
| 30 |
template<typename Archive> |
| 31 |
void serialize(Archive& ar, unsigned version); |
| 32 |
|
| 33 |
private: |
| 34 |
[[nodiscard]] PrinterPortDevice& getPluggedPrintDev() const; |
| 35 |
void setStrobe(bool newStrobe, EmuTime time); |
| 36 |
void writeData(uint8_t newData, EmuTime time); |
| 37 |
|
| 38 |
private: |
| 39 |
struct Debuggable final : SimpleDebuggable { |
| 40 |
Debuggable(MSXMotherBoard& motherBoard, const std::string& name); |
| 41 |
[[nodiscard]] uint8_t read(unsigned address) override; |
| 42 |
void write(unsigned address, uint8_t value) override; |
| 43 |
} debuggable; |
| 44 |
|
| 45 |
bool strobe = false; |
| 46 |
uint8_t data = 255; |
| 47 |
const uint8_t writePortMask; |
| 48 |
const uint8_t readPortMask; |
| 49 |
const uint8_t unusedBits; |
| 50 |
}; |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
#endif |