Made LauncherDialog look for a system-specific gamelist cache file.

Modified the framerate argument, in that it can only be changed from the
integrated GUI, and only for the current game.  The framerate is now
properly set when starting a new game, or when switching between NTSC/PAL
mode, and is based on the ROM format.  The ability to change the framerate
may disappear entirely before the next release (I see no real need for it
anymore).

Some minor code cleanups.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@419 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-05-11 19:36:00 +00:00
parent ee742cb0a3
commit 468f680725
11 changed files with 109 additions and 64 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: SoundSDL.cxx,v 1.14 2005-05-01 18:57:20 stephena Exp $
// $Id: SoundSDL.cxx,v 1.15 2005-05-11 19:35:59 stephena Exp $
//============================================================================
#include <sstream>
@ -250,6 +250,8 @@ void SoundSDL::set(uInt16 addr, uInt8 value, Int32 cycle)
(1193191.66666667));
// Now, adjust the time based on the frame rate the user has selected
// FIXME - not sure this is needed anymore, since the display framerate
// and sound framerate are always locked in sync; hence 1:1
delta = delta * (myDisplayFrameRate / 60.0);//FIXME (double)myOSystem->console().frameRate());
RegWrite info;

View File

@ -0,0 +1,24 @@
//============================================================================
//
// 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-2005 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: Version.hxx,v 1.1 2005-05-11 19:36:00 stephena Exp $
//============================================================================
#ifndef VERSION_HXX
#define VERSION_HXX
#define STELLA_VERSION "2.0_alpha"
#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: Console.cxx,v 1.51 2005-05-06 22:50:14 stephena Exp $
// $Id: Console.cxx,v 1.52 2005-05-11 19:36:00 stephena Exp $
//============================================================================
#include <assert.h>
@ -156,29 +156,32 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
mySystem->reset();
// Set the correct framerate based on the format of the ROM
// This can be overridden by the '-framerate' option
// This can be overridden by changing the framerate in the
// VideoDialog box, but it can't be saved (ie, framerate is now
// solely determined based on ROM format).
myFrameRate = 60;
if(myOSystem->settings().getInt("framerate") > 0)
myFrameRate = myOSystem->settings().getInt("framerate");
// else if(myProperties.get("Display.Format") == "NTSC")
// myFrameRate = 60;
// else if(myProperties.get("Display.Format") == "PAL")
// myFrameRate = 50;
// mySettings.setInt("framerate", myFrameRate, false);
myOSystem->settings().setInt("framerate", myFrameRate);
if(myProperties.get("Display.Format") == "NTSC")
myFrameRate = 60;
else if(myProperties.get("Display.Format") == "PAL")
myFrameRate = 50;
// Don't save the framerate to the settings file; only use it internally
myOSystem->settings().setInt("framerate", myFrameRate, false);
// Initialize the framebuffer interface.
// This must be done *after* a reset, since it needs updated values.
initializeVideo();
// Initialize the sound interface.
uInt32 soundFrameRate = (myProperties.get("Display.Format") == "PAL") ? 50 : 60;
myOSystem->sound().setFrameRate(soundFrameRate);
myOSystem->sound().setFrameRate(myFrameRate);
myOSystem->sound().initialize();
// Initialize the menuing system with updated values from the framebuffer
myOSystem->menu().initialize();
myOSystem->menu().setGameProfile(myProperties);
// Finally, let the main loop know about the framerate
myOSystem->setFramerate(myFrameRate);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -236,6 +239,9 @@ void Console::toggleFormat()
setPalette();
myOSystem->setFramerate(framerate);
// Don't save the framerate to the settings file; only use it internally
myOSystem->settings().setInt("framerate", framerate);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: OSystem.hxx,v 1.11 2005-05-06 18:38:59 stephena Exp $
// $Id: OSystem.hxx,v 1.12 2005-05-11 19:36:00 stephena Exp $
//============================================================================
#ifndef OSYSTEM_HXX
@ -38,7 +38,7 @@ class Launcher;
other objects belong.
@author Stephen Anthony
@version $Id: OSystem.hxx,v 1.11 2005-05-06 18:38:59 stephena Exp $
@version $Id: OSystem.hxx,v 1.12 2005-05-11 19:36:00 stephena Exp $
*/
class OSystem
{
@ -160,15 +160,20 @@ class OSystem
*/
void setConfigFiles(const string& userconfig, const string& systemconfig);
/**
Set the location of the gamelist cache file
*/
void setCacheFile(const string& cachefile) { myGameListCacheFile = cachefile; }
/**
Return the default directory for storing data.
*/
string baseDir() { return myBaseDir; }
const string& baseDir() { return myBaseDir; }
/**
Return the directory for storing state files.
*/
string stateDir() { return myStateDir; }
const string& stateDir() { return myStateDir; }
/**
This method should be called to get the filename of the
@ -176,7 +181,7 @@ class OSystem
@return String representing the full path of the properties filename.
*/
string propertiesInputFilename() { return myPropertiesInputFile; }
const string& propertiesInputFilename() { return myPropertiesInputFile; }
/**
This method should be called to get the filename of the
@ -184,7 +189,7 @@ class OSystem
@return String representing the full path of the properties filename.
*/
string propertiesOutputFilename() { return myPropertiesOutputFile; }
const string& propertiesOutputFilename() { return myPropertiesOutputFile; }
/**
This method should be called to get the filename of the config file
@ -192,7 +197,7 @@ class OSystem
@return String representing the full path of the config filename.
*/
string configInputFilename() { return myConfigInputFile; }
const string& configInputFilename() { return myConfigInputFile; }
/**
This method should be called to get the filename of the config file
@ -200,7 +205,15 @@ class OSystem
@return String representing the full path of the config filename.
*/
string configOutputFilename() { return myConfigOutputFile; }
const string& configOutputFilename() { return myConfigOutputFile; }
/**
This method should be called to get the filename of the gamelist
cache file (used by the Launcher to show a listing of available games).
@return String representing the full path of the gamelist cache file.
*/
const string& cacheFile() { return myGameListCacheFile; }
/**
Creates the various framebuffers/renderers available in this system
@ -319,6 +332,7 @@ class OSystem
string myConfigInputFile;
string myConfigOutputFile;
string myGameListCacheFile;
string myRomFile;
private:

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.39 2005-05-10 19:20:41 stephena Exp $
// $Id: Settings.cxx,v 1.40 2005-05-11 19:36:00 stephena Exp $
//============================================================================
#include <cassert>
@ -21,7 +21,7 @@
#include <fstream>
#include "OSystem.hxx"
#include "Version.hxx"
#include "bspf.hxx"
#include "Settings.hxx"
@ -218,7 +218,7 @@ void Settings::usage()
{
#ifndef MAC_OSX
cout << endl
<< "Stella version 1.5_cvs" << endl
<< "Stella version " << STELLA_VERSION << endl
<< endl
<< "Usage: stella [options ...] romfile" << endl
<< " Run without any options or romfile to use the ROM launcher" << endl
@ -242,7 +242,6 @@ void Settings::usage()
<< " -sound <1|0> Enable sound generation\n"
<< " -fragsize <number> The size of sound fragments (must be a power of two)\n"
#endif
<< " -framerate <number> Display the given number of frames per second\n"
<< " -zoom <size> Makes window be 'size' times normal\n"
<< " -fullscreen <1|0> Play the game in fullscreen mode\n"
<< " -grabmouse <1|0> Keeps the mouse in the game window\n"

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: DialogContainer.cxx,v 1.1 2005-05-04 21:32:25 stephena Exp $
// $Id: DialogContainer.cxx,v 1.2 2005-05-11 19:36:00 stephena Exp $
//============================================================================
#include "OSystem.hxx"
@ -73,10 +73,8 @@ void DialogContainer::reStack()
{
// Pop all items from the stack, and then add the base menu
while(!myDialogStack.empty())
{
Dialog* d = myDialogStack.pop();
d->close();
}
myDialogStack.pop();
myDialogStack.push(myBaseDialog);
}

View File

@ -13,9 +13,10 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Launcher.cxx,v 1.4 2005-05-10 19:20:43 stephena Exp $
// $Id: Launcher.cxx,v 1.5 2005-05-11 19:36:00 stephena Exp $
//============================================================================
#include "Version.hxx"
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "LauncherDialog.hxx"
@ -46,6 +47,6 @@ void Launcher::initialize()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Launcher::initializeVideo()
{
string title = "Stella: ROM Launcher"; // FIXME - include version of Stella
string title = string("Stella version ") + STELLA_VERSION;
myOSystem->frameBuffer().initialize(title, kLauncherWidth, kLauncherHeight, false);
}

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: LauncherDialog.cxx,v 1.7 2005-05-11 01:44:39 stephena Exp $
// $Id: LauncherDialog.cxx,v 1.8 2005-05-11 19:36:00 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -177,7 +177,8 @@ void LauncherDialog::updateListing(bool fullReload)
// Start with empty lists
myGameList->clear();
if(instance()->fileExists("stella.cache") && !fullReload) // FIXME - get name from Settings
string cacheFile = instance()->cacheFile();
if(instance()->fileExists(cacheFile) && !fullReload)
loadListFromCache();
else
loadListFromDisk();
@ -235,7 +236,8 @@ void LauncherDialog::loadListFromDisk()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::loadListFromCache()
{
ifstream in("stella.cache"); // FIXME - get name from Settings
string cacheFile = instance()->cacheFile();
ifstream in(cacheFile.c_str());
if(!in)
{
loadListFromDisk();
@ -273,7 +275,8 @@ void LauncherDialog::loadListFromCache()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::createListCache()
{
ofstream out("stella.cache"); // FIXME - get name from Settings
string cacheFile = instance()->cacheFile();
ofstream out(cacheFile.c_str());
// Write the gamelist to the cachefile (sorting is already done)
for (Int32 i = 0; i < (Int32) myGameList->size(); ++i)

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: VideoDialog.cxx,v 1.10 2005-05-10 19:20:44 stephena Exp $
// $Id: VideoDialog.cxx,v 1.11 2005-05-11 19:36:00 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -276,7 +276,6 @@ void VideoDialog::saveConfig()
// Framerate
i = myFrameRateSlider->getValue();
instance()->settings().setInt("framerate", i);
instance()->setFramerate(i);
// Zoom

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.6 2005-05-06 18:39:00 stephena Exp $
// $Id: OSystemUNIX.cxx,v 1.7 2005-05-11 19:36:00 stephena Exp $
//============================================================================
#include <cstdlib>
@ -36,6 +36,29 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemUNIX::OSystemUNIX()
{
// First set variables that the OSystem needs
string basedir = getenv("HOME");
setBaseDir(basedir);
string stelladir = basedir + "/.stella";
if(!fileExists(stelladir))
makeDir(stelladir);
string statedir = stelladir + "/state/";
if(!fileExists(statedir))
makeDir(statedir);
setStateDir(statedir);
string userPropertiesFile = stelladir + "/stella.pro";
string systemPropertiesFile = "/etc/stella.pro";
setPropertiesFiles(userPropertiesFile, systemPropertiesFile);
string userConfigFile = stelladir + "/stellarc";
string systemConfigFile = "/etc/stellarc";
setConfigFiles(userConfigFile, systemConfigFile);
string cacheFile = stelladir + "/stella.cache";
setCacheFile(cacheFile);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,13 +13,10 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: SettingsUNIX.cxx,v 1.12 2005-05-10 19:20:45 stephena Exp $
// $Id: SettingsUNIX.cxx,v 1.13 2005-05-11 19:36:00 stephena Exp $
//============================================================================
#include <cstdlib>
#include "bspf.hxx"
#include "OSystem.hxx"
#include "Settings.hxx"
#include "SettingsUNIX.hxx"
@ -27,27 +24,6 @@
SettingsUNIX::SettingsUNIX(OSystem* osystem)
: Settings(osystem)
{
// First set variables that the OSystem needs
string basedir = getenv("HOME");
myOSystem->setBaseDir(basedir);
string stelladir = basedir + "/.stella";
if(!myOSystem->fileExists(stelladir))
myOSystem->makeDir(stelladir);
string statedir = stelladir + "/state/";
if(!myOSystem->fileExists(statedir))
myOSystem->makeDir(statedir);
myOSystem->setStateDir(statedir);
string userPropertiesFile = stelladir + "/stella.pro";
string systemPropertiesFile = "/etc/stella.pro";
myOSystem->setPropertiesFiles(userPropertiesFile, systemPropertiesFile);
string userConfigFile = stelladir + "/stellarc";
string systemConfigFile = "/etc/stellarc";
myOSystem->setConfigFiles(userConfigFile, systemConfigFile);
// This argument is only valid for Linux/UNIX, and will eventually be removed
set("accurate", "false");
}