From: notaz Date: Fri, 1 Jun 2007 22:32:48 +0000 (+0000) Subject: fixed: broken fs0, sram saves X-Git-Tag: r1~39 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a6855a31daf79cad83545b1eeee646e10481e5e;p=fceu.git fixed: broken fs0, sram saves git-svn-id: file:///home/notaz/opt/svn/fceu@143 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/cart.c b/cart.c index 742f9b0..0dd8fee 100644 --- a/cart.c +++ b/cart.c @@ -22,6 +22,10 @@ #include #include +#ifdef GP2X +#include // for sync() +#endif + #include "types.h" #include "fce.h" #include "ppu.h" @@ -683,6 +687,10 @@ void FCEU_SaveGameSave(CartInfo *LocalHWInfo) fwrite(LocalHWInfo->SaveGame[x],1, LocalHWInfo->SaveGameLen[x],sp); } + fclose(sp); +#ifdef GP2X + sync(); +#endif } free(soot); } @@ -706,6 +714,7 @@ void FCEU_LoadGameSave(CartInfo *LocalHWInfo) for(x=0;x<4;x++) if(LocalHWInfo->SaveGame[x]) fread(LocalHWInfo->SaveGame[x],1,LocalHWInfo->SaveGameLen[x],sp); + fclose(sp); } free(soot); } diff --git a/drivers/gp2x/main.c b/drivers/gp2x/main.c index caea8cc..3f4dff9 100644 --- a/drivers/gp2x/main.c +++ b/drivers/gp2x/main.c @@ -43,8 +43,6 @@ #include "dface.h" -// TODO! broken fs0, sram saves - void CleanSurface(void); // internals @@ -393,7 +391,6 @@ int CLImain(int argc, char *argv[]) if (Settings.region_force) FCEUI_SetVidSystem(Settings.region_force - 1); ParseGI(fceugi); - //RefreshThrottleFPS(); InitOtherInput(); GameInterface(GI_INFOSTRING, infostring); @@ -421,6 +418,7 @@ int CLImain(int argc, char *argv[]) } PrepareOtherInput(); + RefreshThrottleFPS(); FCEUI_GetCurrentVidSystem(&srendline,&erendline); gp2x_video_changemode(Settings.scaling == 3 ? 15 : 8); switch (Settings.scaling & 3) { diff --git a/drivers/gp2x/throttle.c b/drivers/gp2x/throttle.c index b6b628c..c52eb68 100644 --- a/drivers/gp2x/throttle.c +++ b/drivers/gp2x/throttle.c @@ -3,57 +3,18 @@ #include "gp2x.h" #include "throttle.h" -#if 0 -static uint64 tfreq; -static uint64 desiredfps; - -void RefreshThrottleFPS(void) -{ - uint64 f=FCEUI_GetDesiredFPS(); - // great, a bit faster than before - //f = (f*65) >> 6; - desiredfps=f>>8; - tfreq=1000000; - tfreq<<=16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */ -} - -static uint64 GetCurTime(void) -{ - uint64 ret; - struct timeval tv; - - gettimeofday(&tv,0); - ret=(uint64)tv.tv_sec*1000000; - ret+=tv.tv_usec; - return(ret); -} - -INLINE void SpeedThrottle(void) -{ - static uint64 ttime,ltime; - - waiter: - - ttime=GetCurTime(); - - if( (ttime-ltime) < (tfreq/desiredfps) ) - { - goto waiter; - } - if( (ttime-ltime) >= (tfreq*4/desiredfps)) - ltime=ttime; - else - ltime+=tfreq/desiredfps; -} - -#else extern uint8 PAL; extern int FSkip; static int usec_aim = 0, usec_done = 0; static int skip_count = 0; -INLINE void SpeedThrottle(void) +void RefreshThrottleFPS(void) +{ + usec_aim = usec_done = skip_count = 0; +} + +void SpeedThrottle(void) { static struct timeval tv_prev; struct timeval tv_now; @@ -108,5 +69,4 @@ INLINE void SpeedThrottle(void) usec_done = usec_done - usec_aim + 1; // reset to prevent overflows usec_aim = 0; } -#endif diff --git a/fds.c b/fds.c index e5e4d5b..e5307ac 100644 --- a/fds.c +++ b/fds.c @@ -22,6 +22,10 @@ #include #include +#ifdef GP2X +#include // for sync() +#endif + #include "types.h" #include "x6502.h" #include "fce.h" @@ -911,10 +915,12 @@ void FDSClose(void) { FILE *fp; int x; - char *fn=FCEU_MakeFName(FCEUMKF_FDS,0,0); + char *fn; if(!DiskWritten) return; + fn=FCEU_MakeFName(FCEUMKF_FDS,0,0); + if(!(fp=FCEUD_UTF8fopen(fn,"wb"))) { free(fn); @@ -933,4 +939,8 @@ void FDSClose(void) } FreeFDSMemory(); fclose(fp); +#ifdef GP2X + sync(); +#endif } +