From 7973140c5ad5eab615324ecc01bf7081f343ae97 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 19 Mar 2019 20:44:38 +0100 Subject: [PATCH] refactored and split CartCDFWidget.cxx (see CartCDFInfoWidget.cxx) --- src/debugger/gui/CartCDFInfoWidget.cxx | 68 ++++++++ src/debugger/gui/CartCDFInfoWidget.hxx | 46 ++++++ src/debugger/gui/CartCDFWidget.cxx | 217 +++++++++++++------------ src/debugger/gui/CartDebugWidget.cxx | 25 ++- src/debugger/gui/CartRamWidget.cxx | 12 +- src/debugger/gui/DataGridWidget.cxx | 6 +- src/debugger/gui/DebuggerDialog.cxx | 20 ++- src/debugger/gui/DebuggerDialog.hxx | 1 + src/emucore/Cart.hxx | 15 +- src/emucore/CartCDF.cxx | 23 +++ src/emucore/CartCDF.hxx | 6 +- src/windows/Stella.vcxproj | 2 + src/windows/Stella.vcxproj.filters | 6 + 13 files changed, 311 insertions(+), 136 deletions(-) create mode 100644 src/debugger/gui/CartCDFInfoWidget.cxx create mode 100644 src/debugger/gui/CartCDFInfoWidget.hxx diff --git a/src/debugger/gui/CartCDFInfoWidget.cxx b/src/debugger/gui/CartCDFInfoWidget.cxx new file mode 100644 index 000000000..2c27b5636 --- /dev/null +++ b/src/debugger/gui/CartCDFInfoWidget.cxx @@ -0,0 +1,68 @@ +//============================================================================ +// +// 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-2019 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#include "CartCDFInfoWidget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeCDFInfoWidget::CartridgeCDFInfoWidget( + GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, + int x, int y, int w, int h, CartridgeCDF& cart) + : CartDebugWidget(boss, lfont, nfont, x, y, w, h), + myCart(cart) +{ + uInt16 size = 8 * 4096; + + ostringstream info; + info << describeCDFVersion(cart.myCDFSubtype) << " cartridge\n" + << "32K ROM, seven 4K banks are accessible to 2600\n" + << "8K CDF RAM\n" + << "CDF registers accessible @ $FFF0 - $FFF3\n" + << "Banks accessible at hotspots $FFF5 to $FFFB\n" + << "Startup bank = " << cart.startBank() << "\n"; + +#if 0 + // Eventually, we should query this from the debugger/disassembler + for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF5; i < 7; ++i, offset += 0x1000) + { + uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; + start -= start % 0x1000; + info << "Bank " << i << " @ $" << HEX4 << (start + 0x80) << " - " + << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n"; + } +#endif + + addBaseInformation(size, "AtariAge", info.str()); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string CartridgeCDFInfoWidget::describeCDFVersion(CartridgeCDF::CDFSubtype subtype) +{ + switch(subtype) + { + case CartridgeCDF::CDFSubtype::CDF0: + return "CDF (v0)"; + + case CartridgeCDF::CDFSubtype::CDF1: + return "CDF (v1)"; + + case CartridgeCDF::CDFSubtype::CDFJ: + return "CDFJ"; + + default: + throw runtime_error("unreachable"); + } +} \ No newline at end of file diff --git a/src/debugger/gui/CartCDFInfoWidget.hxx b/src/debugger/gui/CartCDFInfoWidget.hxx new file mode 100644 index 000000000..495fa3bb0 --- /dev/null +++ b/src/debugger/gui/CartCDFInfoWidget.hxx @@ -0,0 +1,46 @@ +//============================================================================ +// +// 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-2019 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#ifndef CARTRIDGECDF_INFO_WIDGET_HXX +#define CARTRIDGECDF_INFO_WIDGET_HXX + +#include "CartCDF.hxx" +#include "CartDebugWidget.hxx" + +class CartridgeCDFInfoWidget : public CartDebugWidget +{ + public: + CartridgeCDFInfoWidget(GuiObject* boss, const GUI::Font& lfont, + const GUI::Font& nfont, + int x, int y, int w, int h, + CartridgeCDF& cart); + virtual ~CartridgeCDFInfoWidget() = default; + + private: + CartridgeCDF& myCart; + + private: + static string describeCDFVersion(CartridgeCDF::CDFSubtype subtype); + + // Following constructors and assignment operators not supported + CartridgeCDFInfoWidget() = delete; + CartridgeCDFInfoWidget(const CartridgeCDFInfoWidget&) = delete; + CartridgeCDFInfoWidget(CartridgeCDFInfoWidget&&) = delete; + CartridgeCDFInfoWidget& operator=(const CartridgeCDFInfoWidget&) = delete; + CartridgeCDFInfoWidget& operator=(CartridgeCDFInfoWidget&&) = delete; +}; +#endif diff --git a/src/debugger/gui/CartCDFWidget.cxx b/src/debugger/gui/CartCDFWidget.cxx index 5d1d92861..41e5ee83d 100644 --- a/src/debugger/gui/CartCDFWidget.cxx +++ b/src/debugger/gui/CartCDFWidget.cxx @@ -19,29 +19,6 @@ #include "PopUpWidget.hxx" #include "CartCDFWidget.hxx" -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string CartridgeCDFWidget::describeCDFVersion(CartridgeCDF::CDFSubtype subtype) { - switch (subtype) { - case CartridgeCDF::CDFSubtype::CDF0: - return "CDF (v0)"; - - case CartridgeCDF::CDFSubtype::CDF1: - return "CDF (v1)"; - - case CartridgeCDF::CDFSubtype::CDFJ: - return "CDFJ"; - - default: - throw runtime_error("unreachable"); - } -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartridgeCDFWidget::isCDFJ() const -{ - return myCart.myCDFSubtype == CartridgeCDF::CDFSubtype::CDFJ; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeCDFWidget::CartridgeCDFWidget( GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, @@ -49,30 +26,12 @@ CartridgeCDFWidget::CartridgeCDFWidget( : CartDebugWidget(boss, lfont, nfont, x, y, w, h), myCart(cart) { - uInt16 size = 8 * 4096; + const int VBORDER = 8; + const int HBORDER = 2; + const int INDENT = 20; + const int VGAP = 4; - ostringstream info; - info << describeCDFVersion(cart.myCDFSubtype) << " cartridge\n" - << "32K ROM, seven 4K banks are accessible to 2600\n" - << "8K CDF RAM\n" - << "CDF registers accessible @ $FFF0 - $FFF3\n" - << "Banks accessible at hotspots $FFF5 to $FFFB\n" - << "Startup bank = " << cart.startBank() << "\n"; - -#if 0 - // Eventually, we should query this from the debugger/disassembler - for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF5; i < 7; ++i, offset += 0x1000) - { - uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; - start -= start % 0x1000; - info << "Bank " << i << " @ $" << HEX4 << (start + 0x80) << " - " - << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n"; - } -#endif - - int xpos = 10, - ypos = addBaseInformation(size, "AtariAge", info.str()) + - myLineHeight; + int xpos = HBORDER, ypos = VBORDER; VariantList items; VarList::push_back(items, "0 ($FFF5)"); @@ -82,35 +41,46 @@ CartridgeCDFWidget::CartridgeCDFWidget( VarList::push_back(items, "4 ($FFF9)"); VarList::push_back(items, "5 ($FFFA)"); VarList::push_back(items, "6 ($FFFB)"); - myBank = - new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("0 ($FFFx) "), - myLineHeight, items, "Set bank ", - _font.getStringWidth("Set bank "), kBankChanged); + myBank = new PopUpWidget(boss, _font, xpos, ypos, _font.getStringWidth("0 ($FFFx) "), + myLineHeight, items, + "Set bank ", _font.getStringWidth("Set bank "), kBankChanged); myBank->setTarget(this); - addFocusWidget(myBank); + //addFocusWidget(myBank); - int lwidth = _font.getStringWidth("Datastream Increments"); // get width of the widest label + // Fast Fetch flag + myFastFetch = new CheckboxWidget(boss, _font, myBank->getRight() + 24, ypos + 1, + "Fast Fetcher enabled"); + myFastFetch->setTarget(this); + myFastFetch->setEditable(false); + + int lwidth; // Datastream Pointers -#define DS_X 30 +#define DS_X (HBORDER + _font.getStringWidth("xx ")) xpos = DS_X; - ypos += myLineHeight + 4; - new StaticTextWidget(boss, _font, xpos, ypos, lwidth, - myFontHeight, "Datastream Pointers", TextAlign::Left); - xpos += lwidth; + ypos += myLineHeight + VGAP * 4; + new StaticTextWidget(boss, _font, xpos, ypos, "Datastream Pointers"); - myDatastreamPointers = new DataGridWidget(boss, _nfont, DS_X, ypos+myLineHeight-2, 4, 8, 6, 32, Common::Base::F_16_3_2); + myDatastreamPointers = new DataGridWidget(boss, _nfont, DS_X, + ypos+myLineHeight, 4, 8, 6, 32, + Common::Base::F_16_3_2); myDatastreamPointers->setTarget(this); myDatastreamPointers->setEditable(false); - myCommandStreamPointer = new DataGridWidget(boss, _nfont, DS_X + myDatastreamPointers->getWidth() * 3 / 4, ypos+myLineHeight-2 + 8*myLineHeight, 1, 1, 6, 32, Common::Base::F_16_3_2); + myCommandStreamPointer = new DataGridWidget(boss, _nfont, DS_X + myDatastreamPointers->getWidth() * 3 / 4, + ypos+myLineHeight + 8*myLineHeight, 1, 1, 6, 32, + Common::Base::F_16_3_2); myCommandStreamPointer->setTarget(this); myCommandStreamPointer->setEditable(false); if (isCDFJ()) - myJumpStreamPointers = new DataGridWidget(boss, _nfont, DS_X + myDatastreamPointers->getWidth() * 2 / 4, ypos+myLineHeight-2 + 9*myLineHeight, 2, 1, 6, 32, Common::Base::F_16_3_2); + myJumpStreamPointers = new DataGridWidget(boss, _nfont, DS_X + myDatastreamPointers->getWidth() * 2 / 4, + ypos+myLineHeight + 9*myLineHeight, 2, 1, 6, 32, + Common::Base::F_16_3_2); else - myJumpStreamPointers = new DataGridWidget(boss, _nfont, DS_X + myDatastreamPointers->getWidth() * 3 / 4, ypos+myLineHeight-2 + 9*myLineHeight, 1, 1, 6, 32, Common::Base::F_16_3_2); + myJumpStreamPointers = new DataGridWidget(boss, _nfont, DS_X + myDatastreamPointers->getWidth() * 3 / 4, + ypos+myLineHeight + 9*myLineHeight, 1, 1, 6, 32, + Common::Base::F_16_3_2); myJumpStreamPointers->setTarget(this); myJumpStreamPointers->setEditable(false); @@ -119,97 +89,105 @@ CartridgeCDFWidget::CartridgeCDFWidget( { myDatastreamLabels[row] = new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "), - ypos+myLineHeight-2 + row*myLineHeight + 2, - myFontWidth*2, myFontHeight, "", TextAlign::Left); - myDatastreamLabels[row]->setLabel(Common::Base::toString(row * 4, Common::Base::F_16_2)); + ypos+myLineHeight + row*myLineHeight + 2, " "); + myDatastreamLabels[row]->setLabel(Common::Base::toString(row * 4, + Common::Base::F_16_2)); } - lwidth = _font.getStringWidth("Jump Data (21+22)"); + lwidth = _font.getStringWidth("Jump Data (21|22)"); myDatastreamLabels[8] = new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "), - ypos+myLineHeight-2 + 8*myLineHeight + 2, - lwidth, myFontHeight, "Write Data (20)", TextAlign::Left); + ypos+myLineHeight + 8*myLineHeight + 2, + lwidth, myFontHeight, "Write Data (20)"); myDatastreamLabels[9] = new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "), - ypos+myLineHeight-2 + 9*myLineHeight + 2, + ypos+myLineHeight + 9*myLineHeight + 2, lwidth, myFontHeight, - isCDFJ() ? "Jmp Data (21+22)" : "Jump Data (21)", - TextAlign::Left); + isCDFJ() ? "Jump Data (21|22)" : "Jump Data (21)"); // Datastream Increments - xpos = DS_X + myDatastreamPointers->getWidth() + 20; - new StaticTextWidget(boss, _font, xpos, ypos, lwidth, - myFontHeight, "Datastream Increments", TextAlign::Left); + xpos = DS_X + myDatastreamPointers->getWidth() + 16; + new StaticTextWidget(boss, _font, xpos, ypos, "Datastream Increments"); - myDatastreamIncrements = new DataGridWidget(boss, _nfont, xpos, ypos+myLineHeight-2, 4, 8, 5, 32, Common::Base::F_16_2_2); + myDatastreamIncrements = new DataGridWidget(boss, _nfont, xpos, + ypos+myLineHeight, 4, 8, 5, 32, + Common::Base::F_16_2_2); myDatastreamIncrements->setTarget(this); myDatastreamIncrements->setEditable(false); - myCommandStreamIncrement = new DataGridWidget(boss, _nfont, xpos, ypos+myLineHeight-2 + 8*myLineHeight, 1, 1, 5, 32, Common::Base::F_16_2_2); + myCommandStreamIncrement = new DataGridWidget(boss, _nfont, xpos, + ypos+myLineHeight + 8*myLineHeight, 1, 1, 5, 32, + Common::Base::F_16_2_2); myCommandStreamIncrement->setTarget(this); myCommandStreamIncrement->setEditable(false); - myJumpStreamIncrements = new DataGridWidget(boss, _nfont, xpos, ypos+myLineHeight-2 + 9*myLineHeight, isCDFJ() ? 2 : 1, 1, 5, 32, Common::Base::F_16_2_2); + myJumpStreamIncrements = new DataGridWidget(boss, _nfont, xpos, + ypos+myLineHeight + 9*myLineHeight, isCDFJ() ? 2 : 1, 1, 5, 32, + Common::Base::F_16_2_2); myJumpStreamIncrements->setTarget(this); myJumpStreamIncrements->setEditable(false); + xpos = HBORDER; ypos += myLineHeight * 11 + VGAP * 4; + + lwidth = _font.getStringWidth("Waveform Sizes "); // Music counters - xpos = 10; ypos += myLineHeight*12 + 4; - new StaticTextWidget(boss, _font, xpos, ypos, lwidth, - myFontHeight, "Music Counters", TextAlign::Left); + new StaticTextWidget(_boss, _font, xpos, ypos, "Music States:"); + xpos += INDENT; + ypos += myLineHeight + VGAP; + + new StaticTextWidget(boss, _font, xpos, ypos, "Counters"); xpos += lwidth; - myMusicCounters = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 8, 32, Common::Base::F_16_8); + myMusicCounters = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 8, 32, + Common::Base::F_16_8); myMusicCounters->setTarget(this); myMusicCounters->setEditable(false); // Music frequencies - xpos = 10; ypos += myLineHeight + 4; - new StaticTextWidget(boss, _font, xpos, ypos, lwidth, - myFontHeight, "Music Frequencies", TextAlign::Left); + xpos = HBORDER + INDENT; ypos += myLineHeight + VGAP; + new StaticTextWidget(boss, _font, xpos, ypos, "Frequencies"); xpos += lwidth; - myMusicFrequencies = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 8, 32, Common::Base::F_16_8); + myMusicFrequencies = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 8, 32, + Common::Base::F_16_8); myMusicFrequencies->setTarget(this); myMusicFrequencies->setEditable(false); // Music waveforms - xpos = 10; ypos += myLineHeight + 4; - new StaticTextWidget(boss, _font, xpos, ypos, lwidth, - myFontHeight, "Music Waveforms", TextAlign::Left); + xpos = HBORDER + INDENT; ypos += myLineHeight + VGAP; + new StaticTextWidget(boss, _font, xpos, ypos, "Waveforms"); xpos += lwidth; - myMusicWaveforms = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 4, 16, Common::Base::F_16_2); + myMusicWaveforms = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 8, 16, + Common::Base::F_16_2); myMusicWaveforms->setTarget(this); myMusicWaveforms->setEditable(false); - int xpossp = xpos + myMusicWaveforms->getWidth() + 20; - int lwidth2 = _font.getStringWidth("Sample Pointer "); - new StaticTextWidget(boss, _font, xpossp, ypos, lwidth2, - myFontHeight, "Sample Pointer ", TextAlign::Left); - - mySamplePointer = new DataGridWidget(boss, _nfont, xpossp + lwidth2, ypos-2, 1, 1, 8, 32, Common::Base::F_16_8); - mySamplePointer->setTarget(this); - mySamplePointer->setEditable(false); - // Music waveform sizes - xpos = 10; ypos += myLineHeight + 4; - new StaticTextWidget(boss, _font, xpos, ypos, lwidth, - myFontHeight, "Music Waveform Sizes", TextAlign::Left); + xpos = HBORDER + INDENT; ypos += myLineHeight + VGAP; + new StaticTextWidget(boss, _font, xpos, ypos, "Waveform Sizes"); xpos += lwidth; - myMusicWaveformSizes = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 4, 16, Common::Base::F_16_2); + myMusicWaveformSizes = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 8, 16, + Common::Base::F_16_2); myMusicWaveformSizes->setTarget(this); myMusicWaveformSizes->setEditable(false); - // Fast Fetch and Digital Audio flags - xpos = 10; ypos += myLineHeight + 4; - myFastFetch = new CheckboxWidget(boss, _font, xpos, ypos, "Fast Fetcher enabled"); - myFastFetch->setTarget(this); - myFastFetch->setEditable(false); + // Digital Audio flag + xpos = HBORDER; ypos += myLineHeight + VGAP; - myDigitalSample = new CheckboxWidget(boss, _font, xpossp, ypos, "Digital Sample mode"); + myDigitalSample = new CheckboxWidget(boss, _font, xpos, ypos, "Digital Sample mode"); myDigitalSample->setTarget(this); myDigitalSample->setEditable(false); + + xpos = HBORDER + INDENT; ypos += myLineHeight + VGAP; + + int lwidth2 = _font.getStringWidth("Sample Pointer "); + new StaticTextWidget(boss, _font, xpos, ypos, "Sample Pointer"); + + mySamplePointer = new DataGridWidget(boss, _nfont, xpos + lwidth2, ypos - 2, 1, 1, 8, 32, + Common::Base::F_16_8); + mySamplePointer->setTarget(this); + mySamplePointer->setEditable(false); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -474,3 +452,28 @@ uInt8 CartridgeCDFWidget::internalRamGetValue(int addr) { return myCart.myCDFRAM[addr]; } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string CartridgeCDFWidget::describeCDFVersion(CartridgeCDF::CDFSubtype subtype) +{ + switch(subtype) + { + case CartridgeCDF::CDFSubtype::CDF0: + return "CDF (v0)"; + + case CartridgeCDF::CDFSubtype::CDF1: + return "CDF (v1)"; + + case CartridgeCDF::CDFSubtype::CDFJ: + return "CDFJ"; + + default: + throw runtime_error("unreachable"); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeCDFWidget::isCDFJ() const +{ + return myCart.myCDFSubtype == CartridgeCDF::CDFSubtype::CDFJ; +} diff --git a/src/debugger/gui/CartDebugWidget.cxx b/src/debugger/gui/CartDebugWidget.cxx index 022a54d90..397617a0b 100644 --- a/src/debugger/gui/CartDebugWidget.cxx +++ b/src/debugger/gui/CartDebugWidget.cxx @@ -45,24 +45,22 @@ int CartDebugWidget::addBaseInformation(int bytes, const string& manufacturer, EditTextWidget* w = nullptr; ostringstream buf; - int x = 10, y = 10; + int x = 2, y = 8; // Add ROM size, manufacturer and bankswitch info - new StaticTextWidget(_boss, _font, x, y, lwidth, - myFontHeight, "ROM Size ", TextAlign::Left); + new StaticTextWidget(_boss, _font, x, y + 1, "ROM Size "); buf << bytes << " bytes"; if(bytes >= 1024) buf << " / " << (bytes/1024) << "KB"; - w = new EditTextWidget(_boss, _nfont, x+lwidth, y, - fwidth, myLineHeight, buf.str()); + w = new EditTextWidget(_boss, _nfont, x+lwidth, y - 1, + fwidth, myLineHeight, buf.str()); w->setEditable(false); y += myLineHeight + 4; - new StaticTextWidget(_boss, _font, x, y, lwidth, - myFontHeight, "Manufacturer ", TextAlign::Left); - w = new EditTextWidget(_boss, _nfont, x+lwidth, y, - fwidth, myLineHeight, manufacturer); + new StaticTextWidget(_boss, _font, x, y + 1, "Manufacturer "); + w = new EditTextWidget(_boss, _nfont, x+lwidth, y - 1, + fwidth, myLineHeight, manufacturer); w->setEditable(false); y += myLineHeight + 4; @@ -72,10 +70,9 @@ int CartDebugWidget::addBaseInformation(int bytes, const string& manufacturer, if(lines < 3) lines = 3; if(lines > maxlines) lines = maxlines; - new StaticTextWidget(_boss, _font, x, y, lwidth, - myFontHeight, "Description ", TextAlign::Left); - myDesc = new StringListWidget(_boss, _nfont, x+lwidth, y, - fwidth, lines * myLineHeight, false); + new StaticTextWidget(_boss, _font, x, y + 1, "Description "); + myDesc = new StringListWidget(_boss, _nfont, x+lwidth, y - 1, + fwidth, lines * myLineHeight, false); myDesc->setEditable(false); myDesc->setList(sl); @@ -93,5 +90,5 @@ void CartDebugWidget::invalidate() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartDebugWidget::loadConfig() { - myDesc->setSelected(0); + //myDesc->setSelected(0); } diff --git a/src/debugger/gui/CartRamWidget.cxx b/src/debugger/gui/CartRamWidget.cxx index 2af1b0415..6a30af6bf 100644 --- a/src/debugger/gui/CartRamWidget.cxx +++ b/src/debugger/gui/CartRamWidget.cxx @@ -44,18 +44,17 @@ CartRamWidget::CartRamWidget( EditTextWidget* etw = nullptr; ostringstream buf; - int xpos = 2, ypos = 5; + int xpos = 2, ypos = 8; // Add RAM size - new StaticTextWidget(_boss, _font, xpos, ypos, lwidth, - myFontHeight, "RAM Size ", TextAlign::Left); + new StaticTextWidget(_boss, _font, xpos, ypos + 1, "RAM Size "); uInt32 ramsize = cartDebug.internalRamSize(); buf << ramsize << " bytes"; if(ramsize >= 1024) buf << " / " << (ramsize/1024) << "KB"; - etw = new EditTextWidget(boss, nfont, xpos+lwidth, ypos, + etw = new EditTextWidget(boss, nfont, xpos+lwidth, ypos - 1, fwidth, myLineHeight, buf.str()); etw->setEditable(false); ypos += myLineHeight + 4; @@ -69,9 +68,8 @@ CartRamWidget::CartRamWidget( if(lines < 3) lines = 3; if(lines > maxlines) lines = maxlines; - new StaticTextWidget(_boss, _font, xpos, ypos, lwidth, - myFontHeight, "Description ", TextAlign::Left); - myDesc = new StringListWidget(boss, nfont, xpos+lwidth, ypos, + new StaticTextWidget(_boss, _font, xpos, ypos + 1, "Description "); + myDesc = new StringListWidget(boss, nfont, xpos+lwidth, ypos - 1, fwidth, lines * myLineHeight, false); myDesc->setEditable(false); myDesc->setList(sl); diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 1c23d88fc..da5e68d9d 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -661,8 +661,10 @@ void DataGridWidget::drawWidget(bool hilite) // Cross out the grid? if(_crossGrid) - for(row = 1; row < 4; ++row) - s.hLine(_x, _y + (row * lineheight/4), _x + linewidth, kColor); + { + s.line(_x + 1, _y + 1, _x + _w - 2, _y + _h - 1, kColor); + s.line(_x + _w - 2, _y + 1, _x + 1, _y + _h - 1, kColor); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index da573c28e..5cfbb87a1 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -632,14 +632,26 @@ void DebuggerDialog::addRomArea() addTabWidget(myRomTab); // The main disassembly tab - tabID = myRomTab->addTab(" Disassembly "); + tabID = myRomTab->addTab(" Disassembly ", TabWidget::AUTO_WIDTH); myRom = new RomWidget(myRomTab, *myLFont, *myNFont, 2, 2, tabWidth - 1, tabHeight - myRomTab->getTabHeight() - 2); myRomTab->setParentWidget(tabID, myRom); addToFocusList(myRom->getFocusList(), myRomTab, tabID); - // The 'cart-specific' information tab - tabID = myRomTab->addTab(instance().console().cartridge().name()); + // The 'cart-specific' information tab (optional) + + tabID = myRomTab->addTab(" " + instance().console().cartridge().name() + " ", TabWidget::AUTO_WIDTH); + myCartInfo = instance().console().cartridge().infoWidget( + myRomTab, *myLFont, *myNFont, 2, 2, tabWidth - 1, + tabHeight - myRomTab->getTabHeight() - 2); + if(myCartInfo != nullptr) + { + myRomTab->setParentWidget(tabID, myCartInfo); + addToFocusList(myCartInfo->getFocusList(), myRomTab, tabID); + tabID = myRomTab->addTab(" States ", TabWidget::AUTO_WIDTH); + } + + // The 'cart-specific' state tab myCartDebug = instance().console().cartridge().debugWidget( myRomTab, *myLFont, *myNFont, 2, 2, tabWidth - 1, tabHeight - myRomTab->getTabHeight() - 2); @@ -651,7 +663,7 @@ void DebuggerDialog::addRomArea() // The cartridge RAM tab if (myCartDebug->internalRamSize() > 0) { - tabID = myRomTab->addTab(" Cartridge RAM "); + tabID = myRomTab->addTab(" Cartridge RAM ", TabWidget::AUTO_WIDTH); myCartRam = new CartRamWidget(myRomTab, *myLFont, *myNFont, 2, 2, tabWidth - 1, tabHeight - myRomTab->getTabHeight() - 2, *myCartDebug); diff --git a/src/debugger/gui/DebuggerDialog.hxx b/src/debugger/gui/DebuggerDialog.hxx index f959f7909..bfffba254 100644 --- a/src/debugger/gui/DebuggerDialog.hxx +++ b/src/debugger/gui/DebuggerDialog.hxx @@ -124,6 +124,7 @@ class DebuggerDialog : public Dialog CpuWidget* myCpu; RamWidget* myRam; RomWidget* myRom; + CartDebugWidget* myCartInfo; CartDebugWidget* myCartDebug; CartRamWidget* myCartRam; EditTextWidget* myMessageBox; diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 9f2b5dbe3..41773bae3 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -199,6 +199,16 @@ class Cartridge : public Device */ virtual uInt32 thumbCallback(uInt8 function, uInt32 value1, uInt32 value2) { return 0; } + /** + Get optional debugger widget responsible for displaying info about the cart. + This can be used when the debugWidget runs out of space. + */ + virtual CartDebugWidget* infoWidget(GuiObject* boss, const GUI::Font& lfont, + const GUI::Font& nfont, int x, int y, int w, int h) + { + return nullptr; + } + /** Get debugger widget responsible for accessing the inner workings of the cart. This will need to be overridden and implemented by @@ -206,7 +216,10 @@ class Cartridge : public Device of each cart type can be very different from each other. */ virtual CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont, - const GUI::Font& nfont, int x, int y, int w, int h) { return nullptr; } + const GUI::Font& nfont, int x, int y, int w, int h) + { + return nullptr; + } protected: /** diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index d34838b40..d33224ae5 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -20,6 +20,7 @@ #ifdef DEBUGGER_SUPPORT #include "Debugger.hxx" #include "CartCDFWidget.hxx" + #include "CartCDFInfoWidget.hxx" #endif #include "System.hxx" @@ -693,6 +694,22 @@ void CartridgeCDF::setVersion() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string CartridgeCDF::name() const +{ + switch(myCDFSubtype) + { + case CDFSubtype::CDF0: + return "CartridgeCDF0"; + case CDFSubtype::CDF1: + return "CartridgeCDF1"; + case CDFSubtype::CDFJ: + return "CartridgeCDFJ"; + default: + return "Cart unknown"; + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #ifdef DEBUGGER_SUPPORT CartDebugWidget* CartridgeCDF::debugWidget(GuiObject* boss, const GUI::Font& lfont, @@ -700,4 +717,10 @@ void CartridgeCDF::setVersion() { return new CartridgeCDFWidget(boss, lfont, nfont, x, y, w, h, *this); } + + CartDebugWidget* CartridgeCDF::infoWidget(GuiObject* boss, const GUI::Font& lfont, + const GUI::Font& nfont, int x, int y, int w, int h) + { + return new CartridgeCDFInfoWidget(boss, lfont, nfont, x, y, w, h, *this); + } #endif diff --git a/src/emucore/CartCDF.hxx b/src/emucore/CartCDF.hxx index de5c3ab7e..7a3f9a3c9 100644 --- a/src/emucore/CartCDF.hxx +++ b/src/emucore/CartCDF.hxx @@ -21,6 +21,7 @@ class System; class Thumbulator; class CartridgeCDFWidget; +class CartridgeCDFInfoWidget; #include "bspf.hxx" #include "Cart.hxx" @@ -41,6 +42,7 @@ class CartridgeCDFWidget; class CartridgeCDF : public Cartridge { friend CartridgeCDFWidget; + friend CartridgeCDFInfoWidget; friend class CartridgeRamCDFWidget; public: @@ -134,7 +136,7 @@ class CartridgeCDF : public Cartridge @return The name of the object */ - string name() const override { return "CartridgeCDF"; } + string name() const override; /** Used for Thumbulator to pass values back to the cartridge @@ -148,6 +150,8 @@ class CartridgeCDF : public Cartridge */ CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, int x, int y, int w, int h) override; + CartDebugWidget* infoWidget(GuiObject* boss, const GUI::Font& lfont, + const GUI::Font& nfont, int x, int y, int w, int h) override; #endif public: diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index 03785edec..9bebffcd5 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -402,6 +402,7 @@ + @@ -1098,6 +1099,7 @@ + diff --git a/src/windows/Stella.vcxproj.filters b/src/windows/Stella.vcxproj.filters index 0c22027b1..b057cebf5 100644 --- a/src/windows/Stella.vcxproj.filters +++ b/src/windows/Stella.vcxproj.filters @@ -954,6 +954,9 @@ Source Files\emucore + + Source Files\debugger + @@ -1949,6 +1952,9 @@ Header Files\emucore + + Header Files\debugger +