X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fmain.c;h=6ac16b8f4d8fac53d2d6bce18dad2a1e5393e260;hb=fa8d133192876a802fbac43c0a0bfe4f5f85b682;hp=50210f66d641cf1f688f38f7e427196e5db371ce;hpb=f7c40368a7700e5f18993c71a7d77bfe768c4900;p=libpicofe.git diff --git a/gp2x/main.c b/gp2x/main.c index 50210f6..6ac16b8 100644 --- a/gp2x/main.c +++ b/gp2x/main.c @@ -1,4 +1,4 @@ -// (c) Copyright 2006 notaz, All rights reserved. +// (c) Copyright 2006-2009 notaz, All rights reserved. // Free for non-commercial use. // For commercial use, separate licencing terms must be obtained. @@ -6,52 +6,34 @@ #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" -#include "squidgehack.h" -#include "cpuctrl.h" - -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; void parse_cmd_line(int argc, char *argv[]) { int x, unrecognized = 0; - for(x = 1; x < argc; x++) + for (x = 1; x < argc; x++) { - if(argv[x][0] == '-') + 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; + if (strcasecmp(argv[x], "-config") == 0) { + if (x+1 < argc) { ++x; PicoConfigFile = argv[x]; } } - else if(strcasecmp(argv[x], "-loadstate") == 0) { - if(x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); } + else if (strcasecmp(argv[x], "-loadstate") == 0) { + if (x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); } } else { unrecognized = 1; @@ -60,9 +42,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; @@ -71,15 +53,11 @@ 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"); + printf("options:\n" + " -config use specified config file instead of default 'config.cfg'\n" + " -loadstate if ROM is specified, try loading slot \n"); } } @@ -88,26 +66,18 @@ int main(int argc, char *argv[]) { g_argv = argv; + plat_early_init(); + + /* in_init() must go before config, config accesses in_ fwk */ + in_init(); emu_prepareDefaultConfig(); emu_ReadConfig(0, 0); config_readlrom(PicoConfigFile); - gp2x_init(); - if (currentConfig.EmuOpt&0x10) { - int ret = mmuhack(); - printf("squidge hack code finished and returned %i\n", ret); fflush(stdout); - mmuhack_status = ret; - } - cpuctrl_init(); - // Reset940(1); - // Pause940(1); - if (currentConfig.EmuOpt&0x100) { - printf("setting RAM timings.. "); fflush(stdout); - // craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2 - set_RAM_Timings(6, 4, 1, 1, 1, 2, 2); - printf("done.\n"); fflush(stdout); - } - sharedmem_init(); + plat_init(); + in_probe(); + in_debug_dump(); + emu_Init(); menu_init(); @@ -118,7 +88,7 @@ int main(int argc, char *argv[]) if (engineState == PGS_ReloadRom) { - if (emu_ReloadRom()) { + if (emu_ReloadRom(rom_fname_reload)) { engineState = PGS_Running; if (load_state_slot >= 0) { state_slot = load_state_slot; @@ -136,7 +106,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"); @@ -163,11 +133,7 @@ int main(int argc, char *argv[]) endloop: emu_Deinit(); - sharedmem_deinit(); - cpuctrl_deinit(); - gp2x_deinit(); - if(mmuhack_status) - mmuunhack(); + plat_finish(); return 0; }