From a7566af776360d388abb47c4856593d18fa63cf5 Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 17 Apr 2013 17:25:13 +0000 Subject: [PATCH] Added MC scheme to debugger ROM tab. This isn't complete, since I don't have any test ROMs to confirm whether the current bankswitching code even works. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2695 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/debugger/gui/CartFEWidget.cxx | 4 +- src/debugger/gui/CartMCWidget.cxx | 119 ++++++++++++++++++++++++++++++ src/debugger/gui/CartMCWidget.hxx | 51 +++++++++++++ src/debugger/gui/module.mk | 1 + src/emucore/CartMC.hxx | 17 +++++ 5 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 src/debugger/gui/CartMCWidget.cxx create mode 100644 src/debugger/gui/CartMCWidget.hxx diff --git a/src/debugger/gui/CartFEWidget.cxx b/src/debugger/gui/CartFEWidget.cxx index 04a60fdf7..16ed9bbfc 100644 --- a/src/debugger/gui/CartFEWidget.cxx +++ b/src/debugger/gui/CartFEWidget.cxx @@ -33,8 +33,8 @@ CartridgeFEWidget::CartridgeFEWidget( "Bank 0 @ $F000 - $FFFF (A13 = 1)\n" "Bank 1 @ $D000 - $DFFF (A13 = 0)\n" "\n" - "Changing banks is not supported, since it " - "would immediately switch on the next address\n"; + "Changing banks is not currently supported, since it " + "would immediately switch on the next address change\n"; addBaseInformation(2 * 4096, "Activision", info); } diff --git a/src/debugger/gui/CartMCWidget.cxx b/src/debugger/gui/CartMCWidget.cxx new file mode 100644 index 000000000..2cee2ff42 --- /dev/null +++ b/src/debugger/gui/CartMCWidget.cxx @@ -0,0 +1,119 @@ +//============================================================================ +// +// 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 "CartMC.hxx" +#include "PopUpWidget.hxx" +#include "CartMCWidget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeMCWidget::CartridgeMCWidget( + GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, CartridgeMC& cart) + : CartDebugWidget(boss, font, x, y, w, h), + myCart(cart) +{ +#define ROM_BLOCKS + + uInt32 size = 128 * 1024; + + string info = + "MC cartridge, 128 1K slices ROM + 32 1K RAM\n" + "Write $80 - $FF into a hotspot for ROM (128)\n" + "Write $00 - $3F into a hotspot for RAM (32)\n" + "Segment 0 @ $F000 - $F3FF (hotspot = $3C)\n" + "Segment 1 @ $F400 - $F7FF (hotspot = $3D)\n" + "Segment 2 @ $F800 - $FBFF (hotspot = $3E)\n" + "Segment 3 @ $FC00 - $FFFF (hotspot = $3F)\n" + "\nTHIS SCHEME IS NOT FULLY IMPLEMENTED OR TESTED\n"; + + int xpos = 10, + ypos = addBaseInformation(size, "Chris Wilkson's Megacart", info) + + myLineHeight; + + StringMap items; + // Add 128 1K 'ROM' blocks + for(uInt32 i = 0x80; i <= 0xFF; ++i) + { + const string& b = BSPF_toString(i); + items.push_back(b + " (ROM)", b); + } + // Add 64 512B 'RAM' blocks + for(uInt32 i = 0x00; i <= 0x3F; ++i) + { + const string& b = BSPF_toString(i); + items.push_back(b + " (RAM)", b); + } + + const int lwidth = font.getStringWidth("Set slice for segment X ($3X): "), + fwidth = font.getStringWidth("255 (ROM)"); + + mySlice0 = + new PopUpWidget(boss, font, xpos, ypos-2, fwidth, + myLineHeight, items, "Set slice for segment 0 ($3C): ", + lwidth, kSlice0Changed); + mySlice0->setTarget(this); + addFocusWidget(mySlice0); + ypos += mySlice0->getHeight() + 4; + + mySlice1 = + new PopUpWidget(boss, font, xpos, ypos-2, fwidth, + myLineHeight, items, "Set slice for segment 1 ($3D): ", + lwidth, kSlice1Changed); + mySlice1->setTarget(this); + addFocusWidget(mySlice1); + ypos += mySlice1->getHeight() + 4; + + mySlice2 = + new PopUpWidget(boss, font, xpos, ypos-2, fwidth, + myLineHeight, items, "Set slice for segment 2 ($3E): ", + lwidth, kSlice2Changed); + mySlice2->setTarget(this); + addFocusWidget(mySlice2); + ypos += mySlice2->getHeight() + 4; + + mySlice3 = + new PopUpWidget(boss, font, xpos, ypos-2, fwidth, + myLineHeight, items, "Set slice for segment 3 ($3F): ", + lwidth, kSlice3Changed); + mySlice3->setTarget(this); + addFocusWidget(mySlice3); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeMCWidget::loadConfig() +{ + const string& b0 = BSPF_toString(myCart.myCurrentBlock[0]); + const string& b1 = BSPF_toString(myCart.myCurrentBlock[1]); + const string& b2 = BSPF_toString(myCart.myCurrentBlock[2]); + const string& b3 = BSPF_toString(myCart.myCurrentBlock[3]); + + mySlice0->setSelected(b0, b0); + mySlice1->setSelected(b1, b1); + mySlice2->setSelected(b2, b2); + mySlice3->setSelected(b3, b3); + + CartDebugWidget::loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeMCWidget::handleCommand(CommandSender* sender, + int cmd, int data, int id) +{ + // TODO - implement this +} diff --git a/src/debugger/gui/CartMCWidget.hxx b/src/debugger/gui/CartMCWidget.hxx new file mode 100644 index 000000000..340d22d8b --- /dev/null +++ b/src/debugger/gui/CartMCWidget.hxx @@ -0,0 +1,51 @@ +//============================================================================ +// +// 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 CARTRIDGEMC_WIDGET_HXX +#define CARTRIDGEMC_WIDGET_HXX + +class CartridgeMC; +class PopUpWidget; + +#include "CartDebugWidget.hxx" + +class CartridgeMCWidget : public CartDebugWidget +{ + public: + CartridgeMCWidget(GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, + CartridgeMC& cart); + virtual ~CartridgeMCWidget() { } + + void loadConfig(); + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + CartridgeMC& myCart; + PopUpWidget *mySlice0, *mySlice1, *mySlice2, *mySlice3; + + enum { + kSlice0Changed = 's0CH', + kSlice1Changed = 's1CH', + kSlice2Changed = 's2CH', + kSlice3Changed = 's3CH' + }; +}; + +#endif diff --git a/src/debugger/gui/module.mk b/src/debugger/gui/module.mk index 9d53dfc70..811b468c7 100644 --- a/src/debugger/gui/module.mk +++ b/src/debugger/gui/module.mk @@ -38,6 +38,7 @@ MODULE_OBJS := \ src/debugger/gui/CartF8SCWidget.o \ src/debugger/gui/CartFAWidget.o \ src/debugger/gui/CartFEWidget.o \ + src/debugger/gui/CartMCWidget.o \ src/debugger/gui/CartSBWidget.o \ src/debugger/gui/CartUAWidget.o \ src/debugger/gui/CartX07Widget.o \ diff --git a/src/emucore/CartMC.hxx b/src/emucore/CartMC.hxx index 82b74f5ae..afb69a4ed 100644 --- a/src/emucore/CartMC.hxx +++ b/src/emucore/CartMC.hxx @@ -24,6 +24,9 @@ class System; #include "bspf.hxx" #include "Cart.hxx" +#ifdef DEBUGGER_SUPPORT + #include "CartMCWidget.hxx" +#endif /** This is the cartridge class for Chris Wilkson's Megacart. It does not @@ -138,6 +141,8 @@ class System; */ class CartridgeMC : public Cartridge { + friend class CartridgeMCWidget; + public: /** Create a new cartridge using the specified image and size. If the @@ -226,6 +231,18 @@ class CartridgeMC : public Cartridge */ string name() const { return "CartridgeMC"; } + #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 CartridgeMCWidget(boss, font, x, y, w, h, *this); + } + #endif + public: /** Get the byte at the specified address