X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fmain.c;h=0ea8e824c771f1df655311ca6e69a426d88d3a27;hb=82abf46f3db8ade517881c03327bdbc0de848eb2;hp=f016411d2ec69dd3cfb73fe8bae4b26fe8630dad;hpb=367b6f1f939dcd7930d372aee0ca900b0b8790b1;p=libpicofe.git diff --git a/gp2x/main.c b/gp2x/main.c index f016411..0ea8e82 100644 --- a/gp2x/main.c +++ b/gp2x/main.c @@ -4,16 +4,18 @@ // For commercial use, separate licencing terms must be obtained. #include +#include #include #include #include #include #include "gp2x.h" -#include "menu.h" #include "../common/menu.h" #include "../common/emu.h" #include "../common/config.h" +#include "../common/input.h" +#include "../common/plat.h" #include "emu.h" #include "940ctl.h" #include "version.h" @@ -25,6 +27,7 @@ extern char *ext_menu, *ext_state; extern int select_exits; extern char *PicoConfigFile; +static int load_state_slot = -1; int mmuhack_status = 0; char **g_argv; @@ -48,6 +51,9 @@ void parse_cmd_line(int argc, char *argv[]) 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; @@ -55,9 +61,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], sizeof(rom_fname_reload)); + rom_fname_reload[sizeof(rom_fname_reload) - 1] = 0; + f = fopen(rom_fname_reload, "rb"); if (f) fclose(f); else unrecognized = 1; engineState = PGS_ReloadRom; @@ -66,14 +72,15 @@ void parse_cmd_line(int argc, char *argv[]) } if (unrecognized) { - printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2007\n"); + printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2008\n"); printf("usage: %s [options] [romfile]\n", argv[0]); printf( "options:\n" "-menu launch a custom program on exit instead of default gp2xmenu\n" "-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"); } } @@ -82,10 +89,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(); if (currentConfig.EmuOpt&0x10) { int ret = mmuhack(); @@ -110,6 +120,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) @@ -119,7 +140,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");