diff --git a/src/debugger/gui/CartFAWidget.cxx b/src/debugger/gui/CartFAWidget.cxx new file mode 100644 index 000000000..b6c02d717 --- /dev/null +++ b/src/debugger/gui/CartFAWidget.cxx @@ -0,0 +1,82 @@ +//============================================================================ +// +// 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-2013 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. +// +// $Id$ +//============================================================================ + +#include "CartFA.hxx" +#include "PopUpWidget.hxx" +#include "CartFAWidget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeFAWidget::CartridgeFAWidget( + GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, CartridgeFA& cart) + : CartDebugWidget(boss, font, x, y, w, h), + myCart(cart) +{ + uInt16 size = 3 * 4096; + + ostringstream info; + info << "CBS RAM+ FA cartridge, three 4K banks\n" + << "256 bytes RAM @ $F000 - $F1FF\n" + << " $F100 - $F1FF (R), $F000 - $F0FF (W)\n" + << "Startup bank = " << cart.myStartBank << "\n"; + + // Eventually, we should query this from the debugger/disassembler + for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF8; i < 3; ++i, offset += 0x1000) + { + uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; + start -= start % 0x1000; + info << "Bank " << i << " @ $" << HEX4 << start << " - " + << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n"; + } + + int xpos = 10, + ypos = addBaseInformation(size, "CBS", info.str()) + myLineHeight; + + StringMap items; + items.push_back("0 ($FF8)", "0"); + items.push_back("1 ($FF9)", "1"); + items.push_back("2 ($FFA)", "2"); + myBank = + new PopUpWidget(boss, font, xpos, ypos-2, font.getStringWidth("0 ($FFx) "), + myLineHeight, items, "Set bank: ", + font.getStringWidth("Set bank: "), kBankChanged); + myBank->setTarget(this); + addFocusWidget(myBank); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeFAWidget::loadConfig() +{ + myBank->setSelected(myCart.myCurrentBank); + + CartDebugWidget::loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeFAWidget::handleCommand(CommandSender* sender, + int cmd, int data, int id) +{ + if(cmd == kBankChanged) + { + myCart.unlockBank(); + myCart.bank(myBank->getSelected()); + myCart.lockBank(); + invalidate(); + } +} diff --git a/src/debugger/gui/CartFAWidget.hxx b/src/debugger/gui/CartFAWidget.hxx new file mode 100644 index 000000000..cefe8e153 --- /dev/null +++ b/src/debugger/gui/CartFAWidget.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-2013 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. +// +// $Id$ +//============================================================================ + +#ifndef CARTRIDGEFA_WIDGET_HXX +#define CARTRIDGEFA_WIDGET_HXX + +class CartridgeFA; +class PopUpWidget; + +#include "CartDebugWidget.hxx" + +class CartridgeFAWidget : public CartDebugWidget +{ + public: + CartridgeFAWidget(GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, + CartridgeFA& cart); + virtual ~CartridgeFAWidget() { } + + void loadConfig(); + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + CartridgeFA& myCart; + PopUpWidget* myBank; + + enum { kBankChanged = 'bkCH' }; +}; + +#endif diff --git a/src/debugger/gui/module.mk b/src/debugger/gui/module.mk index 0446b9d9e..afa92c844 100644 --- a/src/debugger/gui/module.mk +++ b/src/debugger/gui/module.mk @@ -26,6 +26,7 @@ MODULE_OBJS := \ src/debugger/gui/CartEFWidget.o \ src/debugger/gui/CartEFSCWidget.o \ src/debugger/gui/CartF0Widget.o \ + src/debugger/gui/CartFAWidget.o \ src/debugger/gui/CartF4Widget.o \ src/debugger/gui/CartF6Widget.o \ src/debugger/gui/CartF8Widget.o \ diff --git a/src/emucore/CartFA.hxx b/src/emucore/CartFA.hxx index 10197c29e..5b952338e 100644 --- a/src/emucore/CartFA.hxx +++ b/src/emucore/CartFA.hxx @@ -24,6 +24,9 @@ class System; #include "bspf.hxx" #include "Cart.hxx" +#ifdef DEBUGGER_SUPPORT + #include "CartFAWidget.hxx" +#endif /** Cartridge class used for CBS' RAM Plus cartridges. There are @@ -34,6 +37,8 @@ class System; */ class CartridgeFA : public Cartridge { + friend class CartridgeFAWidget; + public: /** Create a new cartridge using the specified image @@ -120,6 +125,18 @@ class CartridgeFA : public Cartridge */ string name() const { return "CartridgeFA"; } + #ifdef DEBUGGER_SUPPORT + /** + Get debugger widget responsible for accessing the inner workings + of the cart. + */ + CartDebugWidget* debugWidget(GuiObject* boss, + const GUI::Font& font, int x, int y, int w, int h) + { + return new CartridgeFAWidget(boss, font, x, y, w, h, *this); + } + #endif + public: /** Get the byte at the specified address. diff --git a/src/emucore/CartFE.cxx b/src/emucore/CartFE.cxx index fa6b06bda..61be04c28 100644 --- a/src/emucore/CartFE.cxx +++ b/src/emucore/CartFE.cxx @@ -129,15 +129,12 @@ bool CartridgeFE::bankChanged() if(myLastAddressChanged) { // A bankswitch occurs when the addresses transition from state to another - bool a1 = ((myLastAddress1 & 0x2000) == 0), - a2 = ((myLastAddress2 & 0x2000) == 0); - myBankChanged = (a1 && !a2) || (a2 && !a1); + myBankChanged = ((myLastAddress1 & 0x2000) == 0) != + ((myLastAddress2 & 0x2000) == 0); myLastAddressChanged = false; } else - { myBankChanged = false; - } // In any event, let the base class know about it return Cartridge::bankChanged(); diff --git a/src/emucore/CartFE.hxx b/src/emucore/CartFE.hxx index 9b13de57e..ffbd78aab 100644 --- a/src/emucore/CartFE.hxx +++ b/src/emucore/CartFE.hxx @@ -26,7 +26,7 @@ class System; #include "Cart.hxx" /** - Bankswitching method used by Activison's Robot Tank and Decathlon. + Bankswitching method used by Activision's Robot Tank and Decathlon. Kevin Horton describes FE as follows: