mirror of https://github.com/stella-emu/stella.git
In the CpuWidget, separated the PC from the rest of the registers.
They're now in separate widgets, and must be tabbed/selected separately. Related to above, made the CPU PC widget hold 16bit values and be wide enough to hold 16 digits (binary mode). Also, made the other registers in CpuWidget be 8bit only. Removed frame around a cell when a DataGridWidget or ToggleBitWidget loses focus. It's obvious when a widget isn't in focus (there's no bounding rectangle around the whole thing), so another visual indicator wasn't really required. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@718 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
51c89930bf
commit
8f6cc81951
|
@ -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.6 2005-08-10 18:44:37 stephena Exp $
|
||||
// $Id: CpuWidget.cxx,v 1.7 2005-08-12 17:12:43 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -33,13 +33,19 @@
|
|||
|
||||
#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,
|
||||
kNumRegs
|
||||
kYRegAddr
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -63,14 +69,31 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
|
|||
int xpos, ypos, lwidth;
|
||||
StaticTextWidget* t;
|
||||
|
||||
// Create a 1x5 grid with labels for the CPU registers
|
||||
// Create a 1x1 grid with label for the PC register
|
||||
xpos = x; ypos = y; lwidth = 4 * fontWidth;
|
||||
myCpuGrid = new DataGridWidget(boss, font, xpos + lwidth, ypos, 1, 5, 8, 16);
|
||||
t = new StaticTextWidget(boss, xpos, ypos+2, lwidth-2, fontHeight,
|
||||
"PC:", kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
myPCGrid = new DataGridWidget(boss, font, xpos + lwidth, ypos, 1, 1, 16, 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, xpos, ypos, fontWidth*15, lineHeight, "");
|
||||
myPCLabel->setFont(font);
|
||||
myPCLabel->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);
|
||||
myCpuGrid->setTarget(this);
|
||||
myCpuGrid->setID(kCpuRegID);
|
||||
addFocusWidget(myCpuGrid);
|
||||
|
||||
string labels[5] = { "PC:", "SP:", "A:", "X:", "Y:" };
|
||||
for(int row = 0; row < 5; ++row)
|
||||
string labels[4] = { "SP:", "A:", "X:", "Y:" };
|
||||
for(int row = 0; row < 4; ++row)
|
||||
{
|
||||
t = new StaticTextWidget(boss, xpos, ypos + row*lineHeight + 2,
|
||||
lwidth-2, fontHeight,
|
||||
|
@ -78,18 +101,12 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
|
|||
t->setFont(font);
|
||||
}
|
||||
|
||||
// Create a read-only textbox containing the current PC label
|
||||
xpos += lwidth + myCpuGrid->getWidth() + 10;
|
||||
myPCLabel = new EditTextWidget(boss, xpos, ypos, fontWidth*25, lineHeight, "");
|
||||
myPCLabel->setFont(font);
|
||||
myPCLabel->setEditable(false);
|
||||
|
||||
// Create a bitfield widget for changing the processor status
|
||||
xpos = x; ypos += 5*lineHeight + 5;
|
||||
t = new StaticTextWidget(boss, xpos, ypos, lwidth-2, fontHeight,
|
||||
xpos = x; ypos += 4*lineHeight + 2;
|
||||
t = new StaticTextWidget(boss, xpos, ypos+2, lwidth-2, fontHeight,
|
||||
"PS:", kTextAlignLeft);
|
||||
t->setFont(font);
|
||||
myPSRegister = new ToggleBitWidget(boss, font, xpos+lwidth, ypos-2, 8, 1);
|
||||
myPSRegister = new ToggleBitWidget(boss, font, xpos+lwidth, ypos, 8, 1);
|
||||
myPSRegister->setTarget(this);
|
||||
addFocusWidget(myPSRegister);
|
||||
|
||||
|
@ -106,7 +123,7 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
|
|||
myPSRegister->setList(off, on);
|
||||
|
||||
// Calculate real dimensions
|
||||
_w = lwidth + myCpuGrid->getWidth() + myPCLabel->getWidth() + 20;
|
||||
_w = lwidth + myPCGrid->getWidth() + myPCLabel->getWidth() + 20;
|
||||
_h = ypos + myPSRegister->getHeight() - y;
|
||||
}
|
||||
|
||||
|
@ -118,14 +135,24 @@ CpuWidget::~CpuWidget()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||
{
|
||||
int addr, value;
|
||||
int addr = -1, value = -1;
|
||||
CpuDebug& dbg = instance()->debugger().cpuDebug();
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
case kDGItemDataChangedCmd:
|
||||
switch(id)
|
||||
{
|
||||
case kPCRegID:
|
||||
addr = myPCGrid->getSelectedAddr();
|
||||
value = myPCGrid->getSelectedValue();
|
||||
break;
|
||||
|
||||
case kCpuRegID:
|
||||
addr = myCpuGrid->getSelectedAddr();
|
||||
value = myCpuGrid->getSelectedValue();
|
||||
break;
|
||||
}
|
||||
|
||||
switch(addr)
|
||||
{
|
||||
|
@ -195,6 +222,13 @@ void CpuWidget::loadConfig()
|
|||
fillGrid();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CpuWidget::setOpsWidget(DataGridOpsWidget* w)
|
||||
{
|
||||
myPCGrid->setOpsWidget(w);
|
||||
myCpuGrid->setOpsWidget(w);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CpuWidget::fillGrid()
|
||||
{
|
||||
|
@ -202,27 +236,33 @@ void CpuWidget::fillGrid()
|
|||
IntArray vlist;
|
||||
BoolArray changed;
|
||||
|
||||
// We push the enumerated items as addresses, and deal with the real
|
||||
// address in the callback (handleCommand)
|
||||
CpuDebug& cpu = instance()->debugger().cpuDebug();
|
||||
CpuState state = (CpuState&) cpu.getState();
|
||||
CpuState oldstate = (CpuState&) cpu.getOldState();
|
||||
|
||||
// We push the enumerated items as addresses, and deal with the real
|
||||
// address in the callback (handleCommand)
|
||||
// Add PC to its own DataGridWidget
|
||||
alist.push_back(kPCRegAddr);
|
||||
vlist.push_back(state.PC);
|
||||
changed.push_back(state.PC != oldstate.PC);
|
||||
|
||||
myPCGrid->setList(alist, vlist, changed);
|
||||
|
||||
// Add the other registers
|
||||
alist.clear(); vlist.clear(); changed.clear();
|
||||
alist.push_back(kSPRegAddr);
|
||||
alist.push_back(kARegAddr);
|
||||
alist.push_back(kXRegAddr);
|
||||
alist.push_back(kYRegAddr);
|
||||
|
||||
// And now fill the values
|
||||
vlist.push_back(state.PC);
|
||||
vlist.push_back(state.SP);
|
||||
vlist.push_back(state.A);
|
||||
vlist.push_back(state.X);
|
||||
vlist.push_back(state.Y);
|
||||
|
||||
// Figure out which items have changed
|
||||
changed.push_back(state.PC != oldstate.PC);
|
||||
changed.push_back(state.SP != oldstate.SP);
|
||||
changed.push_back(state.A != oldstate.A);
|
||||
changed.push_back(state.X != oldstate.X);
|
||||
|
@ -237,30 +277,4 @@ void CpuWidget::fillGrid()
|
|||
changed.push_back(state.PSbits[i] != oldstate.PSbits[i]);
|
||||
|
||||
myPSRegister->setState(state.PSbits, changed);
|
||||
|
||||
/*
|
||||
// Update the other status fields
|
||||
int pc = state.PC;
|
||||
const char* buf;
|
||||
|
||||
Debugger& dbg = instance()->debugger();
|
||||
buf = dbg.equates()->getLabel(pc).c_str();
|
||||
if(*buf)
|
||||
myPCLabel->setEditString(buf);
|
||||
else
|
||||
myPCLabel->setEditString("");
|
||||
|
||||
myPCLabel->setEditString("");
|
||||
|
||||
myCurrentIns->setEditString(dbg.disassemble(pc, 1));
|
||||
|
||||
myCycleCount->setEditString(dbg.valueToString(dbg.cycles(), kBASE_10));
|
||||
|
||||
string status;
|
||||
if(dbg.breakpoints()->isSet(pc))
|
||||
status = "BP set";
|
||||
|
||||
// FIXME - add trap info
|
||||
myStatus->setEditString(status);
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -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.3 2005-08-10 18:44:37 stephena Exp $
|
||||
// $Id: CpuWidget.hxx,v 1.4 2005-08-12 17:12:43 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -42,19 +42,16 @@ class CpuWidget : public Widget, public CommandSender
|
|||
void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
||||
|
||||
void loadConfig();
|
||||
void setOpsWidget(DataGridOpsWidget* w) { myCpuGrid->setOpsWidget(w); }
|
||||
void setOpsWidget(DataGridOpsWidget* w);
|
||||
|
||||
private:
|
||||
void fillGrid();
|
||||
|
||||
private:
|
||||
DataGridWidget* myPCGrid;
|
||||
DataGridWidget* myCpuGrid;
|
||||
ToggleBitWidget* myPSRegister;
|
||||
|
||||
EditTextWidget* myPCLabel;
|
||||
EditTextWidget* myCurrentIns;
|
||||
EditTextWidget* myCycleCount;
|
||||
EditTextWidget* myStatus;
|
||||
};
|
||||
|
||||
#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: RamWidget.cxx,v 1.8 2005-08-11 21:57:30 stephena Exp $
|
||||
// $Id: RamWidget.cxx,v 1.9 2005-08-12 17:12:43 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -102,7 +102,7 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
|
|||
}
|
||||
for(int col = 0; col < 16; ++col)
|
||||
{
|
||||
t = new StaticTextWidget(boss, xpos + col*myRamGrid->colWidth() + lwidth + 7,
|
||||
t = new StaticTextWidget(boss, xpos + col*myRamGrid->colWidth() + lwidth + 8,
|
||||
ypos - lineHeight,
|
||||
fontWidth, fontHeight,
|
||||
Debugger::to_hex_4(col),
|
||||
|
@ -141,7 +141,7 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
|
|||
myBinValue->setEditable(false);
|
||||
|
||||
// Inputbox which will pop up when searching RAM
|
||||
xpos = x + lwidth + 20; ypos = y + 2*lineHeight;
|
||||
xpos = x + lwidth + 20; ypos = y + 2*lineHeight - 5;
|
||||
myInputBox = new InputTextDialog(boss, font, xpos, ypos);
|
||||
myInputBox->setTarget(this);
|
||||
|
||||
|
|
|
@ -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: DataGridWidget.cxx,v 1.21 2005-08-11 21:57:30 stephena Exp $
|
||||
// $Id: DataGridWidget.cxx,v 1.22 2005-08-12 17:12:43 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -481,13 +481,9 @@ void DataGridWidget::drawWidget(bool hilite)
|
|||
int pos = row*_cols + col;
|
||||
|
||||
// Draw the selected item inverted, on a highlighted background.
|
||||
if (_currentRow == row && _currentCol == col)
|
||||
{
|
||||
if (_hasFocus && !_editMode)
|
||||
if (_currentRow == row && _currentCol == col &&
|
||||
_hasFocus && !_editMode)
|
||||
fb.fillRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
|
||||
else
|
||||
fb.frameRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
|
||||
}
|
||||
|
||||
if (_selectedItem == pos && _editMode)
|
||||
{
|
||||
|
|
|
@ -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: ToggleBitWidget.cxx,v 1.7 2005-08-10 12:23:42 stephena Exp $
|
||||
// $Id: ToggleBitWidget.cxx,v 1.8 2005-08-12 17:12:43 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -106,6 +106,7 @@ void ToggleBitWidget::handleMouseUp(int x, int y, int button, int clickCount)
|
|||
if (clickCount == 2 && (_selectedItem == findItem(x, y)))
|
||||
{
|
||||
_stateList[_selectedItem] = !_stateList[_selectedItem];
|
||||
_changedList[_selectedItem] = !_changedList[_selectedItem];
|
||||
sendCommand(kTBItemDataChangedCmd, _selectedItem, _id);
|
||||
setDirty(); draw();
|
||||
}
|
||||
|
@ -220,6 +221,7 @@ bool ToggleBitWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
|||
if(toggle)
|
||||
{
|
||||
_stateList[_selectedItem] = !_stateList[_selectedItem];
|
||||
_changedList[_selectedItem] = !_changedList[_selectedItem];
|
||||
sendCommand(kTBItemDataChangedCmd, _selectedItem, _id);
|
||||
}
|
||||
|
||||
|
@ -271,13 +273,8 @@ cerr << "ToggleBitWidget::drawWidget\n";
|
|||
int pos = row*_cols + col;
|
||||
|
||||
// Draw the selected item inverted, on a highlighted background.
|
||||
if (_currentRow == row && _currentCol == col)
|
||||
{
|
||||
if (_hasFocus)
|
||||
if (_currentRow == row && _currentCol == col && _hasFocus)
|
||||
fb.fillRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
|
||||
else
|
||||
fb.frameRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
|
||||
}
|
||||
|
||||
if(_stateList[pos])
|
||||
buffer = _onList[pos];
|
||||
|
|
Loading…
Reference in New Issue