Fixed bug whereby ROMs that didn't have a properties entry were named

'Untitled' in the Stella main window, as well as when taking snapshots.
The actual ROM filename is now used if a properties entry isn't present.

Added profile entries for Swoops! (NTSC and PAL), thanks to vdub_bobby.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@851 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-10-19 00:59:51 +00:00
parent 064eda4e58
commit 2b88f87049
12 changed files with 85 additions and 53 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: Console.cxx,v 1.73 2005-09-30 00:40:33 stephena Exp $
// $Id: Console.cxx,v 1.74 2005-10-19 00:59:51 stephena Exp $
//============================================================================
#include <assert.h>
@ -32,7 +32,6 @@
#include "Keyboard.hxx"
#include "M6502Hi.hxx"
#include "M6532.hxx"
#include "MD5.hxx"
#include "MediaSrc.hxx"
#include "Paddles.hxx"
#include "Props.hxx"
@ -57,7 +56,8 @@
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
Console::Console(const uInt8* image, uInt32 size, const string& md5,
OSystem* osystem)
: myOSystem(osystem)
{
myControllers[0] = 0;
@ -70,18 +70,13 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
// Attach the event subsystem to the current console
myEvent = myOSystem->eventHandler().event();
// Get the MD5 message-digest for the ROM image
string md5 = MD5(image, size);
// Search for the properties based on MD5
myOSystem->propSet().getMD5(md5, myProperties);
// Make sure the MD5 value of the cartridge is set in the properties
if(myProperties.get("Cartridge.MD5") == "")
myProperties.set("Cartridge.MD5", md5);
#ifdef DEVELOPER_SUPPORT
// A developer can override properties from the commandline
setDeveloperProperties();
#endif
// Make sure height is set properly for PAL ROM
if(myProperties.get("Display.Format", true) == "PAL")

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.hxx,v 1.39 2005-09-23 23:35:02 stephena Exp $
// $Id: Console.hxx,v 1.40 2005-10-19 00:59:51 stephena Exp $
//============================================================================
#ifndef CONSOLE_HXX
@ -37,7 +37,7 @@ class System;
This class represents the entire game console.
@author Bradford W. Mott
@version $Id: Console.hxx,v 1.39 2005-09-23 23:35:02 stephena Exp $
@version $Id: Console.hxx,v 1.40 2005-10-19 00:59:51 stephena Exp $
*/
class Console
{
@ -48,9 +48,11 @@ class Console
@param image The ROM image of the game to emulate
@param size The size of the ROM image
@param md5 The md5 of the ROM image
@param osystem The OSystem object to use
*/
Console(const uInt8* image, uInt32 size, OSystem* osystem);
Console(const uInt8* image, uInt32 size, const string& md5,
OSystem* osystem);
/**
Create a new console object by copying another one

View File

@ -16,7 +16,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: MD5.cxx,v 1.2 2005-06-16 01:11:27 stephena Exp $
// $Id: MD5.cxx,v 1.3 2005-10-19 00:59:51 stephena Exp $
//============================================================================
#include "MD5.hxx"
@ -344,4 +344,3 @@ string MD5(const uInt8* buffer, uInt32 length)
return result;
}

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: MD5.hxx,v 1.2 2005-06-16 01:11:27 stephena Exp $
// $Id: MD5.hxx,v 1.3 2005-10-19 00:59:51 stephena Exp $
//============================================================================
#ifndef MD5_HXX
@ -32,4 +32,3 @@
string MD5(const uInt8* buffer, uInt32 length);
#endif

View File

@ -13,15 +13,13 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: OSystem.cxx,v 1.42 2005-10-18 18:49:46 stephena Exp $
// $Id: OSystem.cxx,v 1.43 2005-10-19 00:59:51 stephena Exp $
//============================================================================
#include <cassert>
#include <sstream>
#include <fstream>
#include "unzip.h"
// FIXME - clean up this mess of platform-specific ifdefs
#include "FrameBuffer.hxx"
#include "FrameBufferSoft.hxx"
@ -49,6 +47,8 @@
#include "Debugger.hxx"
#endif
#include "unzip.h"
#include "MD5.hxx"
#include "FSNode.hxx"
#include "Settings.hxx"
#include "PropsSet.hxx"
@ -309,13 +309,14 @@ bool OSystem::createConsole(const string& romfile)
// Open the cartridge image and read it in
uInt8* image;
int size = -1;
if(openROM(myRomFile, &image, &size))
string md5;
if(openROM(myRomFile, md5, &image, &size))
{
delete myConsole; myConsole = NULL;
// Create an instance of the 2600 game console
// The Console c'tor takes care of updating the eventhandler state
myConsole = new Console(image, size, this);
myConsole = new Console(image, size, md5, this);
if(showmessage)
myFrameBuffer->showMessage("New console created");
@ -360,7 +361,7 @@ void OSystem::createLauncher()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool OSystem::openROM(const string& rom, uInt8** image, int* size)
bool OSystem::openROM(const string& rom, string& md5, uInt8** image, int* size)
{
// Try to open the file as a zipped archive
// If that fails, we assume it's just a normal data file
@ -429,6 +430,30 @@ bool OSystem::openROM(const string& rom, uInt8** image, int* size)
in.close();
}
// If we get to this point, we know we have a valid file to open
// Now we make sure that the file has a valid properties entry
md5 = MD5(*image, *size);
// Some games may not have a name, since there may not
// be an entry in stella.pro. In that case, we use the rom name
// and reinsert the properties object
Properties props;
myPropSet->getMD5(md5, props);
string name = props.get("Cartridge.Name");
if(name == "Untitled")
{
// Get the filename from the rom pathname
string::size_type pos = rom.find_last_of(BSPF_PATH_SEPARATOR);
if(pos+1 != string::npos)
{
name = rom.substr(pos+1);
props.set("Cartridge.MD5", md5);
props.set("Cartridge.Name", name);
myPropSet->insert(props);
}
}
return true;
}

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.29 2005-09-11 22:55:51 stephena Exp $
// $Id: OSystem.hxx,v 1.30 2005-10-19 00:59:51 stephena Exp $
//============================================================================
#ifndef OSYSTEM_HXX
@ -43,7 +43,7 @@ class Debugger;
other objects belong.
@author Stephen Anthony
@version $Id: OSystem.hxx,v 1.29 2005-09-11 22:55:51 stephena Exp $
@version $Id: OSystem.hxx,v 1.30 2005-10-19 00:59:51 stephena Exp $
*/
class OSystem
{
@ -283,14 +283,15 @@ class OSystem
Open the given ROM and return an array containing its contents.
@param rom The absolute pathname of the ROM file
@param md5 The md5 calculated from the ROM file
@param image A pointer to store the ROM data
Note, the calling method is responsible for deleting this
@param size The amount of data read into the image array
@return False on any errors, else true
*/
bool openROM(const string& rom, uInt8** image, int* size);
bool openROM(const string& rom, string& md5, uInt8** image, int* size);
const string& romFile() { return myRomFile; }
const string& romFile() { return myRomFile; }
public:
//////////////////////////////////////////////////////////////////////

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: PropsSet.cxx,v 1.13 2005-09-16 18:15:44 stephena Exp $
// $Id: PropsSet.cxx,v 1.14 2005-10-19 00:59:51 stephena Exp $
//============================================================================
#include <assert.h>
@ -77,7 +77,7 @@ void PropertiesSet::getMD5(const string& md5, Properties &properties)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PropertiesSet::insert(const Properties& properties, bool save)
{
insertNode(myRoot, properties, save);
insertNode(myRoot, properties, save);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: PropsSet.hxx,v 1.9 2005-09-16 18:15:44 stephena Exp $
// $Id: PropsSet.hxx,v 1.10 2005-10-19 00:59:51 stephena Exp $
//============================================================================
#ifndef PROPERTIES_SET_HXX
@ -99,14 +99,6 @@ class PropertiesSet
*/
bool merge(const Properties& properties, const string& filename);
private:
struct TreeNode {
Properties* props;
TreeNode* left;
TreeNode* right;
bool save;
};
/**
Insert the properties into the set. If a duplicate is inserted
the old properties are overwritten with the new ones.
@ -115,7 +107,15 @@ class PropertiesSet
@param save Indicates whether to set the 'save' tag for
this property
*/
void insert(const Properties& properties, bool save);
void insert(const Properties& properties, bool save = true);
private:
struct TreeNode {
Properties* props;
TreeNode* left;
TreeNode* right;
bool save;
};
/**
Insert a node in the bst, keeping the tree sorted.

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.63 2005-10-18 18:49:46 stephena Exp $
// $Id: Settings.cxx,v 1.64 2005-10-19 00:59:51 stephena Exp $
//============================================================================
#include <cassert>
@ -294,6 +294,7 @@ void Settings::usage()
#endif
<< " -listrominfo Display contents of stella.pro, one line per ROM entry\n"
<< " -help Show the text you're now reading\n"
#ifdef DEVELOPER_SUPPORT
<< endl
<< " The following options are meant for developers\n"
<< " Arguments are more fully explained in the manual\n"
@ -318,6 +319,7 @@ void Settings::usage()
<< " -width <arg> Sets the 'Display.Width' property\n"
<< " -height <arg> Sets the 'Display.Height' property\n"
<< " -hmove <arg> Sets the 'Emulation.HmoveBlanks' property\n"
#endif
<< endl;
#endif
}

View File

@ -20711,3 +20711,19 @@
"Cartridge.Name" "Skeleton+ (17-04-2003) (Eric Ball) (PAL)"
"Cartridge.Sound" "Stereo"
""
"Cartridge.MD5" "278f14887d601b5e5b620f1870bc09f6"
"Cartridge.Name" "Swoops! (v0.96) (Thomas Jentzsch)"
"Cartridge.Note" "Uses the Joystick (L) and Paddle (R) Controllers"
"Controller.Right" "Paddles"
"Display.YStart" "28"
""
"Cartridge.MD5" "5d8f1ab95362acdf3426d572a6301bf2"
"Cartridge.Name" "Swoops! (v0.96) (Thomas Jentzsch) (PAL)"
"Cartridge.Note" "Uses the Joystick (L) and Paddle (R) Controllers"
"Controller.Right" "Paddles"
"Display.Format" "PAL"
"Display.YStart" "40"
"Display.Height" "240"
""

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: GameList.hxx,v 1.5 2005-06-16 00:55:59 stephena Exp $
// $Id: GameList.hxx,v 1.6 2005-10-19 00:59:51 stephena Exp $
//
// Based on code from KStella - Stella frontend
// Copyright (C) 2003-2005 Stephen Anthony
@ -38,7 +38,6 @@ class GameList
};
typedef GUI::Array<Entry> EntryList;
EntryList myArray;
public:

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.31 2005-09-15 19:43:36 stephena Exp $
// $Id: LauncherDialog.cxx,v 1.32 2005-10-19 00:59:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -245,11 +245,7 @@ void LauncherDialog::loadListFromDisk()
name = props.get("Cartridge.Name");
note = props.get("Cartridge.Note");
// Some games may not have a name, since there may not
// be an entry in stella.pro. In that case, we use the rom name
if(name == "Untitled")
name = files[idx].displayName();
// Indicate that this ROM doesn't have a properties entry
myGameList->appendGame(rom, name, note);
// Update the progress bar, indicating one more ROM has been processed
@ -333,11 +329,9 @@ string LauncherDialog::MD5FromFile(const string& path)
int size = -1;
string md5 = "";
if(instance()->openROM(path, &image, &size))
md5 = MD5(image, size);
if(size != -1)
delete[] image;
if(instance()->openROM(path, md5, &image, &size))
if(size != -1)
delete[] image;
return md5;
}