From 1b8135712646fcebecc44b2c4c4b62ef430bf916 Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 6 Jul 2005 15:09:16 +0000 Subject: [PATCH] Second pass at TiaWidget. It now contains a DataGridWidget for the 16 bytes of RAM in the TIA, but it isn't tied to the TIA yet (so changes have no effect). I suspect that development on this tab will now proceed quickly, since I think I've found a way to lay everything out in one tab. Removed the 2 second delay from configure when an invalid option is given. There's no need to delay; printing an error is sufficient. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@612 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/configure | 4 +- stella/src/gui/DataGridWidget.hxx | 21 ++-- stella/src/gui/DebuggerDialog.cxx | 5 +- stella/src/gui/TiaWidget.cxx | 196 +++++++++--------------------- stella/src/gui/TiaWidget.hxx | 4 +- stella/src/gui/Widget.cxx | 4 +- stella/src/gui/module.mk | 1 + 7 files changed, 82 insertions(+), 153 deletions(-) diff --git a/stella/configure b/stella/configure index 8db8f09af..d645191cb 100755 --- a/stella/configure +++ b/stella/configure @@ -317,9 +317,7 @@ for ac_option in $@; do _mandir=`echo $ac_option | cut -d '=' -f 2` ;; *) - echo "warning: unrecognised option: $ac_option -Try \`$0 --help' for more information." >&2 - sleep 2 + echo "warning: unrecognised option: $ac_option" ;; esac; done; diff --git a/stella/src/gui/DataGridWidget.hxx b/stella/src/gui/DataGridWidget.hxx index 0065ed35e..ef6d0c028 100644 --- a/stella/src/gui/DataGridWidget.hxx +++ b/stella/src/gui/DataGridWidget.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: DataGridWidget.hxx,v 1.7 2005-07-05 18:00:05 stephena Exp $ +// $Id: DataGridWidget.hxx,v 1.8 2005-07-06 15:09:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -78,15 +78,6 @@ class DataGridWidget : public EditableWidget, public CommandSender int colWidth() { return _colWidth; } - //* Common operations on the currently selected cell */ - void negateCell(); - void invertCell(); - void decrementCell(); - void incrementCell(); - void lshiftCell(); - void rshiftCell(); - void zeroCell(); - protected: void drawWidget(bool hilite); @@ -120,6 +111,16 @@ class DataGridWidget : public EditableWidget, public CommandSender int _selectedItem; int _currentKeyDown; string _backupString; + + private: + //* Common operations on the currently selected cell */ + void negateCell(); + void invertCell(); + void decrementCell(); + void incrementCell(); + void lshiftCell(); + void rshiftCell(); + void zeroCell(); }; #endif diff --git a/stella/src/gui/DebuggerDialog.cxx b/stella/src/gui/DebuggerDialog.cxx index 25e5d4a1b..9a1965ecb 100644 --- a/stella/src/gui/DebuggerDialog.cxx +++ b/stella/src/gui/DebuggerDialog.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: DebuggerDialog.cxx,v 1.21 2005-07-05 15:25:44 stephena Exp $ +// $Id: DebuggerDialog.cxx,v 1.22 2005-07-06 15:09:16 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -25,6 +25,7 @@ #include "PromptWidget.hxx" #include "CpuWidget.hxx" #include "RamWidget.hxx" +#include "TiaWidget.hxx" #include "CheatWidget.hxx" #include "Debugger.hxx" @@ -70,6 +71,8 @@ DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent, // 5) The TIA tab myTab->addTab("TIA"); + TiaWidget* tia = new TiaWidget(myTab, 2, 2, vWidth - vBorder, _h - 25); + myTab->setParentWidget(3, tia, tia->activeWidget()); // 6) The ROM tab diff --git a/stella/src/gui/TiaWidget.cxx b/stella/src/gui/TiaWidget.cxx index d856d69e2..aecb2a789 100644 --- a/stella/src/gui/TiaWidget.cxx +++ b/stella/src/gui/TiaWidget.cxx @@ -13,14 +13,12 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: TiaWidget.cxx,v 1.2 2005-07-05 15:25:44 stephena Exp $ +// $Id: TiaWidget.cxx,v 1.3 2005-07-06 15:09:16 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project //============================================================================ -#include - #include "OSystem.hxx" #include "FrameBuffer.hxx" #include "GuiUtils.hxx" @@ -30,38 +28,44 @@ #include "EditTextWidget.hxx" #include "DataGridWidget.hxx" -#include "RamWidget.hxx" +#include "TiaWidget.hxx" + +// ID's for the various widgets +// We need ID's, since there are more than one of several types of widgets +enum { + kRamID, + kCOLUP0ID, + kCOLUP1ID, + kCOLUBKID, + kCOLUPFID +}; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) +TiaWidget::TiaWidget(GuiObject* boss, int x, int y, int w, int h) : Widget(boss, x, y, w, h), CommandSender(boss) { int xpos = 10; int ypos = 20; - int lwidth = 30; + int lwidth = 25; const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24; const GUI::Font& font = instance()->consoleFont(); - _oldValueList = new ValueList; - // Create a 16x8 grid holding byte values (16 x 8 = 128 RAM bytes) with labels - myRamGrid = new DataGridWidget(boss, xpos+lwidth + 5, ypos, 16, 8, 2, 0xff, kBASE_16); + // Create a 16x1 grid holding byte values with labels + myRamGrid = new DataGridWidget(boss, xpos+lwidth, ypos, 16, 1, 2, 8, kBASE_16); myRamGrid->setTarget(this); - myRamGrid->clearFlags(WIDGET_TAB_NAVIGATE); + myRamGrid->setID(kRamID); myActiveWidget = myRamGrid; - for(int row = 0; row < 8; ++row) - { - StaticTextWidget* t = new StaticTextWidget(boss, xpos, ypos + row*kLineHeight + 2, - lwidth, kLineHeight, - Debugger::to_hex_16(row*16 + kRamStart) + string(":"), - kTextAlignLeft); - t->setFont(font); - } + StaticTextWidget* t = new StaticTextWidget(boss, xpos, ypos + 2, + lwidth, kLineHeight, + Debugger::to_hex_8(0) + string(":"), + kTextAlignLeft); + t->setFont(font); for(int col = 0; col < 16; ++col) { StaticTextWidget* t = new StaticTextWidget(boss, - xpos + col*myRamGrid->colWidth() + lwidth + 12, + xpos + col*myRamGrid->colWidth() + lwidth + 7, ypos - kLineHeight, lwidth, kLineHeight, Debugger::to_hex_4(col), @@ -69,7 +73,7 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) t->setFont(font); } - xpos = 20; ypos = 11 * kLineHeight; + xpos = 20; ypos = 4 * kLineHeight; new StaticTextWidget(boss, xpos, ypos, 30, kLineHeight, "Label: ", kTextAlignLeft); xpos += 30; myLabel = new EditTextWidget(boss, xpos, ypos-2, 100, kLineHeight, ""); @@ -93,65 +97,32 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) myBinValue->setFont(font); myBinValue->setEditable(false); +/* // 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); - - ypos += 16 + space; - // keep a pointer to this one, it gets disabled/enabled - myUndoButton = b = new ButtonWidget(boss, xpos, ypos, buttonw*2+10, 16, "Undo", kUndoCmd, 0); - b->setTarget(this); - - ypos += 16 + space; - // keep a pointer to this one, it gets disabled/enabled - myRevertButton = b = new ButtonWidget(boss, xpos, ypos, buttonw*2+10, 16, "Revert", kRevertCmd, 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, "Neg", 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); +*/ } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -RamWidget::~RamWidget() +TiaWidget::~TiaWidget() { - delete _oldValueList; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) +void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) { // We simply change the values in the ByteGridWidget // It will then send the 'kDGItemDataChangedCmd' signal to change the actual // memory location int addr, value; - unsigned char byte; const char* buf; Debugger& dbg = instance()->debugger(); @@ -159,20 +130,23 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) switch(cmd) { case kDGItemDataChangedCmd: - addr = myRamGrid->getSelectedAddr(); - value = myRamGrid->getSelectedValue(); + switch(id) + { + case kRamID: + changeRam(); + break; - myUndoAddress = addr; - myUndoValue = dbg.readRAM(addr - kRamStart); - - instance()->debugger().writeRAM(addr - kRamStart, value); - myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10)); - myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2)); - myRevertButton->setFlags(WIDGET_ENABLED); - myUndoButton->setFlags(WIDGET_ENABLED); + default: + cerr << "TiaWidget DG changed\n"; + break; + } + // FIXME - maybe issue a full reload, since changing one item can affect + // others in this tab?? break; case kDGSelectionChangedCmd: + // FIXME - for now, only the RAM has multiple cells, so it's the only one + // that can receive this signal addr = myRamGrid->getSelectedAddr(); value = myRamGrid->getSelectedValue(); @@ -183,59 +157,6 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10)); myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2)); 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; - - case kRevertCmd: - for(unsigned int i = 0; i < kRamSize; i++) - dbg.writeRAM(i, (*_oldValueList)[i]); - fillGrid(true); - break; - - case kUndoCmd: - dbg.writeRAM(myUndoAddress - kRamStart, myUndoValue); - myUndoButton->clearFlags(WIDGET_ENABLED); - fillGrid(false); - break; - } // TODO - dirty rect, or is it necessary here? @@ -243,33 +164,36 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void RamWidget::loadConfig() +void TiaWidget::loadConfig() { - fillGrid(true); + fillGrid(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void RamWidget::fillGrid(bool updateOld) +void TiaWidget::fillGrid() { AddrList alist; ValueList vlist; BoolArray changed; - if(updateOld) _oldValueList->clear(); - +// FIXME - have this actually talk to TIADebug Debugger& dbg = instance()->debugger(); - for(unsigned int i = 0; i < kRamSize; i++) + for(unsigned int i = 0; i < 16; i++) { - alist.push_back(kRamStart + i); - vlist.push_back(dbg.readRAM(i)); - if(updateOld) _oldValueList->push_back(dbg.readRAM(i)); - changed.push_back(dbg.ramChanged(i)); + alist.push_back(i); + vlist.push_back(i); + changed.push_back(false); } - myRamGrid->setList(alist, vlist, changed); - if(updateOld) - { - myRevertButton->clearFlags(WIDGET_ENABLED); - myUndoButton->clearFlags(WIDGET_ENABLED); - } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TiaWidget::changeRam() +{ + int addr = myRamGrid->getSelectedAddr(); + int value = myRamGrid->getSelectedValue(); + +//FIXME instance()->debugger().writeRAM(addr - kRamStart, value); + myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10)); + myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2)); } diff --git a/stella/src/gui/TiaWidget.hxx b/stella/src/gui/TiaWidget.hxx index fccedff4f..d0bf88207 100644 --- a/stella/src/gui/TiaWidget.hxx +++ b/stella/src/gui/TiaWidget.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: TiaWidget.hxx,v 1.2 2005-07-05 15:25:44 stephena Exp $ +// $Id: TiaWidget.hxx,v 1.3 2005-07-06 15:09:16 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -45,6 +45,8 @@ class TiaWidget : public Widget, public CommandSender void loadConfig(); private: + void fillGrid(); + void changeRam(); private: Widget* myActiveWidget; diff --git a/stella/src/gui/Widget.cxx b/stella/src/gui/Widget.cxx index b44bc7273..e43e7c685 100644 --- a/stella/src/gui/Widget.cxx +++ b/stella/src/gui/Widget.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: Widget.cxx,v 1.22 2005-07-05 15:25:44 stephena Exp $ +// $Id: Widget.cxx,v 1.23 2005-07-06 15:09:16 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -36,7 +36,7 @@ Widget::Widget(GuiObject* boss, int x, int y, int w, int h) : GuiObject(boss->instance(), boss->parent(), x, y, w, h), _type(0), _boss(boss), - _id(0), + _id(-1), _flags(0), _hasFocus(false), _color(kTextColor), diff --git a/stella/src/gui/module.mk b/stella/src/gui/module.mk index 356dd36a6..783f9eaf6 100644 --- a/stella/src/gui/module.mk +++ b/stella/src/gui/module.mk @@ -31,6 +31,7 @@ MODULE_OBJS := \ src/gui/RamWidget.o \ src/gui/ScrollBarWidget.o \ src/gui/TabWidget.o \ + src/gui/TiaWidget.o \ src/gui/ToggleBitWidget.o \ src/gui/VideoDialog.o \ src/gui/Widget.o \