mirror of https://github.com/stella-emu/stella.git
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
This commit is contained in:
parent
852ba8ba54
commit
3b15f8da5d
|
@ -15,22 +15,21 @@
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include "SerialPort.hxx"
|
#include "MediaFactory.hxx"
|
||||||
#include "System.hxx"
|
#include "System.hxx"
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
#include "AtariVox.hxx"
|
#include "AtariVox.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
AtariVox::AtariVox(Jack jack, const Event& event, const System& system, const OSystem& osystem,
|
AtariVox::AtariVox(Jack jack, const Event& event, const System& system, const OSystem& osystem,
|
||||||
const SerialPort& port, const string& portname,
|
const string& portname, const string& eepromfile)
|
||||||
const string& eepromfile)
|
|
||||||
: SaveKey(jack, event, system, osystem, eepromfile, Controller::AtariVox),
|
: SaveKey(jack, event, system, osystem, eepromfile, Controller::AtariVox),
|
||||||
mySerialPort(const_cast<SerialPort&>(port)),
|
|
||||||
myShiftCount(0),
|
myShiftCount(0),
|
||||||
myShiftRegister(0),
|
myShiftRegister(0),
|
||||||
myLastDataWriteCycle(0)
|
myLastDataWriteCycle(0)
|
||||||
{
|
{
|
||||||
if(mySerialPort.openPort(portname))
|
mySerialPort = MediaFactory::createSerialPort();
|
||||||
|
if(mySerialPort->openPort(portname))
|
||||||
myAboutString = " (using serial port \'" + portname + "\')";
|
myAboutString = " (using serial port \'" + portname + "\')";
|
||||||
else
|
else
|
||||||
myAboutString = " (invalid serial port \'" + portname + "\')";
|
myAboutString = " (invalid serial port \'" + portname + "\')";
|
||||||
|
@ -106,7 +105,7 @@ void AtariVox::clockDataIn(bool value)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uInt8 data = ((myShiftRegister >> 1) & 0xff);
|
uInt8 data = ((myShiftRegister >> 1) & 0xff);
|
||||||
mySerialPort.writeByte(&data);
|
mySerialPort->writeByte(&data);
|
||||||
}
|
}
|
||||||
myShiftRegister = 0;
|
myShiftRegister = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
#ifndef ATARIVOX_HXX
|
#ifndef ATARIVOX_HXX
|
||||||
#define ATARIVOX_HXX
|
#define ATARIVOX_HXX
|
||||||
|
|
||||||
class SerialPort;
|
|
||||||
class OSystem;
|
class OSystem;
|
||||||
|
|
||||||
#include "Control.hxx"
|
#include "Control.hxx"
|
||||||
#include "SaveKey.hxx"
|
#include "SaveKey.hxx"
|
||||||
|
#include "SerialPort.hxx"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Richard Hutchinson's AtariVox "controller": A speech synthesizer and
|
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 event The event object to use for events
|
||||||
@param system The system using this controller
|
@param system The system using this controller
|
||||||
@param osystem The OSystem abstraction
|
@param osystem The OSystem abstraction
|
||||||
@param port The serial port object
|
@param portname Name of the serial port used for reading and writing
|
||||||
@param portname Name of the port used for reading and writing
|
|
||||||
@param eepromfile The file containing the EEPROM data
|
@param eepromfile The file containing the EEPROM data
|
||||||
*/
|
*/
|
||||||
AtariVox(Jack jack, const Event& event, const System& system, const OSystem& osystem,
|
AtariVox(Jack jack, const Event& event, const System& system, const OSystem& osystem,
|
||||||
const SerialPort& port, const string& portname,
|
const string& portname, const string& eepromfile);
|
||||||
const string& eepromfile);
|
|
||||||
virtual ~AtariVox() = default;
|
virtual ~AtariVox() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -95,7 +93,7 @@ class AtariVox : public SaveKey
|
||||||
// Instance of an real serial port on the system
|
// Instance of an real serial port on the system
|
||||||
// Assuming there's a real AtariVox attached, we can send SpeakJet
|
// Assuming there's a real AtariVox attached, we can send SpeakJet
|
||||||
// bytes directly to it
|
// bytes directly to it
|
||||||
SerialPort& mySerialPort;
|
unique_ptr<SerialPort> mySerialPort;
|
||||||
|
|
||||||
// How many bits have been shifted into the shift register?
|
// How many bits have been shifted into the shift register?
|
||||||
uInt8 myShiftCount;
|
uInt8 myShiftCount;
|
||||||
|
|
|
@ -937,8 +937,7 @@ unique_ptr<Controller> Console::getControllerPort(const string& rommd5,
|
||||||
{
|
{
|
||||||
const string& nvramfile = myOSystem.nvramDir() + "atarivox_eeprom.dat";
|
const string& nvramfile = myOSystem.nvramDir() + "atarivox_eeprom.dat";
|
||||||
controller = make_unique<AtariVox>(port, myEvent,
|
controller = make_unique<AtariVox>(port, myEvent,
|
||||||
*mySystem, myOSystem, myOSystem.serialPort(),
|
*mySystem, myOSystem, myOSystem.settings().getString("avoxport"), nvramfile);
|
||||||
myOSystem.settings().getString("avoxport"), nvramfile);
|
|
||||||
}
|
}
|
||||||
else if(controllerName == "SAVEKEY")
|
else if(controllerName == "SAVEKEY")
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
#include "Widget.hxx"
|
#include "Widget.hxx"
|
||||||
#include "Console.hxx"
|
#include "Console.hxx"
|
||||||
#include "Random.hxx"
|
#include "Random.hxx"
|
||||||
#include "SerialPort.hxx"
|
|
||||||
#include "StateManager.hxx"
|
#include "StateManager.hxx"
|
||||||
#include "TimerManager.hxx"
|
#include "TimerManager.hxx"
|
||||||
#include "Version.hxx"
|
#include "Version.hxx"
|
||||||
|
@ -152,11 +151,6 @@ bool OSystem::create()
|
||||||
// that only have a single sound device (no hardware mixing))
|
// that only have a single sound device (no hardware mixing))
|
||||||
createSound();
|
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
|
// Create random number generator
|
||||||
myRandom = make_unique<Random>(uInt32(TimerManager::getTicks()));
|
myRandom = make_unique<Random>(uInt32(TimerManager::getTicks()));
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ class PNGLibrary;
|
||||||
class Properties;
|
class Properties;
|
||||||
class PropertiesSet;
|
class PropertiesSet;
|
||||||
class Random;
|
class Random;
|
||||||
class SerialPort;
|
|
||||||
class Sound;
|
class Sound;
|
||||||
class StateManager;
|
class StateManager;
|
||||||
class TimerManager;
|
class TimerManager;
|
||||||
|
@ -131,13 +130,6 @@ class OSystem
|
||||||
*/
|
*/
|
||||||
AudioSettings& audioSettings() { return *myAudioSettings; }
|
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.
|
Get the settings menu of the system.
|
||||||
|
|
||||||
|
@ -475,9 +467,6 @@ class OSystem
|
||||||
// Pointer to audio settings object
|
// Pointer to audio settings object
|
||||||
unique_ptr<AudioSettings> myAudioSettings;
|
unique_ptr<AudioSettings> myAudioSettings;
|
||||||
|
|
||||||
// Pointer to the serial port object
|
|
||||||
unique_ptr<SerialPort> mySerialPort;
|
|
||||||
|
|
||||||
// Pointer to the Menu object
|
// Pointer to the Menu object
|
||||||
unique_ptr<Menu> myMenu;
|
unique_ptr<Menu> myMenu;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue