From 8ad0d445c3c85766beece50808f621c02c488e48 Mon Sep 17 00:00:00 2001 From: urchlay Date: Mon, 27 Jun 2005 04:45:52 +0000 Subject: [PATCH] Bare beginnings of bankswitching support for the debugger. Unfortunately every single Cart class will have to be touched to make this work, and there are 20 of them. Currently only CartF8 has the necessary methods. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@568 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/debugger/Debugger.cxx | 26 ++++++++++++++++++++- stella/src/debugger/Debugger.hxx | 10 +++++++-- stella/src/debugger/DebuggerParser.cxx | 31 +++++++++++++++++++++++++- stella/src/debugger/DebuggerParser.hxx | 3 ++- stella/src/emucore/Cart.cxx | 27 +++++++++++++++++++++- stella/src/emucore/Cart.hxx | 9 ++++++-- stella/src/emucore/CartF8.cxx | 12 +++++++++- stella/src/emucore/CartF8.hxx | 7 +++--- stella/src/emucore/Console.cxx | 3 ++- stella/src/emucore/Console.hxx | 10 +++++++-- 10 files changed, 123 insertions(+), 15 deletions(-) diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index 90d739e41..20eeebe05 100644 --- a/stella/src/debugger/Debugger.cxx +++ b/stella/src/debugger/Debugger.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.cxx,v 1.35 2005-06-25 17:26:32 stephena Exp $ +// $Id: Debugger.cxx,v 1.36 2005-06-27 04:45:35 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -687,3 +687,27 @@ void Debugger::addLabel(string label, int address) { void Debugger::reloadROM() { myOSystem->createConsole( myOSystem->romFile() ); } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Debugger::setBank(int bank) { + if(myConsole->cartridge().bankCount() > 1) { + myConsole->cartridge().bank(bank); + return true; + } + return false; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int Debugger::getBank() { + return myConsole->cartridge().bank(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int Debugger::bankCount() { + return myConsole->cartridge().bankCount(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +const char *Debugger::getCartType() { + return myConsole->cartridge().name(); +} diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index 673e2c7bb..9c65d90ce 100644 --- a/stella/src/debugger/Debugger.hxx +++ b/stella/src/debugger/Debugger.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.hxx,v 1.32 2005-06-27 03:32:50 urchlay Exp $ +// $Id: Debugger.hxx,v 1.33 2005-06-27 04:45:52 urchlay Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -51,7 +51,7 @@ enum { for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.32 2005-06-27 03:32:50 urchlay Exp $ + @version $Id: Debugger.hxx,v 1.33 2005-06-27 04:45:52 urchlay Exp $ */ class Debugger : public DialogContainer { @@ -229,6 +229,12 @@ class Debugger : public DialogContainer PackedBitArray *writetraps() { return writeTraps; } DebuggerParser *parser() { return myParser; } + + bool setBank(int bank); + int bankCount(); + int getBank(); + const char *getCartType(); + protected: Console* myConsole; System* mySystem; diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index 178daf822..4eb8ae18c 100644 --- a/stella/src/debugger/DebuggerParser.cxx +++ b/stella/src/debugger/DebuggerParser.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerParser.cxx,v 1.37 2005-06-27 03:32:51 urchlay Exp $ +// $Id: DebuggerParser.cxx,v 1.38 2005-06-27 04:45:52 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -33,6 +33,14 @@ Command DebuggerParser::commands[] = { &DebuggerParser::executeA }, + { + "bank", + "Show # of banks (with no args), Switch to bank (with 1 arg)", + false, + { kARG_BYTE, kARG_END_ARGS }, + &DebuggerParser::executeBank + }, + { "base", "Set default base (hex, dec, or bin)", @@ -886,6 +894,27 @@ void DebuggerParser::executeA() { debugger->setA(args[0]); } +// "bank" +void DebuggerParser::executeBank() { + if(argCount == 0) { + int banks = debugger->bankCount(); + commandResult += debugger->getCartType(); + commandResult += ": "; + if(banks < 2) + commandResult += "bankswitching not supported by this cartridge"; + else { + commandResult += debugger->valueToString(debugger->getBank()); + commandResult += "/"; + commandResult += debugger->valueToString(banks); + } + } else { + if(debugger->setBank(args[0])) + commandResult += "switched bank OK"; + else + commandResult += "invalid bank number for cartridge"; + } +} + // "base" void DebuggerParser::executeBase() { if(args[0] == 2 || argStrings[0] == "bin") diff --git a/stella/src/debugger/DebuggerParser.hxx b/stella/src/debugger/DebuggerParser.hxx index a26233265..cc2c1b32e 100644 --- a/stella/src/debugger/DebuggerParser.hxx +++ b/stella/src/debugger/DebuggerParser.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerParser.hxx,v 1.19 2005-06-27 03:32:51 urchlay Exp $ +// $Id: DebuggerParser.hxx,v 1.20 2005-06-27 04:45:52 urchlay Exp $ //============================================================================ #ifndef DEBUGGER_PARSER_HXX @@ -87,6 +87,7 @@ class DebuggerParser string compPrefix; void executeA(); + void executeBank(); void executeBase(); void executeBreak(); void executeC(); diff --git a/stella/src/emucore/Cart.cxx b/stella/src/emucore/Cart.cxx index d096f85c4..575a3c743 100644 --- a/stella/src/emucore/Cart.cxx +++ b/stella/src/emucore/Cart.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Cart.cxx,v 1.9 2005-06-16 00:55:57 stephena Exp $ +// $Id: Cart.cxx,v 1.10 2005-06-27 04:45:52 urchlay Exp $ //============================================================================ #include @@ -266,3 +266,28 @@ Cartridge& Cartridge::operator = (const Cartridge&) return *this; } +// default implementations of bankswitching-related methods. +// These are suitable to be inherited by a cart type that +// doesn't support bankswitching at all. + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int Cartridge::bank() { + return 0; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Cartridge::bank(uInt16 b) { + // do nothing. +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int Cartridge::bankCount() { + return 1; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge::patch(int address, int value) { + return false; +} + + diff --git a/stella/src/emucore/Cart.hxx b/stella/src/emucore/Cart.hxx index 36e39558b..8cd2f8517 100644 --- a/stella/src/emucore/Cart.hxx +++ b/stella/src/emucore/Cart.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Cart.hxx,v 1.3 2005-06-16 00:55:57 stephena Exp $ +// $Id: Cart.hxx,v 1.4 2005-06-27 04:45:52 urchlay Exp $ //============================================================================ #ifndef CARTRIDGE_HXX @@ -31,7 +31,7 @@ class System; game and handles any bankswitching performed by the cartridge. @author Bradford W. Mott - @version $Id: Cart.hxx,v 1.3 2005-06-16 00:55:57 stephena Exp $ + @version $Id: Cart.hxx,v 1.4 2005-06-27 04:45:52 urchlay Exp $ */ class Cartridge : public Device { @@ -59,6 +59,11 @@ class Cartridge : public Device */ virtual ~Cartridge(); + virtual int bank(); // get current bank (-1 if no bankswitching supported) + virtual void bank(uInt16 b); // set bank + virtual int bankCount(); // count # of banks + virtual bool patch(int address, int value); + private: /** Try to auto-detect the bankswitching type of the cartridge diff --git a/stella/src/emucore/CartF8.cxx b/stella/src/emucore/CartF8.cxx index 32d97f05a..2659bcd4c 100644 --- a/stella/src/emucore/CartF8.cxx +++ b/stella/src/emucore/CartF8.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartF8.cxx,v 1.4 2005-06-16 01:11:26 stephena Exp $ +// $Id: CartF8.cxx,v 1.5 2005-06-27 04:45:52 urchlay Exp $ //============================================================================ #include @@ -146,6 +146,16 @@ void CartridgeF8::bank(uInt16 bank) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int CartridgeF8::bank() { + return myCurrentBank; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int CartridgeF8::bankCount() { + return 2; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeF8::save(Serializer& out) { diff --git a/stella/src/emucore/CartF8.hxx b/stella/src/emucore/CartF8.hxx index fc43393fb..c56228824 100644 --- a/stella/src/emucore/CartF8.hxx +++ b/stella/src/emucore/CartF8.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartF8.hxx,v 1.3 2005-06-16 01:11:26 stephena Exp $ +// $Id: CartF8.hxx,v 1.4 2005-06-27 04:45:52 urchlay Exp $ //============================================================================ #ifndef CARTRIDGEF8_HXX @@ -31,7 +31,7 @@ class Deserializer; are two 4K banks. @author Bradford W. Mott - @version $Id: CartF8.hxx,v 1.3 2005-06-16 01:11:26 stephena Exp $ + @version $Id: CartF8.hxx,v 1.4 2005-06-27 04:45:52 urchlay Exp $ */ class CartridgeF8 : public Cartridge { @@ -101,13 +101,14 @@ class CartridgeF8 : public Cartridge */ virtual void poke(uInt16 address, uInt8 value); - private: /** Install pages for the specified bank in the system @param bank The bank that should be installed in the system */ void bank(uInt16 bank); + int bank(); + int bankCount(); private: // Indicates which bank is currently active diff --git a/stella/src/emucore/Console.cxx b/stella/src/emucore/Console.cxx index c3bc83976..fd474a963 100644 --- a/stella/src/emucore/Console.cxx +++ b/stella/src/emucore/Console.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Console.cxx,v 1.60 2005-06-25 17:26:32 stephena Exp $ +// $Id: Console.cxx,v 1.61 2005-06-27 04:45:52 urchlay Exp $ //============================================================================ #include @@ -153,6 +153,7 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem) // Remember what my media source is myMediaSource = tia; myTIAdebugger = new TIADebug(tia); + myCart = cartridge; // Reset, the system to its power-on state mySystem->reset(); diff --git a/stella/src/emucore/Console.hxx b/stella/src/emucore/Console.hxx index 1bb918e24..3a28c91b6 100644 --- a/stella/src/emucore/Console.hxx +++ b/stella/src/emucore/Console.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Console.hxx,v 1.33 2005-06-21 04:30:49 urchlay Exp $ +// $Id: Console.hxx,v 1.34 2005-06-27 04:45:52 urchlay Exp $ //============================================================================ #ifndef CONSOLE_HXX @@ -31,12 +31,13 @@ class System; #include "Props.hxx" #include "TIA.hxx" #include "TIADebug.hxx" +#include "Cart.hxx" /** This class represents the entire game console. @author Bradford W. Mott - @version $Id: Console.hxx,v 1.33 2005-06-21 04:30:49 urchlay Exp $ + @version $Id: Console.hxx,v 1.34 2005-06-27 04:45:52 urchlay Exp $ */ class Console { @@ -102,6 +103,8 @@ class Console */ System& system() const { return *mySystem; } + Cartridge& cartridge() const { return *myCart; } + public: /** Overloaded assignment operator @@ -228,6 +231,9 @@ class Console // Pointer to TIADebug TIADebug *myTIAdebugger; + + // Pointer to the Cartridge (the debugger needs it) + Cartridge *myCart; }; #endif