cleanups, savestates, input (combos), menu
authornotaz <notasas@gmail.com>
Thu, 17 May 2007 21:18:17 +0000 (21:18 +0000)
committernotaz <notasas@gmail.com>
Thu, 17 May 2007 21:18:17 +0000 (21:18 +0000)
git-svn-id: file:///home/notaz/opt/svn/fceu@134 be3aeb3a-fb24-0410-a615-afba39da0efa

Makefile.gp2x
drivers/gp2x/dface.h
drivers/gp2x/gp2x.c
drivers/gp2x/input.c
drivers/gp2x/main.c
drivers/gp2x/menu.c
sound.h
state.c
svga.c

index 6b82e47..40d3c4f 100644 (file)
@@ -23,8 +23,8 @@ asm_6502=1
 
 all:           fceu
 
-gpfce: fceu
-       cp fceu gpfce
+gpfce.gpe: fceu
+       cp fceu $@
 
 include zlib/Makefile
 
@@ -81,7 +81,7 @@ $(error need VER)
 endif
 endif
 
-rel: gpfce
-       zip -9 -j Gpfce_v$(VER).zip $^ drivers/gp2x/mmuhack.o out_gp2x/*
+rel: gpfce.gpe
+       zip -9 -j gpfce_v$(VER).zip $^ drivers/gp2x/mmuhack.o
 
 
index f2c569e..486b4d4 100644 (file)
@@ -12,19 +12,10 @@ void KillSound(void);
 void SilenceSound(int s); /* DOS and SDL */
 
 
-int InitMouse(void);
-void KillMouse(void);
-void GetMouseData(uint32 *MouseData);
-
 int InitJoysticks(void);
 void KillJoysticks(void);
 uint32 *GetJSOr(void);
 
-int InitKeyboard(void);
-int UpdateKeyboard(void);
-char *GetKeyboard(void);
-void KillKeyboard(void);
-
 int InitVideo(void);
 void KillVideo(void);
 void BlitScreen(uint8 *buf);
index 0c48ad4..fbc1c9e 100644 (file)
@@ -116,37 +116,6 @@ void DoDriverArgs(void)
        #endif
 }
 
-int InitMouse(void)
-{
- return(0);
-}
-
-void KillMouse(void){}
-
-void GetMouseData(uint32 *d)
-{
-}
-
-int InitKeyboard(void)
-{
- return(1);
-}
-
-int UpdateKeyboard(void)
-{
- return(1);
-}
-
-void KillKeyboard(void)
-{
-
-}
-
-char *GetKeyboard(void)
-{
- return NULL;
-}
-
 
 char **g_argv;
 int mmuhack_status = 0;
