X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=pandora%2Fmain.c;h=37a69feb7aaa51d0ffe338fb065825c0259e3478;hb=82abf46f3db8ade517881c03327bdbc0de848eb2;hp=55ece53f94c1d6d4819ef7e363fdda315aff549a;hpb=492d353af951b6a34a1f62d07ec64456b6e34600;p=libpicofe.git diff --git a/pandora/main.c b/pandora/main.c index 55ece53..37a69fe 100644 --- a/pandora/main.c +++ b/pandora/main.c @@ -4,23 +4,23 @@ // For commercial use, separate licencing terms must be obtained. #include +#include #include #include #include #include -#include "../gp2x/gp2x.h" -#include "../gp2x/menu.h" +#include "../gp2x/emu.h" // TODO rm #include "../common/menu.h" #include "../common/emu.h" #include "../common/config.h" -#include "../gp2x/emu.h" +#include "../common/input.h" #include "../gp2x/version.h" +#include "pandora.h" -extern int select_exits; extern char *PicoConfigFile; -int mmuhack_status = 0; // TODO rm +static int load_state_slot = -1; char **g_argv; void parse_cmd_line(int argc, char *argv[]) @@ -34,8 +34,8 @@ void parse_cmd_line(int argc, char *argv[]) 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; @@ -44,9 +44,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; @@ -55,14 +55,12 @@ void parse_cmd_line(int argc, char *argv[]) } if (unrecognized) { - printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2008\n"); + printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2009\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"); + "-loadstate if ROM is specified, try loading slot \n"); } } @@ -71,11 +69,14 @@ int main(int argc, char *argv[]) { g_argv = argv; + in_init(); emu_prepareDefaultConfig(); emu_ReadConfig(0, 0); config_readlrom(PicoConfigFile); - gp2x_init(); + in_probe(); + in_debug_dump(); + pnd_init(); emu_Init(); menu_init(); @@ -84,6 +85,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) @@ -93,7 +105,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"); @@ -120,6 +132,7 @@ int main(int argc, char *argv[]) endloop: emu_Deinit(); + pnd_exit(); return 0; }