frameskip, cleanups
authornotaz <notasas@gmail.com>
Sat, 7 Apr 2007 22:26:24 +0000 (22:26 +0000)
committernotaz <notasas@gmail.com>
Sat, 7 Apr 2007 22:26:24 +0000 (22:26 +0000)
git-svn-id: file:///home/notaz/opt/svn/fceu@94 be3aeb3a-fb24-0410-a615-afba39da0efa

Makefile [deleted file]
Makefile.base
Makefile.gp2x
drivers/pc/input.c
drivers/pc/main.c
drivers/pc/sdl-sound.c
drivers/pc/sdl-video.c
drivers/pc/throttle.c
fce.c

diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 1e061ab..0000000
--- a/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-CC     = arm-linux-gcc 
-TFLAGS  =  -mcpu=arm920t -O3 -Izlib  -DGP2X=1 -DLSB_FIRST -DSDL -DUNIX -DPSS_STYLE=1 -DZLIB  -D_REENTRANT 
-RM     = rm -f
-B      = drivers/pc/
-
-all:           fceu
-       mv fceu gpfce
-
-include zlib/Makefile
-
-OBJDRIVER      = ${B}minimal.o ${B}sdl.o ${B}main.o ${B}throttle.o ${B}unix-netplay.o ${B}sdl-sound.o ${B}sdl-video.o ${B}sdl-joystick.o drivers/common/cheat.o drivers/common/config.o drivers/common/args.o drivers/common/vidblit.o ${UNZIPOBJS} ppu.o
-LDRIVER                = -L /mnt/sd/lib  -L/mnt/sd/gp2x/usr/lib  -lm  -lpthread -lz -static 
-#                   `arm-linux-sdl-config --libs` 
-
-include Makefile.base
-
-${B}sdl-joystick.o:    ${B}sdl-joystick.c
-${B}main.o:            ${B}main.c ${B}main.h ${B}usage.h ${B}input.c ${B}keyscan.h
-${B}sdl.o:             ${B}sdl.c ${B}sdl.h
-${B}sdl-video.o:       ${B}sdl-video.c
-${B}sdl-video.o:       ${B}minimal.c
-${B}sdl-sound.o:       ${B}sdl-sound.c
-#${B}sdl-netplay.o:    ${B}sdl-netplay.c
-${B}unix-netplay.o:    ${B}unix-netplay.c
-${B}throttle.o:         ${B}throttle.c ${B}main.h ${B}throttle.h
-ppu.o:                 ppu.c ppu.h
-
-include Makefile.common
index 0a71b12..cedc5a6 100644 (file)
@@ -8,7 +8,10 @@ include mbshare/Makefile
 include input/Makefile
 
 fceu2:         ${OBJECTS} ${MOBJS} ${MUOBJS} ${MUSOBJS} ${INPOBJS} ${OBJDRIVER}
 include input/Makefile
 
 fceu2:         ${OBJECTS} ${MOBJS} ${MUOBJS} ${MUSOBJS} ${INPOBJS} ${OBJDRIVER}
-               ${CC} -s -o fceu ${OBJECTS} ${MOBJS} ${MUOBJS} ${MUSOBJS} ${INPOBJS} ${OBJDRIVER} ${LDRIVER}
+               ${CC} -o fceu ${OBJECTS} ${MOBJS} ${MUOBJS} ${MUSOBJS} ${INPOBJS} ${OBJDRIVER} ${LDRIVER}
+ifndef DEBUG
+               $(STRIP) fceu
+endif
 
 clean:
                ${RM} fceu fceu.exe ${OBJECTS} ${INPOBJS} ${MOBJS} ${MUOBJS} ${MUSOBJS} ${OBJDRIVER}
 
 clean:
                ${RM} fceu fceu.exe ${OBJECTS} ${INPOBJS} ${MOBJS} ${MUOBJS} ${MUSOBJS} ${OBJDRIVER}
index 1e061ab..9d5d47b 100644 (file)
@@ -1,16 +1,24 @@
-CC     = arm-linux-gcc 
-TFLAGS  =  -mcpu=arm920t -O3 -Izlib  -DGP2X=1 -DLSB_FIRST -DSDL -DUNIX -DPSS_STYLE=1 -DZLIB  -D_REENTRANT 
+CC     = arm-linux-gcc
+STRIP  = arm-linux-strip
+TFLAGS  = -mcpu=arm920t -Izlib -DGP2X=1 -DLSB_FIRST -DSDL -DUNIX -DPSS_STYLE=1 -DZLIB -DFRAMESKIP -D_REENTRANT
 RM     = rm -f
 B      = drivers/pc/
 RM     = rm -f
 B      = drivers/pc/
+ifdef DEBUG
+TFLAGS += -ggdb
+else
+TFLAGS += -O3
+endif
 
 all:           fceu
 
 all:           fceu
-       mv fceu gpfce
+
+gpfce: fceu
+       cp fceu gpfce
 
 include zlib/Makefile
 
 OBJDRIVER      = ${B}minimal.o ${B}sdl.o ${B}main.o ${B}throttle.o ${B}unix-netplay.o ${B}sdl-sound.o ${B}sdl-video.o ${B}sdl-joystick.o drivers/common/cheat.o drivers/common/config.o drivers/common/args.o drivers/common/vidblit.o ${UNZIPOBJS} ppu.o
 
 include zlib/Makefile
 
 OBJDRIVER      = ${B}minimal.o ${B}sdl.o ${B}main.o ${B}throttle.o ${B}unix-netplay.o ${B}sdl-sound.o ${B}sdl-video.o ${B}sdl-joystick.o drivers/common/cheat.o drivers/common/config.o drivers/common/args.o drivers/common/vidblit.o ${UNZIPOBJS} ppu.o
-LDRIVER                = -L /mnt/sd/lib  -L/mnt/sd/gp2x/usr/lib  -lm  -lpthread -lz -static 
-#                   `arm-linux-sdl-config --libs` 
+LDRIVER                = -L /mnt/sd/lib  -L/mnt/sd/gp2x/usr/lib  -lm  -lpthread -lz -static
+#                   `arm-linux-sdl-config --libs`
 
 include Makefile.base
 
 
 include Makefile.base
 
@@ -26,3 +34,7 @@ ${B}throttle.o:         ${B}throttle.c ${B}main.h ${B}throttle.h
 ppu.o:                 ppu.c ppu.h
 
 include Makefile.common
 ppu.o:                 ppu.c ppu.h
 
 include Makefile.common
+
+up: fceu
+       cp -v fceu /mnt/gp2x/mnt/sd/emus/Gpfce_v02/gpfce
+
index 212c34d..608404b 100644 (file)
 #include "minimal.h"
 extern int swapbuttons;
 extern int stretch_offset;
 #include "minimal.h"
 extern int swapbuttons;
 extern int stretch_offset;
-extern void SetVideoScaling(int pixels,int width,int height);
-long UpdateGamepadGP2X(void);
-
-
-
-
-
-static void UpdateFKB(void);
-
+extern int FSkip_setting;
 
 
+extern void SetVideoScaling(int pixels,int width,int height);
+INLINE long UpdateGamepadGP2X(void);
 
 
 
 /* UsrInputType[] is user-specified.  InputType[] is current
 
 
 
 /* UsrInputType[] is user-specified.  InputType[] is current
-       (game loading can override user settings) 
+       (game loading can override user settings)
 */
 static int UsrInputType[2]={SI_GAMEPAD,SI_GAMEPAD};
 static int InputType[2];
 */
 static int UsrInputType[2]={SI_GAMEPAD,SI_GAMEPAD};
 static int InputType[2];
@@ -56,210 +50,12 @@ static int InputTypeFC;
 static uint32 JSreturn;
 int NoWaiting=0;
 
 static uint32 JSreturn;
 int NoWaiting=0;
 
-static void DoCheatSeq(void)
-{
- #if defined(DOS) || defined(SDL)
- if(inited&1)
-  SilenceSound(1);
- #endif
- KillKeyboard();
- KillVideo();
-
- DoConsoleCheatConfig();
- InitVideo();
- InitKeyboard();
- #if defined(DOS) || defined(SDL)
- if(inited&1)
-  SilenceSound(0);
- #endif
-}
-
 #include "keyscan.h"
 #include "keyscan.h"
-static char *keys;
-static int DIPS=0;
-#ifndef GP2X
-static uint8 keyonce[MK_COUNT];
-#define KEY(__a) keys[MK(__a)]
-#define keyonly(__a,__z) {if(KEY(__a)){if(!keyonce[MK(__a)]) {keyonce[MK(__a)]=1;__z}}else{keyonce[MK(__a)]=0;}}
-#endif
-
-static int JoySwap=0;
-static int cidisabled=0;
-static int KeyboardUpdate(void)
-{
-#ifndef GP2X
- if(!UpdateKeyboard())
-   if(keys)
-    return 0;
-
-  keys=GetKeyboard(); 
-
-  if(InputTypeFC==SIFC_FKB)
-  {
-   keyonly(SCROLLLOCK,cidisabled^=1;
-    FCEUI_DispMessage("Family Keyboard %sabled.",cidisabled?"en":"dis");)
-   #ifdef SDL
-   SDL_WM_GrabInput(cidisabled?SDL_GRAB_ON:SDL_GRAB_OFF);
-   #endif
-   if(cidisabled) return(1);
-  }
-  #ifdef SVGALIB
-  keyonly(F3,LockConsole();)  
-  keyonly(F4,UnlockConsole();)
-  #elif SDL
-  keyonly(F4,ToggleFS();)
-  #endif
-  NoWaiting&=~1;
-  if(KEY(GRAVE))
-   NoWaiting|=1;
-
-  if(gametype==GIT_FDS)
-  {
-   keyonly(S,DriverInterface(DES_FDSSELECT,0);)
-   keyonly(I,DriverInterface(DES_FDSINSERT,0);)
-   keyonly(E,DriverInterface(DES_FDSEJECT,0);)
-  }
 
 
- keyonly(F9,FCEUI_SaveSnapshot();)
- if(gametype!=GIT_NSF)
- {
-  keyonly(F2,DoCheatSeq();)
-  keyonly(F5,FCEUI_SaveState();)
-  keyonly(F7,FCEUI_LoadState();)
- }
- else
- {
-  keyonly(CURSORLEFT,DriverInterface(DES_NSFDEC,0);)
-  keyonly(CURSORRIGHT,DriverInterface(DES_NSFINC,0);)
-  if( KEY(ENTER)) DriverInterface(DES_NSFRES,0);
-  if( KEY(CURSORUP)) DriverInterface(DES_NSFINC,0);
-  if( KEY(CURSORDOWN)) DriverInterface(DES_NSFDEC,0);
- }
-
- keyonly(F10,DriverInterface(DES_RESET,0);)
- keyonly(F11,DriverInterface(DES_POWER,0);)
- if(KEY(F12) || KEY(ESCAPE)) FCEUI_CloseGame();
-
- if(gametype==GIT_VSUNI)
- {
-   keyonly(C,DriverInterface(DES_VSUNICOIN,0);)
-   keyonly(V,DIPS^=1;DriverInterface(DES_VSUNITOGGLEDIPVIEW,0);)
-   if(!(DIPS&1)) goto DIPSless;
-   keyonly(1,DriverInterface(DES_VSUNIDIPSET,(void *)1);)
-   keyonly(2,DriverInterface(DES_VSUNIDIPSET,(void *)2);)
-   keyonly(3,DriverInterface(DES_VSUNIDIPSET,(void *)3);)
-   keyonly(4,DriverInterface(DES_VSUNIDIPSET,(void *)4);)
-   keyonly(5,DriverInterface(DES_VSUNIDIPSET,(void *)5);)
-   keyonly(6,DriverInterface(DES_VSUNIDIPSET,(void *)6);)
-   keyonly(7,DriverInterface(DES_VSUNIDIPSET,(void *)7);)
-   keyonly(8,DriverInterface(DES_VSUNIDIPSET,(void *)8);)
- }
- else
- {
-  keyonly(H,DriverInterface(DES_NTSCSELHUE,0);)
-  keyonly(T,DriverInterface(DES_NTSCSELTINT,0);)
-  if(KEY(KP_MINUS) || KEY(MINUS)) DriverInterface(DES_NTSCDEC,0);
-  if(KEY(KP_PLUS) || KEY(EQUAL)) DriverInterface(DES_NTSCINC,0);
-
-  DIPSless:
-  keyonly(0,FCEUI_SelectState(0);)
-  keyonly(1,FCEUI_SelectState(1);)
-  keyonly(2,FCEUI_SelectState(2);)
-  keyonly(3,FCEUI_SelectState(3);)
-  keyonly(4,FCEUI_SelectState(4);)
-  keyonly(5,FCEUI_SelectState(5);)
-  keyonly(6,FCEUI_SelectState(6);)
-  keyonly(7,FCEUI_SelectState(7);)
-  keyonly(8,FCEUI_SelectState(8);)
-  keyonly(9,FCEUI_SelectState(9);)
- }
- return 1;
-#else
- return 1;
-#endif
-}
-
-static uint32 KeyboardDodo(void)
-{
-#ifndef GP2X
- uint32 JS=0;
-
- if(gametype!=GIT_NSF)
- {
-  int x,y;
-  x=y=0;
-  keyonly(CAPSLOCK,
-                   {
-                    char tmp[64];
-                    JoySwap=(JoySwap+8)%32;
-                    sprintf(tmp,"Joystick %d selected.",(JoySwap>>3)+1);
-                    FCEUI_DispMessage(tmp);
-                   })
-
-  if(KEY(LEFTALT) || KEY(X))        JS|=JOY_A<<JoySwap;
-  if(KEY(LEFTCONTROL) || KEY(SPACE) || KEY(Z) ) JS |=JOY_B<<JoySwap;
-  if(KEY(ENTER))       JS |= JOY_START<<JoySwap;
-  if(KEY(TAB))         JS |= JOY_SELECT<<JoySwap;
-  if(KEY(CURSORDOWN))  y|= JOY_DOWN;
-  if(KEY(CURSORUP))    y|= JOY_UP;
-  if(KEY(CURSORLEFT))  x|= JOY_LEFT;
-  if(KEY(CURSORRIGHT)) x|= JOY_RIGHT;
-  if(y!=(JOY_DOWN|JOY_UP)) JS|=y<<JoySwap;
-  if(x!=(JOY_LEFT|JOY_RIGHT)) JS|=x<<JoySwap;
- }
- return JS;
-#else
- return 0;
-#endif
-}
-
-#ifndef GP2X
-static int powerpadsc[2][12]={
-                              {
-                               MK(O),MK(P),MK(BRACKET_LEFT),
-                               MK(BRACKET_RIGHT),MK(K),MK(L),MK(SEMICOLON),
-                               MK(APOSTROPHE),
-                               MK(M),MK(COMMA),MK(PERIOD),MK(SLASH)
-                              },
-                              {
-                               MK(O),MK(P),MK(BRACKET_LEFT),
-                               MK(BRACKET_RIGHT),MK(K),MK(L),MK(SEMICOLON),
-                                MK(APOSTROPHE),
-                               MK(M),MK(COMMA),MK(PERIOD),MK(SLASH)
-                              }
-                             };
-
-static uint32 powerpadbuf[2];
-#else
 static int powerpadsc[2][12];
 static int powerpadsc[2][12];
-#endif
 static int powerpadside=0;
 
 
 static int powerpadside=0;
 
 
-static uint32 UpdatePPadData(int w)
-{
-#ifndef GP2X
- static const char shifttableA[12]={8,9,0,1,11,7,4,2,10,6,5,3};
- static const char shifttableB[12]={1,0,9,8,2,4,7,11,3,5,6,10};
- uint32 r=0;
- int *ppadtsc=powerpadsc[w];
- int x;
-
- if(powerpadside&(1<<w))
- {
-  for(x=0;x<12;x++)
-   if(keys[ppadtsc[x]]) r|=1<<shifttableA[x];
- }
- else
- {
-  for(x=0;x<12;x++)
-   if(keys[ppadtsc[x]]) r|=1<<shifttableB[x];
- }
- return r;
-#endif
- return 0;
-}
-
 static uint32 MouseData[3];
 static uint8 fkbkeys[0x48];
 unsigned long lastpad=0;
 static uint32 MouseData[3];
 static uint8 fkbkeys[0x48];
 unsigned long lastpad=0;
@@ -267,19 +63,12 @@ unsigned long lastpad=0;
 void FCEUD_UpdateInput(void)
 {
   int t=0;
 void FCEUD_UpdateInput(void)
 {
   int t=0;
-#ifndef GP2X   
-  int x;
-  static uint32 KeyBJS=0;
-  uint32 JS;
-  int b;
-#endif 
-#ifdef GP2X
   long lastpad2=lastpad;
   long pad = UpdateGamepadGP2X();
   t=1;
   //  JSreturn=(JSreturn&0xFF000000)|(JSreturn&0xFF)|((JSreturn&0xFF0000)>>8)|((JSreturn&0xFF00)<<8);
   if(gametype==GIT_FDS)
   long lastpad2=lastpad;
   long pad = UpdateGamepadGP2X();
   t=1;
   //  JSreturn=(JSreturn&0xFF000000)|(JSreturn&0xFF)|((JSreturn&0xFF0000)>>8)|((JSreturn&0xFF00)<<8);
   if(gametype==GIT_FDS)
-  {    
+  {
     NoWaiting&=~1;
        if ((pad & GP2X_PUSH) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_L)) && (!(pad & GP2X_R)) && (!(lastpad2 & GP2X_PUSH)))
        {
     NoWaiting&=~1;
        if ((pad & GP2X_PUSH) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_L)) && (!(pad & GP2X_R)) && (!(lastpad2 & GP2X_PUSH)))
        {
@@ -295,44 +84,9 @@ void FCEUD_UpdateInput(void)
        }
   }
 
        }
   }
 
-#else
-  UpdateGamepadGP2X();
-  b=KeyboardUpdate();
-
-  for(x=0;x<2;x++)
-   switch(InputType[x])
-   {
-    case SI_GAMEPAD:t|=1;break;
-    case SI_ARKANOID:t|=2;break;
-    case SI_ZAPPER:t|=2;break;
-    case SI_POWERPAD:powerpadbuf[x]=UpdatePPadData(x);break;
-   }
-
-  switch(InputTypeFC)
-  {
-   case SIFC_ARKANOID:t|=2;break;
-   case SIFC_SHADOW:t|=2;break;
-   case SIFC_FKB:if(cidisabled) UpdateFKB();break;
-  }
-
-  if(t&1)
-  {
-   if(b)
-    KeyBJS=KeyboardDodo();
-   JS=KeyBJS;
-   JS|=(uint32)GetJSOr();
-   JSreturn=(JS&0xFF000000)|(JS&0xFF)|((JS&0xFF0000)>>8)|((JS&0xFF00)<<8);
-  }
-  if(t&2)
-   GetMouseData(MouseData);
-   
-#endif
 }
 
 
 }
 
 
-
-
-
 //#ifdef GP2X
 
 extern void ResetNES(void);
 //#ifdef GP2X
 
 extern void ResetNES(void);
@@ -362,67 +116,64 @@ static void setsoundvol(int soundvolume)
                  soundvolmeter[soundvolIndex]='*';
        }
        else
                  soundvolmeter[soundvolIndex]='*';
        }
        else
-       { 
+       {
                  soundvolmeter[soundvolIndex]='_';
        }
     }
     soundvolmeter[20]=0;
                  soundvolmeter[soundvolIndex]='_';
        }
     }
     soundvolmeter[20]=0;