index 8345339..1506f4e 100644 (file)
@@ -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
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#define JOY_A   1
-#define JOY_B   2
-#define JOY_SELECT      4
-#define JOY_START       8
-#define JOY_UP  0x10
-#define JOY_DOWN        0x20
-#define JOY_LEFT        0x40
-#define JOY_RIGHT       0x80
-
-#include "minimal.h"
-
-extern uint8 Exit; // exit emu loop
-
+#include "../../state.h"
+#include "../../general.h"
 
 /* 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 UsrInputTypeFC={SI_NONE};
+
+static int InputType[2];
 static int InputTypeFC;
 
 static uint32 JSreturn;
-int NoWaiting=0;
 
 static int powerpadsc[2][12];
 static int powerpadside=0;
 
-
 static uint32 MouseData[3];
 static uint8 fkbkeys[0x48];
-unsigned long lastpad=0;
 
-char soundvolmeter[21];
-int soundvolIndex=0;
+static uint32 combo_acts = 0, combo_keys = 0;
+static uint32 prev_emu_acts = 0;
 
 
 static void setsoundvol(int soundvolume)
 {
-    //FCEUI_SetSoundVolume(soundvol);
-    // draw on screen :D
-    gp2x_sound_volume(soundvolume, soundvolume);
-    int meterval=soundvolume/5;
-    for (soundvolIndex=0; soundvolIndex < 20; soundvolIndex++)
-    {
-       if (soundvolIndex < meterval)
-       {
-                 soundvolmeter[soundvolIndex]='*';
-       }
-       else
-       {
-                 soundvolmeter[soundvolIndex]='_';
-       }
-    }
-    soundvolmeter[20]=0;
-    FCEU_DispMessage("|%s|", soundvolmeter);
+       int soundvolIndex;
+       static char soundvolmeter[24];
+
+       // draw on screen :D
+       gp2x_sound_volume(soundvolume, soundvolume);
+       int meterval=soundvolume/5;
+       for (soundvolIndex = 0; soundvolIndex < 20; soundvolIndex++)
+       {
+               if (soundvolIndex < meterval)
+               {
+                       soundvolmeter[soundvolIndex]='*';
+               }
+               else
+               {
+                       soundvolmeter[soundvolIndex]='_';
+               }
+       }
+       soundvolmeter[20]=0;
+       FCEU_DispMessage("|%s|", soundvolmeter);
 }
 
 
+static void do_emu_acts(uint32 acts)
+{
+       uint32 actsc = acts;
+       acts &= acts ^ prev_emu_acts;
+       prev_emu_acts = actsc;
+
+       if (acts & (3 << 30))
+       {
+               if (acts & (1 << 30))
+               {
+                       FCEUI_LoadState();
+               }
+               else
+               {
+                       FCEUI_SaveState();
+               }
+       }
+       else if (acts & (1 << 29))
+       {
+               FILE *st;
+               char *fname;
+
+               CurrentState++;
+               if (CurrentState > 9) CurrentState = 0;
+
+               fname = FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0);
+               st=fopen(fname,"rb");
+               free(fname);
+               FCEU_DispMessage("[%s] State Slot %i", st ? "USED" : "FREE", CurrentState);
+               if (st) fclose(st);
+       }
+}
+
 
 void FCEUD_UpdateInput(void)
 {
        static int volpushed_frames = 0;
        static int turbo_rate_cnt_a = 0, turbo_rate_cnt_b = 0;
-       long lastpad2 = lastpad;
        unsigned long keys = gp2x_joystick_read(0);
-       uint32 JS = 0; // RLDU SEBA
+       uint32 all_acts = 0;
        int i;
 
        #define down(b) (keys & GP2X_##b)
        if ((down(VOL_DOWN) && down(VOL_UP)) || (keys & (GP2X_L|GP2X_L|GP2X_START)) == (GP2X_L|GP2X_L|GP2X_START))
        {
                Exit = 1;
-               JSreturn = 0;
                return;
        }
        else if (down(VOL_UP))
@@ -120,36 +136,53 @@ void FCEUD_UpdateInput(void)
        }
 
 
+       JSreturn = 0; // RLDU SEBA
+
        for (i = 0; i < 32; i++)
        {
-               if (keys & (1 << i)) {
-                       int acts = Settings.KeyBinds[i];
+               if (keys & (1 << i))
+               {
+                       uint32 acts, u = 32;
+                       acts = Settings.KeyBinds[i];
                        if (!acts) continue;
-                       JS |= acts & 0xff;
-                       if (acts & 0x100) {             // A turbo
-                               turbo_rate_cnt_a += Settings.turbo_rate_add;
-                               JS |= (turbo_rate_cnt_a >> 24) & 1;
-                       }
-                       if (acts & 0x200) {             // B turbo
-                               turbo_rate_cnt_b += Settings.turbo_rate_add;
-                               JS |= (turbo_rate_cnt_b >> 23) & 2;
+                       if ((1 << i) & combo_keys)
+                       {
+                               // combo key detected, try to find if other is pressed
+                               for (u = i+1; u < 32; u++)
+                               {
+                                       if ((keys & (1 << u)) && (Settings.KeyBinds[u] & acts))
+                                       {
+                                               keys &= ~(1 << u);
+                                               break;
+                                       }
+                               }
                        }
+                       if (u != 32) acts &=  combo_acts; // other combo key pressed
+                       else         acts &= ~combo_acts;
+                       all_acts |= acts;
                }
        }
 
+       JSreturn |= all_acts & 0xff;
+       if (all_acts & 0x100) {         // A turbo
+               turbo_rate_cnt_a += Settings.turbo_rate_add;
+               JSreturn |= (turbo_rate_cnt_a >> 24) & 1;
+       }
+       if (all_acts & 0x200) {         // B turbo
+               turbo_rate_cnt_b += Settings.turbo_rate_add;
+               JSreturn |= (turbo_rate_cnt_b >> 23) & 2;
+       }
 
-       JSreturn = JS;
-       lastpad=keys;
+       do_emu_acts(all_acts);
 
-       //JSreturn=(JS&0xFF000000)|(JS&0xFF)|((JS&0xFF0000)>>8)|((JS&0xFF00)<<8);
 
-#define pad keys
+       //JSreturn=(JS&0xFF000000)|(JS&0xFF)|((JS&0xFF0000)>>8)|((JS&0xFF00)<<8);
 
   //  JSreturn=(JSreturn&0xFF000000)|(JSreturn&0xFF)|((JSreturn&0xFF0000)>>8)|((JSreturn&0xFF00)<<8);
   // TODO: make these bindable, use new interface
+  /*
   if(gametype==GIT_FDS)
   {
-    NoWaiting&=~1;
        if ((pad & GP2X_PUSH) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_L)) && (!(pad & GP2X_R)) && (!(lastpad2 & GP2X_PUSH)))
        {
       DriverInterface(DES_FDSSELECT,0);
@@ -164,6 +197,7 @@ void FCEUD_UpdateInput(void)
        }
   }
   return;
+  */
 }
 
 
@@ -205,9 +239,41 @@ static void InitOtherInput(void)
    FCEUI_SetInputFC(InputTypeFC,InputDPtr,attrib);
    FCEUI_DisableFourScore(eoptions&EO_NOFOURSCORE);
 
-   if(t && !(inited&16))
-   {
-    InitMouse();
-    inited|=16;
-   }
+   inited|=16;
+}
+
+
+static void PrepareOtherInput(void)
+{
+       uint32 act, key, seen_acts;
+
+       combo_acts = combo_keys = prev_emu_acts = seen_acts = 0;
+
+       // find combo_acts
+       for (act = 1; act; act <<= 1)
+       {
+               for (key = 1; key < 32; key++)
+               {
+                       if (Settings.KeyBinds[key] & act)
+                       {
+                               if (seen_acts & act) combo_acts |= act;
+                               else seen_acts |= act;
+                       }
+               }
+       }
+
+       // find combo_keys
+       for (act = 1; act; act <<= 1)
+       {
+               for (key = 0; key < 32; key++)
+               {
+                       if (Settings.KeyBinds[key] & combo_acts)
+                       {
+                               combo_keys |= 1 << key;
+                       }
+               }
+       }
+
+       printf("generated combo_acts: %08x, combo_keys: %08x\n", combo_acts, combo_keys);
 }
+
index 96ef3f9..f700e4f 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 
 #include "main.h"
+#include "minimal.h"
 #include "throttle.h"
 #include "menu.h"
 #include "gp2x.h"
@@ -294,7 +295,7 @@ static int DoArgs(int argc, char *argv[])
         FCEUI_SetRenderedLines(srendlinev[0],erendlinev[0],srendlinev[1],erendlinev[1]);
         FCEUI_SetRenderedLines(0,erendlinev[0],srendlinev[1],erendlinev[1]);
         FCEUI_SetSoundVolume(soundvol);
-       DriverInterface(DES_NTSCCOL,&ntsccol);
+       DriverInterface(DES_NTSCCOL,&ntsccol); // TODO
        DoDriverArgs();
 
        if(fcexp)
@@ -426,6 +427,7 @@ int CLImain(int argc, char *argv[])
          }
          }
 
+        PrepareOtherInput();
         gp2x_video_changemode(Settings.scaling == 3 ? 15 : 8);
         switch (Settings.scaling & 3) {
                 case 0: gp2x_video_RGB_setscaling(0, 320, 240); gp2x_video_set_offs(0); break;
@@ -453,8 +455,6 @@ static int DriverInitialize(void)
     inited|=2;
    if(!InitVideo()) return 0;
    inited|=4;
-   if(!InitKeyboard()) return 0;
-   inited|=8;
    return 1;
 }
 
@@ -465,23 +465,19 @@ static void DriverKill(void)
 
  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();
 }
index 12d6dc6..a4c2a32 100644 (file)
@@ -682,7 +682,7 @@ static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_i
        // draw cursor\r
        gp2x_text_out15(x - 16, tl_y + sel*10, ">");\r
 \r
-       if (sel < 10) {\r
+       if (sel < opt_cnt) {\r
                gp2x_text_out15(30, 190, "Press a button to bind/unbind");\r
                gp2x_text_out15(30, 200, "Use VOL+ to clear");\r
                gp2x_text_out15(30, 210, "To bind UP/DOWN, hold VOL-");\r
@@ -787,8 +787,9 @@ static bind_action_t ctrl_actions[] =
 \r
 static bind_action_t emuctrl_actions[] =\r
 {\r
-       { "Save State  ", 1<<31 },\r
-       { "Load State  ", 1<<30 },\r
+       { "Save State     ", 1<<31 },\r
+       { "Load State     ", 1<<30 },\r
+       { "Next State Slot", 1<<29 },\r
 };\r
 \r
 static void kc_sel_loop(void)\r
@@ -1012,10 +1013,26 @@ static int menu_loop_options(void)
 \r
 static void draw_menu_credits(void)\r
 {\r
+       char vstr[16];\r
+\r
        //int tl_x = 15, tl_y = 70;\r
        gp2x_fceu_copy_bg();\r
 \r
-       // TODO\r
+       sprintf(vstr, "GPFCE v" GP2X_PORT_VERSION " rev%i", GP2X_PORT_REV);\r
+       gp2x_text_out15(20,  30, vstr);\r
+       gp2x_text_out15(20,  40, "(c) notaz, 2007");\r
+\r
+       gp2x_text_out15(20,  70, "Based on FCE Ultra versions");\r
+       gp2x_text_out15(20,  80, "0.81 and 0.98.15");\r
+\r
+       gp2x_text_out15(20, 110, "         - Credits - ");\r
+       gp2x_text_out15(20, 130, "Bero: FCE");\r
+       gp2x_text_out15(20, 140, "Xodnizel: FCE Ultra");\r
+       gp2x_text_out15(20, 150, "zzhu8192: original port");\r
+       gp2x_text_out15(20, 160, "rlyeh: minimal lib");\r
+       gp2x_text_out15(20, 170, "Hermes, theoddbot, god_at_hell:");\r
+       gp2x_text_out15(20, 180, "  cpuctrl, gamma libs");\r
+       gp2x_text_out15(20, 190, "Squidge: squidgehack");\r
 \r
        gp2x_video_flip();\r
 }\r
@@ -1114,6 +1131,8 @@ static int menu_loop_root(void)
                                                /*if(savestate_menu_loop(0))\r
                                                        continue;*/\r
                                                FCEUI_SaveState();\r
+                                               Exit = 0;\r
+                                               while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000);\r
                                                return 0;\r
                                        }\r
                                        break;\r
@@ -1122,6 +1141,8 @@ static int menu_loop_root(void)
                                                /*if(savestate_menu_loop(1))\r
                                                        continue;*/\r
                                                FCEUI_LoadState();\r
+                                               Exit = 0;\r
+                                               while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000);\r
                                                return 0;\r
                                        }\r
                                        break;\r
diff --git a/sound.h b/sound.h
index 9cffd4c..fcbcb25 100644 (file)
--- a/sound.h
+++ b/sound.h
@@ -36,7 +36,7 @@ typedef struct {
 
 extern EXPSOUND GameExpSound;
 
-extern int64 nesincsizeLL;
+//extern int64 nesincsizeLL;
 extern int64 nesincsize;
 extern uint8 PSG[];
 extern uint32 PSG_base;
diff --git a/state.c b/state.c
index c50223d..c349cff 100644 (file)
--- a/state.c
+++ b/state.c
@@ -289,6 +289,7 @@ extern int geniestage;
 void SaveState(void)
 {
        FILE *st=NULL;
+       char *fname;
 
        TempAddrT=TempAddr;
        RefreshAddrT=RefreshAddr;
@@ -299,7 +300,9 @@ void SaveState(void)
         return;
         }
 
-        st=fopen(FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0),"wb");
+        fname = FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0);
+        st=fopen(fname,"wb");
+        free(fname);
 
         if(st!=NULL)
         {
@@ -386,6 +389,7 @@ int FCEUSS_LoadFP(FILE *st, int make_backup)
 void LoadState(void)
 {
        FILE *st=NULL;
+       char *fname;
 
         if(geniestage==1)
         {
@@ -393,15 +397,24 @@ void LoadState(void)
          return;
         }
 
-       st=fopen(FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0),"rb");
+       fname = FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0);
+       st=fopen(fname,"rb");
+       free(fname);
+
        if (st)
        {
         FCEUSS_LoadFP(st, 0);
         fclose(st);
        }
+       else
+       {
+        FCEU_DispMessage("State %d load error (no file).",CurrentState);
+        SaveStateStatus[CurrentState]=0;
+       }
 }
 
 char SaveStateStatus[10];
+#if 0 // leaks memory
 void CheckStates(void)
 {
        FILE *st=NULL;
@@ -420,6 +433,7 @@ void CheckStates(void)
            SaveStateStatus[ssel]=0;
         }
 }
+#endif
 
 void SaveStateRefresh(void)
 {
diff --git a/svga.c b/svga.c
index 00593fa..f345e76 100644 (file)
--- a/svga.c
+++ b/svga.c
@@ -133,15 +133,10 @@ void FCEUI_SetGameGenie(int a)
 #define netplay 0
 #endif
 
-static uint8 StateShow=0;
-
 uint8 Exit=0;
 
 uint8 DIPS=0;
-//uint8 vsdip=0;
-//int coinon=0;
 
-//uint8 pale=0;
 uint8 CommandQueue=0;
 
 static int controlselect=0;
@@ -150,20 +145,6 @@ static int ntsctint=46+10;
 static int ntschue=72;
 static int controllength=0;
 
-#if 0
-pal *palo;
-static pal *palpoint[8]=
-     {
-     palette,
-     palettevscv,
-     palettevssmb,
-     palettevsmar,
-     palettevsgoon,
-     palettevsslalom,
-     palettevseb,
-     rp2c04001
-     };
-#endif
 
 void FCEUI_SetSnapName(int a)
 {
@@ -175,42 +156,28 @@ void FCEUI_SaveExtraDataUnderBase(int a)
  FSettings.SUnderBase=a;
 }
 
-#if 0
-void FCEUI_SetPaletteArray(uint8 *pal)
-{
- if(!pal)
-  palpoint[0]=palette;
- else
- {
-  int x;
-  palpoint[0]=palettec;
-  for(x=0;x<64;x++)
-  {
-   palpoint[0][x].r=*((uint8 *)pal+x+x+x);
-   palpoint[0][x].g=*((uint8 *)pal+x+x+x+1);
-   palpoint[0][x].b=*((uint8 *)pal+x+x+x+2);
-  }
- }
- FCEU_ResetPalette();
-}
-#endif
 
 void FCEUI_SelectState(int w)
 {
- if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF)
-  CommandQueue=42+w;
// if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF)
//  CommandQueue=42+w;
 }
 
 void FCEUI_SaveState(void)
 {
- if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF)
-  CommandQueue=40;
+ // if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF)
+ //  CommandQueue=40;
+
+ //CheckStates();
+ SaveState();
 }
 
 void FCEUI_LoadState(void)
 {
- if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF)
-  CommandQueue=41;
+ // if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF)
+ //  CommandQueue=41;
+ //CheckStates();
+ LoadState();
 }
 
 int32 FCEUI_GetDesiredFPS(void)
@@ -308,122 +275,6 @@ void DriverInterface(int w, void *d)
   }
 }
 
-#if 0
-static uint8 lastd=0;
-void SetNESDeemph(uint8 d, int force)
-{
- static uint16 rtmul[7]={32768*1.239,32768*.794,32768*1.019,32768*.905,32768*1.023,32768*.741,32768*.75};
- static uint16 gtmul[7]={32768*.915,32768*1.086,32768*.98,32768*1.026,32768*.908,32768*.987,32768*.75};
- static uint16 btmul[7]={32768*.743,32768*.882,32768*.653,32768*1.277,32768*.979,32768*.101,32768*.75};
- uint32 r,g,b;
- int x;
-
- /* If it's not forced(only forced when the palette changes),
-    don't waste cpu time if the same deemphasis bits are set as the last call.
- */
- if(!force)
- {
-  if(d==lastd)
-   return;
- }
- else  /* Only set this when palette has changed. */
- {
-  r=rtmul[6];
-  g=rtmul[6];
-  b=rtmul[6];
-
-  for(x=0;x<0x40;x++)
-  {
-   uint32 m,n,o;
-   m=palo[x].r;
-   n=palo[x].g;
-   o=palo[x].b;
-   m=(m*r)>>15;
-   n=(n*g)>>15;
-   o=(o*b)>>15;
-   if(m>0xff) m=0xff;
-   if(n>0xff) n=0xff;
-   if(o>0xff) o=0xff;
-   FCEUD_SetPalette(x|0x40,m,n,o);
-
-
-  }
- }
- if(!d) return;        /* No deemphasis, so return. */
-
-  r=rtmul[d-1];
-  g=gtmul[d-1];
-  b=btmul[d-1];
-
-    for(x=0;x<0x40;x++)
-    {
-     uint32 m,n,o;
-
-     m=palo[x].r;
-     n=palo[x].g;
-     o=palo[x].b;
-     m=(m*r)>>15;
-     n=(n*g)>>15;
-     o=(o*b)>>15;
-     if(m>0xff) m=0xff;
-     if(n>0xff) n=0xff;
-     if(o>0xff) o=0xff;
-
-     FCEUD_SetPalette(x|0xC0,m,n,o);
-
-    }
-
- lastd=d;
-}
-
-#define HUEVAL  ((double)((double)ntschue/(double)2)+(double)300)
-#define TINTVAL ((double)((double)ntsctint/(double)128))
-
-static void CalculatePalette(void)
-{
- int x,z;
- int r,g,b;
- double s,y,theta;
- static uint8 cols[16]={0,24,21,18,15,12,9,6,3,0,33,30,27,0,0,0};
- static uint8 br1[4]={6,9,12,12};
- static double br2[4]={.29,.45,.73,.9};
- static double br3[4]={0,.24,.47,.77};
-
- for(x=0;x<=3;x++)
-  for(z=0;z<16;z++)
-  {
-   s=(double)TINTVAL;
-   y=(double)br2[x];
-   if(z==0)  {s=0;y=((double)br1[x])/12;}
-
-   if(z>=13)
-   {
-    s=y=0;
-    if(z==13)
-     y=(double)br3[x];
-   }
-
-   theta=(double)M_PI*(double)(((double)cols[z]*10+HUEVAL)/(double)180);
-   r=(int)(((double)y+(double)s*(double)sin(theta))*(double)256);
-   g=(int)(((double)y-(double)((double)27/(double)53)*s*(double)sin(theta)+(double)((double)10/(double)53)*s*cos(theta))*(double)256);
-   b=(int)(((double)y-(double)s*(double)cos(theta))*(double)256);
-
-   // TODO:  Fix RGB to compensate for phosphor changes(add to red??).
-
-   if(r>255) r=255;
-   if(g>255) g=255;
-   if(b>255) b=255;
-   if(r<0) r=0;
-   if(g<0) g=0;
-   if(b<0) b=0;
-
-   paletten[(x<<4)+z].r=r;
-   paletten[(x<<4)+z].g=g;
-   paletten[(x<<4)+z].b=b;
-  }
- WritePalette();
-}
-#endif
 
 #include "drawing.h"
 #ifdef FRAMESKIP
