diff options
| author | Jens Arnold <amiconn@rockbox.org> | 2005-03-02 23:49:38 +0000 |
|---|---|---|
| committer | Jens Arnold <amiconn@rockbox.org> | 2005-03-02 23:49:38 +0000 |
| commit | 384de102469fee4e0792df8fe38586d3206774ed (patch) | |
| tree | ee5342103e17738acfb8421328ea7c57433f55e6 /apps/plugins/rockboy/rccmds.c | |
| parent | 48dad47df98bdec632e8930b6a97359dc2c428f5 (diff) | |
| download | rockbox-384de102469fee4e0792df8fe38586d3206774ed.zip rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.gz rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.bz2 rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.xz | |
Rockboy - gameboy emulation for rockbox, based on gnuboy. Still a bit early, but already playable on iRiver H1xx and the simulators. The archos recorder version is currently rather slow...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6104 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockboy/rccmds.c')
| -rw-r--r-- | apps/plugins/rockboy/rccmds.c | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/apps/plugins/rockboy/rccmds.c b/apps/plugins/rockboy/rccmds.c new file mode 100644 index 0000000..c9375b6 --- /dev/null +++ b/apps/plugins/rockboy/rccmds.c @@ -0,0 +1,122 @@ + + + + +#include "rockmacros.h" + +#include "defs.h" +#include "rc.h" +#include "hw.h" +#include "emu.h" +#include "save.h" +#include "split.h" + +/* + * the set command is used to set rc-exported variables. + */ + +static int cmd_set(int argc, char **argv) +{ + if (argc < 3) + return -1; + return rc_setvar(argv[1], argc-2, argv+2); +} + + + +/* + * the following commands allow keys to be bound to perform rc commands. + */ + +static int cmd_reset(int argc, char **argv) +{ + (void)argc; + (void)argv; + emu_reset(); + return 0; +} + +static int cmd_savestate(int argc, char **argv) +{ + state_save(argc > 1 ? atoi(argv[1]) : -1); + return 0; +} + +static int cmd_loadstate(int argc, char **argv) +{ + state_load(argc > 1 ? atoi(argv[1]) : -1); + return 0; +} + + + +/* + * table of command names and the corresponding functions to be called + */ + +rccmd_t rccmds[] = +{ + RCC("set", cmd_set), + RCC("reset", cmd_reset), + RCC("savestate", cmd_savestate), + RCC("loadstate", cmd_loadstate), + RCC_END +}; + + + + + +int rc_command(char *line) +{ + int i, argc, ret; + char *argv[128], linecopy[500]; + +// linecopy = malloc(strlen(line)+1); + strcpy(linecopy, line); + + argc = splitline(argv, (sizeof argv)/(sizeof argv[0]), linecopy); + if (!argc) + { +// free(linecopy); + return -1; + } + + for (i = 0; rccmds[i].name; i++) + { + if (!strcmp(argv[0], rccmds[i].name)) + { + ret = rccmds[i].func(argc, argv); +// free(linecopy); + return ret; + } + } + + /* printf("unknown command: %s\n", argv[0]); */ +// free(linecopy); + + return -1; +} + + + + + + + + + + + + + + + + + + + + + + + |