From 06a673592fc7059a5ff8e46bf417004b181c7304 Mon Sep 17 00:00:00 2001 From: stephena Date: Fri, 5 Sep 2003 18:02:58 +0000 Subject: [PATCH] Yet more code reorganization in preparation for key remapping. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@176 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/build/makefile | 11 +- stella/src/emucore/Frontend.cxx | 43 ++++++ stella/src/emucore/Frontend.hxx | 120 ++++++++++++++++ .../src/{ui/common => emucore}/Settings.cxx | 2 +- .../src/{ui/common => emucore}/Settings.hxx | 2 +- stella/src/ui/frontend/FrontendUNIX.cxx | 103 ++++++++++++++ stella/src/ui/frontend/FrontendUNIX.hxx | 131 ++++++++++++++++++ 7 files changed, 406 insertions(+), 6 deletions(-) create mode 100644 stella/src/emucore/Frontend.cxx create mode 100644 stella/src/emucore/Frontend.hxx rename stella/src/{ui/common => emucore}/Settings.cxx (99%) rename stella/src/{ui/common => emucore}/Settings.hxx (98%) create mode 100644 stella/src/ui/frontend/FrontendUNIX.cxx create mode 100644 stella/src/ui/frontend/FrontendUNIX.hxx diff --git a/stella/src/build/makefile b/stella/src/build/makefile index 0a2d6a249..ba3f4258d 100644 --- a/stella/src/build/makefile +++ b/stella/src/build/makefile @@ -13,7 +13,7 @@ ## See the file "license" for information on usage and redistribution of ## this file, and for a DISCLAIMER OF ALL WARRANTIES. ## -## $Id: makefile,v 1.31 2003-09-03 20:10:58 stephena Exp $ +## $Id: makefile,v 1.32 2003-09-05 18:02:58 stephena Exp $ ##============================================================================ ##============================================================================ @@ -265,7 +265,7 @@ CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \ CartMB.o Console.o Control.o Driving.o \ Event.o Joystick.o Keyboard.o M6532.o MD5.o MediaSrc.o Paddles.o \ Props.o PropsSet.o Random.o Sound.o Switches.o Settings.o TIA.o \ - Serializer.o Deserializer.o TIASound.o EventHandler.o \ + Serializer.o Deserializer.o TIASound.o EventHandler.o Frontend.o \ $(M6502_OBJS) stella.exe: $(CORE_OBJS) $(OBJS) @@ -313,6 +313,9 @@ Event.o: $(CORE)/Event.cxx EventHandler.o: $(CORE)/EventHandler.cxx $(CORE)/EventHandler.hxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/EventHandler.cxx +Frontend.o: $(CORE)/Frontend.cxx $(CORE)/Frontend.hxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Frontend.cxx + Control.o: $(CORE)/Control.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Control.cxx @@ -424,8 +427,8 @@ Serializer.o: $(CORE)/Serializer.cxx Deserializer.o: $(CORE)/Deserializer.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Deserializer.cxx -Settings.o: $(UI)/common/Settings.cxx $(UI)/common/Settings.hxx - $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/common/Settings.cxx +Settings.o: $(CORE)/Settings.cxx $(CORE)/Settings.hxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(CORE)/Settings.cxx Terminal.o: $(UI)/x11/Terminal.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/x11/Terminal.cxx diff --git a/stella/src/emucore/Frontend.cxx b/stella/src/emucore/Frontend.cxx new file mode 100644 index 000000000..6604588ff --- /dev/null +++ b/stella/src/emucore/Frontend.cxx @@ -0,0 +1,43 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-1998 by Bradford W. Mott +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: Frontend.cxx,v 1.1 2003-09-05 18:02:58 stephena Exp $ +//============================================================================ + +#include +#include "Frontend.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Frontend::Frontend() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Frontend::~Frontend() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Frontend::Frontend(const Frontend&) +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Frontend& Frontend::operator = (const Frontend&) +{ + assert(false); + + return *this; +} diff --git a/stella/src/emucore/Frontend.hxx b/stella/src/emucore/Frontend.hxx new file mode 100644 index 000000000..57d5efe41 --- /dev/null +++ b/stella/src/emucore/Frontend.hxx @@ -0,0 +1,120 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-1998 by Bradford W. Mott +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: Frontend.hxx,v 1.1 2003-09-05 18:02:58 stephena Exp $ +//============================================================================ + +#ifndef FRONTEND_HXX +#define FRONTEND_HXX + +class Console; + +#include "bspf.hxx" + +/** + This class provides an interface for accessing frontend specific data. + + @author Stephen Anthony + @version $Id: Frontend.hxx,v 1.1 2003-09-05 18:02:58 stephena Exp $ +*/ +class Frontend +{ + public: + /** + Create a new frontend + */ + Frontend(); + + /** + Destructor + */ + virtual ~Frontend(); + + public: + /** + This method should be called when the emulation core sets + the console object. + */ + virtual void setConsole(Console* console) = 0; + + /** + This method should be called when the emulation core receives + a QUIT event. + */ + virtual void quit() = 0; + + /** + This method should be called at when the emulation core receives + a PAUSE event. + */ + virtual void pause(bool status) = 0; + + /** + This method should be called to get the filename of a state file + given the md5 and state number. + + @return String representing the full path of the state filename. + */ + virtual string& stateFilename(string& md5, uInt32 state) = 0; + + /** + This method should be called to get the filename of a snapshot + file given the md5 and state number. + + @return String representing the full path of the snapshot filename. + */ + virtual string& snapshotFilename(string& md5, uInt32 state) = 0; + + /** + This method should be called to get the filename of the users + properties (stella.pro) file. + + @return String representing the full path of the user properties filename. + */ + virtual string& userPropertiesFilename() = 0; + + /** + This method should be called to get the filename of the system + properties (stella.pro) file. + + @return String representing the full path of the system properties filename. + */ + virtual string& systemPropertiesFilename() = 0; + + /** + This method should be called to get the filename of the users + config (stellarc) file. + + @return String representing the full path of the users config filename. + */ + virtual string& userConfigFilename() = 0; + + /** + This method should be called to get the filename of the system + config (stellarc) file. + + @return String representing the full path of the system config filename. + */ + virtual string& systemConfigFilename() = 0; + + + private: + // Copy constructor isn't supported by this class so make it private + Frontend(const Frontend&); + + // Assignment operator isn't supported by this class so make it private + Frontend& operator = (const Frontend&); +}; +#endif diff --git a/stella/src/ui/common/Settings.cxx b/stella/src/emucore/Settings.cxx similarity index 99% rename from stella/src/ui/common/Settings.cxx rename to stella/src/emucore/Settings.cxx index f4577194d..f20e1c247 100644 --- a/stella/src/ui/common/Settings.cxx +++ b/stella/src/emucore/Settings.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Settings.cxx,v 1.10 2003-09-04 16:50:48 stephena Exp $ +// $Id: Settings.cxx,v 1.1 2003-09-05 18:02:58 stephena Exp $ //============================================================================ #include diff --git a/stella/src/ui/common/Settings.hxx b/stella/src/emucore/Settings.hxx similarity index 98% rename from stella/src/ui/common/Settings.hxx rename to stella/src/emucore/Settings.hxx index b3f5199b8..455977f66 100644 --- a/stella/src/ui/common/Settings.hxx +++ b/stella/src/emucore/Settings.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Settings.hxx,v 1.8 2003-09-04 16:50:48 stephena Exp $ +// $Id: Settings.hxx,v 1.1 2003-09-05 18:02:58 stephena Exp $ //============================================================================ #ifndef SETTINGS_HXX diff --git a/stella/src/ui/frontend/FrontendUNIX.cxx b/stella/src/ui/frontend/FrontendUNIX.cxx new file mode 100644 index 000000000..7cb0cb150 --- /dev/null +++ b/stella/src/ui/frontend/FrontendUNIX.cxx @@ -0,0 +1,103 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2002 by Bradford W. Mott +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: FrontendUNIX.cxx,v 1.1 2003-09-05 18:02:58 stephena Exp $ +//============================================================================ + +#ifndef FRONTEND_UNIX_HXX +#define FRONTEND_UNIX_HXX + +#include "bspf.hxx" +#include "Console.hxx" +#include "FrontendUNIX.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +FrontendUNIX::FrontendUNIX() +{ + myHomeDir = getenv("HOME"); + string path = homeDir + "/.stella"; + + if(access(path.c_str(), R_OK|W_OK|X_OK) != 0 ) + mkdir(path.c_str(), 0777); + + myStateDir = myHomeDir + "/.stella/state/"; + if(access(myStateDir.c_str(), R_OK|W_OK|X_OK) != 0 ) + mkdir(myStateDir.c_str(), 0777); + + myHomePropertiesFile = myHomeDir + "/.stella/stella.pro"; + mySystemPropertiesFile = "/etc/stella.pro"; + myHomeRCFile = myHomeDir + "/.stella/stellarc"; + mySystemRCFile = "/etc/stellarc"; + + mySnapshotFilename = ""; + myStateFilename = ""; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +FrontendUNIX::~FrontendUNIX() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrontendUNIX::setConsole(Console* console) +{ + myConsole = console; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrontendUNIX::quit() +{ + theQuitIndicator = true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrontendUNIX::pause(bool status) +{ + thePauseIndicator = status; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string& FrontendUNIX::stateFilename(string& md5, uInt32 state) +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string& FrontendUNIX::snapshotFilename(string& md5, uInt32 state) +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string& FrontendUNIX::userPropertiesFilename() +{ + return myHomePropertiesFile; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string& FrontendUNIX::systemPropertiesFilename() +{ + return mySystemPropertiesFile; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string& FrontendUNIX::userConfigFilename() +{ + return myHomeRCFile; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string& FrontendUNIX::systemConfigFilename() +{ + return mySystemRCFile; +} diff --git a/stella/src/ui/frontend/FrontendUNIX.hxx b/stella/src/ui/frontend/FrontendUNIX.hxx new file mode 100644 index 000000000..af8907e4c --- /dev/null +++ b/stella/src/ui/frontend/FrontendUNIX.hxx @@ -0,0 +1,131 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2002 by Bradford W. Mott +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: FrontendUNIX.hxx,v 1.1 2003-09-05 18:02:58 stephena Exp $ +//============================================================================ + +#ifndef FRONTEND_UNIX_HXX +#define FRONTEND_UNIX_HXX + +class Console; + +#include "bspf.hxx" +#include "Frontend.hxx" + +/** + This class defines UNIX-like OS's (Linux) system specific file locations + and events. + + @author Stephen Anthony + @version $Id: FrontendUNIX.hxx,v 1.1 2003-09-05 18:02:58 stephena Exp $ +*/ +class FrontendUNIX : public Frontend +{ + public: + /** + Create a new UNIX frontend + +// @param console The console the TIA is associated with +// @param sampleRate The sample rate to create audio samples at + */ + FrontendUNIX(); + + /** + Destructor + */ + virtual ~FrontendUNIX(); + + public: + /** + Let the frontend know about the console object + */ + virtual void setConsole(Console* console); + + /** + Called when the emulation core receives a QUIT event. + */ + virtual void quit(); + + /** + Called when the emulation core receives a PAUSE event. + */ + virtual void pause(bool status); + + /** + Returns the UNIX filename representing a state file. + + @param md5 The md5 string to use as part of the filename. + @param state The state number to use as part of the filename. + @return The full path and filename of the state file. + */ + virtual string& stateFilename(string& md5, uInt32 state); + + /** + Returns the UNIX filename representing a state file. + + @param md5 The md5 string to use as part of the filename. + @param state The state number to use as part of the filename. + @return The full path and filename of the snapshot file. + */ + virtual string& snapshotFilename(string& md5, uInt32 state); + + /** + Returns the UNIX filename representing a users properties file. + + @return The full path and filename of the user properties file. + */ + virtual string& userPropertiesFilename(); + + /** + Returns the UNIX filename representing a system properties file. + + @return The full path and filename of the system properties file. + */ + virtual string& systemPropertiesFilename(); + + /** + Returns the UNIX filename representing a users config file. + + @return The full path and filename of the user config file. + */ + virtual string& userConfigFilename(); + + /** + Returns the UNIX filename representing a system config file. + + @return The full path and filename of the system config file. + */ + virtual string& systemConfigFilename(); + + public: + bool theQuitIndicator; + bool thePauseIndicator + + private: + string myHomeDir; + string myStateDir; + + string mySnapshotFile; + string myStateFile; + string myHomePropertiesFile; + string mySystemPropertiesFile; + string myHomeRCFile; + string mySystemRCFile; + + // The global Console object + Console* myConsole; +}; + +#endif