diff --git a/stella/src/gui/ByteGridWidget.cxx b/stella/src/gui/ByteGridWidget.cxx index e545647d6..61a5ce947 100644 --- a/stella/src/gui/ByteGridWidget.cxx +++ b/stella/src/gui/ByteGridWidget.cxx @@ -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: ByteGridWidget.cxx,v 1.5 2005-06-17 18:17:15 stephena Exp $ +// $Id: ByteGridWidget.cxx,v 1.6 2005-06-17 21:46:23 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -89,6 +89,18 @@ void ByteGridWidget::setList(const ByteAddrList& alist, const ByteValueList& vli _editMode = false; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ByteGridWidget::setSelectedValue(int value) +{ + // Correctly format the data for viewing + _editString = Debugger::to_hex_8(value); + + _valueStringList[_selectedItem] = _editString; + _valueList[_selectedItem] = value; + + sendCommand(kBGItemDataChangedCmd, _selectedItem); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ByteGridWidget::handleMouseDown(int x, int y, int button, int clickCount) { @@ -389,14 +401,7 @@ void ByteGridWidget::endEditMode() abortEditMode(); return; } - - // Correctly format the data for viewing - _editString = Debugger::to_hex_8(value); - - _valueStringList[_selectedItem] = _editString; - _valueList[_selectedItem] = value; - - sendCommand(kBGItemDataChangedCmd, _selectedItem); + setSelectedValue(value); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/ByteGridWidget.hxx b/stella/src/gui/ByteGridWidget.hxx index b38406c3c..847bdf2a7 100644 --- a/stella/src/gui/ByteGridWidget.hxx +++ b/stella/src/gui/ByteGridWidget.hxx @@ -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: ByteGridWidget.hxx,v 1.4 2005-06-17 17:34:01 stephena Exp $ +// $Id: ByteGridWidget.hxx,v 1.5 2005-06-17 21:46:24 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -53,6 +53,7 @@ class ByteGridWidget : public EditableWidget, public CommandSender virtual ~ByteGridWidget(); void setList(const ByteAddrList& alist, const ByteValueList& vlist); + void setSelectedValue(int value); int getSelectedAddr() const { return _addrList[_selectedItem]; } int getSelectedValue() const { return _valueList[_selectedItem]; } diff --git a/stella/src/gui/RamWidget.cxx b/stella/src/gui/RamWidget.cxx index eb090bc66..1ee4bb35d 100644 --- a/stella/src/gui/RamWidget.cxx +++ b/stella/src/gui/RamWidget.cxx @@ -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.4 2005-06-17 17:34:01 stephena Exp $ +// $Id: RamWidget.cxx,v 1.5 2005-06-17 21:46:24 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -31,6 +31,16 @@ #include "RamWidget.hxx" +enum { + kRZeroCmd = 'RWze', + kRInvertCmd = 'RWiv', + kRNegateCmd = 'RWng', + kRIncCmd = 'RWic', + kRDecCmd = 'RWdc', + kRShiftLCmd = 'RWls', + kRShiftRCmd = 'RWrs' +}; + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) : Widget(boss, x, y, w, h), @@ -39,6 +49,7 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) int xpos = 10; int ypos = 20; int lwidth = 30; + const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24; // Create a 16x8 grid (16 x 8 = 128 RAM bytes) with labels for(int row = 0; row < 8; ++row) @@ -62,6 +73,40 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) myRamGrid = new ByteGridWidget(boss, xpos+lwidth + 5, ypos, 16, 8); myRamGrid->setTarget(this); myActiveWidget = myRamGrid; + + // Add some buttons for common actions + ButtonWidget* b; + xpos = vWidth + 10; ypos = 20; + b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "0", kRZeroCmd, 0); + b->setTarget(this); + + ypos += 16 + space; + b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "Inv", kRInvertCmd, 0); + b->setTarget(this); + + ypos += 16 + space; + b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "++", kRIncCmd, 0); + b->setTarget(this); + + ypos += 16 + space; + b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "<<", kRShiftLCmd, 0); + b->setTarget(this); + + xpos = vWidth + 30 + 10; ypos = 20; +// b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "", kRCmd, 0); +// b->setTarget(this); + + ypos += 16 + space; + b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "~", kRNegateCmd, 0); + b->setTarget(this); + + ypos += 16 + space; + b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "--", kRDecCmd, 0); + b->setTarget(this); + + ypos += 16 + space; + b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, ">>", kRShiftRCmd, 0); + b->setTarget(this); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -72,14 +117,62 @@ RamWidget::~RamWidget() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RamWidget::handleCommand(CommandSender* sender, int cmd, int data) { + // We simply change the values in the ByteGridWidget + // It will then send the 'kBGItemDataChangedCmd' signal to change the actual + // memory location + int addr, value; + unsigned char byte; + switch(cmd) { case kBGItemDataChangedCmd: - int addr = myRamGrid->getSelectedAddr() - kRamStart; - int value = myRamGrid->getSelectedValue(); + addr = myRamGrid->getSelectedAddr() - kRamStart; + value = myRamGrid->getSelectedValue(); instance()->debugger().writeRAM(addr, value); break; + + case kRZeroCmd: + myRamGrid->setSelectedValue(0); + break; + + case kRInvertCmd: + byte = (unsigned char) myRamGrid->getSelectedValue(); + byte = ~byte; + myRamGrid->setSelectedValue((int)byte); + break; + + case kRNegateCmd: + byte = (unsigned char) myRamGrid->getSelectedValue(); + byte = (~byte) + 1; + myRamGrid->setSelectedValue((int)byte); + break; + + case kRIncCmd: + byte = (unsigned char) myRamGrid->getSelectedValue(); + byte += 1; + myRamGrid->setSelectedValue((int)byte); + break; + + case kRDecCmd: + byte = (unsigned char) myRamGrid->getSelectedValue(); + byte -= 1; + myRamGrid->setSelectedValue((int)byte); + break; + + case kRShiftLCmd: + byte = (unsigned char) myRamGrid->getSelectedValue(); + byte <<= 1; + myRamGrid->setSelectedValue((int)byte); + break; + + case kRShiftRCmd: + byte = (unsigned char) myRamGrid->getSelectedValue(); + byte >>= 1; + myRamGrid->setSelectedValue((int)byte); + break; } + + instance()->frameBuffer().refresh(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -