diff --git a/src/emucore/AtariVox.cxx b/src/emucore/AtariVox.cxx
index 994b494cf..fd75024e4 100644
--- a/src/emucore/AtariVox.cxx
+++ b/src/emucore/AtariVox.cxx
@@ -50,10 +50,11 @@ bool AtariVox::read(DigitalPin pin)
switch(pin)
{
// Pin 2: SpeakJet READY
- // CTS enabled means the SpeakJet can accept more data
+ // CTS (Clear To Send) is connected inverted
+ // So CTS = 0 means the buffer is full, which pulls pin 2 high
case DigitalPin::Two:
{
- return setPin(pin, mySerialPort->isCTS());
+ return setPin(pin, !mySerialPort->isCTS());
}
default:
diff --git a/src/macos/SerialPortMACOS.cxx b/src/macos/SerialPortMACOS.cxx
index 90235e0a8..9745eceff 100644
--- a/src/macos/SerialPortMACOS.cxx
+++ b/src/macos/SerialPortMACOS.cxx
@@ -73,3 +73,15 @@ bool SerialPortMACOS::writeByte(uInt8 data)
}
return false;
}
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+bool SerialPortMACOS::isCTS()
+{
+ if(myHandle)
+ {
+ int status = 0;
+ ioctl(myHandle, TIOCMGET, &status);
+ return status & TIOCM_CTS;
+ }
+ return false;
+}
diff --git a/src/macos/SerialPortMACOS.hxx b/src/macos/SerialPortMACOS.hxx
index 0c83e5045..3d71d5135 100644
--- a/src/macos/SerialPortMACOS.hxx
+++ b/src/macos/SerialPortMACOS.hxx
@@ -48,6 +48,13 @@ class SerialPortMACOS : public SerialPort
*/
bool writeByte(uInt8 data) override;
+ /**
+ Test for 'Clear To Send' enabled.
+
+ @return True if CTS signal enabled, else false
+ */
+ bool isCTS() override;
+
private:
// File descriptor for serial connection
int myHandle{0};
diff --git a/src/unix/SerialPortUNIX.cxx b/src/unix/SerialPortUNIX.cxx
index f114e18fe..1105d2092 100644
--- a/src/unix/SerialPortUNIX.cxx
+++ b/src/unix/SerialPortUNIX.cxx
@@ -49,6 +49,9 @@ bool SerialPortUNIX::openPort(const string& device)
if(myHandle <= 0)
return false;
+ // Open the device in nonblocking mode
+ fcntl(myHandle, F_SETFL, FNDELAY);
+
struct termios termios;
memset(&termios, 0, sizeof(struct termios));
@@ -71,3 +74,15 @@ bool SerialPortUNIX::writeByte(uInt8 data)
}
return false;
}
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+bool SerialPortUNIX::isCTS()
+{
+ if(myHandle)
+ {
+ int status = 0;
+ ioctl(myHandle, TIOCMGET, &status);
+ return status & TIOCM_CTS;
+ }
+ return false;
+}
diff --git a/src/unix/SerialPortUNIX.hxx b/src/unix/SerialPortUNIX.hxx
index b46d0a64a..7a675298e 100644
--- a/src/unix/SerialPortUNIX.hxx
+++ b/src/unix/SerialPortUNIX.hxx
@@ -48,6 +48,13 @@ class SerialPortUNIX : public SerialPort
*/
bool writeByte(uInt8 data) override;
+ /**
+ Test for 'Clear To Send' enabled.
+
+ @return True if CTS signal enabled, else false
+ */
+ bool isCTS() override;
+
private:
// File descriptor for serial connection
int myHandle{0};
diff --git a/src/windows/SerialPortWINDOWS.cxx b/src/windows/SerialPortWINDOWS.cxx
index 51ed73247..91b6c0bb3 100644
--- a/src/windows/SerialPortWINDOWS.cxx
+++ b/src/windows/SerialPortWINDOWS.cxx
@@ -79,3 +79,15 @@ bool SerialPortWINDOWS::writeByte(uInt8 data)
}
return false;
}
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+bool SerialPortWINDOWS::isCTS()
+{
+ if(myHandle)
+ {
+ DWORD modemStat;
+ GetCommModemStatus(myHandle, &modemStat);
+ return modemStat & MS_CTS_ON;
+ }
+ return false;
+}
diff --git a/src/windows/SerialPortWINDOWS.hxx b/src/windows/SerialPortWINDOWS.hxx
index 8c0ed789c..3f8513573 100644
--- a/src/windows/SerialPortWINDOWS.hxx
+++ b/src/windows/SerialPortWINDOWS.hxx
@@ -47,6 +47,14 @@ class SerialPortWINDOWS : public SerialPort
*/
bool writeByte(uInt8 data) override;
+ /**
+ Test for 'Clear To Send' enabled. By default, assume it's always
+ OK to send more data.
+
+ @return True if CTS signal enabled, else false
+ */
+ bool isCTS() override;
+
private:
// Handle to serial port
HANDLE myHandle{0};
diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj
index c6ba9d7ff..52a8c4327 100644
--- a/src/windows/Stella.vcxproj
+++ b/src/windows/Stella.vcxproj
@@ -1774,6 +1774,7 @@
+
diff --git a/src/windows/Stella.vcxproj.filters b/src/windows/Stella.vcxproj.filters
index 215e9eeab..5875efb8c 100644
--- a/src/windows/Stella.vcxproj.filters
+++ b/src/windows/Stella.vcxproj.filters
@@ -2087,6 +2087,9 @@
Header Files\gui
+
+ Header Files\emucore
+