From de6dbc060c229a846d0be2179c38170ab98389b7 Mon Sep 17 00:00:00 2001 From: stephena Date: Thu, 18 Apr 2013 16:57:33 +0000 Subject: [PATCH] Added first pass of DPC scheme to the debugger ROM tab. For now, it only contains the same functionality as F8; it needs to be expanded to show more DPC-specific stuff. Updated all schemes that contain a fixed RAM address range (mostly the Superchip ones) to exclude that range from the accessible ROM area. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2700 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/debugger/gui/CartCVWidget.cxx | 3 +- src/debugger/gui/CartDPCWidget.cxx | 83 +++++++++++++++++++++++++++++ src/debugger/gui/CartDPCWidget.hxx | 46 ++++++++++++++++ src/debugger/gui/CartE7Widget.cxx | 5 +- src/debugger/gui/CartEFSCWidget.cxx | 2 +- src/debugger/gui/CartF4SCWidget.cxx | 2 +- src/debugger/gui/CartF6SCWidget.cxx | 2 +- src/debugger/gui/CartF8SCWidget.cxx | 2 +- src/debugger/gui/CartFA2Widget.cxx | 2 +- src/debugger/gui/CartFAWidget.cxx | 2 +- src/debugger/gui/module.mk | 1 + src/emucore/CartDPC.cxx | 5 +- src/emucore/CartDPC.hxx | 22 +++++++- 13 files changed, 165 insertions(+), 12 deletions(-) create mode 100644 src/debugger/gui/CartDPCWidget.cxx create mode 100644 src/debugger/gui/CartDPCWidget.hxx diff --git a/src/debugger/gui/CartCVWidget.cxx b/src/debugger/gui/CartCVWidget.cxx index d1432bced..6cff83497 100644 --- a/src/debugger/gui/CartCVWidget.cxx +++ b/src/debugger/gui/CartCVWidget.cxx @@ -35,7 +35,8 @@ CartridgeCVWidget::CartridgeCVWidget( info << "CV 2K ROM + 1K RAM , non-bankswitched\n" << "1024 bytes RAM @ $F000 - $F7FF\n" << " $F000 - $F3FF (R), $F400 - $F7FF (W)\n" - << "ROM accessible @ $" << HEX4 << start << " - " << "$" << (start + size - 1); + << "ROM accessible @ $" << HEX4 << start << " - " + << "$" << (start + size - 1); addBaseInformation(cart.mySize, "CommaVid", info.str()); } diff --git a/src/debugger/gui/CartDPCWidget.cxx b/src/debugger/gui/CartDPCWidget.cxx new file mode 100644 index 000000000..cf22e252d --- /dev/null +++ b/src/debugger/gui/CartDPCWidget.cxx @@ -0,0 +1,83 @@ +//============================================================================ +// +// 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 "CartDPC.hxx" +#include "PopUpWidget.hxx" +#include "CartDPCWidget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeDPCWidget::CartridgeDPCWidget( + GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, CartridgeDPC& cart) + : CartDebugWidget(boss, font, x, y, w, h), + myCart(cart) +{ + uInt16 size = cart.mySize; + + ostringstream info; + info << "DPC cartridge, two 4K banks + 2K display bank\n" + << "DPC registers accessible @ $F000 - $F07F\n" + << " $F000 - $F03F (R), $F040 - $F07F (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 < 2; ++i, offset += 0x1000) + { + uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; + start -= start % 0x1000; + info << "Bank " << i << " @ $" << HEX4 << (start + 0x80) << " - " + << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n"; + } + + int xpos = 10, + ypos = addBaseInformation(size, "Activision (Pitfall II)", info.str()) + + myLineHeight; + + StringMap items; + items.push_back("0 ($FF8)", "0"); + items.push_back("1 ($FF9)", "1"); + 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 CartridgeDPCWidget::loadConfig() +{ + myBank->setSelected(myCart.myCurrentBank); + + CartDebugWidget::loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeDPCWidget::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/CartDPCWidget.hxx b/src/debugger/gui/CartDPCWidget.hxx new file mode 100644 index 000000000..6958ceba5 --- /dev/null +++ b/src/debugger/gui/CartDPCWidget.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 CARTRIDGEDPC_WIDGET_HXX +#define CARTRIDGEDPC_WIDGET_HXX + +class CartridgeDPC; +class PopUpWidget; + +#include "CartDebugWidget.hxx" + +class CartridgeDPCWidget : public CartDebugWidget +{ + public: + CartridgeDPCWidget(GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, + CartridgeDPC& cart); + virtual ~CartridgeDPCWidget() { } + + void loadConfig(); + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + CartridgeDPC& myCart; + PopUpWidget* myBank; + + enum { kBankChanged = 'bkCH' }; +}; + +#endif diff --git a/src/debugger/gui/CartE7Widget.cxx b/src/debugger/gui/CartE7Widget.cxx index 6288011d7..5ec2ebf54 100644 --- a/src/debugger/gui/CartE7Widget.cxx +++ b/src/debugger/gui/CartE7Widget.cxx @@ -40,7 +40,7 @@ CartridgeE7Widget::CartridgeE7Widget( << " Hotspots $FE8 - $FEB (256B of RAM slice 1)\n" << " $F400 - $F7FF (R), $F000 - $F3FF (W)\n" << "Upper 1.5K ROM accessible @ $FA00 - $FFFF\n" - << " Always points to last 2K (1.5) of ROM\n" + << " Always points to last 1.5K of ROM\n" << "Startup slices = " << cart.myStartBank << " / 0\n"; #if 0 @@ -50,7 +50,8 @@ CartridgeE7Widget::CartridgeE7Widget( info << "Bank RORG" << " = $" << HEX4 << start << "\n"; #endif int xpos = 10, - ypos = addBaseInformation(size, "M-Network", info.str(), 15) + 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/CartEFSCWidget.cxx b/src/debugger/gui/CartEFSCWidget.cxx index 2a27e35dc..7a3c61127 100644 --- a/src/debugger/gui/CartEFSCWidget.cxx +++ b/src/debugger/gui/CartEFSCWidget.cxx @@ -41,7 +41,7 @@ CartridgeEFSCWidget::CartridgeEFSCWidget( { uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; start -= start % 0x1000; - info << "Bank " << dec << i << " @ $" << HEX4 << start << " - " + info << "Bank " << dec << i << " @ $" << HEX4 << (start + 0x100) << " - " << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n"; } diff --git a/src/debugger/gui/CartF4SCWidget.cxx b/src/debugger/gui/CartF4SCWidget.cxx index 65762b76d..913c5003a 100644 --- a/src/debugger/gui/CartF4SCWidget.cxx +++ b/src/debugger/gui/CartF4SCWidget.cxx @@ -41,7 +41,7 @@ CartridgeF4SCWidget::CartridgeF4SCWidget( { uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; start -= start % 0x1000; - info << "Bank " << i << " @ $" << HEX4 << start << " - " + info << "Bank " << i << " @ $" << HEX4 << (start + 0x100) << " - " << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n"; } diff --git a/src/debugger/gui/CartF6SCWidget.cxx b/src/debugger/gui/CartF6SCWidget.cxx index 65c945f82..6df8de243 100644 --- a/src/debugger/gui/CartF6SCWidget.cxx +++ b/src/debugger/gui/CartF6SCWidget.cxx @@ -41,7 +41,7 @@ CartridgeF6SCWidget::CartridgeF6SCWidget( { uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; start -= start % 0x1000; - info << "Bank " << i << " @ $" << HEX4 << start << " - " + info << "Bank " << i << " @ $" << HEX4 << (start + 0x100) << " - " << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n"; } diff --git a/src/debugger/gui/CartF8SCWidget.cxx b/src/debugger/gui/CartF8SCWidget.cxx index ad4e4796a..8302aab59 100644 --- a/src/debugger/gui/CartF8SCWidget.cxx +++ b/src/debugger/gui/CartF8SCWidget.cxx @@ -41,7 +41,7 @@ CartridgeF8SCWidget::CartridgeF8SCWidget( { uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; start -= start % 0x1000; - info << "Bank " << i << " @ $" << HEX4 << start << " - " + info << "Bank " << i << " @ $" << HEX4 << (start + 0x100) << " - " << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n"; } diff --git a/src/debugger/gui/CartFA2Widget.cxx b/src/debugger/gui/CartFA2Widget.cxx index 6c85b457d..1c9928eb8 100644 --- a/src/debugger/gui/CartFA2Widget.cxx +++ b/src/debugger/gui/CartFA2Widget.cxx @@ -43,7 +43,7 @@ CartridgeFA2Widget::CartridgeFA2Widget( { uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; start -= start % 0x1000; - info << "Bank " << i << " @ $" << HEX4 << start << " - " + info << "Bank " << i << " @ $" << HEX4 << (start + 0x200) << " - " << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n"; } diff --git a/src/debugger/gui/CartFAWidget.cxx b/src/debugger/gui/CartFAWidget.cxx index b6c02d717..a7ac3b663 100644 --- a/src/debugger/gui/CartFAWidget.cxx +++ b/src/debugger/gui/CartFAWidget.cxx @@ -41,7 +41,7 @@ CartridgeFAWidget::CartridgeFAWidget( { uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; start -= start % 0x1000; - info << "Bank " << i << " @ $" << HEX4 << start << " - " + info << "Bank " << i << " @ $" << HEX4 << (start + 0x200) << " - " << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n"; } diff --git a/src/debugger/gui/module.mk b/src/debugger/gui/module.mk index 4c10d1e66..52a95e656 100644 --- a/src/debugger/gui/module.mk +++ b/src/debugger/gui/module.mk @@ -26,6 +26,7 @@ MODULE_OBJS := \ src/debugger/gui/Cart4A50Widget.o \ src/debugger/gui/Cart4KWidget.o \ src/debugger/gui/CartCVWidget.o \ + src/debugger/gui/CartDPCWidget.o \ src/debugger/gui/CartE0Widget.o \ src/debugger/gui/CartE7Widget.o \ src/debugger/gui/CartEFWidget.o \ diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index 57e485e2b..0ebf3beb0 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -27,11 +27,12 @@ CartridgeDPC::CartridgeDPC(const uInt8* image, uInt32 size, const Settings& settings) : Cartridge(settings), + mySize(size), mySystemCycles(0), myFractionalClocks(0.0) { // Make a copy of the entire image - memcpy(myImage, image, BSPF_min(size, 8192u + 2048u + 255u)); + memcpy(myImage, image, BSPF_min(size, 8192u + 2048u + 256u)); createCodeAccessBase(8192); // Pointer to the program ROM (8K @ 0 byte offset) @@ -467,7 +468,7 @@ bool CartridgeDPC::patch(uInt16 address, uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const uInt8* CartridgeDPC::getImage(int& size) const { - size = 8192 + 2048 + 255; + size = mySize; return myImage; } diff --git a/src/emucore/CartDPC.hxx b/src/emucore/CartDPC.hxx index 28a8e2a47..dfbed84c2 100644 --- a/src/emucore/CartDPC.hxx +++ b/src/emucore/CartDPC.hxx @@ -24,6 +24,9 @@ class System; #include "bspf.hxx" #include "Cart.hxx" +#ifdef DEBUGGER_SUPPORT + #include "CartDPCWidget.hxx" +#endif /** Cartridge class used for Pitfall II. There are two 4K program banks, a @@ -35,6 +38,8 @@ class System; */ class CartridgeDPC : public Cartridge { + friend class CartridgeDPCWidget; + public: /** Create a new cartridge using the specified image @@ -128,6 +133,18 @@ class CartridgeDPC : public Cartridge */ string name() const { return "CartridgeDPC"; } + #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 CartridgeDPCWidget(boss, font, x, y, w, h, *this); + } + #endif + public: /** Get the byte at the specified address. @@ -159,7 +176,10 @@ class CartridgeDPC : public Cartridge private: // The ROM image - uInt8 myImage[8192 + 2048 + 255]; + uInt8 myImage[8192 + 2048 + 256]; + + // (Actual) Size of the ROM image + uInt32 mySize; // Pointer to the 8K program ROM image of the cartridge uInt8* myProgramImage;