-    FCEU_DispMessage("|%s|", soundvolmeter);    
+    FCEU_DispMessage("|%s|", soundvolmeter);
 }
 /**
  * GP2x joystick reader
  *
 }
 /**
  * GP2x joystick reader
  *
- */ 
+ */
 INLINE long UpdateGamepadGP2X(void)
 {
   uint32 JS=0;
 
   unsigned long pad=gp2x_joystick_read();
 INLINE long UpdateGamepadGP2X(void)
 {
   uint32 JS=0;
 
   unsigned long pad=gp2x_joystick_read();
+#define down(b) (pad & GP2X_##b)
+#define last_down(b) (lastpad & GP2X_##b)
 #define L_down (pad & GP2X_L)
 #define R_down (pad & GP2X_R)
 #define last_L_down (lastpad & GP2X_L)
 #define last_R_down (lastpad & GP2X_R)
 #define L_down (pad & GP2X_L)
 #define R_down (pad & GP2X_R)
 #define last_L_down (lastpad & GP2X_L)
 #define last_R_down (lastpad & GP2X_R)
-  
-  if (L_down && R_down && (!(pad & GP2X_PUSH))
-      && (!(last_R_down && last_L_down)))
+#define shift      ((pad     & GP2X_PUSH) || ((pad     & (GP2X_VOL_UP|GP2X_VOL_DOWN)) == (GP2X_VOL_UP|GP2X_VOL_DOWN)))
+#define last_shift ((lastpad & GP2X_PUSH) || ((lastpad & (GP2X_VOL_UP|GP2X_VOL_DOWN)) == (GP2X_VOL_UP|GP2X_VOL_DOWN)))
+
+  if (L_down && R_down && !(pad & GP2X_PUSH) && !(last_R_down && last_L_down))
   {
      ResetNES();
   {
      ResetNES();
-     puts("Reset"); 
-     JSreturn=0;
-     lastpad=pad;
-     return pad;
+     puts("Reset");
+     goto no_pad;
   }
 
   }
 
-
-
-  
-  if (pad & GP2X_VOL_UP)
+  if (down(VOL_UP) && !down(VOL_DOWN))
   {
     soundvol+=1;
     if (soundvol >= 100) soundvol=100;
     //FCEUI_SetSoundVolume(soundvol);
     setsoundvol(soundvol);
   }
   {
     soundvol+=1;
     if (soundvol >= 100) soundvol=100;
     //FCEUI_SetSoundVolume(soundvol);
     setsoundvol(soundvol);
   }
-  if (pad & GP2X_VOL_DOWN)
+  else if (down(VOL_DOWN) && !down(VOL_UP))
   {
     soundvol-=1;
     if (soundvol < 0) soundvol=0;
     //FCEUI_SetSoundVolume(soundvol);
     setsoundvol(soundvol);
   }
   {
     soundvol-=1;
     if (soundvol < 0) soundvol=0;
     //FCEUI_SetSoundVolume(soundvol);
     setsoundvol(soundvol);
   }
-  if (pad & GP2X_PUSH)
-  {    
+
+  if (shift)
+  {
     // only if it's something else then last time, and not moving around the joystick
     // only if it's something else then last time, and not moving around the joystick
-    if (!((pad & GP2X_UP) ||(pad & GP2X_DOWN) || (pad & GP2X_LEFT) || (pad & GP2X_RIGHT)))
+    if (!(pad & (GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT)))
     {
     {
-      if (pad & GP2X_SELECT)
+      if (down(SELECT))
       {
       {
-        if ((lastpad & GP2X_SELECT) && (lastpad & GP2X_PUSH))
+        if (last_down(SELECT) && last_shift)
        {
           // still pressed down from stretching from last one
        {
           // still pressed down from stretching from last one
-          JSreturn=0; 
-          lastpad=pad;
-          return 0;
+          goto no_pad;
        }
         if (stretch_offset == 32)
        {
        }
         if (stretch_offset == 32)
        {
@@ -434,7 +185,7 @@ INLINE long UpdateGamepadGP2X(void)
        }
 
         if (stretch_offset == 32)
        }
 
         if (stretch_offset == 32)
-       {          
+       {
           SetVideoScaling(320, 320, 240);
           CleanSurface();
        }
           SetVideoScaling(320, 320, 240);
           CleanSurface();
        }
@@ -443,34 +194,45 @@ INLINE long UpdateGamepadGP2X(void)
          SetVideoScaling(320, 256, 240);
        }
 
          SetVideoScaling(320, 256, 240);
        }
 
-        JSreturn=0;
-        lastpad=pad;
-        return pad;
+        goto no_pad;
       }
       else if (L_down && R_down)
       {
         FCEUI_CloseGame();
       }
       else if (L_down && R_down)
       {
         FCEUI_CloseGame();
-        puts("Quit"); 
-        JSreturn=0;
-        return 0;
+        puts("Quit");
+        goto no_pad;
       }
       }
-      else if (R_down && (!((lastpad & GP2X_R) && (lastpad & GP2X_PUSH))))
+      else if (R_down && !(last_R_down && last_shift))
       {
        FCEUI_LoadState();
       {
        FCEUI_LoadState();
-       JSreturn=0;
-       lastpad=pad;
-       return 0;
+       goto no_pad;
       }
       }
-      else if (L_down && (!((lastpad & GP2X_L) && (lastpad & GP2X_PUSH))))
+      else if (L_down && !(last_L_down && last_shift))
       {
        FCEUI_SaveState();
       {
        FCEUI_SaveState();
-       JSreturn=0;
-       lastpad=pad;
-       return 0;
+       goto no_pad;
+      }
+      else if (down(A) && !(last_down(A) && last_shift))
+      {
+       FSkip_setting--;
+       if (FSkip_setting < 0) {
+        FSkip_setting = -1;
+        FCEUI_DispMessage("Auto frameskip");
+       }
+       else
+        FCEUI_DispMessage("Frameskip: %i", FSkip_setting);
+       goto no_pad;
+      }
+      else if (down(Y) && !(last_down(Y) && last_shift))
+      {
+       FSkip_setting++;
+       if (FSkip_setting > 8) FSkip_setting = 8;
+       FCEUI_DispMessage("Frameskip: %i", FSkip_setting);
+       goto no_pad;
       }
     }
   }
       }
     }
   }
-  
+
   // r is toggle savestate
   if (R_down)
   {
   // r is toggle savestate
   if (R_down)
   {
@@ -488,7 +250,7 @@ INLINE long UpdateGamepadGP2X(void)
   {
     R_count=0;
   }
   {
     R_count=0;
   }
-  
+
   // l is toggle turbo
   if (L_down)
   {
   // l is toggle turbo
   if (L_down)
   {
@@ -502,36 +264,36 @@ INLINE long UpdateGamepadGP2X(void)
         {
                // was off
                TurboFireTop=1;
         {
                // was off
                TurboFireTop=1;
-               TurboFireBottom=0;              
+               TurboFireBottom=0;
                if (swapbuttons)
                {
                if (swapbuttons)
                {
-                 FCEUI_DispMessage("Turbo A and Y");           
+                 FCEUI_DispMessage("Turbo A and Y");
                }
                else
                {
                }
                else
                {
-                 FCEUI_DispMessage("Turbo Y and B");           
+                 FCEUI_DispMessage("Turbo Y and B");
                }
         }
         else if (TurboFireTop)
         {
                TurboFireTop=0;
                }
         }
         else if (TurboFireTop)
         {
                TurboFireTop=0;
-               TurboFireBottom=1;              
+               TurboFireBottom=1;
                if (swapbuttons)
                {
                if (swapbuttons)
                {
-                         FCEUI_DispMessage("Turbo X and B");           
+                         FCEUI_DispMessage("Turbo X and B");
                }
                else
                {
                }
                else
                {
-                         FCEUI_DispMessage("Turbo A and X");           
+                         FCEUI_DispMessage("Turbo A and X");
                }
         }
         else
         {
                TurboFireTop=0;
                }
         }
         else
         {
                TurboFireTop=0;
-               TurboFireBottom=0;              
-               FCEUI_DispMessage("Turbo Off");         
+               TurboFireBottom=0;
+               FCEUI_DispMessage("Turbo Off");
         }
         }
-       
+
          }
        }
   }
          }
        }
   }
@@ -539,22 +301,20 @@ INLINE long UpdateGamepadGP2X(void)
   {
     L_count=0;
   }
   {
     L_count=0;
   }
-  
-  
-  
+
   //unsigned long padTmp=0;
   // shift the bits in
   // up
   //unsigned long padTmp=0;
   // shift the bits in
   // up
-  //padTmp=(pad & GP2X_UP) ;  // 1 is 2^0, 
+  //padTmp=(pad & GP2X_UP) ;  // 1 is 2^0,
   JS |= ((pad & GP2X_UP) << (4-0));  // 0x10 is 2^4
 
   JS |= ((pad & GP2X_UP) << (4-0));  // 0x10 is 2^4
 
-  //padTmp=(pad & GP2X_DOWN);  // 0x10 is 2^4, 
+  //padTmp=(pad & GP2X_DOWN);  // 0x10 is 2^4,
   JS |= ((pad & GP2X_DOWN) << (5-4));  // 0x20 is 2^5
 
   JS |= ((pad & GP2X_DOWN) << (5-4));  // 0x20 is 2^5
 
-  //padTmp=(pad & GP2X_LEFT);  // 0x4 is 2^2, 
+  //padTmp=(pad & GP2X_LEFT);  // 0x4 is 2^2,
   JS |= ((pad & GP2X_LEFT) << (6-2));  // 0x40 is 2^6
 
   JS |= ((pad & GP2X_LEFT) << (6-2));  // 0x40 is 2^6
 
-  //padTmp=(pad & GP2X_RIGHT);  // 0x40 is 2^6,  
+  //padTmp=(pad & GP2X_RIGHT);  // 0x40 is 2^6,
   JS |= ((pad & GP2X_RIGHT) << (7-6));  // 0x80 is 2^7
 
 
   JS |= ((pad & GP2X_RIGHT) << (7-6));  // 0x80 is 2^7
 
 
