From 805300ceb867d2aae4ec226a46577e60f24890be Mon Sep 17 00:00:00 2001 From: stephena Date: Thu, 4 Jun 2009 09:54:18 +0000 Subject: [PATCH] Check if RAM change succeeded in debugger RAM UI. This previously wasn't necessary, as ZP RAM can always be changed. In the new scheme, however, sometimes the RAM view will actually show ROM, and in those cases it definitely shouldn't be modified. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1749 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/debugger/gui/DataGridWidget.cxx | 10 ++++++++-- src/debugger/gui/DataGridWidget.hxx | 2 ++ src/debugger/gui/RamWidget.cxx | 17 ++++++++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 26de656a7..278ccef26 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -163,11 +163,17 @@ void DataGridWidget::setNumRows(int rows) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::setSelectedValue(int value) { - setValue(_selectedItem, value); + setValue(_selectedItem, value, _valueList[_selectedItem] != value); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::setValue(int position, int value) +{ + setValue(position, value, _valueList[position] != value); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DataGridWidget::setValue(int position, int value, bool changed) { if(position >= 0 && uInt32(position) < _valueList.size()) { @@ -175,7 +181,7 @@ void DataGridWidget::setValue(int position, int value) _editString = instance().debugger().valueToString(value, _base); _valueStringList[position] = _editString; - _changedList[position] = (_valueList[position] != value); + _changedList[position] = changed; _valueList[position] = value; sendCommand(kDGItemDataChangedCmd, position, _id); diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index 6ad9fcc22..dee5d00bd 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -63,6 +63,8 @@ class DataGridWidget : public EditableWidget void setSelectedValue(int value); /** Set value at given position */ void setValue(int position, int value); + /** Set value at given position, manually specifying if the value changed */ + void setValue(int position, int value, bool changed); int getSelectedAddr() const { return _addrList[_selectedItem]; } int getSelectedValue() const { return _valueList[_selectedItem]; } diff --git a/src/debugger/gui/RamWidget.cxx b/src/debugger/gui/RamWidget.cxx index 378fe105b..235f6fa58 100644 --- a/src/debugger/gui/RamWidget.cxx +++ b/src/debugger/gui/RamWidget.cxx @@ -164,18 +164,29 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) switch(cmd) { case kDGItemDataChangedCmd: + { addr = myRamGrid->getSelectedAddr(); value = myRamGrid->getSelectedValue(); - myUndoAddress = addr; - myUndoValue = dbg.read(state.rport[addr]); - + // Attempt the write, and revert if it didn't succeed + uInt8 oldval = dbg.read(state.rport[addr]); dbg.write(state.wport[addr], value); + uInt8 newval = dbg.read(state.rport[addr]); + if(value != newval) + { + myRamGrid->setValue(addr - myCurrentRamBank*128, newval, false); + break; + } + + myUndoAddress = addr; + myUndoValue = oldval; + myDecValue->setEditString(instance().debugger().valueToString(value, kBASE_10)); myBinValue->setEditString(instance().debugger().valueToString(value, kBASE_2)); myRevertButton->setEnabled(true); myUndoButton->setEnabled(true); break; + } case kDGSelectionChangedCmd: {