Ported prompt 'ram' command to the new DebuggerSystem functionality.

I'll be doing small commits after each subsystem is ported, to make sure
I don't do anything too destructive.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@623 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-07-08 12:36:06 +00:00
parent 15a11860c8
commit 9b780540fb
2 changed files with 24 additions and 47 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.54 2005-07-07 18:56:41 stephena Exp $ // $Id: Debugger.cxx,v 1.55 2005-07-08 12:35:53 stephena Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -43,12 +43,12 @@ Debugger::Debugger(OSystem* osystem)
mySystem(NULL), mySystem(NULL),
myParser(NULL), myParser(NULL),
myDebugger(NULL), myDebugger(NULL),
myRamDebug(NULL),
myTIAdebug(NULL),
equateList(NULL), equateList(NULL),
breakPoints(NULL), breakPoints(NULL),
readTraps(NULL), readTraps(NULL),
writeTraps(NULL), writeTraps(NULL)
myRamDebug(NULL),
myTIAdebug(NULL)
{ {
// Init parser // Init parser
myParser = new DebuggerParser(this); myParser = new DebuggerParser(this);
@ -144,9 +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 saveState();
for(int i=0; i<0x80; i++)
myOldRAM[i] = readRAM(i);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -435,27 +433,14 @@ const string Debugger::setRAM(IntArray& args) {
return ret; return ret;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 Debugger::oldRAM(uInt8 offset)
{
offset &= 0x7f;
return myOldRAM[offset];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::ramChanged(uInt8 offset)
{
offset &= 0x7f;
return (myOldRAM[offset] != readRAM(offset));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/* Warning: this method really is for dumping *RAM*, not ROM or I/O! */ /* Warning: this method really is for dumping *RAM*, not ROM or I/O! */
const string Debugger::dumpRAM(uInt8 start, uInt8 len) const string Debugger::dumpRAM()
{ {
string result; string result;
char buf[128]; char buf[128];
int bytesPerLine; int bytesPerLine;
int start = kRamStart, len = kRamSize;
switch(myParser->base()) switch(myParser->base())
{ {
@ -473,6 +458,8 @@ const string Debugger::dumpRAM(uInt8 start, uInt8 len)
return DebuggerParser::red("invalid base, this is a BUG"); return DebuggerParser::red("invalid base, this is a BUG");
} }
RamState state = (RamState&) myRamDebug->getState();
RamState oldstate = (RamState&) myRamDebug->getOldState();
for (uInt8 i = 0x00; i < len; i += bytesPerLine) for (uInt8 i = 0x00; i < len; i += bytesPerLine)
{ {
sprintf(buf, "%.2x: ", start+i); sprintf(buf, "%.2x: ", start+i);
@ -480,9 +467,7 @@ const string Debugger::dumpRAM(uInt8 start, uInt8 len)
for (uInt8 j = 0; j < bytesPerLine; j++) for (uInt8 j = 0; j < bytesPerLine; j++)
{ {
int byte = mySystem->peek(start+i+j); result += invIfChanged(state.ram[i+j], oldstate.ram[i+j]);
result += invIfChanged(byte, myOldRAM[i+j]);
result += " "; result += " ";
if(j == 0x07) result += " "; if(j == 0x07) result += " ";
@ -909,15 +894,9 @@ bool Debugger::patchROM(int addr, int value) {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::saveState() { void Debugger::saveState()
// FIXME - this will be removed when we get state saving working {
// At that point, saving state will be accomplished by calling myRamDebug->saveOldState();
// saveState() on each subsystem
for(int i=0; i<0x80; i++) {
myOldRAM[i] = readRAM(i);
}
///////////////////
myRamDebug->saveOldState();
oldA = getA(); oldA = getA();
oldX = getX(); oldX = getX();

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.43 2005-07-07 15:18:56 stephena Exp $ // $Id: Debugger.hxx,v 1.44 2005-07-08 12:36:06 stephena Exp $
//============================================================================ //============================================================================
#ifndef DEBUGGER_HXX #ifndef DEBUGGER_HXX
@ -52,7 +52,7 @@ 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.43 2005-07-07 15:18:56 stephena Exp $ @version $Id: Debugger.hxx,v 1.44 2005-07-08 12:36:06 stephena Exp $
*/ */
class Debugger : public DialogContainer class Debugger : public DialogContainer
{ {
@ -186,7 +186,7 @@ class Debugger : public DialogContainer
Return a formatted string containing the contents of the specified Return a formatted string containing the contents of the specified
device. device.
*/ */
const string dumpRAM(uInt8 start = kRamStart, uInt8 len = 0x80); const string dumpRAM();
const string dumpTIA(); const string dumpTIA();
// Read and write 128-byte RAM area // Read and write 128-byte RAM area
@ -249,13 +249,11 @@ class Debugger : public DialogContainer
bool setBank(int bank); bool setBank(int bank);
int bankCount(); int bankCount();
int getBank(); int getBank();
const char *getCartType(); const char *getCartType();
bool patchROM(int addr, int value); bool patchROM(int addr, int value);
void saveState(int state); void saveState(int state);
void loadState(int state); void loadState(int state);
uInt8 oldRAM(uInt8 offset);
bool ramChanged(uInt8 offset);
protected: protected:
const string invIfChanged(int reg, int oldReg); const string invIfChanged(int reg, int oldReg);
@ -265,15 +263,15 @@ class Debugger : public DialogContainer
DebuggerParser* myParser; DebuggerParser* myParser;
D6502* myDebugger; D6502* myDebugger;
RamDebug *myRamDebug;
TIADebug *myTIAdebug;
EquateList *equateList; EquateList *equateList;
PackedBitArray *breakPoints; PackedBitArray *breakPoints;
PackedBitArray *readTraps; PackedBitArray *readTraps;
PackedBitArray *writeTraps; PackedBitArray *writeTraps;
PromptWidget *myPrompt; PromptWidget *myPrompt;
RamDebug *myRamDebug;
TIADebug *myTIAdebug;
uInt8 myOldRAM[128];
int oldA; int oldA;
int oldX; int oldX;
int oldY; int oldY;