mirror of https://github.com/stella-emu/stella.git
The debugger CPU area now has editable decimal and binary fields for the
registers. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3189 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
36ef5cd112
commit
237f0e5d35
|
@ -19,6 +19,10 @@
|
|||
etc can be used to toggle each event. Thanks to Buzbard of AtariAge
|
||||
for the suggestion.
|
||||
|
||||
* Added ability to edit values in more widgets in the debugger. For
|
||||
now, this applies mainly to the various decimal and binary fields.
|
||||
More widgets will be made editable in future releases.
|
||||
|
||||
* Changed 'hidecursor' commandline argument (and associated UI item) to
|
||||
'cursor'. The new argument allows to set mouse cursor visibility
|
||||
separately for both UI and emulation modes.
|
||||
|
|
|
@ -70,11 +70,16 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
|
|||
xpos = x + lwidth + myPCGrid->getWidth() + 10;
|
||||
myCpuGridDecValue =
|
||||
new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 3, 8, Common::Base::F_10);
|
||||
myCpuGridDecValue->setEditable(false);
|
||||
myCpuGridDecValue->setTarget(this);
|
||||
myCpuGridDecValue->setID(kCpuRegDecID);
|
||||
addFocusWidget(myCpuGridDecValue);
|
||||
|
||||
xpos += myCpuGridDecValue->getWidth() + 5;
|
||||
myCpuGridBinValue =
|
||||
new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 8, 8, Common::Base::F_2);
|
||||
myCpuGridBinValue->setEditable(false);
|
||||
myCpuGridBinValue->setTarget(this);
|
||||
myCpuGridBinValue->setID(kCpuRegBinID);
|
||||
addFocusWidget(myCpuGridBinValue);
|
||||
|
||||
// Calculate real dimensions (_y will be calculated at the end)
|
||||
_w = lwidth + myPCGrid->getWidth() + myPCLabel->getWidth() + 20;
|
||||
|
@ -137,6 +142,8 @@ void CpuWidget::setOpsWidget(DataGridOpsWidget* w)
|
|||
{
|
||||
myPCGrid->setOpsWidget(w);
|
||||
myCpuGrid->setOpsWidget(w);
|
||||
myCpuGridDecValue->setOpsWidget(w);
|
||||
myCpuGridBinValue->setOpsWidget(w);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -159,6 +166,16 @@ void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
|||
addr = myCpuGrid->getSelectedAddr();
|
||||
value = myCpuGrid->getSelectedValue();
|
||||
break;
|
||||
|
||||
case kCpuRegDecID:
|
||||
addr = myCpuGridDecValue->getSelectedAddr();
|
||||
value = myCpuGridDecValue->getSelectedValue();
|
||||
break;
|
||||
|
||||
case kCpuRegBinID:
|
||||
addr = myCpuGridBinValue->getSelectedAddr();
|
||||
value = myCpuGridBinValue->getSelectedValue();
|
||||
break;
|
||||
}
|
||||
|
||||
switch(addr)
|
||||
|
@ -175,26 +192,30 @@ void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
|||
|
||||
case kSPRegAddr:
|
||||
dbg.setSP(value);
|
||||
myCpuGridDecValue->setValue(0, value);
|
||||
myCpuGridBinValue->setValue(0, value);
|
||||
myCpuGrid->setValueInternal(0, value);
|
||||
myCpuGridDecValue->setValueInternal(0, value);
|
||||
myCpuGridBinValue->setValueInternal(0, value);
|
||||
break;
|
||||
|
||||
case kARegAddr:
|
||||
dbg.setA(value);
|
||||
myCpuGridDecValue->setValue(1, value);
|
||||
myCpuGridBinValue->setValue(1, value);
|
||||
myCpuGrid->setValueInternal(1, value);
|
||||
myCpuGridDecValue->setValueInternal(1, value);
|
||||
myCpuGridBinValue->setValueInternal(1, value);
|
||||
break;
|
||||
|
||||
case kXRegAddr:
|
||||
dbg.setX(value);
|
||||
myCpuGridDecValue->setValue(2, value);
|
||||
myCpuGridBinValue->setValue(2, value);
|
||||
myCpuGrid->setValueInternal(2, value);
|
||||
myCpuGridDecValue->setValueInternal(2, value);
|
||||
myCpuGridBinValue->setValueInternal(2, value);
|
||||
break;
|
||||
|
||||
case kYRegAddr:
|
||||
dbg.setY(value);
|
||||
myCpuGridDecValue->setValue(3, value);
|
||||
myCpuGridBinValue->setValue(3, value);
|
||||
myCpuGrid->setValueInternal(3, value);
|
||||
myCpuGridDecValue->setValueInternal(3, value);
|
||||
myCpuGridBinValue->setValueInternal(3, value);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -48,7 +48,9 @@ class CpuWidget : public Widget, public CommandSender
|
|||
// We need ID's, since there are more than one of several types of widgets
|
||||
enum {
|
||||
kPCRegID,
|
||||
kCpuRegID
|
||||
kCpuRegID,
|
||||
kCpuRegDecID,
|
||||
kCpuRegBinID
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
|
@ -84,22 +84,31 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font,
|
|||
}
|
||||
|
||||
// Add filtering
|
||||
EditableWidget::TextFilter f = [&](char c) {
|
||||
bool isBin = c == '0' || c == '1',
|
||||
isDec = c >= '0' && c <= '9',
|
||||
isHex = isDec || (c >= 'a' && c <= 'f'),
|
||||
isOp = c == '$' || c == '#' || c == '\\';
|
||||
|
||||
if(BSPF_startsWithIgnoreCase(editString(), "$"))
|
||||
return isHex;
|
||||
else if(BSPF_startsWithIgnoreCase(editString(), "#"))
|
||||
return isDec;
|
||||
else if(BSPF_startsWithIgnoreCase(editString(), "\\"))
|
||||
return isBin;
|
||||
else
|
||||
return isHex || isDec || isBin || isOp;
|
||||
};
|
||||
setTextFilter(f);
|
||||
EditableWidget::TextFilter f;
|
||||
switch(base)
|
||||
{
|
||||
case Common::Base::F_16:
|
||||
case Common::Base::F_16_1:
|
||||
case Common::Base::F_16_2:
|
||||
case Common::Base::F_16_4:
|
||||
case Common::Base::F_16_8:
|
||||
setTextFilter([](char c) {
|
||||
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f');
|
||||
});
|
||||
break;
|
||||
case Common::Base::F_10:
|
||||
setTextFilter([](char c) {
|
||||
return (c >= '0' && c <= '9');
|
||||
});
|
||||
break;
|
||||
case Common::Base::F_2:
|
||||
case Common::Base::F_2_8:
|
||||
case Common::Base::F_2_16:
|
||||
setTextFilter([](char c) { return (c >= '0' && c <= '1'); });
|
||||
break;
|
||||
default:
|
||||
break; // no filtering for now
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -206,7 +215,14 @@ void DataGridWidget::setValue(int position, int value)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DataGridWidget::setValue(int position, int value, bool changed)
|
||||
void DataGridWidget::setValueInternal(int position, int value)
|
||||
{
|
||||
setValue(position, value, true, false);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DataGridWidget::setValue(int position, int value, bool changed,
|
||||
bool emitSignal)
|
||||
{
|
||||
if(position >= 0 && uInt32(position) < _valueList.size())
|
||||
{
|
||||
|
@ -217,6 +233,7 @@ void DataGridWidget::setValue(int position, int value, bool changed)
|
|||
_changedList[position] = changed;
|
||||
_valueList[position] = value;
|
||||
|
||||
if(emitSignal)
|
||||
sendCommand(DataGridWidget::kItemDataChangedCmd, position, _id);
|
||||
|
||||
setDirty();
|
||||
|
|
|
@ -63,15 +63,17 @@ class DataGridWidget : public EditableWidget
|
|||
void setSelectedValue(int value);
|
||||
/** Set value at given position */
|
||||
void setValue(int position, int value);
|
||||
/** Set value at given position, do not emit any signals */
|
||||
void setValueInternal(int position, int value);
|
||||
/** Set value at given position, manually specifying if the value changed */
|
||||
void setValue(int position, int value, bool changed);
|
||||
void setValue(int position, int value, bool changed, bool emitSignal = true);
|
||||
|
||||
int getSelectedAddr() const { return _addrList[_selectedItem]; }
|
||||
int getSelectedValue() const { return _valueList[_selectedItem]; }
|
||||
|
||||
void setRange(int lower, int upper);
|
||||
|
||||
bool wantsFocus() override { return true; }
|
||||
bool wantsFocus() const override { return true; }
|
||||
|
||||
// Account for the extra width of embedded scrollbar
|
||||
int getWidth() const override;
|
||||
|
|
|
@ -60,10 +60,10 @@ class EditableWidget : public Widget, public CommandSender
|
|||
bool handleKeyDown(StellaKey key, StellaMod mod) override;
|
||||
|
||||
// We only want to focus this widget when we can edit its contents
|
||||
virtual bool wantsFocus() { return _editable; }
|
||||
virtual bool wantsFocus() const { return _editable; }
|
||||
|
||||
// Set filter used to test whether a character can be inserted
|
||||
void setTextFilter(TextFilter& filter) { _filter = filter; }
|
||||
void setTextFilter(const TextFilter& filter) { _filter = filter; }
|
||||
|
||||
protected:
|
||||
virtual void startEditMode() { setFlags(WIDGET_WANTS_RAWDATA); }
|
||||
|
|
|
@ -177,7 +177,7 @@ void InputTextDialog::setText(const string& str, int idx)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputTextDialog::setTextFilter(EditableWidget::TextFilter& f, int idx)
|
||||
void InputTextDialog::setTextFilter(const EditableWidget::TextFilter& f, int idx)
|
||||
{
|
||||
if((uInt32)idx < myInput.size())
|
||||
myInput[idx]->setTextFilter(f);
|
||||
|
|
|
@ -46,7 +46,7 @@ class InputTextDialog : public Dialog, public CommandSender
|
|||
const string& getResult(int idx = 0);
|
||||
|
||||
void setText(const string& str, int idx = 0);
|
||||
void setTextFilter(EditableWidget::TextFilter& f, int idx = 0);
|
||||
void setTextFilter(const EditableWidget::TextFilter& f, int idx = 0);
|
||||
|
||||
void setEmitSignal(int cmd) { myCmd = cmd; }
|
||||
void setTitle(const string& title);
|
||||
|
|
Loading…
Reference in New Issue