X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pandora%2Fmain.c;h=51f7f8e84758f774a0e16d129b0189be8d4ae8a2;hb=049a6b3e80151f6a5af726e25478ed15e111dfcc;hp=8261446bd3e07e7cf2b24ea1bb0bf5071e3101ce;hpb=fe01739339fe177363948c6fd518352243d5cf37;p=libpicofe.git diff --git a/pandora/main.c b/pandora/main.c index 8261446..51f7f8e 100644 --- a/pandora/main.c +++ b/pandora/main.c @@ -4,6 +4,7 @@ // For commercial use, separate licencing terms must be obtained. #include +#include #include #include #include @@ -14,13 +15,14 @@ #include "../common/menu.h" #include "../common/emu.h" #include "../common/config.h" +#include "../common/input.h" #include "../gp2x/emu.h" #include "../gp2x/version.h" -extern char *ext_menu, *ext_state; extern int select_exits; extern char *PicoConfigFile; +static int load_state_slot = -1; int mmuhack_status = 0; // TODO rm char **g_argv; @@ -32,18 +34,15 @@ void parse_cmd_line(int argc, char *argv[]) { if(argv[x][0] == '-') { - if(strcasecmp(argv[x], "-menu") == 0) { - if(x+1 < argc) { ++x; ext_menu = argv[x]; } /* External Frontend: Program Name */ - } - else if(strcasecmp(argv[x], "-state") == 0) { - if(x+1 < argc) { ++x; ext_state = argv[x]; } /* External Frontend: Arguments */ - } - else if(strcasecmp(argv[x], "-config") == 0) { + if(strcasecmp(argv[x], "-config") == 0) { if(x+1 < argc) { ++x; PicoConfigFile = argv[x]; } } else if(strcasecmp(argv[x], "-selectexit") == 0) { select_exits = 1; } + else if(strcasecmp(argv[x], "-loadstate") == 0) { + if(x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); } + } else { unrecognized = 1; break; @@ -51,9 +50,9 @@ void parse_cmd_line(int argc, char *argv[]) } else { /* External Frontend: ROM Name */ FILE *f; - strncpy(romFileName, argv[x], PATH_MAX); - romFileName[PATH_MAX-1] = 0; - f = fopen(romFileName, "rb"); + strncpy(rom_fname_reload, argv[x], PATH_MAX); + rom_fname_reload[PATH_MAX-1] = 0; + f = fopen(rom_fname_reload, "rb"); if (f) fclose(f); else unrecognized = 1; engineState = PGS_ReloadRom; @@ -69,7 +68,8 @@ void parse_cmd_line(int argc, char *argv[]) "-state pass '-state param' to the menu program\n" "-config use specified config file instead of default 'picoconfig.bin'\n" " see currentConfig_t structure in emu.h for the file format\n" - "-selectexit pressing SELECT will exit the emu and start 'menu_path'\n"); + "-selectexit pressing SELECT will exit the emu and start 'menu_path'\n" + "-loadstate if ROM is specified, try loading slot \n"); } } @@ -78,10 +78,13 @@ int main(int argc, char *argv[]) { g_argv = argv; + in_init(); emu_prepareDefaultConfig(); emu_ReadConfig(0, 0); config_readlrom(PicoConfigFile); + in_probe(); + in_debug_dump(); gp2x_init(); emu_Init(); menu_init(); @@ -91,6 +94,17 @@ int main(int argc, char *argv[]) if (argc > 1) parse_cmd_line(argc, argv); + if (engineState == PGS_ReloadRom) + { + if (emu_ReloadRom(rom_fname_reload)) { + engineState = PGS_Running; + if (load_state_slot >= 0) { + state_slot = load_state_slot; + emu_SaveLoadGame(1, 0); + } + } + } + for (;;) { switch (engineState) @@ -100,7 +114,7 @@ int main(int argc, char *argv[]) break; case PGS_ReloadRom: - if (emu_ReloadRom()) + if (emu_ReloadRom(rom_fname_reload)) engineState = PGS_Running; else { printf("PGS_ReloadRom == 0\n");