From 81d0dfdbdc13e25e86aff5d8f022494e3ba2a3ca Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 29 Jun 2014 18:37:55 +0000 Subject: [PATCH] Some final fixes for the new cartram debugger tab. In cases where the RAM is always mapped into the same place in ROM, the ram grid now shows addresses with the correct read port address, and ram labels are properly accessed. In cases where the RAM is hidden from the 6507 or not mapped into the same place at the same time, the addresses show actual real addresses of the RAM from the POV of the cart itself (ie, RAM location zero is labeled 0, not as $1xxx). This is necessary since quiescent RAM doesn't actually have a 6507 address. Also, labels are disabled in this case. Fixed bug with incorrect offsets when reading cart RAM labels; it seems to be a copy/paste issue, since all such methods were written as if the cart was SaraChip-based. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2936 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/debugger/gui/Cart3EWidget.cxx | 45 +++++------ src/debugger/gui/Cart3EWidget.hxx | 7 +- src/debugger/gui/Cart4KSCWidget.cxx | 40 +++++----- src/debugger/gui/Cart4KSCWidget.hxx | 10 +-- src/debugger/gui/CartBFSCWidget.cxx | 40 +++++----- src/debugger/gui/CartBFSCWidget.hxx | 8 +- src/debugger/gui/CartCMWidget.cxx | 40 +++++----- src/debugger/gui/CartCMWidget.hxx | 6 +- src/debugger/gui/CartCTYWidget.cxx | 40 +++++----- src/debugger/gui/CartCTYWidget.hxx | 8 +- src/debugger/gui/CartCVWidget.cxx | 40 +++++----- src/debugger/gui/CartCVWidget.hxx | 8 +- src/debugger/gui/CartDFSCWidget.cxx | 40 +++++----- src/debugger/gui/CartDFSCWidget.hxx | 8 +- src/debugger/gui/CartDPCPlusWidget.cxx | 52 ++++++------ src/debugger/gui/CartDPCPlusWidget.hxx | 9 ++- src/debugger/gui/CartDebugWidget.hxx | 19 +++-- src/debugger/gui/CartE7Widget.cxx | 51 +++++------- src/debugger/gui/CartE7Widget.hxx | 7 +- src/debugger/gui/CartEFSCWidget.cxx | 40 +++++----- src/debugger/gui/CartEFSCWidget.hxx | 8 +- src/debugger/gui/CartF4SCWidget.cxx | 40 +++++----- src/debugger/gui/CartF4SCWidget.hxx | 9 +-- src/debugger/gui/CartF6SCWidget.cxx | 41 +++++----- src/debugger/gui/CartF6SCWidget.hxx | 9 +-- src/debugger/gui/CartF8SCWidget.cxx | 40 +++++----- src/debugger/gui/CartF8SCWidget.hxx | 9 +-- src/debugger/gui/CartFA2Widget.cxx | 40 +++++----- src/debugger/gui/CartFA2Widget.hxx | 6 +- src/debugger/gui/CartFAWidget.cxx | 40 +++++----- src/debugger/gui/CartFAWidget.hxx | 8 +- src/debugger/gui/CartRamWidget.cxx | 76 +++++++++--------- src/debugger/gui/CartRamWidget.hxx | 105 ++++++++++++------------- src/debugger/gui/DebuggerDialog.cxx | 2 +- 34 files changed, 448 insertions(+), 503 deletions(-) diff --git a/src/debugger/gui/Cart3EWidget.cxx b/src/debugger/gui/Cart3EWidget.cxx index 211a9ed4f..cc925d0db 100644 --- a/src/debugger/gui/Cart3EWidget.cxx +++ b/src/debugger/gui/Cart3EWidget.cxx @@ -169,47 +169,45 @@ string Cartridge3EWidget::bankState() return buf.str(); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Cartridge3EWidget::internalRam() -{ - return true; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 Cartridge3EWidget::internalRamSize() { return 32*1024; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +uInt32 Cartridge3EWidget::internalRamRPort(int start) +{ + return 0x0000 + start; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string Cartridge3EWidget::internalRamDescription() { ostringstream desc; desc << "Accessible 1K at a time via:\n" - << " F000-F3FF used for Read Access\n" - << " F400-F7FF used for Write Access"; + << " $F000 - $F3FF used for Read Access\n" + << " $F400 - $F7FF used for Write Access"; return desc.str(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ByteArray Cartridge3EWidget::internalRamOld(int start, int count) +const ByteArray& Cartridge3EWidget::internalRamOld(int start, int count) { - ByteArray ram; - ram.clear(); - for (int i = 0;iinternalRamSize();i++) - { + for(int i = 0; i < internalRamSize(); ++i) myOldState.internalram.push_back(myCart.myDisplayImage[i]); - } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -337,56 +335,54 @@ string CartridgeDPCPlusWidget::bankState() return buf.str(); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartridgeDPCPlusWidget::internalRam() -{ - return true; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 CartridgeDPCPlusWidget::internalRamSize() { return 5*1024; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +uInt32 CartridgeDPCPlusWidget::internalRamRPort(int start) +{ + return 0x0000 + start; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string CartridgeDPCPlusWidget::internalRamDescription() { ostringstream desc; - desc << "0000-0FFF - 4K display data\n" - << " indirectly accessible to 6507\n" - << " via DPC+'s Data Fetcher registers\n" - << "1000-13FF - 1K frequency table,\n" - << " C variables and C stack\n" - << " not accessible to 6507"; + desc << "$0000 - $0FFF - 4K display data\n" + << " indirectly accessible to 6507\n" + << " via DPC+'s Data Fetcher registers\n" + << "$1000 - $13FF - 1K frequency table,\n" + << " C variables and C stack\n" + << " not accessible to 6507"; return desc.str(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ByteArray CartridgeDPCPlusWidget::internalRamOld(int start, int count) +const ByteArray& CartridgeDPCPlusWidget::internalRamOld(int start, int count) { - ByteArray ram; - ram.clear(); - for (int i = 0;i 16) maxrow = 16; - myPageSize = maxrow * 16; + myNumRows = myRamSize / 16; + if (myNumRows > 16) myNumRows = 16; + myPageSize = myNumRows * 16; myRamGrid = new DataGridWidget(_boss, _nfont, xpos, ypos, - 16, maxrow, 2, 8, Common::Base::F_16, true); + 16, myNumRows, 2, 8, Common::Base::F_16, true); myRamGrid->setTarget(this); addFocusWidget(myRamGrid); @@ -123,28 +123,26 @@ CartRamWidget::CartRamWidget( Common::Base::toString(col, Common::Base::F_16_1), kTextAlignLeft); } - -// xpos = 02 + lwidth - _font.getStringWidth("xxxx "); + myRamStart = new StaticTextWidget(_boss, _font, xpos - _font.getStringWidth("xxxx"), ypos - myLineHeight, _font.getStringWidth("xxxx"), myFontHeight, - "00xx", kTextAlignLeft); - -// xpos = 2 + lwidth - _font.getStringWidth("xxx "); - int row; - for(row = 0; row < maxrow; ++row) + "F0xx", kTextAlignLeft); + + uInt32 row; + for(row = 0; row < myNumRows; ++row) { - new StaticTextWidget(_boss, _font, xpos - _font.getStringWidth("x "), ypos + row*myLineHeight + 2, - 3*myFontWidth, myFontHeight, - Common::Base::toString(row*16, Common::Base::F_16_1), - kTextAlignLeft); + myRamLabels[row] = + new StaticTextWidget(_boss, _font, xpos - _font.getStringWidth("x "), + ypos + row*myLineHeight + 2, + myFontWidth, myFontHeight, "", kTextAlignLeft); } - + // for smaller grids, make sure RAM cell detail fields are below the RESET button - if (maxrow < 8) + if (myNumRows < 8) row = 8 + 1; else - row = maxrow + 1; + row = myNumRows + 1; ypos += myLineHeight * row; // We need to define these widgets from right to left since the leftmost @@ -157,7 +155,7 @@ CartRamWidget::CartRamWidget( myBinValue = new EditTextWidget(boss, nfont, xpos + 4*myFontWidth + 5, ypos-2, 9*myFontWidth, myLineHeight, ""); myBinValue->setEditable(false); - + // Add Decimal display of selected RAM cell xpos -= 8*myFontWidth + 5 + 20; new StaticTextWidget(boss, lfont, xpos, ypos, 4*myFontWidth, myFontHeight, @@ -165,7 +163,7 @@ CartRamWidget::CartRamWidget( myDecValue = new EditTextWidget(boss, nfont, xpos + 4*myFontWidth + 5, ypos-2, 4*myFontWidth, myLineHeight, ""); myDecValue->setEditable(false); - + // Add Label of selected RAM cell int xpos_r = xpos - 20; xpos = x + 10; @@ -200,22 +198,22 @@ void CartRamWidget::fillGrid(bool updateOld) IntArray vlist; BoolArray changed; uInt32 start = myCurrentRamBank * myPageSize; - ByteArray oldRam = myCart.internalRamOld(start, myPageSize); - ByteArray currentRam = myCart.internalRamCurrent(start, myPageSize); - - for(uInt32 i=0; isetNumRows(myRamSize / myPageSize); myRamGrid->setList(alist, vlist, changed); if(updateOld) @@ -223,12 +221,16 @@ void CartRamWidget::fillGrid(bool updateOld) myRevertButton->setEnabled(false); myUndoButton->setEnabled(false); } - + // Update RAM labels + uInt32 rport = myCart.internalRamRPort(start); + uInt32 page = rport & 0xf0; char buf[5]; - BSPF_snprintf(buf, 5, "%04X", start); + BSPF_snprintf(buf, 5, "%04X", rport); buf[2] = buf[3] = 'x'; - myRamStart->setLabel(buf); + myRamStart->setLabel(buf); + for(uInt32 row = 0; row < myNumRows; ++row, page += 0x10) + myRamLabels[row]->setLabel(Common::Base::toString(page, Common::Base::F_16_1)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -266,15 +268,14 @@ string CartRamWidget::doSearch(const string& str) mySearchAddr.clear(); mySearchValue.clear(); mySearchState.clear(); - + // Now, search all memory locations for this value, and add it to the // search array bool hitfound = false; // CartDebug& dbg = instance().debugger().cartDebug(); // const CartState& state = (CartState&) dbg.getState(); - ByteArray currentRam = myCart.internalRamCurrent(0, myCart.internalRamSize()); - + const ByteArray& currentRam = myCart.internalRamCurrent(0, myCart.internalRamSize()); for(uInt32 addr = 0; addr < myCart.internalRamSize(); ++addr) { int value = currentRam[addr]; @@ -290,8 +291,7 @@ string CartRamWidget::doSearch(const string& str) hitfound = true; } } - - + // If we have some hits, enable the comparison methods if(hitfound) { @@ -303,7 +303,7 @@ string CartRamWidget::doSearch(const string& str) // Finally, show the search results in the list showSearchResults(); - return ""; + return EmptyString; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -343,14 +343,14 @@ string CartRamWidget::doCompare(const string& str) // Now, search all memory locations previously 'found' for this value bool hitfound = false; - ByteArray currentRam = myCart.internalRamCurrent(0, myCart.internalRamSize()); + const ByteArray& currentRam = myCart.internalRamCurrent(0, myCart.internalRamSize()); IntArray tempAddrList, tempValueList; mySearchState.clear(); for(uInt32 i = 0; i < myCart.internalRamSize(); ++i) mySearchState.push_back(false); - for(unsigned int i = 0; i < mySearchAddr.size(); ++i) + for(uInt32 i = 0; i < mySearchAddr.size(); ++i) { if(comparitiveSearch) { @@ -382,7 +382,7 @@ string CartRamWidget::doCompare(const string& str) // Finally, show the search results in the list showSearchResults(); - return ""; + return EmptyString; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/CartRamWidget.hxx b/src/debugger/gui/CartRamWidget.hxx index 7cb9b1148..6f1606e82 100644 --- a/src/debugger/gui/CartRamWidget.hxx +++ b/src/debugger/gui/CartRamWidget.hxx @@ -41,28 +41,21 @@ class CartRamWidget : public Widget, public CommandSender { public: CartRamWidget(GuiObject* boss, const GUI::Font& lfont, - const GUI::Font& nfont, + const GUI::Font& nfont, int x, int y, int w, int h, CartDebugWidget& cartDebug); virtual ~CartRamWidget() { }; - public: - - // Inform the ROM Widget that the underlying cart has somehow changed - void invalidate() - { - sendCommand(RomWidget::kInvalidateListing, -1, -1); - } - - void loadConfig(); + private: + void loadConfig(); void handleCommand(CommandSender* sender, int cmd, int data, int id); - void fillGrid(bool updateOld); + void fillGrid(bool updateOld); - void showInputBox(int cmd); - string doSearch(const string& str); - string doCompare(const string& str); - void doRestart(); - void showSearchResults(); + void showInputBox(int cmd); + string doSearch(const string& str); + string doCompare(const string& str); + void doRestart(); + void showSearchResults(); protected: // Font used for 'normal' text; _font is for 'label' text @@ -72,47 +65,47 @@ class CartRamWidget : public Widget, public CommandSender // we may as well make them protected variables int myFontWidth, myFontHeight, myLineHeight, myButtonHeight; - ostringstream& buffer() { myBuffer.str(""); return myBuffer; } - DataGridWidget* myRamGrid; - StaticTextWidget* myRamStart; - private: - enum { - kUndoCmd = 'RWud', - kRevertCmd = 'RWrv', - kSearchCmd = 'RWse', - kCmpCmd = 'RWcp', - kRestartCmd = 'RWrs', - kSValEntered = 'RWsv', - kCValEntered = 'RWcv' - }; - - int myUndoAddress; - int myUndoValue; - - CartDebugWidget& myCart; - StringListWidget* myDesc; - ostringstream myBuffer; - EditTextWidget* myBinValue; - EditTextWidget* myDecValue; - EditTextWidget* myLabel; - int myCurrentRamBank; - uInt32 myRamSize; - uInt32 myPageSize; - - ButtonWidget* myRevertButton; - ButtonWidget* myUndoButton; - ButtonWidget* mySearchButton; - ButtonWidget* myCompareButton; - ButtonWidget* myRestartButton; - - InputTextDialog* myInputBox; - - ByteArray myOldValueList; - IntArray mySearchAddr; - IntArray mySearchValue; - BoolArray mySearchState; - + enum { + kUndoCmd = 'RWud', + kRevertCmd = 'RWrv', + kSearchCmd = 'RWse', + kCmpCmd = 'RWcp', + kRestartCmd = 'RWrs', + kSValEntered = 'RWsv', + kCValEntered = 'RWcv' + }; + + int myUndoAddress; + int myUndoValue; + + CartDebugWidget& myCart; + StringListWidget* myDesc; + + DataGridWidget* myRamGrid; + StaticTextWidget* myRamStart; + StaticTextWidget* myRamLabels[16]; + EditTextWidget* myBinValue; + EditTextWidget* myDecValue; + EditTextWidget* myLabel; + + uInt32 myCurrentRamBank; + uInt32 myRamSize; + uInt32 myPageSize; + uInt32 myNumRows; + + ButtonWidget* myRevertButton; + ButtonWidget* myUndoButton; + ButtonWidget* mySearchButton; + ButtonWidget* myCompareButton; + ButtonWidget* myRestartButton; + + InputTextDialog* myInputBox; + + ByteArray myOldValueList; + IntArray mySearchAddr; + IntArray mySearchValue; + BoolArray mySearchState; }; #endif diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index eafb54c68..061ace68a 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -437,7 +437,7 @@ void DebuggerDialog::addRomArea() addToFocusList(myCartDebug->getFocusList(), myRomTab, tabID); // The cartridge RAM tab - if (myCartDebug->internalRam()) + if (myCartDebug->internalRamSize() > 0) { tabID = myRomTab->addTab(" Cartridge RAM "); myCartRam = new CartRamWidget(myRomTab, *myLFont, *myNFont, 2, 2, tabWidth - 1,