Moved the Array class from namespace GUI to Common, since it's used in

many places other than the GUI code.

As a diversion from the joystick stuff, I'm experimenting with event
recording.  Eventually, this will allow one to record a state + events,
and then load that INP file again.  When loaded, Stella will replay the
events, and you'll be able to see exactly what happened before.  Since
this is based on frames, the replaying can speed up and slow
down by changing the emulation framerate.  And it can be exited at any
point, and normal emulation can continue.  Or at least that's how I
want it to work.

A preliminary spec for the event stream is -X A B A B ... -X ...,
where X represents how many frames to wait, and 'A B' are event/value
pairs representing an event in Stella.  I think this is very similar
to the scheme that Thomas J. recently added to z26, so converting to
a Stella eventstream should be easy.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@905 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-12-09 01:16:14 +00:00
parent eaca8d857b
commit a1c490cd21
16 changed files with 121 additions and 38 deletions

View File

@ -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: CheatManager.hxx,v 1.4 2005-11-27 22:37:24 stephena Exp $ // $Id: CheatManager.hxx,v 1.5 2005-12-09 01:16:13 stephena Exp $
//============================================================================ //============================================================================
#ifndef CHEAT_MANAGER_HXX #ifndef CHEAT_MANAGER_HXX
@ -27,7 +27,7 @@
#include "Cheat.hxx" #include "Cheat.hxx"
typedef GUI::Array<Cheat*> CheatList; typedef Common::Array<Cheat*> CheatList;
typedef map<string,string> CheatCodeMap; typedef map<string,string> CheatCodeMap;
/** /**
@ -36,7 +36,7 @@ typedef map<string,string> CheatCodeMap;
the list of all cheats currently in use. the list of all cheats currently in use.
@author Stephen Anthony @author Stephen Anthony
@version $Id: CheatManager.hxx,v 1.4 2005-11-27 22:37:24 stephena Exp $ @version $Id: CheatManager.hxx,v 1.5 2005-12-09 01:16:13 stephena Exp $
*/ */
class CheatManager class CheatManager
{ {

View File

@ -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: Array.hxx,v 1.7 2005-07-14 18:28:36 stephena Exp $ // $Id: Array.hxx,v 1.1 2005-12-09 01:16:13 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -26,7 +26,7 @@
#include "bspf.hxx" #include "bspf.hxx"
namespace GUI { namespace Common {
template <class T> template <class T>
class Array class Array
@ -192,8 +192,8 @@ class Array
} // Namespace GUI } // Namespace GUI
typedef GUI::Array<int> IntArray; typedef Common::Array<int> IntArray;
typedef GUI::Array<bool> BoolArray; typedef Common::Array<bool> BoolArray;
typedef GUI::Array<uInt8> ByteArray; typedef Common::Array<uInt8> ByteArray;
#endif #endif

View File

@ -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: EquateList.hxx,v 1.11 2005-07-12 02:27:06 urchlay Exp $ // $Id: EquateList.hxx,v 1.12 2005-12-09 01:16:13 stephena Exp $
//============================================================================ //============================================================================
#ifndef EQUATELIST_HXX #ifndef EQUATELIST_HXX
@ -30,7 +30,7 @@ using namespace std;
typedef map<int, string> addrToLabel; typedef map<int, string> addrToLabel;
typedef map<string, int> labelToAddr; typedef map<string, int> labelToAddr;
typedef GUI::Array<Equate> Equates; typedef Common::Array<Equate> Equates;
class EquateList { class EquateList {
public: public:

View File

@ -13,14 +13,15 @@
// 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: Event.cxx,v 1.3 2005-06-16 01:11:27 stephena Exp $ // $Id: Event.cxx,v 1.4 2005-12-09 01:16:13 stephena Exp $
//============================================================================ //============================================================================
#include "Event.hxx" #include "Event.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Event() Event::Event()
: myNumberOfTypes(Event::LastType) : myNumberOfTypes(Event::LastType),
myEventRecordFlag(true)
{ {
// Set all of the events to 0 / false to start with // Set all of the events to 0 / false to start with
clear(); clear();
@ -29,6 +30,28 @@ Event::Event()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::~Event() Event::~Event()
{ {
int events = 0, waits = 0, totalwaits = 0;
cerr << "Event history contains " << myEventHistory.size()/2 << " events\n";
for(unsigned int i = 0; i < myEventHistory.size(); ++i)
{
int tmp = myEventHistory[i];
if(tmp < 0)
{
++waits;
totalwaits += -tmp;
}
else
++events;
cerr << tmp << " ";
}
cerr << endl
<< "events pairs = " << events/2
<< ", frame waits = " << waits
<< ", total frame waits = " << totalwaits
<< endl;
myEventHistory.clear();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -41,6 +64,13 @@ Int32 Event::get(Type type) const
void Event::set(Type type, Int32 value) void Event::set(Type type, Int32 value)
{ {
myValues[type] = value; myValues[type] = value;
// Add to history if we're in recording mode
if(myEventRecordFlag)
{
myEventHistory.push_back(type);
myEventHistory.push_back(value);
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -51,3 +81,28 @@ void Event::clear()
myValues[i] = 0; myValues[i] = 0;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Event::record(bool enable)
{
if(myEventRecordFlag == enable)
return;
else
myEventRecordFlag = enable;
if(myEventRecordFlag)
myEventHistory.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Event::nextFrame()
{
if(myEventRecordFlag)
{
int idx = myEventHistory.size() - 1;
if(idx >= 0 && myEventHistory[idx] < 0)
--myEventHistory[idx];
else
myEventHistory.push_back(-1);
}
}

View File

@ -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: Event.hxx,v 1.13 2005-08-29 18:36:41 stephena Exp $ // $Id: Event.hxx,v 1.14 2005-12-09 01:16:13 stephena Exp $
//============================================================================ //============================================================================
#ifndef EVENT_HXX #ifndef EVENT_HXX
@ -21,11 +21,12 @@
class Event; class Event;
#include "Array.hxx"
#include "bspf.hxx" #include "bspf.hxx"
/** /**
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Event.hxx,v 1.13 2005-08-29 18:36:41 stephena Exp $ @version $Id: Event.hxx,v 1.14 2005-12-09 01:16:13 stephena Exp $
*/ */
class Event class Event
{ {
@ -104,12 +105,35 @@ class Event
*/ */
virtual void clear(); virtual void clear();
/**
Returns the history for this event
*/
virtual const IntArray& history() { return myEventHistory; }
/**
Start/stop recording events to the event history
@param enable Start or stop recording
*/
virtual void record(bool enable);
/**
Indicate that a new frame has been processed
*/
virtual void nextFrame();
protected: protected:
// Number of event types there are // Number of event types there are
const Int32 myNumberOfTypes; const Int32 myNumberOfTypes;
// Array of values associated with each event type // Array of values associated with each event type
Int32 myValues[LastType]; Int32 myValues[LastType];
// Indicates if we're in recording mode
bool myEventRecordFlag;
// Stores the history/record of all events that have been set
IntArray myEventHistory;
}; };
#endif #endif

View File

@ -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.123 2005-12-08 22:30:53 stephena Exp $ // $Id: EventHandler.cxx,v 1.124 2005-12-09 01:16:13 stephena Exp $
//============================================================================ //============================================================================
#include <algorithm> #include <algorithm>
@ -737,6 +737,10 @@ void EventHandler::poll(uInt32 time)
for(unsigned int i = 0; i < cheats.size(); i++) for(unsigned int i = 0; i < cheats.size(); i++)
cheats[i]->evaluate(); cheats[i]->evaluate();
#endif #endif
// Tell the event object that another frame has finished
// This is used for event recording
myEvent->nextFrame();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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: FSNode.hxx,v 1.7 2005-06-16 00:55:58 stephena Exp $ // $Id: FSNode.hxx,v 1.8 2005-12-09 01:16:13 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -61,7 +61,7 @@ class FilesystemNode;
/** /**
* List of multiple file system nodes. E.g. the contents of a given directory. * List of multiple file system nodes. E.g. the contents of a given directory.
*/ */
class FSList : public GUI::Array<FilesystemNode> class FSList : public Common::Array<FilesystemNode>
{ {
public: public:
void sort(); void sort();

View File

@ -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: M6502.hxx,v 1.15 2005-10-11 19:38:10 stephena Exp $ // $Id: M6502.hxx,v 1.16 2005-12-09 01:16:13 stephena Exp $
//============================================================================ //============================================================================
#ifndef M6502_HXX #ifndef M6502_HXX
@ -33,7 +33,7 @@ class PackedBitArray;
#include "Array.hxx" #include "Array.hxx"
#include "StringList.hxx" #include "StringList.hxx"
typedef GUI::Array<Expression*> ExpressionList; typedef Common::Array<Expression*> ExpressionList;
/** /**
This is an abstract base class for classes that emulate the This is an abstract base class for classes that emulate the
@ -41,7 +41,7 @@ typedef GUI::Array<Expression*> ExpressionList;
has a 64K addressing space. has a 64K addressing space.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: M6502.hxx,v 1.15 2005-10-11 19:38:10 stephena Exp $ @version $Id: M6502.hxx,v 1.16 2005-12-09 01:16:13 stephena Exp $
*/ */
class M6502 class M6502
{ {

View File

@ -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: CheckListWidget.hxx,v 1.7 2005-11-27 22:37:25 stephena Exp $ // $Id: CheckListWidget.hxx,v 1.8 2005-12-09 01:16:13 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -36,7 +36,7 @@ enum CheckStyle {
kSolidFill kSolidFill
}; };
typedef GUI::Array<CheckboxWidget*> CheckboxArray; typedef Common::Array<CheckboxWidget*> CheckboxArray;
/** CheckListWidget */ /** CheckListWidget */

View File

@ -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: Dialog.hxx,v 1.21 2005-12-07 20:46:49 stephena Exp $ // $Id: Dialog.hxx,v 1.22 2005-12-09 01:16:13 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -36,7 +36,7 @@ class TabWidget;
This is the base class for all dialog boxes. This is the base class for all dialog boxes.
@author Stephen Anthony @author Stephen Anthony
@version $Id: Dialog.hxx,v 1.21 2005-12-07 20:46:49 stephena Exp $ @version $Id: Dialog.hxx,v 1.22 2005-12-09 01:16:13 stephena Exp $
*/ */
class Dialog : public GuiObject class Dialog : public GuiObject
{ {
@ -46,7 +46,7 @@ class Dialog : public GuiObject
Widget* focusedWidget; Widget* focusedWidget;
WidgetArray focusList; WidgetArray focusList;
}; };
typedef GUI::Array<Focus> FocusList; typedef Common::Array<Focus> FocusList;
public: public:
Dialog(OSystem* instance, DialogContainer* parent, Dialog(OSystem* instance, DialogContainer* parent,

View File

@ -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: GameList.hxx,v 1.6 2005-10-19 00:59:51 stephena Exp $ // $Id: GameList.hxx,v 1.7 2005-12-09 01:16:13 stephena Exp $
// //
// Based on code from KStella - Stella frontend // Based on code from KStella - Stella frontend
// Copyright (C) 2003-2005 Stephen Anthony // Copyright (C) 2003-2005 Stephen Anthony
@ -37,7 +37,7 @@ class GameList
string _note; string _note;
}; };
typedef GUI::Array<Entry> EntryList; typedef Common::Array<Entry> EntryList;
EntryList myArray; EntryList myArray;
public: public:

View File

@ -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: GuiObject.hxx,v 1.15 2005-08-31 19:15:10 stephena Exp $ // $Id: GuiObject.hxx,v 1.16 2005-12-09 01:16:13 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -30,13 +30,13 @@ class Widget;
#include "Array.hxx" #include "Array.hxx"
#include "Font.hxx" #include "Font.hxx"
typedef GUI::Array<Widget*> WidgetArray; typedef Common::Array<Widget*> WidgetArray;
/** /**
This is the base class for all GUI objects/widgets. This is the base class for all GUI objects/widgets.
@author Stephen Anthony @author Stephen Anthony
@version $Id: GuiObject.hxx,v 1.15 2005-08-31 19:15:10 stephena Exp $ @version $Id: GuiObject.hxx,v 1.16 2005-12-09 01:16:13 stephena Exp $
*/ */
class GuiObject : public CommandReceiver class GuiObject : public CommandReceiver
{ {

View File

@ -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: InputTextDialog.hxx,v 1.4 2005-11-27 22:37:25 stephena Exp $ // $Id: InputTextDialog.hxx,v 1.5 2005-12-09 01:16:14 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -29,7 +29,7 @@ class EditTextWidget;
#include "Dialog.hxx" #include "Dialog.hxx"
#include "Command.hxx" #include "Command.hxx"
typedef GUI::Array<EditTextWidget*> InputWidget; typedef Common::Array<EditTextWidget*> InputWidget;
class InputTextDialog : public Dialog, public CommandSender class InputTextDialog : public Dialog, public CommandSender
{ {

View File

@ -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: PopUpWidget.hxx,v 1.10 2005-10-02 22:09:12 stephena Exp $ // $Id: PopUpWidget.hxx,v 1.11 2005-12-09 01:16:14 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -50,7 +50,7 @@ class PopUpWidget : public Widget, public CommandSender
int tag; int tag;
}; };
typedef GUI::Array<Entry> EntryList; typedef Common::Array<Entry> EntryList;
protected: protected:
EntryList _entries; EntryList _entries;

View File

@ -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: StringList.hxx,v 1.3 2005-06-16 00:56:00 stephena Exp $ // $Id: StringList.hxx,v 1.4 2005-12-09 01:16:14 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -26,7 +26,7 @@
#include "bspf.hxx" #include "bspf.hxx"
class StringList : public GUI::Array<string> class StringList : public Common::Array<string>
{ {
public: public:
void push_back(const char *str) void push_back(const char *str)

View File

@ -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: TabWidget.hxx,v 1.9 2005-08-10 12:23:42 stephena Exp $ // $Id: TabWidget.hxx,v 1.10 2005-12-09 01:16:14 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -39,7 +39,7 @@ class TabWidget : public Widget, public CommandSender
Widget* firstWidget; Widget* firstWidget;
Widget* parentWidget; Widget* parentWidget;
}; };
typedef GUI::Array<Tab> TabList; typedef Common::Array<Tab> TabList;
public: public:
TabWidget(GuiObject* boss, int x, int y, int w, int h); TabWidget(GuiObject* boss, int x, int y, int w, int h);