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/gp2x.h"
\r
14 #include "../gp2x/menu.h"
\r
15 #include "../common/menu.h"
\r
16 #include "../common/emu.h"
\r
17 #include "../common/config.h"
\r
18 #include "../common/input.h"
\r
19 #include "../gp2x/emu.h"
\r
20 #include "../gp2x/version.h"
\r
23 extern int select_exits;
\r
24 extern char *PicoConfigFile;
\r
25 static int load_state_slot = -1;
\r
26 int mmuhack_status = 0; // TODO rm
\r
29 void parse_cmd_line(int argc, char *argv[])
\r
31 int x, unrecognized = 0;
\r
33 for(x = 1; x < argc; x++)
\r
35 if(argv[x][0] == '-')
\r
37 if(strcasecmp(argv[x], "-config") == 0) {
\r
38 if(x+1 < argc) { ++x; PicoConfigFile = argv[x]; }
\r
40 else if(strcasecmp(argv[x], "-selectexit") == 0) {
\r
43 else if(strcasecmp(argv[x], "-loadstate") == 0) {
\r
44 if(x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }
\r
51 /* External Frontend: ROM Name */
\r
53 strncpy(romFileName, argv[x], PATH_MAX);
\r
54 romFileName[PATH_MAX-1] = 0;
\r
55 f = fopen(romFileName, "rb");
\r
57 else unrecognized = 1;
\r
58 engineState = PGS_ReloadRom;
\r
64 printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2008\n");
\r
65 printf("usage: %s [options] [romfile]\n", argv[0]);
\r
66 printf( "options:\n"
\r
67 "-menu <menu_path> launch a custom program on exit instead of default gp2xmenu\n"
\r
68 "-state <param> pass '-state param' to the menu program\n"
\r
69 "-config <file> use specified config file instead of default 'picoconfig.bin'\n"
\r
70 " see currentConfig_t structure in emu.h for the file format\n"
\r
71 "-selectexit pressing SELECT will exit the emu and start 'menu_path'\n"
\r
72 "-loadstate <num> if ROM is specified, try loading slot <num>\n");
\r
77 int main(int argc, char *argv[])
\r
82 emu_prepareDefaultConfig();
\r
83 emu_ReadConfig(0, 0);
\r
84 config_readlrom(PicoConfigFile);
\r
92 engineState = PGS_Menu;
\r
95 parse_cmd_line(argc, argv);
\r
97 if (engineState == PGS_ReloadRom)
\r
99 if (emu_ReloadRom(romFileName)) {
\r
100 engineState = PGS_Running;
\r
101 if (load_state_slot >= 0) {
\r
102 state_slot = load_state_slot;
\r
103 emu_SaveLoadGame(1, 0);
\r
110 switch (engineState)
\r
116 case PGS_ReloadRom:
\r
117 if (emu_ReloadRom(romFileName))
\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
136 printf("engine got into unknown state (%i), exitting\n", engineState);
\r