diff --git a/stella/src/common/DCmdQuit.cxx b/stella/src/common/DCmdQuit.cxx index d7bdf2e1e..2a2ef45af 100644 --- a/stella/src/common/DCmdQuit.cxx +++ b/stella/src/common/DCmdQuit.cxx @@ -1,3 +1,20 @@ +//============================================================================ +// +// 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-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: DCmdQuit.cxx,v 1.2 2005-06-09 15:08:21 stephena Exp $ +//============================================================================ #include "bspf.hxx" #include "DCmdQuit.hxx" diff --git a/stella/src/common/DCmdQuit.hxx b/stella/src/common/DCmdQuit.hxx index 611dec573..ebaf5e435 100644 --- a/stella/src/common/DCmdQuit.hxx +++ b/stella/src/common/DCmdQuit.hxx @@ -1,3 +1,20 @@ +//============================================================================ +// +// 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-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: DCmdQuit.hxx,v 1.2 2005-06-09 15:08:21 stephena Exp $ +//============================================================================ #ifndef DCMDQUIT_HXX #define DCMDQUIT_HXX diff --git a/stella/src/common/DebuggerCommand.cxx b/stella/src/common/DebuggerCommand.cxx index 30a2592fe..cd304e37b 100644 --- a/stella/src/common/DebuggerCommand.cxx +++ b/stella/src/common/DebuggerCommand.cxx @@ -1,3 +1,20 @@ +//============================================================================ +// +// 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-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: DebuggerCommand.cxx,v 1.2 2005-06-09 15:08:22 stephena Exp $ +//============================================================================ #include "bspf.hxx" #include "DebuggerCommand.hxx" diff --git a/stella/src/common/DebuggerCommand.hxx b/stella/src/common/DebuggerCommand.hxx index f837b2ff0..c422996d9 100644 --- a/stella/src/common/DebuggerCommand.hxx +++ b/stella/src/common/DebuggerCommand.hxx @@ -1,3 +1,20 @@ +//============================================================================ +// +// 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-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: DebuggerCommand.hxx,v 1.2 2005-06-09 15:08:22 stephena Exp $ +//============================================================================ #ifndef DEBUGGER_COMMAND_HXX #define DEBUGGER_COMMAND_HXX diff --git a/stella/src/common/DebuggerParser.cxx b/stella/src/common/DebuggerParser.cxx index 4c13849fa..e0470596d 100644 --- a/stella/src/common/DebuggerParser.cxx +++ b/stella/src/common/DebuggerParser.cxx @@ -1,14 +1,37 @@ +//============================================================================ +// +// 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-2005 by Bradford W. Mott and the Stella team +// +// 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.2 2005-06-09 15:08:22 stephena Exp $ +//============================================================================ #include "bspf.hxx" #include "DebuggerParser.hxx" #include "DebuggerCommand.hxx" #include "DCmdQuit.hxx" -DebuggerParser::DebuggerParser() { +DebuggerParser::DebuggerParser() + : quitCmd(NULL) +{ done = false; quitCmd = new DCmdQuit(this); } +DebuggerParser::~DebuggerParser() { + delete quitCmd; +} + string DebuggerParser::currentAddress() { return "currentAddress()"; } @@ -17,7 +40,7 @@ void DebuggerParser::setDone() { done = true; } -string DebuggerParser::run(string command) { +string DebuggerParser::run(const string& command) { if(command == "quit") { // TODO: use lookup table to determine which DebuggerCommand to run return quitCmd->execute(); diff --git a/stella/src/common/DebuggerParser.hxx b/stella/src/common/DebuggerParser.hxx index a4d92c9d2..856a14451 100644 --- a/stella/src/common/DebuggerParser.hxx +++ b/stella/src/common/DebuggerParser.hxx @@ -1,3 +1,20 @@ +//============================================================================ +// +// 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-2005 by Bradford W. Mott and the Stella team +// +// 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.2 2005-06-09 15:08:22 stephena Exp $ +//============================================================================ #ifndef DEBUGGER_PARSER_HXX #define DEBUGGER_PARSER_HXX @@ -9,9 +26,11 @@ class DebuggerParser { public: DebuggerParser(); + ~DebuggerParser(); + string currentAddress(); void setDone(); - string run(string command); + string run(const string& command); private: DebuggerCommand *quitCmd; diff --git a/stella/src/emucore/Console.hxx b/stella/src/emucore/Console.hxx index fa19edb57..9e8f12b45 100644 --- a/stella/src/emucore/Console.hxx +++ b/stella/src/emucore/Console.hxx @@ -8,12 +8,12 @@ // SS SS tt ee ll ll aa aa // SSSS ttt eeeee llll llll aaaaa // -// Copyright (c) 1995-2004 by Bradford W. Mott +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team // // 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.31 2005-05-12 18:45:20 stephena Exp $ +// $Id: Console.hxx,v 1.32 2005-06-09 15:08:22 stephena Exp $ //============================================================================ #ifndef CONSOLE_HXX @@ -35,7 +35,7 @@ class System; This class represents the entire game console. @author Bradford W. Mott - @version $Id: Console.hxx,v 1.31 2005-05-12 18:45:20 stephena Exp $ + @version $Id: Console.hxx,v 1.32 2005-06-09 15:08:22 stephena Exp $ */ class Console { diff --git a/stella/src/gui/Debugger.cxx b/stella/src/gui/Debugger.cxx index 152ceb0db..f9c962dd2 100644 --- a/stella/src/gui/Debugger.cxx +++ b/stella/src/gui/Debugger.cxx @@ -13,26 +13,32 @@ // 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.2 2005-06-03 17:52:06 stephena Exp $ +// $Id: Debugger.cxx,v 1.3 2005-06-09 15:08:23 stephena Exp $ //============================================================================ +#include "bspf.hxx" + #include "Version.hxx" #include "OSystem.hxx" #include "FrameBuffer.hxx" #include "DebuggerDialog.hxx" -#include "bspf.hxx" +#include "DebuggerParser.hxx" #include "Debugger.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Debugger::Debugger(OSystem* osystem) - : DialogContainer(osystem), - myConsole(NULL) + : DialogContainer(osystem), + myConsole(NULL), + myParser(NULL) { + // Init parser + myParser = new DebuggerParser(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Debugger::~Debugger() { + delete myParser; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -53,3 +59,9 @@ void Debugger::initializeVideo() string title = string("Stella version ") + STELLA_VERSION + ": Debugger mode"; myOSystem->frameBuffer().initialize(title, kDebuggerWidth, kDebuggerHeight, false); } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +const string Debugger::run(const string& command) +{ + return myParser->run(command); +} diff --git a/stella/src/gui/Debugger.hxx b/stella/src/gui/Debugger.hxx index 75dab67d6..2b230d042 100644 --- a/stella/src/gui/Debugger.hxx +++ b/stella/src/gui/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.2 2005-06-03 17:52:06 stephena Exp $ +// $Id: Debugger.hxx,v 1.3 2005-06-09 15:08:23 stephena Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -21,6 +21,7 @@ class OSystem; class Console; +class DebuggerParser; #include "DialogContainer.hxx" @@ -30,10 +31,11 @@ enum { }; /** - The base dialog for the ROM launcher in Stella. + The base dialog for the ROM launcher in Stella. Also acts as the parent + for all debugging operations in Stella (parser, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.2 2005-06-03 17:52:06 stephena Exp $ + @version $Id: Debugger.hxx,v 1.3 2005-06-09 15:08:23 stephena Exp $ */ class Debugger : public DialogContainer { @@ -59,10 +61,16 @@ class Debugger : public DialogContainer */ void initializeVideo(); + /** + Run the debugger command and return the result. + */ + const string run(const string& command); + void setConsole(Console* console) { myConsole = console; } private: Console* myConsole; + DebuggerParser* myParser; }; #endif diff --git a/stella/src/gui/PromptDialog.cxx b/stella/src/gui/PromptDialog.cxx index 5f09745a9..6e926f1d1 100644 --- a/stella/src/gui/PromptDialog.cxx +++ b/stella/src/gui/PromptDialog.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: PromptDialog.cxx,v 1.6 2005-06-09 04:31:45 urchlay Exp $ +// $Id: PromptDialog.cxx,v 1.7 2005-06-09 15:08:23 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -23,6 +23,7 @@ #include "FrameBuffer.hxx" #include "EventHandler.hxx" #include "Version.hxx" +#include "Debugger.hxx" #include "PromptDialog.hxx" @@ -39,7 +40,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PromptDialog::PromptDialog(OSystem* osystem, DialogContainer* parent, int x, int y, int w, int h) - : Dialog(osystem, parent, x, y, w, h) + : Dialog(osystem, parent, x, y, w, h) { _kConsoleCharWidth = instance()->consoleFont().getMaxCharWidth(); _kConsoleLineHeight = instance()->consoleFont().getFontHeight() + 2; @@ -59,10 +60,6 @@ PromptDialog::PromptDialog(OSystem* osystem, DialogContainer* parent, _scrollBar = new ScrollBarWidget(this, _w - kScrollBarWidth - 1, 0, kScrollBarWidth, _h); _scrollBar->setTarget(this); - // Init callback - _callbackProc = 0; - _callbackRefCon = 0; - // Init History _historyIndex = 0; _historyLine = 0; @@ -72,10 +69,6 @@ PromptDialog::PromptDialog(OSystem* osystem, DialogContainer* parent, _promptStartPos = _promptEndPos = -1; - // Init parser (FIXME: should the parser be a class variable, - // instead of an instance variable? - parser = new DebuggerParser(); - // Display greetings & prompt string version = string("Stella version ") + STELLA_VERSION + "\n"; print(version.c_str()); @@ -152,7 +145,6 @@ void PromptDialog::handleKeyDown(int ascii, int keycode, int modifiers) assert(_promptEndPos >= _promptStartPos); int len = _promptEndPos - _promptStartPos; - bool keepRunning = true; if (len > 0) { @@ -168,11 +160,8 @@ void PromptDialog::handleKeyDown(int ascii, int keycode, int modifiers) // Add the input to the history addToHistory(str); - // Pass it to the input callback, if any - if (_callbackProc) - keepRunning = (*_callbackProc)(this, str, _callbackRefCon); - - print( parser->run(str) + "\n" ); + // Pass the command to the debugger, and print the result + print( instance()->debugger().run(str) + "\n" ); // Get rid of the string buffer delete [] str; diff --git a/stella/src/gui/PromptDialog.hxx b/stella/src/gui/PromptDialog.hxx index ff3306088..da863ba2e 100644 --- a/stella/src/gui/PromptDialog.hxx +++ b/stella/src/gui/PromptDialog.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: PromptDialog.hxx,v 1.4 2005-06-09 04:31:45 urchlay Exp $ +// $Id: PromptDialog.hxx,v 1.5 2005-06-09 15:08:23 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -25,10 +25,10 @@ class CommandSender; class DialogContainer; class ScrollBarWidget; +class DebuggerParser; #include #include "Dialog.hxx" -#include "DebuggerParser.hxx" enum { kBufferSize = 32768, @@ -49,18 +49,6 @@ class PromptDialog : public Dialog int vprintf(const char *format, va_list argptr); #undef putchar void putchar(int c); - - typedef bool (*InputCallbackProc)(PromptDialog *console, const char *input, void *refCon); - typedef bool (*CompletionCallbackProc)(PromptDialog* console, const char *input, char*& completion, void *refCon); - - void setInputCallback(InputCallbackProc proc, void *refCon) { - _callbackProc = proc; - _callbackRefCon = refCon; - } - void setCompletionCallback(CompletionCallbackProc proc, void *refCon) { - _completionCallbackProc = proc; - _completionCallbackRefCon = refCon; - } protected: inline char &buffer(int idx) { return _buffer[idx % kBufferSize]; } @@ -106,16 +94,6 @@ class PromptDialog : public Dialog int _promptEndPos; ScrollBarWidget* _scrollBar; - DebuggerParser* parser; - - // The _callbackProc is called whenver a data line is entered - // - InputCallbackProc _callbackProc; - void *_callbackRefCon; - - // _completionCallbackProc is called when tab is pressed - CompletionCallbackProc _completionCallbackProc; - void *_completionCallbackRefCon; char _history[kHistorySize][kLineBufferSize]; int _historySize;