28 reset(EmuTime::dummy());
39 return getPluggedPrintDev().
getStatus(time);
44 if (newStrobe != strobe) {
46 getPluggedPrintDev().
setStrobe(strobe, time);
52 if (newData != data) {
54 getPluggedPrintDev().
writeData(data, time);
60 return "Yamaha SKW-01 printer port";
65 return "Printer Port";
71 getPluggedPrintDev().
writeData(data, time);
72 getPluggedPrintDev().
setStrobe(strobe, time);
77 return *checked_cast<PrinterPortDevice*>(&
getPlugged());
80template<
typename Archive>
83 ar.template serializeBase<Connector>(*
this);
84 ar.serialize(
"strobe" , strobe,
91 , mainRom(
MSXDevice::getName() +
" main" ,
"rom", config,
"main")
92 , fontRom(
MSXDevice::getName() +
" kanjifont",
"rom", config,
"kanjifont")
93 , dataRom(
MSXDevice::getName() +
" data" ,
"rom", config,
"data")
94 , sram(
MSXDevice::getName() +
" SRAM", 0x800, config)
99 if (mainRom.
size() != 32 * 1024) {
100 throw MSXException(
"Main ROM must be exactly 32kB in size.");
102 if (fontRom.
size() != 128 * 1024) {
103 throw MSXException(
"Font ROM must be exactly 128kB in size.");
105 if (dataRom.
size() != 32 * 1024) {
106 throw MSXException(
"Data ROM must be exactly 32kB in size.");
109 reset(EmuTime::dummy());
114 fontAddress = {0, 0, 0, 0};
117 if (printerPort) printerPort->reset(time);
127 if (address ==
one_of(0x7FC0, 0x7FC2, 0x7FC4, 0x7FC6)) {
129 }
else if (address ==
one_of(0x7FC1, 0x7FC3, 0x7FC5, 0x7FC7)) {
130 unsigned group = (address - 0x7FC1) / 2;
131 unsigned base = 0x8000 * group;
132 unsigned offset = fontAddress[group] & 0x7FFF;
133 return fontRom[base + offset];
134 }
else if (address == 0x7FC8 || address == 0x7FC9) {
136 }
else if (address == 0x7FCA || address == 0x7FCB) {
137 if ((dataAddress & (1 << 15)) == 0) {
138 return dataRom[dataAddress & 0x7FFF];
140 return sram[dataAddress & 0x7FF];
142 }
else if (address == 0x7FCC && printerPort) {
144 return printerPort->getStatus(time)
146 }
else if (address < 0x8000) {
147 return mainRom[address];
155 if (0x7FC0 <= address && address <= 0x7FC7) {
156 unsigned group = (address - 0x7FC0) / 2;
157 if ((address & 1) == 0) {
159 fontAddress[group] = (fontAddress[group] & 0xFF00) | uint16_t(value << 0);
162 fontAddress[group] = (fontAddress[group] & 0x00FF) | uint16_t(value << 8);
164 }
else if (address == 0x7FC8) {
165 dataAddress = (dataAddress & 0xFF00) | uint16_t(value << 0);
166 }
else if (address == 0x7FC9) {
167 dataAddress = (dataAddress & 0x00FF) | uint16_t(value << 8);
168 }
else if (address == 0x7FCA || address == 0x7FCB) {
169 if ((dataAddress & (1 << 15)) != 0) {
170 sram.
write(dataAddress & 0x7FF, value);
172 }
else if (address == 0x7FCC && printerPort) {
173 printerPort->setStrobe(value & 1, time);
174 }
else if (address == 0x7FCE && printerPort) {
175 printerPort->writeData(value, time);
184 }
else if (start < 0x8000) {
185 return &mainRom[start];
201template<
typename Archive>
204 ar.template serializeBase<MSXDevice>(*
this);
205 ar.serialize(
"fontAddress", fontAddress,
206 "dataAddress", dataAddress,
209 printerPort->serialize(ar, version);
#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.
bool getChildDataAsBool(std::string_view name, bool defaultValue=false) const
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
PluggingController & getPluggingController() const
static std::array< byte, 0x10000 > unmappedRead
virtual const std::string & getName() const
Returns a human-readable name for this device.
static std::array< byte, 0x10000 > unmappedWrite
Central administration of Connectors and Pluggables.
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.
void write(size_t addr, byte value)
void reset(EmuTime::param time)
void setStrobe(bool newStrobe, EmuTime::param time)
void plug(Pluggable &dev, EmuTime::param time) override
This plugs a Pluggable in this Connector.
void serialize(Archive &ar, unsigned version)
bool getStatus(EmuTime::param time) const
std::string_view getClass() const override
A Connector belong to a certain class.
YamahaSKW01PrinterPort(PluggingController &pluggingController, const std::string &name)
std::string_view getDescription() const override
Get a description for this connector.
void writeData(uint8_t newData, EmuTime::param time)
byte * getWriteCacheLine(word start) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
YamahaSKW01(const DeviceConfig &config)
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
void reset(EmuTime::param time) override
This method is called on reset.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
void serialize(Archive &ar, unsigned version)
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)