@@ -566,46 +326,46 @@ INLINE long UpdateGamepadGP2X(void)
   // should be 2 cycles held, 1 cycle release
   turbo_toggle_A=(turbo_toggle_A+1) % 3;
   turbo_toggle_B=(turbo_toggle_B+1) % 3;
   // should be 2 cycles held, 1 cycle release
   turbo_toggle_A=(turbo_toggle_A+1) % 3;
   turbo_toggle_B=(turbo_toggle_B+1) % 3;
+
    // 0 is none  // 1 is  Y & B turbo  // 2 is X & A turbo
   // B or X are both considered A
   //padTmp=B_down >> 13;  // 2^13,
    // 0 is none  // 1 is  Y & B turbo  // 2 is X & A turbo
   // B or X are both considered A
   //padTmp=B_down >> 13;  // 2^13,
-  
+
    if (!(TurboFireTop && (!turbo_toggle_A)))
    {
     JS |= ((B_down >> 13) << 0);  // 0x1 is 2^0
    }
    // A or Y are both considered B
    if (!(TurboFireTop && (!turbo_toggle_A)))
    {
     JS |= ((B_down >> 13) << 0);  // 0x1 is 2^0
    }
    // A or Y are both considered B
-   //padTmp=A_down >> 12;  // 2^13,  
+   //padTmp=A_down >> 12;  // 2^13,
    if (!(TurboFireBottom && (!turbo_toggle_B)))
    {
     JS |= ((A_down >> 12) << 1);  // 0x2 is 2^1
    }
    if (!(TurboFireBottom && (!turbo_toggle_B)))
    {
     JS |= ((A_down >> 12) << 1);  // 0x2 is 2^1
    }
-  
+
   if (swapbuttons)
   {
   if (swapbuttons)
   {
-   //padTmp=X_down >> 14;  // 2^13,  
+   //padTmp=X_down >> 14;  // 2^13,
    if (!(TurboFireBottom && (!turbo_toggle_A)))
    {
 //    JS |= ((X_down >> 14) << 0);  // 0x1 is 2^0
     JS |= ((Y_down >> 15) << 0);  // 0x1 is 2^0
    }
 
    if (!(TurboFireBottom && (!turbo_toggle_A)))
    {
 //    JS |= ((X_down >> 14) << 0);  // 0x1 is 2^0
     JS |= ((Y_down >> 15) << 0);  // 0x1 is 2^0
    }
 
-   //padTmp=Y_down >> 15;  // 2^13,  
+   //padTmp=Y_down >> 15;  // 2^13,
    if (!(TurboFireTop && (!turbo_toggle_B)))
    {
     JS |= ((X_down >> 14) << 1);  // 0x2 is 2^1
    }
   }
   else
    if (!(TurboFireTop && (!turbo_toggle_B)))
    {
     JS |= ((X_down >> 14) << 1);  // 0x2 is 2^1
    }
   }
   else
-  {  
-   //padTmp=X_down >> 14;  // 2^13,  
+  {
+   //padTmp=X_down >> 14;  // 2^13,
    if (!(TurboFireBottom && (!turbo_toggle_A)))
    {
     JS |= ((X_down >> 14) << 0);  // 0x1 is 2^0
    }
 
    if (!(TurboFireBottom && (!turbo_toggle_A)))
    {
     JS |= ((X_down >> 14) << 0);  // 0x1 is 2^0
    }
 
-   //padTmp=Y_down >> 15;  // 2^13,  
+   //padTmp=Y_down >> 15;  // 2^13,
    if (!(TurboFireTop && (!turbo_toggle_B)))
    {
     JS |= ((Y_down >> 15) << 1);  // 0x2 is 2^1
    if (!(TurboFireTop && (!turbo_toggle_B)))
    {
     JS |= ((Y_down >> 15) << 1);  // 0x2 is 2^1
@@ -613,11 +373,11 @@ INLINE long UpdateGamepadGP2X(void)
   }
 
   // select
   }
 
   // select
-  //padTmp=(pad & GP2X_SELECT) >> 9;  // 0x40 is 2^9,  
+  //padTmp=(pad & GP2X_SELECT) >> 9;  // 0x40 is 2^9,
   JS |= (((pad & GP2X_SELECT) >> 9) << 2);  // 0x4 is 2^2
 
   // start
   JS |= (((pad & GP2X_SELECT) >> 9) << 2);  // 0x4 is 2^2
 
   // start
-  //padTmp=(pad & GP2X_START) >> 8;  //   2^8,  
+  //padTmp=(pad & GP2X_START) >> 8;  //   2^8,
   JS |= (((pad & GP2X_START) >> 8) << 3);  // 0x8 is 2^3
 
 
   JS |= (((pad & GP2X_START) >> 8) << 3);  // 0x8 is 2^3
 
 
@@ -626,22 +386,14 @@ INLINE long UpdateGamepadGP2X(void)
 
   return pad;
   //JSreturn=(JS&0xFF000000)|(JS&0xFF)|((JS&0xFF0000)>>8)|((JS&0xFF00)<<8);
 
   return pad;
   //JSreturn=(JS&0xFF000000)|(JS&0xFF)|((JS&0xFF0000)>>8)|((JS&0xFF00)<<8);
+no_pad:
+  JSreturn=0;
+  lastpad=pad;
+  return 0;
 }
 //#endif
 
 
 }
 //#endif
 
 
-
-
-
-
-
-
-
-
-
-
-
-
 static void InitOtherInput(void)
 {
 
 static void InitOtherInput(void)
 {
 
@@ -658,7 +410,7 @@ static void InitOtherInput(void)
     switch(InputType[x])
     {
       //case SI_POWERPAD:InputDPtr=&powerpadbuf[x];break;
     switch(InputType[x])
     {
       //case SI_POWERPAD:InputDPtr=&powerpadbuf[x];break;
-     case SI_GAMEPAD:InputDPtr=((uint8 *)&JSreturn)+(x<<1);break;     
+     case SI_GAMEPAD:InputDPtr=((uint8 *)&JSreturn)+(x<<1);break;
      case SI_ARKANOID:InputDPtr=MouseData;t|=1;break;
      case SI_ZAPPER:InputDPtr=MouseData;
                                 t|=1;
      case SI_ARKANOID:InputDPtr=MouseData;t|=1;break;
      case SI_ZAPPER:InputDPtr=MouseData;
                                 t|=1;
@@ -680,40 +432,9 @@ static void InitOtherInput(void)
    FCEUI_SetInputFC(InputTypeFC,InputDPtr,attrib);
    FCEUI_DisableFourScore(eoptions&EO_NOFOURSCORE);
 
    FCEUI_SetInputFC(InputTypeFC,InputDPtr,attrib);
    FCEUI_DisableFourScore(eoptions&EO_NOFOURSCORE);
 
-   if(t && !(inited&16)) 
+   if(t && !(inited&16))
    {
     InitMouse();
     inited|=16;
    }
    {
     InitMouse();
     inited|=16;
    }
-
-}
-#ifndef GP2X
-int fkbmap[0x48]=
-{
- MK(F1),MK(F2),MK(F3),MK(F4),MK(F5),MK(F6),MK(F7),MK(F8),
- MK(1),MK(2),MK(3),MK(4),MK(5),MK(6),MK(7),MK(8),MK(9),MK(0),
-        MK(MINUS),MK(EQUAL),MK(BACKSLASH),MK(BACKSPACE),
- MK(ESCAPE),MK(Q),MK(W),MK(E),MK(R),MK(T),MK(Y),MK(U),MK(I),MK(O),
-        MK(P),MK(GRAVE),MK(BRACKET_LEFT),MK(ENTER),
- MK(LEFTCONTROL),MK(A),MK(S),MK(D),MK(F),MK(G),MK(H),MK(J),MK(K),
-        MK(L),MK(SEMICOLON),MK(APOSTROPHE),MK(BRACKET_RIGHT),MK(INSERT),
- MK(LEFTSHIFT),MK(Z),MK(X),MK(C),MK(V),MK(B),MK(N),MK(M),MK(COMMA),
-        MK(PERIOD),MK(SLASH),MK(RIGHTALT),MK(RIGHTSHIFT),MK(LEFTALT),MK(SPACE),
- MK(DELETE),MK(END),MK(PAGEDOWN),
- MK(CURSORUP),MK(CURSORLEFT),MK(CURSORRIGHT),MK(CURSORDOWN)
-};
-#endif
-
-static void UpdateFKB(void)
-{
-#ifndef GP2X
- int x;
-
- for(x=0;x<0x48;x++)
- {
-  fkbkeys[x]=0;
-  if(keys[fkbmap[x]])
-   fkbkeys[x]=1;
- }
-#endif
 }
 }
index 15a2b5b..d2be777 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 /*  This file contains or coordinates all of the code necessary to compile
  */
 
 /*  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.  
+    on a UNIX system that can use svgalib, such as FreeBSD and Linux.
     This code is not guaranteed to compile on FreeBSD, though.
 */
 
     This code is not guaranteed to compile on FreeBSD, though.
 */
 
@@ -47,7 +47,7 @@
 
 static int ntsccol=0,ntschue=-1,ntsctint=-1;
 int soundvol=70;
 
 static int ntsccol=0,ntschue=-1,ntsctint=-1;
 int soundvol=70;
-int inited=0; 
+int inited=0;
 int swapbuttons=0;
 int showfps=0;
 
 int swapbuttons=0;
 int showfps=0;
 
@@ -124,7 +124,7 @@ static CFGSTRUCT fceuconfig[]={
 };
 
 static void SaveConfig(void)
 };
 
 static void SaveConfig(void)
-{      
+{
        char tdir[2048];
        sprintf(tdir,"%s"PSS"fceu.cfg",BaseDirectory);
         DriverInterface(DES_GETNTSCTINT,&ntsctint);
        char tdir[2048];
        sprintf(tdir,"%s"PSS"fceu.cfg",BaseDirectory);
         DriverInterface(DES_GETNTSCTINT,&ntsctint);
@@ -281,7 +281,7 @@ static void DoArgs(int argc, char *argv[])
          if(!inputa[x])
          continue;
 
          if(!inputa[x])
          continue;
 
-        for(y=0;y<5;y++)        
+        for(y=0;y<5;y++)
         {
          if(!strncmp(cortab[y],inputa[x],8))
          {
         {
          if(!strncmp(cortab[y],inputa[x],8))
          {
@@ -294,7 +294,7 @@ static void DoArgs(int argc, char *argv[])
           free(inputa[x]);
          }
         }
           free(inputa[x]);
          }
         }
-       }       
+       }
 }
 
 #include "usage.h"
 }
 
 #include "usage.h"
