Refactor library command functions to dedicated namespace
This commit is contained in:
parent
6256506884
commit
0cf09e958d
29 changed files with 176 additions and 170 deletions
|
@ -4,9 +4,9 @@
|
|||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include "library/commands.hpp"
|
||||
#include "library/command.hpp"
|
||||
|
||||
extern command_group lsnes_cmd;
|
||||
extern command::group lsnes_cmd;
|
||||
|
||||
void refresh_alias_binds();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _library_commands__hpp__included__
|
||||
#define _library_commands__hpp__included__
|
||||
#ifndef _library_command__hpp__included__
|
||||
#define _library_command__hpp__included__
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
@ -8,22 +8,24 @@
|
|||
#include <list>
|
||||
#include "threadtypes.hpp"
|
||||
|
||||
class command;
|
||||
namespace command
|
||||
{
|
||||
class base;
|
||||
|
||||
/**
|
||||
* A group of commands (with aliases).
|
||||
*/
|
||||
class command_group
|
||||
class group
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Create a new command group. This also places some builtin commands in that new group.
|
||||
*/
|
||||
command_group() throw(std::bad_alloc);
|
||||
group() throw(std::bad_alloc);
|
||||
/**
|
||||
* Destroy a group.
|
||||
*/
|
||||
~command_group() throw();
|
||||
~group() throw();
|
||||
/**
|
||||
* Look up and invoke a command. The command will undergo alias expansion and recursion checking.
|
||||
*
|
||||
|
@ -49,7 +51,7 @@ public:
|
|||
/**
|
||||
* Register a command.
|
||||
*/
|
||||
void do_register(const std::string& name, command& cmd) throw(std::bad_alloc);
|
||||
void do_register(const std::string& name, base& cmd) throw(std::bad_alloc);
|
||||
/**
|
||||
* Unregister a command.
|
||||
*/
|
||||
|
@ -63,19 +65,19 @@ public:
|
|||
*/
|
||||
void set_oom_panic(void (*fn)());
|
||||
private:
|
||||
std::map<std::string, command*> commands;
|
||||
std::map<std::string, base*> commands;
|
||||
std::set<std::string> command_stack;
|
||||
std::map<std::string, std::list<std::string>> aliases;
|
||||
mutex_class int_mutex;
|
||||
std::ostream* output;
|
||||
void (*oom_panic_routine)();
|
||||
command* builtin[1];
|
||||
base* builtin[1];
|
||||
};
|
||||
|
||||
/**
|
||||
* A command.
|
||||
*/
|
||||
class command
|
||||
class base
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -85,12 +87,12 @@ public:
|
|||
* parameter cmd: The command to register.
|
||||
* throws std::bad_alloc: Not enough memory.
|
||||
*/
|
||||
command(command_group& group, const std::string& cmd) throw(std::bad_alloc);
|
||||
base(group& group, const std::string& cmd) throw(std::bad_alloc);
|
||||
|
||||
/**
|
||||
* Deregister a command.
|
||||
*/
|
||||
virtual ~command() throw();
|
||||
virtual ~base() throw();
|
||||
|
||||
/**
|
||||
* Invoke a command.
|
||||
|
@ -114,10 +116,10 @@ public:
|
|||
*/
|
||||
const std::string& get_name() { return commandname; }
|
||||
private:
|
||||
command(const command&);
|
||||
command& operator=(const command&);
|
||||
base(const base&);
|
||||
base& operator=(const base&);
|
||||
std::string commandname;
|
||||
command_group& in_group;
|
||||
group& in_group;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -144,13 +146,13 @@ struct arg_filename
|
|||
* parameter a: The arguments to pass.
|
||||
*/
|
||||
template<typename... args>
|
||||
void invoke_command_fn(void (*fn)(args... arguments), const std::string& a);
|
||||
void invoke_fn(void (*fn)(args... arguments), const std::string& a);
|
||||
|
||||
/**
|
||||
* Warp function pointer as command.
|
||||
*/
|
||||
template<typename... args>
|
||||
class function_ptr_command : public command
|
||||
class fnptr : public base
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -162,9 +164,9 @@ public:
|
|||
* parameter help: Help for the command.
|
||||
* parameter fn: Function to call on command.
|
||||
*/
|
||||
function_ptr_command(command_group& group, const std::string& name, const std::string& _description,
|
||||
fnptr(group& group, const std::string& name, const std::string& _description,
|
||||
const std::string& _help, void (*_fn)(args... arguments)) throw(std::bad_alloc)
|
||||
: command(group, name)
|
||||
: base(group, name)
|
||||
{
|
||||
description = _description;
|
||||
help = _help;
|
||||
|
@ -173,7 +175,7 @@ public:
|
|||
/**
|
||||
* Destroy a commnad.
|
||||
*/
|
||||
~function_ptr_command() throw()
|
||||
~fnptr() throw()
|
||||
{
|
||||
}
|
||||
/**
|
||||
|
@ -183,7 +185,7 @@ public:
|
|||
*/
|
||||
void invoke(const std::string& a) throw(std::bad_alloc, std::runtime_error)
|
||||
{
|
||||
invoke_command_fn(fn, a);
|
||||
invoke_fn(fn, a);
|
||||
}
|
||||
/**
|
||||
* Get short description.
|
||||
|
@ -210,5 +212,6 @@ private:
|
|||
std::string description;
|
||||
std::string help;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -2,7 +2,7 @@
|
|||
#define _library__keyboard_cmd_bridge__hpp__
|
||||
|
||||
#include "keyboard.hpp"
|
||||
#include "commands.hpp"
|
||||
#include "command.hpp"
|
||||
|
||||
class inverse_bind;
|
||||
|
||||
|
@ -15,7 +15,7 @@ public:
|
|||
/**
|
||||
* Create a bridge.
|
||||
*/
|
||||
keyboard_command_bridge(keyboard& kgroup, command_group& cgroup);
|
||||
keyboard_command_bridge(keyboard& kgroup, command::group& cgroup);
|
||||
/**
|
||||
* Destroy a bridge.
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _library__keymapper__hpp__included__
|
||||
#define _library__keymapper__hpp__included__
|
||||
|
||||
#include "commands.hpp"
|
||||
#include "command.hpp"
|
||||
#include <set>
|
||||
#include <list>
|
||||
#include <stdexcept>
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
/**
|
||||
* Create new keyboard mapper.
|
||||
*/
|
||||
keyboard_mapper(keyboard& kbd, command_group& domain) throw(std::bad_alloc);
|
||||
keyboard_mapper(keyboard& kbd, command::group& domain) throw(std::bad_alloc);
|
||||
/**
|
||||
* Destroy a keyboard mapper.
|
||||
*/
|
||||
|
@ -206,7 +206,7 @@ public:
|
|||
/**
|
||||
* Get command group to run commands in..
|
||||
*/
|
||||
command_group& get_command_group() throw();
|
||||
command::group& get_command_group() throw();
|
||||
/**
|
||||
* Fixup command based on polarity.
|
||||
*
|
||||
|
@ -244,7 +244,7 @@ private:
|
|||
std::map<triplet, std::string> bindings;
|
||||
std::set<keyboard_key*> listening;
|
||||
keyboard& kbd;
|
||||
command_group& domain;
|
||||
command::group& domain;
|
||||
mutex_class mutex;
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
function_ptr_command<const std::string&> action(lsnes_cmd, "action", "Execute core action",
|
||||
command::fnptr<const std::string&> action(lsnes_cmd, "action", "Execute core action",
|
||||
"Syntax: action <name> [<params>...]\nExecutes core action.\n",
|
||||
[](const std::string& _args) throw(std::bad_alloc, std::runtime_error) {
|
||||
if(_args == "") {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <set>
|
||||
#include <map>
|
||||
|
||||
command_group lsnes_cmd;
|
||||
command::group lsnes_cmd;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
|
|
@ -436,73 +436,73 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
function_ptr_command<const std::string&> button_p(lsnes_cmd, "+controller", "Press a button",
|
||||
command::fnptr<const std::string&> button_p(lsnes_cmd, "+controller", "Press a button",
|
||||
"Syntax: +controller<button>...\nPress a button\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
do_action(a, 1, 0);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> button_r(lsnes_cmd, "-controller", "Release a button",
|
||||
command::fnptr<const std::string&> button_r(lsnes_cmd, "-controller", "Release a button",
|
||||
"Syntax: -controller<button>...\nRelease a button\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
do_action(a, 0, 0);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> button_h(lsnes_cmd, "hold-controller", "Autohold a button",
|
||||
command::fnptr<const std::string&> button_h(lsnes_cmd, "hold-controller", "Autohold a button",
|
||||
"Syntax: hold-controller<button>...\nAutohold a button\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
do_action(a, 1, 1);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> button_t(lsnes_cmd, "type-controller", "Type a button",
|
||||
command::fnptr<const std::string&> button_t(lsnes_cmd, "type-controller", "Type a button",
|
||||
"Syntax: type-controller<button>...\nType a button\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
do_action(a, 1, 2);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> button_d(lsnes_cmd, "designate-position", "Set postion",
|
||||
command::fnptr<const std::string&> button_d(lsnes_cmd, "designate-position", "Set postion",
|
||||
"Syntax: designate-position <button>...\nDesignate position for an axis\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
do_action(a, 0, 3);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> button_ap(lsnes_cmd, "+autofire-controller", "Start autofire",
|
||||
command::fnptr<const std::string&> button_ap(lsnes_cmd, "+autofire-controller", "Start autofire",
|
||||
"Syntax: +autofire-controller<button> [[<duty> ]<cyclelen>]...\nAutofire a button\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
do_autofire_action(a, 1);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> button_an(lsnes_cmd, "-autofire-controller", "End autofire",
|
||||
command::fnptr<const std::string&> button_an(lsnes_cmd, "-autofire-controller", "End autofire",
|
||||
"Syntax: -autofire-controller<button> [[<duty> ]<cyclelen>]...\nEnd Autofire on a button\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
do_autofire_action(a, 0);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> button_at(lsnes_cmd, "autofire-controller", "Toggle autofire",
|
||||
command::fnptr<const std::string&> button_at(lsnes_cmd, "autofire-controller", "Toggle autofire",
|
||||
"Syntax: autofire-controller<button> [[<duty> ]<cyclelen>]...\nToggle Autofire on a button\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
do_autofire_action(a, -1);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> button_a(lsnes_cmd, "controller-analog", "Analog action",
|
||||
command::fnptr<const std::string&> button_a(lsnes_cmd, "controller-analog", "Analog action",
|
||||
"Syntax: controller-analog <button> <axis>\nAnalog action\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
do_analog_action(a);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> macro_t(lsnes_cmd, "macro", "Toggle a macro",
|
||||
command::fnptr<const std::string&> macro_t(lsnes_cmd, "macro", "Toggle a macro",
|
||||
"Syntax: macro <macroname>\nToggle a macro.\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
controls.do_macro(a, 7);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> macro_e(lsnes_cmd, "+macro", "Enable a macro",
|
||||
command::fnptr<const std::string&> macro_e(lsnes_cmd, "+macro", "Enable a macro",
|
||||
"Syntax: +macro <macroname>\nEnable a macro.\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
controls.do_macro(a, 5);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> macro_d(lsnes_cmd, "-macro", "Disable a macro",
|
||||
command::fnptr<const std::string&> macro_d(lsnes_cmd, "-macro", "Disable a macro",
|
||||
"Syntax: -macro <macroname>\nDisable a macro.\n",
|
||||
[](const std::string& a) throw(std::bad_alloc, std::runtime_error) {
|
||||
controls.do_macro(a, 2);
|
||||
|
|
|
@ -254,7 +254,7 @@ void debug_core_change()
|
|||
|
||||
namespace
|
||||
{
|
||||
function_ptr_command<> callbacks_show(lsnes_cmd, "show-callbacks", "", "",
|
||||
command::fnptr<> callbacks_show(lsnes_cmd, "show-callbacks", "", "",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
for(auto& i : read_cb)
|
||||
for(auto& j : i.second)
|
||||
|
@ -270,7 +270,7 @@ namespace
|
|||
messages << "TRACE proc=" << i.first << " handle=" << &j << std::endl;
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> generate_event(lsnes_cmd, "generate-memory-event", "", "",
|
||||
command::fnptr<const std::string&> generate_event(lsnes_cmd, "generate-memory-event", "", "",
|
||||
[](const std::string& args) throw(std::bad_alloc, std::runtime_error) {
|
||||
regex_results r = regex("([^ \t]+) ([^ \t]+) (.+)", args);
|
||||
if(!r) throw std::runtime_error("generate-memory-event: Bad arguments");
|
||||
|
@ -294,7 +294,7 @@ namespace
|
|||
throw std::runtime_error("Invalid operation");
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> tracelog(lsnes_cmd, "tracelog", "Trace log control",
|
||||
command::fnptr<const std::string&> tracelog(lsnes_cmd, "tracelog", "Trace log control",
|
||||
"Trace log control\nSyntax: tracelog <cpuid> <file> Start tracing\nSyntax: tracelog <cpuid> "
|
||||
"End tracing", [](const std::string& args) throw(std::bad_alloc, std::runtime_error) {
|
||||
regex_results r = regex("([^ \t]+)([ \t]+(.+))?", args);
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace
|
|||
std::string disasm;
|
||||
};
|
||||
|
||||
function_ptr_command<const std::string&> disassemble(lsnes_cmd, "disassemble", "Disassemble code",
|
||||
command::fnptr<const std::string&> disassemble(lsnes_cmd, "disassemble", "Disassemble code",
|
||||
"Syntax: disassemble <kind> <addr> [<count>] [to <filename>]\nDisassemble code\n",
|
||||
[](const std::string& t) throw(std::bad_alloc, std::runtime_error) {
|
||||
regex_results r = regex("([^ \t]+)[ \t]+([0-9]+|0x[0-9A-Fa-f]+)([ \t]+([0-9]+))?"
|
||||
|
|
|
@ -121,9 +121,9 @@ namespace
|
|||
draw_special_screen(target, rl_corrupt);
|
||||
}
|
||||
|
||||
function_ptr_command<arg_filename> take_screenshot_cmd(lsnes_cmd, "take-screenshot", "Takes a screenshot",
|
||||
command::fnptr<command::arg_filename> take_screenshot_cmd(lsnes_cmd, "take-screenshot", "Takes a screenshot",
|
||||
"Syntax: take-screenshot <file>\nSaves screenshot to PNG file <file>\n",
|
||||
[](arg_filename file) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename file) throw(std::bad_alloc, std::runtime_error) {
|
||||
take_screenshot(file);
|
||||
messages << "Saved PNG screenshot" << std::endl;
|
||||
});
|
||||
|
|
|
@ -74,19 +74,19 @@ namespace
|
|||
return std::make_pair(false, n * m);
|
||||
}
|
||||
|
||||
function_ptr_command<> tturbo(lsnes_cmd, "toggle-turbo", "Toggle turbo",
|
||||
command::fnptr<> tturbo(lsnes_cmd, "toggle-turbo", "Toggle turbo",
|
||||
"Syntax: toggle-turbo\nToggle turbo mode.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
turboed = !turboed;
|
||||
});
|
||||
|
||||
function_ptr_command<> pturbo(lsnes_cmd, "+turbo", "Activate turbo",
|
||||
command::fnptr<> pturbo(lsnes_cmd, "+turbo", "Activate turbo",
|
||||
"Syntax: +turbo\nActivate turbo mode.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
turboed = true;
|
||||
});
|
||||
|
||||
function_ptr_command<> nturbo(lsnes_cmd, "-turbo", "Deactivate turbo",
|
||||
command::fnptr<> nturbo(lsnes_cmd, "-turbo", "Deactivate turbo",
|
||||
"Syntax: -turbo\nDeactivate turbo mode.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
turboed = false;
|
||||
|
|
|
@ -1664,12 +1664,12 @@ out:
|
|||
};
|
||||
|
||||
//The tangent function.
|
||||
function_ptr_command<> ptangent(lsnes_cmd, "+tangent", "Voice tangent",
|
||||
command::fnptr<> ptangent(lsnes_cmd, "+tangent", "Voice tangent",
|
||||
"Syntax: +tangent\nVoice tangent.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
active_flag = true;
|
||||
});
|
||||
function_ptr_command<> ntangent(lsnes_cmd, "-tangent", "Voice tangent",
|
||||
command::fnptr<> ntangent(lsnes_cmd, "-tangent", "Voice tangent",
|
||||
"Syntax: -tangent\nVoice tangent.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
active_flag = false;
|
||||
|
|
|
@ -92,7 +92,7 @@ void cleanup_keymapper()
|
|||
|
||||
namespace
|
||||
{
|
||||
function_ptr_command<> show_joysticks(lsnes_cmd, "show-joysticks", "Show joystick info",
|
||||
command::fnptr<> show_joysticks(lsnes_cmd, "show-joysticks", "Show joystick info",
|
||||
"Syntax: show-joysticks\nShow joystick info.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
messages << "--------------------------------------------" << std::endl;
|
||||
|
|
|
@ -521,7 +521,7 @@ public:
|
|||
|
||||
namespace
|
||||
{
|
||||
function_ptr_command<const std::string&> test4(lsnes_cmd, "test4", "test", "test",
|
||||
command::fnptr<const std::string&> test4(lsnes_cmd, "test4", "test", "test",
|
||||
[](const std::string& args) throw(std::bad_alloc, std::runtime_error) {
|
||||
std::list<std::string> _args;
|
||||
std::string args2 = args;
|
||||
|
@ -532,7 +532,7 @@ namespace
|
|||
}
|
||||
lua_callback_do_latch(_args);
|
||||
});
|
||||
function_ptr_command<> count_rerecords(lsnes_cmd, "count-rerecords", "Count rerecords",
|
||||
command::fnptr<> count_rerecords(lsnes_cmd, "count-rerecords", "Count rerecords",
|
||||
"Syntax: count-rerecords\nCounts rerecords.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
std::vector<char> tmp;
|
||||
|
@ -540,7 +540,7 @@ namespace
|
|||
messages << x << " rerecord(s)" << std::endl;
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> quit_emulator(lsnes_cmd, "quit-emulator", "Quit the emulator",
|
||||
command::fnptr<const std::string&> quit_emulator(lsnes_cmd, "quit-emulator", "Quit the emulator",
|
||||
"Syntax: quit-emulator [/y]\nQuits emulator (/y => don't ask for confirmation).\n",
|
||||
[](const std::string& args) throw(std::bad_alloc, std::runtime_error) {
|
||||
amode = ADVANCE_QUIT;
|
||||
|
@ -548,7 +548,7 @@ namespace
|
|||
platform::cancel_wait();
|
||||
});
|
||||
|
||||
function_ptr_command<> unpause_emulator(lsnes_cmd, "unpause-emulator", "Unpause the emulator",
|
||||
command::fnptr<> unpause_emulator(lsnes_cmd, "unpause-emulator", "Unpause the emulator",
|
||||
"Syntax: unpause-emulator\nUnpauses the emulator.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
amode = ADVANCE_AUTO;
|
||||
|
@ -557,7 +557,7 @@ namespace
|
|||
messages << "Unpaused" << std::endl;
|
||||
});
|
||||
|
||||
function_ptr_command<> pause_emulator(lsnes_cmd, "pause-emulator", "(Un)pause the emulator",
|
||||
command::fnptr<> pause_emulator(lsnes_cmd, "pause-emulator", "(Un)pause the emulator",
|
||||
"Syntax: pause-emulator\n(Un)pauses the emulator.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
if(amode != ADVANCE_AUTO) {
|
||||
|
@ -574,7 +574,7 @@ namespace
|
|||
}
|
||||
});
|
||||
|
||||
function_ptr_command<> save_jukebox_prev(lsnes_cmd, "cycle-jukebox-backward", "Cycle save jukebox backwards",
|
||||
command::fnptr<> save_jukebox_prev(lsnes_cmd, "cycle-jukebox-backward", "Cycle save jukebox backwards",
|
||||
"Syntax: cycle-jukebox-backward\nCycle save jukebox backwards\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
if(jukebox_size == 0)
|
||||
|
@ -588,7 +588,7 @@ namespace
|
|||
update_movie_state();
|
||||
});
|
||||
|
||||
function_ptr_command<> save_jukebox_next(lsnes_cmd, "cycle-jukebox-forward", "Cycle save jukebox forwards",
|
||||
command::fnptr<> save_jukebox_next(lsnes_cmd, "cycle-jukebox-forward", "Cycle save jukebox forwards",
|
||||
"Syntax: cycle-jukebox-forward\nCycle save jukebox forwards\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
if(jukebox_size == 0)
|
||||
|
@ -602,7 +602,7 @@ namespace
|
|||
update_movie_state();
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> save_jukebox_set(lsnes_cmd, "set-jukebox-slot", "Set jukebox slot",
|
||||
command::fnptr<const std::string&> save_jukebox_set(lsnes_cmd, "set-jukebox-slot", "Set jukebox slot",
|
||||
"Syntax: set-jukebox-slot\nSet jukebox slot\n", [](const std::string& args)
|
||||
throw(std::bad_alloc, std::runtime_error) {
|
||||
if(!regex_match("[1-9][0-9]{0,8}", args))
|
||||
|
@ -614,7 +614,7 @@ namespace
|
|||
update_movie_state();
|
||||
});
|
||||
|
||||
function_ptr_command<> load_jukebox(lsnes_cmd, "load-jukebox", "Load save from jukebox",
|
||||
command::fnptr<> load_jukebox(lsnes_cmd, "load-jukebox", "Load save from jukebox",
|
||||
"Syntax: load-jukebox\nLoad save from jukebox\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
if(jukebox_size == 0)
|
||||
|
@ -622,7 +622,7 @@ namespace
|
|||
mark_pending_load(save_jukebox_name(save_jukebox_pointer), LOAD_STATE_CURRENT);
|
||||
});
|
||||
|
||||
function_ptr_command<> load_jukebox_readwrite(lsnes_cmd, "load-jukebox-readwrite", "Load save from jukebox in"
|
||||
command::fnptr<> load_jukebox_readwrite(lsnes_cmd, "load-jukebox-readwrite", "Load save from jukebox in"
|
||||
" read-write mode", "Syntax: load-jukebox-readwrite\nLoad save from jukebox in read-write mode\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
if(jukebox_size == 0)
|
||||
|
@ -630,7 +630,7 @@ namespace
|
|||
mark_pending_load(save_jukebox_name(save_jukebox_pointer), LOAD_STATE_RW);
|
||||
});
|
||||
|
||||
function_ptr_command<> load_jukebox_readonly(lsnes_cmd, "load-jukebox-readonly", "Load save from jukebox in "
|
||||
command::fnptr<> load_jukebox_readonly(lsnes_cmd, "load-jukebox-readonly", "Load save from jukebox in "
|
||||
"read-only mode", "Syntax: load-jukebox-readonly\nLoad save from jukebox in read-only mode\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
if(jukebox_size == 0)
|
||||
|
@ -638,7 +638,7 @@ namespace
|
|||
mark_pending_load(save_jukebox_name(save_jukebox_pointer), LOAD_STATE_RO);
|
||||
});
|
||||
|
||||
function_ptr_command<> load_jukebox_preserve(lsnes_cmd, "load-jukebox-preserve", "Load save from jukebox, "
|
||||
command::fnptr<> load_jukebox_preserve(lsnes_cmd, "load-jukebox-preserve", "Load save from jukebox, "
|
||||
"preserving input", "Syntax: load-jukebox-preserve\nLoad save from jukebox, preserving input\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
if(jukebox_size == 0)
|
||||
|
@ -646,7 +646,7 @@ namespace
|
|||
mark_pending_load(save_jukebox_name(save_jukebox_pointer), LOAD_STATE_PRESERVE);
|
||||
});
|
||||
|
||||
function_ptr_command<> load_jukebox_movie(lsnes_cmd, "load-jukebox-movie", "Load save from jukebox as movie",
|
||||
command::fnptr<> load_jukebox_movie(lsnes_cmd, "load-jukebox-movie", "Load save from jukebox as movie",
|
||||
"Syntax: load-jukebox-movie\nLoad save from jukebox as movie\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
if(jukebox_size == 0)
|
||||
|
@ -654,7 +654,7 @@ namespace
|
|||
mark_pending_load(save_jukebox_name(save_jukebox_pointer), LOAD_STATE_MOVIE);
|
||||
});
|
||||
|
||||
function_ptr_command<> save_jukebox_c(lsnes_cmd, "save-jukebox", "Save save to jukebox",
|
||||
command::fnptr<> save_jukebox_c(lsnes_cmd, "save-jukebox", "Save save to jukebox",
|
||||
"Syntax: save-jukebox\nSave save to jukebox\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
if(jukebox_size == 0)
|
||||
|
@ -662,7 +662,7 @@ namespace
|
|||
mark_pending_save(save_jukebox_name(save_jukebox_pointer), SAVE_STATE, -1);
|
||||
});
|
||||
|
||||
function_ptr_command<> padvance_frame(lsnes_cmd, "+advance-frame", "Advance one frame",
|
||||
command::fnptr<> padvance_frame(lsnes_cmd, "+advance-frame", "Advance one frame",
|
||||
"Syntax: +advance-frame\nAdvances the emulation by one frame.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
amode = ADVANCE_FRAME;
|
||||
|
@ -672,7 +672,7 @@ namespace
|
|||
platform::set_paused(false);
|
||||
});
|
||||
|
||||
function_ptr_command<> nadvance_frame(lsnes_cmd, "-advance-frame", "Advance one frame",
|
||||
command::fnptr<> nadvance_frame(lsnes_cmd, "-advance-frame", "Advance one frame",
|
||||
"No help available\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
cancel_advance = true;
|
||||
|
@ -680,7 +680,7 @@ namespace
|
|||
platform::set_paused(false);
|
||||
});
|
||||
|
||||
function_ptr_command<> padvance_poll(lsnes_cmd, "+advance-poll", "Advance one subframe",
|
||||
command::fnptr<> padvance_poll(lsnes_cmd, "+advance-poll", "Advance one subframe",
|
||||
"Syntax: +advance-poll\nAdvances the emulation by one subframe.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
amode = ADVANCE_SUBFRAME;
|
||||
|
@ -690,7 +690,7 @@ namespace
|
|||
platform::set_paused(false);
|
||||
});
|
||||
|
||||
function_ptr_command<> nadvance_poll(lsnes_cmd, "-advance-poll", "Advance one subframe",
|
||||
command::fnptr<> nadvance_poll(lsnes_cmd, "-advance-poll", "Advance one subframe",
|
||||
"No help available\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
cancel_advance = true;
|
||||
|
@ -698,7 +698,7 @@ namespace
|
|||
platform::set_paused(false);
|
||||
});
|
||||
|
||||
function_ptr_command<> advance_skiplag(lsnes_cmd, "advance-skiplag", "Skip to next poll",
|
||||
command::fnptr<> advance_skiplag(lsnes_cmd, "advance-skiplag", "Skip to next poll",
|
||||
"Syntax: advance-skiplag\nAdvances the emulation to the next poll.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
amode = ADVANCE_SKIPLAG_PENDING;
|
||||
|
@ -706,7 +706,7 @@ namespace
|
|||
platform::set_paused(false);
|
||||
});
|
||||
|
||||
function_ptr_command<> reset_c(lsnes_cmd, "reset", "Reset the system",
|
||||
command::fnptr<> reset_c(lsnes_cmd, "reset", "Reset the system",
|
||||
"Syntax: reset\nReset\nResets the system in beginning of the next frame.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
int sreset_action = our_rom.rtype->reset_action(false);
|
||||
|
@ -718,7 +718,7 @@ namespace
|
|||
our_rom.rtype->execute_action(sreset_action, std::vector<interface_action_paramval>());
|
||||
});
|
||||
|
||||
function_ptr_command<> hreset_c(lsnes_cmd, "reset-hard", "Reset the system",
|
||||
command::fnptr<> hreset_c(lsnes_cmd, "reset-hard", "Reset the system",
|
||||
"Syntax: reset-hard\nReset-hard\nHard resets the system in beginning of the next frame.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
int hreset_action = our_rom.rtype->reset_action(true);
|
||||
|
@ -730,80 +730,80 @@ namespace
|
|||
our_rom.rtype->execute_action(hreset_action, std::vector<interface_action_paramval>());
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> load_c(lsnes_cmd, "load", "Load savestate (current mode)",
|
||||
command::fnptr<command::arg_filename> load_c(lsnes_cmd, "load", "Load savestate (current mode)",
|
||||
"Syntax: load <file>\nLoads SNES state from <file> in current mode\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_load(args, LOAD_STATE_CURRENT);
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> load_smart_c(lsnes_cmd, "load-smart", "Load savestate (heuristic mode)",
|
||||
command::fnptr<command::arg_filename> load_smart_c(lsnes_cmd, "load-smart", "Load savestate (heuristic mode)",
|
||||
"Syntax: load <file>\nLoads SNES state from <file> in heuristic mode\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_load(args, LOAD_STATE_DEFAULT);
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> load_state_c(lsnes_cmd, "load-state", "Load savestate (R/W)",
|
||||
command::fnptr<command::arg_filename> load_state_c(lsnes_cmd, "load-state", "Load savestate (R/W)",
|
||||
"Syntax: load-state <file>\nLoads SNES state from <file> in Read/Write mode\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_load(args, LOAD_STATE_RW);
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> load_readonly(lsnes_cmd, "load-readonly", "Load savestate (RO)",
|
||||
command::fnptr<command::arg_filename> load_readonly(lsnes_cmd, "load-readonly", "Load savestate (RO)",
|
||||
"Syntax: load-readonly <file>\nLoads SNES state from <file> in read-only mode\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_load(args, LOAD_STATE_RO);
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> load_preserve(lsnes_cmd, "load-preserve", "Load savestate (preserve "
|
||||
command::fnptr<command::arg_filename> load_preserve(lsnes_cmd, "load-preserve", "Load savestate (preserve "
|
||||
"input)", "Syntax: load-preserve <file>\nLoads SNES state from <file> preserving input\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_load(args, LOAD_STATE_PRESERVE);
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> load_movie_c(lsnes_cmd, "load-movie", "Load movie",
|
||||
command::fnptr<command::arg_filename> load_movie_c(lsnes_cmd, "load-movie", "Load movie",
|
||||
"Syntax: load-movie <file>\nLoads SNES movie from <file>\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_load(args, LOAD_STATE_MOVIE);
|
||||
});
|
||||
|
||||
|
||||
function_ptr_command<arg_filename> save_state(lsnes_cmd, "save-state", "Save state",
|
||||
command::fnptr<command::arg_filename> save_state(lsnes_cmd, "save-state", "Save state",
|
||||
"Syntax: save-state <file>\nSaves SNES state to <file>\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_save(args, SAVE_STATE, -1);
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> save_state2(lsnes_cmd, "save-state-binary", "Save state (binary)",
|
||||
command::fnptr<command::arg_filename> save_state2(lsnes_cmd, "save-state-binary", "Save state (binary)",
|
||||
"Syntax: save-state-binary <file>\nSaves binary state to <file>\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_save(args, SAVE_STATE, 1);
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> save_state3(lsnes_cmd, "save-state-zip", "Save state (zip)",
|
||||
command::fnptr<command::arg_filename> save_state3(lsnes_cmd, "save-state-zip", "Save state (zip)",
|
||||
"Syntax: save-state-zip <file>\nSaves zip state to <file>\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_save(args, SAVE_STATE, 0);
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> save_movie(lsnes_cmd, "save-movie", "Save movie",
|
||||
command::fnptr<command::arg_filename> save_movie(lsnes_cmd, "save-movie", "Save movie",
|
||||
"Syntax: save-movie <file>\nSaves SNES movie to <file>\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_save(args, SAVE_MOVIE, -1);
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> save_movie2(lsnes_cmd, "save-movie-binary", "Save movie (binary)",
|
||||
command::fnptr<command::arg_filename> save_movie2(lsnes_cmd, "save-movie-binary", "Save movie (binary)",
|
||||
"Syntax: save-movie-binary <file>\nSaves binary movie to <file>\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_save(args, SAVE_MOVIE, 1);
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> save_movie3(lsnes_cmd, "save-movie-zip", "Save movie (zip)",
|
||||
command::fnptr<command::arg_filename> save_movie3(lsnes_cmd, "save-movie-zip", "Save movie (zip)",
|
||||
"Syntax: save-movie-zip <file>\nSaves zip movie to <file>\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_save(args, SAVE_MOVIE, 0);
|
||||
});
|
||||
|
||||
function_ptr_command<> set_rwmode(lsnes_cmd, "set-rwmode", "Switch to read/write mode",
|
||||
command::fnptr<> set_rwmode(lsnes_cmd, "set-rwmode", "Switch to read/write mode",
|
||||
"Syntax: set-rwmode\nSwitches to read/write mode\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
lua_callback_movie_lost("readwrite");
|
||||
|
@ -813,7 +813,7 @@ namespace
|
|||
update_movie_state();
|
||||
});
|
||||
|
||||
function_ptr_command<> set_romode(lsnes_cmd, "set-romode", "Switch to read-only mode",
|
||||
command::fnptr<> set_romode(lsnes_cmd, "set-romode", "Switch to read-only mode",
|
||||
"Syntax: set-romode\nSwitches to read-only mode\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
movb.get_movie().readonly_mode(true);
|
||||
|
@ -821,7 +821,7 @@ namespace
|
|||
update_movie_state();
|
||||
});
|
||||
|
||||
function_ptr_command<> toggle_rwmode(lsnes_cmd, "toggle-rwmode", "Toggle read/write mode",
|
||||
command::fnptr<> toggle_rwmode(lsnes_cmd, "toggle-rwmode", "Toggle read/write mode",
|
||||
"Syntax: toggle-rwmode\nToggles read/write mode\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
bool c = movb.get_movie().readonly_mode();
|
||||
|
@ -834,61 +834,61 @@ namespace
|
|||
update_movie_state();
|
||||
});
|
||||
|
||||
function_ptr_command<> repaint(lsnes_cmd, "repaint", "Redraw the screen",
|
||||
command::fnptr<> repaint(lsnes_cmd, "repaint", "Redraw the screen",
|
||||
"Syntax: repaint\nRedraws the screen\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
redraw_framebuffer();
|
||||
});
|
||||
|
||||
function_ptr_command<> tpon(lsnes_cmd, "toggle-pause-on-end", "Toggle pause on end", "Toggle pause on end\n",
|
||||
command::fnptr<> tpon(lsnes_cmd, "toggle-pause-on-end", "Toggle pause on end", "Toggle pause on end\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
bool tmp = pause_on_end;
|
||||
pause_on_end.set(!tmp);
|
||||
messages << "Pause-on-end is now " << (tmp ? "OFF" : "ON") << std::endl;
|
||||
});
|
||||
|
||||
function_ptr_command<> spon(lsnes_cmd, "set-pause-on-end", "Set pause on end", "Set pause on end\n",
|
||||
command::fnptr<> spon(lsnes_cmd, "set-pause-on-end", "Set pause on end", "Set pause on end\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
pause_on_end.set(true);
|
||||
messages << "Pause-on-end is now ON" << std::endl;
|
||||
});
|
||||
|
||||
function_ptr_command<> cpon(lsnes_cmd, "clear-pause-on-end", "Clear pause on end", "Clear pause on end\n",
|
||||
command::fnptr<> cpon(lsnes_cmd, "clear-pause-on-end", "Clear pause on end", "Clear pause on end\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
pause_on_end.set(false);
|
||||
messages << "Pause-on-end is now OFF" << std::endl;
|
||||
});
|
||||
|
||||
function_ptr_command<> rewind_movie(lsnes_cmd, "rewind-movie", "Rewind movie to the beginning",
|
||||
command::fnptr<> rewind_movie(lsnes_cmd, "rewind-movie", "Rewind movie to the beginning",
|
||||
"Syntax: rewind-movie\nRewind movie to the beginning\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
mark_pending_load("SOME NONBLANK NAME", LOAD_STATE_BEGINNING);
|
||||
});
|
||||
|
||||
function_ptr_command<> cancel_save(lsnes_cmd, "cancel-saves", "Cancel all pending saves", "Syntax: "
|
||||
command::fnptr<> cancel_save(lsnes_cmd, "cancel-saves", "Cancel all pending saves", "Syntax: "
|
||||
"cancel-save\nCancel pending saves\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
queued_saves.clear();
|
||||
messages << "Pending saves canceled." << std::endl;
|
||||
});
|
||||
|
||||
function_ptr_command<> flushslots(lsnes_cmd, "flush-slotinfo", "Flush slotinfo cache",
|
||||
command::fnptr<> flushslots(lsnes_cmd, "flush-slotinfo", "Flush slotinfo cache",
|
||||
"Flush slotinfo cache\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
flush_slotinfo();
|
||||
});
|
||||
|
||||
function_ptr_command<> mhold1(lsnes_cmd, "+hold-macro", "Hold macro (hold)",
|
||||
command::fnptr<> mhold1(lsnes_cmd, "+hold-macro", "Hold macro (hold)",
|
||||
"Hold macros enable\n", []() throw(std::bad_alloc, std::runtime_error) {
|
||||
macro_hold_1 = true;
|
||||
});
|
||||
|
||||
function_ptr_command<> mhold2(lsnes_cmd, "-hold-macro", "Hold macro (hold)",
|
||||
command::fnptr<> mhold2(lsnes_cmd, "-hold-macro", "Hold macro (hold)",
|
||||
"Hold macros disable\n", []() throw(std::bad_alloc, std::runtime_error) {
|
||||
macro_hold_1 = false;
|
||||
});
|
||||
|
||||
function_ptr_command<> mhold3(lsnes_cmd, "hold-macro", "Hold macro (toggle)",
|
||||
command::fnptr<> mhold3(lsnes_cmd, "hold-macro", "Hold macro (toggle)",
|
||||
"Hold macros toggle\n", []() throw(std::bad_alloc, std::runtime_error) {
|
||||
macro_hold_2 = !macro_hold_2;
|
||||
if(macro_hold_2)
|
||||
|
|
|
@ -111,11 +111,11 @@ void refresh_cart_mappings() throw(std::bad_alloc)
|
|||
|
||||
namespace
|
||||
{
|
||||
class memorymanip_command : public command
|
||||
class memorymanip_command : public command::base
|
||||
{
|
||||
public:
|
||||
memorymanip_command(const std::string& cmd) throw(std::bad_alloc)
|
||||
: command(lsnes_cmd, cmd)
|
||||
: command::base(lsnes_cmd, cmd)
|
||||
{
|
||||
_command = cmd;
|
||||
}
|
||||
|
|
|
@ -440,14 +440,14 @@ void do_watch_memory()
|
|||
|
||||
namespace
|
||||
{
|
||||
function_ptr_command<const std::string&> add_watch(lsnes_cmd, "add-watch", "Add a memory watch",
|
||||
command::fnptr<const std::string&> add_watch(lsnes_cmd, "add-watch", "Add a memory watch",
|
||||
"Syntax: add-watch <name> <expression>\nAdds a new memory watch\n",
|
||||
[](const std::string& t) throw(std::bad_alloc, std::runtime_error) {
|
||||
auto r = regex("([^ \t]+)[ \t]+(|[^ \t].*)", t, "Name and expression required.");
|
||||
set_watchexpr_for(r[1], r[2]);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> remove_watch(lsnes_cmd, "remove-watch", "Remove a memory watch",
|
||||
command::fnptr<const std::string&> remove_watch(lsnes_cmd, "remove-watch", "Remove a memory watch",
|
||||
"Syntax: remove-watch <name>\nRemoves a memory watch\n",
|
||||
[](const std::string& t) throw(std::bad_alloc, std::runtime_error) {
|
||||
auto r = regex("([^ \t]+)[ \t]*", t, "Name required.");
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace
|
|||
exit(1);
|
||||
}
|
||||
|
||||
function_ptr_command<const std::string&> test4(lsnes_cmd, "panicsave-movie", "", "",
|
||||
command::fnptr<const std::string&> test4(lsnes_cmd, "panicsave-movie", "", "",
|
||||
[](const std::string& args) throw(std::bad_alloc, std::runtime_error) {
|
||||
emerg_save_movie(our_movie, movb.get_movie().get_frame_vector());
|
||||
});
|
||||
|
@ -466,7 +466,7 @@ std::string get_temp_file()
|
|||
#endif
|
||||
}
|
||||
|
||||
function_ptr_command<const std::string&> macro_test(lsnes_cmd, "test-macro", "", "",
|
||||
command::fnptr<const std::string&> macro_test(lsnes_cmd, "test-macro", "", "",
|
||||
[](const std::string& args) throw(std::bad_alloc, std::runtime_error) {
|
||||
regex_results r = regex("([0-9]+)[ \t](.*)", args);
|
||||
if(!r) {
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace
|
|||
return mprefix + "-";
|
||||
}
|
||||
|
||||
function_ptr_command<const std::string&> dump_coresave(lsnes_cmd, "dump-coresave", "Dump bsnes core state",
|
||||
command::fnptr<const std::string&> dump_coresave(lsnes_cmd, "dump-coresave", "Dump bsnes core state",
|
||||
"Syntax: dump-coresave <name>\nDumps core save to <name>\n",
|
||||
[](const std::string& name) throw(std::bad_alloc, std::runtime_error) {
|
||||
auto x = our_rom.save_core_state();
|
||||
|
|
|
@ -162,21 +162,21 @@ bool multitrack_edit::any_records()
|
|||
|
||||
namespace
|
||||
{
|
||||
function_ptr_command<> rotate_forward(lsnes_cmd, "rotate-multitrack", "Rotate multitrack",
|
||||
command::fnptr<> rotate_forward(lsnes_cmd, "rotate-multitrack", "Rotate multitrack",
|
||||
"Syntax: rotate-multitrack\nRotate multitrack\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
multitrack_editor.rotate(true);
|
||||
update_movie_state();
|
||||
});
|
||||
|
||||
function_ptr_command<> rotate_backward(lsnes_cmd, "rotate-multitrack-backwards", "Rotate multitrack backwards",
|
||||
command::fnptr<> rotate_backward(lsnes_cmd, "rotate-multitrack-backwards", "Rotate multitrack backwards",
|
||||
"Syntax: rotate-multitrack-backwards\nRotate multitrack backwards\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
multitrack_editor.rotate(false);
|
||||
update_movie_state();
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> set_mt(lsnes_cmd, "set-multitrack", "Set multitrack mode",
|
||||
command::fnptr<const std::string&> set_mt(lsnes_cmd, "set-multitrack", "Set multitrack mode",
|
||||
"Syntax: set-multitrack <controller> <mode>\nSet multitrack mode\n",
|
||||
[](const std::string& args) throw(std::bad_alloc, std::runtime_error) {
|
||||
regex_results r = regex("(.*)[ \t]+(.*)", args);
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace
|
|||
};
|
||||
|
||||
|
||||
function_ptr_command<const std::string&> edit_subtitle(lsnes_cmd, "edit-subtitle", "Edit a subtitle",
|
||||
command::fnptr<const std::string&> edit_subtitle(lsnes_cmd, "edit-subtitle", "Edit a subtitle",
|
||||
"Syntax: edit-subtitle <first> <length> <text>\nAdd/Edit subtitle\n"
|
||||
"Syntax: edit-subtitle <first> <length>\nADelete subtitle\n",
|
||||
[](const std::string& args) throw(std::bad_alloc, std::runtime_error) {
|
||||
|
@ -116,7 +116,7 @@ namespace
|
|||
redraw_framebuffer();
|
||||
});
|
||||
|
||||
function_ptr_command<> list_subtitle(lsnes_cmd, "list-subtitle", "List the subtitles",
|
||||
command::fnptr<> list_subtitle(lsnes_cmd, "list-subtitle", "List the subtitles",
|
||||
"Syntax: list-subtitle\nList the subtitles.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
for(auto i = our_movie.subtitles.rbegin(); i != our_movie.subtitles.rend(); i++) {
|
||||
|
@ -125,9 +125,9 @@ namespace
|
|||
}
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> save_s(lsnes_cmd, "save-subtitle", "Save subtitles in .sub format",
|
||||
command::fnptr<command::arg_filename> save_s(lsnes_cmd, "save-subtitle", "Save subtitles in .sub format",
|
||||
"Syntax: save-subtitle <file>\nSaves subtitles in .sub format to <file>\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
if(our_movie.subtitles.empty())
|
||||
return;
|
||||
auto i = our_movie.subtitles.begin();
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace
|
|||
{
|
||||
bool queue_function_run = false;
|
||||
|
||||
function_ptr_command<> identify_key(lsnes_cmd, "show-plugins", "Show plugins in use",
|
||||
command::fnptr<> identify_key(lsnes_cmd, "show-plugins", "Show plugins in use",
|
||||
"Syntax: show-plugins\nShows plugins in use.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
messages << "Graphics:\t" << graphics_driver_name() << std::endl;
|
||||
|
@ -72,7 +72,7 @@ namespace
|
|||
messages << "Joystick:\t" << joystick_driver_name() << std::endl;
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> enable_sound(lsnes_cmd, "enable-sound", "Enable/Disable sound",
|
||||
command::fnptr<const std::string&> enable_sound(lsnes_cmd, "enable-sound", "Enable/Disable sound",
|
||||
"Syntax: enable-sound <on/off>\nEnable or disable sound.\n",
|
||||
[](const std::string& args) throw(std::bad_alloc, std::runtime_error) {
|
||||
switch(string_to_bool(args)) {
|
||||
|
|
|
@ -1342,9 +1342,9 @@ again2:
|
|||
return std::make_pair(ADDR_KIND_NONE, 0);
|
||||
}
|
||||
|
||||
function_ptr_command<arg_filename> dump_core(lsnes_cmd, "dump-core", "No description available",
|
||||
command::fnptr<command::arg_filename> dump_core(lsnes_cmd, "dump-core", "No description available",
|
||||
"No description available\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error) {
|
||||
std::vector<char> out;
|
||||
bsnes_core.serialize(out);
|
||||
std::ofstream x(args, std::ios_base::out | std::ios_base::binary);
|
||||
|
@ -1511,7 +1511,7 @@ again2:
|
|||
lsnes_cmd.invoke("tracelog cpu " + r);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> start_trace(lsnes_cmd, "set-trace", "No description available",
|
||||
command::fnptr<const std::string&> start_trace(lsnes_cmd, "set-trace", "No description available",
|
||||
"No description available\n",
|
||||
[](const std::string& r) throw(std::bad_alloc, std::runtime_error) {
|
||||
lsnes_cmd.invoke("tracelog cpu " + r);
|
||||
|
|
|
@ -890,14 +890,14 @@ namespace
|
|||
|
||||
std::vector<char> cmp_save;
|
||||
|
||||
function_ptr_command<> cmp_save1(lsnes_cmd, "set-cmp-save", "", "\n", []() throw(std::bad_alloc,
|
||||
command::fnptr<> cmp_save1(lsnes_cmd, "set-cmp-save", "", "\n", []() throw(std::bad_alloc,
|
||||
std::runtime_error) {
|
||||
if(!internal_rom)
|
||||
return;
|
||||
instance->saveState(cmp_save);
|
||||
});
|
||||
|
||||
function_ptr_command<> cmp_save2(lsnes_cmd, "do-cmp-save", "", "\n", []() throw(std::bad_alloc,
|
||||
command::fnptr<> cmp_save2(lsnes_cmd, "do-cmp-save", "", "\n", []() throw(std::bad_alloc,
|
||||
std::runtime_error) {
|
||||
std::vector<char> x;
|
||||
if(!internal_rom)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "commands.hpp"
|
||||
#include "command.hpp"
|
||||
#include "globalwrap.hpp"
|
||||
#include "minmax.hpp"
|
||||
#include "register-queue.hpp"
|
||||
|
@ -7,12 +7,14 @@
|
|||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace command
|
||||
{
|
||||
namespace
|
||||
{
|
||||
struct run_script : public command
|
||||
struct run_script : public base
|
||||
{
|
||||
run_script(command_group& group, std::ostream*& _output)
|
||||
: command(group, "run-script"), in_group(group), output(_output)
|
||||
run_script(group& group, std::ostream*& _output)
|
||||
: base(group, "run-script"), in_group(group), output(_output)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -51,7 +53,7 @@ namespace
|
|||
"the command line\n";
|
||||
}
|
||||
|
||||
command_group& in_group;
|
||||
group& in_group;
|
||||
std::ostream*& output;
|
||||
};
|
||||
|
||||
|
@ -61,32 +63,32 @@ namespace
|
|||
exit(1);
|
||||
}
|
||||
|
||||
typedef register_queue<command_group, command> regqueue_t;
|
||||
typedef register_queue<group, base> regqueue_t;
|
||||
}
|
||||
|
||||
command::command(command_group& group, const std::string& cmd) throw(std::bad_alloc)
|
||||
base::base(group& group, const std::string& cmd) throw(std::bad_alloc)
|
||||
: in_group(group)
|
||||
{
|
||||
regqueue_t::do_register(in_group, commandname = cmd, *this);
|
||||
}
|
||||
|
||||
command::~command() throw()
|
||||
base::~base() throw()
|
||||
{
|
||||
regqueue_t::do_unregister(in_group, commandname);
|
||||
}
|
||||
|
||||
|
||||
std::string command::get_short_help() throw(std::bad_alloc)
|
||||
std::string base::get_short_help() throw(std::bad_alloc)
|
||||
{
|
||||
return "No description available";
|
||||
}
|
||||
|
||||
std::string command::get_long_help() throw(std::bad_alloc)
|
||||
std::string base::get_long_help() throw(std::bad_alloc)
|
||||
{
|
||||
return "No help available on command " + commandname;
|
||||
}
|
||||
|
||||
command_group::command_group() throw(std::bad_alloc)
|
||||
group::group() throw(std::bad_alloc)
|
||||
{
|
||||
oom_panic_routine = default_oom_panic;
|
||||
output = &std::cerr;
|
||||
|
@ -95,14 +97,14 @@ command_group::command_group() throw(std::bad_alloc)
|
|||
builtin[0] = new run_script(*this, output);
|
||||
}
|
||||
|
||||
command_group::~command_group() throw()
|
||||
group::~group() throw()
|
||||
{
|
||||
for(size_t i = 0; i < sizeof(builtin)/sizeof(builtin[0]); i++)
|
||||
delete builtin[i];
|
||||
regqueue_t::do_ready(*this, false);
|
||||
}
|
||||
|
||||
void command_group::invoke(const std::string& cmd) throw()
|
||||
void group::invoke(const std::string& cmd) throw()
|
||||
{
|
||||
try {
|
||||
std::string cmd2 = strip_CR(cmd);
|
||||
|
@ -158,7 +160,7 @@ not_alias:
|
|||
size_t split = cmd2.find_first_of(" \t");
|
||||
std::string rcmd = cmd2.substr(0, min(split, cmd2.length()));
|
||||
std::string args = cmd2.substr(min(cmd2.find_first_not_of(" \t", split), cmd2.length()));
|
||||
command* cmdh = NULL;
|
||||
base* cmdh = NULL;
|
||||
{
|
||||
umutex_class lock(int_mutex);
|
||||
if(!commands.count(rcmd)) {
|
||||
|
@ -185,7 +187,7 @@ not_alias:
|
|||
}
|
||||
}
|
||||
|
||||
std::set<std::string> command_group::get_aliases() throw(std::bad_alloc)
|
||||
std::set<std::string> group::get_aliases() throw(std::bad_alloc)
|
||||
{
|
||||
umutex_class lock(int_mutex);
|
||||
std::set<std::string> r;
|
||||
|
@ -194,7 +196,7 @@ std::set<std::string> command_group::get_aliases() throw(std::bad_alloc)
|
|||
return r;
|
||||
}
|
||||
|
||||
std::string command_group::get_alias_for(const std::string& aname) throw(std::bad_alloc)
|
||||
std::string group::get_alias_for(const std::string& aname) throw(std::bad_alloc)
|
||||
{
|
||||
umutex_class lock(int_mutex);
|
||||
if(!valid_alias_name(aname))
|
||||
|
@ -208,7 +210,7 @@ std::string command_group::get_alias_for(const std::string& aname) throw(std::ba
|
|||
return "";
|
||||
}
|
||||
|
||||
void command_group::set_alias_for(const std::string& aname, const std::string& avalue) throw(std::bad_alloc)
|
||||
void group::set_alias_for(const std::string& aname, const std::string& avalue) throw(std::bad_alloc)
|
||||
{
|
||||
umutex_class lock(int_mutex);
|
||||
if(!valid_alias_name(aname))
|
||||
|
@ -228,7 +230,7 @@ void command_group::set_alias_for(const std::string& aname, const std::string& a
|
|||
aliases[aname] = newlist;
|
||||
}
|
||||
|
||||
bool command_group::valid_alias_name(const std::string& aliasname) throw(std::bad_alloc)
|
||||
bool group::valid_alias_name(const std::string& aliasname) throw(std::bad_alloc)
|
||||
{
|
||||
if(aliasname.length() == 0 || aliasname[0] == '?' || aliasname[0] == '*')
|
||||
return false;
|
||||
|
@ -237,7 +239,7 @@ bool command_group::valid_alias_name(const std::string& aliasname) throw(std::ba
|
|||
return true;
|
||||
}
|
||||
|
||||
void command_group::do_register(const std::string& name, command& cmd) throw(std::bad_alloc)
|
||||
void group::do_register(const std::string& name, base& cmd) throw(std::bad_alloc)
|
||||
{
|
||||
umutex_class lock(int_mutex);
|
||||
if(commands.count(name))
|
||||
|
@ -245,18 +247,18 @@ void command_group::do_register(const std::string& name, command& cmd) throw(std
|
|||
commands[name] = &cmd;
|
||||
}
|
||||
|
||||
void command_group::do_unregister(const std::string& name) throw(std::bad_alloc)
|
||||
void group::do_unregister(const std::string& name) throw(std::bad_alloc)
|
||||
{
|
||||
umutex_class lock(int_mutex);
|
||||
commands.erase(name);
|
||||
}
|
||||
|
||||
void command_group::set_output(std::ostream& s)
|
||||
void group::set_output(std::ostream& s)
|
||||
{
|
||||
output = &s;
|
||||
}
|
||||
|
||||
void command_group::set_oom_panic(void (*fn)())
|
||||
void group::set_oom_panic(void (*fn)())
|
||||
{
|
||||
if(fn)
|
||||
oom_panic_routine = fn;
|
||||
|
@ -265,13 +267,13 @@ void command_group::set_oom_panic(void (*fn)())
|
|||
}
|
||||
|
||||
template<>
|
||||
void invoke_command_fn(void (*fn)(const std::string& args), const std::string& args)
|
||||
void invoke_fn(void (*fn)(const std::string& args), const std::string& args)
|
||||
{
|
||||
fn(args);
|
||||
}
|
||||
|
||||
template<>
|
||||
void invoke_command_fn(void (*fn)(), const std::string& args)
|
||||
void invoke_fn(void (*fn)(), const std::string& args)
|
||||
{
|
||||
if(args != "")
|
||||
throw std::runtime_error("This command does not take arguments");
|
||||
|
@ -279,7 +281,7 @@ void invoke_command_fn(void (*fn)(), const std::string& args)
|
|||
}
|
||||
|
||||
template<>
|
||||
void invoke_command_fn(void (*fn)(struct arg_filename a), const std::string& args)
|
||||
void invoke_fn(void (*fn)(struct arg_filename a), const std::string& args)
|
||||
{
|
||||
if(args == "")
|
||||
throw std::runtime_error("Filename required");
|
||||
|
@ -287,3 +289,4 @@ void invoke_command_fn(void (*fn)(struct arg_filename a), const std::string& arg
|
|||
b.v = args;
|
||||
fn(b);
|
||||
}
|
||||
}
|
|
@ -135,7 +135,7 @@ keyboard& keyboard_mapper::get_keyboard() throw()
|
|||
return kbd;
|
||||
}
|
||||
|
||||
keyboard_mapper::keyboard_mapper(keyboard& _kbd, command_group& _domain) throw(std::bad_alloc)
|
||||
keyboard_mapper::keyboard_mapper(keyboard& _kbd, command::group& _domain) throw(std::bad_alloc)
|
||||
: inverse_proxy(*this), controllerkey_proxy(*this), kbd(_kbd), domain(_domain)
|
||||
{
|
||||
register_queue<_inverse_proxy, inverse_bind>::do_ready(inverse_proxy, true);
|
||||
|
@ -227,7 +227,7 @@ std::list<key_specifier> keyboard_mapper::get_bindings() throw(std::bad_alloc)
|
|||
return r;
|
||||
}
|
||||
|
||||
command_group& keyboard_mapper::get_command_group() throw()
|
||||
command::group& keyboard_mapper::get_command_group() throw()
|
||||
{
|
||||
return domain;
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ private:
|
|||
inverse_bind ikey;
|
||||
};
|
||||
|
||||
class lua_command_binding : public command
|
||||
class lua_command_binding : public command::base
|
||||
{
|
||||
public:
|
||||
lua_command_binding(lua_state& _L, const std::string& cmd, int idx)
|
||||
: command(lsnes_cmd, cmd), L(_L)
|
||||
: command::base(lsnes_cmd, cmd), L(_L)
|
||||
{
|
||||
L.pushlightuserdata(this);
|
||||
L.pushvalue(idx);
|
||||
|
|
|
@ -386,7 +386,7 @@ bool lua_callback_do_button(uint32_t port, uint32_t controller, uint32_t index,
|
|||
|
||||
namespace
|
||||
{
|
||||
function_ptr_command<const std::string&> evaluate_lua(lsnes_cmd, "evaluate-lua", "Evaluate expression in "
|
||||
command::fnptr<const std::string&> evaluate_lua(lsnes_cmd, "evaluate-lua", "Evaluate expression in "
|
||||
"Lua VM", "Syntax: evaluate-lua <expression>\nEvaluates <expression> in Lua VM.\n",
|
||||
[](const std::string& args) throw(std::bad_alloc, std::runtime_error) {
|
||||
if(args == "")
|
||||
|
@ -394,7 +394,7 @@ namespace
|
|||
do_eval_lua(lsnes_lua_state, args);
|
||||
});
|
||||
|
||||
function_ptr_command<const std::string&> evaluate_lua2(lsnes_cmd, "L", "Evaluate expression in "
|
||||
command::fnptr<const std::string&> evaluate_lua2(lsnes_cmd, "L", "Evaluate expression in "
|
||||
"Lua VM", "Syntax: evaluate-lua <expression>\nEvaluates <expression> in Lua VM.\n",
|
||||
[](const std::string& args) throw(std::bad_alloc, std::runtime_error) {
|
||||
if(args == "")
|
||||
|
@ -402,14 +402,14 @@ namespace
|
|||
do_eval_lua(lsnes_lua_state, args);
|
||||
});
|
||||
|
||||
function_ptr_command<arg_filename> run_lua(lsnes_cmd, "run-lua", "Run Lua script in Lua VM",
|
||||
command::fnptr<command::arg_filename> run_lua(lsnes_cmd, "run-lua", "Run Lua script in Lua VM",
|
||||
"Syntax: run-lua <file>\nRuns <file> in Lua VM.\n",
|
||||
[](arg_filename args) throw(std::bad_alloc, std::runtime_error)
|
||||
[](command::arg_filename args) throw(std::bad_alloc, std::runtime_error)
|
||||
{
|
||||
do_run_lua(lsnes_lua_state, args);
|
||||
});
|
||||
|
||||
function_ptr_command<> reset_lua(lsnes_cmd, "reset-lua", "Reset the Lua VM",
|
||||
command::fnptr<> reset_lua(lsnes_cmd, "reset-lua", "Reset the Lua VM",
|
||||
"Syntax: reset-lua\nReset the Lua VM.\n",
|
||||
[]() throw(std::bad_alloc, std::runtime_error)
|
||||
{
|
||||
|
|
|
@ -351,7 +351,7 @@ namespace
|
|||
}
|
||||
};
|
||||
|
||||
function_ptr_command<> callbacks_show_lua(lsnes_cmd, "show-lua-callbacks", "", "",
|
||||
command::fnptr<> callbacks_show_lua(lsnes_cmd, "show-lua-callbacks", "", "",
|
||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||
for(auto& i : cbs)
|
||||
for(auto& j : i.second)
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace
|
|||
return true;
|
||||
}
|
||||
|
||||
function_ptr_command<const std::string&> x(lsnes_cmd, "libao-set-id", "", "",
|
||||
command::fnptr<const std::string&> x(lsnes_cmd, "libao-set-id", "", "",
|
||||
[](const std::string& value) throw(std::bad_alloc, std::runtime_error) {
|
||||
driver_id = parse_value<int>(value);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue