diff --git a/src/debugger/gui/CartDebugWidget.hxx b/src/debugger/gui/CartDebugWidget.hxx index 9b613052b..bbf3e9875 100644 --- a/src/debugger/gui/CartDebugWidget.hxx +++ b/src/debugger/gui/CartDebugWidget.hxx @@ -50,7 +50,7 @@ class CartDebugWidget : public Widget, public CommandSender public: int addBaseInformation(int bytes, const string& manufacturer, - const string& desc) + const string& desc, const uInt16 maxlines = 10) { const int lwidth = _font.getStringWidth("Manufacturer: "), fwidth = _w - lwidth - 20; @@ -82,7 +82,7 @@ class CartDebugWidget : public Widget, public CommandSender const StringList& sl = bs.stringList(); uInt32 lines = sl.size(); if(lines < 3) lines = 3; - if(lines > 10) lines = 10; + if(lines > maxlines) lines = maxlines; new StaticTextWidget(_boss, _font, x, y, lwidth, myFontHeight, "Description: ", kTextAlignLeft); diff --git a/src/debugger/gui/CartE7Widget.cxx b/src/debugger/gui/CartE7Widget.cxx index 79cdc3428..6288011d7 100644 --- a/src/debugger/gui/CartE7Widget.cxx +++ b/src/debugger/gui/CartE7Widget.cxx @@ -50,7 +50,7 @@ CartridgeE7Widget::CartridgeE7Widget( info << "Bank RORG" << " = $" << HEX4 << start << "\n"; #endif int xpos = 10, - ypos = addBaseInformation(size, "M-Network", info.str()) + myLineHeight; + ypos = addBaseInformation(size, "M-Network", info.str(), 15) + myLineHeight; StringMap items0, items1; items0.push_back("0 - ROM ($FE0)", "0"); diff --git a/src/debugger/gui/CartF4SCWidget.cxx b/src/debugger/gui/CartF4SCWidget.cxx index a5a3d447a..65762b76d 100644 --- a/src/debugger/gui/CartF4SCWidget.cxx +++ b/src/debugger/gui/CartF4SCWidget.cxx @@ -46,7 +46,7 @@ CartridgeF4SCWidget::CartridgeF4SCWidget( } int xpos = 10, - ypos = addBaseInformation(size, "Atari", info.str()) + myLineHeight; + ypos = addBaseInformation(size, "Atari", info.str(), 15) + myLineHeight; StringMap items; items.push_back("0 ($FF4)", "0"); diff --git a/src/debugger/gui/CartF4Widget.cxx b/src/debugger/gui/CartF4Widget.cxx index cb0309fd1..38aabcdd3 100644 --- a/src/debugger/gui/CartF4Widget.cxx +++ b/src/debugger/gui/CartF4Widget.cxx @@ -44,7 +44,7 @@ CartridgeF4Widget::CartridgeF4Widget( } int xpos = 10, - ypos = addBaseInformation(size, "Atari", info.str()) + myLineHeight; + ypos = addBaseInformation(size, "Atari", info.str(), 15) + myLineHeight; StringMap items; items.push_back("0 ($FF4)", "0"); diff --git a/src/debugger/gui/CartFA2Widget.cxx b/src/debugger/gui/CartFA2Widget.cxx new file mode 100644 index 000000000..55e6e75a6 --- /dev/null +++ b/src/debugger/gui/CartFA2Widget.cxx @@ -0,0 +1,92 @@ +//============================================================================ +// +// 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 "CartFA2.hxx" +#include "PopUpWidget.hxx" +#include "CartFA2Widget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeFA2Widget::CartridgeFA2Widget( + GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, CartridgeFA2& cart) + : CartDebugWidget(boss, font, x, y, w, h), + myCart(cart) +{ + uInt16 size = cart.mySize; + + ostringstream info; + info << "Modified FA RAM+, six or seven 4K banks\n" + << "256 bytes RAM @ $F000 - $F1FF\n" + << " $F100 - $F1FF (R), $F000 - $F0FF (W)\n" + << "RAM can be loaded/saved to Harmony flash by accessing $FF4 " + "(not currently accessible)\n" + << "Startup bank = " << cart.myStartBank << "\n"; + + // Eventually, we should query this from the debugger/disassembler + for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF5; i < cart.bankCount(); + ++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, "Chris D. Walton (Star Castle 2600)", + info.str(), 15) + myLineHeight; + + StringMap items; + items.push_back("0 ($FF5)", "0"); + items.push_back("1 ($FF6)", "1"); + items.push_back("2 ($FF7)", "2"); + items.push_back("3 ($FF8)", "3"); + items.push_back("4 ($FF9)", "4"); + items.push_back("5 ($FFA)", "5"); + if(cart.bankCount() == 7) + items.push_back("6 ($FFB)", "6"); + + 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 CartridgeFA2Widget::loadConfig() +{ + myBank->setSelected(myCart.myCurrentBank); + + CartDebugWidget::loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeFA2Widget::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/CartFA2Widget.hxx b/src/debugger/gui/CartFA2Widget.hxx new file mode 100644 index 000000000..a6111dfb3 --- /dev/null +++ b/src/debugger/gui/CartFA2Widget.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 CARTRIDGEFA2_WIDGET_HXX +#define CARTRIDGEFA2_WIDGET_HXX + +class CartridgeFA2; +class PopUpWidget; + +#include "CartDebugWidget.hxx" + +class CartridgeFA2Widget : public CartDebugWidget +{ + public: + CartridgeFA2Widget(GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, + CartridgeFA2& cart); + virtual ~CartridgeFA2Widget() { } + + void loadConfig(); + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + CartridgeFA2& myCart; + PopUpWidget* myBank; + + enum { kBankChanged = 'bkCH' }; +}; + +#endif diff --git a/src/debugger/gui/CartMCWidget.cxx b/src/debugger/gui/CartMCWidget.cxx index 2cee2ff42..1a5b78045 100644 --- a/src/debugger/gui/CartMCWidget.cxx +++ b/src/debugger/gui/CartMCWidget.cxx @@ -115,5 +115,24 @@ void CartridgeMCWidget::loadConfig() void CartridgeMCWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) { - // TODO - implement this + myCart.unlockBank(); + + switch(cmd) + { + case kSlice0Changed: + myCart.myCurrentBlock[0] = atoi(mySlice0->getSelectedTag().c_str()); + break; + case kSlice1Changed: + myCart.myCurrentBlock[1] = atoi(mySlice1->getSelectedTag().c_str()); + break; + case kSlice2Changed: + myCart.myCurrentBlock[2] = atoi(mySlice2->getSelectedTag().c_str()); + break; + case kSlice3Changed: + myCart.myCurrentBlock[3] = atoi(mySlice3->getSelectedTag().c_str()); + break; + } + + myCart.lockBank(); + invalidate(); } diff --git a/src/debugger/gui/module.mk b/src/debugger/gui/module.mk index 811b468c7..2999c6697 100644 --- a/src/debugger/gui/module.mk +++ b/src/debugger/gui/module.mk @@ -37,6 +37,7 @@ MODULE_OBJS := \ src/debugger/gui/CartF6SCWidget.o \ src/debugger/gui/CartF8SCWidget.o \ src/debugger/gui/CartFAWidget.o \ + src/debugger/gui/CartFA2Widget.o \ src/debugger/gui/CartFEWidget.o \ src/debugger/gui/CartMCWidget.o \ src/debugger/gui/CartSBWidget.o \ diff --git a/src/emucore/CartFA2.hxx b/src/emucore/CartFA2.hxx index e4727e894..9d47506f1 100644 --- a/src/emucore/CartFA2.hxx +++ b/src/emucore/CartFA2.hxx @@ -24,6 +24,9 @@ class System; #include "bspf.hxx" #include "Cart.hxx" +#ifdef DEBUGGER_SUPPORT + #include "CartFA2Widget.hxx" +#endif /** This is an extended version of the CBS RAM Plus bankswitching scheme @@ -33,11 +36,17 @@ class System; of RAM can be loaded/saved to Harmony cart flash, which is emulated by storing in a file. + For 29K versions of the scheme, the first 1K is ARM code + (implements actual bankswitching on the Harmony cart), which is + completely ignored by the emulator. + @author Chris D. Walton @version $Id$ */ class CartridgeFA2 : public Cartridge { + friend class CartridgeFA2Widget; + public: /** Create a new cartridge using the specified image @@ -132,6 +141,18 @@ class CartridgeFA2 : 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 CartridgeFA2Widget(boss, font, x, y, w, h, *this); + } + #endif + public: /** Get the byte at the specified address.