diff --git a/stella/Debugger.txt b/stella/Debugger.txt index a3b144e36..2bcd99ff7 100644 --- a/stella/Debugger.txt +++ b/stella/Debugger.txt @@ -54,6 +54,12 @@ What the debugger can do: - TIA display is updated during step/trace, so we can see our scanlines being drawn as it happens. This isn't 100% perfect: unlike a real TIA, the one in Stella only updates when it's written to. +- Script (batch) file support, including auto-running a script file + named after the ROM image. +- Saving the current debugger state to a script file (including + breakpoints, traps, etc). +- Built-in functions for use with "breakif", to support common conditions + (such as breaking when the user presses Game Select...) Planned features for Stella 2.0 release: - Graphical TIA tab, with register names and GUI buttons for @@ -66,10 +72,6 @@ Planned features for Stella 2.0 release: that aren't supported. - Patch ROM support for a few cart types doesn't work. - Some way to control joystick/etc. input from within the debugger. -- Script (batch) file support, including auto-running a script file - named after the ROM image. -- Saving the current debugger state to a script file (including - breakpoints, traps, etc). - Source-level debugging: if a DASM .lst file is available, we'll show the listing in the ROM tab instead of a disassembly. This is already availabe in a very crude form ("loadlist" and "list" commands). @@ -78,7 +80,7 @@ Planned features for Stella 2.0 release: use all the CPU registers and flags in expressions (e.g. "print a+1" does what you expect), and the pseudo-variables "_scan" and "_bank" (which evaluate the the current scanline and bank number). Need to add more TIA, - RIOT registers too. + RIOT registers too. Also, more functions for the builtin function lib. Future plans (post 2.0): - Possibly a mini-assembler diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index 70101da16..7e610c7da 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.77 2005-07-29 16:37:17 urchlay Exp $ +// $Id: Debugger.cxx,v 1.78 2005-07-30 16:25:45 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -1006,3 +1006,11 @@ const string Debugger::builtinHelp() { return result; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Debugger::saveROM(string filename) { + // TODO: error checking + ofstream *out = new ofstream(filename.c_str(), ios::out | ios::binary); + bool res = myConsole->cartridge().save(*out); + delete out; + return res; +} diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index be5dd4170..cf6184118 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.62 2005-07-29 16:37:17 urchlay Exp $ +// $Id: Debugger.hxx,v 1.63 2005-07-30 16:25:48 urchlay Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -74,7 +74,7 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)(); for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.62 2005-07-29 16:37:17 urchlay Exp $ + @version $Id: Debugger.hxx,v 1.63 2005-07-30 16:25:48 urchlay Exp $ */ class Debugger : public DialogContainer { @@ -255,6 +255,8 @@ class Debugger : public DialogContainer string loadListFile(string f = ""); const string getSourceLines(int addr); + bool saveROM(string filename); + private: /** Save state of each debugger subsystem diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index 7ae4a9640..0ffd56119 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.72 2005-07-29 16:37:17 urchlay Exp $ +// $Id: DebuggerParser.cxx,v 1.73 2005-07-30 16:25:48 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -357,6 +357,14 @@ Command DebuggerParser::commands[] = { &DebuggerParser::executeSave }, + { + "saverom", + "Save (possibly patched) ROM to file", + true, + { kARG_FILE, kARG_END_ARGS }, + &DebuggerParser::executeSaverom + }, + { "saveses", "Save console session to file", @@ -1525,13 +1533,20 @@ void DebuggerParser::executeS() { // "save" void DebuggerParser::executeSave() { - cerr << "got here" << endl; if(saveScriptFile(argStrings[0])) commandResult = "saved script to file " + argStrings[0]; else commandResult = red("I/O error"); } +// "saverom" +void DebuggerParser::executeSaverom() { + if(debugger->saveROM(argStrings[0])) + commandResult = "saved ROM"; + else + commandResult = red("failed to save ROM"); +} + // "saveses" void DebuggerParser::executeSaveses() { if(debugger->prompt()->saveBuffer(argStrings[0])) diff --git a/stella/src/debugger/DebuggerParser.hxx b/stella/src/debugger/DebuggerParser.hxx index 493253c82..8fd9e4218 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.38 2005-07-23 19:07:15 urchlay Exp $ +// $Id: DebuggerParser.hxx,v 1.39 2005-07-30 16:25:48 urchlay Exp $ //============================================================================ #ifndef DEBUGGER_PARSER_HXX @@ -134,6 +134,7 @@ class DebuggerParser void executeRunTo(); void executeS(); void executeSave(); + void executeSaverom(); void executeSaveses(); void executeSavestate(); void executeSavesym(); diff --git a/stella/src/emucore/Cart.cxx b/stella/src/emucore/Cart.cxx index b044ff106..c9835ad72 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.14 2005-07-09 15:19:24 urchlay Exp $ +// $Id: Cart.cxx,v 1.15 2005-07-30 16:25:48 urchlay Exp $ //============================================================================ #include @@ -311,4 +311,25 @@ bool Cartridge::patch(uInt16 address, uInt8 value) { return false; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge::save(ofstream& out) { + int size = -1; + + uInt8* image = getImage(size); + if(image == 0 || size <= 0) { + cerr << "save not supported" << endl; + return false; + } + + for(int i=0; i #include "bspf.hxx" #include "Device.hxx" @@ -31,7 +32,7 @@ class System; game and handles any bankswitching performed by the cartridge. @author Bradford W. Mott - @version $Id: Cart.hxx,v 1.7 2005-07-09 15:19:24 urchlay Exp $ + @version $Id: Cart.hxx,v 1.8 2005-07-30 16:25:48 urchlay Exp $ */ class Cartridge : public Device { @@ -62,7 +63,9 @@ class Cartridge : public Device virtual void bank(uInt16 b); // set bank virtual int bank(); // get current bank (-1 if no bankswitching supported) virtual int bankCount(); // count # of banks - virtual bool patch(uInt16 address, uInt8 value); + virtual bool patch(uInt16 address, uInt8 value); // yes, this writes to ROM + bool save(ofstream& out); // need a way to save patched ROMs + virtual uInt8* getImage(int& size); // save() uses this private: /** diff --git a/stella/src/emucore/Cart4K.cxx b/stella/src/emucore/Cart4K.cxx index 4412f37ec..6bcd45996 100644 --- a/stella/src/emucore/Cart4K.cxx +++ b/stella/src/emucore/Cart4K.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: Cart4K.cxx,v 1.6 2005-06-27 15:07:54 urchlay Exp $ +// $Id: Cart4K.cxx,v 1.7 2005-07-30 16:25:48 urchlay Exp $ //============================================================================ #include @@ -136,3 +136,9 @@ bool Cartridge4K::load(Deserializer& in) return true; } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +uInt8* Cartridge4K::getImage(int& size) { + size = 4096; + return &myImage[0]; +} diff --git a/stella/src/emucore/Cart4K.hxx b/stella/src/emucore/Cart4K.hxx index d63eb5f92..2561e4d3a 100644 --- a/stella/src/emucore/Cart4K.hxx +++ b/stella/src/emucore/Cart4K.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: Cart4K.hxx,v 1.5 2005-06-27 15:07:54 urchlay Exp $ +// $Id: Cart4K.hxx,v 1.6 2005-07-30 16:25:48 urchlay Exp $ //============================================================================ #ifndef CARTRIDGE4K_HXX @@ -32,7 +32,7 @@ class Deserializer; not bankswitched. @author Bradford W. Mott - @version $Id: Cart4K.hxx,v 1.5 2005-06-27 15:07:54 urchlay Exp $ + @version $Id: Cart4K.hxx,v 1.6 2005-07-30 16:25:48 urchlay Exp $ */ class Cartridge4K : public Cartridge { @@ -86,6 +86,8 @@ class Cartridge4K : public Cartridge */ virtual bool load(Deserializer& in); + virtual uInt8* getImage(int& size); + public: /** Get the byte at the specified address.