X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=drivers%2Fgp2x%2Fmain.c;fp=drivers%2Fgp2x%2Fmain.c;h=0000000000000000000000000000000000000000;hp=091fc835e13aefea7f9d9b9ee60fb84b425456d2;hb=4a2a617ac879a95babe3b8a822188b71e9769ba4;hpb=396c448eb538587248ddbf586a90371c71b48183 diff --git a/drivers/gp2x/main.c b/drivers/gp2x/main.c deleted file mode 100644 index 091fc83..0000000 --- a/drivers/gp2x/main.c +++ /dev/null @@ -1,508 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../common/main.h" -#include "minimal.h" -#include "throttle.h" -#include "menu.h" -#include "gp2x.h" - -#include "../common/config.h" -#include "../common/args.h" -#include "../common/unixdsp.h" -#include "../common/cheat.h" - -#include "../../fce.h" -#include "../../cart.h" - -#include "dface.h" - - -void CleanSurface(void); - -// internals -extern char lastLoadedGameName[2048]; -extern uint8 Exit; // exit emu loop flag -extern int FSkip; -void CloseGame(void); - -FCEUGI *fceugi = NULL; -int ntsccol=0,ntschue=-1,ntsctint=-1; -int soundvol=70; -int inited=0; - -int srendlinev[2]={8,0}; -int erendlinev[2]={231,239}; -int srendline,erendline; - - -static char BaseDirectory[2048]; - -int eoptions=0; - -static void DriverKill(void); -static int DriverInitialize(void); - -static int gametype; -#include "input.c" - -static void ParseGI(FCEUGI *gi) -{ - gametype=gi->type; - - InputType[0]=UsrInputType[0]; - InputType[1]=UsrInputType[1]; - InputTypeFC=UsrInputTypeFC; - - if(gi->input[0]>=0) - InputType[0]=gi->input[0]; - if(gi->input[1]>=0) - InputType[1]=gi->input[1]; - if(gi->inputfc>=0) - InputTypeFC=gi->inputfc; -} - -void FCEUD_PrintError(char *s) -{ - puts(s); -} - -char *cpalette=0; -void LoadCPalette(void) -{ - char tmpp[192]; - FILE *fp; - - if(!(fp=fopen(cpalette,"rb"))) - { - printf(" Error loading custom palette from file: %s\n",cpalette); - free(cpalette); - cpalette=0; - return; - } - fread(tmpp,1,192,fp); - FCEUI_SetPaletteArray((uint8 *)tmpp); - fclose(fp); -} - -static CFGSTRUCT fceuconfig[]={ - AC(soundvol), - ACS(cpalette), - AC(ntsctint), - AC(ntschue), - AC(ntsccol), - AC(UsrInputTypeFC), - ACA(UsrInputType), - AC(powerpadside), - AC(powerpadsc), - AC(eoptions), - ACA(srendlinev), - ACA(erendlinev), - ADDCFGSTRUCT(DriverConfig), - ENDCFGSTRUCT -}; - -static const char *skip_path(const char *path) -{ - const char *p; - if (path == NULL) return NULL; - for (p = path+strlen(path)-1; p > path && *p != '/'; p--); - if (*p == '/') p++; - return p; -} - -int SaveConfig(const char *llgn_path) -{ - const char *name = skip_path(llgn_path); - char tdir[2048]; - int ret; - if (name) - sprintf(tdir,"%s"PSS"cfg"PSS"%s.cfg",BaseDirectory,name); - else sprintf(tdir,"%s"PSS"fceu2.cfg",BaseDirectory); - printf("saving cfg to %s ... ", tdir); fflush(stdout); - FCEUI_GetNTSCTH(&ntsctint, &ntschue); - ret=SaveFCEUConfig(tdir,fceuconfig); - printf(ret == 0 ? "done\n" : "failed\n"); - return ret; -} - -static int LoadConfig(const char *llgn_path) -{ - const char *name = skip_path(llgn_path); - char tdir[2048]; - int ret; - if (name) - sprintf(tdir,"%s"PSS"cfg"PSS"%s.cfg",BaseDirectory,name); - else sprintf(tdir,"%s"PSS"fceu2.cfg",BaseDirectory); - printf("loading cfg from %s ... ", tdir); fflush(stdout); - FCEUI_GetNTSCTH(&ntsctint, &ntschue); /* Get default settings for if no config file exists. */ - ret=LoadFCEUConfig(tdir,fceuconfig); - FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue); - printf(ret == 0 ? "done\n" : "failed\n"); - return ret; -} - -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] && !(eoptions&EO_NOAUTOWRITE)) - { - 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[]={"fcs","snaps","gameinfo","sav","cheats","cfg","pal"}; - char tdir[2048]; - int x; - - mkdir(BaseDirectory,S_IRWXU); - for(x=0;x239) srendlinev[x]=0; - if(erendlinev[x]239) erendlinev[x]=239; - } - - FCEUI_SetRenderedLines(srendlinev[0],erendlinev[0],srendlinev[1],erendlinev[1]); - FCEUI_SetSoundVolume(80); - DoDriverArgs(); - - if(fcexp) - { - int y; - for(y=0;y<5;y++) - { - if(!strncmp(fccortab[y],fcexp,8)) - { - UsrInputTypeFC=fccortabi[y]; - break; - } - } - free(fcexp); - } - for(x=0;x<2;x++) - { - int y; - - if(!inputa[x]) - continue; - - for(y=0;y<5;y++) - { - if(!strncmp(cortab[y],inputa[x],8)) - { - UsrInputType[x]=cortabi[y]; - if(y==3) - { - powerpadside&=~(1< 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(); - ret=LoadConfig(lastLoadedGameName); - if (ret != 0) - { - LoadConfig(NULL); - } - FCEUI_SetEmuMode(Settings.accurate_mode); - fceugi=FCEUI_LoadGame(lastLoadedGameName); - if (fceugi) - { - char infostring[32]; - if (Settings.region_force) - FCEUI_SetVidSystem(Settings.region_force - 1); - ParseGI(fceugi); - InitOtherInput(); - - if ((eoptions&EO_GG) && geniestage == 0) { - strcpy(infostring, "gg.rom is missing, GG disabled"); - eoptions&=~EO_GG; - FCEUI_SetGameGenie(0); - } else - GameInterface(GI_INFOSTRING, infostring); - FCEU_DispMessage("%s", infostring); - } - else - { - switch(LoadGameLastError) { - default: strcpy(menuErrorMsg, "failed to load ROM"); break; - case 2: strcpy(menuErrorMsg, "Can't find a ROM for ips/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) - { - int ret; - ret = gp2x_menu_do(); - if (ret == 1) break; // exit emu - if (ret == 2) { // reload ROM - Exit = 0; - continue; - } - } - - gp2x_opt_update(); - PrepareOtherInput(); - FCEUI_GetCurrentVidSystem(&srendline,&erendline); - gp2x_video_changemode(Settings.scaling == 3 ? 15 : 8); - switch (Settings.scaling & 3) { - case 0: gp2x_video_set_offs(0); gp2x_video_RGB_setscaling(320, 240); break; - case 1: gp2x_video_set_offs(32); gp2x_video_RGB_setscaling(256, 240); break; - case 2: gp2x_video_set_offs(32+srendline*320); gp2x_video_RGB_setscaling(256, erendline-srendline); break; - case 3: gp2x_video_set_offs(32); gp2x_video_RGB_setscaling(320, 240); break; - } - CleanSurface(); - gp2x_start_sound(Settings.sound_rate, 16, 0); - RefreshThrottleFPS(); - FCEUI_Emulate(); - } - - if (fceugi) - CloseGame(); - - SaveLLGN(); - FCEUI_Kill(); - DriverKill(); - return 0; -} - -static int DriverInitialize(void) -{ - SetSignals((void *)CloseStuff); - - if(!InitVideo()) return 0; - inited|=4; - return 1; -} - -static void DriverKill(void) -{ - // SaveConfig(NULL); // done explicitly in menu now - SetSignals(SIG_DFL); - - if(cpalette) free(cpalette); - cpalette=0; - - if(inited&4) - KillVideo(); - if(inited&1) - KillSound(); - inited=0; -} - -void FCEUD_Update(uint8 *xbuf, int16 *Buffer, int Count) -{ - FCEUD_UpdateInput(); // must update input before blitting because of save confirmation stuff - BlitPrepare(xbuf == NULL); - if(!(eoptions&EO_NOTHROTTLE)) - { - if(Count) - WriteSound(Buffer,Count); - SpeedThrottle(); - } - BlitScreen(xbuf == NULL); - // make sure last frame won't get skipped, because we need it for menu bg - if (Exit) FSkip=0; -} -