Added non-edit mode to DataGridWidget.

Some work on TIADebug.  Change tracking now works for the color
registers.  Getting/setting the color registers works (sort of,
since the change doesn't seem to be registering in TIA).

Some work on TiaWidget.  Color registers and scanline count are
shown.  VSync and VBlank are shown, but can't be changed.

Made CheckboxWidget only emit a signal when interactively
clicking on the checkbox (changing state programmatically no
longer emits the signal).  TODO: maybe two signals should be used??


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@647 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-07-14 18:28:36 +00:00
parent 10298d8ba2
commit 0f4b93acf3
7 changed files with 158 additions and 74 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIADebug.cxx,v 1.10 2005-07-09 23:44:07 urchlay Exp $ // $Id: TIADebug.cxx,v 1.11 2005-07-14 18:28:35 stephena Exp $
//============================================================================ //============================================================================
#include "System.hxx" #include "System.hxx"
@ -44,6 +44,12 @@ DebuggerState& TIADebug::getState()
for(int i = 0; i < 0x010; ++i) for(int i = 0; i < 0x010; ++i)
myState.ram.push_back(myTIA->peek(i)); myState.ram.push_back(myTIA->peek(i));
myState.coluRegs.clear();
myState.coluRegs.push_back(coluP0());
myState.coluRegs.push_back(coluP1());
myState.coluRegs.push_back(coluPF());
myState.coluRegs.push_back(coluBK());
return myState; return myState;
} }
@ -53,6 +59,56 @@ void TIADebug::saveOldState()
myOldState.ram.clear(); myOldState.ram.clear();
for(int i = 0; i < 0x010; ++i) for(int i = 0; i < 0x010; ++i)
myOldState.ram.push_back(myTIA->peek(i)); myOldState.ram.push_back(myTIA->peek(i));
myOldState.coluRegs.clear();
myOldState.coluRegs.push_back(coluP0());
myOldState.coluRegs.push_back(coluP1());
myOldState.coluRegs.push_back(coluPF());
myOldState.coluRegs.push_back(coluBK());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIADebug::coluP0(int newVal)
{
// TIA::myCOLUxx are stored 4 copies to each int,
// we need only 1 when fetching, but store all 4
if(newVal > -1)
myTIA->myCOLUP0 = (((((newVal << 8) | newVal) << 8) | newVal) << 8) | newVal;
return myTIA->myCOLUP0 & 0xff;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIADebug::coluP1(int newVal)
{
// TIA::myCOLUxx are stored 4 copies to each int,
// we need only 1 when fetching, but store all 4
if(newVal > -1)
myTIA->myCOLUP1 = (((((newVal << 8) | newVal) << 8) | newVal) << 8) | newVal;
return myTIA->myCOLUP1 & 0xff;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIADebug::coluPF(int newVal)
{
// TIA::myCOLUxx are stored 4 copies to each int,
// we need only 1 when fetching, but store all 4
if(newVal > -1)
myTIA->myCOLUPF = (((((newVal << 8) | newVal) << 8) | newVal) << 8) | newVal;
return myTIA->myCOLUPF & 0xff;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIADebug::coluBK(int newVal)
{
// TIA::myCOLUxx are stored 4 copies to each int,
// we need only 1 when fetching, but store all 4
if(newVal > -1)
myTIA->myCOLUBK = (((((newVal << 8) | newVal) << 8) | newVal) << 8) | newVal;
return myTIA->myCOLUBK & 0xff;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -141,11 +197,10 @@ string TIADebug::state()
// TODO: inverse video for changed regs. Core needs to track this. // TODO: inverse video for changed regs. Core needs to track this.
// TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR // TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR
// TIA::myCOLUxx are stored 4 copies to each int, we need only 1 uInt8 COLUP0 = coluP0();
uInt8 COLUP0 = myTIA->myCOLUP0 & 0xff; uInt8 COLUP1 = coluP1();
uInt8 COLUP1 = myTIA->myCOLUP1 & 0xff; uInt8 COLUPF = coluPF();
uInt8 COLUPF = myTIA->myCOLUPF & 0xff; uInt8 COLUBK = coluBK();
uInt8 COLUBK = myTIA->myCOLUBK & 0xff;
// TIA::myPF holds all 3 PFx regs, we shall extract // TIA::myPF holds all 3 PFx regs, we shall extract
int PF = myTIA->myPF; int PF = myTIA->myPF;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIADebug.hxx,v 1.6 2005-07-08 17:22:40 stephena Exp $ // $Id: TIADebug.hxx,v 1.7 2005-07-14 18:28:35 stephena Exp $
//============================================================================ //============================================================================
#ifndef TIA_DEBUG_HXX #ifndef TIA_DEBUG_HXX
@ -29,6 +29,7 @@ class TiaState : public DebuggerState
{ {
public: public:
IntArray ram; IntArray ram;
IntArray coluRegs;
}; };
class TIADebug : public DebuggerSystem class TIADebug : public DebuggerSystem
@ -42,6 +43,10 @@ class TIADebug : public DebuggerSystem
void saveOldState(); void saveOldState();
// FIXME - add whole slew of setXXX() methods // FIXME - add whole slew of setXXX() methods
uInt8 coluP0(int newVal = -1);
uInt8 coluP1(int newVal = -1);
uInt8 coluPF(int newVal = -1);
uInt8 coluBK(int newVal = -1);
int scanlines(); int scanlines();
int frameCount(); int frameCount();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Array.hxx,v 1.6 2005-07-02 18:34:54 stephena Exp $ // $Id: Array.hxx,v 1.7 2005-07-14 18:28:36 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -192,7 +192,8 @@ class Array
} // Namespace GUI } // Namespace GUI
typedef GUI::Array<int> IntArray; typedef GUI::Array<int> IntArray;
typedef GUI::Array<bool> BoolArray; typedef GUI::Array<bool> BoolArray;
typedef GUI::Array<uInt8> ByteArray;
#endif #endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: DataGridWidget.cxx,v 1.13 2005-07-07 15:19:04 stephena Exp $ // $Id: DataGridWidget.cxx,v 1.14 2005-07-14 18:28:36 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -297,42 +297,63 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers)
break; break;
case 'n': // negate case 'n': // negate
negateCell(); if(_editable)
dirty = true; {
negateCell();
dirty = true;
}
break; break;
case 'i': // invert case 'i': // invert
case '!': case '!':
invertCell(); if(_editable)
dirty = true; {
invertCell();
dirty = true;
}
break; break;
case '-': // decrement case '-': // decrement
decrementCell(); if(_editable)
dirty = true; {
decrementCell();
dirty = true;
}
break; break;
case '+': // increment case '+': // increment
case '=': case '=':
incrementCell(); if(_editable)
dirty = true; {
incrementCell();
dirty = true;
}
break; break;
case '<': // shift left case '<': // shift left
case ',': case ',':
lshiftCell(); if(_editable)
dirty = true; {
lshiftCell();
dirty = true;
}
break; break;
case '>': // shift right case '>': // shift right
case '.': case '.':
rshiftCell(); if(_editable)
dirty = true; {
rshiftCell();
dirty = true;
}
break; break;
case 'z': // zero case 'z': // zero
zeroCell(); if(_editable)
dirty = true; {
zeroCell();
dirty = true;
}
break; break;
default: default:

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TiaWidget.cxx,v 1.9 2005-07-12 02:27:07 urchlay Exp $ // $Id: TiaWidget.cxx,v 1.10 2005-07-14 18:28:36 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -33,18 +33,18 @@
// ID's for the various widgets // ID's for the various widgets
// We need ID's, since there are more than one of several types of widgets // We need ID's, since there are more than one of several types of widgets
enum { enum {
kRamID, kRamID = 'TWra',
kColorRegsID, kColorRegsID = 'TWcr',
kVSyncID, kVSyncID = 'TWvs',
kVBlankID kVBlankID = 'TWvb'
}; };
// Color registers // Color registers
enum { enum {
kCOLUP0Addr, kCOLUP0Addr,
kCOLUP1Addr, kCOLUP1Addr,
kCOLUBKAddr, kCOLUPFAddr,
kCOLUPFAddr kCOLUBKAddr
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -60,6 +60,7 @@ TiaWidget::TiaWidget(GuiObject* boss, int x, int y, int w, int h)
// Create a 16x1 grid holding byte values with labels // Create a 16x1 grid holding byte values with labels
myRamGrid = new DataGridWidget(boss, xpos+lwidth, ypos, 16, 1, 2, 8, kBASE_16); myRamGrid = new DataGridWidget(boss, xpos+lwidth, ypos, 16, 1, 2, 8, kBASE_16);
myRamGrid->setEditable(false);
myRamGrid->setTarget(this); myRamGrid->setTarget(this);
myRamGrid->setID(kRamID); myRamGrid->setID(kRamID);
myActiveWidget = myRamGrid; myActiveWidget = myRamGrid;
@ -130,10 +131,10 @@ TiaWidget::TiaWidget(GuiObject* boss, int x, int y, int w, int h)
xpos = 10; ypos += 2* kLineHeight; xpos = 10; ypos += 2* kLineHeight;
for(int row = 0; row < 4; ++row) for(int row = 0; row < 4; ++row)
{ {
StaticTextWidget* t = new StaticTextWidget(boss, xpos, ypos + row*kLineHeight + 2, new StaticTextWidget(boss, xpos, ypos + row*kLineHeight + 2,
40, kLineHeight, 40, kLineHeight,
regNames[row] + string(":"), regNames[row] + string(":"),
kTextAlignLeft); kTextAlignLeft);
} }
xpos += 40; xpos += 40;
myColorRegs = new DataGridWidget(boss, xpos, ypos-1, 1, 4, 2, 8, kBASE_16); myColorRegs = new DataGridWidget(boss, xpos, ypos-1, 1, 4, 2, 8, kBASE_16);
@ -168,7 +169,7 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
// It will then send the 'kDGItemDataChangedCmd' signal to change the actual // It will then send the 'kDGItemDataChangedCmd' signal to change the actual
// memory location // memory location
int addr, value; int addr, value;
const char* buf; string buf;
Debugger& dbg = instance()->debugger(); Debugger& dbg = instance()->debugger();
@ -177,10 +178,6 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case kDGItemDataChangedCmd: case kDGItemDataChangedCmd:
switch(id) switch(id)
{ {
case kRamID:
changeRam();
break;
case kColorRegsID: case kColorRegsID:
changeColorRegs(); changeColorRegs();
break; break;
@ -201,12 +198,10 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
addr = myRamGrid->getSelectedAddr(); addr = myRamGrid->getSelectedAddr();
value = myRamGrid->getSelectedValue(); value = myRamGrid->getSelectedValue();
buf = instance()->debugger().equates()->getLabel(addr).c_str(); myLabel->setEditString(dbg.equates()->getLabel(addr));
if(*buf) myLabel->setEditString(buf);
else myLabel->setEditString("");
myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10)); myDecValue->setEditString(dbg.valueToString(value, kBASE_10));
myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2)); myBinValue->setEditString(dbg.valueToString(value, kBASE_2));
break; break;
} }
break; break;
@ -243,7 +238,8 @@ void TiaWidget::fillGrid()
IntArray vlist; IntArray vlist;
BoolArray changed; BoolArray changed;
TIADebug& tia = instance()->debugger().tiaDebug(); Debugger& dbg = instance()->debugger();
TIADebug& tia = dbg.tiaDebug();
TiaState state = (TiaState&) tia.getState(); TiaState state = (TiaState&) tia.getState();
TiaState oldstate = (TiaState&) tia.getOldState(); TiaState oldstate = (TiaState&) tia.getOldState();
@ -258,40 +254,43 @@ void TiaWidget::fillGrid()
myRamGrid->setList(alist, vlist, changed); myRamGrid->setList(alist, vlist, changed);
// Scanline and VSync/VBlank // Scanline and VSync/VBlank
// FIXME myScanlines->setEditString(dbg.valueToString(tia.scanlines(), kBASE_10));
myVSync->setState(tia.vsync());
myVBlank->setState(tia.vblank());
// Color registers // Color registers
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(unsigned int i = 0; i < 4; i++) for(unsigned int i = 0; i < 4; i++)
{ {
alist.push_back(i); alist.push_back(i);
vlist.push_back(i); vlist.push_back(state.coluRegs[i]);
changed.push_back(false); changed.push_back(state.coluRegs[i] != oldstate.coluRegs[i]);
} }
myColorRegs->setList(alist, vlist, changed); myColorRegs->setList(alist, vlist, changed);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaWidget::changeRam()
{
int addr = myRamGrid->getSelectedAddr();
int value = myRamGrid->getSelectedValue();
IntArray ram;
ram.push_back(addr);
ram.push_back(value);
// instance()->debugger().setRAM(ram);
myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10));
myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaWidget::changeColorRegs() void TiaWidget::changeColorRegs()
{ {
cerr << "TiaWidget::changeColorRegs()\n";
int addr = myColorRegs->getSelectedAddr(); int addr = myColorRegs->getSelectedAddr();
int value = myColorRegs->getSelectedValue(); int value = myColorRegs->getSelectedValue();
//FIXME instance()->debugger().writeRAM(addr - kRamStart, value); switch(addr)
{
case kCOLUP0Addr:
instance()->debugger().tiaDebug().coluP0(value);
break;
case kCOLUP1Addr:
instance()->debugger().tiaDebug().coluP1(value);
break;
case kCOLUPFAddr:
instance()->debugger().tiaDebug().coluPF(value);
break;
case kCOLUBKAddr:
instance()->debugger().tiaDebug().coluBK(value);
break;
}
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TiaWidget.hxx,v 1.4 2005-07-06 19:09:26 stephena Exp $ // $Id: TiaWidget.hxx,v 1.5 2005-07-14 18:28:36 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -46,7 +46,6 @@ class TiaWidget : public Widget, public CommandSender
private: private:
void fillGrid(); void fillGrid();
void changeRam();
void changeColorRegs(); void changeColorRegs();
private: private:

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Widget.cxx,v 1.23 2005-07-06 15:09:16 stephena Exp $ // $Id: Widget.cxx,v 1.24 2005-07-14 18:28:36 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -246,17 +246,17 @@ void Widget::setNextInChain(Widget* start, Widget* hasFocus)
if(!start) if(!start)
return; return;
// FIXME - get this working // FIXME - get this working
cerr << "--------------------------------\nWidget list:\n"; //cerr << "--------------------------------\nWidget list:\n";
Widget* w1 = start; Widget* w1 = start;
while(w1) while(w1)
{ {
if(w1->getFlags() & WIDGET_TAB_NAVIGATE) if(w1->getFlags() & WIDGET_TAB_NAVIGATE)
{ {
cerr << w1 << endl; // cerr << w1 << endl;
} }
w1 = w1->_next; w1 = w1->_next;
} }
cerr << "\n--------------------------------\n"; //cerr << "\n--------------------------------\n";
// We search the array in circular fashion until the 'end' is reached // We search the array in circular fashion until the 'end' is reached
@ -397,7 +397,12 @@ CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h,
void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount) void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount)
{ {
if(isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) if(isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h)
{
toggleState(); toggleState();
// We only send a command when the widget has been changed interactively
sendCommand(_cmd, _state, _id);
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -409,7 +414,6 @@ void CheckboxWidget::setState(bool state)
_flags ^= WIDGET_INV_BORDER; _flags ^= WIDGET_INV_BORDER;
draw(); draw();
} }
sendCommand(_cmd, _state, _id);
// Refresh the screen after the checkbox is drawn // Refresh the screen after the checkbox is drawn
// TODO - create dirty rectangle // TODO - create dirty rectangle