3 * (C) notaz, 2006-2010
\r
5 * This work is licensed under the terms of MAME license.
\r
6 * See COPYING file in the top-level directory.
\r
12 #include <strings.h>
\r
14 #include "../libpicofe/input.h"
\r
15 #include "../libpicofe/plat.h"
\r
16 #include "menu_pico.h"
\r
18 #include "version.h"
\r
19 #include <cpu/debug.h>
\r
22 static int load_state_slot = -1;
\r
25 void parse_cmd_line(int argc, char *argv[])
\r
27 int x, unrecognized = 0;
\r
29 for (x = 1; x < argc; x++)
\r
31 if (argv[x][0] == '-')
\r
33 if (strcasecmp(argv[x], "-config") == 0) {
\r
34 if (x+1 < argc) { ++x; PicoConfigFile = argv[x]; }
\r
36 else if (strcasecmp(argv[x], "-loadstate") == 0
\r
37 || strcasecmp(argv[x], "-load") == 0)
\r
39 if (x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }
\r
41 else if (strcasecmp(argv[x], "-pdb") == 0) {
\r
42 if (x+1 < argc) { ++x; pdb_command(argv[x]); }
\r
44 else if (strcasecmp(argv[x], "-pdb_connect") == 0) {
\r
45 if (x+2 < argc) { pdb_net_connect(argv[x+1], argv[x+2]); x += 2; }
\r
52 FILE *f = fopen(argv[x], "rb");
\r
55 rom_fname_reload = argv[x];
\r
56 engineState = PGS_ReloadRom;
\r
65 printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2009,2013\n");
\r
66 printf("usage: %s [options] [romfile]\n", argv[0]);
\r
68 " -config <file> use specified config file instead of default 'config.cfg'\n"
\r
69 " -loadstate <num> if ROM is specified, try loading savestate slot <num>\n");
\r
75 int main(int argc, char *argv[])
\r
87 emu_prep_defconfig(); // depends on input
\r
88 emu_read_config(NULL, 0);
\r
93 engineState = PGS_Menu;
\r
96 parse_cmd_line(argc, argv);
\r
98 if (engineState == PGS_ReloadRom)
\r
100 if (emu_reload_rom(rom_fname_reload)) {
\r
101 engineState = PGS_Running;
\r
102 if (load_state_slot >= 0) {
\r
103 state_slot = load_state_slot;
\r
104 emu_save_load_game(1, 0);
\r
111 switch (engineState)
\r
121 case PGS_ReloadRom:
\r
122 if (emu_reload_rom(rom_fname_reload))
\r
123 engineState = PGS_Running;
\r
125 printf("PGS_ReloadRom == 0\n");
\r
126 engineState = PGS_Menu;
\r
130 case PGS_RestartRun:
\r
131 engineState = PGS_Running;
\r
132 /* vvv fallthrough */
\r
142 printf("engine got into unknown state (%i), exitting\n", engineState);
\r
151 plat_target_finish();
\r