From 43e96939594d534e28665bac82c86fa837adfd1e Mon Sep 17 00:00:00 2001 From: thrust26 Date: Mon, 2 Oct 2017 14:23:08 +0200 Subject: [PATCH] added 'echo' command to debugger prompt --- src/debugger/DebuggerParser.cxx | 37 ++++++++++++++++++++++++++++++--- src/debugger/DebuggerParser.hxx | 4 +++- src/emucore/SaveKey.cxx | 4 ++-- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 329ebaf32..20ad001a2 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -427,6 +427,14 @@ bool DebuggerParser::validateArgs(int cmd) switch(*p) { + case kARG_DWORD: + if(curArgInt > 0xffffffff) + { + commandResult.str(red("invalid word argument (must be 0-$ffffffff)")); + return false; + } + break; + case kARG_WORD: if(curArgInt > 0xffff) { @@ -925,6 +933,20 @@ void DebuggerParser::executeDump() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "echo" +void DebuggerParser::executeEcho() +{ + int res = YaccParser::parse(argStrings[0].c_str()); + if(res == 0) + { + unique_ptr expr(YaccParser::getResult()); + commandResult << expr->evaluate(); + } + else + commandResult << red("invalid expression"); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "exec" void DebuggerParser::executeExec() @@ -1688,7 +1710,6 @@ void DebuggerParser::executeZ() debugger.cpuDebug().setZ(args[0]); } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // List of all commands available to the parser DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { @@ -1907,7 +1928,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { { "dump", "Dump data at address [to yy]", - "Examples:\n" + "Example:\n" " dump f000 - dumps 128 bytes @ f000\n" " dump f000 f0ff - dumps all bytes from f000 to f0ff", true, @@ -1916,6 +1937,16 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { std::mem_fn(&DebuggerParser::executeDump) }, + { + "echo", + "Echo expression result", + "Example: echo _fycles, echo _scan*#76, echo _bank==1", + false, + true, + { kARG_DWORD, kARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeEcho) + }, + { "exec", "Execute script file ", @@ -1949,7 +1980,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { { "function", "Define function name xx for expression yy", - "Example: define FUNC1 { ... }", + "Example: function FUNC1 { ... }", true, false, { kARG_LABEL, kARG_WORD, kARG_END_ARGS }, diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index f4737487e..154988db2 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -68,7 +68,7 @@ class DebuggerParser bool saveScriptFile(string file); private: - enum { kNumCommands = 72 }; + enum { kNumCommands = 73 }; // Constants for argument processing enum { @@ -80,6 +80,7 @@ class DebuggerParser enum parameters { kARG_WORD, // single 16-bit value + kARG_DWORD, // single 32-bit value kARG_MULTI_WORD, // multiple 16-bit values (must occur last) kARG_BYTE, // single 8-bit value kARG_MULTI_BYTE, // multiple 8-bit values (must occur last) @@ -143,6 +144,7 @@ class DebuggerParser void executeDelwatch(); void executeDisasm(); void executeDump(); + void executeEcho(); void executeExec(); void executeExitRom(); void executeFrame(); diff --git a/src/emucore/SaveKey.cxx b/src/emucore/SaveKey.cxx index 725737ca8..ac67e6760 100644 --- a/src/emucore/SaveKey.cxx +++ b/src/emucore/SaveKey.cxx @@ -26,7 +26,7 @@ SaveKey::SaveKey(Jack jack, const Event& event, const System& system, { myEEPROM = make_unique(eepromfile, system); - myDigitalPinState[One] = myDigitalPinState[Two] = true; + myDigitalPinState[One] = myDigitalPinState[Two] = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -44,7 +44,7 @@ bool SaveKey::read(DigitalPin pin) default: return Controller::read(pin); - } + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -