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 <linux/limits.h>
\r
14 #include "../common/menu.h"
\r
15 #include "../common/emu.h"
\r
18 #include "version.h"
\r
20 #include "squidgehack.h"
\r
21 #include "cpuctrl.h"
\r
24 extern char *ext_menu, *ext_state;
\r
25 extern int select_exits;
\r
26 extern char *PicoConfigFile;
\r
27 int mmuhack_status = 0;
\r
30 void parse_cmd_line(int argc, char *argv[])
\r
32 int x, unrecognized = 0;
\r
34 for(x = 1; x < argc; x++)
\r
36 if(argv[x][0] == '-')
\r
38 if(strcasecmp(argv[x], "-menu") == 0) {
\r
39 if(x+1 < argc) { ++x; ext_menu = argv[x]; } /* External Frontend: Program Name */
\r
41 else if(strcasecmp(argv[x], "-state") == 0) {
\r
42 if(x+1 < argc) { ++x; ext_state = argv[x]; } /* External Frontend: Arguments */
\r
44 else if(strcasecmp(argv[x], "-config") == 0) {
\r
45 if(x+1 < argc) { ++x; PicoConfigFile = argv[x]; }
\r
47 else if(strcasecmp(argv[x], "-selectexit") == 0) {
\r
55 /* External Frontend: ROM Name */
\r
57 strncpy(romFileName, argv[x], PATH_MAX);
\r
58 romFileName[PATH_MAX-1] = 0;
\r
59 f = fopen(romFileName, "rb");
\r
61 else unrecognized = 1;
\r
62 engineState = PGS_ReloadRom;
\r
68 printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2007\n");
\r
69 printf("usage: %s [options] [romfile]\n", argv[0]);
\r
70 printf( "options:\n"
\r
71 "-menu <menu_path> launch a custom program on exit instead of default gp2xmenu\n"
\r
72 "-state <param> pass '-state param' to the menu program\n"
\r
73 "-config <file> use specified config file instead of default 'picoconfig.bin'\n"
\r
74 " see currentConfig_t structure in emu.h for the file format\n"
\r
75 "-selectexit pressing SELECT will exit the emu and start 'menu_path'\n");
\r
80 int main(int argc, char *argv[])
\r
84 emu_ReadConfig(0, 0);
\r
86 if (currentConfig.EmuOpt&0x10) {
\r
87 int ret = mmuhack();
\r
88 printf("squidge hack code finished and returned %i\n", ret); fflush(stdout);
\r
89 mmuhack_status = ret;
\r
94 if (currentConfig.EmuOpt&0x100) {
\r
95 printf("setting RAM timings.. "); fflush(stdout);
\r
96 // craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2
\r
97 set_RAM_Timings(6, 4, 1, 1, 1, 2, 2);
\r
98 printf("done.\n"); fflush(stdout);
\r
104 engineState = PGS_Menu;
\r
107 parse_cmd_line(argc, argv);
\r
111 switch (engineState)
\r
117 case PGS_ReloadRom:
\r
118 if (emu_ReloadRom())
\r
119 engineState = PGS_Running;
\r
121 printf("PGS_ReloadRom == 0\n");
\r
122 engineState = PGS_Menu;
\r
126 case PGS_RestartRun:
\r
127 engineState = PGS_Running;
\r
137 printf("engine got into unknown state (%i), exitting\n", engineState);
\r
145 sharedmem_deinit();
\r