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 <version.h>
\r
19 extern char *PicoConfigFile;
\r
20 static int load_state_slot = -1;
\r
23 void parse_cmd_line(int argc, char *argv[])
\r
25 int x, unrecognized = 0;
\r
27 for (x = 1; x < argc; x++)
\r
29 if (argv[x][0] == '-')
\r
31 if (strcasecmp(argv[x], "-config") == 0) {
\r
32 if (x+1 < argc) { ++x; PicoConfigFile = argv[x]; }
\r
34 else if (strcasecmp(argv[x], "-loadstate") == 0) {
\r
35 if (x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }
\r
42 /* External Frontend: ROM Name */
\r
44 strncpy(rom_fname_reload, argv[x], sizeof(rom_fname_reload));
\r
45 rom_fname_reload[sizeof(rom_fname_reload) - 1] = 0;
\r
46 f = fopen(rom_fname_reload, "rb");
\r
48 else unrecognized = 1;
\r
49 engineState = PGS_ReloadRom;
\r
55 printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2009\n");
\r
56 printf("usage: %s [options] [romfile]\n", argv[0]);
\r
58 " -config <file> use specified config file instead of default 'config.cfg'\n"
\r
59 " -loadstate <num> if ROM is specified, try loading slot <num>\n");
\r
64 int main(int argc, char *argv[])
\r
70 /* in_init() must go before config, config accesses in_ fwk */
\r
72 pemu_prep_defconfig();
\r
73 emu_read_config(0, 0);
\r
74 config_readlrom(PicoConfigFile);
\r
83 engineState = PGS_Menu;
\r
86 parse_cmd_line(argc, argv);
\r
88 if (engineState == PGS_ReloadRom)
\r
90 if (emu_reload_rom(rom_fname_reload)) {
\r
91 engineState = PGS_Running;
\r
92 if (load_state_slot >= 0) {
\r
93 state_slot = load_state_slot;
\r
94 emu_save_load_game(1, 0);
\r
101 switch (engineState)
\r
111 case PGS_ReloadRom:
\r
112 if (emu_reload_rom(rom_fname_reload))
\r
113 engineState = PGS_Running;
\r
115 printf("PGS_ReloadRom == 0\n");
\r
116 engineState = PGS_Menu;
\r
120 case PGS_RestartRun:
\r
121 engineState = PGS_Running;
\r
122 /* vvv fallthrough */
\r
132 printf("engine got into unknown state (%i), exitting\n", engineState);
\r