From 67c6be3c73387e45535a75caa38fe7a9b9e3f71b Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 11 Dec 2022 21:07:51 +0200 Subject: [PATCH] Serial RI fix --- cia.cpp | 6 +++--- od-win32/serial_win32.cpp | 17 ++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/cia.cpp b/cia.cpp index ec861382..b64e00ad 100644 --- a/cia.cpp +++ b/cia.cpp @@ -1796,9 +1796,6 @@ static uae_u8 ReadCIAB(uae_u32 addr, uae_u32 *flags) switch (reg) { case 0: tmp = (c->pra & c->dra) | (c->dra ^ 0xff); -#ifdef SERIAL_PORT - tmp |= serial_readstatus(tmp, c->dra); -#endif #ifdef PARALLEL_PORT if (isprinter() > 0) { tmp &= ~3; // clear BUSY and PAPEROUT @@ -1819,6 +1816,9 @@ static uae_u8 ReadCIAB(uae_u32 addr, uae_u32 *flags) } tmp = handle_parport_joystick(1, tmp); } +#endif +#ifdef SERIAL_PORT + tmp = serial_readstatus(tmp, c->dra); #endif tmp = dongle_cia_read(1, reg, c->pra, tmp); #if DONGLE_DEBUG > 0 diff --git a/od-win32/serial_win32.cpp b/od-win32/serial_win32.cpp index 8c871f0b..d7f6eb66 100644 --- a/od-win32/serial_win32.cpp +++ b/od-win32/serial_win32.cpp @@ -1084,20 +1084,14 @@ uae_u8 serial_readstatus(uae_u8 v, uae_u8 dir) if (!isprinter()) { // SEL == RI - v |= 4; serbits |= 0x04; } else { serbits &= ~0x04; serbits |= v & 0x04; } - if (status & TIOCM_RI) { - if (serbits & 0x04) { - serbits &= ~0x04; -#if SERIALHSDEBUG > 0 - write_log("SERIAL: RI on\n"); -#endif - } + if (!(status & TIOCM_RI)) { + serbits &= ~0x04; } serbits &= 0x04 | 0x08 | 0x10 | 0x20; @@ -1106,7 +1100,8 @@ uae_u8 serial_readstatus(uae_u8 v, uae_u8 dir) serial_status_debug (_T("read")); - return (v & (0x80 | 0x40 | 0x02 | 0x01)) | serbits; + v = (v & (0x80 | 0x40 | 0x02 | 0x01)) | serbits; + return v; } uae_u8 serial_writestatus (uae_u8 newstate, uae_u8 dir) @@ -1164,8 +1159,8 @@ uae_u8 serial_writestatus (uae_u8 newstate, uae_u8 dir) if (rp_ismodem()) { if ((oldserbits & (0x80 | 0x40)) != (newstate & (0x80 | 0x40))) { rp_writemodemstatus( - (newstate & 0x40) != 0, (oldserbits & 0x40) != (newstate & 0x40), - (newstate & 0x80) != 0, (oldserbits & 0x80) != (newstate & 0x80)); + (newstate & 0x40) == 0, (oldserbits & 0x40) != (newstate & 0x40), + (newstate & 0x80) == 0, (oldserbits & 0x80) != (newstate & 0x80)); } } -- 2.47.3