68 getScheduler(), cntr0.get(), cntr1.get(), nullptr,
72 , rom(config.findChild(
"rom")
76 , ram(config.getChildDataAsBool(
"ram", false)
82 , rxrdyIRQlatch(false)
83 , rxrdyIRQenabled(false)
84 , hasMemoryBasedIo(config.getChildDataAsBool(
"memorybasedio", false))
85 , ioAccessEnabled(!hasMemoryBasedIo)
86 , switchSetting(config.getChildDataAsBool(
"toshiba_rs232c_switch",
88 "toshiba_rs232c_switch",
"status of the RS-232C enable switch",
94 i8254->getClockPin(0).setPeriodicState(total, hi, time);
95 i8254->getClockPin(1).setPeriodicState(total, hi, time);
96 i8254->getClockPin(2).setPeriodicState(total, hi, time);
115 rxrdyIRQlatch =
false;
116 rxrdyIRQenabled =
false;
119 ioAccessEnabled = !hasMemoryBasedIo;
128 if (hasMemoryBasedIo && (0xBFF8 <= address) && (address <= 0xBFFF)) {
129 return readIOImpl(address & 0x07, time);
131 word addr = address & 0x3FFF;
134 }
else if (rom.get() && (0x4000 <= address) && (address < 0x8000)) {
143 if (hasMemoryBasedIo && (start == (0xBFF8 & CacheLine::HIGH))) {
146 word addr = start & 0x3FFF;
149 }
else if (rom.get() && (0x4000 <= start) && (start < 0x8000)) {
150 return &(*rom)[addr];
159 if (hasMemoryBasedIo && (0xBFF8 <= address) && (address <= 0xBFFF)) {
165 if (address == 0xBFFA) {
166 ioAccessEnabled = (value & (1 << 4))!=0;
168 return writeIOImpl(address & 0x07, value, time);
170 word addr = address & 0x3FFF;
178 if (hasMemoryBasedIo && (start == (0xBFF8 & CacheLine::HIGH))) {
181 word addr = start & 0x3FFF;
191 if (ioAccessEnabled) {
192 return readIOImpl(port & 0x07, time);
203 result = i8251->readIO(port, time);
206 result = readStatus(time);
215 result = i8254->readIO(port - 4, time);
225 if (hasMemoryBasedIo && !ioAccessEnabled)
return 0xFF;
231 result = i8251->peekIO(port, time);
243 result = i8254->peekIO(port - 4, time);
253 if (ioAccessEnabled) writeIOImpl(port & 0x07, value, time);
261 i8251->writeIO(port, value, time);
272 i8254->writeIO(port - 4, value, time);
299 if (!rxrdyIRQenabled && switchSetting.get() &&
300 switchSetting->getValue()) {
304 if (!interf->getCTS(time)) {
307 if (i8254->getOutputPin(2).getState(time)) {
313 void MSXRS232::setIRQMask(
byte value)
315 enableRxRDYIRQ(!(value & 1));
318 void MSXRS232::setRxRDYIRQ(
bool status)
320 if (rxrdyIRQlatch != status) {
321 rxrdyIRQlatch = status;
322 if (rxrdyIRQenabled) {
332 void MSXRS232::enableRxRDYIRQ(
bool enabled)
334 if (rxrdyIRQenabled != enabled) {
335 rxrdyIRQenabled = enabled;
336 if (!rxrdyIRQenabled && rxrdyIRQlatch) {
356 rs232.setRxRDYIRQ(status);
418 ClockPin& clk = rs232.i8251->getClockPin();
446 ClockPin& clk = rs232.i8251->getClockPin();
465 return i8251->isRecvReady();
470 return i8251->isRecvEnabled();
475 i8251->setDataBits(bits);
480 i8251->setStopBits(bits);
485 i8251->setParityBit(enable, parity);
490 i8251->recvByte(value, time);
496 template<
typename Archive>
499 ar.template serializeBase<MSXDevice>(*this);
500 ar.template serializeBase<RS232Connector>(*this);
502 ar.serialize(
"I8254", *i8254);
503 ar.serialize(
"I8251", *i8251);
505 ar.serialize(
"ram", *ram);
507 ar.serialize(
"rxrdyIRQ", rxrdyIRQ);
508 ar.serialize(
"rxrdyIRQlatch", rxrdyIRQlatch);
509 ar.serialize(
"rxrdyIRQenabled", rxrdyIRQenabled);
510 if (ar.versionAtLeast(version, 2)) {
511 ar.serialize(
"ioAccessEnabled", ioAccessEnabled);
513 assert(ar.isLoader());
514 ioAccessEnabled = !hasMemoryBasedIo;