From 3fa7dadcbaa42eb3005b3657b600119613f1b851 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sun, 2 Aug 2020 10:59:41 -0230 Subject: [PATCH] Finalize AVox CTS support. Now more testing is needed ... --- Changes.txt | 4 ++++ src/emucore/AtariVox.cxx | 16 ++++++++++------ src/emucore/AtariVox.hxx | 5 +++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Changes.txt b/Changes.txt index 9db31b627..61b036ebc 100644 --- a/Changes.txt +++ b/Changes.txt @@ -33,6 +33,10 @@ Basically, you are now able to put many files that Stella uses inside one ZIP file, and distribute just that file. + * Extended AtariVox support to handle flow control, so that long phrases + are no longer corrupted/cut off. Note that some USB-serial adaptors + don't support this mode, so there may still be issues with those. + * Added option to select the audio device. * Added option to display detected settings info when a ROM is loaded. diff --git a/src/emucore/AtariVox.cxx b/src/emucore/AtariVox.cxx index fd75024e4..731232456 100644 --- a/src/emucore/AtariVox.cxx +++ b/src/emucore/AtariVox.cxx @@ -28,7 +28,13 @@ AtariVox::AtariVox(Jack jack, const Event& event, const System& system, { mySerialPort = MediaFactory::createSerialPort(); if(mySerialPort->openPort(portname)) - myAboutString = " (using serial port \'" + portname + "\')"; + { + myCTSFlip = !mySerialPort->isCTS(); + if(myCTSFlip) + myAboutString = " (serial port \'" + portname + "\', inverted CTS)"; + else + myAboutString = " (serial port \'" + portname + "\')"; + } else myAboutString = " (invalid serial port \'" + portname + "\')"; @@ -50,12 +56,10 @@ bool AtariVox::read(DigitalPin pin) switch(pin) { // Pin 2: SpeakJet READY - // CTS (Clear To Send) is connected inverted - // So CTS = 0 means the buffer is full, which pulls pin 2 high + // CTS (Clear To Send) is sent directly to pin 2 + // We also deal with the case where devices send CTS inverted case DigitalPin::Two: - { - return setPin(pin, !mySerialPort->isCTS()); - } + return setPin(pin, mySerialPort->isCTS() ^ myCTSFlip); default: return SaveKey::read(pin); diff --git a/src/emucore/AtariVox.hxx b/src/emucore/AtariVox.hxx index 3251234ed..132b2c377 100644 --- a/src/emucore/AtariVox.hxx +++ b/src/emucore/AtariVox.hxx @@ -117,6 +117,11 @@ class AtariVox : public SaveKey // "close enough". uInt64 myLastDataWriteCycle{0}; + // Some USB-Serial adaptors either don't support CTS, or send the signal + // as inverted; we detect that when opening the port, and flip the signal + // when necessary + bool myCTSFlip{false}; + // Holds information concerning serial port usage string myAboutString;