diff --git a/stella/src/debugger/TIADebug.cxx b/stella/src/debugger/TIADebug.cxx index 621cc5b55..8f9e483b8 100644 --- a/stella/src/debugger/TIADebug.cxx +++ b/stella/src/debugger/TIADebug.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: TIADebug.cxx,v 1.22 2005-08-18 16:21:11 stephena Exp $ +// $Id: TIADebug.cxx,v 1.23 2005-10-13 18:53:07 stephena Exp $ //============================================================================ #include "System.hxx" @@ -86,6 +86,15 @@ DebuggerState& TIADebug::getState() myState.size.push_back(nusizM1()); myState.size.push_back(sizeBL()); + // Audio registers + myState.aud.clear(); + myState.aud.push_back(audF0()); + myState.aud.push_back(audF1()); + myState.aud.push_back(audC0()); + myState.aud.push_back(audC1()); + myState.aud.push_back(audV0()); + myState.aud.push_back(audV1()); + return myState; } @@ -138,6 +147,14 @@ void TIADebug::saveOldState() myOldState.size.push_back(nusizM1()); myOldState.size.push_back(sizeBL()); + // Audio registers + myOldState.aud.clear(); + myOldState.aud.push_back(audF0()); + myOldState.aud.push_back(audF1()); + myOldState.aud.push_back(audC0()); + myOldState.aud.push_back(audC1()); + myOldState.aud.push_back(audV0()); + myOldState.aud.push_back(audV1()); } /* the set methods now use mySystem->poke(). This will save us the diff --git a/stella/src/debugger/TIADebug.hxx b/stella/src/debugger/TIADebug.hxx index 9bc260f20..428b737a2 100644 --- a/stella/src/debugger/TIADebug.hxx +++ b/stella/src/debugger/TIADebug.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: TIADebug.hxx,v 1.18 2005-08-18 16:19:07 stephena Exp $ +// $Id: TIADebug.hxx,v 1.19 2005-10-13 18:53:07 stephena Exp $ //============================================================================ #ifndef TIA_DEBUG_HXX @@ -96,6 +96,7 @@ class TiaState : public DebuggerState IntArray hm; IntArray pf; IntArray size; + IntArray aud; }; class TIADebug : public DebuggerSystem diff --git a/stella/src/debugger/gui/AudioWidget.cxx b/stella/src/debugger/gui/AudioWidget.cxx new file mode 100644 index 000000000..7d3c9c5e7 --- /dev/null +++ b/stella/src/debugger/gui/AudioWidget.cxx @@ -0,0 +1,184 @@ +//============================================================================ +// +// 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: AudioWidget.cxx,v 1.1 2005-10-13 18:53:07 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#include "OSystem.hxx" +#include "FrameBuffer.hxx" +#include "GuiUtils.hxx" +#include "GuiObject.hxx" +#include "TIADebug.hxx" +#include "Widget.hxx" +#include "DataGridWidget.hxx" +#include "AudioWidget.hxx" + +// ID's for the various widgets +// We need ID's, since there are more than one of several types of widgets +enum { + kAUDFID, + kAUDCID, + kAUDVID +}; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +AudioWidget::AudioWidget(GuiObject* boss, int x, int y, int w, int h) + : Widget(boss, x, y, w, h), + CommandSender(boss) +{ + const GUI::Font& font = instance()->consoleFont(); + const int fontWidth = font.getMaxCharWidth(), + fontHeight = font.getFontHeight(), + lineHeight = font.getLineHeight(); + int xpos = 10, ypos = 25, lwidth = font.getStringWidth("AUDW: "); + StaticTextWidget* t; + + // AudF registers + t = new StaticTextWidget(boss, xpos, ypos+2, + lwidth, fontHeight, + "AUDF:", kTextAlignLeft); + t->setFont(font); + xpos += lwidth; + myAudF = new DataGridWidget(boss, font, xpos, ypos, + 2, 1, 2, 5, kBASE_16); + myAudF->setTarget(this); + myAudF->setID(kAUDFID); + myAudF->setEditable(false); + addFocusWidget(myAudF); + + for(int col = 0; col < 2; ++col) + { + t = new StaticTextWidget(boss, xpos + col*myAudF->colWidth() + 7, + ypos - lineHeight, + fontWidth, fontHeight, + Debugger::to_hex_4(col), + kTextAlignLeft); + t->setFont(font); + } + + // AudC registers + xpos = 10; ypos += lineHeight + 5; + t = new StaticTextWidget(boss, xpos, ypos+2, + lwidth, fontHeight, + "AUDC:", kTextAlignLeft); + t->setFont(font); + xpos += lwidth; + myAudC = new DataGridWidget(boss, font, xpos, ypos, + 2, 1, 2, 4, kBASE_16); + myAudC->setTarget(this); + myAudC->setID(kAUDCID); + myAudC->setEditable(false); + addFocusWidget(myAudC); + + // AudV registers + xpos = 10; ypos += lineHeight + 5; + t = new StaticTextWidget(boss, xpos, ypos+2, + lwidth, fontHeight, + "AUDV:", kTextAlignLeft); + t->setFont(font); + xpos += lwidth; + myAudV = new DataGridWidget(boss, font, xpos, ypos, + 2, 1, 2, 4, kBASE_16); + myAudV->setTarget(this); + myAudV->setID(kAUDVID); + myAudV->setEditable(false); + addFocusWidget(myAudV); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +AudioWidget::~AudioWidget() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void AudioWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) +{ +/* FIXME - implement this + // We simply change the values in the DataGridWidget + // It will then send the 'kDGItemDataChangedCmd' signal to change the actual + // memory location + int addr, value; + string buf; + + Debugger& dbg = instance()->debugger(); + TIADebug& tia = dbg.tiaDebug(); + + switch(cmd) + { + case kDGItemDataChangedCmd: + switch(id) + { + case kNusizP0ID: + tia.nusizP0(myNusizP0->getSelectedValue()); + myNusizP0Text->setEditString(tia.nusizP0String()); + break; + } + break; + } +*/ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void AudioWidget::loadConfig() +{ +//cerr << "AudioWidget::loadConfig()\n"; + fillGrid(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void AudioWidget::fillGrid() +{ + IntArray alist; + IntArray vlist; + BoolArray blist, changed, grNew, grOld; + + Debugger& dbg = instance()->debugger(); + TIADebug& tia = dbg.tiaDebug(); + TiaState state = (TiaState&) tia.getState(); + TiaState oldstate = (TiaState&) tia.getOldState(); + + // AUDF0/1 + alist.clear(); vlist.clear(); changed.clear(); + for(unsigned int i = 0; i < 2; i++) + { + alist.push_back(i); + vlist.push_back(state.aud[i]); + changed.push_back(state.aud[i] != oldstate.aud[i]); + } + myAudF->setList(alist, vlist, changed); + + // AUDC0/1 + alist.clear(); vlist.clear(); changed.clear(); + for(unsigned int i = 2; i < 4; i++) + { + alist.push_back(i-2); + vlist.push_back(state.aud[i]); + changed.push_back(state.aud[i] != oldstate.aud[i]); + } + myAudC->setList(alist, vlist, changed); + + // AUDV0/1 + alist.clear(); vlist.clear(); changed.clear(); + for(unsigned int i = 4; i < 6; i++) + { + alist.push_back(i-4); + vlist.push_back(state.aud[i]); + changed.push_back(state.aud[i] != oldstate.aud[i]); + } + myAudV->setList(alist, vlist, changed); +} diff --git a/stella/src/debugger/gui/AudioWidget.hxx b/stella/src/debugger/gui/AudioWidget.hxx new file mode 100644 index 000000000..379ca9192 --- /dev/null +++ b/stella/src/debugger/gui/AudioWidget.hxx @@ -0,0 +1,50 @@ +//============================================================================ +// +// 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: AudioWidget.hxx,v 1.1 2005-10-13 18:53:07 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#ifndef AUDIO_WIDGET_HXX +#define AUDIO_WIDGET_HXX + +class GuiObject; +class DataGridWidget; + +#include "Widget.hxx" +#include "Command.hxx" + + +class AudioWidget : public Widget, public CommandSender +{ + public: + AudioWidget(GuiObject* boss, int x, int y, int w, int h); + virtual ~AudioWidget(); + + void handleCommand(CommandSender* sender, int cmd, int data, int id); + void loadConfig(); + + private: + void fillGrid(); + + private: + DataGridWidget* myAudF; + DataGridWidget* myAudC; + DataGridWidget* myAudV; +}; + +#endif diff --git a/stella/src/debugger/gui/DataGridWidget.cxx b/stella/src/debugger/gui/DataGridWidget.cxx index 082a07feb..426f5b69d 100644 --- a/stella/src/debugger/gui/DataGridWidget.cxx +++ b/stella/src/debugger/gui/DataGridWidget.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: DataGridWidget.cxx,v 1.2 2005-09-23 23:35:02 stephena Exp $ +// $Id: DataGridWidget.cxx,v 1.3 2005-10-13 18:53:07 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -64,6 +64,9 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font, int size = _rows * _cols; while((int)_hiliteList.size() < size) _hiliteList.push_back(false); + + // Set lower and upper bounds to sane values + setRange(0, 1 << bits); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -167,6 +170,13 @@ void DataGridWidget::setSelectedValue(int value) setDirty(); draw(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DataGridWidget::setRange(int lower, int upper) +{ + _lowerBound = MAX(0, lower); + _upperBound = MIN(1 << _bits, upper); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::handleMouseDown(int x, int y, int button, int clickCount) { @@ -572,7 +582,7 @@ void DataGridWidget::endEditMode() // Update the both the string representation and the real data int value = instance()->debugger().stringToValue(_editString); - if(value < 0 || value > (1 << _bits)) + if(value < _lowerBound || value >= _upperBound) { abortEditMode(); return; @@ -609,6 +619,8 @@ void DataGridWidget::negateCell() { int mask = (1 << _bits) - 1; int value = getSelectedValue(); + if(mask != _upperBound - 1) // ignore when values aren't byte-aligned + return; value = ((~value) + 1) & mask; setSelectedValue(value); @@ -619,6 +631,8 @@ void DataGridWidget::invertCell() { int mask = (1 << _bits) - 1; int value = getSelectedValue(); + if(mask != _upperBound - 1) // ignore when values aren't byte-aligned + return; value = ~value & mask; setSelectedValue(value); @@ -629,6 +643,8 @@ void DataGridWidget::decrementCell() { int mask = (1 << _bits) - 1; int value = getSelectedValue(); + if(value <= _lowerBound) // take care of wrap-around + value = _upperBound; value = (value - 1) & mask; setSelectedValue(value); @@ -639,6 +655,8 @@ void DataGridWidget::incrementCell() { int mask = (1 << _bits) - 1; int value = getSelectedValue(); + if(value >= _upperBound - 1) // take care of wrap-around + value = _lowerBound - 1; value = (value + 1) & mask; setSelectedValue(value); @@ -649,6 +667,8 @@ void DataGridWidget::lshiftCell() { int mask = (1 << _bits) - 1; int value = getSelectedValue(); + if(mask != _upperBound - 1) // ignore when values aren't byte-aligned + return; value = (value << 1) & mask; setSelectedValue(value); @@ -659,6 +679,8 @@ void DataGridWidget::rshiftCell() { int mask = (1 << _bits) - 1; int value = getSelectedValue(); + if(mask != _upperBound - 1) // ignore when values aren't byte-aligned + return; value = (value >> 1) & mask; setSelectedValue(value); diff --git a/stella/src/debugger/gui/DataGridWidget.hxx b/stella/src/debugger/gui/DataGridWidget.hxx index 47a9a0005..2b5a13cb9 100644 --- a/stella/src/debugger/gui/DataGridWidget.hxx +++ b/stella/src/debugger/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.1 2005-08-30 17:51:26 stephena Exp $ +// $Id: DataGridWidget.hxx,v 1.2 2005-10-13 18:53:07 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -59,6 +59,8 @@ class DataGridWidget : public EditableWidget int getSelectedAddr() const { return _addrList[_selectedItem]; } int getSelectedValue() const { return _valueList[_selectedItem]; } + void setRange(int lower, int upper); + virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, int button, int clickCount); virtual bool handleKeyDown(int ascii, int keycode, int modifiers); @@ -96,6 +98,8 @@ class DataGridWidget : public EditableWidget int _rowHeight; int _colWidth; int _bits; + int _lowerBound; + int _upperBound; BaseFormat _base; diff --git a/stella/src/debugger/gui/DebuggerDialog.cxx b/stella/src/debugger/gui/DebuggerDialog.cxx index 8af734c97..9d186d5bd 100644 --- a/stella/src/debugger/gui/DebuggerDialog.cxx +++ b/stella/src/debugger/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.7 2005-09-30 00:40:33 stephena Exp $ +// $Id: DebuggerDialog.cxx,v 1.8 2005-10-13 18:53:07 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -25,6 +25,7 @@ #include "TiaInfoWidget.hxx" #include "TiaOutputWidget.hxx" #include "TiaZoomWidget.hxx" +#include "AudioWidget.hxx" #include "PromptWidget.hxx" #include "CpuWidget.hxx" #include "RamWidget.hxx" @@ -167,6 +168,12 @@ void DebuggerDialog::addTabArea() myTab->setParentWidget(tabID, tia); addToFocusList(tia->getFocusList(), tabID); + // The Audio tab + tabID = myTab->addTab("Audio"); + AudioWidget* aud = new AudioWidget(myTab, 2, 2, widWidth, widHeight); + myTab->setParentWidget(tabID, aud); + addToFocusList(aud->getFocusList(), tabID); + // The input/output tab (part of RIOT) // tabID = myTab->addTab("I/O"); diff --git a/stella/src/debugger/gui/RomWidget.cxx b/stella/src/debugger/gui/RomWidget.cxx index cf481279f..d2a1ad000 100644 --- a/stella/src/debugger/gui/RomWidget.cxx +++ b/stella/src/debugger/gui/RomWidget.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: RomWidget.cxx,v 1.11 2005-10-13 01:13:20 urchlay Exp $ +// $Id: RomWidget.cxx,v 1.12 2005-10-13 18:53:07 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -24,6 +24,7 @@ #include "Debugger.hxx" #include "DebuggerParser.hxx" #include "CpuDebug.hxx" +#include "DataGridWidget.hxx" #include "PackedBitArray.hxx" #include "GuiObject.hxx" #include "InputTextDialog.hxx" @@ -44,9 +45,42 @@ RomWidget::RomWidget(GuiObject* boss, const GUI::Font& font, int x, int y) myCurrentBank(-1) { int w = 58 * font.getMaxCharWidth(), - h = 31 * font.getLineHeight(); + h = 30 * font.getLineHeight(), + xpos, ypos; + StaticTextWidget* t; - myRomList = new RomListWidget(boss, font, x, y, w, h); + // Create bank editable area + xpos = x + 40; ypos = y; + t = new StaticTextWidget(boss, xpos, ypos, + font.getStringWidth("Current bank: "), + font.getFontHeight(), + "Current bank:", kTextAlignLeft); + t->setFont(font); + + xpos += t->getWidth() + 10; + myBank = new DataGridWidget(boss, font, xpos, ypos-2, + 1, 1, 1, 2, kBASE_16_4); + myBank->setTarget(this); + myBank->setRange(0, instance()->debugger().bankCount()); + addFocusWidget(myBank); + + // Show number of banks + xpos += myBank->getWidth() + 45; + t = new StaticTextWidget(boss, xpos, ypos, + font.getStringWidth("Total banks: "), + font.getFontHeight(), + "Total banks:", kTextAlignLeft); + t->setFont(font); + + xpos += t->getWidth() + 10; + myBankCount = new EditTextWidget(boss, xpos, ypos-2, + 20, font.getLineHeight(), ""); + myBankCount->setFont(font); + myBankCount->setEditable(false); + + // Create rom listing + xpos = x; ypos += myBank->getHeight() + 2; + myRomList = new RomListWidget(boss, font, xpos, ypos, w, h); myRomList->setTarget(this); myRomList->myMenu->setTarget(this); myRomList->setStyle(kSolidFill); @@ -113,6 +147,12 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) } break; } + + case kDGItemDataChangedCmd: + { + int bank = myBank->getSelectedValue(); + instance()->debugger().setBank(bank); + } } } @@ -120,9 +160,10 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) void RomWidget::loadConfig() { Debugger& dbg = instance()->debugger(); + bool bankChanged = myCurrentBank != dbg.getBank(); // Only reload full bank when necessary - if(myListIsDirty || myCurrentBank != dbg.getBank()) + if(myListIsDirty || bankChanged) { initialUpdate(); myListIsDirty = false; @@ -131,7 +172,6 @@ void RomWidget::loadConfig() { incrementalUpdate(myRomList->currentPos(), myRomList->rows()); } - myCurrentBank = dbg.getBank(); // Update romlist to point to current PC @@ -152,6 +192,20 @@ void RomWidget::loadConfig() if(iter != myLineList.end()) myRomList->setHighlighted(iter->second); + + // Set current bank + IntArray alist; + IntArray vlist; + BoolArray changed; + + alist.push_back(-1); + vlist.push_back(dbg.getBank()); + changed.push_back(bankChanged); + myBank->setList(alist, vlist, changed); + + // Indicate total number of banks + int bankCount = dbg.bankCount(); + myBankCount->setEditString(dbg.valueToString(bankCount)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/debugger/gui/RomWidget.hxx b/stella/src/debugger/gui/RomWidget.hxx index e50a71c6c..877c2dc69 100644 --- a/stella/src/debugger/gui/RomWidget.hxx +++ b/stella/src/debugger/gui/RomWidget.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: RomWidget.hxx,v 1.6 2005-10-06 17:28:55 stephena Exp $ +// $Id: RomWidget.hxx,v 1.7 2005-10-13 18:53:07 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -23,6 +23,8 @@ #define ROM_WIDGET_HXX class GuiObject; +class DataGridWidget; +class EditTextWidget; class InputTextDialog; class RomListWidget; class StringList; @@ -65,6 +67,8 @@ class RomWidget : public Widget, public CommandSender /** List of line numbers indexed by address */ AddrToLine myLineList; + DataGridWidget* myBank; + EditTextWidget* myBankCount; InputTextDialog* mySaveRom; bool myListIsDirty; diff --git a/stella/src/debugger/gui/TiaWidget.hxx b/stella/src/debugger/gui/TiaWidget.hxx index 9c33e8263..adfe34292 100644 --- a/stella/src/debugger/gui/TiaWidget.hxx +++ b/stella/src/debugger/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.1 2005-08-30 17:51:26 stephena Exp $ +// $Id: TiaWidget.hxx,v 1.2 2005-10-13 18:53:07 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -47,8 +47,6 @@ class TiaWidget : public Widget, public CommandSender private: void fillGrid(); void changeColorRegs(); - void convertCharToBool(BoolArray& b, unsigned char value); - int convertBoolToInt(const BoolArray& b); private: DataGridWidget* myRamGrid; diff --git a/stella/src/debugger/gui/module.mk b/stella/src/debugger/gui/module.mk index e957afb95..60bb8c430 100644 --- a/stella/src/debugger/gui/module.mk +++ b/stella/src/debugger/gui/module.mk @@ -1,6 +1,7 @@ MODULE := src/debugger/gui MODULE_OBJS := \ + src/debugger/gui/AudioWidget.o \ src/debugger/gui/CpuWidget.o \ src/debugger/gui/PromptWidget.o \ src/debugger/gui/RamWidget.o \