Made CPU registers and program counter always show in hexidecimal.

Added 'Dec' and 'Bin' textboxes to CPU area to show the decimal and binary
equivalents for the currently selected CPU register.  This isn't done for
the PC or status registers, since I don't feel it's important for those.

Made the label textbox much longer for the PC, since there's now extra
space there.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1703 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-04-13 15:17:07 +00:00
parent cd4eb84425
commit 9d22c883d4
4 changed files with 118 additions and 90 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: Debugger.cxx,v 1.135 2009-03-26 19:46:05 stephena Exp $
// $Id: Debugger.cxx,v 1.136 2009-04-13 15:17:06 stephena Exp $
//============================================================================
#include "bspf.hxx"
@ -57,34 +57,34 @@ Debugger* Debugger::myStaticDebugger;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static const string builtin_functions[][3] = {
// { "name", "definition", "help text" }
// { "name", "definition", "help text" }
// left joystick:
{ "_joy0left", "!(*SWCHA & $40)", "Left joystick moved left" },
{ "_joy0right", "!(*SWCHA & $80)", "Left joystick moved right" },
{ "_joy0up", "!(*SWCHA & $10)", "Left joystick moved up" },
{ "_joy0down", "!(*SWCHA & $20)", "Left joystick moved down" },
{ "_joy0button", "!(*INPT4 & $80)", "Left joystick button pressed" },
// left joystick:
{ "_joy0left", "!(*SWCHA & $40)", "Left joystick moved left" },
{ "_joy0right", "!(*SWCHA & $80)", "Left joystick moved right" },
{ "_joy0up", "!(*SWCHA & $10)", "Left joystick moved up" },
{ "_joy0down", "!(*SWCHA & $20)", "Left joystick moved down" },
{ "_joy0button", "!(*INPT4 & $80)", "Left joystick button pressed" },
// right joystick:
{ "_joy1left", "!(*SWCHA & $04)", "Right joystick moved left" },
{ "_joy1right", "!(*SWCHA & $08)", "Right joystick moved right" },
{ "_joy1up", "!(*SWCHA & $01)", "Right joystick moved up" },
{ "_joy1down", "!(*SWCHA & $02)", "Right joystick moved down" },
{ "_joy1button", "!(*INPT5 & $80)", "Right joystick button pressed" },
// right joystick:
{ "_joy1left", "!(*SWCHA & $04)", "Right joystick moved left" },
{ "_joy1right", "!(*SWCHA & $08)", "Right joystick moved right" },
{ "_joy1up", "!(*SWCHA & $01)", "Right joystick moved up" },
{ "_joy1down", "!(*SWCHA & $02)", "Right joystick moved down" },
{ "_joy1button", "!(*INPT5 & $80)", "Right joystick button pressed" },
// console switches:
{ "_select", "!(*SWCHB & $02)", "Game Select pressed" },
{ "_reset", "!(*SWCHB & $01)", "Game Reset pressed" },
{ "_color", "*SWCHB & $08", "Color/BW set to Color" },
{ "_bw", "!(*SWCHB & $08)", "Color/BW set to BW" },
{ "_diff0b", "!(*SWCHB & $40)", "Left difficulty set to B (easy)" },
{ "_diff0a", "*SWCHB & $40", "Left difficulty set to A (hard)" },
{ "_diff1b", "!(*SWCHB & $80)", "Right difficulty set to B (easy)" },
{ "_diff1a", "*SWCHB & $80", "Right difficulty set to A (hard)" },
// console switches:
{ "_select", "!(*SWCHB & $02)", "Game Select pressed" },
{ "_reset", "!(*SWCHB & $01)", "Game Reset pressed" },
{ "_color", "*SWCHB & $08", "Color/BW set to Color" },
{ "_bw", "!(*SWCHB & $08)", "Color/BW set to BW" },
{ "_diff0b", "!(*SWCHB & $40)", "Left difficulty set to B (easy)" },
{ "_diff0a", "*SWCHB & $40", "Left difficulty set to A (hard)" },
{ "_diff1b", "!(*SWCHB & $80)", "Right difficulty set to B (easy)" },
{ "_diff1a", "*SWCHB & $80", "Right difficulty set to A (hard)" },
// empty string marks end of list, do not remove
{ "", "", "" }
// empty string marks end of list, do not remove
{ "", "", "" }
};
@ -325,35 +325,34 @@ string Debugger::getSourceLines(int addr) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::autoExec() {
// autoexec.stella is always run
myPrompt->print("autoExec():\n" +
myParser->exec(
myOSystem->baseDir() +
BSPF_PATH_SEPARATOR +
"autoexec.stella") +
"\n");
void Debugger::autoExec()
{
// autoexec.stella is always run
const string& autoexec = myOSystem->baseDir(false) + BSPF_PATH_SEPARATOR +
"autoexec.stella";
myPrompt->print("autoExec():\n" + myParser->exec(autoexec) + "\n");
// also, "romname.stella" if present
string file = myOSystem->romFile();
// Also, "romname.stella" if present
string file = myOSystem->romFile();
string::size_type pos;
if( (pos = file.find_last_of('.')) != string::npos ) {
file.replace(pos, file.size(), ".stella");
} else {
file += ".stella";
}
myPrompt->print("autoExec():\n" + myParser->exec(file) + "\n");
myPrompt->printPrompt();
string::size_type pos;
if( (pos = file.find_last_of('.')) != string::npos )
file.replace(pos, file.size(), ".stella");
else
file += ".stella";
// init builtins
for(int i=0; builtin_functions[i][0] != ""; i++) {
string f = builtin_functions[i][1];
int res = YaccParser::parse(f.c_str());
if(res != 0) cerr << "ERROR in builtin function!" << endl;
Expression *exp = YaccParser::getResult();
addFunction(builtin_functions[i][0], builtin_functions[i][1], exp, true);
}
myPrompt->print("autoExec():\n" + myParser->exec(file) + "\n");
myPrompt->printPrompt();
// Init builtins
for(int i = 0; builtin_functions[i][0] != ""; i++)
{
// TODO - check this for memory leaks
int res = YaccParser::parse(builtin_functions[i][1].c_str());
if(res != 0) cerr << "ERROR in builtin function!" << endl;
Expression* exp = YaccParser::getResult();
addFunction(builtin_functions[i][0], builtin_functions[i][1], exp, 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: DebuggerParser.cxx,v 1.110 2009-01-14 20:31:07 stephena Exp $
// $Id: DebuggerParser.cxx,v 1.111 2009-04-13 15:17:06 stephena Exp $
//============================================================================
#include <fstream>
@ -30,6 +30,7 @@
#include "YaccParser.hxx"
#include "M6502.hxx"
#include "Expression.hxx"
#include "FSNode.hxx"
#include "RomWidget.hxx"
#ifdef CHEATCODE_SUPPORT
@ -125,16 +126,14 @@ string DebuggerParser::run(const string& command)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string DebuggerParser::exec(const string& file, bool verbose)
{
string ret, path = file;
string ret;
int count = 0;
char buffer[256]; // FIXME: static buffers suck
if( file.find_last_of('.') == string::npos )
path += ".stella";
ifstream in(path.c_str());
FilesystemNode node(file);
ifstream in(node.getPath().c_str());
if(!in.is_open())
return red("file \"" + path + "\" not found.");
return red("file \'" + file + "\' not found.");
while( !in.eof() ) {
if(!in.getline(buffer, 255))
@ -152,7 +151,7 @@ string DebuggerParser::exec(const string& file, bool verbose)
ret += "Executed ";
ret += debugger->valueToString(count);
ret += " commands from \"";
ret += path;
ret += file;
ret += "\"\n";
return ret;
}

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: CpuWidget.cxx,v 1.15 2009-01-01 18:13:35 stephena Exp $
// $Id: CpuWidget.cxx,v 1.16 2009-04-13 15:17:07 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -32,31 +32,6 @@
#include "CpuWidget.hxx"
// ID's for the various widgets
// We need ID's, since there are more than one of several types of widgets
enum {
kPCRegID,
kCpuRegID
};
enum {
kPCRegAddr,
kSPRegAddr,
kARegAddr,
kXRegAddr,
kYRegAddr
};
enum {
kPSRegN = 0,
kPSRegV = 1,
kPSRegB = 3,
kPSRegD = 4,
kPSRegI = 5,
kPSRegZ = 6,
kPSRegC = 7
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
: Widget(boss, font, x, y, 16, 16),
@ -73,20 +48,37 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
xpos = x; ypos = y; lwidth = 4 * fontWidth;
new StaticTextWidget(boss, font, xpos, ypos+2, lwidth-2, fontHeight,
"PC:", kTextAlignLeft);
myPCGrid = new DataGridWidget(boss, font, xpos + lwidth, ypos, 1, 1, 16, 16);
myPCGrid =
new DataGridWidget(boss, font, xpos + lwidth, ypos, 1, 1, 4, 16, kBASE_16);
myPCGrid->setTarget(this);
myPCGrid->setID(kPCRegID);
addFocusWidget(myPCGrid);
// Create a read-only textbox containing the current PC label
xpos += lwidth + myPCGrid->getWidth() + 10;
myPCLabel = new EditTextWidget(boss, font, xpos, ypos, fontWidth*15,
myPCLabel = new EditTextWidget(boss, font, xpos, ypos, fontWidth*25,
lineHeight, "");
myPCLabel->setEditable(false);
// Create read-only textboxes for decimal and binary of currently selected item
ypos += myPCLabel->getHeight() + 5 + 5;
new StaticTextWidget(boss, font, xpos, ypos, 4*fontWidth, fontHeight,
"Dec:", kTextAlignLeft);
myDecValue = new EditTextWidget(boss, font, xpos+4*fontWidth + 5, ypos-2,
4*fontWidth, lineHeight, "");
myDecValue->setEditable(false);
ypos += myPCLabel->getHeight() + 5;
new StaticTextWidget(boss, font, xpos, ypos, 4*fontWidth, fontHeight,
"Bin:", kTextAlignLeft);
myBinValue = new EditTextWidget(boss, font, xpos+4*fontWidth + 5, ypos-2,
9*fontWidth, lineHeight, "");
myBinValue->setEditable(false);
// Create a 1x4 grid with labels for the other CPU registers
xpos = x; ypos += myPCGrid->getHeight() + 1;
myCpuGrid = new DataGridWidget(boss, font, xpos + lwidth, ypos, 1, 4, 8, 8);
xpos = x; ypos += myPCGrid->getHeight() + 1 - 2*(myPCLabel->getHeight() + 5) - 5;
myCpuGrid =
new DataGridWidget(boss, font, xpos + lwidth, ypos, 1, 4, 2, 8, kBASE_16);
myCpuGrid->setTarget(this);
myCpuGrid->setID(kCpuRegID);
addFocusWidget(myCpuGrid);
@ -148,6 +140,8 @@ void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case kCpuRegID:
addr = myCpuGrid->getSelectedAddr();
value = myCpuGrid->getSelectedValue();
myDecValue->setEditString(instance().debugger().valueToString(value, kBASE_10));
myBinValue->setEditString(instance().debugger().valueToString(value, kBASE_2));
break;
}
@ -181,6 +175,15 @@ void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
}
break;
case kDGSelectionChangedCmd:
if(id == kCpuRegID)
{
value = myCpuGrid->getSelectedValue();
myDecValue->setEditString(instance().debugger().valueToString(value, kBASE_10));
myBinValue->setEditString(instance().debugger().valueToString(value, kBASE_2));
}
break;
case kTWItemDataChangedCmd:
{
bool state = myPSRegister->getSelectedState();

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: CpuWidget.hxx,v 1.5 2009-01-01 18:13:35 stephena Exp $
// $Id: CpuWidget.hxx,v 1.6 2009-04-13 15:17:07 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -48,10 +48,37 @@ class CpuWidget : public Widget, public CommandSender
void fillGrid();
private:
// ID's for the various widgets
// We need ID's, since there are more than one of several types of widgets
enum {
kPCRegID,
kCpuRegID
};
enum {
kPCRegAddr,
kSPRegAddr,
kARegAddr,
kXRegAddr,
kYRegAddr
};
enum {
kPSRegN = 0,
kPSRegV = 1,
kPSRegB = 3,
kPSRegD = 4,
kPSRegI = 5,
kPSRegZ = 6,
kPSRegC = 7
};
DataGridWidget* myPCGrid;
DataGridWidget* myCpuGrid;
ToggleBitWidget* myPSRegister;
EditTextWidget* myPCLabel;
EditTextWidget* myBinValue;
EditTextWidget* myDecValue;
};
#endif