X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fgp2x%2Fmain.c;h=6a31f9d71c16165a61dc7e0fe9ffdaca17b41b7c;hb=b547bda76671cf9c99973dd3faad97804949ced3;hp=95ed4bd5cd41108498ee9007759181765e036d7d;hpb=d97315ac0bca825d2d50a44453bc5652946e2c67;p=fceu.git diff --git a/drivers/gp2x/main.c b/drivers/gp2x/main.c index 95ed4bd..6a31f9d 100644 --- a/drivers/gp2x/main.c +++ b/drivers/gp2x/main.c @@ -1,7 +1,4 @@ /* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Ben Parnell * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,11 +15,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* This file contains or coordinates all of the code necessary to compile - on a UNIX system that can use svgalib, such as FreeBSD and Linux. - This code is not guaranteed to compile on FreeBSD, though. -*/ - #include #include @@ -37,6 +29,8 @@ #include "main.h" #include "throttle.h" +#include "menu.h" +#include "gp2x.h" #include "../common/config.h" #include "../common/args.h" @@ -45,16 +39,22 @@ #include "dface.h" +// just for printing some iNES info for user.. +#include "../../fce.h" +#include "../../ines.h" + +// internals +extern char lastLoadedGameName[2048]; +extern uint8 Exit; // exit emu loop flag +void CloseGame(void); + +FCEUGI *fceugi = NULL; static int ntsccol=0,ntschue=-1,ntsctint=-1; int soundvol=70; int inited=0; -int swapbuttons=0; -int showfps=0; int srendlinev[2]={0,0}; -//int srendlinev[2]={0,0}; int erendlinev[2]={239,239}; -//int erendlinev[2]={231,239}; int srendline,erendline; @@ -119,23 +119,28 @@ static CFGSTRUCT fceuconfig[]={ AC(eoptions), ACA(srendlinev), ACA(erendlinev), + ACA(lastLoadedGameName), ADDCFGSTRUCT(DriverConfig), ENDCFGSTRUCT }; -static void SaveConfig(void) +void SaveConfig(const char *name) { char tdir[2048]; - sprintf(tdir,"%s"PSS"fceu.cfg",BaseDirectory); + if (name) + sprintf(tdir,"%s"PSS"cfg"PSS"%s.cfg",BaseDirectory,name); + else sprintf(tdir,"%s"PSS"fceu2.cfg",BaseDirectory); DriverInterface(DES_GETNTSCTINT,&ntsctint); DriverInterface(DES_GETNTSCHUE,&ntschue); SaveFCEUConfig(tdir,fceuconfig); } -static void LoadConfig(void) +static void LoadConfig(const char *name) { char tdir[2048]; - sprintf(tdir,"%s"PSS"fceu.cfg",BaseDirectory); + if (name) + sprintf(tdir,"%s"PSS"cfg"PSS"%s.cfg",BaseDirectory,name); + else sprintf(tdir,"%s"PSS"fceu2.cfg",BaseDirectory); LoadFCEUConfig(tdir,fceuconfig); if(ntsctint>=0) DriverInterface(DES_SETNTSCTINT,&ntsctint); if(ntschue>=0) DriverInterface(DES_SETNTSCHUE,&ntschue); @@ -143,12 +148,12 @@ static void LoadConfig(void) static void CreateDirs(void) { - char *subs[5]={"fcs","snaps","gameinfo","sav","cheats"}; + char *subs[]={"fcs","snaps","gameinfo","sav","cheats","cfg"}; char tdir[2048]; int x; mkdir(BaseDirectory,S_IRWXU); - for(x=0;x<5;x++) + for(x=0;x 1 && !last_arg_parsed) + { + strncpy(lastLoadedGameName, argv[argc-1], sizeof(lastLoadedGameName)); + lastLoadedGameName[sizeof(lastLoadedGameName)-1] = 0; + Exit = 0; + } + else + { + Exit = 1; + } + + while (1) + { + if(!Exit) + { + if (fceugi) + CloseGame(); + fceugi=FCEUI_LoadGame(lastLoadedGameName); + if (fceugi) + { + LoadConfig(lastLoadedGameName); + ParseGI(fceugi); + //RefreshThrottleFPS(); + InitOtherInput(); + + // additional print for gpfce + // TODO: handlers for other formats then iNES + { + int MapperNo; + iNES_HEADER *head = iNESGetHead(); + MapperNo = (head->ROM_type>>4); + MapperNo|=(head->ROM_type2&0xF0); + FCEU_DispMessage("%s, Mapper: %d%s%s", PAL?"PAL":"NTSC", MapperNo, (head->ROM_type&2)?", BB":"", (head->ROM_type&4)?", T":""); + } + } + else + strcpy(menuErrorMsg, "failed to load ROM"); + } + if(Exit || !fceugi) + { + int ret; + ret = gp2x_menu_do(); + if (ret == 1) break; // exit emu + if (ret == 2) { // reload ROM + Exit = 0; + continue; + } + } + + gp2x_video_changemode(Settings.scaling == 3 ? 15 : 8); + gp2x_video_RGB_setscaling(0, 320, 240); + gp2x_start_sound(22050, 16, 0); + FCEUI_Emulate(); + } + + if (fceugi) + CloseGame(); - dk: DriverKill(); - return(ret?0:1); + return 0; } static int DriverInitialize(void) @@ -358,7 +411,7 @@ static int DriverInitialize(void) static void DriverKill(void) { - SaveConfig(); + SaveConfig(NULL); SetSignals(SIG_IGN); if(inited&2)