diff --git a/src/debugger/gui/CartCTYWidget.cxx b/src/debugger/gui/CartCTYWidget.cxx new file mode 100644 index 000000000..54a701f98 --- /dev/null +++ b/src/debugger/gui/CartCTYWidget.cxx @@ -0,0 +1,77 @@ +//============================================================================ +// +// 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 "CartCTY.hxx" +#include "PopUpWidget.hxx" +#include "CartCTYWidget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeCTYWidget::CartridgeCTYWidget( + GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, CartridgeCTY& cart) + : CartDebugWidget(boss, font, x, y, w, h), + myCart(cart) +{ + uInt16 size = 8 * 4096; + + string info = + "Chetiry cartridge, eight 4K banks (bank 0 is ARM code and is ignored)\n" + "64 bytes RAM @ $F000 - $F080\n" + " $F040 - $F07F (R), $F000 - $F03F (W)\n" + "\nTHIS SCHEME IS NOT FULLY IMPLEMENTED OR TESTED\n"; + + int xpos = 10, + ypos = addBaseInformation(size, "Chris D. Walton", info) + myLineHeight; + + StringMap items; + items.push_back("1 ($FF5)", "1"); + items.push_back("2 ($FF6)", "2"); + items.push_back("3 ($FF7)", "3"); + items.push_back("4 ($FF8)", "4"); + items.push_back("5 ($FF9)", "5"); + items.push_back("6 ($FFA)", "6"); + items.push_back("7 ($FFB)", "7"); + 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 CartridgeCTYWidget::loadConfig() +{ + myBank->setSelected(myCart.bank()-1); + + CartDebugWidget::loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeCTYWidget::handleCommand(CommandSender* sender, + int cmd, int data, int id) +{ + if(cmd == kBankChanged) + { + myCart.unlockBank(); + myCart.bank(myBank->getSelected()+1); + myCart.lockBank(); + invalidate(); + } +} diff --git a/src/debugger/gui/CartCTYWidget.hxx b/src/debugger/gui/CartCTYWidget.hxx new file mode 100644 index 000000000..439eba542 --- /dev/null +++ b/src/debugger/gui/CartCTYWidget.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 CARTRIDGECTY_WIDGET_HXX +#define CARTRIDGECTY_WIDGET_HXX + +class CartridgeCTY; +class PopUpWidget; + +#include "CartDebugWidget.hxx" + +class CartridgeCTYWidget : public CartDebugWidget +{ + public: + CartridgeCTYWidget(GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, + CartridgeCTY& cart); + virtual ~CartridgeCTYWidget() { } + + void loadConfig(); + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + CartridgeCTY& myCart; + PopUpWidget* myBank; + + enum { kBankChanged = 'bkCH' }; +}; + +#endif diff --git a/src/debugger/gui/module.mk b/src/debugger/gui/module.mk index a6e311816..bc4e57864 100644 --- a/src/debugger/gui/module.mk +++ b/src/debugger/gui/module.mk @@ -27,6 +27,7 @@ MODULE_OBJS := \ src/debugger/gui/Cart4KWidget.o \ src/debugger/gui/CartARWidget.o \ src/debugger/gui/CartCMWidget.o \ + src/debugger/gui/CartCTYWidget.o \ src/debugger/gui/CartCVWidget.o \ src/debugger/gui/CartDPCWidget.o \ src/debugger/gui/CartDPCPlusWidget.o \ diff --git a/src/emucore/CartCTY.hxx b/src/emucore/CartCTY.hxx index 6e75d3946..be46b6da9 100644 --- a/src/emucore/CartCTY.hxx +++ b/src/emucore/CartCTY.hxx @@ -24,6 +24,9 @@ class System; #include "bspf.hxx" #include "Cart.hxx" +#ifdef DEBUGGER_SUPPORT + #include "CartCTYWidget.hxx" +#endif /** The 'Chetiry' bankswitch scheme was developed by Chris D. Walton for a @@ -109,6 +112,8 @@ class System; */ class CartridgeCTY : public Cartridge { + friend class CartridgeCTYWidget; + public: /** Create a new cartridge using the specified image @@ -210,6 +215,18 @@ class CartridgeCTY : public Cartridge */ void setRomName(const string& name); + #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 CartridgeCTYWidget(boss, font, x, y, w, h, *this); + } + #endif + public: /** Get the byte at the specified address.