2001-12-27 19:54:36 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2014-01-12 17:23:42 +00:00
|
|
|
// Copyright (c) 1995-2014 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2001-12-27 19:54:36 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2001-12-27 19:54:36 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2001-12-27 19:54:36 +00:00
|
|
|
//============================================================================
|
|
|
|
|
OK, this looks like a huge update, but it's only because of some Serializer
class reworking. Serializer class now handles read/write of state from
files as well as in-memory streams. As a result, Deserializer class has
been removed.
Added state rewinding to the debugger. For now, this is limited to 100
levels of undo, with a new state generated each time a step/trace/frame/
scanline advance is performed. The undo level is 'rolling', in that it
remembers the last 100 levels (so you lose the oldest states when you
start adding more than 100). For now, this is tied to the 'Alt-r' key
in the debugger. Still TODO is add a button for it, and clean up some
TIA output issues when rewinding.
Added support for 6K version of Supercharger ROMs (this fixes issues
with the 6K version of Cubis).
Cleaned up the Serializable infrastructure, making sure that all
classes that need to implement it actually do so now.
Fixed issue with editable widgets in the UI, where pressing Enter
on the keypad wasn't actually being registered.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1849 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2009-08-05 16:05:34 +00:00
|
|
|
#include <fstream>
|
Some configure work:
- removed TEXTURES_ARE_DIRTY logic, and just recreate the GL textures
when a screenmode changes
- enable checking for machine type and if nasm is available
- logic to enable scaler mode only when in OpenGL mode (still not complete
and defaults to off)
First pass at adding scaler code to OpenGL. Still much work TODO,
but the C version is working correctly (asm is causing crashes,
haven't figured out why). GL quad coordinates aren't properly
set yet, so the image always appears in the upper left corner, and
is not scaled to the window size. CPU usage is also quite high,
but I'm on a 1GHz laptop with i950 GL, so that may explain it.
Fixed long-standing bug in software rendering, where switching to a
lower-res screen while a message is being displayed would cause a
segfault.
Large refactoring of mainSDL. Specifically, OSystem now owns all
the subsystems except for Settings, taking responsibility for creating
and destroying them.
Properties fixes for 'Tomarc the Barbarian' and 'Gyruss'.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1136 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-10-22 18:58:46 +00:00
|
|
|
#include <sstream>
|
2009-06-08 16:50:14 +00:00
|
|
|
#include <map>
|
Some configure work:
- removed TEXTURES_ARE_DIRTY logic, and just recreate the GL textures
when a screenmode changes
- enable checking for machine type and if nasm is available
- logic to enable scaler mode only when in OpenGL mode (still not complete
and defaults to off)
First pass at adding scaler code to OpenGL. Still much work TODO,
but the C version is working correctly (asm is causing crashes,
haven't figured out why). GL quad coordinates aren't properly
set yet, so the image always appears in the upper left corner, and
is not scaled to the window size. CPU usage is also quite high,
but I'm on a 1GHz laptop with i950 GL, so that may explain it.
Fixed long-standing bug in software rendering, where switching to a
lower-res screen while a message is being displayed would cause a
segfault.
Large refactoring of mainSDL. Specifically, OSystem now owns all
the subsystems except for Settings, taking responsibility for creating
and destroying them.
Properties fixes for 'Tomarc the Barbarian' and 'Gyruss'.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1136 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-10-22 18:58:46 +00:00
|
|
|
|
2007-09-03 18:37:24 +00:00
|
|
|
#include "bspf.hxx"
|
|
|
|
|
2006-03-05 01:18:42 +00:00
|
|
|
#include "DefProps.hxx"
|
2001-12-27 19:54:36 +00:00
|
|
|
#include "Props.hxx"
|
2007-09-03 18:37:24 +00:00
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
#include "PropsSet.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-10-26 15:54:02 +00:00
|
|
|
PropertiesSet::PropertiesSet(const string& propsfile)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2014-10-26 15:54:02 +00:00
|
|
|
load(propsfile);
|
2009-06-08 16:50:14 +00:00
|
|
|
}
|
Some configure work:
- removed TEXTURES_ARE_DIRTY logic, and just recreate the GL textures
when a screenmode changes
- enable checking for machine type and if nasm is available
- logic to enable scaler mode only when in OpenGL mode (still not complete
and defaults to off)
First pass at adding scaler code to OpenGL. Still much work TODO,
but the C version is working correctly (asm is causing crashes,
haven't figured out why). GL quad coordinates aren't properly
set yet, so the image always appears in the upper left corner, and
is not scaled to the window size. CPU usage is also quite high,
but I'm on a 1GHz laptop with i950 GL, so that may explain it.
Fixed long-standing bug in software rendering, where switching to a
lower-res screen while a message is being displayed would cause a
segfault.
Large refactoring of mainSDL. Specifically, OSystem now owns all
the subsystems except for Settings, taking responsibility for creating
and destroying them.
Properties fixes for 'Tomarc the Barbarian' and 'Gyruss'.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1136 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-10-22 18:58:46 +00:00
|
|
|
|
2009-06-08 16:50:14 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
PropertiesSet::~PropertiesSet()
|
|
|
|
{
|
|
|
|
myExternalProps.clear();
|
|
|
|
myTempProps.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void PropertiesSet::load(const string& filename)
|
|
|
|
{
|
|
|
|
ifstream in(filename.c_str(), ios::in);
|
|
|
|
|
|
|
|
// Loop reading properties
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
// Make sure the stream is still good or we're done
|
|
|
|
if(!in)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Get the property list associated with this profile
|
|
|
|
Properties prop;
|
|
|
|
prop.load(in);
|
|
|
|
|
|
|
|
// If the stream is still good then insert the properties
|
|
|
|
if(in)
|
|
|
|
insert(prop);
|
|
|
|
}
|
|
|
|
if(in)
|
|
|
|
in.close();
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2009-06-08 16:50:14 +00:00
|
|
|
bool PropertiesSet::save(const string& filename) const
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2009-06-08 16:50:14 +00:00
|
|
|
ofstream out(filename.c_str(), ios::out);
|
|
|
|
if(!out)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Only save those entries in the external list
|
2014-11-02 23:40:20 +00:00
|
|
|
for(const auto& i: myExternalProps)
|
|
|
|
i.second.save(out);
|
2009-06-08 16:50:14 +00:00
|
|
|
|
|
|
|
return true;
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2009-06-17 17:04:55 +00:00
|
|
|
bool PropertiesSet::getMD5(const string& md5, Properties& properties,
|
2006-12-01 18:30:21 +00:00
|
|
|
bool useDefaults) const
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2006-03-05 01:18:42 +00:00
|
|
|
properties.setDefaults();
|
2002-01-08 17:11:32 +00:00
|
|
|
bool found = false;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2009-06-08 16:50:14 +00:00
|
|
|
// There are three lists to search when looking for a properties entry,
|
|
|
|
// which must be done in the following order
|
|
|
|
// If 'useDefaults' is specified, only use the built-in list
|
|
|
|
//
|
|
|
|
// 'save': entries previously inserted that are saved on program exit
|
|
|
|
// 'temp': entries previously inserted that are discarded
|
|
|
|
// 'builtin': the defaults compiled into the program
|
|
|
|
|
|
|
|
// First check properties from external file
|
|
|
|
if(!useDefaults)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2009-06-08 16:50:14 +00:00
|
|
|
// Check external list
|
2014-11-02 23:40:20 +00:00
|
|
|
const auto ext = myExternalProps.find(md5);
|
|
|
|
if(ext != myExternalProps.end())
|
2009-06-08 16:50:14 +00:00
|
|
|
{
|
2014-11-02 23:40:20 +00:00
|
|
|
properties = ext->second;
|
2009-06-08 16:50:14 +00:00
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
else // Search temp list
|
2006-03-05 01:18:42 +00:00
|
|
|
{
|
2014-11-02 23:40:20 +00:00
|
|
|
const auto tmp = myTempProps.find(md5);
|
|
|
|
if(tmp != myTempProps.end())
|
2006-03-05 01:18:42 +00:00
|
|
|
{
|
2014-11-02 23:40:20 +00:00
|
|
|
properties = tmp->second;
|
2009-06-08 16:50:14 +00:00
|
|
|
found = true;
|
2006-03-05 01:18:42 +00:00
|
|
|
}
|
|
|
|
}
|
2002-01-16 02:14:25 +00:00
|
|
|
}
|
2005-09-11 22:55:51 +00:00
|
|
|
|
2007-04-09 18:12:40 +00:00
|
|
|
// Otherwise, search the internal database using binary search
|
2006-03-05 01:18:42 +00:00
|
|
|
if(!found)
|
|
|
|
{
|
2007-07-31 15:46:21 +00:00
|
|
|
int low = 0, high = DEF_PROPS_SIZE - 1;
|
2007-04-09 18:12:40 +00:00
|
|
|
while(low <= high)
|
2006-03-05 01:18:42 +00:00
|
|
|
{
|
2007-04-09 18:12:40 +00:00
|
|
|
int i = (low + high) / 2;
|
2013-08-11 15:41:36 +00:00
|
|
|
int cmp = BSPF_compareIgnoreCase(md5, DefProps[i][Cartridge_MD5]);
|
2007-04-09 18:12:40 +00:00
|
|
|
|
|
|
|
if(cmp == 0) // found it
|
2006-03-05 01:18:42 +00:00
|
|
|
{
|
|
|
|
for(int p = 0; p < LastPropType; ++p)
|
2006-03-19 00:46:04 +00:00
|
|
|
if(DefProps[i][p][0] != 0)
|
2006-03-05 01:18:42 +00:00
|
|
|
properties.set((PropertyType)p, DefProps[i][p]);
|
|
|
|
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if(cmp < 0)
|
2007-04-09 18:12:40 +00:00
|
|
|
high = i - 1; // look at lower range
|
2006-03-05 01:18:42 +00:00
|
|
|
else
|
2007-04-09 18:12:40 +00:00
|
|
|
low = i + 1; // look at upper range
|
2006-03-05 01:18:42 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-17 17:04:55 +00:00
|
|
|
|
|
|
|
return found;
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 23:09:31 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void PropertiesSet::getMD5WithInsert(const FilesystemNode& rom,
|
|
|
|
const string& md5, Properties& properties)
|
|
|
|
{
|
|
|
|
if(!getMD5(md5, properties))
|
|
|
|
{
|
2013-05-16 19:11:44 +00:00
|
|
|
properties.set(Cartridge_MD5, md5);
|
2013-02-13 23:09:31 +00:00
|
|
|
// Create a name suitable for using in properties
|
2013-06-21 12:15:32 +00:00
|
|
|
properties.set(Cartridge_Name, rom.getNameWithExt(""));
|
2013-02-13 23:09:31 +00:00
|
|
|
|
|
|
|
insert(properties, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-09-16 18:15:44 +00:00
|
|
|
void PropertiesSet::insert(const Properties& properties, bool save)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2009-06-08 16:50:14 +00:00
|
|
|
// Note that the following code is optimized for insertion when an item
|
|
|
|
// doesn't already exist, and when the external properties file is
|
|
|
|
// relatively small (which is the case with current versions of Stella,
|
|
|
|
// as the properties are built-in)
|
|
|
|
// If an item does exist, it will be removed and insertion done again
|
|
|
|
// This shouldn't be a speed issue, as insertions will only fail with
|
|
|
|
// duplicates when you're changing the current ROM properties, which
|
|
|
|
// most people tend not to do
|
|
|
|
|
2007-09-06 02:15:00 +00:00
|
|
|
// Since the PropSet is keyed by md5, we can't insert without a valid one
|
2009-06-08 16:50:14 +00:00
|
|
|
const string& md5 = properties.get(Cartridge_MD5);
|
|
|
|
if(md5 == "")
|
2007-09-06 02:15:00 +00:00
|
|
|
return;
|
|
|
|
|
2009-06-08 16:50:14 +00:00
|
|
|
// The status of 'save' determines which list to save to
|
|
|
|
PropsList& list = save ? myExternalProps : myTempProps;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2014-11-02 23:40:20 +00:00
|
|
|
auto ret = list.insert(make_pair(md5, properties));
|
2009-06-08 16:50:14 +00:00
|
|
|
if(ret.second == false)
|
2002-01-08 17:11:32 +00:00
|
|
|
{
|
2009-06-08 16:50:14 +00:00
|
|
|
// Remove old item and insert again
|
|
|
|
list.erase(ret.first);
|
|
|
|
list.insert(make_pair(md5, properties));
|
2002-01-08 17:11:32 +00:00
|
|
|
}
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2009-06-08 16:50:14 +00:00
|
|
|
void PropertiesSet::removeMD5(const string& md5)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2009-06-08 16:50:14 +00:00
|
|
|
// We only remove from the external list
|
|
|
|
myExternalProps.erase(md5);
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
2004-07-05 00:53:48 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2006-12-01 18:30:21 +00:00
|
|
|
void PropertiesSet::print() const
|
2004-07-05 00:53:48 +00:00
|
|
|
{
|
2009-06-08 16:50:14 +00:00
|
|
|
// We only look at the external properties and the built-in ones;
|
|
|
|
// the temp properties are ignored
|
|
|
|
// Also, any properties entries in the external file override the built-in
|
|
|
|
// ones
|
|
|
|
// The easiest way to merge the lists is to create another temporary one
|
|
|
|
// This isn't fast, but I suspect this method isn't used too often (or at all)
|
|
|
|
|
|
|
|
PropsList list;
|
|
|
|
|
|
|
|
// First insert all external props
|
|
|
|
list = myExternalProps;
|
|
|
|
|
|
|
|
// Now insert all the built-in ones
|
|
|
|
// Note that if we try to insert a duplicate, the insertion will fail
|
|
|
|
// This is fine, since a duplicate in the built-in list means it should
|
|
|
|
// be overrided anyway (and insertion shouldn't be done)
|
|
|
|
Properties properties;
|
|
|
|
for(int i = 0; i < DEF_PROPS_SIZE; ++i)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2009-06-08 16:50:14 +00:00
|
|
|
properties.setDefaults();
|
|
|
|
for(int p = 0; p < LastPropType; ++p)
|
|
|
|
if(DefProps[i][p][0] != 0)
|
|
|
|
properties.set((PropertyType)p, DefProps[i][p]);
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2009-06-08 16:50:14 +00:00
|
|
|
list.insert(make_pair(DefProps[i][Cartridge_MD5], properties));
|
2004-07-05 00:53:48 +00:00
|
|
|
}
|
|
|
|
|
2009-06-08 16:50:14 +00:00
|
|
|
// Now, print the resulting list
|
2010-02-24 14:46:05 +00:00
|
|
|
Properties::printHeader();
|
2014-11-02 23:40:20 +00:00
|
|
|
for(const auto& i: list)
|
|
|
|
i.second.print();
|
2002-01-08 17:11:32 +00:00
|
|
|
}
|