@@ -310,7 +310,7 @@ int CLImain(int argc, char *argv[])
        FCEUI_SetBaseDirectory(BaseDirectory);
 
        CreateDirs();
        FCEUI_SetBaseDirectory(BaseDirectory);
 
        CreateDirs();
-        if(argc<=1) 
+        if(argc<=1)
         {
          ShowUsage(argv[0]);
          return 1;
         {
          ShowUsage(argv[0]);
          return 1;
@@ -328,7 +328,7 @@ int CLImain(int argc, char *argv[])
          goto dk;
         }
        ParseGI(tmp);
          goto dk;
         }
        ParseGI(tmp);
-       RefreshThrottleFPS();
+       //RefreshThrottleFPS();
         if(!DriverInitialize())
         {
          ret=0;
         if(!DriverInitialize())
         {
          ret=0;
index c5cd806..6693222 100644 (file)
@@ -24,7 +24,7 @@
 #include <sys/time.h>
 #include <pthread.h>
 #include <unistd.h>
 #include <sys/time.h>
 #include <pthread.h>
 #include <unistd.h>
-#include <sys/ioctl.h> 
+#include <sys/ioctl.h>
 #include <linux/soundcard.h>
 
 #include "sdl.h"
 #include <linux/soundcard.h>
 
 #include "sdl.h"
@@ -32,7 +32,6 @@
 
 #define GP2X_SOUND 1
 
 
 #define GP2X_SOUND 1
 
-extern INLINE SpeedThrottle(void);
 extern void pthread_yield(void);
 extern void FCEUI_FrameSkip(int x);
 
 extern void pthread_yield(void);
 extern void FCEUI_FrameSkip(int x);
 
@@ -68,10 +67,9 @@ pthread_cond_t gp2x_sound_cond=PTHREAD_COND_INITIALIZER;
 pthread_mutex_t gp2x_sound_mutex = PTHREAD_MUTEX_INITIALIZER;
 int zzdebug01_entry=0;
 int zzdebug01_wait=0;
 pthread_mutex_t gp2x_sound_mutex = PTHREAD_MUTEX_INITIALIZER;
 int zzdebug01_entry=0;
 int zzdebug01_wait=0;
-int hasSound=0; 
+int hasSound=0;
 extern unsigned long fps;
 extern unsigned long avg_fps;
 extern unsigned long fps;
 extern unsigned long avg_fps;
-extern unsigned long framesRendered;
 extern unsigned long ticks;
 
 int throttlecount=0;
 extern unsigned long ticks;
 
 int throttlecount=0;
@@ -85,7 +83,7 @@ void WriteSound(int32 *Buffer, int Count)
 
 void* gp2x_write_sound(void* blah)
   {
 
 void* gp2x_write_sound(void* blah)
   {
-  gp2x_in_sound_thread=1;  
+  gp2x_in_sound_thread=1;
   {
     if (hasSound)
   {
   {
     if (hasSound)
   {
@@ -111,9 +109,9 @@ int InitSound(FCEUGI *gi)
   FCEUI_Sound(Settings.sound);
   gp2x_sound_volume(soundvol, soundvol);
   printf("InitSound() sound_rate: %d\n", Settings.sound);
   FCEUI_Sound(Settings.sound);
   gp2x_sound_volume(soundvol, soundvol);
   printf("InitSound() sound_rate: %d\n", Settings.sound);
-  if(firstentry) 
-  {   
-      firstentry=0; 
+  if(firstentry)
+  {
+      firstentry=0;
       gp2x_sound_inited=1;
   }
   return 1 ;
       gp2x_sound_inited=1;
   }
   return 1 ;
index f2d404c..9a4e787 100644 (file)
@@ -1,7 +1,4 @@
 /* FCE Ultra - NES/Famicom Emulator
 /* 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
  *
  * 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
 
 #include <stdio.h>
 #include <string.h>
 
 #include <stdio.h>
 #include <string.h>
-#include <stdlib.h>
 #include <sys/time.h>
 #include <sys/time.h>
-#include <pthread.h>
 
 #include "sdl.h"
 
 #include "sdl.h"
-#include "../common/vidblit.h"
+//#include "../common/vidblit.h"
 
 
 
 
-#ifdef GP2X
 #include "minimal.h"
 
 #include "minimal.h"
 
-char* fps_str=NULL;
-#endif
 extern int showfps;
 
 extern int showfps;
 
-int stretch_offset=32;
-
-unsigned long framesRendered;
-unsigned long fps;
-unsigned long fps_samplecount=0;
-unsigned long total_fps=-1;
-unsigned long ticks;
-
-pthread_t       gp2x_video_thread=0;
-uint8 * XBufHelper=NULL;
-
-
-#define _sline srendline
-#define _eline erendline
-
-#ifndef GP2X
-SDL_Surface *screen;
-#endif
-
-static int tlines;
-static int inited=0;
-
-static int exs,eys,eefx;
-#define NWIDTH (256-((eoptions&EO_CLIPSIDES)?16:0))
-#define NOFFSET        (eoptions&EO_CLIPSIDES?8:0)
-
-
+static char fps_str[32];
+static int framesEmulated, framesRendered;
 
 
+int stretch_offset=32;
 int paletterefresh;
 int paletterefresh;
-#ifdef GP2X
-static int screenSizeInBytes = 320 * 240;
-#endif
-#define FPS_COLOR 61
-
 
 
+#define FPS_COLOR 61
 
 
 static unsigned char fontdata8x8[] =
 
 
 static unsigned char fontdata8x8[] =
@@ -144,14 +108,14 @@ static void gp2x_text(unsigned char *screen, int x, int y, char *text, int color
 {
        int i,l,slen;
         slen=strlen(text);
 {
        int i,l,slen;
         slen=strlen(text);
-       
+
        screen=screen+x+y*320;
        screen=screen+x+y*320;
-       
-       for (i=0;i<slen;i++) 
+
+       for (i=0;i<slen;i++)
         {
         {
-               for (l=0;l<8;l++) 
+               for (l=0;l<8;l++)
                 {
                 {
-                 
+
                        screen[l*320+0]=(fontdata8x8[((text[i])*8)+l]&0x80)?color:screen[l*320+0];
                        screen[l*320+1]=(fontdata8x8[((text[i])*8)+l]&0x40)?color:screen[l*320+1];
                        screen[l*320+2]=(fontdata8x8[((text[i])*8)+l]&0x20)?color:screen[l*320+2];
                        screen[l*320+0]=(fontdata8x8[((text[i])*8)+l]&0x80)?color:screen[l*320+0];
                        screen[l*320+1]=(fontdata8x8[((text[i])*8)+l]&0x40)?color:screen[l*320+1];
                        screen[l*320+2]=(fontdata8x8[((text[i])*8)+l]&0x20)?color:screen[l*320+2];
@@ -163,433 +127,143 @@ static void gp2x_text(unsigned char *screen, int x, int y, char *text, int color
 
                }
                screen+=8;
 
                }
                screen+=8;
-       } 
+       }
 }
 
 
 }
 
 
-
-
 void CleanSurface(void)
 {
 void CleanSurface(void)
 {
-#ifdef GP2X
-  int c=4; 
-  while (c--)
-{
-    memset (gp2x_screen8, 0x80, screenSizeInBytes);    
-    gp2x_video_flip();
-  }
-
-#else
- uint32 x;
-
- x=screen->pitch*screen->h;
-
- if(SDL_MUSTLOCK(screen))
-  SDL_LockSurface(screen);
-
- memset((uint8*)screen->pixels, 0x3F, x);
-
- if(SDL_MUSTLOCK(screen))
-  SDL_UnlockSurface(screen);
-
- SDL_UpdateRect(screen, 0, 0, 0, 0);
-#endif
+       int c=4;
+       while (c--)
+       {
+               memset (gp2x_screen8, 0x80, 320*240);
+               gp2x_video_flip();
+       }
 }
 
 
 }
 
 
-
 void KillVideo(void)
 {
 void KillVideo(void)
 {
-#ifdef GP2X
-  if (fps_str) 
-    free(fps_str);
-  inited&=~1;
-
-  
-#else
- if(inited&1)
- {
-  SDL_QuitSubSystem(SDL_INIT_VIDEO);
- }
- inited=0;
-#endif
 }
 
 }
 
-int InitVideo(void)
-{
-#ifdef GP2X
-
-
-  fps_str=malloc(3);
-  fps_str[0]='5'; fps_str[1]='0'; fps_str[2]=0;
-  
-  CleanSurface();
-
-
-  inited|=1;
-
-  puts("Initialized GP2X VIDEO via minimal");
-
-  srendline=0;
-  erendline=239;
-  return 1;
-
-
-#else
- const SDL_VideoInfo *vinf;
- int flags=0;
-
- #ifdef BROKEN
- if(_fullscreen && _fshack)
-  setenv("SDL_VIDEODRIVER",_fshack,1);
- else
- {
-  if(!_fshacksave)
-   unsetenv("SDL_VIDEODRIVER");
-  else
-   setenv("SDL_VIDEODRIVER",_fshacksave,1);
- }
- #endif
- if(SDL_InitSubSystem(SDL_INIT_VIDEO)==-1)
- {
-  puts(SDL_GetError());
-  return(0);
- }
- inited|=1;
-
- SDL_ShowCursor(0);
- tlines=_eline-_sline+1;
-
- vinf=SDL_GetVideoInfo();
-
- if(vinf->hw_available)
-  flags|=SDL_HWSURFACE;
-
- if(_fullscreen)
-  flags|=SDL_FULLSCREEN;
- flags|=SDL_HWPALETTE;
-
- if(_fullscreen)
- {
-  exs=_xscalefs;
-  eys=_yscalefs;
-  eefx=_efxfs;
-  if(_xres<NWIDTH*exs || _yres<tlines*eys)
-  {
-   puts("xscale and/or yscale out of bounds.");
-   KillVideo();
-   return(0);
-  }
-  screen = SDL_SetVideoMode(_xres, _yres, 8, flags);
- }
- else
- {
-  exs=_xscale;
-  eys=_yscale;
-  eefx=_efx;
-  screen = SDL_SetVideoMode(NWIDTH*exs, tlines*eys, 8, flags);
- }
- if(!screen)
- {
-  puts(SDL_GetError());
-  KillVideo();
-  return(0);
- }
- inited=1;
- CleanSurface();
-
- SDL_WM_SetCaption("FCE Ultra","FCE Ultra");
- paletterefresh=1;
- printf("srendline %d, erendline %d\n", srendline, erendline);
- return 1;
-#endif
-}
 
 
-void ToggleFS(void)
+int InitVideo(void)
 {
 {
-#ifndef GP2X
- KillVideo();
- _fullscreen=!_fullscreen;
-
- if(!InitVideo())
- {
-  _fullscreen=!_fullscreen;
-  if(!InitVideo())
-  {
-   puts("Gah, bailing out.");
-   exit(1);
-  }
- }
-#endif
-}
+       fps_str[0]=0;
 
 
+       CleanSurface();
 
 
-#ifndef GP2X
-static SDL_Color psdl[256];
+       puts("Initialized GP2X VIDEO via minimal");
 
 
-void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)
-{
-
- psdl[index].r=r;
- psdl[index].g=g;
- psdl[index].b=b;
-
- paletterefresh=1;
+       srendline=0;
+       erendline=239;
+       return 1;
 }
 
 }
 
-void FCEUD_GetPalette(uint8 index, uint8 *r, uint8 *g, uint8 *b)
-{
- *r=psdl[index].r;
- *g=psdl[index].g;
- *b=psdl[index].b;
-}
 
 
-static void RedoPalette(void)
+void ToggleFS(void)
 {
 {
- SDL_SetPalette(screen,SDL_PHYSPAL,psdl,0,256);
 }
 }
-#else
-
 
 
 void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)
 {
 
 
 void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)
 {
-  gp2x_video_color8(index, r, g, b);
-  gp2x_video_setpalette();
-
+       gp2x_video_color8(index, r, g, b);
+       gp2x_video_setpalette();
 
 
-  paletterefresh = 1;
-}
-void FCEUD_GetPalette(uint8 index, uint8 * r, uint8 * g, uint8 * b)
-{
-  *r = (uint8) gp2x_palette[(index << 1) + 1];
-  *g = (uint8) (gp2x_palette[(index << 1) + 0] >> 8);
-  *b = (uint8) gp2x_palette[(index << 1) + 0];
+       paletterefresh = 1;
 }
 
 }
 
-static void RedoPalette(void)
+
+void FCEUD_GetPalette(uint8 index, uint8 * r, uint8 * g, uint8 * b)
 {
 {
+       *r = (uint8) gp2x_palette[(index << 1) + 1];
+       *g = (uint8) (gp2x_palette[(index << 1) + 0] >> 8);
+       *b = (uint8) gp2x_palette[(index << 1) + 0];
 }
 
 
 }
 
 
-
-unsigned int gp2x_ticks_per_ms=7372800; 
-int needfpsflip=1;
-#ifdef FRAMESKIP
-int skipval=16;
-int framecount=0;
-int numrepeats=0;
-int doskipping=0;
-#endif
-
-
-INLINE void printFps(uint8 *screen)
-{ 
-     int y;  
-     int* destt;
-
-     if (needfpsflip)
-     { 
-        if (stretch_offset > 0)
-       {
-          y=240;
-          while (y--)
-          {
-
-          int* dest=(int *) (screen+((y << 8) + (y << 6))+stretch_offset);
-
-          destt=dest - 8;
-          destt[0]=0x3F3F3F3F; destt[1]=0x3F3F3F3F; destt[2]=0x3F3F3F3F; destt[3]=0x3F3F3F3F;
-          destt[4]=0x3F3F3F3F; destt[5]=0x3F3F3F3F; destt[6]=0x3F3F3F3F; destt[7]=0x3F3F3F3F;
-
-          destt=dest + 64;
-          destt[0]=0x3F3F3F3F; destt[1]=0x3F3F3F3F; destt[2]=0x3F3F3F3F; destt[3]=0x3F3F3F3F;
-          destt[4]=0x3F3F3F3F; destt[5]=0x3F3F3F3F; destt[6]=0x3F3F3F3F; destt[7]=0x3F3F3F3F;
-          }
-          if (showfps)
-          {
-            gp2x_text(screen, 0, 0, fps_str, FPS_COLOR, 0);
-          }
-       }
-
-       if (needfpsflip <= 3)
-       {
-                if (showfps)
-                {
-           gp2x_text(screen, 0, 0, fps_str, FPS_COLOR, 0);
-                }
-         needfpsflip++;
-       }
-       else
-       {
-         needfpsflip=0;
-       }
-     }
-#ifdef FRAMESKIP
-     if ((fps < 59) && doskipping && ((framesRendered % skipval) == (skipval-1)))  
-     {
-       FCEUI_FrameSkip(1);
-     }
-#endif     
-     if ((framesRendered & 0x3F) != 0x3F)
-     { 
-       return;
-     }
-
-     unsigned long currTime=gp2x_timer_read_ms();
-     fps= (unsigned long)( framesRendered * 7372800 / (currTime - ticks));
-       if (fps > 90) 
-         fps=90;
-
-       if (fps > 30)
-       {
-         fps_samplecount++;
-         total_fps+=fps;
-       }
-       if (stretch_offset && showfps)
-       {
-         sprintf(fps_str, "%d", (int)fps);
-         needfpsflip=1;
-         fps_str[2]=0;
-         gp2x_text(screen, 0, 0, fps_str, stretch_offset, 0);
-       }
-       
-#ifdef FRAMESKIP
-  if (fps < 59)
-  {
-    numrepeats++;
-    if (numrepeats >= 4)
-    {
-       if (skipval > 4)
-       {
-         skipval-=2;
-       }
-       doskipping=1;
-       printf("skipping every %dth frame, currfps=%d\n", skipval, fps);
-       numrepeats=0;       
-    }
-  }
-  else
-  {
-       numrepeats=0;
-  }
-#endif
-       ticks = currTime;
-       framesRendered = 0;
+static INLINE void printFps(uint8 *screen)
+{
+       struct timeval tv_now;
+       static int prevsec, needfpsflip = 0;
+
+       gettimeofday(&tv_now, 0);
+       if (prevsec != tv_now.tv_sec)
+       {
+               sprintf(fps_str, "%i/%i", framesRendered, framesEmulated);
+               framesEmulated = framesRendered = 0;
+               needfpsflip = 4;
+               prevsec = tv_now.tv_sec;
+       }
+
+       if (stretch_offset > 0)
+       {
+               if (needfpsflip)
+               {
+                       int y, *destt = (int *) screen;
+                       for (y = 240; y; y--)
+                       {
+                               *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F;
+                               *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F;
+                               destt += 64;
+
+                               *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F;
+                               *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F;
+                       }
+                       if (showfps)
+                       {
+                               fps_str[2] = 0;
+                               gp2x_text(screen, 0,  0, fps_str,   FPS_COLOR, 0);
+                               gp2x_text(screen, 0, 10, fps_str+3, FPS_COLOR, 0);
+                       }
+                       needfpsflip--;
+               }
+       }
+       else
+       {
+               if (showfps)
+               {
+                       gp2x_text(screen, 0, 0, fps_str, FPS_COLOR, 0);
+               }
+       }
 }
 }
-#endif
-
-
-
-
-
-
 
 
 
 
-
-
-
-void LockConsole(){}
-void UnlockConsole(){}
-
-
-#ifdef GP2X
-
 void BlitScreen(uint8 * XBuf)
 void BlitScreen(uint8 * XBuf)
-{ 
-  
-  int x, y, yinc;
-  if (!XBuf) return;
-  XBufHelper=XBuf;
-  framesRendered++;
-  XBuf = XBuf ;
-
-      y=240;
-      yinc=272*(y-1);
-      while (y--)
-      {
-        int* dest=(int *) (gp2x_screen8+((y << 8) + (y << 6))+stretch_offset);
-        
-        int* src=(int *) (XBuf+yinc);          
-        x=64;
-        while (x--)
-        {
-          dest[x]=src[x];
-        }
-        yinc-=272;
-      }
-
-  if (paletterefresh)
-  {
-      gp2x_video_setpalette();
-      paletterefresh = 0;
-  }
-
-  printFps(gp2x_screen8);
-  gp2x_video_flip();
-}
-
-
-
-
-#else
-extern void SpeedThrottle();
-void BlitScreen(uint8 *XBuf)
 {
 {
- uint8 *dest;
- int xo=0,yo=0;
+       int x, y, yinc;
 
 
SpeedThrottle();
      framesEmulated++;
 
 
- if(paletterefresh)
- {
-  RedoPalette();
-  paletterefresh=0;
- }
+       if (!XBuf) return;
 
 
XBuf+=_sline*272;
      framesRendered++;
 
 
- if(SDL_MUSTLOCK(screen))
-  SDL_LockSurface(screen);
+#if 1 // 48->54
+       y=240;
+       yinc=272*(y-1);
+       while (y--)
+       {
+               int* dest=(int *) (gp2x_screen8+((y << 8) + (y << 6))+stretch_offset);
 
 
- dest=screen->pixels;
-
- if(_fullscreen)
- {
-  xo=(((screen->w-NWIDTH*exs))>>1);
-  dest+=xo;
-  if(screen->h>(tlines*eys))
-  {
-   yo=((screen->h-tlines*eys)>>1);
-   dest+=yo*screen->pitch;
-  }
- }
-
- Blit8To8(XBuf+NOFFSET,dest, NWIDTH, tlines, screen->pitch,exs,eys,eefx);
-
- if(SDL_MUSTLOCK(screen))
-  SDL_UnlockSurface(screen);
-
- SDL_UpdateRect(screen, xo, yo, NWIDTH*exs, tlines*eys);
-
- if (0)
- {
-   gp2x_text(NULL, 0, 0, NULL, 0, 0);
- }
+               int* src=(int *) (XBuf+yinc);
+               x=64;
+               while (x--)
+               {
+                       dest[x]=src[x];
+               }
+               yinc-=272;
+       }
+
+       if (paletterefresh)
+       {
+               gp2x_video_setpalette();
+               paletterefresh = 0;
+       }
+#endif
+       printFps(gp2x_screen8);
+       gp2x_video_flip();
 }
 
 }
 
-uint32 PtoV(uint16 x, uint16 y)
-{
- if(_fullscreen)
- {
-
- }
- else
- {
-  if(eoptions&EO_CLIPSIDES)
-   x+=8;
-  y+=srendline;
- }
- return(x|(y<<16));
-}
-#endif
+
index 91879ae..81cd916 100644 (file)
@@ -2,6 +2,7 @@
 #include "main.h"
 #include "throttle.h"
 
 #include "main.h"
 #include "throttle.h"
 
+#if 0
 static uint64 tfreq;
 static uint64 desiredfps;
 
 static uint64 tfreq;
 static uint64 desiredfps;
 
@@ -44,3 +45,66 @@ INLINE void SpeedThrottle(void)
   ltime+=tfreq/desiredfps;
 }
 
   ltime+=tfreq/desiredfps;
 }
 
+#else
+
+extern uint8 PAL;
+extern int FSkip, FSkip_setting;
+static int usec_aim = 0, usec_done = 0;
+static int skip_count = 0;
+
+INLINE void SpeedThrottle(void)
+{
+       static struct timeval tv_prev;
+       struct timeval tv_now;
+       int delta_nom = PAL ? 19997 : 16639; // ~50.007, 19.997 ms/frame : ~60.1, 16.639 ms/frame
+
+
+       if (usec_done == 0) { // first time
+               usec_done = 1;
+               gettimeofday(&tv_prev, 0);
+               return;
+       }
+
+       gettimeofday(&tv_now, 0);
+
+       usec_aim += delta_nom;
+       if (tv_now.tv_sec != tv_prev.tv_sec)
+               usec_done += 1000000;
+       usec_done += tv_now.tv_usec - tv_prev.tv_usec;
+
+#ifdef FRAMESKIP
+       if (FSkip_setting >= 0)
+       {
+               if (skip_count >= FSkip_setting)
+                       skip_count = 0;
+               else {
+                       skip_count++;
+                       FSkip = 1;
+               }
+       }
+       else if (usec_done > usec_aim)
+       {
+               /* auto frameskip */
+               if (usec_done - usec_aim > 150000)
+                       usec_done = usec_aim = 0; // too much behind, try to recover..
+               FSkip = 1;
+               tv_prev = tv_now;
+               return;
+       }
+#endif
+
+       tv_prev = tv_now;
+       while (usec_done < usec_aim)
+       {
+               gettimeofday(&tv_now, 0);
+
+               if (tv_now.tv_sec != tv_prev.tv_sec)
+                       usec_done += 1000000;
+               usec_done += tv_now.tv_usec - tv_prev.tv_usec;
+               tv_prev = tv_now;
+       }
+       usec_done = usec_done - usec_aim + 1; // reset to prevent overflows
+       usec_aim = 0;
+}
+#endif
+
diff --git a/fce.c b/fce.c
index 5b72b3b..214a41f 100644 (file)
--- a/fce.c
+++ b/fce.c
@@ -1,7 +1,7 @@
 /* FCE Ultra - NES/Famicom Emulator
  *
  * Copyright notice for this file:
 /* FCE Ultra - NES/Famicom Emulator
  *
  * Copyright notice for this file:
- *  Copyright (C) 1998 BERO 
+ *  Copyright (C) 1998 BERO
  *  Copyright (C) 2002 Ben Parnell
  *
  * This program is free software; you can redistribute it and/or modify
  *  Copyright (C) 2002 Ben Parnell
  *
  * This program is free software; you can redistribute it and/or modify
@@ -63,7 +63,7 @@ int MMC5Hack;
 uint32 MMC5HackVROMMask;
 uint8 *MMC5HackExNTARAMPtr;
 uint8 *MMC5HackVROMPTR;
 uint32 MMC5HackVROMMask;
 uint8 *MMC5HackExNTARAMPtr;
 uint8 *MMC5HackVROMPTR;
-uint8 MMC5HackCHRMode=0; 
+uint8 MMC5HackCHRMode=0;
 uint8 MMC5HackSPMode;
 uint8 MMC5HackSPScroll;
 uint8 MMC5HackSPPage;
 uint8 MMC5HackSPMode;
 uint8 MMC5HackSPScroll;
 uint8 MMC5HackSPPage;
@@ -217,9 +217,9 @@ uint8 PAL=0;
 
 #define MMC5BGVRAMADR(V)      &MMC5BGVPage[(V)>>10][(V)]
 #define        VRAMADR(V)      &VPage[(V)>>10][(V)]
 
 #define MMC5BGVRAMADR(V)      &MMC5BGVPage[(V)>>10][(V)]
 #define        VRAMADR(V)      &VPage[(V)>>10][(V)]
+
 static DECLFW(BRAML)
 static DECLFW(BRAML)
-{  
+{
         RAM[A]=V;
 }
 
         RAM[A]=V;
 }
 
@@ -238,7 +238,7 @@ static DECLFR(ARAMH)
         return RAM[A&0x7FF];
 }
 
         return RAM[A&0x7FF];
 }
 
-           
+
 static DECLFR(A2002)
 {
                         uint8 ret;
 static DECLFR(A2002)
 {
                         uint8 ret;
@@ -260,11 +260,11 @@ static DECLFR(A2007)
 
                         PPUGenLatch=ret=VRAMBuffer;
                        if(PPU_hook) PPU_hook(tmp);
 
                         PPUGenLatch=ret=VRAMBuffer;
                        if(PPU_hook) PPU_hook(tmp);
-                        if(tmp<0x2000) 
+                        if(tmp<0x2000)
                        {
                         VRAMBuffer=VPage[tmp>>10][tmp];
                        }
                        {
                         VRAMBuffer=VPage[tmp>>10][tmp];
                        }
-                        else 
+                        else
                        {
                         VRAMBuffer=vnapage[(tmp>>10)&0x3][tmp&0x3FF];
                        }
                        {
                         VRAMBuffer=vnapage[(tmp>>10)&0x3][tmp&0x3FF];
                        }
@@ -366,7 +366,7 @@ static DECLFW(B2006)
 }
 
 static DECLFW(B2007)
 }
 
 static DECLFW(B2007)
-{  
+{
                        uint32 tmp=RefreshAddr&0x3FFF;
 
                         PPUGenLatch=V;
                        uint32 tmp=RefreshAddr&0x3FFF;
 
                         PPUGenLatch=V;
@@ -384,7 +384,7 @@ static DECLFW(B2007)
                             VPage[tmp>>10][tmp]=V;
                         }
                         else
                             VPage[tmp>>10][tmp]=V;
                         }
                         else
-                       {                                               
+                       {
                          if(PPUNTARAM&(1<<((tmp&0xF00)>>10)))
                           vnapage[((tmp&0xF00)>>10)][tmp&0x3FF]=V;
                         }
                          if(PPUNTARAM&(1<<((tmp&0xF00)>>10)))
                           vnapage[((tmp&0xF00)>>10)][tmp&0x3FF]=V;
                         }
@@ -394,7 +394,7 @@ static DECLFW(B2007)
 }
 
 static DECLFW(B4014)
 }
 
 static DECLFW(B4014)
-{                        
+{
        uint32 t=V<<8;
        int x;
        for(x=0;x<256;x++)
        uint32 t=V<<8;
        int x;
        for(x=0;x<256;x++)
@@ -415,7 +415,7 @@ void BGRender(uint8 *target)
 }
 
 #ifdef FRAMESKIP
 }
 
 #ifdef FRAMESKIP
-extern int framesRendered;
+int FSkip_setting=-1; // auto
 int FSkip=0;
 void FCEUI_FrameSkip(int x)
 {
 int FSkip=0;
 void FCEUI_FrameSkip(int x)
 {
@@ -466,7 +466,7 @@ static void Loop6502(void)
         {
         #endif
          if(PPU[1]&0x01)
         {
         #endif
          if(PPU[1]&0x01)
-         { 
+         {
           for(x=63;x>=0;x--)
            *(uint32 *)&target[x<<2]=(*(uint32*)&target[x<<2])&0xF0F0F0F0;
          }
           for(x=63;x>=0;x--)
            *(uint32 *)&target[x<<2]=(*(uint32*)&target[x<<2])&0xF0F0F0F0;
          }
@@ -488,7 +488,7 @@ static void Loop6502(void)
        {
         tem=Pal[0]|(Pal[0]<<8)|(Pal[0]<<16)|(Pal[0]<<24);
         FCEU_dwmemset(target,tem,256);
        {
         tem=Pal[0]|(Pal[0]<<8)|(Pal[0]<<16)|(Pal[0]<<24);
         FCEU_dwmemset(target,tem,256);
-       }               
+       }
         if(InputScanlineHook)
          InputScanlineHook(target, scanline);
 }
         if(InputScanlineHook)
          InputScanlineHook(target, scanline);
 }
@@ -526,10 +526,10 @@ static void FASTAPASS(1) RefreshLine(uint8 *target)
 {
        uint32 vofs;
         int X1;
 {
        uint32 vofs;
         int X1;
-        uint8 *P=target; 
+        uint8 *P=target;
 
        vofs=0;
 
        vofs=0;
-       
+
         Pal[0]|=64;
         Pal[4]|=64;
         Pal[8]|=64;
         Pal[0]|=64;
         Pal[4]|=64;
         Pal[8]|=64;
@@ -556,12 +556,12 @@ static void FASTAPASS(1) RefreshLine(uint8 *target)
                 uint8 cc,zz,zz2;
                 uint32 vadr;
 
                 uint8 cc,zz,zz2;
                 uint32 vadr;
 
-                if((tochange<=0 && MMC5HackSPMode&0x40) || 
+                if((tochange<=0 && MMC5HackSPMode&0x40) ||
                   (tochange>0 && !(MMC5HackSPMode&0x40)))
                 {
                  uint8 xs,ys;
 
                   (tochange>0 && !(MMC5HackSPMode&0x40)))
                 {
                  uint8 xs,ys;
 
-                 xs=33-X1; 
+                 xs=33-X1;
                  ys=((scanline>>3)+MMC5HackSPScroll)&0x1F;
                  if(ys>=0x1E) ys-=0x1E;
                  vadr=(MMC5HackExNTARAMPtr[xs|(ys<<5)]<<4)+(vofs&7);
                  ys=((scanline>>3)+MMC5HackSPScroll)&0x1F;
                  if(ys>=0x1E) ys-=0x1E;
                  vadr=(MMC5HackExNTARAMPtr[xs|(ys<<5)]<<4)+(vofs&7);
@@ -608,7 +608,7 @@ static void FASTAPASS(1) RefreshLine(uint8 *target)
                 {
                  uint8 xs,ys;
 
                 {
                  uint8 xs,ys;
 
-                 xs=33-X1; 
+                 xs=33-X1;
                  ys=((scanline>>3)+MMC5HackSPScroll)&0x1F;
                  if(ys>=0x1E) ys-=0x1E;
                  vadr=(MMC5HackExNTARAMPtr[xs|(ys<<5)]<<4)+(vofs&7);
                  ys=((scanline>>3)+MMC5HackSPScroll)&0x1F;
                  if(ys>=0x1E) ys-=0x1E;
                  vadr=(MMC5HackExNTARAMPtr[xs|(ys<<5)]<<4)+(vofs&7);
@@ -642,15 +642,15 @@ static void FASTAPASS(1) RefreshLine(uint8 *target)
          {
           for(X1=33;X1;X1--,P+=8)
           {
          {
           for(X1=33;X1;X1--,P+=8)
           {
-                uint8 *C;                                   
+                uint8 *C;
                 uint8 cc;
                 uint8 zz2;
                 uint8 cc;
                 uint8 zz2;
-                uint32 vadr;  
+                uint32 vadr;
 
                 C=MMC5HackVROMPTR;
                 zz2=(RefreshAddr>>10)&3;
                 vadr = (vnapage[zz2][RefreshAddr & 0x3ff] << 4) + vofs;
 
                 C=MMC5HackVROMPTR;
                 zz2=(RefreshAddr>>10)&3;
                 vadr = (vnapage[zz2][RefreshAddr & 0x3ff] << 4) + vofs;
-                C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f & 
+                C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f &
                        MMC5HackVROMMask) << 12) + (vadr & 0xfff);
                 vadr = (MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff] & 0xC0)>> 4;
                 cc = vadr;
                        MMC5HackVROMMask) << 12) + (vadr & 0xfff);
                 vadr = (MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff] & 0xC0)>> 4;
                 cc = vadr;
@@ -678,22 +678,22 @@ static void FASTAPASS(1) RefreshLine(uint8 *target)
                 cc=((cc >> ((zz&2) + ((RefreshAddr&0x40)>>4))) &3) <<2;
 
                #include "fceline.h"
                 cc=((cc >> ((zz&2) + ((RefreshAddr&0x40)>>4))) &3) <<2;
 
                #include "fceline.h"
-                
+
                if((RefreshAddr&0x1f)==0x1f)
                  RefreshAddr^=0x41F;
                 else
                  RefreshAddr++;
                if((RefreshAddr&0x1f)==0x1f)
                  RefreshAddr^=0x41F;
                 else
                  RefreshAddr++;
-          }          
+          }
          }
          }
-        }       // End if(MMC5Hack) 
+        }       // End if(MMC5Hack)
 
         else if(PPU_hook)
         {
          for(X1=33;X1;X1--,P+=8)
          {
 
         else if(PPU_hook)
         {
          for(X1=33;X1;X1--,P+=8)
          {
-                uint8 *C;                                   
+                uint8 *C;
                 uint8 cc,zz,zz2;
                 uint8 cc,zz,zz2;
-                uint32 vadr;  
+                uint32 vadr;
 
                 zz=RefreshAddr&0x1F;
                 zz2=(RefreshAddr>>10)&3;
 
                 zz=RefreshAddr&0x1F;
                 zz2=(RefreshAddr>>10)&3;
@@ -714,7 +714,7 @@ static void FASTAPASS(1) RefreshLine(uint8 *target)
          }
         }
         else
          }
         }
         else
-        {      
+        {
          for(X1=33;X1;X1--,P+=8)
          {
                 uint8 *C;
          for(X1=33;X1;X1--,P+=8)
          {
                 uint8 *C;
@@ -728,7 +728,7 @@ static void FASTAPASS(1) RefreshLine(uint8 *target)
                cc=vnapage[zz2][0x3c0+(zz>>2)+((RefreshAddr&0x380)>>4)];
                cc=((cc >> ((zz&2) + ((RefreshAddr&0x40)>>4))) &3) <<2;
                #include "fceline.h"
                cc=vnapage[zz2][0x3c0+(zz>>2)+((RefreshAddr&0x380)>>4)];
                cc=((cc >> ((zz&2) + ((RefreshAddr&0x40)>>4))) &3) <<2;
                #include "fceline.h"
-                
+
                 if((RefreshAddr&0x1f)==0x1f)
                  RefreshAddr^=0x41F;
                 else
                 if((RefreshAddr&0x1f)==0x1f)
                  RefreshAddr^=0x41F;
                 else
@@ -874,7 +874,7 @@ void CloseGame(void)
    FlushGameCheats();
   #ifdef NETWORK
   if(FSettings.NetworkPlay) KillNetplay();
    FlushGameCheats();
   #ifdef NETWORK
   if(FSettings.NetworkPlay) KillNetplay();
-  #endif       
+  #endif
   GameInterface(GI_CLOSE);
   CloseGenie();
   GameLoaded=0;
   GameInterface(GI_CLOSE);
   CloseGenie();
   GameLoaded=0;
@@ -934,7 +934,7 @@ FCEUGI *FCEUI_LoadGame(char *name)
 
         endlseq:
         FCEU_fclose(fp);
 
         endlseq:
         FCEU_fclose(fp);
-        GameLoaded=1;        
+        GameLoaded=1;
 
         FCEU_ResetVidSys();
         if(FCEUGameInfo.type!=GIT_NSF)
 
         FCEU_ResetVidSys();
         if(FCEUGameInfo.type!=GIT_NSF)
@@ -951,7 +951,7 @@ FCEUGI *FCEUI_LoadGame(char *name)
          LoadGamePalette();
          LoadGameCheats();
         }
          LoadGamePalette();
          LoadGameCheats();
         }
-        
+
        FCEU_ResetPalette();
         Exit=0;
         return(&FCEUGameInfo);
        FCEU_ResetPalette();
         Exit=0;
         return(&FCEUGameInfo);
@@ -983,6 +983,7 @@ void FCEU_ResetVidSys(void)
   FSettings.FirstSLine=FSettings.UsrFirstSLine[0];
   FSettings.LastSLine=FSettings.UsrLastSLine[0];
  }
   FSettings.FirstSLine=FSettings.UsrFirstSLine[0];
   FSettings.LastSLine=FSettings.UsrLastSLine[0];
  }
+ printf("PAL = %i\n", PAL);
  SetSoundVariables();
 }
 
  SetSoundVariables();
 }
 
@@ -1004,7 +1005,7 @@ static INLINE void Thingo(void)
    Loop6502();
 
    if(tosprite>=256)
    Loop6502();
 
    if(tosprite>=256)
-   { 
+   {
     X6502_Run(256-harko);
     Fixit1();
     X6502_Run(harko);
     X6502_Run(256-harko);
     Fixit1();
     X6502_Run(harko);
@@ -1047,14 +1048,14 @@ void EmLoop(void)
                                  breaks a Super Donkey Kong game. */
 
   X6502_Run(12);               /* I need to figure out the true nature and length
                                  breaks a Super Donkey Kong game. */
 
   X6502_Run(12);               /* I need to figure out the true nature and length
-                                  of this delay. 
+                                  of this delay.
                                */
   if(FCEUGameInfo.type==GIT_NSF)
    TriggerNMINSF();
   else if(VBlankON)
    TriggerNMI();
 
                                */
   if(FCEUGameInfo.type==GIT_NSF)
    TriggerNMINSF();
   else if(VBlankON)
    TriggerNMI();
 
-  X6502_Run((scanlines_per_frame-242)*(256+85)-12); 
+  X6502_Run((scanlines_per_frame-242)*(256+85)-12);
 
   PPU_status&=0x1f;
 
 
   PPU_status&=0x1f;
 
@@ -1110,7 +1111,6 @@ void EmLoop(void)
    {
     FCEU_PutImageDummy();
     FSkip--;
    {
     FCEU_PutImageDummy();
     FSkip--;
-    framesRendered++;
     FCEUD_Update(0,WaveFinalMono,ssize);
    }
    else
     FCEUD_Update(0,WaveFinalMono,ssize);
    }
    else
@@ -1194,7 +1194,7 @@ void ResetNES(void)
         X6502_Reset();
 }
 
         X6502_Reset();
 }
 
-void PowerNES(void) 
+void PowerNES(void)
 {
         if(!GameLoaded) return;
 
 {
         if(!GameLoaded) return;