Commit 0f0625d9 authored by stephena's avatar stephena
Browse files

Cleaned up the SDL event gathering loop. It now almost exclusively

makes use of switch/case statements instead of the slower if/elseif
structure.  Hopefully this will fix event problems some users were
experiencing.

The Control or Alt button can actually now be used in event remapping.
Due to the old event handling, the Control key could be assigned to
an event but would never actually be usable.

Removed the option to remap the exit event (for now), since I haven't
figured out a way to remap it *back* to 'Escape' if that mapping is
ever removed.

Added beginning of support for Stella to automatically determine the
correct framerate based on ROM format type.  The final version of this
will probably wait until Stella 1.5.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@329 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
parent e060f521
This diff is collapsed.
...@@ -13,7 +13,7 @@ ...@@ -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.35 2004-07-22 01:54:08 stephena Exp $ // $Id: Console.cxx,v 1.36 2004-07-28 23:54:38 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <assert.h>
...@@ -65,8 +65,6 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename, ...@@ -65,8 +65,6 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename,
mySystem = 0; mySystem = 0;
myEvent = 0; myEvent = 0;
myFrameRate = mySettings.getInt("framerate");
// Create an event handler which will collect and dispatch events // Create an event handler which will collect and dispatch events
myEventHandler = new EventHandler(this); myEventHandler = new EventHandler(this);
myEvent = myEventHandler->event(); myEvent = myEventHandler->event();
...@@ -162,13 +160,25 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename, ...@@ -162,13 +160,25 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename,
// Reset, the system to its power-on state // Reset, the system to its power-on state
mySystem->reset(); mySystem->reset();
// Set the correct framerate based on the format of the ROM
// This can be overridden by the '-framerate' option
myFrameRate = 60;
if(mySettings.getInt("framerate") > 0)
myFrameRate = mySettings.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);
mySettings.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.
myFrameBuffer.initDisplay(this, myMediaSource); myFrameBuffer.initDisplay(this, myMediaSource);
// Initialize the sound interface. // Initialize the sound interface.
uInt32 framerate = (myProperties.get("Display.Format") == "PAL") ? 50 : 60; uInt32 soundFrameRate = (myProperties.get("Display.Format") == "PAL") ? 50 : 60;
mySound.init(this, myMediaSource, mySystem, framerate); mySound.init(this, myMediaSource, mySystem, soundFrameRate);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......
...@@ -13,7 +13,7 @@ ...@@ -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.28 2004-07-21 00:15:08 stephena Exp $ // $Id: EventHandler.cxx,v 1.29 2004-07-28 23:54:39 stephena Exp $
//============================================================================ //============================================================================
#include <algorithm> #include <algorithm>
...@@ -338,15 +338,13 @@ bool EventHandler::isValidList(string list, uInt32 length) ...@@ -338,15 +338,13 @@ bool EventHandler::isValidList(string list, uInt32 length)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::saveState() void EventHandler::saveState()
{ {
ostringstream buf;
// Do a state save using the System // Do a state save using the System
string md5 = myConsole->properties().get("Cartridge.MD5"); string md5 = myConsole->properties().get("Cartridge.MD5");
string filename = myConsole->settings().stateFilename(md5, myCurrentState); string filename = myConsole->settings().stateFilename(md5, myCurrentState);
int result = myConsole->system().saveState(filename, md5); int result = myConsole->system().saveState(filename, md5);
// Print appropriate message // Print appropriate message
buf.str(""); ostringstream buf;
if(result == 1) if(result == 1)
buf << "State " << myCurrentState << " saved"; buf << "State " << myCurrentState << " saved";
else if(result == 2) else if(result == 2)
...@@ -375,13 +373,13 @@ void EventHandler::changeState() ...@@ -375,13 +373,13 @@ void EventHandler::changeState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::loadState() void EventHandler::loadState()
{ {
ostringstream buf;
// Do a state save using the System // Do a state save using the System
string md5 = myConsole->properties().get("Cartridge.MD5"); string md5 = myConsole->properties().get("Cartridge.MD5");
string filename = myConsole->settings().stateFilename(md5, myCurrentState); string filename = myConsole->settings().stateFilename(md5, myCurrentState);
int result = myConsole->system().loadState(filename, md5); int result = myConsole->system().loadState(filename, md5);
// Print appropriate message
ostringstream buf;
if(result == 1) if(result == 1)
buf << "State " << myCurrentState << " loaded"; buf << "State " << myCurrentState << " loaded";
else if(result == 2) else if(result == 2)
......
...@@ -13,7 +13,7 @@ ...@@ -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.11 2004-07-22 01:54:08 stephena Exp $ // $Id: FrameBuffer.cxx,v 1.12 2004-07-28 23:54:39 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
...@@ -696,7 +696,7 @@ FrameBuffer::MainMenuItem FrameBuffer::ourMainMenu[2] = { ...@@ -696,7 +696,7 @@ FrameBuffer::MainMenuItem FrameBuffer::ourMainMenu[2] = {
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBuffer::RemapMenuItem FrameBuffer::ourRemapMenu[58] = { FrameBuffer::RemapMenuItem FrameBuffer::ourRemapMenu[57] = {
{ Event::ConsoleSelect, "Select", "" }, { Event::ConsoleSelect, "Select", "" },
{ Event::ConsoleReset, "Reset", "" }, { Event::ConsoleReset, "Reset", "" },
{ Event::ConsoleColor, "Color TV", "" }, { Event::ConsoleColor, "Color TV", "" },
...@@ -710,7 +710,7 @@ FrameBuffer::RemapMenuItem FrameBuffer::ourRemapMenu[58] = { ...@@ -710,7 +710,7 @@ FrameBuffer::RemapMenuItem FrameBuffer::ourRemapMenu[58] = {
{ Event::LoadState, "Load State", "" }, { Event::LoadState, "Load State", "" },
{ Event::TakeSnapshot, "Snapshot", "" }, { Event::TakeSnapshot, "Snapshot", "" },
{ Event::Pause, "Pause", "" }, { Event::Pause, "Pause", "" },
{ Event::Quit, "Quit", "" }, // { Event::Quit, "Quit", "" },
{ Event::JoystickZeroUp, "Left-Joy Up", "" }, { Event::JoystickZeroUp, "Left-Joy Up", "" },
{ Event::JoystickZeroDown, "Left-Joy Down", "" }, { Event::JoystickZeroDown, "Left-Joy Down", "" },
......
...@@ -13,7 +13,7 @@ ...@@ -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.11 2004-07-22 01:54:08 stephena Exp $ // $Id: FrameBuffer.hxx,v 1.12 2004-07-28 23:54:39 stephena Exp $
//============================================================================ //============================================================================
#ifndef FRAMEBUFFER_HXX #ifndef FRAMEBUFFER_HXX
...@@ -35,7 +35,7 @@ class Console; ...@@ -35,7 +35,7 @@ class Console;
can be changed. can be changed.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.11 2004-07-22 01:54:08 stephena Exp $ @version $Id: FrameBuffer.hxx,v 1.12 2004-07-28 23:54:39 stephena Exp $
*/ */
class FrameBuffer class FrameBuffer
{ {
...@@ -337,7 +337,7 @@ class FrameBuffer ...@@ -337,7 +337,7 @@ class FrameBuffer
static MainMenuItem ourMainMenu[2]; static MainMenuItem ourMainMenu[2];
// Holds static strings for the remap menu // Holds static strings for the remap menu
static RemapMenuItem ourRemapMenu[58]; static RemapMenuItem ourRemapMenu[57];
// Holds the current key mappings // Holds the current key mappings
Event::Type* myKeyTable; Event::Type* myKeyTable;
......
...@@ -13,7 +13,7 @@ ...@@ -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: Props.cxx,v 1.7 2004-07-12 04:05:03 stephena Exp $ // $Id: Props.cxx,v 1.8 2004-07-28 23:54:39 stephena Exp $
//============================================================================ //============================================================================
#include "Props.hxx" #include "Props.hxx"
...@@ -151,10 +151,14 @@ void Properties::save(ostream& out) ...@@ -151,10 +151,14 @@ void Properties::save(ostream& out)
// Write out each of the key and value pairs // Write out each of the key and value pairs
for(uInt32 i = 0; i < mySize; ++i) for(uInt32 i = 0; i < mySize; ++i)
{ {
writeQuotedString(out, myProperties[i].key); // Try to save some space by only saving the items that differ from default
out.put(' '); if(myProperties[i].value != myDefaults->get(myProperties[i].key))
writeQuotedString(out, myProperties[i].value); {
out.put('\n'); writeQuotedString(out, myProperties[i].key);
out.put(' ');
writeQuotedString(out, myProperties[i].value);
out.put('\n');
}
} }
// Put a trailing null string so we know when to stop reading // Put a trailing null string so we know when to stop reading
......
...@@ -13,7 +13,7 @@ ...@@ -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.cxx,v 1.26 2004-07-12 02:26:57 stephena Exp $ // $Id: Settings.cxx,v 1.27 2004-07-28 23:54:39 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
...@@ -45,7 +45,7 @@ Settings::Settings() ...@@ -45,7 +45,7 @@ Settings::Settings()
set("hidecursor", "false"); set("hidecursor", "false");
set("volume", "-1"); set("volume", "-1");
set("accurate", "false"); set("accurate", "false");
set("framerate", "60"); set("framerate", "-1");
set("keymap", ""); set("keymap", "");
set("joymap", ""); set("joymap", "");
set("zoom", "1"); set("zoom", "1");
...@@ -167,7 +167,7 @@ void Settings::usage() ...@@ -167,7 +167,7 @@ void Settings::usage()
{ {
#ifndef MAC_OSX #ifndef MAC_OSX
cout << endl cout << endl
<< "Stella version 1.4\n\nUsage: stella [options ...] romfile" << endl << "Stella version 1.4.1_cvs\n\nUsage: stella [options ...] romfile" << endl
<< endl << endl
<< "Valid options are:" << endl << "Valid options are:" << endl
<< endl << endl
...@@ -282,39 +282,39 @@ void Settings::set(const string& key, const string& value, bool save) ...@@ -282,39 +282,39 @@ void Settings::set(const string& key, const string& value, bool save)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::setInt(const string& key, const uInt32 value) void Settings::setInt(const string& key, const uInt32 value, bool save)
{ {
ostringstream stream; ostringstream stream;
stream << value; stream << value;
set(key, stream.str()); set(key, stream.str(), save);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::setFloat(const string& key, const float value) void Settings::setFloat(const string& key, const float value, bool save)
{ {
ostringstream stream; ostringstream stream;
stream << value; stream << value;
set(key, stream.str()); set(key, stream.str(), save);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::setBool(const string& key, const bool value) void Settings::setBool(const string& key, const bool value, bool save)
{ {
ostringstream stream; ostringstream stream;
stream << value; stream << value;
set(key, stream.str()); set(key, stream.str(), save);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::setString(const string& key, const string& value) void Settings::setString(const string& key, const string& value, bool save)
{ {
ostringstream stream; ostringstream stream;
stream << value; stream << value;
set(key, stream.str()); set(key, stream.str(), save);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......
...@@ -13,7 +13,7 @@ ...@@ -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.16 2004-07-09 00:27:39 stephena Exp $ // $Id: Settings.hxx,v 1.17 2004-07-28 23:54:39 stephena Exp $
//============================================================================ //============================================================================
#ifndef SETTINGS_HXX #ifndef SETTINGS_HXX
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
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.16 2004-07-09 00:27:39 stephena Exp $ @version $Id: Settings.hxx,v 1.17 2004-07-28 23:54:39 stephena Exp $
*/ */
class Settings class Settings
{ {
...@@ -107,7 +107,7 @@ class Settings ...@@ -107,7 +107,7 @@ class Settings
@param value The value to assign to the setting @param value The value to assign to the setting
@param save Whether this setting should be saved to the rc-file. @param save Whether this setting should be saved to the rc-file.
*/ */
void setInt(const string& key, const uInt32 value); void setInt(const string& key, const uInt32 value, bool save = true);
/** /**
Set the value associated with key to the given value. Set the value associated with key to the given value.
...@@ -116,7 +116,7 @@ class Settings ...@@ -116,7 +116,7 @@ class Settings
@param value The value to assign to the setting @param value The value to assign to the setting
@param save Whether this setting should be saved to the rc-file. @param save Whether this setting should be saved to the rc-file.
*/ */
void setFloat(const string& key, const float value); void setFloat(const string& key, const float value, bool save = true);
/** /**
Set the value associated with key to the given value. Set the value associated with key to the given value.
...@@ -125,7 +125,7 @@ class Settings ...@@ -125,7 +125,7 @@ class Settings
@param value The value to assign to the setting @param value The value to assign to the setting
@param save Whether this setting should be saved to the rc-file. @param save Whether this setting should be saved to the rc-file.
*/ */
void setBool(const string& key, const bool value); void setBool(const string& key, const bool value, bool save = true);
/** /**
Set the value associated with key to the given value. Set the value associated with key to the given value.
...@@ -134,7 +134,7 @@ class Settings ...@@ -134,7 +134,7 @@ class Settings
@param value The value to assign to the setting @param value The value to assign to the setting
@param save Whether this setting should be saved to the rc-file. @param save Whether this setting should be saved to the rc-file.
*/ */
void setString(const string& key, const string& value); void setString(const string& key, const string& value, bool save = true);
public: public:
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
......
...@@ -13,7 +13,7 @@ ...@@ -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.3 2004-07-14 06:54:17 markgrebe Exp $ // $Id: mainSDL.cxx,v 1.4 2004-07-28 23:54:39 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
...@@ -558,13 +558,13 @@ void handleEvents() ...@@ -558,13 +558,13 @@ void handleEvents()
{ {
if (theSettings->getInt("framerate") != 10000000) if (theSettings->getInt("framerate") != 10000000)
{ {
theSettings->setInt("framerate",10000000); theSettings->setInt("framerate",10000000, false);
timePerFrame = 1.0 / 10000000.0; timePerFrame = 1.0 / 10000000.0;
setSpeedLimitMenu(0); setSpeedLimitMenu(0);
} }
else else
{ {
theSettings->setInt("framerate",60); theSettings->setInt("framerate",60, false);
timePerFrame = 1.0 / 60.0; timePerFrame = 1.0 / 60.0;
setSpeedLimitMenu(1); setSpeedLimitMenu(1);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment