Added DebuggerSystem and DebuggerState classes to clean up the unwieldy

Debugger class.  There will be a subsystem for each GUI debugger tab,
and it will have responsibility for all thing related to that tab,
eliminating a lot of code from Debugger class.

Added RamDebug class, and changed the GUI RAM tab to use the new RamDebug
subsystem.  The prompt still uses the old method, which will have to be
fixed.  At that point, Debugger::(readRAM, writeRAM, ramChanged) can be
eliminated.  If the Debugger ever wants to access RAM related things,
it should refer to RamDebug.

Still TODO is create a CpuDebug subsystem, and turn the current TIADebug
into a real subsystem.

Cleaned up some redundant typedefs (changed AddrList/ValueList to
IntArray).  As well, we're moving away from having bspf stuff seeded
throughout the system.  Integer values will be stored/passed around as
'int', and truncated where necessary as close to the given method as
possible.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@615 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-07-07 15:19:04 +00:00
parent ad5ab7be92
commit c3fab46791
13 changed files with 242 additions and 54 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: Debugger.cxx,v 1.52 2005-07-07 02:30:48 urchlay Exp $ // $Id: Debugger.cxx,v 1.53 2005-07-07 15:18:55 stephena Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -33,6 +33,7 @@
#include "Debugger.hxx" #include "Debugger.hxx"
#include "EquateList.hxx" #include "EquateList.hxx"
#include "RamDebug.hxx"
#include "TIADebug.hxx" #include "TIADebug.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -46,6 +47,7 @@ Debugger::Debugger(OSystem* osystem)
breakPoints(NULL), breakPoints(NULL),
readTraps(NULL), readTraps(NULL),
writeTraps(NULL), writeTraps(NULL),
myRamDebug(NULL),
myTIAdebug(NULL) myTIAdebug(NULL)
{ {
// Init parser // Init parser
@ -63,6 +65,7 @@ Debugger::~Debugger()
{ {
delete myParser; delete myParser;
delete myDebugger; delete myDebugger;
delete myRamDebug;
delete myTIAdebug; delete myTIAdebug;
delete equateList; delete equateList;
delete breakPoints; delete breakPoints;
@ -123,6 +126,10 @@ void Debugger::setConsole(Console* console)
myConsole = console; myConsole = console;
mySystem = &(myConsole->system()); mySystem = &(myConsole->system());
// Create debugger subsystems
delete myRamDebug;
myRamDebug = new RamDebug(this);
// Create a new TIA debugger for this console // Create a new TIA debugger for this console
// This code is somewhat ugly, since we derive a TIA from the MediaSource // This code is somewhat ugly, since we derive a TIA from the MediaSource
// for no particular reason. Maybe it's better to make the TIA be the // for no particular reason. Maybe it's better to make the TIA be the
@ -137,6 +144,7 @@ void Debugger::setConsole(Console* console)
autoLoadSymbols(myOSystem->romFile()); autoLoadSymbols(myOSystem->romFile());
// FIXME - use the new RamDebug state stuff, and this is eliminated entirely
for(int i=0; i<0x80; i++) for(int i=0; i<0x80; i++)
myOldRAM[i] = readRAM(i); myOldRAM[i] = readRAM(i);
} }
@ -549,7 +557,7 @@ void Debugger::loadState(int state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Debugger::step() int Debugger::step()
{ {
saveRegs(); saveState();
int cyc = mySystem->cycles(); int cyc = mySystem->cycles();
mySystem->m6502().execute(1); mySystem->m6502().execute(1);
@ -575,7 +583,7 @@ int Debugger::trace()
{ {
// 32 is the 6502 JSR instruction: // 32 is the 6502 JSR instruction:
if(mySystem->peek(myDebugger->pc()) == 32) { if(mySystem->peek(myDebugger->pc()) == 32) {
saveRegs(); saveState();
int cyc = mySystem->cycles(); int cyc = mySystem->cycles();
int targetPC = myDebugger->pc() + 3; // return address int targetPC = myDebugger->pc() + 3; // return address
@ -807,7 +815,7 @@ string Debugger::disassemble(int start, int lines) {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::nextFrame(int frames) { void Debugger::nextFrame(int frames) {
saveRegs(); saveState();
myOSystem->frameBuffer().advance(frames); myOSystem->frameBuffer().advance(frames);
} }
@ -901,10 +909,16 @@ bool Debugger::patchROM(int addr, int value) {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::saveRegs() { void Debugger::saveState() {
// FIXME - this will be removed when we get state saving working
// At that point, saving state will be accomplished by calling
// saveState() on each subsystem
for(int i=0; i<0x80; i++) { for(int i=0; i<0x80; i++) {
myOldRAM[i] = readRAM(i); myOldRAM[i] = readRAM(i);
} }
///////////////////
myRamDebug->saveOldState();
oldA = getA(); oldA = getA();
oldX = getX(); oldX = getX();
oldY = getY(); oldY = getY();

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: Debugger.hxx,v 1.42 2005-07-07 02:30:48 urchlay Exp $ // $Id: Debugger.hxx,v 1.43 2005-07-07 15:18:56 stephena Exp $
//============================================================================ //============================================================================
#ifndef DEBUGGER_HXX #ifndef DEBUGGER_HXX
@ -24,6 +24,8 @@ class OSystem;
class Console; class Console;
class System; class System;
class D6502; class D6502;
class RamDebug;
class TIADebug;
#include "DialogContainer.hxx" #include "DialogContainer.hxx"
#include "M6502.hxx" #include "M6502.hxx"
@ -31,7 +33,6 @@ class D6502;
#include "EquateList.hxx" #include "EquateList.hxx"
#include "PackedBitArray.hxx" #include "PackedBitArray.hxx"
#include "PromptWidget.hxx" #include "PromptWidget.hxx"
#include "TIADebug.hxx"
#include "bspf.hxx" #include "bspf.hxx"
enum { enum {
@ -51,11 +52,13 @@ enum {
for all debugging operations in Stella (parser, 6502 debugger, etc). for all debugging operations in Stella (parser, 6502 debugger, etc).
@author Stephen Anthony @author Stephen Anthony
@version $Id: Debugger.hxx,v 1.42 2005-07-07 02:30:48 urchlay Exp $ @version $Id: Debugger.hxx,v 1.43 2005-07-07 15:18:56 stephena Exp $
*/ */
class Debugger : public DialogContainer class Debugger : public DialogContainer
{ {
friend class DebuggerParser; friend class DebuggerParser;
friend class RamDebug;
friend class TIADebug;
public: public:
/** /**
@ -84,10 +87,13 @@ class Debugger : public DialogContainer
*/ */
void setConsole(Console* console); void setConsole(Console* console);
/* save registers to oldA, oldX, etc. */ /* Save state of each debugger subsystem */
void saveRegs(); void saveState();
/* return the TIADebugger, since the GUI needs it */ /* The debugger subsystem responsible for all RAM state */
RamDebug& ramDebug() { return *myRamDebug; }
/* The debugger subsystem responsible for all TIA state */
TIADebug& tiaDebug() { return *myTIAdebug; } TIADebug& tiaDebug() { return *myTIAdebug; }
/** Convenience methods to convert to hexidecimal values */ /** Convenience methods to convert to hexidecimal values */
@ -264,6 +270,7 @@ class Debugger : public DialogContainer
PackedBitArray *readTraps; PackedBitArray *readTraps;
PackedBitArray *writeTraps; PackedBitArray *writeTraps;
PromptWidget *myPrompt; PromptWidget *myPrompt;
RamDebug *myRamDebug;
TIADebug *myTIAdebug; TIADebug *myTIAdebug;
uInt8 myOldRAM[128]; uInt8 myOldRAM[128];
@ -273,7 +280,6 @@ class Debugger : public DialogContainer
int oldS; int oldS;
int oldP; int oldP;
int oldPC; int oldPC;
}; };
#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: DebuggerParser.cxx,v 1.47 2005-07-03 08:15:31 urchlay Exp $ // $Id: DebuggerParser.cxx,v 1.48 2005-07-07 15:18:57 stephena Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -1195,7 +1195,7 @@ void DebuggerParser::executeRom() {
// "run" // "run"
void DebuggerParser::executeRun() { void DebuggerParser::executeRun() {
debugger->saveRegs(); debugger->saveState();
debugger->quit(); debugger->quit();
commandResult = "exiting debugger"; commandResult = "exiting debugger";
} }
@ -1233,7 +1233,6 @@ void DebuggerParser::executeSavesym() {
// "step" // "step"
void DebuggerParser::executeStep() { void DebuggerParser::executeStep() {
debugger->saveRegs();
int cycles = debugger->step(); int cycles = debugger->step();
commandResult = "executed "; commandResult = "executed ";
commandResult += debugger->valueToString(cycles); commandResult += debugger->valueToString(cycles);
@ -1247,7 +1246,6 @@ void DebuggerParser::executeTia() {
// "trace" // "trace"
void DebuggerParser::executeTrace() { void DebuggerParser::executeTrace() {
debugger->saveRegs();
int cycles = debugger->trace(); int cycles = debugger->trace();
commandResult = "executed "; commandResult = "executed ";
commandResult += debugger->valueToString(cycles); commandResult += debugger->valueToString(cycles);

View File

@ -0,0 +1,56 @@
//============================================================================
//
// 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
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerSystem.hxx,v 1.1 2005-07-07 15:18:58 stephena Exp $
//============================================================================
#ifndef DEBUGGER_SYSTEM_HXX
#define DEBUGGER_SYSTEM_HXX
#include "Debugger.hxx"
/**
The DebuggerState class is used as a base class for state in all
DebuggerSystem objects. We make it a class so we can take advantage
of the copy constructor.
*/
class DebuggerState
{
public:
DebuggerState() { }
~DebuggerState() { }
};
/**
The base class for all debugger objects. Its real purpose is to
clean up the Debugger API, partitioning it into separate
subsystems.
*/
class DebuggerSystem
{
public:
DebuggerSystem(Debugger* dbg) { myDebugger = dbg; }
virtual ~DebuggerSystem() { };
virtual DebuggerState& getState() = 0;
virtual DebuggerState& getOldState() = 0;
virtual void saveOldState() = 0;
protected:
Debugger* myDebugger;
};
#endif

View File

@ -0,0 +1,59 @@
//============================================================================
//
// 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
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: RamDebug.cxx,v 1.1 2005-07-07 15:18:58 stephena Exp $
//============================================================================
#include "Array.hxx"
#include "RamDebug.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RamDebug::RamDebug(Debugger* dbg)
: DebuggerSystem(dbg)
{
saveOldState();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DebuggerState& RamDebug::getState()
{
myState.ram.clear();
for(int i=0; i<0x80; i++)
myState.ram.push_back(myDebugger->readRAM(i));
return myState;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RamDebug::saveOldState()
{
myOldState.ram.clear();
for(int i=0; i<0x80; i++)
myOldState.ram.push_back(myDebugger->readRAM(i));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int RamDebug::read(int offset)
{
offset &= 0x7f; // there are only 128 bytes
return myDebugger->mySystem->peek(offset + 0x80);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RamDebug::write(int offset, int value)
{
offset &= 0x7f; // there are only 128 bytes
myDebugger->mySystem->poke(offset + 0x80, value);
}

View File

@ -0,0 +1,49 @@
//============================================================================
//
// 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
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: RamDebug.hxx,v 1.1 2005-07-07 15:18:58 stephena Exp $
//============================================================================
#ifndef RAM_DEBUG_HXX
#define RAM_DEBUG_HXX
#include "Array.hxx"
#include "DebuggerSystem.hxx"
class RamState : public DebuggerState
{
public:
IntArray ram;
};
class RamDebug : public DebuggerSystem
{
public:
RamDebug(Debugger* dbg);
DebuggerState& getState();
DebuggerState& getOldState() { return myOldState; }
void saveOldState();
int read(int offset);
void write(int offset, int value);
private:
RamState myState;
RamState myOldState;
};
#endif

View File

@ -5,6 +5,7 @@ MODULE_OBJS := \
src/debugger/DebuggerParser.o \ src/debugger/DebuggerParser.o \
src/debugger/EquateList.o \ src/debugger/EquateList.o \
src/debugger/PackedBitArray.o \ src/debugger/PackedBitArray.o \
src/debugger/RamDebug.o \
src/debugger/TIADebug.o src/debugger/TIADebug.o
MODULE_DIRS += \ MODULE_DIRS += \

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: CpuWidget.cxx,v 1.12 2005-07-06 19:09:26 stephena Exp $ // $Id: CpuWidget.cxx,v 1.13 2005-07-07 15:19:01 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
@ -222,8 +222,8 @@ void CpuWidget::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuWidget::fillGrid() void CpuWidget::fillGrid()
{ {
AddrList alist; IntArray alist;
ValueList vlist; IntArray vlist;
BoolArray changed; BoolArray changed;
// We push the enumerated items as addresses, and deal with the real // We push the enumerated items as addresses, and deal with the real

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: DataGridWidget.cxx,v 1.12 2005-07-05 18:00:05 stephena Exp $ // $Id: DataGridWidget.cxx,v 1.13 2005-07-07 15:19:04 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
@ -65,9 +65,15 @@ DataGridWidget::~DataGridWidget()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DataGridWidget::setList(const AddrList& alist, const ValueList& vlist, void DataGridWidget::setList(const IntArray& alist, const IntArray& vlist,
const BoolArray& changed) const BoolArray& changed)
{ {
/*
cerr << "alist.size() = " << alist.size()
<< ", vlist.size() = " << vlist.size()
<< ", changed.size() = " << changed.size()
<< ", _rows*_cols = " << _rows * _cols << endl << endl;
*/
int size = vlist.size(); // assume the alist is the same size int size = vlist.size(); // assume the alist is the same size
assert(size == _rows * _cols); assert(size == _rows * _cols);

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: DataGridWidget.hxx,v 1.8 2005-07-06 15:09:15 stephena Exp $ // $Id: DataGridWidget.hxx,v 1.9 2005-07-07 15:19:04 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
@ -31,9 +31,6 @@
#include "Array.hxx" #include "Array.hxx"
#include "Rect.hxx" #include "Rect.hxx"
typedef GUI::Array<int> AddrList;
typedef GUI::Array<int> ValueList;
// Some special commands // Some special commands
enum { enum {
kDGItemDoubleClickedCmd = 'DGdb', kDGItemDoubleClickedCmd = 'DGdb',
@ -58,7 +55,7 @@ class DataGridWidget : public EditableWidget, public CommandSender
int colchars, int bits, BaseFormat format = kBASE_DEFAULT); int colchars, int bits, BaseFormat format = kBASE_DEFAULT);
virtual ~DataGridWidget(); virtual ~DataGridWidget();
void setList(const AddrList& alist, const ValueList& vlist, void setList(const IntArray& alist, const IntArray& vlist,
const BoolArray& changed); const BoolArray& changed);
void setSelectedValue(int value); void setSelectedValue(int value);
@ -101,8 +98,8 @@ class DataGridWidget : public EditableWidget, public CommandSender
BaseFormat _base; BaseFormat _base;
AddrList _addrList; IntArray _addrList;
ValueList _valueList; IntArray _valueList;
StringList _addrStringList; StringList _addrStringList;
StringList _valueStringList; StringList _valueStringList;
BoolArray _changedList; BoolArray _changedList;

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: RamWidget.cxx,v 1.16 2005-07-06 19:09:26 stephena Exp $ // $Id: RamWidget.cxx,v 1.17 2005-07-07 15:19:04 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
@ -25,10 +25,10 @@
#include "FrameBuffer.hxx" #include "FrameBuffer.hxx"
#include "GuiUtils.hxx" #include "GuiUtils.hxx"
#include "GuiObject.hxx" #include "GuiObject.hxx"
#include "Debugger.hxx"
#include "Widget.hxx" #include "Widget.hxx"
#include "EditTextWidget.hxx" #include "EditTextWidget.hxx"
#include "DataGridWidget.hxx" #include "DataGridWidget.hxx"
#include "RamDebug.hxx"
#include "RamWidget.hxx" #include "RamWidget.hxx"
@ -42,7 +42,6 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h)
int lwidth = 30; int lwidth = 30;
const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24; const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24;
const GUI::Font& font = instance()->consoleFont(); const GUI::Font& font = instance()->consoleFont();
_oldValueList = new ValueList;
// Create a 16x8 grid holding byte values (16 x 8 = 128 RAM bytes) with labels // Create a 16x8 grid holding byte values (16 x 8 = 128 RAM bytes) with labels
myRamGrid = new DataGridWidget(boss, xpos+lwidth + 5, ypos, 16, 8, 2, 8, kBASE_16); myRamGrid = new DataGridWidget(boss, xpos+lwidth + 5, ypos, 16, 8, 2, 8, kBASE_16);
@ -143,7 +142,6 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RamWidget::~RamWidget() RamWidget::~RamWidget()
{ {
delete _oldValueList;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -155,8 +153,7 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
int addr, value; int addr, value;
const char* buf; const char* buf;
Debugger& dbg = instance()->debugger(); RamDebug& dbg = instance()->debugger().ramDebug();
switch(cmd) switch(cmd)
{ {
case kDGItemDataChangedCmd: case kDGItemDataChangedCmd:
@ -164,13 +161,13 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
value = myRamGrid->getSelectedValue(); value = myRamGrid->getSelectedValue();
myUndoAddress = addr; myUndoAddress = addr;
myUndoValue = dbg.readRAM(addr - kRamStart); myUndoValue = dbg.read(addr);
instance()->debugger().writeRAM(addr - kRamStart, value); dbg.write(addr, value);
myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10)); myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10));
myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2)); myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2));
myRevertButton->setFlags(WIDGET_ENABLED); myRevertButton->setEnabled(true);
myUndoButton->setFlags(WIDGET_ENABLED); myUndoButton->setEnabled(true);
break; break;
case kDGSelectionChangedCmd: case kDGSelectionChangedCmd:
@ -187,12 +184,12 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case kRevertCmd: case kRevertCmd:
for(unsigned int i = 0; i < kRamSize; i++) for(unsigned int i = 0; i < kRamSize; i++)
dbg.writeRAM(i, (*_oldValueList)[i]); dbg.write(i, _oldValueList[i]);
fillGrid(true); fillGrid(true);
break; break;
case kUndoCmd: case kUndoCmd:
dbg.writeRAM(myUndoAddress - kRamStart, myUndoValue); dbg.write(myUndoAddress, myUndoValue);
myUndoButton->setEnabled(false); myUndoButton->setEnabled(false);
fillGrid(false); fillGrid(false);
break; break;
@ -212,19 +209,24 @@ void RamWidget::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RamWidget::fillGrid(bool updateOld) void RamWidget::fillGrid(bool updateOld)
{ {
AddrList alist; IntArray alist;
ValueList vlist; IntArray vlist;
BoolArray changed; BoolArray changed;
if(updateOld) _oldValueList->clear(); if(updateOld) _oldValueList.clear();
Debugger& dbg = instance()->debugger(); RamDebug& dbg = instance()->debugger().ramDebug();
for(unsigned int i = 0; i < kRamSize; i++)
RamState state = (RamState&) dbg.getState();
RamState oldstate = (RamState&) dbg.getOldState();
vlist = state.ram;
if(updateOld) _oldValueList = state.ram;
for(unsigned int i = 0; i < 16*8; i++)
{ {
alist.push_back(kRamStart + i); alist.push_back(i);
vlist.push_back(dbg.readRAM(i)); changed.push_back(state.ram[i] != oldstate.ram[i]);
if(updateOld) _oldValueList->push_back(dbg.readRAM(i));
changed.push_back(dbg.ramChanged(i));
} }
myRamGrid->setList(alist, vlist, changed); myRamGrid->setList(alist, vlist, changed);

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: RamWidget.hxx,v 1.7 2005-07-05 18:00:05 stephena Exp $ // $Id: RamWidget.hxx,v 1.8 2005-07-07 15:19:04 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
@ -65,7 +65,7 @@ class RamWidget : public Widget, public CommandSender
ButtonWidget *myRevertButton; ButtonWidget *myRevertButton;
ButtonWidget *myUndoButton; ButtonWidget *myUndoButton;
ValueList *_oldValueList; IntArray _oldValueList;
}; };
#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: TiaWidget.cxx,v 1.4 2005-07-06 19:09:26 stephena Exp $ // $Id: TiaWidget.cxx,v 1.5 2005-07-07 15:19:04 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
@ -239,8 +239,8 @@ void TiaWidget::fillGrid()
{ {
// FIXME - have these widget get correct values from TIADebug // FIXME - have these widget get correct values from TIADebug
Debugger& dbg = instance()->debugger(); Debugger& dbg = instance()->debugger();
AddrList alist; IntArray alist;
ValueList vlist; IntArray vlist;
BoolArray changed; BoolArray changed;
// TIA RAM // TIA RAM