1 // (c) Copyright 2006 notaz, All rights reserved.
\r
2 // Free for non-commercial use.
\r
4 // For commercial use, separate licencing terms must be obtained.
\r
10 #include <strings.h>
\r
11 #include <linux/limits.h>
\r
13 #include "../gp2x/emu.h" // TODO rm
\r
14 #include "../common/menu.h"
\r
15 #include "../common/emu.h"
\r
16 #include "../common/config.h"
\r
17 #include "../common/input.h"
\r
18 #include "../gp2x/version.h"
\r
19 #include "pandora.h"
\r
22 extern char *PicoConfigFile;
\r
23 static int load_state_slot = -1;
\r
26 void parse_cmd_line(int argc, char *argv[])
\r
28 int x, unrecognized = 0;
\r
30 for(x = 1; x < argc; x++)
\r
32 if(argv[x][0] == '-')
\r
34 if(strcasecmp(argv[x], "-config") == 0) {
\r
35 if(x+1 < argc) { ++x; PicoConfigFile = argv[x]; }
\r
37 else if(strcasecmp(argv[x], "-loadstate") == 0) {
\r
38 if(x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }
\r
45 /* External Frontend: ROM Name */
\r
47 strncpy(rom_fname_reload, argv[x], sizeof(rom_fname_reload));
\r
48 rom_fname_reload[sizeof(rom_fname_reload) - 1] = 0;
\r
49 f = fopen(rom_fname_reload, "rb");
\r
51 else unrecognized = 1;
\r
52 engineState = PGS_ReloadRom;
\r
58 printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2009\n");
\r
59 printf("usage: %s [options] [romfile]\n", argv[0]);
\r
60 printf( "options:\n"
\r
61 "-config <file> use specified config file instead of default 'picoconfig.bin'\n"
\r
62 " see currentConfig_t structure in emu.h for the file format\n"
\r
63 "-loadstate <num> if ROM is specified, try loading slot <num>\n");
\r
68 int main(int argc, char *argv[])
\r
73 emu_prepareDefaultConfig();
\r
74 emu_ReadConfig(0, 0);
\r
75 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_ReloadRom(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_SaveLoadGame(1, 0);
\r
101 switch (engineState)
\r
107 case PGS_ReloadRom:
\r
108 if (emu_ReloadRom(rom_fname_reload))
\r
109 engineState = PGS_Running;
\r
111 printf("PGS_ReloadRom == 0\n");
\r
112 engineState = PGS_Menu;
\r
116 case PGS_RestartRun:
\r
117 engineState = PGS_Running;
\r
127 printf("engine got into unknown state (%i), exitting\n", engineState);
\r