X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=platform%2Fcommon%2Fmain.c;h=526766762f0ca8c163f60a6b8bc0863ed7b195f6;hb=refs%2Fremotes%2Fgithub%2Fmaster;hp=bdcdc1428e30af72c10d36bc625f02ebb2485ae3;hpb=b24e0f6ce6e8a59ba43597520709ca79fa36ff8e;p=picodrive.git diff --git a/platform/common/main.c b/platform/common/main.c index bdcdc142..8e6987e4 100644 --- a/platform/common/main.c +++ b/platform/common/main.c @@ -1,22 +1,26 @@ -// (c) Copyright 2006-2009 notaz, All rights reserved. -// Free for non-commercial use. - -// For commercial use, separate licencing terms must be obtained. +/* + * PicoDrive + * (C) notaz, 2006-2010 + * + * This work is licensed under the terms of MAME license. + * See COPYING file in the top-level directory. + */ #include #include #include #include +#ifdef USE_SDL +#include +#endif -#include "menu.h" +#include "../libpicofe/input.h" +#include "../libpicofe/plat.h" +#include "menu_pico.h" #include "emu.h" -#include "config.h" -#include "input.h" -#include "plat.h" -#include - +#include "version.h" +#include -extern char *PicoConfigFile; static int load_state_slot = -1; char **g_argv; @@ -24,39 +28,46 @@ void parse_cmd_line(int argc, char *argv[]) { int x, unrecognized = 0; - for (x = 1; x < argc; x++) + for (x = 1; x < argc && !unrecognized; x++) { if (argv[x][0] == '-') { if (strcasecmp(argv[x], "-config") == 0) { if (x+1 < argc) { ++x; PicoConfigFile = argv[x]; } } - else if (strcasecmp(argv[x], "-loadstate") == 0) { + else if (strcasecmp(argv[x], "-loadstate") == 0 + || strcasecmp(argv[x], "-load") == 0) + { if (x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); } } + else if (strcasecmp(argv[x], "-pdb") == 0) { + if (x+1 < argc) { ++x; pdb_command(argv[x]); } + } + else if (strcasecmp(argv[x], "-pdb_connect") == 0) { + if (x+2 < argc) { pdb_net_connect(argv[x+1], argv[x+2]); x += 2; } + } else { - unrecognized = 1; - break; + unrecognized = plat_parse_arg(argc, argv, &x); } } else { - /* External Frontend: ROM Name */ - FILE *f; - 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; + FILE *f = fopen(argv[x], "rb"); + if (f) { + fclose(f); + rom_fname_reload = argv[x]; + } + else + unrecognized = 1; break; } } if (unrecognized) { - printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2009\n"); + printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2009,2013\n"); printf("usage: %s [options] [romfile]\n", argv[0]); printf("options:\n" " -config use specified config file instead of default 'config.cfg'\n" - " -loadstate if ROM is specified, try loading slot \n"); + " -loadstate if ROM is specified, try loading savestate slot \n"); + exit(1); } } @@ -67,26 +78,27 @@ int main(int argc, char *argv[]) plat_early_init(); - /* in_init() must go before config, config accesses in_ fwk */ in_init(); - pemu_prep_defconfig(); - emu_read_config(0, 0); - config_readlrom(PicoConfigFile); + //in_probe(); - plat_init(); - in_probe(); - in_debug_dump(); + plat_target_init(); + if (argc > 1) + parse_cmd_line(argc, argv); - emu_init(); + plat_init(); menu_init(); - engineState = PGS_Menu; + emu_prep_defconfig(); // depends on input + emu_read_config(NULL, 0); - if (argc > 1) - parse_cmd_line(argc, argv); + emu_init(); + + engineState = rom_fname_reload ? PGS_ReloadRom : PGS_Menu; + plat_video_menu_enter(0); if (engineState == PGS_ReloadRom) { + plat_video_menu_begin(); if (emu_reload_rom(rom_fname_reload)) { engineState = PGS_Running; if (load_state_slot >= 0) { @@ -94,7 +106,9 @@ int main(int argc, char *argv[]) emu_save_load_game(1, 0); } } + plat_video_menu_end(); } + plat_video_menu_leave(); for (;;) { @@ -104,6 +118,10 @@ int main(int argc, char *argv[]) menu_loop(); break; + case PGS_TrayMenu: + menu_loop_tray(); + break; + case PGS_ReloadRom: if (emu_reload_rom(rom_fname_reload)) engineState = PGS_Running; @@ -115,9 +133,16 @@ int main(int argc, char *argv[]) case PGS_RestartRun: engineState = PGS_Running; + /* vvv fallthrough */ case PGS_Running: +#ifdef GPERF + ProfilerStart("gperf.out"); +#endif emu_loop(); +#ifdef GPERF + ProfilerStop(); +#endif break; case PGS_Quit: @@ -133,6 +158,7 @@ int main(int argc, char *argv[]) emu_finish(); plat_finish(); + plat_target_finish(); return 0; }