--- source/linux/main.cpp.orig	2007-07-29 17:24:26.000000000 -0400
+++ source/linux/main.cpp	2007-07-29 17:36:46.000000000 -0400
@@ -649,36 +649,6 @@
 		filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
 
 		// load the cartridge
-		strcpy(savename, filename);
-
-		// strip the . and extention off the filename for saving
-		for (i = strlen(savename)-1; i > 0; i--)
-		{
-			if (savename[i] == '.')
-			{
-				savename[i] = '\0';
-				break;
-			}
-		}
-
-		strcpy(capname, savename);
-		// strip the path off the savename to get the filename only
-		for (i = strlen(capname)-1; i > 0; i--)
-		{
-			if (capname[i] == '/')
-			{
-				strcpy(capname, &capname[i+1]);
-				break;
-			}
-		}
-
-
-		// also generate the window caption
-		sprintf(caption, "NEStopia %s: %s", NST_VERSION, capname);
-
-		strcpy(rootname, savename);
-		strcat(savename, ".sav");
-
 		LoadGame(filename);
 		g_free (filename);
 	}
@@ -1279,6 +1249,42 @@
 	Nes::Api::Input(emulator).ConnectController( 1, Nes::Api::Input::PAD2 );
 }
 
+void configure_savename( const char* filename )
+{
+	int i = 0;
+
+	strcpy(savename, filename);
+
+	// strip the . and extention off the filename for saving
+	for (i = strlen(savename)-1; i > 0; i--)
+	{
+		if (savename[i] == '.')
+		{
+			savename[i] = '\0';
+			break;
+		}
+	}
+
+	strcpy(capname, savename);
+	// strip the path off the savename to get the filename only
+	for (i = strlen(capname)-1; i > 0; i--)
+	{
+		if (capname[i] == '/')
+		{
+			strcpy(capname, &capname[i+1]);
+			break;
+		}
+	}
+
+
+	// also generate the window caption
+	sprintf(caption, "NEStopia %s: %s", NST_VERSION, capname);
+
+	strcpy(rootname, savename);
+	strcat(savename, ".sav");
+}
+
+
 // load a game or NES music file
 void LoadGame(const char* filename)
 {
@@ -1305,6 +1311,9 @@
 	// unload if necessary
 	nst_unload();
 
+	// (re)configure savename
+	configure_savename(filename);
+
 	// check if it's an archive
 	wascomp = 0;
 	if (auxio_load_archive(filename, &compbuffer, &compsize, &compoffset))

