1 // (c) Copyright 2006-2009 notaz, All rights reserved.
\r
2 // Free for non-commercial use.
\r
4 // For commercial use, separate licencing terms must be obtained.
\r
16 #include <cpu/debug.h>
\r
17 #include <version.h>
\r
20 extern char *PicoConfigFile;
\r
21 static int load_state_slot = -1;
\r
24 void parse_cmd_line(int argc, char *argv[])
\r
26 int x, unrecognized = 0;
\r
28 for (x = 1; x < argc; x++)
\r
30 if (argv[x][0] == '-')
\r
32 if (strcasecmp(argv[x], "-config") == 0) {
\r
33 if (x+1 < argc) { ++x; PicoConfigFile = argv[x]; }
\r
35 else if (strcasecmp(argv[x], "-loadstate") == 0) {
\r
36 if (x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }
\r
38 else if (strcasecmp(argv[x], "-pdb") == 0) {
\r
39 if (x+1 < argc) { ++x; pdb_command(argv[x]); }
\r
41 else if (strcasecmp(argv[x], "-pdb_connect") == 0) {
\r
42 if (x+2 < argc) { pdb_net_connect(argv[x+1], argv[x+2]); x += 2; }
\r
49 /* External Frontend: ROM Name */
\r
51 strncpy(rom_fname_reload, argv[x], sizeof(rom_fname_reload));
\r
52 rom_fname_reload[sizeof(rom_fname_reload) - 1] = 0;
\r
53 f = fopen(rom_fname_reload, "rb");
\r
55 else unrecognized = 1;
\r
56 engineState = PGS_ReloadRom;
\r
62 printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2009\n");
\r
63 printf("usage: %s [options] [romfile]\n", argv[0]);
\r
65 " -config <file> use specified config file instead of default 'config.cfg'\n"
\r
66 " -loadstate <num> if ROM is specified, try loading slot <num>\n");
\r
71 int main(int argc, char *argv[])
\r
82 emu_prep_defconfig(); // depends on input
\r
83 emu_read_config(NULL, 0);
\r
88 engineState = PGS_Menu;
\r
91 parse_cmd_line(argc, argv);
\r
93 if (engineState == PGS_ReloadRom)
\r
95 if (emu_reload_rom(rom_fname_reload)) {
\r
96 engineState = PGS_Running;
\r
97 if (load_state_slot >= 0) {
\r
98 state_slot = load_state_slot;
\r
99 emu_save_load_game(1, 0);
\r
106 switch (engineState)
\r
116 case PGS_ReloadRom:
\r
117 if (emu_reload_rom(rom_fname_reload))
\r
118 engineState = PGS_Running;
\r
120 printf("PGS_ReloadRom == 0\n");
\r
121 engineState = PGS_Menu;
\r
125 case PGS_RestartRun:
\r
126 engineState = PGS_Running;
\r
127 /* vvv fallthrough */
\r
137 printf("engine got into unknown state (%i), exitting\n", engineState);
\r