From bfef7362c900f72b86809cb425c7f891a15883bf Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 19 Apr 2020 18:59:07 +0200 Subject: [PATCH] refactored Cart3F, CartCV and CartBF(SC) widgets --- src/debugger/gui/Cart3FWidget.cxx | 79 ++------- src/debugger/gui/Cart3FWidget.hxx | 17 +- src/debugger/gui/CartBFSCWidget.cxx | 218 ++---------------------- src/debugger/gui/CartBFSCWidget.hxx | 33 +--- src/debugger/gui/CartBFWidget.cxx | 145 +--------------- src/debugger/gui/CartBFWidget.hxx | 15 +- src/debugger/gui/CartCVWidget.cxx | 85 +-------- src/debugger/gui/CartE0Widget.hxx | 1 + src/debugger/gui/CartEnhancedWidget.cxx | 17 +- src/debugger/gui/CartEnhancedWidget.hxx | 2 +- src/debugger/gui/CartF0Widget.hxx | 2 +- src/emucore/CartEnhanced.cxx | 3 - 12 files changed, 65 insertions(+), 552 deletions(-) diff --git a/src/debugger/gui/Cart3FWidget.cxx b/src/debugger/gui/Cart3FWidget.cxx index 13cd851bd..76f331502 100644 --- a/src/debugger/gui/Cart3FWidget.cxx +++ b/src/debugger/gui/Cart3FWidget.cxx @@ -16,80 +16,33 @@ //============================================================================ #include "Cart3F.hxx" -#include "PopUpWidget.hxx" #include "Cart3FWidget.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cartridge3FWidget::Cartridge3FWidget( GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, int x, int y, int w, int h, Cartridge3F& cart) - : CartDebugWidget(boss, lfont, nfont, x, y, w, h), - myCart(cart) + : CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart) +{ + myHotspotDelta = 0; + initialize(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string Cartridge3FWidget::description() { ostringstream info; size_t size; + const uInt8* image = myCart.getImage(size); - cart.getImage(size); - info << "Tigervision 3F cartridge, 2-256 2K banks\n" - << "Startup bank = " << cart.startBank() << " or undetermined\n" - << "First 2K bank selected by writing to $3F\n" - << "Last 2K always points to last 2K of ROM\n"; - + info << "Tigervision 3F cartridge, 2 - 256 2K banks\n" + << "First 2K bank selected by writing to " << hotspotStr() << "\n" + << "Last 2K always points to last 2K of ROM\n" + << "Startup bank = " << myCart.startBank() << " or undetermined\n"; // Eventually, we should query this from the debugger/disassembler - uInt16 start = (cart.myImage[size-3] << 8) | cart.myImage[size-4]; + uInt16 start = (image[size-3] << 8) | image[size-4]; start -= start % 0x1000; - info << "Bank RORG" << " = $" << Common::Base::HEX4 << start << "\n"; + info << "Bank RORG $" << Common::Base::HEX4 << start << "\n"; - int xpos = 2, - ypos = addBaseInformation(size, "TigerVision", info.str()) + myLineHeight; - - VariantList items; - for(uInt16 i = 0; i < cart.romBankCount(); ++i) - VarList::push_back(items, Variant(i).toString() + " ($3F)"); - - ostringstream label; - label << "Set bank ($" << Common::Base::HEX4 << start << " - $" << - (start+0x7FF) << ") "; - myBank = - new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("0 ($3F) "), - myLineHeight, items, label.str(), - _font.getStringWidth(label.str()), kBankChanged); - myBank->setTarget(this); - addFocusWidget(myBank); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Cartridge3FWidget::loadConfig() -{ - Debugger& dbg = instance().debugger(); - CartDebug& cart = dbg.cartDebug(); - const CartState& state = static_cast(cart.getState()); - const CartState& oldstate = static_cast(cart.getOldState()); - - myBank->setSelectedIndex(myCart.getBank(0), state.bank != oldstate.bank); - - CartDebugWidget::loadConfig(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Cartridge3FWidget::handleCommand(CommandSender* sender, - int cmd, int data, int id) -{ - if(cmd == kBankChanged) - { - myCart.unlockBank(); - myCart.bank(myBank->getSelected()); - myCart.lockBank(); - invalidate(); - } -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string Cartridge3FWidget::bankState() -{ - ostringstream& buf = buffer(); - - buf << "Bank = #" << std::dec << myCart.getSegmentBank() << ", hotspot = $3F"; - - return buf.str(); + return info.str(); } diff --git a/src/debugger/gui/Cart3FWidget.hxx b/src/debugger/gui/Cart3FWidget.hxx index 859184057..7e3ee65e9 100644 --- a/src/debugger/gui/Cart3FWidget.hxx +++ b/src/debugger/gui/Cart3FWidget.hxx @@ -19,11 +19,10 @@ #define CARTRIDGE3F_WIDGET_HXX class Cartridge3F; -class PopUpWidget; -#include "CartDebugWidget.hxx" +#include "CartEnhancedWidget.hxx" -class Cartridge3FWidget : public CartDebugWidget +class Cartridge3FWidget : public CartEnhancedWidget { public: Cartridge3FWidget(GuiObject* boss, const GUI::Font& lfont, @@ -33,17 +32,13 @@ class Cartridge3FWidget : public CartDebugWidget virtual ~Cartridge3FWidget() = default; private: - Cartridge3F& myCart; - PopUpWidget* myBank{nullptr}; + string manufacturer() override { return "TigerVision"; } - enum { kBankChanged = 'bkCH' }; + string description() override; + + int bankSegs() override { return 1; } private: - void loadConfig() override; - void handleCommand(CommandSender* sender, int cmd, int data, int id) override; - - string bankState() override; - // Following constructors and assignment operators not supported Cartridge3FWidget() = delete; Cartridge3FWidget(const Cartridge3FWidget&) = delete; diff --git a/src/debugger/gui/CartBFSCWidget.cxx b/src/debugger/gui/CartBFSCWidget.cxx index 819e72b39..00109d9e9 100644 --- a/src/debugger/gui/CartBFSCWidget.cxx +++ b/src/debugger/gui/CartBFSCWidget.cxx @@ -15,221 +15,25 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#include "Debugger.hxx" -#include "CartDebug.hxx" #include "CartBFSC.hxx" -#include "PopUpWidget.hxx" #include "CartBFSCWidget.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeBFSCWidget::CartridgeBFSCWidget( - GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, - int x, int y, int w, int h, CartridgeBFSC& cart) - : CartDebugWidget(boss, lfont, nfont, x, y, w, h), - myCart(cart) + GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, + int x, int y, int w, int h, CartridgeBFSC& cart) + : CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart) { - uInt32 size = 64 * 4096; + initialize(); +} +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string CartridgeBFSCWidget::description() +{ ostringstream info; - info << "256K BFSC + RAM, 64 4K banks\n" - << "128 bytes RAM @ $F000 - $F0FF\n" - << " $F080 - $F0FF (R), $F000 - $F07F (W)\n" - << "Startup bank = " << cart.startBank() << "\n"; - // Eventually, we should query this from the debugger/disassembler - for(uInt32 i = 0, offset = 0xFFC, spot = 0xF80; i < 64; ++i, offset += 0x1000) - { - uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; - start -= start % 0x1000; - info << "Bank " << std::dec << i << " @ $" << Common::Base::HEX4 << (start + 0x100) - << " - " << "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n"; - } + info << "256K BFSC + RAM, 64 4K banks\n"; + info << CartEnhancedWidget::description(); - int xpos = 2, - ypos = addBaseInformation(size, "CPUWIZ", info.str()) + myLineHeight; - - VariantList items; - VarList::push_back(items, " 0 ($FF80)"); - VarList::push_back(items, " 1 ($FF81)"); - VarList::push_back(items, " 2 ($FF82)"); - VarList::push_back(items, " 3 ($FF83)"); - VarList::push_back(items, " 4 ($FF84)"); - VarList::push_back(items, " 5 ($FF85)"); - VarList::push_back(items, " 6 ($FF86)"); - VarList::push_back(items, " 7 ($FF87)"); - VarList::push_back(items, " 8 ($FF88)"); - VarList::push_back(items, " 9 ($FF89)"); - VarList::push_back(items, "10 ($FF8A)"); - VarList::push_back(items, "11 ($FF8B)"); - VarList::push_back(items, "12 ($FF8C)"); - VarList::push_back(items, "13 ($FF8D)"); - VarList::push_back(items, "14 ($FF8E)"); - VarList::push_back(items, "15 ($FF8F)"); - VarList::push_back(items, "16 ($FF90)"); - VarList::push_back(items, "17 ($FF91)"); - VarList::push_back(items, "18 ($FF92)"); - VarList::push_back(items, "19 ($FF93)"); - VarList::push_back(items, "20 ($FF94)"); - VarList::push_back(items, "21 ($FF95)"); - VarList::push_back(items, "22 ($FF96)"); - VarList::push_back(items, "23 ($FF97)"); - VarList::push_back(items, "24 ($FF98)"); - VarList::push_back(items, "25 ($FF99)"); - VarList::push_back(items, "26 ($FF9A)"); - VarList::push_back(items, "27 ($FF9B)"); - VarList::push_back(items, "28 ($FF9C)"); - VarList::push_back(items, "29 ($FF9D)"); - VarList::push_back(items, "30 ($FF9E)"); - VarList::push_back(items, "31 ($FF9F)"); - VarList::push_back(items, "32 ($FFA0)"); - VarList::push_back(items, "33 ($FFA1)"); - VarList::push_back(items, "34 ($FFA2)"); - VarList::push_back(items, "35 ($FFA3)"); - VarList::push_back(items, "36 ($FFA4)"); - VarList::push_back(items, "37 ($FFA5)"); - VarList::push_back(items, "38 ($FFA6)"); - VarList::push_back(items, "39 ($FFA7)"); - VarList::push_back(items, "40 ($FFA8)"); - VarList::push_back(items, "41 ($FFA9)"); - VarList::push_back(items, "42 ($FFAA)"); - VarList::push_back(items, "43 ($FFAB)"); - VarList::push_back(items, "44 ($FFAC)"); - VarList::push_back(items, "45 ($FFAD)"); - VarList::push_back(items, "46 ($FFAE)"); - VarList::push_back(items, "47 ($FFAF)"); - VarList::push_back(items, "48 ($FFB0)"); - VarList::push_back(items, "49 ($FFB1)"); - VarList::push_back(items, "50 ($FFB2)"); - VarList::push_back(items, "51 ($FFB3)"); - VarList::push_back(items, "52 ($FFB4)"); - VarList::push_back(items, "53 ($FFB5)"); - VarList::push_back(items, "54 ($FFB6)"); - VarList::push_back(items, "55 ($FFB7)"); - VarList::push_back(items, "56 ($FFB8)"); - VarList::push_back(items, "57 ($FFB9)"); - VarList::push_back(items, "58 ($FFBA)"); - VarList::push_back(items, "59 ($FFBB)"); - VarList::push_back(items, "60 ($FFBC)"); - VarList::push_back(items, "61 ($FFBD)"); - VarList::push_back(items, "62 ($FFBE)"); - VarList::push_back(items, "63 ($FFBF)"); - - myBank = - new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("63 ($FFBF)"), - myLineHeight, items, "Set bank ", - 0, kBankChanged); - myBank->setTarget(this); - addFocusWidget(myBank); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeBFSCWidget::saveOldState() -{ - myOldState.internalram.clear(); - - for(uInt32 i = 0; i < internalRamSize(); ++i) - myOldState.internalram.push_back(myCart.myRAM[i]); - - myOldState.bank = myCart.getBank(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeBFSCWidget::loadConfig() -{ - myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank); - - CartDebugWidget::loadConfig(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeBFSCWidget::handleCommand(CommandSender* sender, - int cmd, int data, int id) -{ - if(cmd == kBankChanged) - { - myCart.unlockBank(); - myCart.bank(myBank->getSelected()); - myCart.lockBank(); - invalidate(); - } -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string CartridgeBFSCWidget::bankState() -{ - ostringstream& buf = buffer(); - - static constexpr std::array spot = { - "$FF80", "$FF81", "$FF82", "$FF83", "$FF84", "$FF85", "$FF86", "$FF87", - "$FF88", "$FF89", "$FF8A", "$FF8B", "$FF8C", "$FF8D", "$FF8E", "$FF8F", - "$FF90", "$FF91", "$FF92", "$FF93", "$FF94", "$FF95", "$FF96", "$FF97", - "$FF98", "$FF99", "$FF9A", "$FF9B", "$FF9C", "$FF9D", "$FF9E", "$FF9F", - "$FFA0", "$FFA1", "$FFA2", "$FFA3", "$FFA4", "$FFA5", "$FFA6", "$FFA7", - "$FFA8", "$FFA9", "$FFAA", "$FFAB", "$FFAC", "$FFAD", "$FFAE", "$FFAF", - "$FFB0", "$FFB1", "$FFB2", "$FFB3", "$FFB4", "$FFB5", "$FFB6", "$FFB7", - "$FFB8", "$FFB9", "$FFBA", "$FFBB", "$FFBC", "$FFBD", "$FFBE", "$FFBF" - }; - buf << "Bank = " << std::dec << myCart.getBank() - << ", hotspot = " << spot[myCart.getBank()]; - - return buf.str(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 CartridgeBFSCWidget::internalRamSize() -{ - return 128; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 CartridgeBFSCWidget::internalRamRPort(int start) -{ - return 0xF080 + start; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string CartridgeBFSCWidget::internalRamDescription() -{ - ostringstream desc; - desc << "$F000 - $F07F used for Write Access\n" - << "$F080 - $F0FF used for Read Access"; - - return desc.str(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const ByteArray& CartridgeBFSCWidget::internalRamOld(int start, int count) -{ - myRamOld.clear(); - for(int i = 0; i < count; i++) - myRamOld.push_back(myOldState.internalram[start + i]); - return myRamOld; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const ByteArray& CartridgeBFSCWidget::internalRamCurrent(int start, int count) -{ - myRamCurrent.clear(); - for(int i = 0; i < count; i++) - myRamCurrent.push_back(myCart.myRAM[start + i]); - return myRamCurrent; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeBFSCWidget::internalRamSetValue(int addr, uInt8 value) -{ - myCart.myRAM[addr] = value; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 CartridgeBFSCWidget::internalRamGetValue(int addr) -{ - return myCart.myRAM[addr]; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string CartridgeBFSCWidget::internalRamLabel(int addr) -{ - CartDebug& dbg = instance().debugger().cartDebug(); - return dbg.getLabel(addr + 0xF080, false); + return info.str(); } diff --git a/src/debugger/gui/CartBFSCWidget.hxx b/src/debugger/gui/CartBFSCWidget.hxx index 3068672f0..5e394eae5 100644 --- a/src/debugger/gui/CartBFSCWidget.hxx +++ b/src/debugger/gui/CartBFSCWidget.hxx @@ -19,11 +19,10 @@ #define CARTRIDGEBFSC_WIDGET_HXX class CartridgeBFSC; -class PopUpWidget; -#include "CartDebugWidget.hxx" +#include "CartEnhancedWidget.hxx" -class CartridgeBFSCWidget : public CartDebugWidget +class CartridgeBFSCWidget : public CartEnhancedWidget { public: CartridgeBFSCWidget(GuiObject* boss, const GUI::Font& lfont, @@ -33,35 +32,11 @@ class CartridgeBFSCWidget : public CartDebugWidget virtual ~CartridgeBFSCWidget() = default; private: - CartridgeBFSC& myCart; - PopUpWidget* myBank{nullptr}; + string manufacturer() override { return "CPUWIZ"; } - struct CartState { - ByteArray internalram; - uInt16 bank{0}; - }; - CartState myOldState; - - enum { kBankChanged = 'bkCH' }; + string description() override; private: - void saveOldState() override; - void loadConfig() override; - void handleCommand(CommandSender* sender, int cmd, int data, int id) override; - - string bankState() override; - - // start of functions for Cartridge RAM tab - uInt32 internalRamSize() override; - uInt32 internalRamRPort(int start) override; - string internalRamDescription() override; - const ByteArray& internalRamOld(int start, int count) override; - const ByteArray& internalRamCurrent(int start, int count) override; - void internalRamSetValue(int addr, uInt8 value) override; - uInt8 internalRamGetValue(int addr) override; - string internalRamLabel(int addr) override; - // end of functions for Cartridge RAM tab - // Following constructors and assignment operators not supported CartridgeBFSCWidget() = delete; CartridgeBFSCWidget(const CartridgeBFSCWidget&) = delete; diff --git a/src/debugger/gui/CartBFWidget.cxx b/src/debugger/gui/CartBFWidget.cxx index 96ddc5662..001f50658 100644 --- a/src/debugger/gui/CartBFWidget.cxx +++ b/src/debugger/gui/CartBFWidget.cxx @@ -16,151 +16,24 @@ //============================================================================ #include "CartBF.hxx" -#include "PopUpWidget.hxx" #include "CartBFWidget.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeBFWidget::CartridgeBFWidget( GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, int x, int y, int w, int h, CartridgeBF& cart) - : CartDebugWidget(boss, lfont, nfont, x, y, w, h), - myCart(cart) + : CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart) { - uInt32 size = 64 * 4096; + initialize(); +} +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string CartridgeBFWidget::description() +{ ostringstream info; - info << "BF cartridge, 64 4K banks\n" - << "Startup bank = " << cart.startBank() << "\n"; - // Eventually, we should query this from the debugger/disassembler - for(uInt32 i = 0, offset = 0xFFC, spot = 0xF80; i < 64; ++i, offset += 0x1000) - { - uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; - start -= start % 0x1000; - info << "Bank " << std::dec << i << " @ $" << Common::Base::HEX4 << start << " - " - << "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n"; - } + info << "256K BF cartridge, 64 4K banks\n"; + info << CartEnhancedWidget::description(); - int xpos = 2, - ypos = addBaseInformation(size, "CPUWIZ", info.str()) + myLineHeight; - - VariantList items; - VarList::push_back(items, " 0 ($FF80)"); - VarList::push_back(items, " 1 ($FF81)"); - VarList::push_back(items, " 2 ($FF82)"); - VarList::push_back(items, " 3 ($FF83)"); - VarList::push_back(items, " 4 ($FF84)"); - VarList::push_back(items, " 5 ($FF85)"); - VarList::push_back(items, " 6 ($FF86)"); - VarList::push_back(items, " 7 ($FF87)"); - VarList::push_back(items, " 8 ($FF88)"); - VarList::push_back(items, " 9 ($FF89)"); - VarList::push_back(items, "10 ($FF8A)"); - VarList::push_back(items, "11 ($FF8B)"); - VarList::push_back(items, "12 ($FF8C)"); - VarList::push_back(items, "13 ($FF8D)"); - VarList::push_back(items, "14 ($FF8E)"); - VarList::push_back(items, "15 ($FF8F)"); - VarList::push_back(items, "16 ($FF90)"); - VarList::push_back(items, "17 ($FF91)"); - VarList::push_back(items, "18 ($FF92)"); - VarList::push_back(items, "19 ($FF93)"); - VarList::push_back(items, "20 ($FF94)"); - VarList::push_back(items, "21 ($FF95)"); - VarList::push_back(items, "22 ($FF96)"); - VarList::push_back(items, "23 ($FF97)"); - VarList::push_back(items, "24 ($FF98)"); - VarList::push_back(items, "25 ($FF99)"); - VarList::push_back(items, "26 ($FF9A)"); - VarList::push_back(items, "27 ($FF9B)"); - VarList::push_back(items, "28 ($FF9C)"); - VarList::push_back(items, "29 ($FF9D)"); - VarList::push_back(items, "30 ($FF9E)"); - VarList::push_back(items, "31 ($FF9F)"); - VarList::push_back(items, "32 ($FFA0)"); - VarList::push_back(items, "33 ($FFA1)"); - VarList::push_back(items, "34 ($FFA2)"); - VarList::push_back(items, "35 ($FFA3)"); - VarList::push_back(items, "36 ($FFA4)"); - VarList::push_back(items, "37 ($FFA5)"); - VarList::push_back(items, "38 ($FFA6)"); - VarList::push_back(items, "39 ($FFA7)"); - VarList::push_back(items, "40 ($FFA8)"); - VarList::push_back(items, "41 ($FFA9)"); - VarList::push_back(items, "42 ($FFAA)"); - VarList::push_back(items, "43 ($FFAB)"); - VarList::push_back(items, "44 ($FFAC)"); - VarList::push_back(items, "45 ($FFAD)"); - VarList::push_back(items, "46 ($FFAE)"); - VarList::push_back(items, "47 ($FFAF)"); - VarList::push_back(items, "48 ($FFB0)"); - VarList::push_back(items, "49 ($FFB1)"); - VarList::push_back(items, "50 ($FFB2)"); - VarList::push_back(items, "51 ($FFB3)"); - VarList::push_back(items, "52 ($FFB4)"); - VarList::push_back(items, "53 ($FFB5)"); - VarList::push_back(items, "54 ($FFB6)"); - VarList::push_back(items, "55 ($FFB7)"); - VarList::push_back(items, "56 ($FFB8)"); - VarList::push_back(items, "57 ($FFB9)"); - VarList::push_back(items, "58 ($FFBA)"); - VarList::push_back(items, "59 ($FFBB)"); - VarList::push_back(items, "60 ($FFBC)"); - VarList::push_back(items, "61 ($FFBD)"); - VarList::push_back(items, "62 ($FFBE)"); - VarList::push_back(items, "63 ($FFBF)"); - - myBank = - new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("64 ($FFBF)"), - myLineHeight, items, "Set bank ", - 0, kBankChanged); - myBank->setTarget(this); - addFocusWidget(myBank); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeBFWidget::loadConfig() -{ - Debugger& dbg = instance().debugger(); - CartDebug& cart = dbg.cartDebug(); - const CartState& state = static_cast(cart.getState()); - const CartState& oldstate = static_cast(cart.getOldState()); - - myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank); - - CartDebugWidget::loadConfig(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeBFWidget::handleCommand(CommandSender* sender, - int cmd, int data, int id) -{ - if(cmd == kBankChanged) - { - myCart.unlockBank(); - myCart.bank(myBank->getSelected()); - myCart.lockBank(); - invalidate(); - } -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string CartridgeBFWidget::bankState() -{ - ostringstream& buf = buffer(); - - static constexpr std::array spot = { - "$FF80", "$FF81", "$FF82", "$FF83", "$FF84", "$FF85", "$FF86", "$FF87", - "$FF88", "$FF89", "$FF8A", "$FF8B", "$FF8C", "$FF8D", "$FF8E", "$FF8F", - "$FF90", "$FF91", "$FF92", "$FF93", "$FF94", "$FF95", "$FF96", "$FF97", - "$FF98", "$FF99", "$FF9A", "$FF9B", "$FF9C", "$FF9D", "$FF9E", "$FF9F", - "$FFA0", "$FFA1", "$FFA2", "$FFA3", "$FFA4", "$FFA5", "$FFA6", "$FFA7", - "$FFA8", "$FFA9", "$FFAA", "$FFAB", "$FFAC", "$FFAD", "$FFAE", "$FFAF", - "$FFB0", "$FFB1", "$FFB2", "$FFB3", "$FFB4", "$FFB5", "$FFB6", "$FFB7", - "$FFB8", "$FFB9", "$FFBA", "$FFBB", "$FFBC", "$FFBD", "$FFBE", "$FFBF" - }; - buf << "Bank = " << std::dec << myCart.getBank() - << ", hotspot = " << spot[myCart.getBank()]; - - return buf.str(); + return info.str(); } diff --git a/src/debugger/gui/CartBFWidget.hxx b/src/debugger/gui/CartBFWidget.hxx index d084dbbc3..6c8d37257 100644 --- a/src/debugger/gui/CartBFWidget.hxx +++ b/src/debugger/gui/CartBFWidget.hxx @@ -19,11 +19,10 @@ #define CARTRIDGEBF_WIDGET_HXX class CartridgeBF; -class PopUpWidget; -#include "CartDebugWidget.hxx" +#include "CartEnhancedWidget.hxx" -class CartridgeBFWidget : public CartDebugWidget +class CartridgeBFWidget : public CartEnhancedWidget { public: CartridgeBFWidget(GuiObject* boss, const GUI::Font& lfont, @@ -33,17 +32,11 @@ class CartridgeBFWidget : public CartDebugWidget virtual ~CartridgeBFWidget() = default; private: - CartridgeBF& myCart; - PopUpWidget* myBank{nullptr}; + string manufacturer() override { return "CPUWIZ"; } - enum { kBankChanged = 'bkCH' }; + string description() override; private: - void loadConfig() override; - void handleCommand(CommandSender* sender, int cmd, int data, int id) override; - - string bankState() override; - // Following constructors and assignment operators not supported CartridgeBFWidget() = delete; CartridgeBFWidget(const CartridgeBFWidget&) = delete; diff --git a/src/debugger/gui/CartCVWidget.cxx b/src/debugger/gui/CartCVWidget.cxx index 167ff7122..1517cc843 100644 --- a/src/debugger/gui/CartCVWidget.cxx +++ b/src/debugger/gui/CartCVWidget.cxx @@ -27,20 +27,6 @@ CartridgeCVWidget::CartridgeCVWidget( : CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart) { initialize(); - - //// Eventually, we should query this from the debugger/disassembler - //uInt16 size = 2048; - //uInt16 start = (cart.myImage[size-3] << 8) | cart.myImage[size-4]; - //start -= start % size; - - //ostringstream info; - //info << "CV 2K ROM + 1K RAM , non-bankswitched\n" - // << "1024 bytes RAM @ $F000 - $F7FF\n" - // << " $F000 - $F3FF (R), $F400 - $F7FF (W)\n" - // << "ROM accessible @ $" << Common::Base::HEX4 << start << " - " - // << "$" << (start + size - 1); - - //addBaseInformation(cart.mySize, "CommaVid", info.str()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -48,77 +34,8 @@ string CartridgeCVWidget::description() { ostringstream info; - info << "CV 2K ROM + 1K RAM , non-bankswitched\n"; + info << "CV 2K ROM + 1K RAM, non-bankswitched\n"; info << CartEnhancedWidget::description(); return info.str(); } - - -//// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//void CartridgeCVWidget::saveOldState() -//{ -// myOldState.internalram.clear(); -// -// for(uInt32 i = 0; i < internalRamSize(); ++i) -// myOldState.internalram.push_back(myCart.myRAM[i]); -//} -// -//// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//uInt32 CartridgeCVWidget::internalRamSize() -//{ -// return 1024; -//} -// -//// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//uInt32 CartridgeCVWidget::internalRamRPort(int start) -//{ -// return 0xF000 + start; -//} -// -//// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//string CartridgeCVWidget::internalRamDescription() -//{ -// ostringstream desc; -// desc << "$F000 - $F3FF used for Read Access\n" -// << "$F400 - $F7FF used for Write Access"; -// -// return desc.str(); -//} -// -//// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//const ByteArray& CartridgeCVWidget::internalRamOld(int start, int count) -//{ -// myRamOld.clear(); -// for(int i = 0; i < count; i++) -// myRamOld.push_back(myOldState.internalram[start + i]); -// return myRamOld; -//} -// -//// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//const ByteArray& CartridgeCVWidget::internalRamCurrent(int start, int count) -//{ -// myRamCurrent.clear(); -// for(int i = 0; i < count; i++) -// myRamCurrent.push_back(myCart.myRAM[start + i]); -// return myRamCurrent; -//} -// -//// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//void CartridgeCVWidget::internalRamSetValue(int addr, uInt8 value) -//{ -// myCart.myRAM[addr] = value; -//} -// -//// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//uInt8 CartridgeCVWidget::internalRamGetValue(int addr) -//{ -// return myCart.myRAM[addr]; -//} -// -//// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//string CartridgeCVWidget::internalRamLabel(int addr) -//{ -// CartDebug& dbg = instance().debugger().cartDebug(); -// return dbg.getLabel(addr + 0xF000, false); -//} diff --git a/src/debugger/gui/CartE0Widget.hxx b/src/debugger/gui/CartE0Widget.hxx index fe3e9d374..0bc5694ea 100644 --- a/src/debugger/gui/CartE0Widget.hxx +++ b/src/debugger/gui/CartE0Widget.hxx @@ -41,6 +41,7 @@ class CartridgeE0Widget : public CartEnhancedWidget string hotspotStr(int bank, int segment) override; int bankSegs() override { return 3; } + private: // Following constructors and assignment operators not supported CartridgeE0Widget() = delete; diff --git a/src/debugger/gui/CartEnhancedWidget.cxx b/src/debugger/gui/CartEnhancedWidget.cxx index 39732fc80..d38c5534c 100644 --- a/src/debugger/gui/CartEnhancedWidget.cxx +++ b/src/debugger/gui/CartEnhancedWidget.cxx @@ -92,25 +92,30 @@ string CartEnhancedWidget::romDescription() if(myCart.romBankCount() > 1) { - info << "Startup bank = #" << myCart.startBank() << " or undetermined\n"; for(int bank = 0, offset = 0xFFC; bank < myCart.romBankCount(); ++bank, offset += 0x1000) { uInt16 start = (image[offset + 1] << 8) | image[offset]; start -= start % 0x1000; - info << "Bank #" << bank << " @ $" + info << "Bank #" << std::dec << bank << " @ $" << Common::Base::HEX4 << (start + myCart.myRomOffset) << " - $" << (start + 0xFFF) << " (hotspot " << hotspotStr(bank) << ")\n"; } + info << "Startup bank = #" << std::dec << myCart.startBank() << " or undetermined\n"; } else { uInt16 start = (image[myCart.mySize - 3] << 8) | image[myCart.mySize - 4]; - start -= start % std::min(int(size), 0x1000); + start -= start % std::min(int(size), 0x1000); + // special check for ROMs where the extra RAM is not included in the image (e.g. CV). + if((start & 0xFFF) < size) + { + start += myCart.myRomOffset; + } info << "ROM accessible @ $" - << Common::Base::HEX4 << (start + myCart.myRomOffset) << " - " - << "$" << Common::Base::HEX4 << (start + myCart.mySize - 1); + << Common::Base::HEX4 << start << " - $" + << Common::Base::HEX4 << (start + myCart.mySize - 1); } return info.str(); @@ -201,7 +206,7 @@ string CartEnhancedWidget::bankState() { buf << "Bank #" << std::dec << myCart.getBank(); - if(hotspot >= 0x100) + //if(hotspot >= 0x100) buf << " (hotspot " << hotspotStr(myCart.getSegmentBank()) << ")"; } return buf.str(); diff --git a/src/debugger/gui/CartEnhancedWidget.hxx b/src/debugger/gui/CartEnhancedWidget.hxx index 3bff6350a..dccc9fde0 100644 --- a/src/debugger/gui/CartEnhancedWidget.hxx +++ b/src/debugger/gui/CartEnhancedWidget.hxx @@ -53,7 +53,7 @@ class CartEnhancedWidget : public CartDebugWidget virtual void bankSelect(int& ypos); - virtual string hotspotStr(int bank, int segment = 0); + virtual string hotspotStr(int bank = 0, int segment = 0); virtual int bankSegs(); // { return myCart.myBankSegs; } diff --git a/src/debugger/gui/CartF0Widget.hxx b/src/debugger/gui/CartF0Widget.hxx index b7aa701bc..9ba5aa3ab 100644 --- a/src/debugger/gui/CartF0Widget.hxx +++ b/src/debugger/gui/CartF0Widget.hxx @@ -38,7 +38,7 @@ class CartridgeF0Widget : public CartEnhancedWidget string bankState() override; -private: + private: // Following constructors and assignment operators not supported CartridgeF0Widget() = delete; CartridgeF0Widget(const CartridgeF0Widget&) = delete; diff --git a/src/emucore/CartEnhanced.cxx b/src/emucore/CartEnhanced.cxx index ea167b1d5..3e69a06f8 100644 --- a/src/emucore/CartEnhanced.cxx +++ b/src/emucore/CartEnhanced.cxx @@ -146,9 +146,6 @@ uInt8 CartridgeEnhanced::peek(uInt16 address) bool CartridgeEnhanced::poke(uInt16 address, uInt8 value) { // Switch banks if necessary - // Note: (TODO?) - // The checkSwitchBank() call makes no difference between ROM and e.g TIA space - // Writing to e.g. 0xf0xx might triger a bankswitch, is (and was!) this a bug??? if (checkSwitchBank(address & ADDR_MASK, value)) return false;