diff --git a/stella/src/build/makefile b/stella/src/build/makefile index bc2238f0f..bf0090300 100644 --- a/stella/src/build/makefile +++ b/stella/src/build/makefile @@ -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: makefile,v 1.88 2005-06-08 18:45:07 stephena Exp $ +## $Id: makefile,v 1.89 2005-06-09 04:31:44 urchlay Exp $ ##============================================================================ ##============================================================================ @@ -170,6 +170,7 @@ CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \ Props.o PropsSet.o Random.o SoundNull.o Switches.o Settings.o TIA.o \ Serializer.o Deserializer.o EventHandler.o FrameBuffer.o \ OSystem.o FSNode.o unzip.o \ + DebuggerParser.o DebuggerCommand.o DCmdQuit.o \ $(M6502_OBJS) $(GUI_OBJS) stella: $(CORE_OBJS) $(OBJS) @@ -454,3 +455,13 @@ DebuggerDialog.o: $(GUI)/DebuggerDialog.cxx $(GUI)/DebuggerDialog.hxx PromptDialog.o: $(GUI)/PromptDialog.cxx $(GUI)/PromptDialog.hxx $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/PromptDialog.cxx + +DebuggerParser.o: $(COMMON)/DebuggerParser.cxx $(COMMON)/DebuggerParser.hxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(COMMON)/DebuggerParser.cxx + +DebuggerCommand.o: $(COMMON)/DebuggerCommand.cxx $(COMMON)/DebuggerCommand.hxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(COMMON)/DebuggerCommand.cxx + +DCmdQuit.o: $(COMMON)/DCmdQuit.cxx $(COMMON)/DCmdQuit.hxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(COMMON)/DCmdQuit.cxx + diff --git a/stella/src/common/DCmdQuit.cxx b/stella/src/common/DCmdQuit.cxx new file mode 100644 index 000000000..d7bdf2e1e --- /dev/null +++ b/stella/src/common/DCmdQuit.cxx @@ -0,0 +1,24 @@ + +#include "bspf.hxx" +#include "DCmdQuit.hxx" +#include "DebuggerParser.hxx" + + + +DCmdQuit::DCmdQuit(DebuggerParser* p) { + parser = p; +} + +string DCmdQuit::getName() { + return "Quit"; +} + +int DCmdQuit::getArgCount() { + return 0; +} + +string DCmdQuit::execute() { + parser->setDone(); + return "If you quit the debugger, I'll summon Satan all over your hard drive!"; +} + diff --git a/stella/src/common/DCmdQuit.hxx b/stella/src/common/DCmdQuit.hxx new file mode 100644 index 000000000..611dec573 --- /dev/null +++ b/stella/src/common/DCmdQuit.hxx @@ -0,0 +1,19 @@ + +#ifndef DCMDQUIT_HXX +#define DCMDQUIT_HXX + +#include "bspf.hxx" +#include "DebuggerParser.hxx" +#include "DebuggerCommand.hxx" + +class DCmdQuit: public DebuggerCommand +{ + public: + DCmdQuit(DebuggerParser* p); + + string getName(); + int getArgCount(); + string execute(); +}; + +#endif diff --git a/stella/src/common/DebuggerCommand.cxx b/stella/src/common/DebuggerCommand.cxx new file mode 100644 index 000000000..30a2592fe --- /dev/null +++ b/stella/src/common/DebuggerCommand.cxx @@ -0,0 +1,11 @@ + +#include "bspf.hxx" +#include "DebuggerCommand.hxx" +#include "DebuggerParser.hxx" + +DebuggerCommand::DebuggerCommand() { +} + +DebuggerCommand::DebuggerCommand(DebuggerParser* p) { + parser = p; +} diff --git a/stella/src/common/DebuggerCommand.hxx b/stella/src/common/DebuggerCommand.hxx new file mode 100644 index 000000000..f837b2ff0 --- /dev/null +++ b/stella/src/common/DebuggerCommand.hxx @@ -0,0 +1,23 @@ + +#ifndef DEBUGGER_COMMAND_HXX +#define DEBUGGER_COMMAND_HXX + +#include "bspf.hxx" + +class DebuggerParser; + +class DebuggerCommand +{ + public: + DebuggerCommand(); + DebuggerCommand(DebuggerParser* p); + + virtual string getName() = 0; + virtual int getArgCount() = 0; + virtual string execute() = 0; + + protected: + DebuggerParser *parser; +}; + +#endif diff --git a/stella/src/common/DebuggerParser.cxx b/stella/src/common/DebuggerParser.cxx new file mode 100644 index 000000000..4c13849fa --- /dev/null +++ b/stella/src/common/DebuggerParser.cxx @@ -0,0 +1,27 @@ + +#include "bspf.hxx" +#include "DebuggerParser.hxx" +#include "DebuggerCommand.hxx" +#include "DCmdQuit.hxx" + +DebuggerParser::DebuggerParser() { + done = false; + quitCmd = new DCmdQuit(this); +} + +string DebuggerParser::currentAddress() { + return "currentAddress()"; +} + +void DebuggerParser::setDone() { + done = true; +} + +string DebuggerParser::run(string command) { + if(command == "quit") { + // TODO: use lookup table to determine which DebuggerCommand to run + return quitCmd->execute(); + } else { + return "unimplemented command"; + } +} diff --git a/stella/src/common/DebuggerParser.hxx b/stella/src/common/DebuggerParser.hxx new file mode 100644 index 000000000..a4d92c9d2 --- /dev/null +++ b/stella/src/common/DebuggerParser.hxx @@ -0,0 +1,21 @@ + +#ifndef DEBUGGER_PARSER_HXX +#define DEBUGGER_PARSER_HXX + +#include "bspf.hxx" +#include "DebuggerCommand.hxx" + +class DebuggerParser +{ + public: + DebuggerParser(); + string currentAddress(); + void setDone(); + string run(string command); + + private: + DebuggerCommand *quitCmd; + bool done; +}; + +#endif diff --git a/stella/src/gui/PromptDialog.cxx b/stella/src/gui/PromptDialog.cxx index 74b1aaa4b..5f09745a9 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.5 2005-06-08 21:16:06 stephena Exp $ +// $Id: PromptDialog.cxx,v 1.6 2005-06-09 04:31:45 urchlay Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -72,6 +72,10 @@ 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()); @@ -168,7 +172,8 @@ void PromptDialog::handleKeyDown(int ascii, int keycode, int modifiers) if (_callbackProc) keepRunning = (*_callbackProc)(this, str, _callbackRefCon); -cerr << "Command entered: \'" << str << "\'\n"; // FIXME - tie this into DebuggerParser + print( parser->run(str) + "\n" ); + // Get rid of the string buffer delete [] str; } @@ -626,6 +631,12 @@ void PromptDialog::putcharIntern(int c) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void PromptDialog::print(string str) // laziness/convenience method +{ + print(str.c_str()); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PromptDialog::print(const char *str) { diff --git a/stella/src/gui/PromptDialog.hxx b/stella/src/gui/PromptDialog.hxx index 98766d336..ff3306088 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.3 2005-06-08 18:45:09 stephena Exp $ +// $Id: PromptDialog.hxx,v 1.4 2005-06-09 04:31:45 urchlay Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -28,6 +28,7 @@ class ScrollBarWidget; #include #include "Dialog.hxx" +#include "DebuggerParser.hxx" enum { kBufferSize = 32768, @@ -69,6 +70,7 @@ class PromptDialog : public Dialog void putcharIntern(int c); void insertIntoPrompt(const char *str); void print(const char *str); + void print(string str); void updateScrollBuffer(); void scrollToCurrent(); @@ -104,6 +106,7 @@ class PromptDialog : public Dialog int _promptEndPos; ScrollBarWidget* _scrollBar; + DebuggerParser* parser; // The _callbackProc is called whenver a data line is entered //