X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fgp2x%2Fmain.c;h=50210f66d641cf1f688f38f7e427196e5db371ce;hb=e163b67f960e11d7c1ac8c6cd46a39d765ecd659;hp=e4e3bcfa66361ab976dc42c8cc5a8e30bc414f1e;hpb=a12e01162349cd970e9b6fe5674497760631279b;p=picodrive.git diff --git a/platform/gp2x/main.c b/platform/gp2x/main.c index e4e3bcf..50210f6 100644 --- a/platform/gp2x/main.c +++ b/platform/gp2x/main.c @@ -4,6 +4,7 @@ // For commercial use, separate licencing terms must be obtained. #include +#include #include #include #include @@ -11,6 +12,9 @@ #include "gp2x.h" #include "menu.h" +#include "../common/menu.h" +#include "../common/emu.h" +#include "../common/config.h" #include "emu.h" #include "940ctl.h" #include "version.h" @@ -22,6 +26,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; @@ -45,6 +50,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; @@ -63,14 +71,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"); } } @@ -79,7 +88,10 @@ int main(int argc, char *argv[]) { g_argv = argv; + emu_prepareDefaultConfig(); emu_ReadConfig(0, 0); + config_readlrom(PicoConfigFile); + gp2x_init(); if (currentConfig.EmuOpt&0x10) { int ret = mmuhack(); @@ -104,6 +116,17 @@ int main(int argc, char *argv[]) if (argc > 1) parse_cmd_line(argc, argv); + if (engineState == PGS_ReloadRom) + { + if (emu_ReloadRom()) { + engineState = PGS_Running; + if (load_state_slot >= 0) { + state_slot = load_state_slot; + emu_SaveLoadGame(1, 0); + } + } + } + for (;;) { switch (engineState)