diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index 54b1dcb5e..4ad16e8af 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -75,6 +75,7 @@ class Debugger : public DialogContainer // Make these friend classes, to ease communications with the debugger // Although it isn't enforced, these classes should use accessor methods // directly, and not touch the instance variables + friend class CartDebugWidget; friend class DebuggerDialog; friend class DebuggerParser; friend class EventHandler; diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index c9043bc22..fac1bb5cd 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -638,7 +638,7 @@ void DebuggerParser::executeA() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// "bank" +// "bank" void DebuggerParser::executeBank() { int banks = debugger->cartDebug().bankCount(); diff --git a/src/debugger/gui/CartDebugWidget.hxx b/src/debugger/gui/CartDebugWidget.hxx index 5cd4a7cb2..80bf7c89f 100644 --- a/src/debugger/gui/CartDebugWidget.hxx +++ b/src/debugger/gui/CartDebugWidget.hxx @@ -25,6 +25,8 @@ class ButtonWidget; #include "Font.hxx" #include "Command.hxx" +#include "Debugger.hxx" +#include "RomWidget.hxx" #include "Widget.hxx" #include "EditTextWidget.hxx" #include "StringListWidget.hxx" @@ -81,7 +83,7 @@ class CartDebugWidget : public Widget, public CommandSender const StringList& sl = bs.stringList(); uInt32 lines = sl.size(); if(lines < 3) lines = 3; - if(lines > 6) lines = 6; +// if(lines > 6) lines = 6; new StaticTextWidget(_boss, _font, x, y, lwidth, myFontHeight, "Description: ", kTextAlignLeft); @@ -94,6 +96,12 @@ class CartDebugWidget : public Widget, public CommandSender return y; } + // Inform the ROM Widget that the underlying cart has somehow changed + void invalidate() + { + Debugger::debugger().rom().invalidate(); + } + virtual void loadConfig() { }; virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) { }; diff --git a/src/debugger/gui/CartF4Widget.cxx b/src/debugger/gui/CartF4Widget.cxx new file mode 100644 index 000000000..d3c8588d6 --- /dev/null +++ b/src/debugger/gui/CartF4Widget.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 "CartF4.hxx" +#include "PopUpWidget.hxx" +#include "CartF4Widget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeF4Widget::CartridgeF4Widget( + GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, CartridgeF4& cart) + : CartDebugWidget(boss, font, x, y, w, h), + myCart(cart) +{ + uInt16 size = 8 * 4096; + + ostringstream info; + info << "Standard F4 cartridge, eight 4K banks\n" + << "Startup bank = " << cart.myStartBank << "\n"; + + // Eventually, we should query this from the debugger/disassembler + for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF4; i < 8; ++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, "Atari", info.str()) + myLineHeight; + + StringMap items; + items.push_back("0 ($FF4)", "0"); + items.push_back("1 ($FF5)", "1"); + items.push_back("2 ($FF6)", "2"); + items.push_back("3 ($FF7)", "3"); + items.push_back("4 ($FF8)", "0"); + items.push_back("5 ($FF9)", "1"); + items.push_back("6 ($FFA)", "2"); + items.push_back("7 ($FFB)", "3"); + myBank = + new PopUpWidget(boss, font, xpos, ypos-2, font.getStringWidth("1 ($FF9)"), + myLineHeight, items, "Set bank: ", + font.getStringWidth("Set bank: "), kBankChanged); + myBank->setTarget(this); + addFocusWidget(myBank); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeF4Widget::loadConfig() +{ + myBank->setSelected(myCart.myCurrentBank); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeF4Widget::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/CartF4Widget.hxx b/src/debugger/gui/CartF4Widget.hxx new file mode 100644 index 000000000..2533208bb --- /dev/null +++ b/src/debugger/gui/CartF4Widget.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 CARTRIDGEF4_WIDGET_HXX +#define CARTRIDGEF4_WIDGET_HXX + +class CartridgeF4; +class PopUpWidget; + +#include "CartDebugWidget.hxx" + +class CartridgeF4Widget : public CartDebugWidget +{ + public: + CartridgeF4Widget(GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, + CartridgeF4& cart); + virtual ~CartridgeF4Widget() { } + + void loadConfig(); + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + CartridgeF4& myCart; + PopUpWidget* myBank; + + enum { kBankChanged = 'bkCH' }; +}; + +#endif diff --git a/src/debugger/gui/CartF6Widget.cxx b/src/debugger/gui/CartF6Widget.cxx new file mode 100644 index 000000000..9379b8ed4 --- /dev/null +++ b/src/debugger/gui/CartF6Widget.cxx @@ -0,0 +1,79 @@ +//============================================================================ +// +// 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 "CartF6.hxx" +#include "PopUpWidget.hxx" +#include "CartF6Widget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeF6Widget::CartridgeF6Widget( + GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, CartridgeF6& cart) + : CartDebugWidget(boss, font, x, y, w, h), + myCart(cart) +{ + uInt16 size = 4 * 4096; + + ostringstream info; + info << "Standard F6 cartridge, four 4K banks\n" + << "Startup bank = " << cart.myStartBank << "\n"; + + // Eventually, we should query this from the debugger/disassembler + for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF6; i < 4; ++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, "Atari", info.str()) + myLineHeight; + + StringMap items; + items.push_back("0 ($FF6)", "0"); + items.push_back("1 ($FF7)", "1"); + items.push_back("2 ($FF8)", "2"); + items.push_back("3 ($FF9)", "3"); + myBank = + new PopUpWidget(boss, font, xpos, ypos-2, font.getStringWidth("0 ($FF6) "), + myLineHeight, items, "Set bank: ", + font.getStringWidth("Set bank: "), kBankChanged); + myBank->setTarget(this); + addFocusWidget(myBank); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeF6Widget::loadConfig() +{ + myBank->setSelected(myCart.myCurrentBank); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeF6Widget::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/CartF6Widget.hxx b/src/debugger/gui/CartF6Widget.hxx new file mode 100644 index 000000000..e12d8392c --- /dev/null +++ b/src/debugger/gui/CartF6Widget.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 CARTRIDGEF6_WIDGET_HXX +#define CARTRIDGEF6_WIDGET_HXX + +class CartridgeF6; +class PopUpWidget; + +#include "CartDebugWidget.hxx" + +class CartridgeF6Widget : public CartDebugWidget +{ + public: + CartridgeF6Widget(GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, + CartridgeF6& cart); + virtual ~CartridgeF6Widget() { } + + void loadConfig(); + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + CartridgeF6& myCart; + PopUpWidget* myBank; + + enum { kBankChanged = 'bkCH' }; +}; + +#endif diff --git a/src/debugger/gui/CartF8Widget.cxx b/src/debugger/gui/CartF8Widget.cxx new file mode 100644 index 000000000..9d72b4cc1 --- /dev/null +++ b/src/debugger/gui/CartF8Widget.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 "CartF8.hxx" +#include "PopUpWidget.hxx" +#include "CartF8Widget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeF8Widget::CartridgeF8Widget( + GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, CartridgeF8& cart) + : CartDebugWidget(boss, font, x, y, w, h), + myCart(cart) +{ + uInt16 size = 8192; + + ostringstream info; + info << "Standard F8 cartridge, two 4K banks\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 << " - " + << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n"; + } + + int xpos = 10, + ypos = addBaseInformation(size, "Atari", 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 ($FF8) "), + myLineHeight, items, "Set bank: ", + font.getStringWidth("Set bank: "), kBankChanged); + myBank->setTarget(this); + addFocusWidget(myBank); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeF8Widget::loadConfig() +{ + myBank->setSelected(myCart.myCurrentBank); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeF8Widget::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/CartF8Widget.hxx b/src/debugger/gui/CartF8Widget.hxx new file mode 100644 index 000000000..cd3abf3cc --- /dev/null +++ b/src/debugger/gui/CartF8Widget.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 CARTRIDGEF8_WIDGET_HXX +#define CARTRIDGEF8_WIDGET_HXX + +class CartridgeF8; +class PopUpWidget; + +#include "CartDebugWidget.hxx" + +class CartridgeF8Widget : public CartDebugWidget +{ + public: + CartridgeF8Widget(GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, + CartridgeF8& cart); + virtual ~CartridgeF8Widget() { } + + void loadConfig(); + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + CartridgeF8& myCart; + PopUpWidget* myBank; + + enum { kBankChanged = 'bkCH' }; +}; + +#endif diff --git a/src/debugger/gui/module.mk b/src/debugger/gui/module.mk index 080970947..61a5a0e7a 100644 --- a/src/debugger/gui/module.mk +++ b/src/debugger/gui/module.mk @@ -21,6 +21,9 @@ MODULE_OBJS := \ src/debugger/gui/ToggleWidget.o \ src/debugger/gui/Cart2KWidget.o \ src/debugger/gui/Cart4KWidget.o \ + src/debugger/gui/CartF4Widget.o \ + src/debugger/gui/CartF6Widget.o \ + src/debugger/gui/CartF8Widget.o \ src/debugger/gui/JoystickWidget.o \ src/debugger/gui/PaddleWidget.o \ src/debugger/gui/BoosterWidget.o \ diff --git a/src/emucore/CartF4.hxx b/src/emucore/CartF4.hxx index a6c1092fe..a07a78059 100644 --- a/src/emucore/CartF4.hxx +++ b/src/emucore/CartF4.hxx @@ -24,6 +24,9 @@ class System; #include "bspf.hxx" #include "Cart.hxx" +#ifdef DEBUGGER_SUPPORT + #include "CartF4Widget.hxx" +#endif /** Cartridge class used for Atari's 32K bankswitched games. There @@ -34,6 +37,8 @@ class System; */ class CartridgeF4 : public Cartridge { + friend class CartridgeF4Widget; + public: /** Create a new cartridge using the specified image @@ -120,6 +125,18 @@ class CartridgeF4 : public Cartridge */ string name() const { return "CartridgeF4"; } + #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 CartridgeF4Widget(boss, font, x, y, w, h, *this); + } + #endif + public: /** Get the byte at the specified address. diff --git a/src/emucore/CartF6.hxx b/src/emucore/CartF6.hxx index abff27f6b..758d5cf66 100644 --- a/src/emucore/CartF6.hxx +++ b/src/emucore/CartF6.hxx @@ -24,6 +24,9 @@ class System; #include "bspf.hxx" #include "Cart.hxx" +#ifdef DEBUGGER_SUPPORT + #include "CartF6Widget.hxx" +#endif /** Cartridge class used for Atari's 16K bankswitched games. There @@ -34,6 +37,8 @@ class System; */ class CartridgeF6 : public Cartridge { + friend class CartridgeF6Widget; + public: /** Create a new cartridge using the specified image @@ -120,6 +125,18 @@ class CartridgeF6 : public Cartridge */ string name() const { return "CartridgeF6"; } + #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 CartridgeF6Widget(boss, font, x, y, w, h, *this); + } + #endif + public: /** Get the byte at the specified address. diff --git a/src/emucore/CartF8.hxx b/src/emucore/CartF8.hxx index bcf04aaf2..496f0e2c1 100644 --- a/src/emucore/CartF8.hxx +++ b/src/emucore/CartF8.hxx @@ -24,6 +24,9 @@ class System; #include "bspf.hxx" #include "Cart.hxx" +#ifdef DEBUGGER_SUPPORT + #include "CartF8Widget.hxx" +#endif /** Cartridge class used for Atari's 8K bankswitched games. There @@ -34,6 +37,8 @@ class System; */ class CartridgeF8 : public Cartridge { + friend class CartridgeF8Widget; + public: /** Create a new cartridge using the specified image @@ -122,6 +127,18 @@ class CartridgeF8 : public Cartridge */ string name() const { return "CartridgeF8"; } + #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 CartridgeF8Widget(boss, font, x, y, w, h, *this); + } + #endif + public: /** Get the byte at the specified address.