X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=drivers%2Fgp2x%2Fmain.c;h=a399e1ed44608148b4053ed9ccdc8b2a2987042a;hp=e9223f2b1d817f8008cc5192c6a68c55aac93b9d;hb=e328100eecae3adfce1c3b57364bee5d166217ef;hpb=b2b95d2e0d1fd5e52d03c2152605b09b024c1d0e diff --git a/drivers/gp2x/main.c b/drivers/gp2x/main.c index e9223f2..a399e1e 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 @@ -36,6 +28,7 @@ #include #include "main.h" +#include "minimal.h" #include "throttle.h" #include "menu.h" #include "gp2x.h" @@ -60,8 +53,6 @@ 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 erendlinev[2]={239,239}; @@ -129,37 +120,74 @@ 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); } +static void LoadLLGN(void) +{ + char tdir[2048]; + FILE *f; + int len; + sprintf(tdir,"%s"PSS"last_rom.txt",BaseDirectory); + f=fopen(tdir, "r"); + if(f) + { + len = fread(lastLoadedGameName, 1, sizeof(lastLoadedGameName)-1, f); + lastLoadedGameName[len] = 0; + fclose(f); + } +} + +static void SaveLLGN(void) +{ + // save last loaded game name + if (lastLoadedGameName[0]) + { + char tdir[2048]; + FILE *f; + sprintf(tdir,"%s"PSS"last_rom.txt",BaseDirectory); + f=fopen(tdir, "w"); + if(f) + { + fwrite(lastLoadedGameName, 1, strlen(lastLoadedGameName), f); + fclose(f); + sync(); + } + } +} + + 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;xROM_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"); + { + switch(LoadGameLastError) { + default: strcpy(menuErrorMsg, "failed to load ROM"); break; + case 2: strcpy(menuErrorMsg, "Can't find a ROM for movie"); break; + case 10: strcpy(menuErrorMsg, "FDS BIOS ROM is missing, read docs"); break; + case 11: strcpy(menuErrorMsg, "Error reading auxillary FDS file"); break; + } + } } if(Exit || !fceugi) { @@ -389,12 +427,22 @@ int CLImain(int argc, char *argv[]) } } + PrepareOtherInput(); gp2x_video_changemode(Settings.scaling == 3 ? 15 : 8); - gp2x_video_RGB_setscaling(0, 320, 240); - gp2x_start_sound(22050, 16, 0); + switch (Settings.scaling & 3) { + case 0: gp2x_video_RGB_setscaling(0, 320, 240); gp2x_video_set_offs(0); break; + case 1: gp2x_video_RGB_setscaling(0, 256, 240); gp2x_video_set_offs(32); break; + case 2: gp2x_video_RGB_setscaling(0, 256, 240); gp2x_video_set_offs(32); break; // TODO + case 3: gp2x_video_RGB_setscaling(0, 320, 240); gp2x_video_set_offs(32); break; + } + gp2x_start_sound(Settings.sound_rate, 16, 0); FCEUI_Emulate(); } + if (fceugi) + CloseGame(); + + SaveLLGN(); DriverKill(); return 0; } @@ -403,39 +451,29 @@ static int DriverInitialize(void) { SetSignals((void *)CloseStuff); - if(InitJoysticks()) - inited|=2; if(!InitVideo()) return 0; inited|=4; - if(!InitKeyboard()) return 0; - inited|=8; return 1; } static void DriverKill(void) { - SaveConfig(); + // SaveConfig(NULL); // done explicitly in menu now SetSignals(SIG_IGN); - if(inited&2) - KillJoysticks(); - if(inited&8) - KillKeyboard(); if(inited&4) KillVideo(); if(inited&1) KillSound(); - if(inited&16) - KillMouse(); inited=0; } void FCEUD_Update(uint8 *xbuf, int16 *Buffer, int Count) { - if(!Count && !NoWaiting && !(eoptions&EO_NOTHROTTLE)) + if(!Count && !(eoptions&EO_NOTHROTTLE)) SpeedThrottle(); BlitScreen(xbuf); - if(Count && !NoWaiting && !(eoptions&EO_NOTHROTTLE)) + if(Count && !(eoptions&EO_NOTHROTTLE)) WriteSound(Buffer,Count); FCEUD_UpdateInput(); }