X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=platform%2Fpandora%2Fmain.c;fp=platform%2Fpandora%2Fmain.c;h=8261446bd3e07e7cf2b24ea1bb0bf5071e3101ce;hb=3a3947cd905ca45447ea4ea0aca45cdf0f79a47a;hp=0000000000000000000000000000000000000000;hpb=6bae2e90d459dcbff157252ddfa7b87d25b8309f;p=picodrive.git diff --git a/platform/pandora/main.c b/platform/pandora/main.c new file mode 100644 index 0000000..8261446 --- /dev/null +++ b/platform/pandora/main.c @@ -0,0 +1,132 @@ +// (c) Copyright 2006 notaz, All rights reserved. +// Free for non-commercial use. + +// For commercial use, separate licencing terms must be obtained. + +#include +#include +#include +#include +#include + +#include "../gp2x/gp2x.h" +#include "../gp2x/menu.h" +#include "../common/menu.h" +#include "../common/emu.h" +#include "../common/config.h" +#include "../gp2x/emu.h" +#include "../gp2x/version.h" + + +extern char *ext_menu, *ext_state; +extern int select_exits; +extern char *PicoConfigFile; +int mmuhack_status = 0; // TODO rm +char **g_argv; + +void parse_cmd_line(int argc, char *argv[]) +{ + int x, unrecognized = 0; + + for(x = 1; x < argc; x++) + { + 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(x+1 < argc) { ++x; PicoConfigFile = argv[x]; } + } + else if(strcasecmp(argv[x], "-selectexit") == 0) { + select_exits = 1; + } + else { + unrecognized = 1; + break; + } + } else { + /* External Frontend: ROM Name */ + FILE *f; + strncpy(romFileName, argv[x], PATH_MAX); + romFileName[PATH_MAX-1] = 0; + f = fopen(romFileName, "rb"); + if (f) fclose(f); + else unrecognized = 1; + engineState = PGS_ReloadRom; + break; + } + } + + if (unrecognized) { + 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"); + } +} + + +int main(int argc, char *argv[]) +{ + g_argv = argv; + + emu_prepareDefaultConfig(); + emu_ReadConfig(0, 0); + config_readlrom(PicoConfigFile); + + gp2x_init(); + emu_Init(); + menu_init(); + + engineState = PGS_Menu; + + if (argc > 1) + parse_cmd_line(argc, argv); + + for (;;) + { + switch (engineState) + { + case PGS_Menu: + menu_loop(); + break; + + case PGS_ReloadRom: + if (emu_ReloadRom()) + engineState = PGS_Running; + else { + printf("PGS_ReloadRom == 0\n"); + engineState = PGS_Menu; + } + break; + + case PGS_RestartRun: + engineState = PGS_Running; + + case PGS_Running: + emu_Loop(); + break; + + case PGS_Quit: + goto endloop; + + default: + printf("engine got into unknown state (%i), exitting\n", engineState); + goto endloop; + } + } + + endloop: + + emu_Deinit(); + + return 0; +}