Made all statefiles be named according to their romname as given in

the properties file (instead of using md5sum).  The md5sum naming
is no longer needed, and made it very difficult for users to
distribute the state files.

Similar to above, removed ability to name snapshots according to
md5sum, and instead use romname.  Consequently, removed all
references to 'ssname' commandline argument and GUI related
config options.

Added ability to specify a different 'base directory' for settings,
state files, etc.  Normally, this is chosen at compile time, and is
set to $HOME/.stella/ for Linux and OSX, and the current dir for Win32.
Now, if you set the 'STELLA_BASEDIR' environment variable, it will
use that path instead.  Note that this must be set every time Stella
is run, since there's no way to save it to a settings file (since
the settings file location is dependent on what the env var contains).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1147 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-11-13 00:21:41 +00:00
parent 8757c935c2
commit 76eb15a8be
17 changed files with 76 additions and 98 deletions

View File

@ -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: mainSDL.cxx,v 1.66 2006-10-22 18:58:45 stephena Exp $
// $Id: mainSDL.cxx,v 1.67 2006-11-13 00:21:40 stephena Exp $
//============================================================================
#include <SDL.h>
@ -85,23 +85,29 @@ int SDL_main(int argc, char* argv[])
int main(int argc, char* argv[])
#endif
{
// Get the base directory for storing all Stella settings/statefiles/etc
// This can't be stored in the actual settings file for obvious reasons,
// so we get it from an environment var (if it exists)
const char* bd_ptr = SDL_getenv("STELLA_BASEDIR");
const string& basedir = bd_ptr ? string(bd_ptr) : "";
// Create the parent OSystem object and settings
#if defined(UNIX)
theOSystem = new OSystemUNIX();
theOSystem = new OSystemUNIX(basedir);
SettingsUNIX settings(theOSystem);
#elif defined(WIN32)
theOSystem = new OSystemWin32();
theOSystem = new OSystemWin32(basedir);
SettingsWin32 settings(theOSystem);
#elif defined(MAC_OSX)
theOSystem = new OSystemMACOSX();
theOSystem = new OSystemMACOSX(basedir);
SettingsMACOSX settings(theOSystem);
#elif defined(GP2X)
theOSystem = new OSystemGP2X();
theOSystem = new OSystemGP2X(basedir);
SettingsGP2X settings(theOSystem);
#elif defined(PSP)
fprintf(stderr,"---------------- Stderr Begins ----------------\n");
fprintf(stdout,"---------------- Stdout Begins ----------------\n");
theOSystem = new OSystemPSP();
theOSystem = new OSystemPSP(basedir);
SettingsPSP settings(theOSystem);
#else
#error Unsupported platform!
@ -136,7 +142,7 @@ int main(int argc, char* argv[])
// Request that the SDL window be centered, if possible
// At some point, this should be properly integrated into the UI
if(theOSystem->settings().getBool("center"))
putenv("SDL_VIDEO_CENTERED=1");
SDL_putenv("SDL_VIDEO_CENTERED=1");
//// Main loop ////
// First we check if a ROM is specified on the commandline. If so, and if
@ -162,7 +168,7 @@ int main(int argc, char* argv[])
// Set up any breakpoint that was on the command line
// (and remove the key from the settings, so they won't get set again)
string initBreak = theOSystem->settings().getString("break");
const string& initBreak = theOSystem->settings().getString("break");
if(initBreak != "")
{
int bp = dbg.stringToValue(initBreak);

View File

@ -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: EventHandler.cxx,v 1.169 2006-11-10 06:14:14 stephena Exp $
// $Id: EventHandler.cxx,v 1.170 2006-11-13 00:21:40 stephena Exp $
//============================================================================
#include <sstream>
@ -2033,9 +2033,12 @@ inline bool EventHandler::isJitter(int paddle, int value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::saveState()
{
string md5 = myOSystem->console().properties().get(Cartridge_MD5);
const string& name = myOSystem->console().properties().get(Cartridge_Name);
const string& md5 = myOSystem->console().properties().get(Cartridge_MD5);
ostringstream buf;
buf << myOSystem->stateDir() << BSPF_PATH_SEPARATOR << md5 << ".st" << myLSState;
buf << myOSystem->stateDir() << BSPF_PATH_SEPARATOR
<< name << ".st" << myLSState;
// Make sure the file can be opened for writing
Serializer out;
@ -2052,8 +2055,8 @@ void EventHandler::saveState()
buf << "State " << myLSState << " saved";
if(myOSystem->settings().getBool("autoslot"))
{
buf << ", switching to slot " << (myLSState+1) % 10;
changeState(false); // don't show a message for state change
buf << ", switching to slot " << myLSState;
}
}
else
@ -2087,9 +2090,12 @@ void EventHandler::changeState(bool show)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::loadState()
{
string md5 = myOSystem->console().properties().get(Cartridge_MD5);
const string& name = myOSystem->console().properties().get(Cartridge_Name);
const string& md5 = myOSystem->console().properties().get(Cartridge_MD5);
ostringstream buf;
buf << myOSystem->stateDir() << BSPF_PATH_SEPARATOR << md5 << ".st" << myLSState;
buf << myOSystem->stateDir() << BSPF_PATH_SEPARATOR
<< name << ".st" << myLSState;
// Make sure the file can be opened for reading
Deserializer in;
@ -2126,16 +2132,11 @@ void EventHandler::takeSnapshot()
// Figure out the correct snapshot name
string filename;
string sspath = myOSystem->settings().getString("ssdir");
string ssname = myOSystem->settings().getString("ssname");
if(sspath.length() > 0)
if(sspath.substr(sspath.length()-1) != BSPF_PATH_SEPARATOR)
sspath += BSPF_PATH_SEPARATOR;
if(ssname == "romname")
sspath += myOSystem->console().properties().get(Cartridge_Name);
else if(ssname == "md5sum")
sspath += myOSystem->console().properties().get(Cartridge_MD5);
sspath += myOSystem->console().properties().get(Cartridge_Name);
// Check whether we want multiple snapshots created
if(!myOSystem->settings().getBool("sssingle"))

View File

@ -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.89 2006-11-08 00:09:53 stephena Exp $
// $Id: Settings.cxx,v 1.90 2006-11-13 00:21:41 stephena Exp $
//============================================================================
#include <cassert>
@ -73,7 +73,6 @@ Settings::Settings(OSystem* osystem)
setInternal("showinfo", "false");
setInternal("ssdir", "");
setInternal("ssname", "romname");
setInternal("sssingle", "false");
setInternal("romdir", "");
@ -266,10 +265,6 @@ void Settings::validate()
s = getString("palette");
if(s != "standard" && s != "original" && s != "z26")
setInternal("palette", "standard");
s = getString("ssname");
if(s != "romname" && s != "md5sum")
setInternal("ssname", "romname");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -333,7 +328,6 @@ void Settings::usage()
#endif
#ifdef SNAPSHOT_SUPPORT
<< " -ssdir <path> The directory to save snapshot files to\n"
<< " -ssname <name> How to name the snapshot (romname or md5sum)\n"
<< " -sssingle <1|0> Generate single snapshot instead of many\n"
<< endl
#endif

View File

@ -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: OSystemGP2X.cxx,v 1.10 2006-09-17 21:44:22 azaballa Exp $
// $Id: OSystemGP2X.cxx,v 1.11 2006-11-13 00:21:41 stephena Exp $
// Modified on 2006/01/06 by Alex Zaballa for use on GP2X
//============================================================================
@ -48,7 +48,7 @@
*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemGP2X::OSystemGP2X()
OSystemGP2X::OSystemGP2X(const string& path) : OSystem()
{
// GP2X needs all config files in exec directory

View File

@ -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: OSystemGP2X.hxx,v 1.6 2006-03-02 13:10:53 stephena Exp $
// $Id: OSystemGP2X.hxx,v 1.7 2006-11-13 00:21:41 stephena Exp $
// Modified by Alex Zaballa on 2006/01/04 for use on GP2X
//============================================================================
@ -32,7 +32,7 @@ class OSystemGP2X : public OSystem
/**
Create a new GP2X-specific operating system object
*/
OSystemGP2X();
OSystemGP2X(const string& path);
/**
Destructor

View File

@ -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: LauncherOptionsDialog.cxx,v 1.17 2006-05-04 17:45:25 stephena Exp $
// $Id: LauncherOptionsDialog.cxx,v 1.18 2006-11-13 00:21:41 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -97,19 +97,8 @@ LauncherOptionsDialog::LauncherOptionsDialog(
_w - xpos - 10, font.getLineHeight(),
"", kTextAlignLeft);
// Snapshot save name
xpos = 10; ypos += mySnapPath->getHeight() + 8;
mySnapTypePopup = new PopUpWidget(myTab, font, xpos, ypos,
font.getStringWidth("romname"),
font.getLineHeight(),
"Save snapshot as: ",
font.getStringWidth("Save snapshot as: "), 0);
mySnapTypePopup->appendEntry("romname", 1);
mySnapTypePopup->appendEntry("md5sum", 2);
wid.push_back(mySnapTypePopup);
// Snapshot single or multiple saves
xpos = 30; ypos += mySnapTypePopup->getHeight() + 5;
xpos = 30; ypos += mySnapPath->getHeight() + 8;
mySnapSingleCheckbox = new CheckboxWidget(myTab, font, xpos, ypos,
"Multiple snapshots");
wid.push_back(mySnapSingleCheckbox);
@ -168,14 +157,6 @@ void LauncherOptionsDialog::loadConfig()
s = instance()->settings().getString("ssdir");
mySnapPath->setLabel(s);
s = instance()->settings().getString("ssname");
if(s == "romname")
mySnapTypePopup->setSelectedTag(1);
else if(s == "md5sum")
mySnapTypePopup->setSelectedTag(2);
else
mySnapTypePopup->setSelectedTag(0);
b = instance()->settings().getBool("sssingle");
mySnapSingleCheckbox->setState(!b);
@ -197,9 +178,6 @@ void LauncherOptionsDialog::saveConfig()
s = mySnapPath->getLabel();
instance()->settings().setString("ssdir", s);
s = mySnapTypePopup->getSelectedString();
instance()->settings().setString("ssname", s);
b = mySnapSingleCheckbox->getState();
instance()->settings().setBool("sssingle", !b);

View File

@ -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: LauncherOptionsDialog.hxx,v 1.10 2006-03-19 20:57:55 stephena Exp $
// $Id: LauncherOptionsDialog.hxx,v 1.11 2006-11-13 00:21:41 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -47,7 +47,17 @@ class LauncherOptionsDialog : public Dialog, public CommandSender
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
protected:
private:
void openRomBrowser();
void openSnapBrowser();
private:
enum {
kChooseRomDirCmd = 'LOrm', // rom select
kChooseSnapDirCmd = 'LOsn', // snap select
kBrowseDirCmd = 'LObd' // browse mode
};
BrowserDialog* myBrowser;
TabWidget* myTab;
@ -58,18 +68,7 @@ class LauncherOptionsDialog : public Dialog, public CommandSender
// Snapshot controls
StaticTextWidget* mySnapPath;
PopUpWidget* mySnapTypePopup;
CheckboxWidget* mySnapSingleCheckbox;
private:
enum {
kChooseRomDirCmd = 'LOrm', // rom select
kChooseSnapDirCmd = 'LOsn', // snap select
kBrowseDirCmd = 'LObd' // browse mode
};
void openRomBrowser();
void openSnapBrowser();
};
#endif

View File

@ -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: OSystemMACOSX.cxx,v 1.11 2006-04-05 02:18:58 markgrebe Exp $
// $Id: OSystemMACOSX.cxx,v 1.12 2006-11-13 00:21:41 stephena Exp $
//============================================================================
#include <cstdlib>
@ -93,10 +93,10 @@ void macOSXSendMenuEvent(int event)
*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemMACOSX::OSystemMACOSX()
OSystemMACOSX::OSystemMACOSX(const string& path) : OSystem()
{
// First set variables that the OSystem needs
string basedir = string(getenv("HOME")) + "/.stella";
const string& basedir = (path.length() > 0) ? path :
string(getenv("HOME")) + "/.stella";
setBaseDir(basedir);
setStateDir(basedir + "/state");

View File

@ -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: OSystemMACOSX.hxx,v 1.4 2006-03-27 16:00:37 stephena Exp $
// $Id: OSystemMACOSX.hxx,v 1.5 2006-11-13 00:21:41 stephena Exp $
//============================================================================
#ifndef OSYSTEM_MACOSX_HXX
@ -26,7 +26,7 @@
This class defines UNIX-like OS's (Linux) system specific settings.
@author Mark Grebe
@version $Id: OSystemMACOSX.hxx,v 1.4 2006-03-27 16:00:37 stephena Exp $
@version $Id: OSystemMACOSX.hxx,v 1.5 2006-11-13 00:21:41 stephena Exp $
*/
class OSystemMACOSX : public OSystem
{
@ -34,7 +34,7 @@ class OSystemMACOSX : public OSystem
/**
Create a new UNIX-specific operating system object
*/
OSystemMACOSX();
OSystemMACOSX(const string& path);
/**
Destructor

View File

@ -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: OSystemPSP.cxx,v 1.5 2006-01-08 02:28:04 stephena Exp $
// $Id: OSystemPSP.cxx,v 1.6 2006-11-13 00:21:41 stephena Exp $
//============================================================================
#include <cstdlib>
@ -55,7 +55,7 @@
*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemPSP::OSystemPSP()
OSystemPSP::OSystemPSP(const string& path) : OSystem()
{
// First set variables that the OSystem needs
string basedir = string("ms0:/stella");

View File

@ -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: OSystemPSP.hxx,v 1.4 2006-03-02 13:10:53 stephena Exp $
// $Id: OSystemPSP.hxx,v 1.5 2006-11-13 00:21:41 stephena Exp $
//============================================================================
#ifndef OSYSTEM_PSP_HXX
@ -26,7 +26,7 @@
This class defines PSP-specific settings.
@author Stephen Anthony
@version $Id: OSystemPSP.hxx,v 1.4 2006-03-02 13:10:53 stephena Exp $
@version $Id: OSystemPSP.hxx,v 1.5 2006-11-13 00:21:41 stephena Exp $
*/
class OSystemPSP : public OSystem
{
@ -34,7 +34,7 @@ class OSystemPSP : public OSystem
/**
Create a new PSP-specific operating system object
*/
OSystemPSP();
OSystemPSP(const string& path);
/**
Destructor

View File

@ -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: OSystemUNIX.cxx,v 1.20 2006-03-25 00:34:17 stephena Exp $
// $Id: OSystemUNIX.cxx,v 1.21 2006-11-13 00:21:41 stephena Exp $
//============================================================================
#include <SDL.h>
@ -50,10 +50,10 @@
*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemUNIX::OSystemUNIX()
OSystemUNIX::OSystemUNIX(const string& path) : OSystem()
{
// First set variables that the OSystem needs
string basedir = string(getenv("HOME")) + "/.stella";
const string& basedir = (path.length() > 0) ? path :
string(getenv("HOME")) + "/.stella";
setBaseDir(basedir);
setStateDir(basedir + "/state");

View File

@ -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: OSystemUNIX.hxx,v 1.10 2006-01-31 17:26:56 stephena Exp $
// $Id: OSystemUNIX.hxx,v 1.11 2006-11-13 00:21:41 stephena Exp $
//============================================================================
#ifndef OSYSTEM_UNIX_HXX
@ -26,7 +26,7 @@
This class defines UNIX-like OS's (Linux) system specific settings.
@author Stephen Anthony
@version $Id: OSystemUNIX.hxx,v 1.10 2006-01-31 17:26:56 stephena Exp $
@version $Id: OSystemUNIX.hxx,v 1.11 2006-11-13 00:21:41 stephena Exp $
*/
class OSystemUNIX : public OSystem
{
@ -34,7 +34,7 @@ class OSystemUNIX : public OSystem
/**
Create a new UNIX-specific operating system object
*/
OSystemUNIX();
OSystemUNIX(const string& path);
/**
Destructor

View File

@ -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: OSystemWin32.cxx,v 1.12 2006-03-17 19:44:19 stephena Exp $
// $Id: OSystemWin32.cxx,v 1.13 2006-11-13 00:21:41 stephena Exp $
//============================================================================
#include <sstream>
@ -38,23 +38,23 @@
*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemWin32::OSystemWin32()
OSystemWin32::OSystemWin32(const string& path) : OSystem()
{
// TODO - there really should be code here to determine which version
// of Windows is being used.
// If using a version which supports multiple users (NT and above),
// the relevant directories should be created in per-user locations.
// For now, we just put it in the same directory as the executable.
const string& basedir = (path.length() > 0) ? path : ".";
string basedir = ".\\";
setBaseDir(basedir);
setStateDir(basedir + "state\\");
setStateDir(basedir + "\\state\\");
setPropertiesDir(basedir);
setConfigFile(basedir + "stella.ini");
setConfigFile(basedir + "\\stella.ini");
setCacheFile(basedir + "stella.cache");
setCacheFile(basedir + "\\stella.cache");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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: OSystemWin32.hxx,v 1.5 2006-01-08 02:28:04 stephena Exp $
// $Id: OSystemWin32.hxx,v 1.6 2006-11-13 00:21:41 stephena Exp $
//============================================================================
#ifndef OSYSTEM_WIN32_HXX
@ -25,7 +25,7 @@
This class defines Windows system specific settings.
@author Stephen Anthony
@version $Id: OSystemWin32.hxx,v 1.5 2006-01-08 02:28:04 stephena Exp $
@version $Id: OSystemWin32.hxx,v 1.6 2006-11-13 00:21:41 stephena Exp $
*/
class OSystemWin32 : public OSystem
{
@ -33,7 +33,7 @@ class OSystemWin32 : public OSystem
/**
Create a new Win32 operating system object
*/
OSystemWin32();
OSystemWin32(const string& path);
/**
Destructor

View File

@ -31,7 +31,7 @@ extern void KeySetMode(int);
extern bool RequestRefresh;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemWinCE::OSystemWinCE()
OSystemWinCE::OSystemWinCE(const string& path) : OSystem()
{
string basedir = ((string) getcwd()) + '\\';
setBaseDir(basedir);

View File

@ -25,7 +25,7 @@
class OSystemWinCE : public OSystem
{
public:
OSystemWinCE();
OSystemWinCE(const string& path);
virtual ~OSystemWinCE();
public: