Added a library of built-in functions. These let the user test for

common conditions such as "joystick 0 pressed to the left" (this would
be "_joy0left"). To see the list, type "help".


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@699 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
urchlay 2005-07-29 16:37:17 +00:00
parent 7d095313e0
commit ab0c70fe45
3 changed files with 69 additions and 4 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Debugger.cxx,v 1.76 2005-07-23 19:07:15 urchlay Exp $ // $Id: Debugger.cxx,v 1.77 2005-07-29 16:37:17 urchlay Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -42,10 +42,45 @@
#include "TiaOutputWidget.hxx" #include "TiaOutputWidget.hxx"
#include "Expression.hxx" #include "Expression.hxx"
#include "YaccParser.hxx"
#include "Debugger.hxx" #include "Debugger.hxx"
Debugger* Debugger::myStaticDebugger; Debugger* Debugger::myStaticDebugger;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static const string builtin_functions[][3] = {
// { "name", "definition", "help text" }
// left joystick:
{ "_joy0left", "!(*SWCHA & $40)", "Left joystick moved left" },
{ "_joy0right", "!(*SWCHA & $80)", "Left joystick moved right" },
{ "_joy0up", "!(*SWCHA & $10)", "Left joystick moved up" },
{ "_joy0down", "!(*SWCHA & $20)", "Left joystick moved down" },
{ "_joy0button", "!(*INPT4 & $80)", "Left joystick button pressed" },
// right joystick:
{ "_joy1left", "!(*SWCHA & $04)", "Right joystick moved left" },
{ "_joy1right", "!(*SWCHA & $08)", "Right joystick moved right" },
{ "_joy1up", "!(*SWCHA & $01)", "Right joystick moved up" },
{ "_joy1down", "!(*SWCHA & $02)", "Right joystick moved down" },
{ "_joy1button", "!(*INPT5 & $80)", "Right joystick button pressed" },
// console switches:
{ "_select", "!(*SWCHB & $01)", "Game Select pressed" },
{ "_reset", "!(*SWCHB & $02)", "Game Reset pressed" },
{ "_color", "*SWCHB & $08", "Color/BW set to Color" },
{ "_bw", "!(*SWCHB & $08)", "Color/BW set to BW" },
{ "_diff0a", "!(*SWCHB & $40)", "Right difficulty set to A (easy)" },
{ "_diff0b", "*SWCHB & $40", "Right difficulty set to B (hard)" },
{ "_diff1a", "!(*SWCHB & $80)", "Right difficulty set to A (easy)" },
{ "_diff1b", "*SWCHB & $80", "Right difficulty set to B (hard)" },
// empty string marks end of list, do not remove
{ "", "", "" }
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Debugger::Debugger(OSystem* osystem) Debugger::Debugger(OSystem* osystem)
: DialogContainer(osystem), : DialogContainer(osystem),
@ -74,6 +109,15 @@ Debugger::Debugger(OSystem* osystem)
// there will only be ever one instance of debugger in Stella, // there will only be ever one instance of debugger in Stella,
// I don't care :) // I don't care :)
myStaticDebugger = this; myStaticDebugger = this;
// init builtins
for(int i=0; builtin_functions[i][0] != ""; i++) {
string f = builtin_functions[i][1];
int res = YaccParser::parse(f.c_str());
if(res != 0) cerr << "ERROR in builtin function!" << endl;
Expression *exp = YaccParser::getResult();
addFunction(builtin_functions[i][0], exp);
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -945,3 +989,20 @@ Expression *Debugger::getFunction(string name) {
const FunctionMap Debugger::getFunctionMap() { const FunctionMap Debugger::getFunctionMap() {
return functions; return functions;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Debugger::builtinHelp() {
string result;
for(int i=0; builtin_functions[i][0] != ""; i++) {
result += builtin_functions[i][0];
result += " {";
result += builtin_functions[i][1];
result += "}\n";
result += " ";
result += builtin_functions[i][2];
result += "\n";
}
return result;
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Debugger.hxx,v 1.61 2005-07-23 19:07:15 urchlay Exp $ // $Id: Debugger.hxx,v 1.62 2005-07-29 16:37:17 urchlay Exp $
//============================================================================ //============================================================================
#ifndef DEBUGGER_HXX #ifndef DEBUGGER_HXX
@ -74,7 +74,7 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)();
for all debugging operations in Stella (parser, 6502 debugger, etc). for all debugging operations in Stella (parser, 6502 debugger, etc).
@author Stephen Anthony @author Stephen Anthony
@version $Id: Debugger.hxx,v 1.61 2005-07-23 19:07:15 urchlay Exp $ @version $Id: Debugger.hxx,v 1.62 2005-07-29 16:37:17 urchlay Exp $
*/ */
class Debugger : public DialogContainer class Debugger : public DialogContainer
{ {
@ -125,6 +125,7 @@ class Debugger : public DialogContainer
void delFunction(string name); void delFunction(string name);
Expression *getFunction(string name); Expression *getFunction(string name);
const FunctionMap getFunctionMap(); const FunctionMap getFunctionMap();
const string builtinHelp();
/** /**
The debugger subsystem responsible for all CPU state The debugger subsystem responsible for all CPU state

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: DebuggerParser.cxx,v 1.71 2005-07-27 01:36:50 urchlay Exp $ // $Id: DebuggerParser.cxx,v 1.72 2005-07-29 16:37:17 urchlay Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -1360,6 +1360,9 @@ void DebuggerParser::executeHelp() {
commandResult += buf; commandResult += buf;
} while(commands[++i].cmdString != ""); } while(commands[++i].cmdString != "");
commandResult += "\nBuilt-in functions:\n";
commandResult += debugger->builtinHelp();
} }
// "frame" // "frame"