More huge code reorganizations.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@368 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-02-21 20:43:53 +00:00
parent c30051b0a3
commit 9c42f79392
21 changed files with 242 additions and 214 deletions

View File

@ -13,7 +13,7 @@
## See the file "license" for information on usage and redistribution of ## See the file "license" for information on usage and redistribution of
## this file, and for a DISCLAIMER OF ALL WARRANTIES. ## this file, and for a DISCLAIMER OF ALL WARRANTIES.
## ##
## $Id: makefile,v 1.59 2005-02-21 02:23:47 stephena Exp $ ## $Id: makefile,v 1.60 2005-02-21 20:41:04 stephena Exp $
##============================================================================ ##============================================================================
##============================================================================ ##============================================================================
@ -32,7 +32,7 @@ OPTIMIZATIONS =
### to include support for saving snapshots in png format ### to include support for saving snapshots in png format
### (requires PNG library) ### (requires PNG library)
SNAPSHOT_SUPPORT = 1 # SNAPSHOT_SUPPORT = 1
### to include support for game developers ### to include support for game developers
### enables some extra commandline options that allow the user ### enables some extra commandline options that allow the user
@ -41,7 +41,7 @@ OPTIMIZATIONS =
### to build on SMP (or distcc-based) machines ### to build on SMP (or distcc-based) machines
### change to number of CPU's you have ### change to number of CPU's you have
NUMBER_CPU = 1 NUMBER_CPU = 3
##============================================================================ ##============================================================================
## All done, type make to get a list of frontends ## All done, type make to get a list of frontends

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBufferSoft.cxx,v 1.7 2005-02-21 02:23:48 stephena Exp $ // $Id: FrameBufferSoft.cxx,v 1.8 2005-02-21 20:41:18 stephena Exp $
//============================================================================ //============================================================================
#include <SDL.h> #include <SDL.h>
@ -28,8 +28,8 @@
#include "OSystem.hxx" #include "OSystem.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBufferSoft::FrameBufferSoft() FrameBufferSoft::FrameBufferSoft(OSystem* osystem)
: FrameBuffer() : FrameBuffer(osystem)
{ {
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBufferSoft.hxx,v 1.5 2005-02-21 02:23:48 stephena Exp $ // $Id: FrameBufferSoft.hxx,v 1.6 2005-02-21 20:41:19 stephena Exp $
//============================================================================ //============================================================================
#ifndef FRAMEBUFFER_SOFT_HXX #ifndef FRAMEBUFFER_SOFT_HXX
@ -22,6 +22,8 @@
#include <SDL.h> #include <SDL.h>
#include <SDL_syswm.h> #include <SDL_syswm.h>
class OSystem;
#include "bspf.hxx" #include "bspf.hxx"
#include "FrameBuffer.hxx" #include "FrameBuffer.hxx"
@ -32,7 +34,7 @@ class RectList;
This class implements an SDL software framebuffer. This class implements an SDL software framebuffer.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBufferSoft.hxx,v 1.5 2005-02-21 02:23:48 stephena Exp $ @version $Id: FrameBufferSoft.hxx,v 1.6 2005-02-21 20:41:19 stephena Exp $
*/ */
class FrameBufferSoft : public FrameBuffer class FrameBufferSoft : public FrameBuffer
{ {
@ -40,7 +42,7 @@ class FrameBufferSoft : public FrameBuffer
/** /**
Creates a new software framebuffer Creates a new software framebuffer
*/ */
FrameBufferSoft(); FrameBufferSoft(OSystem* osystem);
/** /**
Destructor Destructor

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: mainSDL.cxx,v 1.21 2005-02-21 02:23:48 stephena Exp $ // $Id: mainSDL.cxx,v 1.22 2005-02-21 20:41:20 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
@ -121,6 +121,9 @@ static Event::Type Paddle_Button[4] = {
// Pointer to the main parent osystem object or the null pointer // Pointer to the main parent osystem object or the null pointer
static OSystem* theOSystem = (OSystem*) NULL; static OSystem* theOSystem = (OSystem*) NULL;
// Pointer to the display object or the null pointer
static EventHandler* theEventHandler = (EventHandler*) NULL;
// Pointer to the display object or the null pointer // Pointer to the display object or the null pointer
static FrameBuffer* theDisplay = (FrameBuffer*) NULL; static FrameBuffer* theDisplay = (FrameBuffer*) NULL;
@ -804,18 +807,21 @@ void Cleanup()
} }
#endif #endif
if(theOSystem)
delete theOSystem;
/*
if(theConsole)
delete theConsole;
if(theSound) if(theSound)
delete theSound; delete theSound;
if(theDisplay) if(theDisplay)
delete theDisplay; delete theDisplay;
*/
if(theEventHandler)
delete theEventHandler;
if(theOSystem)
{
theOSystem->detachConsole();
delete theOSystem;
}
if(SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO) if(SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO)
SDL_Quit(); SDL_Quit();
} }
@ -826,10 +832,13 @@ int main(int argc, char* argv[])
{ {
uInt8* image = NULL; uInt8* image = NULL;
// Create the parent OSystem object and settings
#if defined(UNIX) #if defined(UNIX)
theSettings = new SettingsUNIX(); theOSystem = new OSystemUNIX();
theSettings = new SettingsUNIX(theOSystem);
#elif defined(WIN32) #elif defined(WIN32)
theSettings = new SettingsWin32(); theOSystem = new OSystemWin32();
theSettings = new SettingsWin32(theOSystem);
#else #else
#error Unsupported platform! #error Unsupported platform!
#endif #endif
@ -847,6 +856,9 @@ int main(int argc, char* argv[])
return 0; return 0;
} }
// Create the event handler for the system
theEventHandler = new EventHandler(theOSystem);
// Cache some settings so they don't have to be repeatedly searched for // Cache some settings so they don't have to be repeatedly searched for
thePaddleMode = theSettings->getInt("paddle"); thePaddleMode = theSettings->getInt("paddle");
theShowInfoFlag = theSettings->getBool("showinfo"); theShowInfoFlag = theSettings->getBool("showinfo");
@ -856,6 +868,7 @@ int main(int argc, char* argv[])
// Create a properties set for us to use and set it up // Create a properties set for us to use and set it up
PropertiesSet propertiesSet; PropertiesSet propertiesSet;
SetupProperties(propertiesSet); SetupProperties(propertiesSet);
theOSystem->attach(&propertiesSet);
// Check to see if the 'listroms' argument was given // Check to see if the 'listroms' argument was given
// If so, list the roms and immediately exit // If so, list the roms and immediately exit
@ -885,7 +898,7 @@ int main(int argc, char* argv[])
string videodriver = theSettings->getString("video"); string videodriver = theSettings->getString("video");
if(videodriver == "soft") if(videodriver == "soft")
{ {
theDisplay = new FrameBufferSoft(); theDisplay = new FrameBufferSoft(theOSystem);
} }
#ifdef DISPLAY_OPENGL #ifdef DISPLAY_OPENGL
else if(videodriver == "gl") else if(videodriver == "gl")
@ -896,7 +909,7 @@ int main(int argc, char* argv[])
#endif #endif
else // a driver that doesn't exist was requested, so use software mode else // a driver that doesn't exist was requested, so use software mode
{ {
theDisplay = new FrameBufferSoft(); theDisplay = new FrameBufferSoft(theOSystem);
} }
if(!theDisplay) if(!theDisplay)
@ -927,15 +940,6 @@ int main(int argc, char* argv[])
ShowInfo("Sound disabled"); ShowInfo("Sound disabled");
} }
// Create the parent OSystem object
#if defined(UNIX)
theOSystem = new OSystemUNIX(*theDisplay, *theSound, *theSettings, propertiesSet);
#elif defined(WIN32)
theSettings = new SettingsWin32();
#else
#error Unsupported platform!
#endif
// Get a pointer to the file which contains the cartridge ROM // Get a pointer to the file which contains the cartridge ROM
const char* file = argv[argc - 1]; const char* file = argv[argc - 1];
@ -953,12 +957,10 @@ int main(int argc, char* argv[])
uInt32 size = in.gcount(); uInt32 size = in.gcount();
in.close(); in.close();
// Get just the filename of the file containing the ROM image
const char* filename = (!strrchr(file, '/')) ? file : strrchr(file, '/') + 1;
// Create the 2600 game console // Create the 2600 game console
// theConsole = new Console(image, size, filename, *theSettings, propertiesSet, Console* theConsole = new Console(image, size, theOSystem);
// *theDisplay, *theSound);
cerr << "got here\n";
// Free the image since we don't need it any longer // Free the image since we don't need it any longer
delete[] image; delete[] image;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Console.cxx,v 1.39 2005-02-21 02:23:49 stephena Exp $ // $Id: Console.cxx,v 1.40 2005-02-21 20:41:24 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <assert.h>
@ -51,8 +51,7 @@
#endif #endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Console::Console(const uInt8* image, uInt32 size, const char* filename, Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
OSystem& osystem)
: myOSystem(osystem) : myOSystem(osystem)
{ {
myControllers[0] = 0; myControllers[0] = 0;
@ -63,16 +62,16 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename,
myEvent = 0; myEvent = 0;
// Add the current console to the system // Add the current console to the system
myOSystem.addConsole(this); myOSystem->attach(this);
// Attach the event subsystem to the current console // Attach the event subsystem to the current console
myEvent = myOSystem.eventHandler().event(); myEvent = myOSystem->eventHandler().event();
// Get the MD5 message-digest for the ROM image // Get the MD5 message-digest for the ROM image
string md5 = MD5(image, size); string md5 = MD5(image, size);
// Search for the properties based on MD5 // Search for the properties based on MD5
myOSystem.propSet().getMD5(md5, myProperties); myOSystem->propSet().getMD5(md5, myProperties);
// Make sure the MD5 value of the cartridge is set in the properties // Make sure the MD5 value of the cartridge is set in the properties
if(myProperties.get("Cartridge.MD5") == "") if(myProperties.get("Cartridge.MD5") == "")
@ -143,7 +142,7 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename,
} }
M6532* m6532 = new M6532(*this); M6532* m6532 = new M6532(*this);
TIA* tia = new TIA(myOSystem); TIA* tia = new TIA(*this, myOSystem->sound(), myOSystem->settings());
Cartridge* cartridge = Cartridge::create(image, size, myProperties); Cartridge* cartridge = Cartridge::create(image, size, myProperties);
mySystem->attach(m6502); mySystem->attach(m6502);
@ -160,27 +159,26 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename,
// Set the correct framerate based on the format of the ROM // Set the correct framerate based on the format of the ROM
// This can be overridden by the '-framerate' option // This can be overridden by the '-framerate' option
myFrameRate = 60; myFrameRate = 60;
if(myOSystem.settings().getInt("framerate") > 0) if(myOSystem->settings().getInt("framerate") > 0)
myFrameRate = myOSystem.settings().getInt("framerate"); myFrameRate = myOSystem->settings().getInt("framerate");
// else if(myProperties.get("Display.Format") == "NTSC") // else if(myProperties.get("Display.Format") == "NTSC")
// myFrameRate = 60; // myFrameRate = 60;
// else if(myProperties.get("Display.Format") == "PAL") // else if(myProperties.get("Display.Format") == "PAL")
// myFrameRate = 50; // myFrameRate = 50;
// mySettings.setInt("framerate", myFrameRate, false); // mySettings.setInt("framerate", myFrameRate, false);
myOSystem.settings().setInt("framerate", myFrameRate); myOSystem->settings().setInt("framerate", myFrameRate);
// Initialize the framebuffer interface. // Initialize the framebuffer interface.
// This must be done *after* a reset, since it needs updated values. // This must be done *after* a reset, since it needs updated values.
ostringstream title; ostringstream title;
title << "Stella: \"" << myProperties.get("Cartridge.Name") << "\""; title << "Stella: \"" << myProperties.get("Cartridge.Name") << "\"";
myOSystem.frameBuffer().initialize(&myOSystem, myOSystem->frameBuffer().initialize(title.str(),
title.str(),
myMediaSource->width() << 1, myMediaSource->width() << 1,
myMediaSource->height()); myMediaSource->height());
// Initialize the sound interface. // Initialize the sound interface.
uInt32 soundFrameRate = (myProperties.get("Display.Format") == "PAL") ? 50 : 60; uInt32 soundFrameRate = (myProperties.get("Display.Format") == "PAL") ? 50 : 60;
myOSystem.sound().initialize(&myOSystem, mySystem, soundFrameRate); myOSystem->sound().initialize(myOSystem, mySystem, soundFrameRate);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -224,40 +222,40 @@ void Console::toggleFormat()
{ {
myProperties.set("Display.Format", "PAL"); myProperties.set("Display.Format", "PAL");
mySystem->reset(); mySystem->reset();
myOSystem.frameBuffer().showMessage("PAL Mode"); myOSystem->frameBuffer().showMessage("PAL Mode");
} }
else if(format == "PAL") else if(format == "PAL")
{ {
myProperties.set("Display.Format", "NTSC"); myProperties.set("Display.Format", "NTSC");
mySystem->reset(); mySystem->reset();
myOSystem.frameBuffer().showMessage("NTSC Mode"); myOSystem->frameBuffer().showMessage("NTSC Mode");
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::togglePalette() void Console::togglePalette()
{ {
string type = myOSystem.settings().getString("palette"); string type = myOSystem->settings().getString("palette");
if(type == "standard") // switch to original if(type == "standard") // switch to original
{ {
myOSystem.frameBuffer().showMessage("Original Stella colors"); myOSystem->frameBuffer().showMessage("Original Stella colors");
myOSystem.settings().setString("palette", "original"); myOSystem->settings().setString("palette", "original");
} }
else if(type == "original") // switch to z26 else if(type == "original") // switch to z26
{ {
myOSystem.frameBuffer().showMessage("Z26 colors"); myOSystem->frameBuffer().showMessage("Z26 colors");
myOSystem.settings().setString("palette", "z26"); myOSystem->settings().setString("palette", "z26");
} }
else if(type == "z26") // switch to standard else if(type == "z26") // switch to standard
{ {
myOSystem.frameBuffer().showMessage("Standard Stella colors"); myOSystem->frameBuffer().showMessage("Standard Stella colors");
myOSystem.settings().setString("palette", "standard"); myOSystem->settings().setString("palette", "standard");
} }
else // switch to standard mode if we get this far else // switch to standard mode if we get this far
{ {
myOSystem.frameBuffer().showMessage("Standard Stella colors"); myOSystem->frameBuffer().showMessage("Standard Stella colors");
myOSystem.settings().setString("palette", "standard"); myOSystem->settings().setString("palette", "standard");
} }
} }
@ -267,10 +265,10 @@ void Console::saveProperties(string filename, bool merge)
// Merge the current properties into the PropertiesSet file // Merge the current properties into the PropertiesSet file
if(merge) if(merge)
{ {
if(myOSystem.propSet().merge(myProperties, filename)) if(myOSystem->propSet().merge(myProperties, filename))
myOSystem.frameBuffer().showMessage("Properties merged"); myOSystem->frameBuffer().showMessage("Properties merged");
else else
myOSystem.frameBuffer().showMessage("Properties not merged"); myOSystem->frameBuffer().showMessage("Properties not merged");
} }
else // Save to the specified file directly else // Save to the specified file directly
{ {
@ -280,11 +278,11 @@ void Console::saveProperties(string filename, bool merge)
{ {
myProperties.save(out); myProperties.save(out);
out.close(); out.close();
myOSystem.frameBuffer().showMessage("Properties saved"); myOSystem->frameBuffer().showMessage("Properties saved");
} }
else else
{ {
myOSystem.frameBuffer().showMessage("Properties not saved"); myOSystem->frameBuffer().showMessage("Properties not saved");
} }
} }
} }
@ -303,12 +301,12 @@ void Console::changeXStart(const uInt32 direction)
xstart += 4; xstart += 4;
if(xstart > 80) if(xstart > 80)
{ {
myOSystem.frameBuffer().showMessage("XStart at maximum"); myOSystem->frameBuffer().showMessage("XStart at maximum");
return; return;
} }
else if((width + xstart) > 160) else if((width + xstart) > 160)
{ {
myOSystem.frameBuffer().showMessage("XStart no effect"); myOSystem->frameBuffer().showMessage("XStart no effect");
return; return;
} }
} }
@ -317,7 +315,7 @@ void Console::changeXStart(const uInt32 direction)
xstart -= 4; xstart -= 4;
if(xstart < 0) if(xstart < 0)
{ {
myOSystem.frameBuffer().showMessage("XStart at minimum"); myOSystem->frameBuffer().showMessage("XStart at minimum");
return; return;
} }
} }
@ -328,7 +326,7 @@ void Console::changeXStart(const uInt32 direction)
message = "XStart "; message = "XStart ";
message += strval.str(); message += strval.str();
myOSystem.frameBuffer().showMessage(message); myOSystem->frameBuffer().showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -343,7 +341,7 @@ void Console::changeYStart(const uInt32 direction)
ystart++; ystart++;
if(ystart > 64) if(ystart > 64)
{ {
myOSystem.frameBuffer().showMessage("YStart at maximum"); myOSystem->frameBuffer().showMessage("YStart at maximum");
return; return;
} }
} }
@ -352,7 +350,7 @@ void Console::changeYStart(const uInt32 direction)
ystart--; ystart--;
if(ystart < 0) if(ystart < 0)
{ {
myOSystem.frameBuffer().showMessage("YStart at minimum"); myOSystem->frameBuffer().showMessage("YStart at minimum");
return; return;
} }
} }
@ -363,7 +361,7 @@ void Console::changeYStart(const uInt32 direction)
message = "YStart "; message = "YStart ";
message += strval.str(); message += strval.str();
myOSystem.frameBuffer().showMessage(message); myOSystem->frameBuffer().showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -379,12 +377,12 @@ void Console::changeWidth(const uInt32 direction)
width += 4; width += 4;
if((width > 160) || ((width % 4) != 0)) if((width > 160) || ((width % 4) != 0))
{ {
myOSystem.frameBuffer().showMessage("Width at maximum"); myOSystem->frameBuffer().showMessage("Width at maximum");
return; return;
} }
else if((width + xstart) > 160) else if((width + xstart) > 160)
{ {
myOSystem.frameBuffer().showMessage("Width no effect"); myOSystem->frameBuffer().showMessage("Width no effect");
return; return;
} }
} }
@ -393,7 +391,7 @@ void Console::changeWidth(const uInt32 direction)
width -= 4; width -= 4;
if(width < 80) if(width < 80)
{ {
myOSystem.frameBuffer().showMessage("Width at minimum"); myOSystem->frameBuffer().showMessage("Width at minimum");
return; return;
} }
} }
@ -404,7 +402,7 @@ void Console::changeWidth(const uInt32 direction)
message = "Width "; message = "Width ";
message += strval.str(); message += strval.str();
myOSystem.frameBuffer().showMessage(message); myOSystem->frameBuffer().showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -419,7 +417,7 @@ void Console::changeHeight(const uInt32 direction)
height++; height++;
if(height > 256) if(height > 256)
{ {
myOSystem.frameBuffer().showMessage("Height at maximum"); myOSystem->frameBuffer().showMessage("Height at maximum");
return; return;
} }
} }
@ -428,7 +426,7 @@ void Console::changeHeight(const uInt32 direction)
height--; height--;
if(height < 100) if(height < 100)
{ {
myOSystem.frameBuffer().showMessage("Height at minimum"); myOSystem->frameBuffer().showMessage("Height at minimum");
return; return;
} }
} }
@ -439,6 +437,6 @@ void Console::changeHeight(const uInt32 direction)
message = "Height "; message = "Height ";
message += strval.str(); message += strval.str();
myOSystem.frameBuffer().showMessage(message); myOSystem->frameBuffer().showMessage(message);
} }
#endif #endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Console.hxx,v 1.23 2005-02-21 02:23:49 stephena Exp $ // $Id: Console.hxx,v 1.24 2005-02-21 20:41:26 stephena Exp $
//============================================================================ //============================================================================
#ifndef CONSOLE_HXX #ifndef CONSOLE_HXX
@ -36,7 +36,7 @@ class OSystem;
This class represents the entire game console. This class represents the entire game console.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Console.hxx,v 1.23 2005-02-21 02:23:49 stephena Exp $ @version $Id: Console.hxx,v 1.24 2005-02-21 20:41:26 stephena Exp $
*/ */
class Console class Console
{ {
@ -47,11 +47,9 @@ class Console
@param image The ROM image of the game to emulate @param image The ROM image of the game to emulate
@param size The size of the ROM image @param size The size of the ROM image
@param filename The name of the file that contained the ROM image
@param osystem The OSystem object to use @param osystem The OSystem object to use
*/ */
Console(const uInt8* image, uInt32 size, const char* filename, Console(const uInt8* image, uInt32 size, OSystem* osystem);
OSystem& osystem);
/** /**
Create a new console object by copying another one Create a new console object by copying another one
@ -177,8 +175,8 @@ class Console
#endif #endif
private: private:
// Reference to the osystem object // Pointer to the osystem object
OSystem& myOSystem; OSystem* myOSystem;
// Pointers to the left and right controllers // Pointers to the left and right controllers
Controller* myControllers[2]; Controller* myControllers[2];

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventHandler.cxx,v 1.31 2005-02-21 02:23:49 stephena Exp $ // $Id: EventHandler.cxx,v 1.32 2005-02-21 20:42:07 stephena Exp $
//============================================================================ //============================================================================
#include <algorithm> #include <algorithm>
@ -34,7 +34,7 @@
#endif #endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandler::EventHandler(OSystem& osystem) EventHandler::EventHandler(OSystem* osystem)
: myOSystem(osystem), : myOSystem(osystem),
myCurrentState(0), myCurrentState(0),
myPauseStatus(false), myPauseStatus(false),
@ -42,6 +42,10 @@ EventHandler::EventHandler(OSystem& osystem)
myMenuStatus(false), myMenuStatus(false),
myRemapEnabledFlag(true) myRemapEnabledFlag(true)
{ {
cerr << "EventHandler::EventHandler()\n";
// Add this eventhandler object to the OSystem
myOSystem->attach(this);
// Create the event object which will be used for this handler // Create the event object which will be used for this handler
myEvent = new Event(); myEvent = new Event();
@ -90,14 +94,14 @@ void EventHandler::sendKeyEvent(StellaEvent::KeyCode key, Int32 state)
if(myRemapEnabledFlag && key == StellaEvent::KCODE_TAB && state == 1 && !myPauseStatus) if(myRemapEnabledFlag && key == StellaEvent::KCODE_TAB && state == 1 && !myPauseStatus)
{ {
myMenuStatus = !myMenuStatus; myMenuStatus = !myMenuStatus;
myOSystem.frameBuffer().showMenu(myMenuStatus); myOSystem->frameBuffer().showMenu(myMenuStatus);
myOSystem.sound().mute(myMenuStatus); myOSystem->sound().mute(myMenuStatus);
return; return;
} }
// Determine where the event should be sent // Determine where the event should be sent
if(myMenuStatus) if(myMenuStatus)
myOSystem.frameBuffer().sendKeyEvent(key, state); myOSystem->frameBuffer().sendKeyEvent(key, state);
else else
sendEvent(myKeyTable[key], state); sendEvent(myKeyTable[key], state);
} }
@ -108,7 +112,7 @@ void EventHandler::sendJoyEvent(StellaEvent::JoyStick stick,
{ {
// Determine where the event should be sent // Determine where the event should be sent
if(myMenuStatus) if(myMenuStatus)
myOSystem.frameBuffer().sendJoyEvent(stick, code, state); myOSystem->frameBuffer().sendJoyEvent(stick, code, state);
else else
sendEvent(myJoyTable[stick*StellaEvent::LastJCODE + code], state); sendEvent(myJoyTable[stick*StellaEvent::LastJCODE + code], state);
} }
@ -147,19 +151,19 @@ void EventHandler::sendEvent(Event::Type event, Int32 state)
else if(event == Event::Pause) else if(event == Event::Pause)
{ {
myPauseStatus = !myPauseStatus; myPauseStatus = !myPauseStatus;
myOSystem.frameBuffer().pause(myPauseStatus); myOSystem->frameBuffer().pause(myPauseStatus);
myOSystem.sound().mute(myPauseStatus); myOSystem->sound().mute(myPauseStatus);
return; return;
} }
else if(event == Event::Quit) else if(event == Event::Quit)
{ {
myQuitStatus = !myQuitStatus; myQuitStatus = !myQuitStatus;
myOSystem.settings().saveConfig(); myOSystem->settings().saveConfig();
return; return;
} }
if(ourMessageTable[event] != "") if(ourMessageTable[event] != "")
myOSystem.frameBuffer().showMessage(ourMessageTable[event]); myOSystem->frameBuffer().showMessage(ourMessageTable[event]);
} }
// Otherwise, pass it to the emulation core // Otherwise, pass it to the emulation core
@ -171,7 +175,7 @@ void EventHandler::setKeymap()
{ {
// Since istringstream swallows whitespace, we have to make the // Since istringstream swallows whitespace, we have to make the
// delimiters be spaces // delimiters be spaces
string list = myOSystem.settings().getString("keymap"); string list = myOSystem->settings().getString("keymap");
replace(list.begin(), list.end(), ':', ' '); replace(list.begin(), list.end(), ':', ' ');
if(isValidList(list, StellaEvent::LastKCODE)) if(isValidList(list, StellaEvent::LastKCODE))
@ -195,7 +199,7 @@ void EventHandler::setJoymap()
{ {
// Since istringstream swallows whitespace, we have to make the // Since istringstream swallows whitespace, we have to make the
// delimiters be spaces // delimiters be spaces
string list = myOSystem.settings().getString("joymap"); string list = myOSystem->settings().getString("joymap");
replace(list.begin(), list.end(), ':', ' '); replace(list.begin(), list.end(), ':', ' ');
if(isValidList(list, StellaEvent::LastJSTICK*StellaEvent::LastJCODE)) if(isValidList(list, StellaEvent::LastJSTICK*StellaEvent::LastJCODE))
@ -339,9 +343,9 @@ bool EventHandler::isValidList(string list, uInt32 length)
void EventHandler::saveState() void EventHandler::saveState()
{ {
// Do a state save using the System // Do a state save using the System
string md5 = myOSystem.console().properties().get("Cartridge.MD5"); string md5 = myOSystem->console().properties().get("Cartridge.MD5");
string filename = myOSystem.stateFilename(md5, myCurrentState); string filename = myOSystem->stateFilename(md5, myCurrentState);
int result = myOSystem.console().system().saveState(filename, md5); int result = myOSystem->console().system().saveState(filename, md5);
// Print appropriate message // Print appropriate message
ostringstream buf; ostringstream buf;
@ -352,7 +356,7 @@ void EventHandler::saveState()
else if(result == 3) else if(result == 3)
buf << "Invalid state " << myCurrentState << " file"; buf << "Invalid state " << myCurrentState << " file";
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem->frameBuffer().showMessage(buf.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -367,16 +371,16 @@ void EventHandler::changeState()
ostringstream buf; ostringstream buf;
buf << "Changed to slot " << myCurrentState; buf << "Changed to slot " << myCurrentState;
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem->frameBuffer().showMessage(buf.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::loadState() void EventHandler::loadState()
{ {
// Do a state save using the System // Do a state save using the System
string md5 = myOSystem.console().properties().get("Cartridge.MD5"); string md5 = myOSystem->console().properties().get("Cartridge.MD5");
string filename = myOSystem.stateFilename(md5, myCurrentState); string filename = myOSystem->stateFilename(md5, myCurrentState);
int result = myOSystem.console().system().loadState(filename, md5); int result = myOSystem->console().system().loadState(filename, md5);
// Print appropriate message // Print appropriate message
ostringstream buf; ostringstream buf;
@ -387,7 +391,7 @@ void EventHandler::loadState()
else if(result == 3) else if(result == 3)
buf << "Invalid state " << myCurrentState << " file"; buf << "Invalid state " << myCurrentState << " file";
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem->frameBuffer().showMessage(buf.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -396,30 +400,30 @@ void EventHandler::takeSnapshot()
#ifdef SNAPSHOT_SUPPORT #ifdef SNAPSHOT_SUPPORT
// Figure out the correct snapshot name // Figure out the correct snapshot name
string filename; string filename;
string sspath = myOSystem.settings().getString("ssdir"); string sspath = myOSystem->settings().getString("ssdir");
string ssname = myOSystem.settings().getString("ssname"); string ssname = myOSystem->settings().getString("ssname");
if(ssname == "romname") if(ssname == "romname")
sspath = sspath + BSPF_PATH_SEPARATOR + sspath = sspath + BSPF_PATH_SEPARATOR +
myOSystem.console().properties().get("Cartridge.Name"); myOSystem->console().properties().get("Cartridge.Name");
else if(ssname == "md5sum") else if(ssname == "md5sum")
sspath = sspath + BSPF_PATH_SEPARATOR + sspath = sspath + BSPF_PATH_SEPARATOR +
myOSystem.console().properties().get("Cartridge.MD5"); myOSystem->console().properties().get("Cartridge.MD5");
// Check whether we want multiple snapshots created // Check whether we want multiple snapshots created
if(!myOSystem.settings().getBool("sssingle")) if(!myOSystem->settings().getBool("sssingle"))
{ {
// Determine if the file already exists, checking each successive filename // Determine if the file already exists, checking each successive filename
// until one doesn't exist // until one doesn't exist
filename = sspath + ".png"; filename = sspath + ".png";
if(myOSystem.fileExists(filename)) if(myOSystem->fileExists(filename))
{ {
ostringstream buf; ostringstream buf;
for(uInt32 i = 1; ;++i) for(uInt32 i = 1; ;++i)
{ {
buf.str(""); buf.str("");
buf << sspath << "_" << i << ".png"; buf << sspath << "_" << i << ".png";
if(!myOSystem.fileExists(buf.str())) if(!myOSystem->fileExists(buf.str()))
break; break;
} }
filename = buf.str(); filename = buf.str();
@ -429,11 +433,11 @@ void EventHandler::takeSnapshot()
filename = sspath + ".png"; filename = sspath + ".png";
// Now create a Snapshot object and save the PNG // Now create a Snapshot object and save the PNG
myOSystem.frameBuffer().refresh(true); myOSystem->frameBuffer().refresh(true);
Snapshot snapshot(myOSystem.frameBuffer()); Snapshot snapshot(myOSystem->frameBuffer());
string result = snapshot.savePNG(filename); string result = snapshot.savePNG(filename);
myOSystem.frameBuffer().showMessage(result); myOSystem->frameBuffer().showMessage(result);
#else #else
myOSystem.frameBuffer().showMessage("Snapshots unsupported"); myOSystem->frameBuffer().showMessage("Snapshots unsupported");
#endif #endif
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventHandler.hxx,v 1.15 2005-02-21 02:23:49 stephena Exp $ // $Id: EventHandler.hxx,v 1.16 2005-02-21 20:42:21 stephena Exp $
//============================================================================ //============================================================================
#ifndef EVENTHANDLER_HXX #ifndef EVENTHANDLER_HXX
@ -40,7 +40,7 @@ class OSystem;
mapping can take place. mapping can take place.
@author Stephen Anthony @author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.15 2005-02-21 02:23:49 stephena Exp $ @version $Id: EventHandler.hxx,v 1.16 2005-02-21 20:42:21 stephena Exp $
*/ */
class EventHandler class EventHandler
{ {
@ -48,7 +48,7 @@ class EventHandler
/** /**
Create a new event handler object Create a new event handler object
*/ */
EventHandler(OSystem& osystem); EventHandler(OSystem* osystem);
/** /**
Destructor Destructor
@ -123,8 +123,8 @@ class EventHandler
void takeSnapshot(); void takeSnapshot();
private: private:
// Global Console object // Global OSystem object
OSystem& myOSystem; OSystem* myOSystem;
// Array of key events // Array of key events
Event::Type myKeyTable[StellaEvent::LastKCODE]; Event::Type myKeyTable[StellaEvent::LastKCODE];

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.cxx,v 1.13 2005-02-21 02:23:49 stephena Exp $ // $Id: FrameBuffer.cxx,v 1.14 2005-02-21 20:42:38 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -47,8 +47,8 @@
#define RIGHTMARKER 16 // Indicates item being remapped #define RIGHTMARKER 16 // Indicates item being remapped
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBuffer::FrameBuffer() FrameBuffer::FrameBuffer(OSystem* osystem)
: myOSystem(0), : myOSystem(osystem),
myWidth(0), myWidth(0),
myHeight(0), myHeight(0),
theRedrawEntireFrameIndicator(true), theRedrawEntireFrameIndicator(true),
@ -81,6 +81,7 @@ FrameBuffer::FrameBuffer()
myMenuRedraws(2), myMenuRedraws(2),
myInfoMenuWidth(0) myInfoMenuWidth(0)
{ {
myOSystem->attach(this);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -89,10 +90,8 @@ FrameBuffer::~FrameBuffer(void)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::initialize(OSystem* osystem, const string title, void FrameBuffer::initialize(const string title, uInt32 width, uInt32 height)
uInt32 width, uInt32 height)
{ {
myOSystem = osystem;
myWidth = width; myWidth = width;
myHeight = height; myHeight = height;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.hxx,v 1.14 2005-02-21 02:23:49 stephena Exp $ // $Id: FrameBuffer.hxx,v 1.15 2005-02-21 20:43:10 stephena Exp $
//============================================================================ //============================================================================
#ifndef FRAMEBUFFER_HXX #ifndef FRAMEBUFFER_HXX
@ -39,7 +39,7 @@ FIXME This class also implements a MAME-like user interface where Stella settin
can be changed. can be changed.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.14 2005-02-21 02:23:49 stephena Exp $ @version $Id: FrameBuffer.hxx,v 1.15 2005-02-21 20:43:10 stephena Exp $
*/ */
class FrameBuffer class FrameBuffer
{ {
@ -47,7 +47,7 @@ class FrameBuffer
/** /**
Creates a new Frame Buffer Creates a new Frame Buffer
*/ */
FrameBuffer(); FrameBuffer(OSystem* osystem);
/** /**
Destructor Destructor
@ -58,12 +58,11 @@ class FrameBuffer
Initializes the framebuffer display. This must be called before any Initializes the framebuffer display. This must be called before any
calls are made to derived methods. calls are made to derived methods.
@param osystem The parent osystem
@param title The title of the window @param title The title of the window
@param width The width of the framebuffer @param width The width of the framebuffer
@param height The height of the framebuffer @param height The height of the framebuffer
*/ */
void initialize(OSystem* osystem, const string title, uInt32 width, uInt32 height); void initialize(const string title, uInt32 width, uInt32 height);
/** /**
Updates the display, which depending on the current mode could mean Updates the display, which depending on the current mode could mean

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystem.cxx,v 1.1 2005-02-21 02:23:49 stephena Exp $ // $Id: OSystem.cxx,v 1.2 2005-02-21 20:43:20 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -29,15 +29,8 @@
#include "OSystem.hxx" #include "OSystem.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystem::OSystem(FrameBuffer& framebuffer, Sound& sound, OSystem::OSystem()
Settings& settings, PropertiesSet& propset)
: myFrameBuffer(framebuffer),
mySound(sound),
mySettings(settings),
myPropSet(propset)
{ {
// Create an event handler which will collect and dispatch events
myEventHandler = new EventHandler(*this);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -53,10 +46,6 @@ void OSystem::update()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystem::OSystem(const OSystem& osystem) OSystem::OSystem(const OSystem& osystem)
: myFrameBuffer(osystem.myFrameBuffer),
mySound(osystem.mySound),
mySettings(osystem.mySettings),
myPropSet(osystem.myPropSet)
{ {
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystem.hxx,v 1.1 2005-02-21 02:23:49 stephena Exp $ // $Id: OSystem.hxx,v 1.2 2005-02-21 20:43:20 stephena Exp $
//============================================================================ //============================================================================
#ifndef OSYSTEM_HXX #ifndef OSYSTEM_HXX
@ -35,7 +35,7 @@ class PropertiesSet;
other objects belong. other objects belong.
@author Stephen Anthony @author Stephen Anthony
@version $Id: OSystem.hxx,v 1.1 2005-02-21 02:23:49 stephena Exp $ @version $Id: OSystem.hxx,v 1.2 2005-02-21 20:43:20 stephena Exp $
*/ */
class OSystem class OSystem
{ {
@ -43,8 +43,7 @@ class OSystem
/** /**
Create a new OSystem abstract class Create a new OSystem abstract class
*/ */
OSystem(FrameBuffer& framebuffer, Sound& sound, OSystem();
Settings& settings, PropertiesSet& propset);
/** /**
Destructor Destructor
@ -58,24 +57,52 @@ class OSystem
*/ */
void update(); void update();
/**
Adds the specified eventhandler to the system.
@param eventhandler The eventhandler to add
*/
void attach(EventHandler* eventhandler) { myEventHandler = eventhandler; }
/**
Adds the specified framebuffer to the system.
@param framebuffer The framebuffer to add
*/
void attach(FrameBuffer* framebuffer) { myFrameBuffer = framebuffer; }
/**
Adds the specified sound device to the system.
@param sound The sound device to add
*/
void attach(Sound* sound) { mySound = sound; }
/**
Adds the specified settings object to the system.
@param settings The settings object to add
*/
void attach(Settings* settings) { mySettings = settings; }
/**
Adds the specified game properties set to the system.
@param propset The properties set to add
*/
void attach(PropertiesSet* propset) { myPropSet = propset; }
/** /**
Adds the specified console to the system. Adds the specified console to the system.
@param console The console (game emulation object) to add @param console The console (game emulation object) to add
*/ */
void addConsole(Console* console) { myConsole = console; } void attach(Console* console) { myConsole = console; }
/** /**
Removes the currently attached console from the system. Removes the currently attached console from the system.
*/ */
void removeConsole(void) { delete myConsole; myConsole = NULL; } void detachConsole(void) { delete myConsole; myConsole = NULL; }
/**
Get the console of the system.
@return The console object
*/
Console& console(void) const { return *myConsole; }
/** /**
Get the event handler of the system Get the event handler of the system
@ -89,35 +116,41 @@ class OSystem
@return The frame buffer @return The frame buffer
*/ */
FrameBuffer& frameBuffer() const { return myFrameBuffer; } FrameBuffer& frameBuffer() const { return *myFrameBuffer; }
/** /**
Get the sound object of the system Get the sound object of the system
@return The sound object @return The sound object
*/ */
Sound& sound() const { return mySound; } Sound& sound() const { return *mySound; }
/** /**
Get the settings object of the system Get the settings object of the system
@return The settings object @return The settings object
*/ */
Settings& settings() const { return mySettings; } Settings& settings() const { return *mySettings; }
/** /**
Get the set of game properties for the system Get the set of game properties for the system
@return The properties set object @return The properties set object
*/ */
PropertiesSet& propSet() const { return myPropSet; } PropertiesSet& propSet() const { return *myPropSet; }
/**
Get the console of the system.
@return The console object
*/
Console& console(void) const { return *myConsole; }
public: public:
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// The following methods are system-specific and must be implemented // The following methods are system-specific and must be implemented
// in derived classes. // in derived classes.
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
/** /**
This method should be called to get the filename of a state file This method should be called to get the filename of a state file
given the state number. given the state number.
@ -142,17 +175,17 @@ class OSystem
// Pointer to the EventHandler object // Pointer to the EventHandler object
EventHandler* myEventHandler; EventHandler* myEventHandler;
// Reference to the FrameBuffer object // Pointer to the FrameBuffer object
FrameBuffer& myFrameBuffer; FrameBuffer* myFrameBuffer;
// Reference to the Sound object // Pointer to the Sound object
Sound& mySound; Sound* mySound;
// Reference to the Settings object // Pointer to the Settings object
Settings& mySettings; Settings* mySettings;
// Reference to the PropertiesSet object // Pointer to the PropertiesSet object
PropertiesSet& myPropSet; PropertiesSet* myPropSet;
// Pointer to the (currently defined) Console object // Pointer to the (currently defined) Console object
Console* myConsole; Console* myConsole;

View File

@ -13,19 +13,25 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Settings.cxx,v 1.31 2005-02-21 02:23:57 stephena Exp $ // $Id: Settings.cxx,v 1.32 2005-02-21 20:43:20 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
#include "OSystem.hxx"
#include "bspf.hxx" #include "bspf.hxx"
#include "Settings.hxx" #include "Settings.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Settings::Settings() Settings::Settings(OSystem* osystem)
: myOSystem(osystem)
{ {
// Add this settings object to the OSystem
myOSystem->attach(this);
// First create the settings array // First create the settings array
myCapacity = 30; myCapacity = 30;
mySettings = new Setting[myCapacity]; mySettings = new Setting[myCapacity];

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Settings.hxx,v 1.19 2005-02-21 02:23:57 stephena Exp $ // $Id: Settings.hxx,v 1.20 2005-02-21 20:43:21 stephena Exp $
//============================================================================ //============================================================================
#ifndef SETTINGS_HXX #ifndef SETTINGS_HXX
@ -28,7 +28,7 @@ class OSystem;
This class provides an interface for accessing frontend specific settings. This class provides an interface for accessing frontend specific settings.
@author Stephen Anthony @author Stephen Anthony
@version $Id: Settings.hxx,v 1.19 2005-02-21 02:23:57 stephena Exp $ @version $Id: Settings.hxx,v 1.20 2005-02-21 20:43:21 stephena Exp $
*/ */
class Settings class Settings
{ {
@ -36,7 +36,7 @@ class Settings
/** /**
Create a new settings abstract class Create a new settings abstract class
*/ */
Settings(); Settings(OSystem* osystem);
/** /**
Destructor Destructor

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIA.cxx,v 1.36 2005-02-21 02:23:57 stephena Exp $ // $Id: TIA.cxx,v 1.37 2005-02-21 20:43:22 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -30,15 +30,14 @@
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include "Settings.hxx" #include "Settings.hxx"
#include "Sound.hxx" #include "Sound.hxx"
#include "OSystem.hxx"
#define HBLANK 68 #define HBLANK 68
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TIA::TIA(OSystem& osystem) TIA::TIA(const Console& console, Sound& sound, Settings& settings)
: myOSystem(osystem), : myConsole(console),
myConsole(osystem.console()), mySound(sound),
mySound(osystem.sound()), mySettings(settings),
myColorLossEnabled(false), myColorLossEnabled(false),
myMaximumNumberOfScanlines(262), myMaximumNumberOfScanlines(262),
myCOLUBK(myColor[0]), myCOLUBK(myColor[0]),
@ -266,6 +265,7 @@ void TIA::install(System& system)
uInt16 shift = mySystem->pageShift(); uInt16 shift = mySystem->pageShift();
mySystem->resetCycles(); mySystem->resetCycles();
cerr << "TIA::install()\n";
// All accesses are to this device // All accesses are to this device
@ -282,6 +282,7 @@ void TIA::install(System& system)
mySystem->setPageAccess(i >> shift, access); mySystem->setPageAccess(i >> shift, access);
} }
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -535,7 +536,7 @@ void TIA::update()
const uInt32* TIA::palette() const const uInt32* TIA::palette() const
{ {
// See which palette we should be using // See which palette we should be using
string type = myOSystem.settings().getString("palette"); string type = mySettings.getString("palette");
string format = myConsole.properties().get("Display.Format"); string format = myConsole.properties().get("Display.Format");
if(type == "standard") if(type == "standard")
@ -3272,9 +3273,9 @@ const uInt32 TIA::ourPALPaletteZ26[256] = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TIA::TIA(const TIA& c) TIA::TIA(const TIA& c)
: myOSystem(c.myOSystem), : myConsole(c.myConsole),
myConsole(c.myConsole),
mySound(c.mySound), mySound(c.mySound),
mySettings(c.mySettings),
myCOLUBK(myColor[0]), myCOLUBK(myColor[0]),
myCOLUPF(myColor[1]), myCOLUPF(myColor[1]),
myCOLUP0(myColor[2]), myCOLUP0(myColor[2]),

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIA.hxx,v 1.15 2005-02-21 02:23:57 stephena Exp $ // $Id: TIA.hxx,v 1.16 2005-02-21 20:43:25 stephena Exp $
//============================================================================ //============================================================================
#ifndef TIA_HXX #ifndef TIA_HXX
@ -24,7 +24,7 @@ class Sound;
class System; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
class OSystem; class Settings;
#include "bspf.hxx" #include "bspf.hxx"
#include "Device.hxx" #include "Device.hxx"
@ -42,7 +42,7 @@ class OSystem;
be displayed on screen. be displayed on screen.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: TIA.hxx,v 1.15 2005-02-21 02:23:57 stephena Exp $ @version $Id: TIA.hxx,v 1.16 2005-02-21 20:43:25 stephena Exp $
*/ */
class TIA : public Device , public MediaSource class TIA : public Device , public MediaSource
{ {
@ -52,8 +52,9 @@ class TIA : public Device , public MediaSource
@param console The console the TIA is associated with @param console The console the TIA is associated with
@param sound The sound object the TIA is associated with @param sound The sound object the TIA is associated with
@param settings The settings object the TIA is associated with
*/ */
TIA(OSystem& osystem); TIA(const Console& console, Sound& sound, Settings& settings);
/** /**
Destructor Destructor
@ -203,15 +204,15 @@ class TIA : public Device , public MediaSource
void waitHorizontalSync(); void waitHorizontalSync();
private: private:
// OSsystem the TIA is associated with
const OSystem& myOSystem;
// Console the TIA is associated with // Console the TIA is associated with
const Console& myConsole; const Console& myConsole;
// Sound object the TIA is associated with // Sound object the TIA is associated with
Sound& mySound; Sound& mySound;
// Settings object the TIA is associated with
Settings& mySettings;
private: private:
// Indicates if color loss should be enabled or disabled. Color loss // Indicates if color loss should be enabled or disabled. Color loss
// occurs on PAL (and maybe SECAM) systems when the previous frame // occurs on PAL (and maybe SECAM) systems when the previous frame

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: System.cxx,v 1.4 2002-08-11 17:48:13 stephena Exp $ // $Id: System.cxx,v 1.5 2005-02-21 20:43:28 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <assert.h>
@ -101,6 +101,7 @@ void System::reset()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void System::attach(Device* device) void System::attach(Device* device)
{ {
cerr << "System::attach()\n";
assert(myNumberOfDevices < 100); assert(myNumberOfDevices < 100);
// Add device to my collection of devices // Add device to my collection of devices

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystemUNIX.cxx,v 1.1 2005-02-21 02:23:57 stephena Exp $ // $Id: OSystemUNIX.cxx,v 1.2 2005-02-21 20:43:47 stephena Exp $
//============================================================================ //============================================================================
#include <cstdlib> #include <cstdlib>
@ -29,9 +29,7 @@
#include "OSystemUNIX.hxx" #include "OSystemUNIX.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemUNIX::OSystemUNIX(FrameBuffer& framebuffer, Sound& sound, OSystemUNIX::OSystemUNIX()
Settings& settings, PropertiesSet& propset)
: OSystem(framebuffer, sound, settings, propset)
{ {
} }

View File

@ -13,17 +13,12 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystemUNIX.hxx,v 1.1 2005-02-21 02:23:57 stephena Exp $ // $Id: OSystemUNIX.hxx,v 1.2 2005-02-21 20:43:53 stephena Exp $
//============================================================================ //============================================================================
#ifndef OSYSTEM_UNIX_HXX #ifndef OSYSTEM_UNIX_HXX
#define OSYSTEM_UNIX_HXX #define OSYSTEM_UNIX_HXX
class FrameBuffer;
class Sound;
class Settings;
class PropertiesSet;
#include "bspf.hxx" #include "bspf.hxx"
@ -31,7 +26,7 @@ class PropertiesSet;
This class defines UNIX-like OS's (Linux) system specific settings. This class defines UNIX-like OS's (Linux) system specific settings.
@author Stephen Anthony @author Stephen Anthony
@version $Id: OSystemUNIX.hxx,v 1.1 2005-02-21 02:23:57 stephena Exp $ @version $Id: OSystemUNIX.hxx,v 1.2 2005-02-21 20:43:53 stephena Exp $
*/ */
class OSystemUNIX : public OSystem class OSystemUNIX : public OSystem
{ {
@ -39,8 +34,7 @@ class OSystemUNIX : public OSystem
/** /**
Create a new UNIX-specific operating system object Create a new UNIX-specific operating system object
*/ */
OSystemUNIX(FrameBuffer& framebuffer, Sound& sound, OSystemUNIX();
Settings& settings, PropertiesSet& propset);
/** /**
Destructor Destructor

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: SettingsUNIX.cxx,v 1.8 2005-02-21 02:23:57 stephena Exp $ // $Id: SettingsUNIX.cxx,v 1.9 2005-02-21 20:43:53 stephena Exp $
//============================================================================ //============================================================================
#include <cstdlib> #include <cstdlib>
@ -30,7 +30,8 @@
#include "SettingsUNIX.hxx" #include "SettingsUNIX.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SettingsUNIX::SettingsUNIX() SettingsUNIX::SettingsUNIX(OSystem* osystem)
: Settings(osystem)
{ {
// First set variables that the parent class needs // First set variables that the parent class needs
myBaseDir = getenv("HOME"); myBaseDir = getenv("HOME");

View File

@ -13,19 +13,21 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: SettingsUNIX.hxx,v 1.4 2005-02-21 02:23:57 stephena Exp $ // $Id: SettingsUNIX.hxx,v 1.5 2005-02-21 20:43:53 stephena Exp $
//============================================================================ //============================================================================
#ifndef SETTINGS_UNIX_HXX #ifndef SETTINGS_UNIX_HXX
#define SETTINGS_UNIX_HXX #define SETTINGS_UNIX_HXX
class OSystem;
#include "bspf.hxx" #include "bspf.hxx"
/** /**
This class defines UNIX-like OS's (Linux) system specific settings. This class defines UNIX-like OS's (Linux) system specific settings.
@author Stephen Anthony @author Stephen Anthony
@version $Id: SettingsUNIX.hxx,v 1.4 2005-02-21 02:23:57 stephena Exp $ @version $Id: SettingsUNIX.hxx,v 1.5 2005-02-21 20:43:53 stephena Exp $
*/ */
class SettingsUNIX : public Settings class SettingsUNIX : public Settings
{ {
@ -33,7 +35,7 @@ class SettingsUNIX : public Settings
/** /**
Create a new UNIX settings object Create a new UNIX settings object
*/ */
SettingsUNIX(); SettingsUNIX(OSystem* osystem);
/** /**
Destructor Destructor