diff --git a/src/debugger/gui/CartE0Widget.cxx b/src/debugger/gui/CartE0Widget.cxx new file mode 100644 index 000000000..6f4fde217 --- /dev/null +++ b/src/debugger/gui/CartE0Widget.cxx @@ -0,0 +1,138 @@ +//============================================================================ +// +// 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 "CartE0.hxx" +#include "PopUpWidget.hxx" +#include "CartE0Widget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeE0Widget::CartridgeE0Widget( + GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, CartridgeE0& cart) + : CartDebugWidget(boss, font, x, y, w, h), + myCart(cart) +{ + uInt32 size = 8 * 1024; + + ostringstream info; + info << "Parker Bros E0 cartridge, 8 1K slices\n" + << "Segment 0 accessible @ $F000 - $F3FF\n" + << " Hotspots $FE0 to $FE7\n" + << "Segment 1 accessible @ $F400 - $F7FF\n" + << " Hotspots $FE8 to $FEF\n" + << "Segment 2 accessible @ $F800 - $FBFF\n" + << " Hotspots $FF0 to $FF7\n" + << "Segment 3 accessible @ $FC00 - $FFFF\n" + << " Always points to last 1K of ROM\n" + << "Startup slices = 0 / 1 / 2\n"; + +#if 0 + // Eventually, we should query this from the debugger/disassembler + uInt16 start = (cart.myImage[size-3] << 8) | cart.myImage[size-4]; + start -= start % 0x1000; + info << "Bank RORG" << " = $" << HEX4 << start << "\n"; +#endif + int xpos = 10, + ypos = addBaseInformation(size, "Parker Brothers", info.str()) + myLineHeight; + + StringMap items0, items1, items2; + items0.push_back("0 ($FE0)", "0"); + items0.push_back("1 ($FE1)", "1"); + items0.push_back("2 ($FE2)", "2"); + items0.push_back("3 ($FE3)", "3"); + items0.push_back("4 ($FE4)", "4"); + items0.push_back("5 ($FE5)", "5"); + items0.push_back("6 ($FE6)", "6"); + items0.push_back("7 ($FE7)", "7"); + + items1.push_back("0 ($FE8)", "0"); + items1.push_back("1 ($FE9)", "1"); + items1.push_back("2 ($FEA)", "2"); + items1.push_back("3 ($FEB)", "3"); + items1.push_back("4 ($FEC)", "4"); + items1.push_back("5 ($FED)", "5"); + items1.push_back("6 ($FEE)", "6"); + items1.push_back("7 ($FEF)", "7"); + + items2.push_back("0 ($FF0)", "0"); + items2.push_back("1 ($FF1)", "1"); + items2.push_back("2 ($FF2)", "2"); + items2.push_back("3 ($FF3)", "3"); + items2.push_back("4 ($FF4)", "4"); + items2.push_back("5 ($FF5)", "5"); + items2.push_back("6 ($FF6)", "6"); + items2.push_back("7 ($FF7)", "7"); + + const int lwidth = font.getStringWidth("Set slice for segment X: "); + mySlice0 = + new PopUpWidget(boss, font, xpos, ypos-2, font.getStringWidth("7 ($FF7)"), + myLineHeight, items0, "Set slice for segment 0: ", + lwidth, kSlice0Changed); + mySlice0->setTarget(this); + addFocusWidget(mySlice0); + ypos += mySlice0->getHeight() + 4; + + mySlice1 = + new PopUpWidget(boss, font, xpos, ypos-2, font.getStringWidth("7 ($FF7)"), + myLineHeight, items1, "Set slice for segment 1: ", + lwidth, kSlice1Changed); + mySlice1->setTarget(this); + addFocusWidget(mySlice1); + ypos += mySlice1->getHeight() + 4; + + mySlice2 = + new PopUpWidget(boss, font, xpos, ypos-2, font.getStringWidth("7 ($FF7)"), + myLineHeight, items2, "Set slice for segment 2: ", + lwidth, kSlice2Changed); + mySlice2->setTarget(this); + addFocusWidget(mySlice2); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeE0Widget::loadConfig() +{ + mySlice0->setSelected(myCart.myCurrentSlice[0]); + mySlice1->setSelected(myCart.myCurrentSlice[1]); + mySlice2->setSelected(myCart.myCurrentSlice[2]); + + CartDebugWidget::loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeE0Widget::handleCommand(CommandSender* sender, + int cmd, int data, int id) +{ + myCart.unlockBank(); + + switch(cmd) + { + case kSlice0Changed: + myCart.segmentZero(mySlice0->getSelected()); + break; + case kSlice1Changed: + myCart.segmentOne(mySlice1->getSelected()); + break; + case kSlice2Changed: + myCart.segmentTwo(mySlice2->getSelected()); + break; + } + + myCart.lockBank(); + invalidate(); +} diff --git a/src/debugger/gui/CartE0Widget.hxx b/src/debugger/gui/CartE0Widget.hxx new file mode 100644 index 000000000..fd02fe57d --- /dev/null +++ b/src/debugger/gui/CartE0Widget.hxx @@ -0,0 +1,50 @@ +//============================================================================ +// +// 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 CARTRIDGEE0_WIDGET_HXX +#define CARTRIDGEE0_WIDGET_HXX + +class CartridgeE0; +class PopUpWidget; + +#include "CartDebugWidget.hxx" + +class CartridgeE0Widget : public CartDebugWidget +{ + public: + CartridgeE0Widget(GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, + CartridgeE0& cart); + virtual ~CartridgeE0Widget() { } + + void loadConfig(); + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + CartridgeE0& myCart; + PopUpWidget *mySlice0, *mySlice1, *mySlice2; + + enum { + kSlice0Changed = 's0CH', + kSlice1Changed = 's1CH', + kSlice2Changed = 's2CH' + }; +}; + +#endif diff --git a/src/debugger/gui/CartE7Widget.cxx b/src/debugger/gui/CartE7Widget.cxx new file mode 100644 index 000000000..79cdc3428 --- /dev/null +++ b/src/debugger/gui/CartE7Widget.cxx @@ -0,0 +1,113 @@ +//============================================================================ +// +// 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 "CartE7.hxx" +#include "PopUpWidget.hxx" +#include "CartE7Widget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeE7Widget::CartridgeE7Widget( + GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, CartridgeE7& cart) + : CartDebugWidget(boss, font, x, y, w, h), + myCart(cart) +{ + uInt32 size = 8 * 2048; + + ostringstream info; + info << "E7 cartridge, 8 2K slices ROM + 2 1K RAM\n" + << "Lower 2K accessible @ $F000 - $F7FF\n" + << " Slice 0 - 6 of ROM (hotspots $FE0 to $FE6)\n" + << " Slice 0 (1K) of RAM (hotspot $FE7)\n" + << " $F400 - $F7FF (R), $F000 - $F3FF (W)\n" + << "256B RAM accessible @ $F800 - $F9FF\n" + << " 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" + << "Startup slices = " << cart.myStartBank << " / 0\n"; + +#if 0 + // Eventually, we should query this from the debugger/disassembler + uInt16 start = (cart.myImage[size-3] << 8) | cart.myImage[size-4]; + start -= start % 0x1000; + info << "Bank RORG" << " = $" << HEX4 << start << "\n"; +#endif + int xpos = 10, + ypos = addBaseInformation(size, "M-Network", info.str()) + myLineHeight; + + StringMap items0, items1; + items0.push_back("0 - ROM ($FE0)", "0"); + items0.push_back("1 - ROM ($FE1)", "1"); + items0.push_back("2 - ROM ($FE2)", "2"); + items0.push_back("3 - ROM ($FE3)", "3"); + items0.push_back("4 - ROM ($FE4)", "4"); + items0.push_back("5 - ROM ($FE5)", "5"); + items0.push_back("6 - ROM ($FE6)", "6"); + items0.push_back("7 - RAM ($FE7)", "7"); + + items1.push_back("0 - RAM ($FE8)", "0"); + items1.push_back("1 - RAM ($FE9)", "1"); + items1.push_back("2 - RAM ($FEA)", "2"); + items1.push_back("3 - RAM ($FEB)", "3"); + + const int lwidth = font.getStringWidth("Set slice for upper 256B: "), + fwidth = font.getStringWidth("3 - RAM ($FEB)"); + myLower2K = + new PopUpWidget(boss, font, xpos, ypos-2, fwidth, myLineHeight, items0, + "Set slice for lower 2K: ", lwidth, kLowerChanged); + myLower2K->setTarget(this); + addFocusWidget(myLower2K); + ypos += myLower2K->getHeight() + 4; + + myUpper256B = + new PopUpWidget(boss, font, xpos, ypos-2, fwidth, myLineHeight, items1, + "Set slice for upper 256B: ", lwidth, kUpperChanged); + myUpper256B->setTarget(this); + addFocusWidget(myUpper256B); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeE7Widget::loadConfig() +{ + myLower2K->setSelected(myCart.myCurrentSlice[0]); + myUpper256B->setSelected(myCart.myCurrentRAM); + + CartDebugWidget::loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CartridgeE7Widget::handleCommand(CommandSender* sender, + int cmd, int data, int id) +{ + myCart.unlockBank(); + + switch(cmd) + { + case kLowerChanged: + myCart.bank(myLower2K->getSelected()); + break; + case kUpperChanged: + myCart.bankRAM(myUpper256B->getSelected()); + break; + } + + myCart.lockBank(); + invalidate(); +} diff --git a/src/debugger/gui/CartE7Widget.hxx b/src/debugger/gui/CartE7Widget.hxx new file mode 100644 index 000000000..bdc58084b --- /dev/null +++ b/src/debugger/gui/CartE7Widget.hxx @@ -0,0 +1,49 @@ +//============================================================================ +// +// 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 CARTRIDGEE7_WIDGET_HXX +#define CARTRIDGEE7_WIDGET_HXX + +class CartridgeE7; +class PopUpWidget; + +#include "CartDebugWidget.hxx" + +class CartridgeE7Widget : public CartDebugWidget +{ + public: + CartridgeE7Widget(GuiObject* boss, const GUI::Font& font, + int x, int y, int w, int h, + CartridgeE7& cart); + virtual ~CartridgeE7Widget() { } + + void loadConfig(); + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + CartridgeE7& myCart; + PopUpWidget *myLower2K, *myUpper256B; + + enum { + kLowerChanged = 'lwCH', + kUpperChanged = 'upCH' + }; +}; + +#endif diff --git a/src/debugger/gui/module.mk b/src/debugger/gui/module.mk index 219d51305..927cdaada 100644 --- a/src/debugger/gui/module.mk +++ b/src/debugger/gui/module.mk @@ -25,6 +25,8 @@ MODULE_OBJS := \ src/debugger/gui/Cart3FWidget.o \ src/debugger/gui/Cart4KWidget.o \ src/debugger/gui/CartCVWidget.o \ + src/debugger/gui/CartE0Widget.o \ + src/debugger/gui/CartE7Widget.o \ src/debugger/gui/CartEFWidget.o \ src/debugger/gui/CartEFSCWidget.o \ src/debugger/gui/CartF0Widget.o \ diff --git a/src/emucore/CartE0.hxx b/src/emucore/CartE0.hxx index 28643556a..80c5bcf40 100644 --- a/src/emucore/CartE0.hxx +++ b/src/emucore/CartE0.hxx @@ -24,6 +24,9 @@ class System; #include "bspf.hxx" #include "Cart.hxx" +#ifdef DEBUGGER_SUPPORT + #include "CartE0Widget.hxx" +#endif /** This is the cartridge class for Parker Brothers' 8K games. In @@ -31,7 +34,7 @@ class System; is broken into four 1K segments. The desired 1K slice of the ROM is selected by accessing 1FE0 to 1FE7 for the first 1K. 1FE8 to 1FEF selects the slice for the second 1K, and 1FF0 to - 1FF8 selects the slice for the third 1K. The last 1K segment + 1FF7 selects the slice for the third 1K. The last 1K segment always points to the last 1K of the ROM image. Because of the complexity of this scheme, the cart reports having @@ -43,6 +46,8 @@ class System; */ class CartridgeE0 : public Cartridge { + friend class CartridgeE0Widget; + public: /** Create a new cartridge using the specified image @@ -129,6 +134,18 @@ class CartridgeE0 : public Cartridge */ string name() const { return "CartridgeE0"; } + #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 CartridgeE0Widget(boss, font, x, y, w, h, *this); + } + #endif + public: /** Get the byte at the specified address. diff --git a/src/emucore/CartE7.hxx b/src/emucore/CartE7.hxx index f59bc8e08..3a07ea09f 100644 --- a/src/emucore/CartE7.hxx +++ b/src/emucore/CartE7.hxx @@ -24,6 +24,9 @@ class System; #include "bspf.hxx" #include "Cart.hxx" +#ifdef DEBUGGER_SUPPORT + #include "CartE7Widget.hxx" +#endif /** This is the cartridge class for M-Network bankswitched games. @@ -60,6 +63,8 @@ class System; */ class CartridgeE7 : public Cartridge { + friend class CartridgeE7Widget; + public: /** Create a new cartridge using the specified image @@ -146,6 +151,18 @@ class CartridgeE7 : public Cartridge */ string name() const { return "CartridgeE7"; } + #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 CartridgeE7Widget(boss, font, x, y, w, h, *this); + } + #endif + public: /** Get the byte at the specified address.