Fixed case sensitivity when specifying developer options on the

commandline.  So, for example, the format of a ROM can be
specified with 'NTSC', 'Ntsc', 'ntsc', etc.

Cleaned up some dead code in Properties class.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@789 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-09-22 22:10:57 +00:00
parent 7fd1a9089b
commit b9613ec228
7 changed files with 52 additions and 68 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: Cart.cxx,v 1.15 2005-07-30 16:25:48 urchlay Exp $
// $Id: Cart.cxx,v 1.16 2005-09-22 22:10:57 stephena Exp $
//============================================================================
#include <assert.h>
@ -49,13 +49,11 @@ Cartridge* Cartridge::create(const uInt8* image, uInt32 size,
Cartridge* cartridge = 0;
// Get the type of the cartridge we're creating
string type = properties.get("Cartridge.Type");
string type = properties.get("Cartridge.Type", true);
// See if we should try to auto-detect the cartridge type
if(type == "Auto-detect")
{
if(type == "AUTO-DETECT")
type = autodetectType(image, size);
}
// We should know the cart's type by now so let's create it
if(type == "2K")

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.70 2005-09-11 22:55:51 stephena Exp $
// $Id: Console.cxx,v 1.71 2005-09-22 22:10:57 stephena Exp $
//============================================================================
#include <assert.h>
@ -84,28 +84,28 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
setDeveloperProperties();
// Make sure height is set properly for PAL ROM
if(myProperties.get("Display.Format") == "PAL")
if(myProperties.get("Display.Format", true) == "PAL")
if(myProperties.get("Display.Height") == "210")
myProperties.set("Display.Height", "250");
// Setup the controllers based on properties
string left = myProperties.get("Controller.Left");
string right = myProperties.get("Controller.Right");
string left = myProperties.get("Controller.Left", true);
string right = myProperties.get("Controller.Right", true);
// Construct left controller
if(left == "Booster-Grip")
if(left == "BOOSTER-GRIP")
{
myControllers[0] = new BoosterGrip(Controller::Left, *myEvent);
}
else if(left == "Driving")
else if(left == "DRIVING")
{
myControllers[0] = new Driving(Controller::Left, *myEvent);
}
else if((left == "Keyboard") || (left == "Keypad"))
else if((left == "KEYBOARD") || (left == "KEYPAD"))
{
myControllers[0] = new Keyboard(Controller::Left, *myEvent);
}
else if(left == "Paddles")
else if(left == "PADDLES")
{
myControllers[0] = new Paddles(Controller::Left, *myEvent);
}
@ -115,19 +115,19 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
}
// Construct right controller
if(right == "Booster-Grip")
if(right == "BOOSTER-GRIP")
{
myControllers[1] = new BoosterGrip(Controller::Right, *myEvent);
}
else if(right == "Driving")
else if(right == "DRIVING")
{
myControllers[1] = new Driving(Controller::Right, *myEvent);
}
else if((right == "Keyboard") || (right == "Keypad"))
else if((right == "KEYBOARD") || (right == "KEYPAD"))
{
myControllers[1] = new Keyboard(Controller::Right, *myEvent);
}
else if(right == "Paddles")
else if(right == "PADDLES")
{
myControllers[1] = new Paddles(Controller::Right, *myEvent);
}
@ -173,9 +173,10 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
uInt32 framerate = myOSystem->settings().getInt("framerate");
if(framerate == 0)
{
if(myProperties.get("Display.Format") == "NTSC")
string s = myProperties.get("Display.Format", true);
if(s == "NTSC")
framerate = 60;
else if(myProperties.get("Display.Format") == "PAL")
else if(s == "PAL")
framerate = 50;
else
framerate = 60;
@ -192,9 +193,10 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
uInt32 channels = myOSystem->settings().getInt("channels");
if(channels == 0)
{
if(myProperties.get("Cartridge.Sound") == "Stereo")
string s = myProperties.get("Cartridge.Sound", true);
if(s == "STEREO")
channels = 2;
else if(myProperties.get("Cartridge.Sound") == "Mono")
else if(s == "MONO")
channels = 1;
else
channels = 1;
@ -252,7 +254,7 @@ Console& Console::operator = (const Console&)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleFormat()
{
string format = myProperties.get("Display.Format");
string format = myProperties.get("Display.Format", true);
uInt32 framerate = 60;
if(format == "NTSC")
@ -630,10 +632,6 @@ void Console::setDeveloperProperties()
if(s != "")
myProperties.set("Display.Height", s);
s = settings.getString("cpu");
if(s != "")
myProperties.set("Emulation.CPU", s);
s = settings.getString("hmove");
if(s != "")
myProperties.set("Emulation.HmoveBlanks", s);

View File

@ -13,9 +13,12 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Props.cxx,v 1.10 2005-06-16 01:11:28 stephena Exp $
// $Id: Props.cxx,v 1.11 2005-09-22 22:10:57 stephena Exp $
//============================================================================
#include <cctype>
#include <algorithm>
#include "Props.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -41,14 +44,19 @@ Properties::~Properties()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Properties::get(const string& key) const
string Properties::get(const string& key, bool useUppercase) const
{
string s;
// Try to find the named property and answer its value
for(uInt32 i = 0; i < mySize; ++i)
{
if(key == myProperties[i].key)
{
return myProperties[i].value;
s = myProperties[i].value;
if(useUppercase)
transform(s.begin(), s.end(), s.begin(), (int(*)(int)) toupper);
return s;
}
}
@ -56,7 +64,10 @@ string Properties::get(const string& key) const
if(myDefaults != 0)
{
// Ask the default properties object to find the key
return myDefaults->get(key);
s = myDefaults->get(key);
if(useUppercase)
transform(s.begin(), s.end(), s.begin(), (int(*)(int)) toupper);
return s;
}
else
{
@ -266,23 +277,6 @@ void Properties::copy(const Properties& properties)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Properties::merge(const Properties& properties)
{
// Merge each property from properties if it isn't -1
for(uInt32 i = 0; i < properties.mySize; ++i)
{
if(properties.myProperties[i].value != "-1")
{
cerr << "Properties::merge ==> changing " << properties.myProperties[i].key
<< " from value " << get(properties.myProperties[i].key) << " to "
<< properties.myProperties[i].value << endl;
set(properties.myProperties[i].key, properties.myProperties[i].value);
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Properties::print()
{

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: Props.hxx,v 1.5 2005-06-16 01:11:28 stephena Exp $
// $Id: Props.hxx,v 1.6 2005-09-22 22:10:57 stephena Exp $
//============================================================================
#ifndef PROPERTIES_HXX
@ -30,7 +30,7 @@
if the property key is not found in the original property list.
@author Bradford W. Mott
@version $Id: Props.hxx,v 1.5 2005-06-16 01:11:28 stephena Exp $
@version $Id: Props.hxx,v 1.6 2005-09-22 22:10:57 stephena Exp $
*/
class Properties
{
@ -60,10 +60,12 @@ class Properties
Get the value assigned to the specified key. If the key does
not exist then the empty string is returned.
@param key The key of the property to lookup
@param key The key of the property to lookup
@param useUppercase Convert the property to uppercase
@return The value of the property
*/
string get(const string& key) const;
string get(const string& key, bool useUppercase = false) const;
/**
Set the value associated with key to the given value.
@ -88,13 +90,6 @@ class Properties
*/
void save(ostream& out);
/**
Merge the given properties into this properties object
@param properties The properties object to merge
*/
void merge(const Properties& properties);
/**
Print the attributes of this properties object
*/

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.60 2005-09-13 18:27:42 stephena Exp $
// $Id: Settings.cxx,v 1.61 2005-09-22 22:10:57 stephena Exp $
//============================================================================
#include <cassert>
@ -314,7 +314,6 @@ void Settings::usage()
<< " -ystart <arg> Sets the 'Display.YStart' property\n"
<< " -width <arg> Sets the 'Display.Width' property\n"
<< " -height <arg> Sets the 'Display.Height' property\n"
<< " -cpu <arg> Sets the 'Emulation.CPU' property\n"
<< " -hmove <arg> Sets the 'Emulation.HmoveBlanks' property\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: Switches.cxx,v 1.3 2005-06-16 00:55:58 stephena Exp $
// $Id: Switches.cxx,v 1.4 2005-09-22 22:10:57 stephena Exp $
//============================================================================
#include "Event.hxx"
@ -25,7 +25,7 @@ Switches::Switches(const Event& event, const Properties& properties)
: myEvent(event),
mySwitches(0xFF)
{
if(properties.get("Console.RightDifficulty") == "B")
if(properties.get("Console.RightDifficulty", true) == "B")
{
mySwitches &= ~0x80;
}
@ -34,7 +34,7 @@ Switches::Switches(const Event& event, const Properties& properties)
mySwitches |= 0x80;
}
if(properties.get("Console.LeftDifficulty") == "B")
if(properties.get("Console.LeftDifficulty", true) == "B")
{
mySwitches &= ~0x40;
}
@ -43,7 +43,7 @@ Switches::Switches(const Event& event, const Properties& properties)
mySwitches |= 0x40;
}
if(properties.get("Console.TelevisionType") == "Color")
if(properties.get("Console.TelevisionType", true) == "COLOR")
{
mySwitches |= 0x08;
}

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: TIA.cxx,v 1.58 2005-09-15 19:43:36 stephena Exp $
// $Id: TIA.cxx,v 1.59 2005-09-22 22:10:57 stephena Exp $
//============================================================================
#include <cassert>
@ -217,7 +217,7 @@ void TIA::reset()
myDumpDisabledCycle = 0;
myAllowHMOVEBlanks =
(myConsole.properties().get("Emulation.HmoveBlanks") == "Yes");
(myConsole.properties().get("Emulation.HmoveBlanks", true) == "YES");
myFrameXStart = atoi(myConsole.properties().get("Display.XStart").c_str());
myFrameWidth = atoi(myConsole.properties().get("Display.Width").c_str());
@ -236,7 +236,7 @@ void TIA::reset()
myFrameWidth = 160;
}
if(myConsole.properties().get("Display.Format") == "PAL")
if(myConsole.properties().get("Display.Format", true) == "PAL")
{
myColorLossEnabled = true;
myMaximumNumberOfScanlines = 342;
@ -616,7 +616,7 @@ const uInt32* TIA::palette() const
{
// See which palette we should be using
string type = mySettings.getString("palette");
string format = myConsole.properties().get("Display.Format");
string format = myConsole.properties().get("Display.Format", true);
if(type == "standard")
return (format == "PAL") ? ourPALPalette : ourNTSCPalette;