refactoring for Wiz port; random cleanups
[libpicofe.git] / gp2x / main.c
index 0ea8e82..2eed35b 100644 (file)
@@ -10,7 +10,6 @@
 #include <strings.h>\r
 #include <linux/limits.h>\r
 \r
-#include "gp2x.h"\r
 #include "../common/menu.h"\r
 #include "../common/emu.h"\r
 #include "../common/config.h"\r
@@ -24,8 +23,6 @@
 #include "cpuctrl.h"\r
 \r
 \r
-extern char *ext_menu, *ext_state;\r
-extern int select_exits;\r
 extern char *PicoConfigFile;\r
 static int load_state_slot = -1;\r
 int mmuhack_status = 0;\r
@@ -35,24 +32,15 @@ void parse_cmd_line(int argc, char *argv[])
 {\r
        int x, unrecognized = 0;\r
 \r
-       for(x = 1; x < argc; x++)\r
+       for (x = 1; x < argc; x++)\r
        {\r
-               if(argv[x][0] == '-')\r
+               if (argv[x][0] == '-')\r
                {\r
-                       if(strcasecmp(argv[x], "-menu") == 0) {\r
-                               if(x+1 < argc) { ++x; ext_menu = argv[x]; } /* External Frontend: Program Name */\r
+                       if (strcasecmp(argv[x], "-config") == 0) {\r
+                               if (x+1 < argc) { ++x; PicoConfigFile = argv[x]; }\r
                        }\r
-                       else if(strcasecmp(argv[x], "-state") == 0) {\r
-                               if(x+1 < argc) { ++x; ext_state = argv[x]; } /* External Frontend: Arguments */\r
-                       }\r
-                       else if(strcasecmp(argv[x], "-config") == 0) {\r
-                               if(x+1 < argc) { ++x; PicoConfigFile = argv[x]; }\r
-                       }\r
-                       else if(strcasecmp(argv[x], "-selectexit") == 0) {\r
-                               select_exits = 1;\r
-                       }\r
-                       else if(strcasecmp(argv[x], "-loadstate") == 0) {\r
-                               if(x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }\r
+                       else if (strcasecmp(argv[x], "-loadstate") == 0) {\r
+                               if (x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }\r
                        }\r
                        else {\r
                                unrecognized = 1;\r
@@ -72,15 +60,11 @@ void parse_cmd_line(int argc, char *argv[])
        }\r
 \r
        if (unrecognized) {\r
-               printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2008\n");\r
+               printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2009\n");\r
                printf("usage: %s [options] [romfile]\n", argv[0]);\r
-               printf( "options:\n"\r
-                               "-menu <menu_path> launch a custom program on exit instead of default gp2xmenu\n"\r
-                               "-state <param>    pass '-state param' to the menu program\n"\r
-                               "-config <file>    use specified config file instead of default 'picoconfig.bin'\n"\r
-                               "                  see currentConfig_t structure in emu.h for the file format\n"\r
-                               "-selectexit       pressing SELECT will exit the emu and start 'menu_path'\n"\r
-                               "-loadstate <num>  if ROM is specified, try loading slot <num>\n");\r
+               printf("options:\n"\r
+                       " -config <file>    use specified config file instead of default 'config.cfg'\n"\r
+                       " -loadstate <num>  if ROM is specified, try loading slot <num>\n");\r
        }\r
 }\r
 \r
@@ -89,22 +73,22 @@ int main(int argc, char *argv[])
 {\r
        g_argv = argv;\r
 \r
+       /* in_init() must go before config, config accesses in_ fwk */\r
        in_init();\r
        emu_prepareDefaultConfig();\r
        emu_ReadConfig(0, 0);\r
        config_readlrom(PicoConfigFile);\r
 \r
+       plat_init();\r
        in_probe();\r
        in_debug_dump();\r
-       gp2x_init();\r
+\r
        if (currentConfig.EmuOpt&0x10) {\r
                int ret = mmuhack();\r
                printf("squidge hack code finished and returned %i\n", ret); fflush(stdout);\r
                mmuhack_status = ret;\r
        }\r
        cpuctrl_init();\r
-       // Reset940(1);\r
-       // Pause940(1);\r
        if (currentConfig.EmuOpt&0x100) {\r
                printf("setting RAM timings.. "); fflush(stdout);\r
                // craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2\r
@@ -169,8 +153,8 @@ int main(int argc, char *argv[])
        emu_Deinit();\r
        sharedmem_deinit();\r
        cpuctrl_deinit();\r
-       gp2x_deinit();\r
-       if(mmuhack_status)\r
+       plat_finish();\r
+       if (mmuhack_status)\r
                mmuunhack();\r
 \r
        return 0;\r