From 2872b6be03b9a7efefdac581c900892f0b3d14c7 Mon Sep 17 00:00:00 2001 From: stephena Date: Fri, 12 Apr 2013 13:12:39 +0000 Subject: [PATCH] Added X07 scheme to the debugger ROM tab. Since I have only one test ROM, and it is extremely basic, I can't be sure how well this new functionality works. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2691 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/debugger/gui/CartX07Widget.cxx | 96 ++++++++++++++++++++++++++++++ src/debugger/gui/CartX07Widget.hxx | 46 ++++++++++++++ src/debugger/gui/module.mk | 1 + src/emucore/CartX07.hxx | 17 ++++++ 4 files changed, 160 insertions(+) create mode 100644 src/debugger/gui/CartX07Widget.cxx create mode 100644 src/debugger/gui/CartX07Widget.hxx diff --git a/src/debugger/gui/CartX07Widget.cxx b/src/debugger/gui/CartX07Widget.cxx new file mode 100644 index 000000000..0770badc8 --- /dev/null +++ b/src/debugger/gui/CartX07Widget.cxx @@ -0,0 +1,96 @@ +//============================================================================ +// +// 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 "CartX07.hxx" +#include "PopUpWidget.hxx" +#include "CartX07Widget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeX07Widget::CartridgeX07Widget( + GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, CartridgeX07& cart) + : CartDebugWidget(boss, font, x, y, w, h), + myCart(cart) +{ + uInt32 size = 16 * 4096; + + ostringstream info; + info << "64K X07 cartridge, 16 4K banks\n" + << "Startup bank = " << cart.myStartBank << "\n" + << "Multiple hotspots, all below $1000\n" + << "See documentation for further details\n"; + + // Eventually, we should query this from the debugger/disassembler + for(uInt32 i = 0, offset = 0xFFC; i < 16; ++i, offset += 0x1000) + { + uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; + start -= start % 0x1000; + info << "Bank " << dec << i << " @ $" << HEX4 << start << " - " + << "$" << (start + 0xFFF) << "\n"; + } + + int xpos = 10, + ypos = addBaseInformation(size, "AtariAge / John Payson / Fred Quimby", + info.str()) + myLineHeight; + + StringMap items; + items.push_back(" 0", "0"); + items.push_back(" 1", "1"); + items.push_back(" 2", "2"); + items.push_back(" 3", "3"); + items.push_back(" 4", "4"); + items.push_back(" 5", "5"); + items.push_back(" 6", "6"); + items.push_back(" 7", "7"); + items.push_back(" 8", "8"); + items.push_back(" 9", "9"); + items.push_back(" 10", "10"); + items.push_back(" 11", "11"); + items.push_back(" 12", "12"); + items.push_back(" 13", "13"); + items.push_back(" 14", "14"); + items.push_back(" 15", "15"); + myBank = + new PopUpWidget(boss, font, xpos, ypos-2, font.getStringWidth(" 15 "), + myLineHeight, items, "Set bank: ", + font.getStringWidth("Set bank: "), kBankChanged); + myBank->setTarget(this); + addFocusWidget(myBank); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeX07Widget::loadConfig() +{ + myBank->setSelected(myCart.myCurrentBank); + + CartDebugWidget::loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeX07Widget::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/CartX07Widget.hxx b/src/debugger/gui/CartX07Widget.hxx new file mode 100644 index 000000000..4d8812abf --- /dev/null +++ b/src/debugger/gui/CartX07Widget.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 CARTRIDGEX07_WIDGET_HXX +#define CARTRIDGEX07_WIDGET_HXX + +class CartridgeX07; +class PopUpWidget; + +#include "CartDebugWidget.hxx" + +class CartridgeX07Widget : public CartDebugWidget +{ + public: + CartridgeX07Widget(GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, + CartridgeX07& cart); + virtual ~CartridgeX07Widget() { } + + void loadConfig(); + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + CartridgeX07& myCart; + PopUpWidget* myBank; + + enum { kBankChanged = 'bkCH' }; +}; + +#endif diff --git a/src/debugger/gui/module.mk b/src/debugger/gui/module.mk index 927cdaada..f6f61bcbe 100644 --- a/src/debugger/gui/module.mk +++ b/src/debugger/gui/module.mk @@ -38,6 +38,7 @@ MODULE_OBJS := \ src/debugger/gui/CartF6SCWidget.o \ src/debugger/gui/CartF8SCWidget.o \ src/debugger/gui/CartUAWidget.o \ + src/debugger/gui/CartX07Widget.o \ src/debugger/gui/JoystickWidget.o \ src/debugger/gui/PaddleWidget.o \ src/debugger/gui/BoosterWidget.o \ diff --git a/src/emucore/CartX07.hxx b/src/emucore/CartX07.hxx index a1026886e..0c631606a 100644 --- a/src/emucore/CartX07.hxx +++ b/src/emucore/CartX07.hxx @@ -24,6 +24,9 @@ class System; #include "bspf.hxx" #include "Cart.hxx" +#ifdef DEBUGGER_SUPPORT + #include "CartX07Widget.hxx" +#endif /** Bankswitching method as defined/created by John Payson (aka Supercat) @@ -44,6 +47,8 @@ class System; */ class CartridgeX07 : public Cartridge { + friend class CartridgeX07Widget; + public: /** Create a new cartridge using the specified image @@ -130,6 +135,18 @@ class CartridgeX07 : public Cartridge */ string name() const { return "CartridgeX07"; } + #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 CartridgeX07Widget(boss, font, x, y, w, h, *this); + } + #endif + public: /** Get the byte at the specified address.