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
17 #include "version.h"
\r
19 #include "squidgehack.h"
\r
20 #include "cpuctrl.h"
\r
23 extern char *ext_menu, *ext_state;
\r
24 extern int select_exits;
\r
25 extern char *PicoConfigFile;
\r
26 int mmuhack_status = 0;
\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], "-menu") == 0) {
\r
38 if(x+1 < argc) { ++x; ext_menu = argv[x]; } /* External Frontend: Program Name */
\r
40 else if(strcasecmp(argv[x], "-state") == 0) {
\r
41 if(x+1 < argc) { ++x; ext_state = argv[x]; } /* External Frontend: Arguments */
\r
43 else if(strcasecmp(argv[x], "-config") == 0) {
\r
44 if(x+1 < argc) { ++x; PicoConfigFile = argv[x]; }
\r
46 else if(strcasecmp(argv[x], "-selectexit") == 0) {
\r
54 /* External Frontend: ROM Name */
\r
56 strncpy(romFileName, argv[x], PATH_MAX);
\r
57 romFileName[PATH_MAX-1] = 0;
\r
58 f = fopen(romFileName, "rb");
\r
60 else unrecognized = 1;
\r
61 engineState = PGS_ReloadRom;
\r
67 printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2007\n");
\r
68 printf("usage: %s [options] [romfile]\n", argv[0]);
\r
69 printf( "options:\n"
\r
70 "-menu <menu_path> launch a custom program on exit instead of default gp2xmenu\n"
\r
71 "-state <param> pass '-state param' to the menu program\n"
\r
72 "-config <file> use specified config file instead of default 'picoconfig.bin'\n"
\r
73 " see currentConfig_t structure in emu.h for the file format\n"
\r
74 "-selectexit pressing SELECT will exit the emu and start 'menu_path'\n");
\r
79 int main(int argc, char *argv[])
\r
83 emu_ReadConfig(0, 0);
\r
85 if (currentConfig.EmuOpt&0x10) {
\r
86 int ret = mmuhack();
\r
87 printf("squidge hack code finished and returned %i\n", ret); fflush(stdout);
\r
88 mmuhack_status = ret;
\r
93 if (currentConfig.EmuOpt&0x100) {
\r
94 printf("setting RAM timings.. "); fflush(stdout);
\r
95 // craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2
\r
96 set_RAM_Timings(6, 4, 1, 1, 1, 2, 2);
\r
97 printf("done.\n"); fflush(stdout);
\r
103 engineState = PGS_Menu;
\r
106 parse_cmd_line(argc, argv);
\r
110 switch (engineState)
\r
116 case PGS_ReloadRom:
\r
117 if (emu_ReloadRom())
\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
144 sharedmem_deinit();
\r