]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Serial RI fix
authorToni Wilen <twilen@winuae.net>
Sun, 11 Dec 2022 19:07:51 +0000 (21:07 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 11 Dec 2022 19:07:51 +0000 (21:07 +0200)
cia.cpp
od-win32/serial_win32.cpp

diff --git a/cia.cpp b/cia.cpp
index ec86138211bd2a9c3fb250f6d14a4ef4816b01fe..b64e00ad5914ab80883c149dc036427102ad8144 100644 (file)
--- 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
index 8c871f0b2671fead10e36d59b1dbc12e6ce9e77e..d7f6eb6672105cfbd0034e9ec13668717eded469 100644 (file)
@@ -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));
                }
        }