mirror of https://github.com/stella-emu/stella.git
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:
parent
797cf67ee7
commit
e0490c08c7
|
@ -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.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"
|
||||
|
@ -782,38 +782,31 @@ const string& Debugger::disassemble(int start, int lines) {
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::disassemble(StringList& addrLabel, IntArray& addr,
|
||||
StringList& data, int start, int lines)
|
||||
void Debugger::disassemble(IntArray& addr, StringList& addrLabel,
|
||||
StringList& bytes, StringList& data,
|
||||
int start, int lines)
|
||||
{
|
||||
char buf[255], bbuf[255];
|
||||
string result;
|
||||
string tmp;
|
||||
|
||||
do {
|
||||
result = "";
|
||||
|
||||
const char *label = equateList->getFormatted(start, 4);
|
||||
addrLabel.push_back(label);
|
||||
do
|
||||
{
|
||||
tmp = equateList->getFormatted(start, 4);
|
||||
addrLabel.push_back(tmp + ":");
|
||||
addr.push_back(start);
|
||||
|
||||
result += label;
|
||||
result += ": ";
|
||||
|
||||
int count = myCpuDebug->disassemble(start, buf, equateList);
|
||||
|
||||
tmp = "";
|
||||
for(int i=0; i<count; i++) {
|
||||
sprintf(bbuf, "%02x ", peek(start++));
|
||||
result += bbuf;
|
||||
tmp += bbuf;
|
||||
}
|
||||
bytes.push_back(tmp);
|
||||
|
||||
if(count < 3) result += " ";
|
||||
if(count < 2) result += " ";
|
||||
|
||||
result += " ";
|
||||
result += buf;
|
||||
|
||||
data.push_back(result);
|
||||
|
||||
} while(--lines > 0 && start <= 0xffff);
|
||||
data.push_back(buf);
|
||||
}
|
||||
while(--lines > 0 && start <= 0xffff);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -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.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
|
||||
|
@ -77,7 +77,7 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)();
|
|||
for all debugging operations in Stella (parser, 6502 debugger, etc).
|
||||
|
||||
@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
|
||||
{
|
||||
|
@ -186,10 +186,11 @@ class Debugger : public DialogContainer
|
|||
|
||||
/**
|
||||
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,
|
||||
StringList& data, int start, int lines);
|
||||
void disassemble(IntArray& addr, StringList& addrLabel,
|
||||
StringList& bytes, StringList& data,
|
||||
int start, int lines);
|
||||
|
||||
int step();
|
||||
int trace();
|
||||
|
|
|
@ -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: 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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -29,7 +29,8 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& font,
|
|||
myMenu(NULL),
|
||||
myHighlightedItem(-1)
|
||||
{
|
||||
myMenu = new ContextMenu(this, instance()->consoleFont());
|
||||
setFont(font);
|
||||
myMenu = new ContextMenu(this, font);
|
||||
|
||||
StringList l;
|
||||
l.push_back("Add bookmark");
|
||||
|
@ -39,6 +40,9 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& font,
|
|||
l.push_back("Set PC");
|
||||
|
||||
myMenu->setList(l);
|
||||
|
||||
myLabelWidth = font.getMaxCharWidth() * 16;
|
||||
myBytesWidth = font.getMaxCharWidth() * 12;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -47,6 +51,16 @@ RomListWidget::~RomListWidget()
|
|||
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)
|
||||
{
|
||||
|
@ -56,8 +70,8 @@ void RomListWidget::handleMouseDown(int x, int y, int button, int clickCount)
|
|||
myMenu->setPos(x + getAbsX(), y + getAbsY());
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
fb.fillRect(_x + r.left - 3, _y + 1 + _rowHeight * i,
|
||||
_w - r.left, _rowHeight,
|
||||
kHiliteColor);
|
||||
fb.frameRect(_x + l.left - 3, _y + 1 + _rowHeight * i,
|
||||
_w - l.left, _rowHeight,
|
||||
kHiliteColor);
|
||||
}
|
||||
|
||||
// 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,
|
||||
_w - r.left, _rowHeight,
|
||||
r.width(), _rowHeight,
|
||||
kTextColorHi);
|
||||
else
|
||||
fb.frameRect(_x + r.left - 3, _y + 1 + _rowHeight * i,
|
||||
_w - r.left, _rowHeight,
|
||||
r.width(), _rowHeight,
|
||||
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)
|
||||
{
|
||||
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);
|
||||
const int yoffset = (_selectedItem - _currentPos) * _rowHeight,
|
||||
|
@ -160,3 +183,17 @@ GUI::Rect RomListWidget::getEditRect() const
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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: 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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -36,16 +36,24 @@ class RomListWidget : public CheckListWidget
|
|||
int x, int y, int w, int h);
|
||||
virtual ~RomListWidget();
|
||||
|
||||
void setList(StringList& label, StringList& bytes, StringList& disasm,
|
||||
BoolArray& state);
|
||||
|
||||
protected:
|
||||
void handleMouseDown(int x, int y, int button, int clickCount);
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
||||
|
||||
void drawWidget(bool hilite);
|
||||
GUI::Rect getLineRect() const;
|
||||
GUI::Rect getEditRect() const;
|
||||
|
||||
private:
|
||||
ContextMenu* myMenu;
|
||||
int myHighlightedItem;
|
||||
int myLabelWidth;
|
||||
int myBytesWidth;
|
||||
|
||||
StringList myLabel, myDisasm;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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: 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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -114,13 +114,15 @@ void RomWidget::initialUpdate()
|
|||
; // FIXME
|
||||
else
|
||||
{
|
||||
StringList label, data;
|
||||
BoolArray state;
|
||||
// Clear old mappings
|
||||
myAddrList.clear();
|
||||
myLineList.clear();
|
||||
|
||||
StringList label, data, disasm;
|
||||
BoolArray state;
|
||||
|
||||
// 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)
|
||||
state.push_back(false);
|
||||
|
||||
|
@ -129,7 +131,7 @@ void RomWidget::initialUpdate()
|
|||
for(unsigned int i = 0; i < myAddrList.size(); ++i)
|
||||
myLineList.insert(make_pair(myAddrList[i], i));
|
||||
|
||||
myRomList->setList(data, state);
|
||||
myRomList->setList(label, data, disasm, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue