--- source/linux/main.cpp.orig	2007-08-05 12:49:57.000000000 -0400
+++ source/linux/main.cpp	2007-08-05 12:50:01.000000000 -0400
@@ -86,6 +86,18 @@
 
 static LinuxNstSettings *Settings;
 
+struct Border
+{
+	Border() : draw(false) {}
+	SDL_Rect s;
+	bool     draw;
+};
+
+static Border border_l;
+static Border border_r;
+static Border border_t;
+static Border border_b;
+
 #ifdef INCLUDE_OPENGL
 static bool         using_opengl  = false;
 static bool         opengl_2xscale = false;
@@ -167,8 +179,8 @@
 
 	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (linear_filter?GL_LINEAR:GL_NEAREST) ) ;
 	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ) ;
-	//glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ) ;
-	//glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ) ;
+	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ) ;
+	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ) ;
 
 	area.x = area.y = 0;
 	area.w = screen->w;
@@ -222,6 +234,97 @@
 }
 #endif
 
+struct Game_Border
+{
+	const char* name;
+	int         l;
+	int         r;
+	int         t;
+	int         b;
+};
+
+static Game_Border game_border[] = {
+	{ "CRYSTALIS", 0, 0, 4, 4 }
+};
+
+static const int num_games = sizeof(game_border)/sizeof(Game_Border);
+
+struct ObjToUpper
+{
+	int operator()( int ch )
+	{
+		return std::toupper(ch);
+	}
+};
+
+void init_border()
+{
+	std::string gamename(savename);
+	//toUpper(gamename);
+	std::transform(gamename.begin(),gamename.end(),gamename.begin(),ObjToUpper());
+	// TEST
+	// set up border coordinates
+	// LT xy is the same
+	border_l.s.x  = border_t.s.x = 0;
+	border_l.s.y  = border_t.s.y = 0;
+	border_r.s.y = 0;
+
+	// LR wh is the same
+	border_l.s.h  = border_r.s.h = cur_height;
+
+	// tb wh is the same
+	border_t.s.w  = border_b.s.w = cur_width;
+
+	Game_Border* border = 0;;
+
+	for ( int i = 0; i < num_games; ++i )
+	{
+		if ( std::string::npos != gamename.find(game_border[i].name) )
+		{
+			border = game_border+i;
+			break;
+		}
+	}
+
+	if ( 0 != border )
+	{
+		border_l.draw = (0!=border->l);
+		border_r.draw = (0!=border->r);
+		border_t.draw = (0!=border->t);
+		border_b.draw = (0!=border->b);
+
+		const int heightAdj = (cur_height/240);
+		const int widthAdj = (cur_width/256);
+		border_l.s.w = border->l*widthAdj;
+
+		border_t.s.h = border->t*heightAdj;
+
+		border_r.s.w = border->r*widthAdj;
+		border_r.s.x = screen->w - border_r.s.w;
+
+		border_b.s.h = border->b*heightAdj;
+		border_b.s.y = screen->h - border_b.s.h;
+	}
+	else
+	{
+		border_l.draw = border_r.draw = border_t.draw = border_b.draw = false;
+	}
+}
+
+void draw_border( Border& border )
+{
+	if (border.draw)
+		SDL_FillRect( screen, &border.s, 0 ); 
+}
+
+void draw_borders()
+{
+	draw_border( border_l );
+	draw_border( border_r );
+	draw_border( border_t );
+	draw_border( border_b );
+}
+
 static void load_file_by_uri(char *filename)
 {
 	char *fsub;
@@ -334,6 +437,8 @@
 {
 	if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
 
+	draw_borders();
+
 #ifdef INCLUDE_OPENGL
 	if ( using_opengl )
 	{
@@ -1349,6 +1454,8 @@
 		exit(-1);
 	}
 
+	init_border();
+
 	// example configuration
 	renderState.bits.count = screen->format->BitsPerPixel;
 	renderState.bits.mask.r = screen->format->Rmask;

