From 3b15f8da5d04e4fdfcbe7622a17fecd4ad9f1f63 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sun, 3 Mar 2019 21:30:53 -0330 Subject: [PATCH] Move SerialPort declaration/instantiation directly into AtariVox. - This is the only class that uses it, so it makes no sense for OSystem to even care about it --- src/emucore/AtariVox.cxx | 11 +++++------ src/emucore/AtariVox.hxx | 10 ++++------ src/emucore/Console.cxx | 3 +-- src/emucore/OSystem.cxx | 6 ------ src/emucore/OSystem.hxx | 11 ----------- 5 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/emucore/AtariVox.cxx b/src/emucore/AtariVox.cxx index c15361b54..d1b3f6352 100644 --- a/src/emucore/AtariVox.cxx +++ b/src/emucore/AtariVox.cxx @@ -15,22 +15,21 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#include "SerialPort.hxx" +#include "MediaFactory.hxx" #include "System.hxx" #include "OSystem.hxx" #include "AtariVox.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AtariVox::AtariVox(Jack jack, const Event& event, const System& system, const OSystem& osystem, - const SerialPort& port, const string& portname, - const string& eepromfile) + const string& portname, const string& eepromfile) : SaveKey(jack, event, system, osystem, eepromfile, Controller::AtariVox), - mySerialPort(const_cast(port)), myShiftCount(0), myShiftRegister(0), myLastDataWriteCycle(0) { - if(mySerialPort.openPort(portname)) + mySerialPort = MediaFactory::createSerialPort(); + if(mySerialPort->openPort(portname)) myAboutString = " (using serial port \'" + portname + "\')"; else myAboutString = " (invalid serial port \'" + portname + "\')"; @@ -106,7 +105,7 @@ void AtariVox::clockDataIn(bool value) else { uInt8 data = ((myShiftRegister >> 1) & 0xff); - mySerialPort.writeByte(&data); + mySerialPort->writeByte(&data); } myShiftRegister = 0; } diff --git a/src/emucore/AtariVox.hxx b/src/emucore/AtariVox.hxx index dc474d85b..fb85faf48 100644 --- a/src/emucore/AtariVox.hxx +++ b/src/emucore/AtariVox.hxx @@ -18,11 +18,11 @@ #ifndef ATARIVOX_HXX #define ATARIVOX_HXX -class SerialPort; class OSystem; #include "Control.hxx" #include "SaveKey.hxx" +#include "SerialPort.hxx" /** Richard Hutchinson's AtariVox "controller": A speech synthesizer and @@ -43,13 +43,11 @@ class AtariVox : public SaveKey @param event The event object to use for events @param system The system using this controller @param osystem The OSystem abstraction - @param port The serial port object - @param portname Name of the port used for reading and writing + @param portname Name of the serial port used for reading and writing @param eepromfile The file containing the EEPROM data */ AtariVox(Jack jack, const Event& event, const System& system, const OSystem& osystem, - const SerialPort& port, const string& portname, - const string& eepromfile); + const string& portname, const string& eepromfile); virtual ~AtariVox() = default; public: @@ -95,7 +93,7 @@ class AtariVox : public SaveKey // Instance of an real serial port on the system // Assuming there's a real AtariVox attached, we can send SpeakJet // bytes directly to it - SerialPort& mySerialPort; + unique_ptr mySerialPort; // How many bits have been shifted into the shift register? uInt8 myShiftCount; diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 892b7bd3c..c014c2d86 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -937,8 +937,7 @@ unique_ptr Console::getControllerPort(const string& rommd5, { const string& nvramfile = myOSystem.nvramDir() + "atarivox_eeprom.dat"; controller = make_unique(port, myEvent, - *mySystem, myOSystem, myOSystem.serialPort(), - myOSystem.settings().getString("avoxport"), nvramfile); + *mySystem, myOSystem, myOSystem.settings().getString("avoxport"), nvramfile); } else if(controllerName == "SAVEKEY") { diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 9b7cee17e..8db2d6ac8 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -48,7 +48,6 @@ #include "Widget.hxx" #include "Console.hxx" #include "Random.hxx" -#include "SerialPort.hxx" #include "StateManager.hxx" #include "TimerManager.hxx" #include "Version.hxx" @@ -152,11 +151,6 @@ bool OSystem::create() // that only have a single sound device (no hardware mixing)) createSound(); - // Create the serial port object - // This is used by any controller that wants to directly access - // a real serial port on the system - mySerialPort = MediaFactory::createSerialPort(); - // Create random number generator myRandom = make_unique(uInt32(TimerManager::getTicks())); diff --git a/src/emucore/OSystem.hxx b/src/emucore/OSystem.hxx index 04533bfdf..5d9f71416 100644 --- a/src/emucore/OSystem.hxx +++ b/src/emucore/OSystem.hxx @@ -33,7 +33,6 @@ class PNGLibrary; class Properties; class PropertiesSet; class Random; -class SerialPort; class Sound; class StateManager; class TimerManager; @@ -131,13 +130,6 @@ class OSystem */ AudioSettings& audioSettings() { return *myAudioSettings; } - /** - Get the serial port of the system. - - @return The serial port object - */ - SerialPort& serialPort() const { return *mySerialPort; } - /** Get the settings menu of the system. @@ -475,9 +467,6 @@ class OSystem // Pointer to audio settings object unique_ptr myAudioSettings; - // Pointer to the serial port object - unique_ptr mySerialPort; - // Pointer to the Menu object unique_ptr myMenu;