From 87161c63ddc5b9c28ce02a2294d07c32727c4d12 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 4 Mar 2021 21:56:43 +0100 Subject: [PATCH] Only bits 4 to 2 of LSR are now writable, and only in loopback mode. --- src/device/serial.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/device/serial.c b/src/device/serial.c index ed6915438..4cda5841f 100644 --- a/src/device/serial.c +++ b/src/device/serial.c @@ -484,14 +484,16 @@ serial_write(uint16_t addr, uint8_t val, void *p) } break; case 5: - dev->lsr = val; - if (dev->lsr & 0x01) - dev->int_status |= SERIAL_INT_RECEIVE; - if (dev->lsr & 0x1e) - dev->int_status |= SERIAL_INT_LSR; - if (dev->lsr & 0x20) - dev->int_status |= SERIAL_INT_TRANSMIT; - serial_update_ints(dev); + if (dev->mctrl & 0x10) { + dev->lsr = (dev->lsr & 0xe3) | (val & 0x1c); + if (dev->lsr & 0x01) + dev->int_status |= SERIAL_INT_RECEIVE; + if (dev->lsr & 0x1e) + dev->int_status |= SERIAL_INT_LSR; + if (dev->lsr & 0x20) + dev->int_status |= SERIAL_INT_TRANSMIT; + serial_update_ints(dev); + } break; case 6: dev->msr = val;