Start of the TiaWidget. This one is going to be huge, and may take some

time to finish.

Changed colors of modified cells in DataGridWidget.  They're now much
easier to see.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@606 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-07-04 15:59:38 +00:00
parent c4d5f9d54b
commit fe8c605d8d
4 changed files with 352 additions and 11 deletions

View File

@ -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.8 2005-07-03 21:14:42 urchlay Exp $
// $Id: DataGridWidget.cxx,v 1.9 2005-07-04 15:59:38 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -414,12 +414,16 @@ void DataGridWidget::drawWidget(bool hilite)
}
else
{
if(_changedList[pos])
fb.fillRect(x - 3, y - 1, _colWidth-1, kLineHeight-1, kTextColorEm);
buffer = _valueStringList[pos];
deltax = 0;
fb.drawString(_font, buffer, x, y, _colWidth, kTextColor);
if(_changedList[pos])
{
fb.fillRect(x - 3, y - 1, _colWidth-1, kLineHeight-1, kTextColorEm);
fb.drawString(_font, buffer, x, y, _colWidth, kTextColorHi);
}
else
fb.drawString(_font, buffer, x, y, _colWidth, kTextColor);
}
}
}

View File

@ -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.19 2005-06-30 00:08:01 stephena Exp $
// $Id: DebuggerDialog.cxx,v 1.20 2005-07-04 15:59:38 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -59,24 +59,28 @@ DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent,
CpuWidget* cpu = new CpuWidget(myTab, 2, 2, vWidth - vBorder, _h - 25);
myTab->setParentWidget(1, cpu, cpu->activeWidget());
// 3) The RAM tab
// 3) The RAM tab (part of RIOT)
myTab->addTab("RAM");
RamWidget* ram = new RamWidget(myTab, 2, 2, vWidth - vBorder, _h - 25);
myTab->setParentWidget(2, ram, ram->activeWidget());
// 4) The ROM tab
myTab->addTab("ROM");
// 4) The input/output tab (part of RIOT)
myTab->addTab("I/O");
// 5) The TIA tab
myTab->addTab("TIA");
// 6) The Cheat tab
// 6) The ROM tab
myTab->addTab("ROM");
// 7) The Cheat tab
myTab->addTab("Cheat");
CheatWidget* cheat = new CheatWidget(myTab, 2, 2,
vWidth - vBorder, _h - 25);
myTab->setParentWidget(5, cheat, cheat->activeWidget());
myTab->setParentWidget(6, cheat, cheat->activeWidget());
// Set active tab to prompt
myTab->setActiveTab(0);

View File

@ -0,0 +1,275 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// 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.1 2005-07-04 15:59:38 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================
#include <sstream>
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "GuiUtils.hxx"
#include "GuiObject.hxx"
#include "Debugger.hxx"
#include "Widget.hxx"
#include "EditTextWidget.hxx"
#include "DataGridWidget.hxx"
#include "RamWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RamWidget::RamWidget(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;
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);
myRamGrid->setTarget(this);
myRamGrid->clearFlags(WIDGET_TAB_NAVIGATE);
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);
}
for(int col = 0; col < 16; ++col)
{
StaticTextWidget* t = new StaticTextWidget(boss,
xpos + col*myRamGrid->colWidth() + lwidth + 12,
ypos - kLineHeight,
lwidth, kLineHeight,
Debugger::to_hex_4(col),
kTextAlignLeft);
t->setFont(font);
}
xpos = 20; ypos = 11 * kLineHeight;
new StaticTextWidget(boss, xpos, ypos, 30, kLineHeight, "Label: ", kTextAlignLeft);
xpos += 30;
myLabel = new EditTextWidget(boss, xpos, ypos-2, 100, kLineHeight, "");
myLabel->clearFlags(WIDGET_TAB_NAVIGATE);
myLabel->setFont(font);
myLabel->setEditable(false);
xpos += 120;
new StaticTextWidget(boss, xpos, ypos, 35, kLineHeight, "Decimal: ", kTextAlignLeft);
xpos += 35;
myDecValue = new EditTextWidget(boss, xpos, ypos-2, 30, kLineHeight, "");
myDecValue->clearFlags(WIDGET_TAB_NAVIGATE);
myDecValue->setFont(font);
myDecValue->setEditable(false);
xpos += 48;
new StaticTextWidget(boss, xpos, ypos, 35, kLineHeight, "Binary: ", kTextAlignLeft);
xpos += 35;
myBinValue = new EditTextWidget(boss, xpos, ypos-2, 60, kLineHeight, "");
myBinValue->clearFlags(WIDGET_TAB_NAVIGATE);
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()
{
delete _oldValueList;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RamWidget::handleCommand(CommandSender* sender, int cmd, int data)
{
// 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();
switch(cmd)
{
case kDGItemDataChangedCmd:
addr = myRamGrid->getSelectedAddr();
value = myRamGrid->getSelectedValue();
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);
break;
case kDGSelectionChangedCmd:
addr = myRamGrid->getSelectedAddr();
value = myRamGrid->getSelectedValue();
buf = instance()->debugger().equates()->getLabel(addr);
if(buf) myLabel->setEditString(buf);
else myLabel->setEditString("");
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?
instance()->frameBuffer().refreshOverlay();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RamWidget::loadConfig()
{
fillGrid(true);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RamWidget::fillGrid(bool updateOld)
{
AddrList alist;
ValueList vlist;
BoolArray changed;
if(updateOld) _oldValueList->clear();
Debugger& dbg = instance()->debugger();
for(unsigned int i = 0; i < kRamSize; 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));
}
myRamGrid->setList(alist, vlist, changed);
if(updateOld)
{
myRevertButton->clearFlags(WIDGET_ENABLED);
myUndoButton->clearFlags(WIDGET_ENABLED);
}
}

View File

@ -0,0 +1,58 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// 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.1 2005-07-04 15:59:38 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================
#ifndef TIA_WIDGET_HXX
#define TIA_WIDGET_HXX
class GuiObject;
class ButtonWidget;
class StaticTextWidget;
class EditTextWidget;
#include "Array.hxx"
#include "Widget.hxx"
#include "Command.hxx"
#include "DataGridWidget.hxx"
class TiaWidget : public Widget, public CommandSender
{
public:
TiaWidget(GuiObject* boss, int x, int y, int w, int h);
virtual ~TiaWidget();
Widget* activeWidget() { return myActiveWidget; }
void handleCommand(CommandSender* sender, int cmd, int data);
void loadConfig();
private:
private:
Widget* myActiveWidget;
DataGridWidget* myRamGrid;
EditTextWidget* myBinValue;
EditTextWidget* myDecValue;
EditTextWidget* myLabel;
};
#endif