Some cleanups for the RomListWidget. Separated the disassembly

stuff into their own columns, making things easier to read but also
making it much easier to edit specific parts of a line.

Still TODO is actually patch ROM when editing the 'bytes' field,
and also possibly edit the label field (which would translate to
creating a new define at that address).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@758 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-09-01 19:14:09 +00:00
parent 797cf67ee7
commit e0490c08c7
5 changed files with 88 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.90 2005-08-31 19:15:10 stephena Exp $ // $Id: Debugger.cxx,v 1.91 2005-09-01 19:14:09 stephena Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -782,38 +782,31 @@ const string& Debugger::disassemble(int start, int lines) {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::disassemble(StringList& addrLabel, IntArray& addr, void Debugger::disassemble(IntArray& addr, StringList& addrLabel,
StringList& data, int start, int lines) StringList& bytes, StringList& data,
int start, int lines)
{ {
char buf[255], bbuf[255]; char buf[255], bbuf[255];
string result; string tmp;
do { do
result = ""; {
tmp = equateList->getFormatted(start, 4);
const char *label = equateList->getFormatted(start, 4); addrLabel.push_back(tmp + ":");
addrLabel.push_back(label);
addr.push_back(start); addr.push_back(start);
result += label;
result += ": ";
int count = myCpuDebug->disassemble(start, buf, equateList); int count = myCpuDebug->disassemble(start, buf, equateList);
tmp = "";
for(int i=0; i<count; i++) { for(int i=0; i<count; i++) {
sprintf(bbuf, "%02x ", peek(start++)); sprintf(bbuf, "%02x ", peek(start++));
result += bbuf; tmp += bbuf;
} }
bytes.push_back(tmp);
if(count < 3) result += " "; data.push_back(buf);
if(count < 2) result += " "; }
while(--lines > 0 && start <= 0xffff);
result += " ";
result += buf;
data.push_back(result);
} while(--lines > 0 && start <= 0xffff);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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.73 2005-08-31 19:15:10 stephena Exp $ // $Id: Debugger.hxx,v 1.74 2005-09-01 19:14:09 stephena Exp $
//============================================================================ //============================================================================
#ifndef DEBUGGER_HXX #ifndef DEBUGGER_HXX
@ -77,7 +77,7 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)();
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.73 2005-08-31 19:15:10 stephena Exp $ @version $Id: Debugger.hxx,v 1.74 2005-09-01 19:14:09 stephena Exp $
*/ */
class Debugger : public DialogContainer class Debugger : public DialogContainer
{ {
@ -186,10 +186,11 @@ class Debugger : public DialogContainer
/** /**
Disassemble from the starting address the specified number of lines Disassemble from the starting address the specified number of lines
and place addresses and data in given arrays. and place addresses, bytes and data in given arrays.
*/ */
void disassemble(StringList& addrLabel, IntArray& addr, void disassemble(IntArray& addr, StringList& addrLabel,
StringList& data, int start, int lines); StringList& bytes, StringList& data,
int start, int lines);
int step(); int step();
int trace(); int trace();

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: RomListWidget.cxx,v 1.2 2005-08-31 19:15:10 stephena Exp $ // $Id: RomListWidget.cxx,v 1.3 2005-09-01 19:14:09 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,8 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& font,
myMenu(NULL), myMenu(NULL),
myHighlightedItem(-1) myHighlightedItem(-1)
{ {
myMenu = new ContextMenu(this, instance()->consoleFont()); setFont(font);
myMenu = new ContextMenu(this, font);
StringList l; StringList l;
l.push_back("Add bookmark"); l.push_back("Add bookmark");
@ -39,6 +40,9 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& font,
l.push_back("Set PC"); l.push_back("Set PC");
myMenu->setList(l); myMenu->setList(l);
myLabelWidth = font.getMaxCharWidth() * 16;
myBytesWidth = font.getMaxCharWidth() * 12;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -47,6 +51,16 @@ RomListWidget::~RomListWidget()
delete myMenu; delete myMenu;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListWidget::setList(StringList& label, StringList& bytes, StringList& disasm,
BoolArray& state)
{
myLabel = label;
myDisasm = disasm;
CheckListWidget::setList(bytes, state);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListWidget::handleMouseDown(int x, int y, int button, int clickCount) void RomListWidget::handleMouseDown(int x, int y, int button, int clickCount)
{ {
@ -56,8 +70,8 @@ void RomListWidget::handleMouseDown(int x, int y, int button, int clickCount)
myMenu->setPos(x + getAbsX(), y + getAbsY()); myMenu->setPos(x + getAbsX(), y + getAbsY());
myMenu->show(); myMenu->show();
} }
else
ListWidget::handleMouseDown(x, y, button, clickCount); ListWidget::handleMouseDown(x, y, button, clickCount);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -101,29 +115,38 @@ void RomListWidget::drawWidget(bool hilite)
const int y = _y + 2 + _rowHeight * i; const int y = _y + 2 + _rowHeight * i;
GUI::Rect r(getEditRect()); GUI::Rect l = getLineRect();
GUI::Rect r = getEditRect();
// Draw highlighted item inverted, on a highlighted background. // Draw highlighted item in a frame
if (_highlightedItem == pos) if (_highlightedItem == pos)
{ {
fb.fillRect(_x + r.left - 3, _y + 1 + _rowHeight * i, fb.frameRect(_x + l.left - 3, _y + 1 + _rowHeight * i,
_w - r.left, _rowHeight, _w - l.left, _rowHeight,
kHiliteColor); kHiliteColor);
} }
// Draw the selected item inverted, on a highlighted background. // Draw the selected item inverted, on a highlighted background.
if (_selectedItem == pos) if (_selectedItem == pos && _hasFocus)
{ {
if (_hasFocus && !_editMode) if (!_editMode)
fb.fillRect(_x + r.left - 3, _y + 1 + _rowHeight * i, fb.fillRect(_x + r.left - 3, _y + 1 + _rowHeight * i,
_w - r.left, _rowHeight, r.width(), _rowHeight,
kTextColorHi); kTextColorHi);
else else
fb.frameRect(_x + r.left - 3, _y + 1 + _rowHeight * i, fb.frameRect(_x + r.left - 3, _y + 1 + _rowHeight * i,
_w - r.left, _rowHeight, r.width(), _rowHeight,
kTextColorHi); kTextColorHi);
} }
// Draw labels and actual disassembly
fb.drawString(_font, myLabel[pos], _x + r.left - myLabelWidth, y,
myLabelWidth, kTextColor);
fb.drawString(_font, myDisasm[pos], _x + r.right, y,
_w - r.right, kTextColor);
// Draw editable bytes
if (_selectedItem == pos && _editMode) if (_selectedItem == pos && _editMode)
{ {
buffer = _editString; buffer = _editString;
@ -148,7 +171,7 @@ void RomListWidget::drawWidget(bool hilite)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GUI::Rect RomListWidget::getEditRect() const GUI::Rect RomListWidget::getLineRect() const
{ {
GUI::Rect r(2, 1, _w, _rowHeight); GUI::Rect r(2, 1, _w, _rowHeight);
const int yoffset = (_selectedItem - _currentPos) * _rowHeight, const int yoffset = (_selectedItem - _currentPos) * _rowHeight,
@ -160,3 +183,17 @@ GUI::Rect RomListWidget::getEditRect() const
return r; return r;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GUI::Rect RomListWidget::getEditRect() const
{
GUI::Rect r(2, 1, _w, _rowHeight);
const int yoffset = (_selectedItem - _currentPos) * _rowHeight,
xoffset = CheckboxWidget::boxSize() + 10;
r.top += yoffset;
r.bottom += yoffset;
r.left += xoffset + myLabelWidth;
r.right = r.left + myBytesWidth;
return r;
}

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: RomListWidget.hxx,v 1.2 2005-08-31 19:15:10 stephena Exp $ // $Id: RomListWidget.hxx,v 1.3 2005-09-01 19:14:09 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,16 +36,24 @@ class RomListWidget : public CheckListWidget
int x, int y, int w, int h); int x, int y, int w, int h);
virtual ~RomListWidget(); virtual ~RomListWidget();
void setList(StringList& label, StringList& bytes, StringList& disasm,
BoolArray& state);
protected: protected:
void handleMouseDown(int x, int y, int button, int clickCount); void handleMouseDown(int x, int y, int button, int clickCount);
void handleCommand(CommandSender* sender, int cmd, int data, int id); void handleCommand(CommandSender* sender, int cmd, int data, int id);
void drawWidget(bool hilite); void drawWidget(bool hilite);
GUI::Rect getLineRect() const;
GUI::Rect getEditRect() const; GUI::Rect getEditRect() const;
private: private:
ContextMenu* myMenu; ContextMenu* myMenu;
int myHighlightedItem; int myHighlightedItem;
int myLabelWidth;
int myBytesWidth;
StringList myLabel, myDisasm;
}; };
#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: RomWidget.cxx,v 1.1 2005-08-30 17:51:26 stephena Exp $ // $Id: RomWidget.cxx,v 1.2 2005-09-01 19:14:09 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
@ -114,13 +114,15 @@ void RomWidget::initialUpdate()
; // FIXME ; // FIXME
else else
{ {
StringList label, data; // Clear old mappings
BoolArray state;
myAddrList.clear(); myAddrList.clear();
myLineList.clear(); myLineList.clear();
StringList label, data, disasm;
BoolArray state;
// Disassemble entire bank (up to 4096 lines) // Disassemble entire bank (up to 4096 lines)
dbg.disassemble(label, myAddrList, data, 0xf000, 4096); dbg.disassemble(myAddrList, label, data, disasm, 0xf000, 4096);
for(unsigned int i = 0; i < data.size(); ++i) for(unsigned int i = 0; i < data.size(); ++i)
state.push_back(false); state.push_back(false);
@ -129,7 +131,7 @@ void RomWidget::initialUpdate()
for(unsigned int i = 0; i < myAddrList.size(); ++i) for(unsigned int i = 0; i < myAddrList.size(); ++i)
myLineList.insert(make_pair(myAddrList[i], i)); myLineList.insert(make_pair(myAddrList[i], i));
myRomList->setList(data, state); myRomList->setList(label, data, disasm, state);
} }
} }