*** unix/unix.cpp	Mon Sep 17 23:03:40 2001
--- ../../release/unix/unix.cpp	Wed Nov 28 00:58:18 2001
***************
*** 96,101 ****
--- 96,102 ----
  #include "gfx.h"
  #include "soundux.h"
  #include "spc700.h"
+ #include "port.h"
  
  #ifdef SPCTOOL
  #include "spctool/spc700.h"
***************
*** 111,116 ****
--- 112,125 ----
  int NumControllers = 5;
  
  #ifdef JOYSTICK_SUPPORT
+ 
+ /* Special control constants for saving, tried to pick numbers that don't conflict w/ shifts*/
+ #define SNES_SAVE_CONST		3
+ #define SNES_LOAD_CONST		1
+ 
+ /* Tracks last save/load if externed in x11.cpp/svga.cpp/etc */
+ int js_save_last_key = 0;
+ 
  #ifdef __linux
  #include <linux/joystick.h>
  int js_fd [4] = {-1, -1, -1, -1};
***************
*** 209,214 ****
--- 218,234 ----
  	else
  	    S9xUsage ();
      }
+     else if (strcasecmp (argv [i], "-joysave" ) == 0)
+     {
+ 	if (i + 2 < argc)
+ 	{
+ 	    int t;
+ 	    if ((t = atoi (argv [++i])) < 15) js_map_button [0][t] = SNES_SAVE_CONST;
+ 	    if ((t = atoi (argv [++i])) < 15) js_map_button [0][t] = SNES_LOAD_CONST;
+ 	}
+ 	else
+ 	    S9xUsage ();
+     }
      else if (strcasecmp (argv [i], "-joymap1") == 0)
      {
  	if (i + 8 < argc)
***************
*** 720,726 ****
  		    break;
  
  		if (js_ev.value)
! 		    joypads [i] |= js_map_button [i][js_ev.number];
  		else
  		    joypads [i] &= ~js_map_button [i][js_ev.number];
  
--- 740,776 ----
  		    break;
  
  		if (js_ev.value)
! 		{
! 		    /* Handle extra save buttons */
! 		    if( js_map_button [i][js_ev.number] == SNES_SAVE_CONST )
! 		    {
!                         char def [PATH_MAX];
!                         char filename [PATH_MAX];
!                         char drive [_MAX_DRIVE];
!                         char dir [_MAX_DIR];
!                         char ext [_MAX_EXT];
! 
!                         _splitpath (Memory.ROMFilename, drive, dir, def, ext);
!                         sprintf (filename, "%s%s%s.%03d",
!                                  S9xGetSnapshotDirectory (), SLASH_STR, def,
!                                  js_save_last_key );
!                         Snapshot (filename);
! 		    }else if( js_map_button [i][js_ev.number] == SNES_LOAD_CONST )
! 		    {
!                         char def [PATH_MAX];
!                         char filename [PATH_MAX];
!                         char drive [_MAX_DRIVE];
!                         char dir [_MAX_DIR];
!                         char ext [_MAX_EXT];
! 
!                         _splitpath (Memory.ROMFilename, drive, dir, def, ext);
!                         sprintf (filename, "%s%s%s.%03d",
!                                  S9xGetSnapshotDirectory (), SLASH_STR, def,
!                                  js_save_last_key);
!                         S9xLoadSnapshot (filename);
! 		    }else
! 		    	joypads [i] |= js_map_button [i][js_ev.number];
! 		}
  		else
  		    joypads [i] &= ~js_map_button [i][js_ev.number];
  
