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
17 #include "../libpicofe/input.h"
\r
18 #include "../libpicofe/plat.h"
\r
19 #include "menu_pico.h"
\r
21 #include "version.h"
\r
22 #include <cpu/debug.h>
\r
24 static int load_state_slot = -1;
\r
27 void parse_cmd_line(int argc, char *argv[])
\r
29 int x, unrecognized = 0;
\r
31 for (x = 1; x < argc && !unrecognized; x++)
\r
33 if (argv[x][0] == '-')
\r
35 if (strcasecmp(argv[x], "-config") == 0) {
\r
36 if (x+1 < argc) { ++x; PicoConfigFile = argv[x]; }
\r
38 else if (strcasecmp(argv[x], "-loadstate") == 0
\r
39 || strcasecmp(argv[x], "-load") == 0)
\r
41 if (x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }
\r
43 else if (strcasecmp(argv[x], "-pdb") == 0) {
\r
44 if (x+1 < argc) { ++x; pdb_command(argv[x]); }
\r
46 else if (strcasecmp(argv[x], "-pdb_connect") == 0) {
\r
47 if (x+2 < argc) { pdb_net_connect(argv[x+1], argv[x+2]); x += 2; }
\r
50 unrecognized = plat_parse_arg(argc, argv, &x);
\r
53 FILE *f = fopen(argv[x], "rb");
\r
56 rom_fname_reload = argv[x];
\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
86 parse_cmd_line(argc, argv);
\r
91 emu_prep_defconfig(); // depends on input
\r
92 emu_read_config(NULL, 0);
\r
96 engineState = rom_fname_reload ? PGS_ReloadRom : PGS_Menu;
\r
97 plat_video_menu_enter(0);
\r
99 if (engineState == PGS_ReloadRom)
\r
101 plat_video_menu_begin();
\r
102 if (emu_reload_rom(rom_fname_reload)) {
\r
103 engineState = PGS_Running;
\r
104 if (load_state_slot >= 0) {
\r
105 state_slot = load_state_slot;
\r
106 emu_save_load_game(1, 0);
\r
109 plat_video_menu_end();
\r
111 plat_video_menu_leave();
\r
115 switch (engineState)
\r
125 case PGS_ReloadRom:
\r
126 if (emu_reload_rom(rom_fname_reload))
\r
127 engineState = PGS_Running;
\r
129 printf("PGS_ReloadRom == 0\n");
\r
130 engineState = PGS_Menu;
\r
134 case PGS_RestartRun:
\r
135 engineState = PGS_Running;
\r
136 /* vvv fallthrough */
\r
140 ProfilerStart("gperf.out");
\r
152 printf("engine got into unknown state (%i), exitting\n", engineState);
\r
161 plat_target_finish();
\r