From 5b207618c880c11b673491b0834baf49ddab9b58 Mon Sep 17 00:00:00 2001 From: Markus Uhr Date: Mon, 13 Nov 2017 20:39:53 +0100 Subject: [PATCH] Add debugger commands to manipulate controller state. --- src/debugger/DebuggerParser.cxx | 210 ++++++++++++++++++++++++++++++++ src/debugger/DebuggerParser.hxx | 12 +- 2 files changed, 221 insertions(+), 1 deletion(-) diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 357132e7f..8751f14af 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -1161,6 +1161,116 @@ void DebuggerParser::executeHelp() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "joy0up" +void DebuggerParser::executeJoy0Up() +{ + Controller& controller = debugger.riotDebug().controller(Controller::Left); + if(argCount == 0) + controller.set(Controller::One, !controller.read(Controller::One)); + else if(argCount == 1) + controller.set(Controller::One, args[0] != 0); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "joy0down" +void DebuggerParser::executeJoy0Down() +{ + Controller& controller = debugger.riotDebug().controller(Controller::Left); + if(argCount == 0) + controller.set(Controller::Two, !controller.read(Controller::Two)); + else if(argCount == 1) + controller.set(Controller::Two, args[0] != 0); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "joy0left" +void DebuggerParser::executeJoy0Left() +{ + Controller& controller = debugger.riotDebug().controller(Controller::Left); + if(argCount == 0) + controller.set(Controller::Three, !controller.read(Controller::Three)); + else if(argCount == 1) + controller.set(Controller::Three, args[0] != 0); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "joy0right" +void DebuggerParser::executeJoy0Right() +{ + Controller& controller = debugger.riotDebug().controller(Controller::Left); + if(argCount == 0) + controller.set(Controller::Four, !controller.read(Controller::Four)); + else if(argCount == 1) + controller.set(Controller::Four, args[0] != 0); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "joy0fire" +void DebuggerParser::executeJoy0Fire() +{ + Controller& controller = debugger.riotDebug().controller(Controller::Left); + if(argCount == 0) + controller.set(Controller::Six, !controller.read(Controller::Six)); + else if(argCount == 1) + controller.set(Controller::Six, args[0] != 0); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "joy1up" +void DebuggerParser::executeJoy1Up() +{ + Controller& controller = debugger.riotDebug().controller(Controller::Right); + if(argCount == 0) + controller.set(Controller::One, !controller.read(Controller::One)); + else if(argCount == 1) + controller.set(Controller::One, args[0] != 0); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "joy1down" +void DebuggerParser::executeJoy1Down() +{ + Controller& controller = debugger.riotDebug().controller(Controller::Right); + if(argCount == 0) + controller.set(Controller::Two, !controller.read(Controller::Two)); + else if(argCount == 1) + controller.set(Controller::Two, args[0] != 0); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "joy1left" +void DebuggerParser::executeJoy1Left() +{ + Controller& controller = debugger.riotDebug().controller(Controller::Right); + if(argCount == 0) + controller.set(Controller::Three, !controller.read(Controller::Three)); + else if(argCount == 1) + controller.set(Controller::Three, args[0] != 0); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "joy1right" +void DebuggerParser::executeJoy1Right() +{ + Controller& controller = debugger.riotDebug().controller(Controller::Right); + if(argCount == 0) + controller.set(Controller::Four, !controller.read(Controller::Four)); + else if(argCount == 1) + controller.set(Controller::Four, args[0] != 0); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "joy1fire" +void DebuggerParser::executeJoy1Fire() +{ + Controller& controller = debugger.riotDebug().controller(Controller::Right); + if(argCount == 0) + controller.set(Controller::Six, !controller.read(Controller::Six)); + else if(argCount == 1) + controller.set(Controller::Six, args[0] != 0); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "jump" void DebuggerParser::executeJump() @@ -2305,6 +2415,106 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { std::mem_fn(&DebuggerParser::executeHelp) }, + { + "joy0up", + "Set joystick 0 up direction to value (0 or 1), or toggle (no arg)", + "Example: joy0up 0", + false, + true, + { kARG_BOOL, kARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeJoy0Up) + }, + + { + "joy0down", + "Set joystick 0 down direction to value (0 or 1), or toggle (no arg)", + "Example: joy0down 0", + false, + true, + { kARG_BOOL, kARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeJoy0Down) + }, + + { + "joy0left", + "Set joystick 0 left direction to value (0 or 1), or toggle (no arg)", + "Example: joy0left 0", + false, + true, + { kARG_BOOL, kARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeJoy0Left) + }, + + { + "joy0right", + "Set joystick 0 right direction to value (0 or 1), or toggle (no arg)", + "Example: joy0left 0", + false, + true, + { kARG_BOOL, kARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeJoy0Right) + }, + + { + "joy0fire", + "Set joystick 0 fire button to value (0 or 1), or toggle (no arg)", + "Example: joy0fire 0", + false, + true, + { kARG_BOOL, kARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeJoy0Fire) + }, + + { + "joy1up", + "Set joystick 1 up direction to value (0 or 1), or toggle (no arg)", + "Example: joy1up 0", + false, + true, + { kARG_BOOL, kARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeJoy1Up) + }, + + { + "joy1down", + "Set joystick 1 down direction to value (0 or 1), or toggle (no arg)", + "Example: joy1down 0", + false, + true, + { kARG_BOOL, kARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeJoy1Down) + }, + + { + "joy1left", + "Set joystick 1 left direction to value (0 or 1), or toggle (no arg)", + "Example: joy1left 0", + false, + true, + { kARG_BOOL, kARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeJoy1Left) + }, + + { + "joy1right", + "Set joystick 1 right direction to value (0 or 1), or toggle (no arg)", + "Example: joy1left 0", + false, + true, + { kARG_BOOL, kARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeJoy1Right) + }, + + { + "joy1fire", + "Set joystick 1 fire button to value (0 or 1), or toggle (no arg)", + "Example: joy1fire 0", + false, + true, + { kARG_BOOL, kARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeJoy1Fire) + }, + { "jump", "Scroll disassembly to address xx", diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index b804ace65..3f1706b9d 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -66,7 +66,7 @@ class DebuggerParser string saveScriptFile(string file); private: - enum { kNumCommands = 81 }; + enum { kNumCommands = 91 }; // Constants for argument processing enum { @@ -165,6 +165,16 @@ class DebuggerParser void executeFunction(); void executeGfx(); void executeHelp(); + void executeJoy0Up(); + void executeJoy0Down(); + void executeJoy0Left(); + void executeJoy0Right(); + void executeJoy0Fire(); + void executeJoy1Up(); + void executeJoy1Down(); + void executeJoy1Left(); + void executeJoy1Right(); + void executeJoy1Fire(); void executeJump(); void executeListbreaks(); void executeListconfig();