@@ -433,7 +284,6 @@ void FCEU_PutImageDummy(void)
  {
   if(controllength) controllength--;
  }
- if(StateShow) StateShow--; /* DrawState() */
  if(howlong) howlong--;        /* DrawMessage() */
  #ifdef FPS
  {
@@ -469,7 +319,6 @@ void FCEU_PutImage(void)
          }
         if(FCEUGameInfo.type==GIT_VSUNI)
                 FCEU_VSUniDraw(XBuf);
-         //if(StateShow) DrawState();
 
         //FCEU_DrawSaveStates(XBuf);
         //FCEU_DrawMovies(XBuf);
@@ -489,73 +338,6 @@ void FCEU_PutImage(void)
 }
 
 #if 0
-static int ipalette=0;
-
-void LoadGamePalette(void)
-{
-  uint8 ptmp[192];
-  FILE *fp;
-  ipalette=0;
-  if((fp=fopen(FCEU_MakeFName(FCEUMKF_PALETTE,0,0),"rb")))
-  {
-   int x;
-   fread(ptmp,1,192,fp);
-   fclose(fp);
-   for(x=0;x<64;x++)
-   {
-    palettei[x].r=ptmp[x+x+x];
-    palettei[x].g=ptmp[x+x+x+1];
-    palettei[x].b=ptmp[x+x+x+2];
-   }
-   ipalette=1;
-  }
-}
-
-void FCEU_ResetPalette(void)
-{
-   ChoosePalette();
-   WritePalette();
-}
-
-static void ChoosePalette(void)
-{
-    if(FCEUGameInfo.type==GIT_NSF)
-     palo=NSFPalette;
-    else if(ipalette)
-     palo=palettei;
-    else if(ntsccol && !PAL && FCEUGameInfo.type!=GIT_VSUNI)
-     {
-      palo=paletten;
-      CalculatePalette();
-     }
-    else
-     palo=palpoint[pale];
-}
-
-void WritePalette(void)
-{
-    int x;
-
-    for(x=0;x<6;x++)
-     FCEUD_SetPalette(x+128,unvpalette[x].r,unvpalette[x].g,unvpalette[x].b);
-    if(FCEUGameInfo.type==GIT_NSF)
-    {
-     for(x=0;x<39;x++)
-      FCEUD_SetPalette(x,palo[x].r,palo[x].g,palo[x].b);
-    }
-    else
-    {
-     for(x=0;x<64;x++)
-      FCEUD_SetPalette(x,palo[x].r,palo[x].g,palo[x].b);
-     SetNESDeemph(lastd,1);
-    }
-}
-
-void FlushCommandQueue(void)
-{
-  if(!netplay && CommandQueue) {DoCommand(CommandQueue);CommandQueue=0;}
-}
-
 void DoCommand(uint8 c)
 {
  switch(c)