Binary files orig/Frodo/Frodo and Frodo/Frodo differ
diff -Nur orig/Frodo/Src/C64.cpp Frodo/Src/C64.cpp
--- orig/Frodo/Src/C64.cpp	Wed Aug  6 20:56:24 1997
+++ Frodo/Src/C64.cpp	Sat May 22 23:11:47 1999
@@ -698,7 +698,7 @@
 #endif
 
 #ifdef __unix
-#include "C64_x.i"
+#include "C64_unix.i"
 #endif
 
 #ifdef __mac__
diff -Nur orig/Frodo/Src/C64.h Frodo/Src/C64.h
--- orig/Frodo/Src/C64.h	Wed Aug  6 20:56:25 1997
+++ Frodo/Src/C64.h	Sat May 22 23:11:47 1999
@@ -138,6 +138,9 @@
 #ifdef __unix
 	int joyfd[2];			// File descriptors for joysticks
 	double speed_index;
+	uint8 joystate[2];
+	int new_joydrv;		// True if we have the new event-driven
+				// joystick driver.
 public:
 	CmdPipe *gui;
 #endif
diff -Nur orig/Frodo/Src/C64_unix.i Frodo/Src/C64_unix.i
--- orig/Frodo/Src/C64_unix.i	Thu Jan  1 01:00:00 1970
+++ Frodo/Src/C64_unix.i	Sat May 22 23:11:47 1999
@@ -0,0 +1,500 @@
+/*
+ *  C64_unix.i - Put the pieces together, UNIX specific stuff
+ *
+ *  Frodo (C) 1994-1997 Christian Bauer
+ *  Unix stuff by Bernd Schmidt/Lutz Vieweg
+ *  New joystick driver by Marcus Sundberg
+ */
+
+#include "main.h"
+
+
+static struct timeval tv_start;
+
+#ifndef HAVE_USLEEP
+/*
+ *  NAME:
+ *      usleep     -- This is the precision timer for Test Set
+ *                    Automation. It uses the select(2) system
+ *                    call to delay for the desired number of
+ *                    micro-seconds. This call returns ZERO
+ *                    (which is usually ignored) on successful
+ *                    completion, -1 otherwise.
+ *
+ *  ALGORITHM:
+ *      1) We range check the passed in microseconds and log a
+ *         warning message if appropriate. We then return without
+ *         delay, flagging an error.
+ *      2) Load the Seconds and micro-seconds portion of the
+ *         interval timer structure.
+ *      3) Call select(2) with no file descriptors set, just the
+ *         timer, this results in either delaying the proper
+ *         ammount of time or being interupted early by a signal.
+ *
+ *  HISTORY:
+ *      Added when the need for a subsecond timer was evident.
+ *
+ *  AUTHOR:
+ *      Michael J. Dyer                   Telephone:   AT&T 414.647.4044
+ *      General Electric Medical Systems        GE DialComm  8 *767.4044
+ *      P.O. Box 414  Mail Stop 12-27         Sect'y   AT&T 414.647.4584
+ *      Milwaukee, Wisconsin  USA 53201                      8 *767.4584
+ *      internet:  mike@sherlock.med.ge.com     GEMS WIZARD e-mail: DYER
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/param.h>
+#include <sys/types.h>
+
+int usleep(unsigned long int microSeconds)
+{
+        unsigned int            Seconds, uSec;
+        int                     nfds, readfds, writefds, exceptfds;
+        struct  timeval         Timer;
+
+        nfds = readfds = writefds = exceptfds = 0;
+
+        if( (microSeconds == (unsigned long) 0)
+                || microSeconds > (unsigned long) 4000000 )
+        {
+                errno = ERANGE;         /* value out of range */
+                perror( "usleep time out of range ( 0 -> 4000000 ) " );
+                return -1;
+        }
+
+        Seconds = microSeconds / (unsigned long) 1000000;
+        uSec    = microSeconds % (unsigned long) 1000000;
+
+        Timer.tv_sec            = Seconds;
+        Timer.tv_usec           = uSec;
+
+        if( select( nfds, &readfds, &writefds, &exceptfds, &Timer ) < 0 )
+        {
+                perror( "usleep (select) failed" );
+                return -1;
+        }
+
+        return 0;
+}
+#endif
+
+
+/*
+ *  Constructor, system-dependent things
+ */
+
+void C64::c64_ctor1(void)
+{
+	// Initialize joystick variables
+	joyfd[0] = joyfd[1] = -1;
+	joy_minx = joy_miny = 32767;
+	joy_maxx = joy_maxy = -32768;
+	joystate[0] = joystate[1] = 0xff;
+
+	// we need to create a potential GUI subprocess here, because we don't want
+	// it to inherit file-descriptors (such as for the audio-device and alike..)
+#if !defined(__x11__)
+	gui = 0;
+#else
+	// try to start up Tk gui.
+	gui = new CmdPipe("wish", "TkGui.tcl");
+	if (gui) {
+		if (gui->fail) {
+			delete gui; gui = 0;
+		}
+	}
+	// wait until the GUI process responds (if it does...)
+	if (gui) {
+		if (5 != gui->ewrite("ping\n",5)) {
+			delete gui; gui = 0;
+		} else {
+			char c;
+			fd_set set;
+			FD_ZERO(&set);
+			FD_SET(gui->get_read_fd(), &set);
+ 			struct timeval tv;
+			tv.tv_usec = 0;
+			tv.tv_sec = 5;
+// Use the following commented line for HP-UX < 10.20
+//			if (select(FD_SETSIZE, (int *)&set, (int *)NULL, (int *)NULL, &tv) <= 0) {
+			if (select(FD_SETSIZE, &set, NULL, NULL, &tv) <= 0) {
+				delete gui; gui = 0;
+			} else {
+				if (1 != gui->eread(&c, 1)) {
+					delete gui; gui = 0;
+				} else {
+					if (c != 'o') {
+						delete gui; gui = 0;
+					}
+				}
+			}
+		}
+	}
+#endif // !__x11__
+}
+
+void C64::c64_ctor2(void)
+{
+#ifdef  __x11__
+   if (!gui) {
+   	fprintf(stderr,"Alas, master, no preferences window will be available.\n"
+   	               "If you wish to see one, make sure the 'wish' interpreter\n"
+   	               "(Tk version >= 4.1) is installed in your path.\n"
+   	               "You can still use Frodo, though. Use F10 to quit, \n"
+   	               "F11 to cause an NMI and F12 to reset the C64.\n"
+   	               "You can change the preferences by editing ~/.frodorc\n");
+   }
+#endif // __x11__
+  
+	gettimeofday(&tv_start, NULL);
+}
+
+
+/*
+ *  Destructor, system-dependent things
+ */
+
+void C64::c64_dtor(void)
+{
+}
+
+
+/*
+ *  Start main emulation thread
+ */
+
+void C64::Run(void)
+{
+	// Reset chips
+	TheCPU->Reset();
+	TheSID->Reset();
+	TheCIA1->Reset();
+	TheCIA2->Reset();
+	TheCPU1541->Reset();
+
+	// Patch kernal IEC routines
+	orig_kernal_1d84 = Kernal[0x1d84];
+	orig_kernal_1d85 = Kernal[0x1d85];
+	PatchKernal(ThePrefs.FastReset, ThePrefs.Emul1541Proc);
+
+	quit_thyself = false;
+	thread_func();
+}
+
+
+/*
+ *  Vertical blank: Poll keyboard and joysticks, update window
+ */
+
+void C64::VBlank(bool draw_frame)
+{
+	// Poll keyboard
+	TheDisplay->PollKeyboard(TheCIA1->KeyMatrix, TheCIA1->RevMatrix, &joykey);
+	if (TheDisplay->quit_requested)
+		quit_thyself = true;
+
+	// Poll joysticks
+	TheCIA1->Joystick1 = poll_joystick(0);
+	TheCIA1->Joystick2 = poll_joystick(1);
+
+	if (ThePrefs.JoystickSwap) {
+		uint8 tmp = TheCIA1->Joystick1;
+		TheCIA1->Joystick1 = TheCIA1->Joystick2;
+		TheCIA1->Joystick2 = tmp;
+	}
+
+	// Joystick keyboard emulation
+	if (TheDisplay->NumLock())
+		TheCIA1->Joystick1 &= joykey;
+	else
+		TheCIA1->Joystick2 &= joykey;
+       
+	// Count TOD clocks
+	TheCIA1->CountTOD();
+	TheCIA2->CountTOD();
+
+	// Update window if needed
+	if (draw_frame) {
+    	TheDisplay->Update();
+
+		// Calculate time between VBlanks, display speedometer
+		struct timeval tv;
+		gettimeofday(&tv, NULL);
+		if ((tv.tv_usec -= tv_start.tv_usec) < 0) {
+			tv.tv_usec += 1000000;
+			tv.tv_sec -= 1;
+		}
+		tv.tv_sec -= tv_start.tv_sec;
+		double elapsed_time = (double)tv.tv_sec * 1000000 + tv.tv_usec;
+		speed_index = 20000 / (elapsed_time + 1) * ThePrefs.SkipFrames * 100;
+
+		// Limit speed to 100% if desired
+		if ((speed_index > 100) && ThePrefs.LimitSpeed) {
+			usleep((unsigned long)(ThePrefs.SkipFrames * 20000 - elapsed_time));
+			speed_index = 100;
+		}
+
+		gettimeofday(&tv_start, NULL);
+
+		TheDisplay->Speedometer((int)speed_index);
+	}
+}
+
+
+/*
+ *  Open/close joystick drivers given old and new state of
+ *  joystick preferences
+ */
+
+#ifdef HAVE_LINUX_JOYSTICK_H
+/* Check if we have the new event-driven joystick driver */
+static int
+check4new_joydrv(int fd)
+{
+	int version;
+	
+	if (ioctl(fd, JSIOCGVERSION, &version) == 0
+	    && version >= 0x00010008)
+		return 1;
+	else
+		return 0;
+}
+#endif
+
+void C64::open_close_joysticks(bool oldjoy1, bool oldjoy2, bool newjoy1, bool newjoy2)
+{
+#ifdef HAVE_LINUX_JOYSTICK_H
+	if (oldjoy1 != newjoy1) {
+		joy_minx = joy_miny = 32767;	// Reset calibration
+		joy_maxx = joy_maxy = -32768;
+		if (newjoy1) {
+			joyfd[0] = open("/dev/js0", O_RDONLY);
+			if (joyfd[0] < 0)
+				fprintf(stderr, "Couldn't open joystick 1\n");
+			else {
+				new_joydrv = check4new_joydrv(joyfd[0]);
+				joystate[0] = 0xff;
+			}
+		} else {
+			close(joyfd[0]);
+			joyfd[0] = -1;
+		}
+	}
+
+	if (oldjoy2 != newjoy2) {
+		joy_minx = joy_miny = 32767;	// Reset calibration
+		joy_maxx = joy_maxy = -32768;
+		if (newjoy2) {
+			joyfd[1] = open("/dev/js1", O_RDONLY);
+			if (joyfd[1] < 0)
+				fprintf(stderr, "Couldn't open joystick 2\n");
+			else {
+				new_joydrv = check4new_joydrv(joyfd[1]);
+				joystate[1] = 0xff;
+			}
+		} else {
+			close(joyfd[1]);
+			joyfd[1] = -1;
+		}
+	}
+#endif
+}
+
+
+/*
+ *  Poll joystick port, return CIA mask
+ */
+
+uint8 C64::poll_joystick(int port)
+{
+#ifdef HAVE_LINUX_JOYSTICK_H
+#define BUTTON	0xef
+#define LEFT	0xfb
+#define RIGHT	0xf7
+#define UP	0xfe
+#define DOWN	0xfd
+	if (new_joydrv) {
+		if (joyfd[port] >= 0) {
+			struct js_event js;
+			fd_set set;
+			struct timeval tv = {0, 0};
+
+			FD_ZERO(&set);
+			FD_SET(joyfd[port], &set);
+			
+			while (select(joyfd[port]+1, &set, NULL, NULL, &tv) > 0
+			       && read(joyfd[port], &js, sizeof(struct js_event))
+			       == sizeof(struct js_event)) {
+				if (js.type & JS_EVENT_BUTTON
+				    && js.number == 0) {
+					if (js.value)
+						joystate[port] &= BUTTON;
+					else
+						joystate[port] |= ~BUTTON;
+				} else if (js.type & JS_EVENT_AXIS) {
+					switch (js.number) {
+					case 0:
+						joystate[port] = joystate[port] | ~LEFT | ~RIGHT;
+						if (js.value < -5000)
+							joystate[port] &= LEFT;
+						else if (js.value > 5000)
+							joystate[port] &= RIGHT;
+						break;
+					case 1:
+						joystate[port] = joystate[port] | ~UP | ~DOWN;
+						if (js.value < -5000)
+							joystate[port] &= UP;
+						else if (js.value > 5000)
+							joystate[port] &= DOWN;
+						break;
+					}
+				}
+				FD_ZERO(&set);
+				FD_SET(joyfd[port], &set);
+				tv.tv_sec = 0;
+				tv.tv_usec = 0;
+			}
+		}
+		return joystate[port];
+	} else {
+		JS_DATA_TYPE js;
+		uint8 j = 0xff;
+		
+		if (joyfd[port] >= 0) {
+			if (read(joyfd[port], &js, JS_RETURN) == JS_RETURN) {
+				if (js.x > joy_maxx)
+					joy_maxx = js.x;
+				if (js.x < joy_minx)
+					joy_minx = js.x;
+				if (js.y > joy_maxy)
+					joy_maxy = js.y;
+				if (js.y < joy_miny)
+					joy_miny = js.y;
+
+				if (joy_maxx-joy_minx < 100 || joy_maxy-joy_miny < 100)
+					return 0xff;
+
+				if (js.x < (joy_minx + (joy_maxx-joy_minx)/3))
+					j &= LEFT;
+				else if (js.x > (joy_minx + 2*(joy_maxx-joy_minx)/3))
+					j &= RIGHT;
+
+				if (js.y < (joy_miny + (joy_maxy-joy_miny)/3))
+					j &= UP;
+				else if (js.y > (joy_miny + 2*(joy_maxy-joy_miny)/3))
+					j &= DOWN;
+
+				if (js.buttons & 1)
+					j &= BUTTON;
+			}
+		}
+		return j;
+	}
+#else
+	return 0xff;
+#endif
+}
+
+
+/*
+ * The emulation's main loop
+ */
+
+void C64::thread_func(void)
+{
+	int linecnt = 0;
+
+#ifdef FRODO_SC
+	while (!quit_thyself) {
+
+		// The order of calls is important here
+		if (TheVIC->EmulateCycle())
+			TheSID->EmulateLine();
+		TheCIA1->CheckIRQs();
+		TheCIA2->CheckIRQs();
+		TheCIA1->EmulateCycle();
+		TheCIA2->EmulateCycle();
+		TheCPU->EmulateCycle();
+
+		if (ThePrefs.Emul1541Proc) {
+			TheCPU1541->CountVIATimers(1);
+			if (!TheCPU1541->Idle)
+				TheCPU1541->EmulateCycle();
+		}
+		CycleCounter++;
+#else
+	while (!quit_thyself) {
+
+		// The order of calls is important here
+		int cycles = TheVIC->EmulateLine();
+		TheSID->EmulateLine();
+#if !PRECISE_CIA_CYCLES
+		TheCIA1->EmulateLine(ThePrefs.CIACycles);
+		TheCIA2->EmulateLine(ThePrefs.CIACycles);
+#endif
+
+		if (ThePrefs.Emul1541Proc) {
+			int cycles_1541 = ThePrefs.FloppyCycles;
+			TheCPU1541->CountVIATimers(cycles_1541);
+
+			if (!TheCPU1541->Idle) {
+				// 1541 processor active, alternately execute
+				//  6502 and 6510 instructions until both have
+				//  used up their cycles
+				while (cycles >= 0 || cycles_1541 >= 0)
+					if (cycles > cycles_1541)
+						cycles -= TheCPU->EmulateLine(1);
+					else
+						cycles_1541 -= TheCPU1541->EmulateLine(1);
+			} else
+				TheCPU->EmulateLine(cycles);
+		} else
+			// 1541 processor disabled, only emulate 6510
+			TheCPU->EmulateLine(cycles);
+#endif
+		linecnt++;
+#if defined(__x11__)
+		if ((linecnt & 0xfff) == 0 && gui) {
+
+			// check for command from GUI process
+		// fprintf(stderr,":");
+			while (gui->probe()) {
+				char c;
+				if (gui->eread(&c, 1) != 1) {
+					delete gui;
+					gui = 0;
+					fprintf(stderr,"Oops, GUI process died...\n");
+				} else {
+               // fprintf(stderr,"%c",c);
+					switch (c) {
+						case 'q':
+							quit_thyself = true;
+							break;
+						case 'r':
+							Reset();
+							break;
+						case 'p':{
+							Prefs *np = Frodo::reload_prefs();
+							NewPrefs(np);
+							ThePrefs = *np;
+							break;
+						}
+						default:
+							break;
+					}
+				}
+			}
+		}
+#endif
+	}
+#if defined(__x11__)
+	if (gui) {
+		gui->ewrite("quit\n",5);
+	}
+#endif
+}
diff -Nur orig/Frodo/Src/C64_x.i Frodo/Src/C64_x.i
--- orig/Frodo/Src/C64_x.i	Wed Aug  6 20:56:25 1997
+++ Frodo/Src/C64_x.i	Sat May 22 23:11:47 1999
@@ -1,425 +0,0 @@
-/*
- *  C64_x.i - Put the pieces together, X specific stuff
- *
- *  Frodo (C) 1994-1997 Christian Bauer
- *  Unix stuff by Bernd Schmidt/Lutz Vieweg
- */
-
-#include "main.h"
-
-
-static struct timeval tv_start;
-
-#ifndef HAVE_USLEEP
-/*
- *  NAME:
- *      usleep     -- This is the precision timer for Test Set
- *                    Automation. It uses the select(2) system
- *                    call to delay for the desired number of
- *                    micro-seconds. This call returns ZERO
- *                    (which is usually ignored) on successful
- *                    completion, -1 otherwise.
- *
- *  ALGORITHM:
- *      1) We range check the passed in microseconds and log a
- *         warning message if appropriate. We then return without
- *         delay, flagging an error.
- *      2) Load the Seconds and micro-seconds portion of the
- *         interval timer structure.
- *      3) Call select(2) with no file descriptors set, just the
- *         timer, this results in either delaying the proper
- *         ammount of time or being interupted early by a signal.
- *
- *  HISTORY:
- *      Added when the need for a subsecond timer was evident.
- *
- *  AUTHOR:
- *      Michael J. Dyer                   Telephone:   AT&T 414.647.4044
- *      General Electric Medical Systems        GE DialComm  8 *767.4044
- *      P.O. Box 414  Mail Stop 12-27         Sect'y   AT&T 414.647.4584
- *      Milwaukee, Wisconsin  USA 53201                      8 *767.4584
- *      internet:  mike@sherlock.med.ge.com     GEMS WIZARD e-mail: DYER
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <time.h>
-#include <sys/time.h>
-#include <sys/param.h>
-#include <sys/types.h>
-
-int usleep(unsigned long int microSeconds)
-{
-        unsigned int            Seconds, uSec;
-        int                     nfds, readfds, writefds, exceptfds;
-        struct  timeval         Timer;
-
-        nfds = readfds = writefds = exceptfds = 0;
-
-        if( (microSeconds == (unsigned long) 0)
-                || microSeconds > (unsigned long) 4000000 )
-        {
-                errno = ERANGE;         /* value out of range */
-                perror( "usleep time out of range ( 0 -> 4000000 ) " );
-                return -1;
-        }
-
-        Seconds = microSeconds / (unsigned long) 1000000;
-        uSec    = microSeconds % (unsigned long) 1000000;
-
-        Timer.tv_sec            = Seconds;
-        Timer.tv_usec           = uSec;
-
-        if( select( nfds, &readfds, &writefds, &exceptfds, &Timer ) < 0 )
-        {
-                perror( "usleep (select) failed" );
-                return -1;
-        }
-
-        return 0;
-}
-#endif
-
-
-/*
- *  Constructor, system-dependent things
- */
-
-void C64::c64_ctor1(void)
-{
-	// Initialize joystick variables
-	joyfd[0] = joyfd[1] = -1;
-	joy_minx = joy_miny = 32767;
-	joy_maxx = joy_maxy = -32768;
-
-	// we need to create a potential GUI subprocess here, because we don't want
-	// it to inherit file-descriptors (such as for the audio-device and alike..)
-#if defined(__svgalib__)
-	gui = 0;
-#else
-	// try to start up Tk gui.
-	gui = new CmdPipe("wish", "TkGui.tcl");
-	if (gui) {
-		if (gui->fail) {
-			delete gui; gui = 0;
-		}
-	}
-	// wait until the GUI process responds (if it does...)
-	if (gui) {
-		if (5 != gui->ewrite("ping\n",5)) {
-			delete gui; gui = 0;
-		} else {
-			char c;
-			fd_set set;
-			FD_ZERO(&set);
-			FD_SET(gui->get_read_fd(), &set);
- 			struct timeval tv;
-			tv.tv_usec = 0;
-			tv.tv_sec = 5;
-// Use the following commented line for HP-UX < 10.20
-//			if (select(FD_SETSIZE, (int *)&set, (int *)NULL, (int *)NULL, &tv) <= 0) {
-			if (select(FD_SETSIZE, &set, NULL, NULL, &tv) <= 0) {
-				delete gui; gui = 0;
-			} else {
-				if (1 != gui->eread(&c, 1)) {
-					delete gui; gui = 0;
-				} else {
-					if (c != 'o') {
-						delete gui; gui = 0;
-					}
-				}
-			}
-		}
-	}
-#endif // __svgalib__
-}
-
-void C64::c64_ctor2(void)
-{
-#ifndef  __svgalib__  
-   if (!gui) {
-   	fprintf(stderr,"Alas, master, no preferences window will be available.\n"
-   	               "If you wish to see one, make sure the 'wish' interpreter\n"
-   	               "(Tk version >= 4.1) is installed in your path.\n"
-   	               "You can still use Frodo, though. Use F10 to quit, \n"
-   	               "F11 to cause an NMI and F12 to reset the C64.\n"
-   	               "You can change the preferences by editing ~/.frodorc\n");
-   }
-#endif // SVGAlib
-  
-	gettimeofday(&tv_start, NULL);
-}
-
-
-/*
- *  Destructor, system-dependent things
- */
-
-void C64::c64_dtor(void)
-{
-}
-
-
-/*
- *  Start main emulation thread
- */
-
-void C64::Run(void)
-{
-	// Reset chips
-	TheCPU->Reset();
-	TheSID->Reset();
-	TheCIA1->Reset();
-	TheCIA2->Reset();
-	TheCPU1541->Reset();
-
-	// Patch kernal IEC routines
-	orig_kernal_1d84 = Kernal[0x1d84];
-	orig_kernal_1d85 = Kernal[0x1d85];
-	PatchKernal(ThePrefs.FastReset, ThePrefs.Emul1541Proc);
-
-	quit_thyself = false;
-	thread_func();
-}
-
-
-/*
- *  Vertical blank: Poll keyboard and joysticks, update window
- */
-
-void C64::VBlank(bool draw_frame)
-{
-	// Poll keyboard
-	TheDisplay->PollKeyboard(TheCIA1->KeyMatrix, TheCIA1->RevMatrix, &joykey);
-	if (TheDisplay->quit_requested)
-		quit_thyself = true;
-
-	// Poll joysticks
-	TheCIA1->Joystick1 = poll_joystick(0);
-	TheCIA1->Joystick2 = poll_joystick(1);
-
-	if (ThePrefs.JoystickSwap) {
-		uint8 tmp = TheCIA1->Joystick1;
-		TheCIA1->Joystick1 = TheCIA1->Joystick2;
-		TheCIA1->Joystick2 = tmp;
-	}
-
-	// Joystick keyboard emulation
-	if (TheDisplay->NumLock())
-		TheCIA1->Joystick1 &= joykey;
-	else
-		TheCIA1->Joystick2 &= joykey;
-       
-	// Count TOD clocks
-	TheCIA1->CountTOD();
-	TheCIA2->CountTOD();
-
-	// Update window if needed
-	if (draw_frame) {
-    	TheDisplay->Update();
-
-		// Calculate time between VBlanks, display speedometer
-		struct timeval tv;
-		gettimeofday(&tv, NULL);
-		if ((tv.tv_usec -= tv_start.tv_usec) < 0) {
-			tv.tv_usec += 1000000;
-			tv.tv_sec -= 1;
-		}
-		tv.tv_sec -= tv_start.tv_sec;
-		double elapsed_time = (double)tv.tv_sec * 1000000 + tv.tv_usec;
-		speed_index = 20000 / (elapsed_time + 1) * ThePrefs.SkipFrames * 100;
-
-		// Limit speed to 100% if desired
-		if ((speed_index > 100) && ThePrefs.LimitSpeed) {
-			usleep((unsigned long)(ThePrefs.SkipFrames * 20000 - elapsed_time));
-			speed_index = 100;
-		}
-
-		gettimeofday(&tv_start, NULL);
-
-		TheDisplay->Speedometer((int)speed_index);
-	}
-}
-
-
-/*
- *  Open/close joystick drivers given old and new state of
- *  joystick preferences
- */
-
-void C64::open_close_joysticks(bool oldjoy1, bool oldjoy2, bool newjoy1, bool newjoy2)
-{
-#ifdef HAVE_LINUX_JOYSTICK_H
-	if (oldjoy1 != newjoy1) {
-		joy_minx = joy_miny = 32767;	// Reset calibration
-		joy_maxx = joy_maxy = -32768;
-		if (newjoy1) {
-			joyfd[0] = open("/dev/js0", O_RDONLY);
-			if (joyfd[0] < 0)
-				fprintf(stderr, "Couldn't open joystick 1\n");
-		} else {
-			close(joyfd[0]);
-			joyfd[0] = -1;
-		}
-	}
-
-	if (oldjoy2 != newjoy2) {
-		joy_minx = joy_miny = 32767;	// Reset calibration
-		joy_maxx = joy_maxy = -32768;
-		if (newjoy2) {
-			joyfd[1] = open("/dev/js1", O_RDONLY);
-			if (joyfd[1] < 0)
-				fprintf(stderr, "Couldn't open joystick 2\n");
-		} else {
-			close(joyfd[1]);
-			joyfd[1] = -1;
-		}
-	}
-#endif
-}
-
-
-/*
- *  Poll joystick port, return CIA mask
- */
-
-uint8 C64::poll_joystick(int port)
-{
-#ifdef HAVE_LINUX_JOYSTICK_H
-	JS_DATA_TYPE js;
-	uint8 j = 0xff;
-
-	if (joyfd[port] >= 0) {
-		if (read(joyfd[port], &js, JS_RETURN) == JS_RETURN) {
-			if (js.x > joy_maxx)
-				joy_maxx = js.x;
-			if (js.x < joy_minx)
-				joy_minx = js.x;
-			if (js.y > joy_maxy)
-				joy_maxy = js.y;
-			if (js.y < joy_miny)
-				joy_miny = js.y;
-
-			if (joy_maxx-joy_minx < 100 || joy_maxy-joy_miny < 100)
-				return 0xff;
-
-			if (js.x < (joy_minx + (joy_maxx-joy_minx)/3))
-				j &= 0xfb;							// Left
-			else if (js.x > (joy_minx + 2*(joy_maxx-joy_minx)/3))
-				j &= 0xf7;							// Right
-
-			if (js.y < (joy_miny + (joy_maxy-joy_miny)/3))
-				j &= 0xfe;							// Up
-			else if (js.y > (joy_miny + 2*(joy_maxy-joy_miny)/3))
-				j &= 0xfd;							// Down
-
-			if (js.buttons & 1)
-				j &= 0xef;							// Button
-		}
-	}
-	return j;
-#else
-	return 0xff;
-#endif
-}
-
-
-/*
- * The emulation's main loop
- */
-
-void C64::thread_func(void)
-{
-	int linecnt = 0;
-
-#ifdef FRODO_SC
-	while (!quit_thyself) {
-
-		// The order of calls is important here
-		if (TheVIC->EmulateCycle())
-			TheSID->EmulateLine();
-		TheCIA1->CheckIRQs();
-		TheCIA2->CheckIRQs();
-		TheCIA1->EmulateCycle();
-		TheCIA2->EmulateCycle();
-		TheCPU->EmulateCycle();
-
-		if (ThePrefs.Emul1541Proc) {
-			TheCPU1541->CountVIATimers(1);
-			if (!TheCPU1541->Idle)
-				TheCPU1541->EmulateCycle();
-		}
-		CycleCounter++;
-#else
-	while (!quit_thyself) {
-
-		// The order of calls is important here
-		int cycles = TheVIC->EmulateLine();
-		TheSID->EmulateLine();
-#if !PRECISE_CIA_CYCLES
-		TheCIA1->EmulateLine(ThePrefs.CIACycles);
-		TheCIA2->EmulateLine(ThePrefs.CIACycles);
-#endif
-
-		if (ThePrefs.Emul1541Proc) {
-			int cycles_1541 = ThePrefs.FloppyCycles;
-			TheCPU1541->CountVIATimers(cycles_1541);
-
-			if (!TheCPU1541->Idle) {
-				// 1541 processor active, alternately execute
-				//  6502 and 6510 instructions until both have
-				//  used up their cycles
-				while (cycles >= 0 || cycles_1541 >= 0)
-					if (cycles > cycles_1541)
-						cycles -= TheCPU->EmulateLine(1);
-					else
-						cycles_1541 -= TheCPU1541->EmulateLine(1);
-			} else
-				TheCPU->EmulateLine(cycles);
-		} else
-			// 1541 processor disabled, only emulate 6510
-			TheCPU->EmulateLine(cycles);
-#endif
-		linecnt++;
-#if !defined(__svgalib__)
-		if ((linecnt & 0xfff) == 0 && gui) {
-
-			// check for command from GUI process
-		// fprintf(stderr,":");
-			while (gui->probe()) {
-				char c;
-				if (gui->eread(&c, 1) != 1) {
-					delete gui;
-					gui = 0;
-					fprintf(stderr,"Oops, GUI process died...\n");
-				} else {
-               // fprintf(stderr,"%c",c);
-					switch (c) {
-						case 'q':
-							quit_thyself = true;
-							break;
-						case 'r':
-							Reset();
-							break;
-						case 'p':{
-							Prefs *np = Frodo::reload_prefs();
-							NewPrefs(np);
-							ThePrefs = *np;
-							break;
-						}
-						default:
-							break;
-					}
-				}
-			}
-		}
-#endif
-	}
-#if !defined(__svgalib__)
-	if (gui) {
-		gui->ewrite("quit\n",5);
-	}
-#endif
-}
diff -Nur orig/Frodo/Src/Display.cpp Frodo/Src/Display.cpp
--- orig/Frodo/Src/Display.cpp	Wed Aug  6 20:56:26 1997
+++ Frodo/Src/Display.cpp	Sat May 22 23:11:47 1999
@@ -79,6 +79,8 @@
 #ifdef __unix
 #ifdef __svgalib__
 #include "Display_svga.i"
+#elif defined(__ggi__)
+#include "Display_ggi.i"
 #else
 #include "Display_x.i"
 #endif
diff -Nur orig/Frodo/Src/Display_ggi.i Frodo/Src/Display_ggi.i
--- orig/Frodo/Src/Display_ggi.i	Thu Jan  1 01:00:00 1970
+++ Frodo/Src/Display_ggi.i	Sat May 22 23:43:45 1999
@@ -0,0 +1,878 @@
+/*
+ *  Display_ggi.i - C64 graphics display, emulator window handling,
+ *                  GGI specific stuff
+ *
+ *  Frodo    (C) 1994-1997 Christian Bauer
+ *  GGI code (C) 1998-1999 Marcus Sundberg
+ */
+
+#include <ggi/ggi.h>
+
+#include "C64.h"
+
+static int bitdepth;
+static void *fb;
+static uint8 *c64fb;
+static int stride, c64stride;
+static int usedb;
+static ggi_visual_t vis;
+static const ggi_directbuffer *dbuf = NULL;
+static ggi_graphtype gt;
+static unsigned int bpp;
+static ggi_pixel black, fill_gray, shine_gray, shadow_gray, red, green;
+static void *palette;
+static int firstline, lastline;
+static char tmpstr[256];
+static int firstrow, lastrow, linewidth;
+#define STATHEIGHT 16
+#define MINWIDTH  320
+#define MINHEIGHT 200
+
+// Statusbar
+static int usestatus;
+static C64Display *c64_disp;
+static struct sigaction pulse_sa;
+static itimerval pulse_tv;
+
+// Keyboard and joystick
+static int keystate[256];
+static int joystate = 0xFF;
+static int f11pressed = 0, f12pressed = 0, quit = 0;
+static int numlock = 0;
+
+/*
+  C64 keyboard matrix:
+
+    Bit 7   6   5   4   3   2   1   0
+  0    CUD  F5  F3  F1  F7 CLR RET DEL
+  1    SHL  E   S   Z   4   A   W   3
+  2     X   T   F   C   6   D   R   5
+  3     V   U   H   B   8   G   Y   7
+  4     N   O   K   M   0   J   I   9
+  5     ,   @   :   .   -   L   P   +
+  6     /   ^   =  SHR HOM  ;   *   £
+  7    R/S  Q   C= SPC  2  CTL  <-  1
+*/
+#define MATRIX(a,b) (((a) << 3) | (b))
+
+#define KEY_F9 512
+#define KEY_F10 513
+#define KEY_F11 514
+#define KEY_F12 515
+
+#define KEY_FIRE 516
+#define KEY_JU 517
+#define KEY_JD 518
+#define KEY_JL 519
+#define KEY_JR 520
+
+#define KEY_JUL 521
+#define KEY_JUR 522
+#define KEY_JDL 523
+#define KEY_JDR 524
+
+#define KEY_KP_PLUS 525
+#define KEY_KP_MINUS 526
+#define KEY_KP_MULT 527
+#define KEY_KP_DIV 528
+#define KEY_NUM_LOCK 529
+
+#define KEY_DRV_SWAP 530
+
+static int ksym2c64(int klabel)
+{
+	switch (klabel) {
+	case 'A': return MATRIX(1,2);
+	case 'B': return MATRIX(3,4);
+	case 'C': return MATRIX(2,4);
+	case 'D': return MATRIX(2,2);
+	case 'E': return MATRIX(1,6);
+	case 'F': return MATRIX(2,5);
+	case 'G': return MATRIX(3,2);
+	case 'H': return MATRIX(3,5);
+	case 'I': return MATRIX(4,1);
+	case 'J': return MATRIX(4,2);
+	case 'K': return MATRIX(4,5);
+	case 'L': return MATRIX(5,2);
+	case 'M': return MATRIX(4,4);
+	case 'N': return MATRIX(4,7);
+	case 'O': return MATRIX(4,6);
+	case 'P': return MATRIX(5,1);
+	case 'Q': return MATRIX(7,6);
+	case 'R': return MATRIX(2,1);
+	case 'S': return MATRIX(1,5);
+	case 'T': return MATRIX(2,6);
+	case 'U': return MATRIX(3,6);
+	case 'V': return MATRIX(3,7);
+	case 'W': return MATRIX(1,1);
+	case 'X': return MATRIX(2,7);
+	case 'Y': return MATRIX(3,1);
+	case 'Z': return MATRIX(1,4);
+		
+	case '0': return MATRIX(4,3);
+	case '1': return MATRIX(7,0);
+	case '2': return MATRIX(7,3);
+	case '3': return MATRIX(1,0);
+	case '4': return MATRIX(1,3);
+	case '5': return MATRIX(2,0);
+	case '6': return MATRIX(2,3);
+	case '7': return MATRIX(3,0);
+	case '8': return MATRIX(3,3);
+	case '9': return MATRIX(4,0);
+
+	case GIIUC_Space: return MATRIX(7,4);
+	case GIIUC_Grave: return MATRIX(7,1);
+	case GIIUC_BackSlash: return MATRIX(6,6);
+	case GIIUC_Comma: return MATRIX(5,7);
+	case GIIUC_Period: return MATRIX(5,4);
+		
+	case GIIUC_Escape: return MATRIX(7,7);
+	case GIIUC_Return: return MATRIX(0,1);
+	case GIIUC_BackSpace: case GIIUC_Delete: return MATRIX(0,0);
+
+	/* US keymapping */
+	case GIIUC_Minus: return MATRIX(5,0);
+	case GIIUC_Equal: return MATRIX(5,3);
+	case GIIUC_BracketLeft: return MATRIX(5,6);
+	case GIIUC_BracketRight: return MATRIX(6,1);
+	case GIIUC_Semicolon: return MATRIX(5,5);
+	case GIIUC_Apostrophe: return MATRIX(6,2);
+	case GIIUC_Slash: return MATRIX(6,7);
+
+	case GIIK_Insert: return MATRIX(6,3);
+	case GIIK_Home: case GIIK_Help: return MATRIX(6,3);
+	case GIIK_End: return MATRIX(6,0);
+	case GIIK_PageUp: return MATRIX(6,0);
+	case GIIK_PageDown: return MATRIX(6,5);
+
+	case GIIK_CtrlL: return MATRIX(7,2);
+	case GIIK_CtrlR: return MATRIX(7,5);
+	case GIIK_ShiftL: return MATRIX(1,7);
+	case GIIK_ShiftR: return MATRIX(6,4);
+	case GIIK_AltL: case GIIK_MetaL:
+	case GIIK_AltR: case GIIK_MetaR: return MATRIX(7,5);
+		
+	case GIIK_Up: return MATRIX(0,7)| 0x80;
+	case GIIK_Down: return MATRIX(0,7);
+	case GIIK_Left: return MATRIX(0,2) | 0x80;
+	case GIIK_Right: return MATRIX(0,2);
+		
+	case GIIK_F1: return MATRIX(0,4);
+	case GIIK_F2: return MATRIX(0,4) | 0x80;
+	case GIIK_F3: return MATRIX(0,5);
+	case GIIK_F4: return MATRIX(0,5) | 0x80;
+	case GIIK_F5: return MATRIX(0,6);
+	case GIIK_F6: return MATRIX(0,6) | 0x80;
+	case GIIK_F7: return MATRIX(0,3);
+	case GIIK_F8: return MATRIX(0,3) | 0x80;
+		
+	case GIIK_F9: return KEY_F9;
+	case GIIK_F10: return KEY_F10;
+	case GIIK_F11: return KEY_F11;
+	case GIIK_F12: return KEY_F12;
+		
+	case GIIK_P0: return KEY_FIRE;
+	case GIIK_P1: return KEY_JDL;
+	case GIIK_P2: return KEY_JD;
+	case GIIK_P3: return KEY_JDR;
+	case GIIK_P4: return KEY_JL;
+	case GIIK_P5: return KEY_FIRE;
+	case GIIK_P6: return KEY_JR;
+	case GIIK_P7: return KEY_JUL;
+	case GIIK_P8: return KEY_JU;
+	case GIIK_P9: return KEY_JUR;
+		
+	case GIIK_PPlus: return KEY_KP_PLUS;
+	case GIIK_PMinus: return KEY_KP_MINUS;
+	case GIIK_PStar: return KEY_KP_MULT;
+	case GIIK_PSlash: return MATRIX(6,7);
+	case GIIK_PEnter: return MATRIX(0,1);
+		
+	case GIIK_NumLock: return KEY_NUM_LOCK;
+		
+	default:
+		fprintf(stderr, "Unknown GGI keylabel: 0x%x:'%c'\n", klabel, klabel);
+		return -1;
+	}
+}
+
+C64Display::C64Display(C64 *the_c64) : TheC64(the_c64)
+{
+	int i;
+	
+	quit_requested = false;
+	
+	if (usestatus) {
+		// LEDs off
+		for (i=0; i<4; i++)
+			led_state[i] = old_led_state[i] = LED_OFF;
+		
+		// Start timer for LED error blinking
+		c64_disp = this;
+		pulse_sa.sa_handler = pulse_handler;
+		pulse_sa.sa_flags = 0;
+		sigemptyset(&pulse_sa.sa_mask);
+		sigaction(SIGALRM, &pulse_sa, NULL);
+		pulse_tv.it_interval.tv_sec = 0;
+		pulse_tv.it_interval.tv_usec = 400000;
+		pulse_tv.it_value.tv_sec = 0;
+		pulse_tv.it_value.tv_usec = 400000;
+		setitimer(ITIMER_REAL, &pulse_tv, NULL);
+	}
+}
+
+C64Display::~C64Display()
+{
+	if (GT_SCHEME(gt) != GT_PALETTE) {
+		free(palette);
+	}
+	ggiClose(vis);
+	ggiExit();
+}
+
+
+/*
+ *  Prefs may have changed
+ */
+
+void C64Display::NewPrefs(Prefs *prefs)
+{
+}
+
+/*
+ *  Draw one drive LED
+ */
+
+void C64Display::draw_led(int num, int state)
+{
+	switch (state) {
+		case LED_OFF:
+		case LED_ERROR_OFF:
+			ggiSetGCForeground(vis, black);
+			break;
+		case LED_ON:
+			ggiSetGCForeground(vis, green);
+			break;
+		case LED_ERROR_ON:
+			ggiSetGCForeground(vis, red);
+			break;
+	}
+	ggiDrawBox(vis, linewidth*(num+2)/5-23, DISPLAY_Y+5, 14, 6);
+}
+
+/*
+ *  LED error blink
+ */
+
+void C64Display::pulse_handler(...)
+{
+	for (int i=0; i<4; i++)
+		switch (c64_disp->led_state[i]) {
+			case LED_ERROR_ON:
+				c64_disp->led_state[i] = LED_ERROR_OFF;
+				break;
+			case LED_ERROR_OFF:
+				c64_disp->led_state[i] = LED_ERROR_ON;
+				break;
+		}
+}
+
+/*
+ *  Draw speedometer
+ */
+
+void C64Display::Speedometer(int speed)
+{
+	static int delay = 0;
+	
+	if (usestatus) {
+		if (delay >= 20) {
+			char str[16];
+			sprintf(str, "%d%%", speed);
+			ggiSetGCForeground(vis, fill_gray);
+			ggiDrawBox(vis, 1, DISPLAY_Y+1, linewidth/5-2, 14);
+			ggiSetGCForeground(vis, black);
+			ggiSetGCBackground(vis, fill_gray);
+			ggiPuts(vis, 24, DISPLAY_Y+4, str);
+			delay = 0;
+		} else
+			delay++;
+	}
+}
+
+
+int init_graphics(void)
+{	
+	ggi_color col;
+	ggi_mode tm;
+	ggi_pixellinearbuffer *plb;
+	int width=DISPLAY_X, height=DISPLAY_Y+STATHEIGHT;
+	
+	if (ggiInit()) {
+		fprintf(stderr, "Failed to init libggi?!\n");
+		return 0;
+	}
+		
+	if ((vis=ggiOpen(NULL))==NULL) {
+		fprintf(stderr, "Can't open default visual.\n");
+		ggiExit();
+		return 0;
+	}
+	ggiSetFlags(vis, GGIFLAG_ASYNC);
+	
+	ggiCheckGraphMode(vis, width, height, GGI_AUTO, GGI_AUTO,
+			  GT_8BIT, &tm);
+	if (tm.visible.x >= MINWIDTH &&
+	    tm.visible.y >= MINHEIGHT &&
+	    (GT_SIZE(tm.graphtype) == 8 ||
+	     GT_SIZE(tm.graphtype) == 16 ||
+	     GT_SIZE(tm.graphtype) == 24 ||
+	     GT_SIZE(tm.graphtype) == 32)) {
+		if (((float)tm.visible.y) / tm.visible.x > 1) {
+			ggiCheckGraphMode(vis, 320, 200, GGI_AUTO, GGI_AUTO,
+					  GT_8BIT, &tm);
+		}
+		ggiSetMode(vis, &tm);
+		gt = tm.graphtype;
+	} else {
+		fprintf(stderr, "Unable to set a suitable mode.\n");
+		fprintf(stderr, "Closest is: %dx%dx%d\n",
+			tm.visible.x, tm.visible.y, GT_SIZE(tm.graphtype));
+		ggiClose(vis);
+		ggiExit();
+		return 0;
+	}
+	
+	if (tm.visible.x < DISPLAY_X) {
+		firstrow = (DISPLAY_X - tm.visible.x)/2;
+		lastrow = firstrow + tm.visible.x;
+	} else {
+		firstrow = 0;
+		lastrow = DISPLAY_X;
+	}
+	linewidth = lastrow - firstrow;
+	if (tm.visible.y < DISPLAY_Y) {
+		firstline = ((DISPLAY_Y - tm.visible.y)-1)/2;
+		lastline = firstline + tm.visible.y;
+	} else {
+		firstline = 0;
+		lastline = DISPLAY_Y;
+	}
+	if (tm.visible.y < DISPLAY_Y+STATHEIGHT) {
+		usestatus=0;
+	} else {
+		usestatus=1;
+	}
+
+	bpp = GT_SIZE(gt)/8;
+	
+	c64stride = DISPLAY_X;
+	stride = tm.visible.x;
+
+	if ((dbuf = ggiDBGetBuffer(vis, 0)) != NULL
+	    && (dbuf->type&GGI_DB_SIMPLE_PLB)) {
+		stride = dbuf->buffer.plb.stride;
+		if (GT_SCHEME(gt) == GT_PALETTE
+		    && bpp == 1
+		    && tm.visible.x >= DISPLAY_X
+		    && tm.visible.y >= DISPLAY_Y
+		    && !ggiResourceMustAcquire(dbuf->resource)) {
+			usedb = 2;
+			fb = (void*) dbuf->write;
+			c64fb = (uint8*)fb;
+			c64stride = stride;
+		} else {
+			usedb = 1;
+			c64fb = (uint8*)malloc(DISPLAY_X * DISPLAY_Y);
+		}
+		printf("Using DirectBuffer, %s\n",
+		       usedb == 2 ? "direct" : "scaled");
+	} else {
+		c64fb = (uint8*)malloc(DISPLAY_X * DISPLAY_Y);
+		usedb = 0;
+	}
+	
+	memset(keystate, 0, sizeof(keystate));
+	
+	return 1;
+}
+
+
+void C64Display::Update(void)
+{
+	int y;
+	
+	if (usedb) {
+		if (usedb == 1) {
+			if (ggiResourceAcquire(dbuf->resource,GGI_ACTYPE_WRITE)
+			    != 0) {
+				ggiPanic("Unable to acquire DirectBuffer!\n");
+			}
+			fb = (void*) dbuf->write;
+		}
+
+		switch (bpp) {
+		case 1:
+			if (GT_SCHEME(gt) != GT_PALETTE) {
+				uint8 *fbptr = (uint8*)fb,
+					*palptr = (uint8*)palette;
+				uint8 *c64ptr = c64fb + DISPLAY_X*firstline+firstrow;
+				int x;
+				for (y=firstline; y < lastline; y++) {
+					for (x=0; x < linewidth; x++) {
+						fbptr[x] = palptr[c64ptr[x]];
+					}
+					fbptr += stride;
+					c64ptr+= DISPLAY_X;
+				}
+			} else if (usedb < 2) {
+				uint8 *fbptr = (uint8*)fb;
+				uint8 *c64ptr = c64fb + DISPLAY_X*firstline+firstrow;
+				int x;
+				for (y=firstline; y < lastline; y++) {
+					for (x=0; x < linewidth; x++) {
+						fbptr[x] = c64ptr[x];
+					}
+					fbptr += stride;
+					c64ptr+= DISPLAY_X;
+				}
+			}
+			break;
+		case 2: {
+			uint16 *fbptr = (uint16*)fb,
+				*palptr = (uint16*)palette;
+			uint8 *c64ptr = c64fb + DISPLAY_X*firstline+firstrow;
+			int x;
+			for (y=firstline; y < lastline; y++) {
+				for (x=0; x < linewidth; x++) {
+					fbptr[x] = palptr[c64ptr[x]];
+				}
+				fbptr = (uint16*)((uint8*)fbptr+stride);
+				c64ptr+= DISPLAY_X;
+			}
+		}
+		break;
+		case 3:
+		{
+			uint8 *fbptr = (uint8*)fb;
+			uint32 *palptr = (uint32*)palette;
+			uint8 *c64ptr = c64fb + DISPLAY_X*firstline+firstrow;
+			int diff = stride - lastrow*3;
+			int x;
+			for (y=firstline; y < lastline; y++) {
+				for (x=0; x < linewidth; x++) {
+					register uint32 pix=palptr[c64ptr[x]];
+					*(fbptr++) = pix & 0xff;
+					*(fbptr++) = (pix >> 8) & 0xff;
+					*(fbptr++) = (pix >> 16) & 0xff;
+				}
+				fbptr += diff;
+				c64ptr+= DISPLAY_X;
+			}
+		}
+		break;
+		case 4: {
+			uint32 *fbptr = (uint32*)fb,
+				*palptr = (uint32*)palette;
+			uint8 *c64ptr = c64fb + DISPLAY_X*firstline+firstrow;
+			int x;
+			for (y=firstline; y < lastline; y++) {
+				for (x=0; x < linewidth; x++) {
+					fbptr[x] = palptr[c64ptr[x]];
+				}
+				fbptr = (uint32*)((uint8*)fbptr+stride);
+				c64ptr+= DISPLAY_X;
+			}
+		}	
+		break;
+		default:
+			break;
+		}
+		if (usedb == 1) {
+			ggiResourceRelease(dbuf->resource);
+		}
+	} else {
+		switch (bpp) {
+		case 1: {
+			uint8 *c64ptr = c64fb+firstrow+firstline*DISPLAY_X;
+			int width = lastrow - firstrow, i;
+			for (i=0,y=firstline; y < lastline; y++,i++) {
+				ggiPutHLine(vis, 0, i, width, c64ptr);
+				c64ptr+=DISPLAY_X;
+			}
+		}
+		break;
+		case 2: {
+			uint16 scanline[DISPLAY_X],
+				*palptr = (uint16*)palette;;
+			uint8 *c64ptr = c64fb+firstrow+firstline*DISPLAY_X;
+			int x,i;
+			for (i=0,y=firstline; y < lastline; y++,i++) {
+				int j;
+				for (j=0,x=firstrow; x < lastrow; x++,j++) {
+					scanline[j] = palptr[c64ptr[x]];
+				}
+				ggiPutHLine(vis, 0, i, DISPLAY_X, scanline);
+				c64ptr+=DISPLAY_X;
+			}
+		}
+		break;
+		case 3:
+		{
+			uint8 scanline[DISPLAY_X*3];
+			uint32 *palptr = (uint32*)palette;
+			uint8 *c64ptr = c64fb+firstrow+firstline*DISPLAY_X;
+			int diff = stride - lastrow*3;
+			int x,i;
+			for (i=0,y=firstline; y < lastline; y++,i++) {
+				uint8 *slptr = scanline;
+				for (x=firstrow; x < lastrow; x++) {
+					register uint32 pix=palptr[c64ptr[x]];
+					*(slptr++) = pix & 0xff;
+					*(slptr++) = (pix >> 8) & 0xff;
+					*(slptr++) = (pix >> 16) & 0xff;
+				}
+				ggiPutHLine(vis, 0, i, DISPLAY_X, scanline);
+				c64ptr+= DISPLAY_X;
+			}
+		}
+		break;
+		case 4: {
+			uint32 scanline[DISPLAY_X],
+				*palptr = (uint32*)palette;;
+			uint8 *c64ptr = c64fb+firstrow+firstline*DISPLAY_X;
+			int x,i;
+			for (i=0,y=firstline; y < lastline; y++,i++) {
+				int j;
+				for (j=0,x=firstrow; x < DISPLAY_X; x++,i++) {
+					scanline[j] = palptr[c64ptr[x]];
+				}
+				ggiPutHLine(vis, 0, i, DISPLAY_X, scanline);
+				c64ptr+=DISPLAY_X;
+			}
+		}
+		break;
+		}
+	}
+	
+	// Update drive LEDs
+	for (int i=0; i<4; i++) {
+		if (led_state[i] != old_led_state[i]) {
+			draw_led(i, led_state[i]);
+			old_led_state[i] = led_state[i];
+		}
+	}
+	
+	ggiFlush(vis);
+}
+
+
+uint8 *C64Display::BitmapBase(void)
+{
+       return (uint8 *)c64fb;
+}
+
+
+int C64Display::BitmapXMod(void)
+{
+       return c64stride;
+}
+
+
+void C64Display::PollKeyboard(uint8 *key_matrix, uint8 *rev_matrix,
+			      uint8 *joystick)
+{
+	ggi_event ev;
+	struct timeval tv;
+	int kc;
+	
+	while (1) {
+		tv = (struct timeval) { 0, 0 };
+		if (ggiEventPoll(vis, emKey, &tv) == 0)
+			break;
+		ggiEventRead(vis, &ev, emKey);
+		kc = ksym2c64(ev.key.label);
+		
+		if (ev.any.type == evKeyPress) {
+			switch (kc) {
+			case KEY_KP_PLUS:
+				if (ThePrefs.SkipFrames < 10)
+					ThePrefs.SkipFrames++;
+				break;
+				
+			case KEY_KP_MINUS:
+				if (ThePrefs.SkipFrames > 1)
+					ThePrefs.SkipFrames--;
+				break;
+				
+			case KEY_KP_MULT:
+				ThePrefs.LimitSpeed = !ThePrefs.LimitSpeed;
+				break;
+				
+			case KEY_KP_DIV:
+				ThePrefs.JoystickSwap = !ThePrefs.JoystickSwap;
+				break;
+				
+			case KEY_NUM_LOCK:
+				numlock = !numlock;
+				break;
+				
+/*			case KEY_F9:	// F9: Invoke SAM
+				SAM(TheC64);
+				break;
+*/
+
+			case KEY_F10:
+				quit = 1;
+				break;
+				
+			case KEY_F11:
+				f11pressed = 1;
+				break;
+				
+			case KEY_F12:
+				f12pressed = 1;
+				break;
+				
+			case KEY_FIRE:
+				joystate &= ~0x10;
+				break;
+			case KEY_JD:
+				joystate &= ~0x02;
+				break;
+			case KEY_JU:
+				joystate &= ~0x01;
+				break;
+			case KEY_JL:
+				joystate &= ~0x04;
+				break;
+			case KEY_JR:
+				joystate &= ~0x08;
+				break;
+			case KEY_JUL:
+				joystate &= ~0x05;
+				break;
+			case KEY_JUR:
+				joystate &= ~0x09;
+				break;
+			case KEY_JDL:
+				joystate &= ~0x06;
+				break;
+			case KEY_JDR:
+				joystate &= ~0x0a;
+				break;
+				
+			case KEY_DRV_SWAP:
+/*				strcpy(tmpstr, ThePrefs.DrivePath[0]);
+				strcpy(ThePrefs.DrivePath[0],
+				       ThePrefs.DrivePath[1]);
+				strcpy(ThePrefs.DrivePath[1], tmpstr);
+				delete drive[0];
+				delete drive[1];
+				drive[0] = new D64Drive(this, ThePrefs.DrivePath[0]);
+				drive[1] = new D64Drive(this, ThePrefs.DrivePath[1]);*/
+				break;
+			default:
+				if (keystate[kc])
+					break;
+				keystate[kc] = 1;
+				int c64_byte, c64_bit, shifted;
+				c64_byte = kc >> 3;
+				c64_bit = kc & 7;
+				shifted = kc & 128;
+				c64_byte &= 7;
+				if (shifted) {
+					key_matrix[6] &= 0xef;
+					rev_matrix[4] &= 0xbf;
+				}
+				key_matrix[c64_byte] &= ~(1 << c64_bit);
+				rev_matrix[c64_bit] &= ~(1 << c64_byte);
+				break;
+			}
+		} else if (ev.any.type == evKeyRelease) {
+			switch (kc) {			
+			case KEY_FIRE:
+				joystate |= 0x10;
+				break;
+			case KEY_JD:
+				joystate |= 0x02;
+				break;
+			case KEY_JU:
+				joystate |= 0x01;
+				break;
+			case KEY_JL:
+				joystate |= 0x04;
+				break;
+			case KEY_JR:
+				joystate |= 0x08;
+				break;
+			case KEY_JUL:
+				joystate |= 0x05;
+				break;
+			case KEY_JUR:
+				joystate |= 0x09;
+				break;
+			case KEY_JDL:
+				joystate |= 0x06;
+				break;
+			case KEY_JDR:
+				joystate |= 0x0a;
+				break;
+				
+			default:
+				if (!keystate[kc])
+					break;
+				keystate[kc] = 0;
+				int c64_byte, c64_bit, shifted;
+				c64_byte = kc >> 3;
+				c64_bit = kc & 7;
+				shifted = kc & 128;
+				c64_byte &= 7;
+				if (shifted) {
+					key_matrix[6] |= 0x10;
+					rev_matrix[4] |= 0x40;
+				}
+				key_matrix[c64_byte] |= (1 << c64_bit);
+				rev_matrix[c64_bit] |= (1 << c64_byte);
+				break;
+			}
+			
+		}
+	}
+
+    *joystick = joystate;
+    if (f11pressed)
+		TheC64->NMI();
+    if (f12pressed)
+		TheC64->Reset();
+    if (quit)
+		quit_requested = true;
+    f11pressed = f12pressed = 0;
+}
+
+
+/*
+ *  Check if NumLock is down (for switching the joystick keyboard emulation)
+ */
+
+bool C64Display::NumLock(void)
+{
+       return numlock;
+}
+
+
+/*
+ *  Allocate C64 colors
+ */
+
+static int colorval(int v)
+{
+       return ((v & 255)*0x01010101) >> 26;
+}
+
+void C64Display::InitColors(uint8 *colors)
+{
+	int i;
+	char str[16];
+	ggi_color col;
+
+	if (GT_SCHEME(gt) != GT_PALETTE) {
+		if (bpp == 3)
+			palette = malloc(256*4);
+		else 
+			palette = malloc(256*bpp);
+	}
+	for (i=0; i < 256; i++) {
+		col.r = colorval(palette_red[i & 0x0f])<<10;
+		col.g = colorval(palette_green[i & 0x0f])<<10;
+		col.b = colorval(palette_blue[i & 0x0f])<<10;
+		ggiSetPalette(vis, i, 1, &col);
+		if (GT_SCHEME(gt) != GT_PALETTE) {
+			if (bpp == 1) {
+				uint8 *palptr = (uint8*)palette;
+				palptr[i] = ggiMapColor(vis, &col);
+			} else if (bpp == 2) {
+				uint16 *palptr = (uint16*)palette;
+				palptr[i] = ggiMapColor(vis, &col);
+			} else if (bpp == 3 || bpp == 4) {
+				uint32 *palptr = (uint32*)palette;
+				palptr[i] = ggiMapColor(vis, &col);
+			}
+		}
+		colors[i] = i;
+	}
+
+	if (usestatus) {
+		col.r = 0xd000;
+		col.g = 0xd000;
+		col.b = 0xd000;
+		fill_gray = ggiMapColor(vis, &col);
+		col.r = 0xe800;
+		col.g = 0xe800;
+		col.b = 0xe800;
+		shine_gray = ggiMapColor(vis, &col);
+		col.r = 0x9800;
+		col.g = 0x9800;
+		col.b = 0x9800;
+		shadow_gray = ggiMapColor(vis, &col);
+		col.r = 0xd000;
+		col.g = 0x0;
+		col.b = 0x0;
+		red = ggiMapColor(vis, &col);
+		col.r = 0x0;
+		col.g = 0xf000;
+		col.b = 0x0;
+		green = ggiMapColor(vis, &col);
+		
+		/* Draw speedometer/LEDs
+		   (We must only do it after the palette has been set) */
+		
+		
+		ggiSetGCForeground(vis, fill_gray);
+		ggiDrawBox(vis, 0, DISPLAY_Y, linewidth-1, STATHEIGHT);
+		
+		ggiSetGCForeground(vis, shine_gray);
+		ggiDrawLine(vis, 0, DISPLAY_Y, linewidth-1, DISPLAY_Y);
+		for (i=0; i<5; i++)
+			ggiDrawLine(vis, linewidth*i/5, DISPLAY_Y,
+				    linewidth*i/5, DISPLAY_Y+14);
+		for (i=2; i<6; i++) {
+			ggiDrawLine(vis, linewidth*i/5-23, DISPLAY_Y+11,
+				    linewidth*i/5-9, DISPLAY_Y+11);
+			ggiDrawLine(vis, linewidth*i/5-9, DISPLAY_Y+11,
+				    linewidth*i/5-9, DISPLAY_Y+5);
+		}
+		
+		ggiSetGCForeground(vis, shadow_gray);
+		ggiDrawLine(vis, 0, DISPLAY_Y+15, linewidth-1, DISPLAY_Y+15);
+		for (i=1; i<6; i++)
+			ggiDrawLine(vis, linewidth*i/5-1, DISPLAY_Y+1,
+				    linewidth*i/5-1, DISPLAY_Y+15);
+		for (i=2; i<6; i++) {
+			ggiDrawLine(vis, linewidth*i/5-24, DISPLAY_Y+11,
+				    linewidth*i/5-24, DISPLAY_Y+4);
+			ggiDrawLine(vis, linewidth*i/5-24, DISPLAY_Y+4,
+				    linewidth*i/5-9, DISPLAY_Y+4);
+		}
+		
+		for (i=0; i<4; i++) {
+			sprintf(str, " %d", i+8);
+			ggiSetGCForeground(vis, black);
+			ggiSetGCBackground(vis, fill_gray);
+			ggiPuts(vis, linewidth*(i+1)/5+8, DISPLAY_Y+4, str);
+			draw_led(i, LED_OFF);
+		}
+	}
+}
+
+
+/*
+ *  Show a requester (error message)
+ */
+
+long int ShowRequester(char *a,char *b,char *)
+{
+       printf("%s: %s\n", a, b);
+       return 1;
+}
+
diff -Nur orig/Frodo/Src/Display_x.i Frodo/Src/Display_x.i
--- orig/Frodo/Src/Display_x.i	Wed Aug  6 20:56:26 1997
+++ Frodo/Src/Display_x.i	Sat May 22 23:11:47 1999
@@ -4,6 +4,7 @@
  *
  *  Frodo (C) 1994-1997 Christian Bauer
  *  X11 stuff by Bernd Schmidt/Lutz Vieweg
+ *  Support for visuals >8 bits by Michael Krause
  */
 
 #include "CmdPipe.h"
@@ -35,7 +36,8 @@
 static Visual *vis;
 static XVisualInfo visualInfo;
 static int bitdepth;
-static char *bufmem;
+static char *bufmem, *bufmem8;
+static uint32 trans[1<<12];
 static int hsize;
 
 // For LED error blinking
@@ -382,13 +384,8 @@
 
 	screen = XDefaultScreen(display);
 	rootwin = XRootWindow(display, screen);
-#if 0  
 	if (XMatchVisualInfo(display, screen, 16, TrueColor, &visualInfo)) {
-	} else if (XMatchVisualInfo(display, screen, 24, TrueColor, &visualInfo)) {
-	} else 
-#endif
-	if (XMatchVisualInfo(display, screen, 8, PseudoColor, &visualInfo)) {
-		/* for our HP boxes */
+	} else if (XMatchVisualInfo(display, screen, 8, PseudoColor, &visualInfo)) {
 	} else if (XMatchVisualInfo(display, screen, 8, GrayScale, &visualInfo)) {
 	} else {
 		fprintf(stderr, "Can't obtain appropriate X visual\n");
@@ -398,7 +395,7 @@
 	vis = visualInfo.visual;
 	bitdepth = visualInfo.depth;
 	pixbytes = (bitdepth == 24 || bitdepth == 32 ? 4 : bitdepth == 12 || bitdepth == 16 ? 2 : 1);
-	fprintf(stderr, "Using %d bit visual\n", bitdepth);
+	fprintf(stderr, "Using %d bit visual%s", bitdepth, bitdepth>8 ? " - please use 8 bits for highest performance!\n" : "\n");
 
 	hsize = (DISPLAY_X + 3) & ~3;
 
@@ -419,6 +416,10 @@
 	img = XCreateImage(display, vis, bitdepth, ZPixmap, 0, bufmem, hsize, DISPLAY_Y, 32, 0);
 #endif
 
+	if(bitdepth > 8) {
+	    bufmem8 = (char*)malloc(hsize * DISPLAY_Y);
+	}
+
 	cmap = XCreateColormap(display, rootwin, vis, AllocNone);
 
 	XParseColor(display, cmap, "#000000", &black);
@@ -484,6 +485,27 @@
 {
 	// Update C64 display
 	XSync(display, 0);
+
+	if(bitdepth == 16) {
+	    // Best thing would be to change
+	    // VIC.cpp so it could render directly into 16-bit or 32-bit
+	    // memory instead of into an 8-bit chunky buffer.
+	    uint16 *p = (uint16*)bufmem8, *x = p + hsize*DISPLAY_Y/2;
+	    uint32 *d = (uint32*)bufmem;
+	    while(p < x) {
+		*d++ = trans[*p++ & 0x0fff];
+	    }
+#if 0
+	    // Just a plain version. Might be necessary on non-i386
+	    // machines?
+	    uint8 *p = (uint8*)bufmem8, *x = p + hsize*DISPLAY_Y;
+	    uint16 *d = (uint16*)bufmem;
+	    while(p < x) {
+		*d++ = eight2sixteen[*p++];
+	    }
+#endif
+	}
+
 #if defined(X_USE_SHM)
 	XShmPutImage(display, mywin, black_gc, img, 0, 0, 0, 0, DISPLAY_X, DISPLAY_Y, 0);
 #else
@@ -566,7 +588,7 @@
 
 uint8 *C64Display::BitmapBase(void)
 {
-	return (uint8 *)bufmem;
+	return (uint8*)(bitdepth>8 ? bufmem8 : bufmem);
 }
 
 
@@ -776,14 +798,27 @@
 	int i;
 	XColor col;
 	char str[20];
+	uint16 eight2sixteen[16];
 
 	for (i=0; i< 256; i++) {
+	    if(bitdepth == 16) {
+		colors[i] = i & 0x0f;
+		if(i < 16) {
+		    eight2sixteen[i] = ((uint16(palette_red[i]) << 8) & 0xf800) | ((uint16(palette_green[i]) << 3) & 0x07e0) | (palette_blue[i] >> 3);
+		}
+	    } else {
 		sprintf(str, "rgb:%x/%x/%x", palette_red[i & 0x0f], palette_green[i & 0x0f], palette_blue[i & 0x0f]);
 		XParseColor(display, cmap, str, &col);
 		if (XAllocColor(display, cmap, &col))
 			colors[i] = col.pixel;
 		else
 			fprintf(stderr, "Couldn't get all colors\n");
+	    }
+	}
+
+	// Table to translate two 8-bit src -> two 16-bit dest
+	for(i=0; i<1<<12;i++) {
+	    trans[i] = eight2sixteen[i & 0x0f] | (eight2sixteen[i >> 8] << 16);
 	}
 }
 
diff -Nur orig/Frodo/Src/Makefile.in Frodo/Src/Makefile.in
--- orig/Frodo/Src/Makefile.in	Wed Aug  6 20:56:29 1997
+++ Frodo/Src/Makefile.in	Sat May 22 23:11:47 1999
@@ -55,7 +55,7 @@
 .cpp.s:
 	$(CC) $(INCLUDES) $(CFLAGS) $(EXTRAFLAGS) -o $@ -S $*.cpp -g0
 
-C64_PC.o: C64.cpp C64.h C64_x.i CmdPipe.h CPUC64.h CPU1541.h VIC.h SID.h CIA.h REU.h IEC.h 1541job.h Display.h Prefs.h
+C64_PC.o: C64.cpp C64.h C64_unix.i CmdPipe.h CPUC64.h CPU1541.h VIC.h SID.h CIA.h REU.h IEC.h 1541job.h Display.h Prefs.h
 	$(CC) $(INCLUDES) $(CFLAGS) $(PCFLAGS) -o $@ -c $*.cpp
 
 CPUC64_PC.o: CPUC64.cpp CPUC64.h CPU_emulline.i C64.h VIC.h SID.h CIA.h REU.h IEC.h Display.h Version.h
@@ -64,7 +64,7 @@
 CPU1541_PC.o: CPU1541.cpp CPU1541.h CPU_emulline.i 1541job.h C64.h CIA.h Display.h
 	$(CC) $(INCLUDES) $(CFLAGS) $(PCFLAGS) -o $@ -c $*.cpp
 
-C64_SC.o: C64_SC.cpp C64.h C64_x.i CmdPipe.h CPUC64.h CPU1541.h VIC.h SID.h CIA.h REU.h IEC.h 1541job.h Display.h Prefs.h
+C64_SC.o: C64_SC.cpp C64.h C64_unix.i CmdPipe.h CPUC64.h CPU1541.h VIC.h SID.h CIA.h REU.h IEC.h 1541job.h Display.h Prefs.h
 	$(CC) $(INCLUDES) $(CFLAGS) $(SCFLAGS) -o $@ -c $*.cpp
 
 CPUC64_SC.o: CPUC64_SC.cpp CPUC64.h CPU_emulcycle.i CPU_common.h C64.h VIC.h SID.h CIA.h REU.h IEC.h Display.h Version.h
@@ -81,9 +81,9 @@
 
 ## Dependencies
 main.o: main.cpp main.h main_x.i C64.h Display.h Prefs.h SAM.h Version.h
-C64.o: C64.cpp C64.h C64_x.i CmdPipe.h CPUC64.h CPU1541.h VIC.h SID.h CIA.h REU.h IEC.h 1541job.h Display.h Prefs.h
+C64.o: C64.cpp C64.h C64_unix.i CmdPipe.h CPUC64.h CPU1541.h VIC.h SID.h CIA.h REU.h IEC.h 1541job.h Display.h Prefs.h
 CmdPipe.o: CmdPipe.h
-Display.o: Display.cpp Display.h Display_x.i Display_svga.i main.h Prefs.h
+Display.o: Display.cpp Display.h Display_x.i Display_svga.i Display_ggi.i main.h Prefs.h
 Prefs.o: Prefs.cpp Prefs.h Display.h main.h
 CPUC64.o: CPUC64.cpp CPUC64.h CPU_emulline.i C64.h VIC.h SID.h CIA.h REU.h IEC.h Display.h Version.h
 CPU1541.o: CPU1541.cpp CPU1541.h CPU_emulline.i 1541job.h C64.h CIA.h Display.h
Binary files orig/Frodo/Src/a.out and Frodo/Src/a.out differ
diff -Nur orig/Frodo/Src/configure Frodo/Src/configure
--- orig/Frodo/Src/configure	Wed Aug  6 20:56:31 1997
+++ Frodo/Src/configure	Sat May 22 23:39:53 1999
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.12 
+# Generated automatically using autoconf version 2.13 
 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
 #
 # This configure script is free software; the Free Software Foundation
@@ -17,6 +17,8 @@
   --enable-kbd-lang-de    Use german keyboard layout"
 ac_help="$ac_help
   --enable-kbd-lang-us    Use american keyboard layout"
+ac_help="$ac_help
+  --enable-ggi            Use the GGI library"
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
@@ -55,6 +57,7 @@
 # Initialize some other variables.
 subdirs=
 MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
 # Maximum number of lines to put in a shell here document.
 ac_max_here_lines=12
 
@@ -338,7 +341,7 @@
     verbose=yes ;;
 
   -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 2.12"
+    echo "configure generated by autoconf version 2.13"
     exit 0 ;;
 
   -with-* | --with-*)
@@ -508,9 +511,11 @@
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
+ac_exeext=
+ac_objext=o
 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
@@ -528,15 +533,16 @@
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:532: checking for $ac_word" >&5
+echo "configure:537: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_CC="gcc"
@@ -557,16 +563,17 @@
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:561: checking for $ac_word" >&5
+echo "configure:567: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
-  for ac_dir in $PATH; do
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
@@ -601,25 +608,61 @@
   echo "$ac_t""no" 1>&6
 fi
 
+  if test -z "$CC"; then
+    case "`uname -s`" in
+    *win32* | *WIN32*)
+      # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:618: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CC="cl"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+ ;;
+    esac
+  fi
   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:609: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:650: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
-cat > conftest.$ac_ext <<EOF
-#line 619 "configure"
+cat > conftest.$ac_ext << EOF
+
+#line 661 "configure"
 #include "confdefs.h"
+
 main(){return(0);}
 EOF
-if { (eval echo configure:623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -633,18 +676,24 @@
   ac_cv_prog_cc_works=no
 fi
 rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
 if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:643: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:692: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:648: checking whether we are using GNU C" >&5
+echo "configure:697: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -653,7 +702,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:657: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:706: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -664,11 +713,15 @@
 
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
-  ac_test_CFLAGS="${CFLAGS+set}"
-  ac_save_CFLAGS="$CFLAGS"
-  CFLAGS=
-  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:672: checking whether ${CC-cc} accepts -g" >&5
+else
+  GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:725: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -683,32 +736,37 @@
 fi
 
 echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-  if test "$ac_test_CFLAGS" = set; then
-    CFLAGS="$ac_save_CFLAGS"
-  elif test $ac_cv_prog_cc_g = yes; then
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
     CFLAGS="-g -O2"
   else
-    CFLAGS="-O2"
+    CFLAGS="-g"
   fi
 else
-  GCC=
-  test "${CFLAGS+set}" = set || CFLAGS="-g"
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
 fi
 
-for ac_prog in $CCC c++ g++ gcc CC cxx cc++
+for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:704: checking for $ac_word" >&5
+echo "configure:761: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CXX"; then
   ac_cv_prog_CXX="$CXX" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_CXX="$ac_prog"
@@ -731,21 +789,23 @@
 
 
 echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:735: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:793: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
 
 ac_ext=C
 # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cxx_cross
 
-cat > conftest.$ac_ext <<EOF
-#line 745 "configure"
+cat > conftest.$ac_ext << EOF
+
+#line 804 "configure"
 #include "confdefs.h"
-main(){return(0);}
+
+int main(){return(0);}
 EOF
-if { (eval echo configure:749: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:809: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cxx_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -763,7 +823,7 @@
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6
@@ -771,12 +831,12 @@
   { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:775: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:835: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
 cross_compiling=$ac_cv_prog_cxx_cross
 
 echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
-echo "configure:780: checking whether we are using GNU C++" >&5
+echo "configure:840: checking whether we are using GNU C++" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -785,7 +845,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:789: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:849: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gxx=yes
 else
   ac_cv_prog_gxx=no
@@ -796,11 +856,15 @@
 
 if test $ac_cv_prog_gxx = yes; then
   GXX=yes
-  ac_test_CXXFLAGS="${CXXFLAGS+set}"
-  ac_save_CXXFLAGS="$CXXFLAGS"
-  CXXFLAGS=
-  echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
-echo "configure:804: checking whether ${CXX-g++} accepts -g" >&5
+else
+  GXX=
+fi
+
+ac_test_CXXFLAGS="${CXXFLAGS+set}"
+ac_save_CXXFLAGS="$CXXFLAGS"
+CXXFLAGS=
+echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
+echo "configure:868: checking whether ${CXX-g++} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -815,20 +879,24 @@
 fi
 
 echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6
-  if test "$ac_test_CXXFLAGS" = set; then
-    CXXFLAGS="$ac_save_CXXFLAGS"
-  elif test $ac_cv_prog_cxx_g = yes; then
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS="$ac_save_CXXFLAGS"
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
     CXXFLAGS="-g -O2"
   else
-    CXXFLAGS="-O2"
+    CXXFLAGS="-g"
   fi
 else
-  GXX=
-  test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
 fi
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:832: checking how to run the C preprocessor" >&5
+echo "configure:900: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -843,14 +911,14 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 847 "configure"
+#line 915 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:853: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:921: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
 else
@@ -860,14 +928,31 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 864 "configure"
+#line 932 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:938: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP="${CC-cc} -nologo -E"
+  cat > conftest.$ac_ext <<EOF
+#line 949 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:870: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:955: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
 else
@@ -880,6 +965,8 @@
 rm -f conftest*
 fi
 rm -f conftest*
+fi
+rm -f conftest*
   ac_cv_prog_CPP="$CPP"
 fi
   CPP="$ac_cv_prog_CPP"
@@ -889,7 +976,7 @@
 echo "$ac_t""$CPP" 1>&6
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:893: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:980: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -929,9 +1016,9 @@
 fi
 
 echo $ac_n "checking for AIX""... $ac_c" 1>&6
-echo "configure:933: checking for AIX" >&5
+echo "configure:1020: checking for AIX" >&5
 cat > conftest.$ac_ext <<EOF
-#line 935 "configure"
+#line 1022 "configure"
 #include "confdefs.h"
 #ifdef _AIX
   yes
@@ -953,7 +1040,7 @@
 
 
 echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
-echo "configure:957: checking for POSIXized ISC" >&5
+echo "configure:1044: checking for POSIXized ISC" >&5
 if test -d /etc/conf/kconfig.d &&
   grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
 then
@@ -976,7 +1063,7 @@
 
 HAVE_BEBOX=n
 echo $ac_n "checking for OpenLibrary in -lamiga""... $ac_c" 1>&6
-echo "configure:980: checking for OpenLibrary in -lamiga" >&5
+echo "configure:1067: checking for OpenLibrary in -lamiga" >&5
 ac_lib_var=`echo amiga'_'OpenLibrary | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -984,7 +1071,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lamiga  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 988 "configure"
+#line 1075 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -995,7 +1082,7 @@
 OpenLibrary()
 ; return 0; }
 EOF
-if { (eval echo configure:999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1086: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1017,7 +1104,7 @@
 fi
 
 echo $ac_n "checking for vga_setmode in -lvga""... $ac_c" 1>&6
-echo "configure:1021: checking for vga_setmode in -lvga" >&5
+echo "configure:1108: checking for vga_setmode in -lvga" >&5
 ac_lib_var=`echo vga'_'vga_setmode | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1025,7 +1112,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lvga  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1029 "configure"
+#line 1116 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1036,7 +1123,7 @@
 vga_setmode()
 ; return 0; }
 EOF
-if { (eval echo configure:1040: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1127: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1057,13 +1144,54 @@
 HAVE_SVGA_LIB=n
 fi
 
+echo $ac_n "checking for ggiResourceFastAcquire in -lggi""... $ac_c" 1>&6
+echo "configure:1149: checking for ggiResourceFastAcquire in -lggi" >&5
+ac_lib_var=`echo ggi'_'ggiResourceFastAcquire | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lggi  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1157 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char ggiResourceFastAcquire();
+
+int main() {
+ggiResourceFastAcquire()
+; return 0; }
+EOF
+if { (eval echo configure:1168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  HAVE_GGI_LIB=yes
+else
+  echo "$ac_t""no" 1>&6
+HAVE_GGI_LIB=no
+fi
+
 
 # If we find X, set shell vars x_includes and x_libraries to the
 # paths, otherwise set no_x=yes.
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:1067: checking for X" >&5
+echo "configure:1195: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -1125,13 +1253,13 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 1129 "configure"
+#line 1257 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1134: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1262: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   # We can compile using X headers with no special include directory.
@@ -1199,14 +1327,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1203 "configure"
+#line 1331 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:1210: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1338: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -1312,17 +1440,17 @@
     case "`(uname -sr) 2>/dev/null`" in
     "SunOS 5"*)
       echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
-echo "configure:1316: checking whether -R must be followed by a space" >&5
+echo "configure:1444: checking whether -R must be followed by a space" >&5
       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
       cat > conftest.$ac_ext <<EOF
-#line 1319 "configure"
+#line 1447 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1326: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1454: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -1338,14 +1466,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 1342 "configure"
+#line 1470 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1477: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -1377,7 +1505,7 @@
     # libraries were built with DECnet support.  And karl@cs.umb.edu says
     # the Alpha needs dnet_stub (dnet does not exist).
     echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:1381: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:1509: checking for dnet_ntoa in -ldnet" >&5
 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1385,7 +1513,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1389 "configure"
+#line 1517 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1396,7 +1524,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:1400: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1528: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1418,7 +1546,7 @@
 
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:1422: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:1550: checking for dnet_ntoa in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1426,7 +1554,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1430 "configure"
+#line 1558 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1437,7 +1565,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:1441: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1569: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1466,12 +1594,12 @@
     # The nsl library prevents programs from opening the X display
     # on Irix 5.2, according to dickey@clark.net.
     echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:1470: checking for gethostbyname" >&5
+echo "configure:1598: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1475 "configure"
+#line 1603 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -1494,7 +1622,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1626: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -1515,7 +1643,7 @@
 
     if test $ac_cv_func_gethostbyname = no; then
       echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:1519: checking for gethostbyname in -lnsl" >&5
+echo "configure:1647: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1523,7 +1651,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1527 "configure"
+#line 1655 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1534,7 +1662,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:1538: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1564,12 +1692,12 @@
     # -lsocket must be given before -lnsl if both are needed.
     # We assume that if connect needs -lnsl, so does gethostbyname.
     echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:1568: checking for connect" >&5
+echo "configure:1696: checking for connect" >&5
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1573 "configure"
+#line 1701 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -1592,7 +1720,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1596: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1724: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -1613,7 +1741,7 @@
 
     if test $ac_cv_func_connect = no; then
       echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:1617: checking for connect in -lsocket" >&5
+echo "configure:1745: checking for connect in -lsocket" >&5
 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1621,7 +1749,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1625 "configure"
+#line 1753 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1632,7 +1760,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:1636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1656,12 +1784,12 @@
 
     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
     echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:1660: checking for remove" >&5
+echo "configure:1788: checking for remove" >&5
 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1665 "configure"
+#line 1793 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -1684,7 +1812,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1688: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1816: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -1705,7 +1833,7 @@
 
     if test $ac_cv_func_remove = no; then
       echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:1709: checking for remove in -lposix" >&5
+echo "configure:1837: checking for remove in -lposix" >&5
 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1713,7 +1841,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lposix  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1717 "configure"
+#line 1845 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1724,7 +1852,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:1728: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1748,12 +1876,12 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:1752: checking for shmat" >&5
+echo "configure:1880: checking for shmat" >&5
 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1757 "configure"
+#line 1885 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -1776,7 +1904,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -1797,7 +1925,7 @@
 
     if test $ac_cv_func_shmat = no; then
       echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:1801: checking for shmat in -lipc" >&5
+echo "configure:1929: checking for shmat in -lipc" >&5
 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1805,7 +1933,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lipc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1809 "configure"
+#line 1937 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1816,7 +1944,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:1820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1948: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1849,15 +1977,15 @@
   # libraries we check for below, so use a different variable.
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:1853: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:1981: checking for IceConnectionNumber in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lICE  $LIBS"
+LIBS="-lICE $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1861 "configure"
+#line 1989 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1868,7 +1996,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:1872: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2000: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1899,12 +2027,12 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:1903: checking for $ac_hdr that defines DIR" >&5
+echo "configure:2031: checking for $ac_hdr that defines DIR" >&5
 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1908 "configure"
+#line 2036 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -1912,7 +2040,7 @@
 DIR *dirp = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:1916: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2044: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_header_dirent_$ac_safe=yes"
 else
@@ -1937,7 +2065,7 @@
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:1941: checking for opendir in -ldir" >&5
+echo "configure:2069: checking for opendir in -ldir" >&5
 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1945,7 +2073,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldir  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1949 "configure"
+#line 2077 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1956,7 +2084,7 @@
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:1960: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1978,7 +2106,7 @@
 
 else
 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:1982: checking for opendir in -lx" >&5
+echo "configure:2110: checking for opendir in -lx" >&5
 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1986,7 +2114,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lx  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1990 "configure"
+#line 2118 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1997,7 +2125,7 @@
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:2001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2020,12 +2148,12 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:2024: checking for ANSI C header files" >&5
+echo "configure:2152: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2029 "configure"
+#line 2157 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -2033,8 +2161,8 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2037: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:2165: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   ac_cv_header_stdc=yes
@@ -2050,7 +2178,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 2054 "configure"
+#line 2182 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -2068,7 +2196,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 2072 "configure"
+#line 2200 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -2089,7 +2217,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 2093 "configure"
+#line 2221 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -2100,7 +2228,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:2104: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2232: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -2127,18 +2255,18 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2131: checking for $ac_hdr" >&5
+echo "configure:2259: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2136 "configure"
+#line 2264 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2141: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:2269: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
@@ -2167,18 +2295,18 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2171: checking for $ac_hdr" >&5
+echo "configure:2299: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2176 "configure"
+#line 2304 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2181: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:2309: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
@@ -2206,11 +2334,12 @@
 
 if [ "$ac_cv_header_linux_joystick_h" = "yes" ]; then
   echo $ac_n "checking whether linux/joystick.h is broken""... $ac_c" 1>&6
-echo "configure:2210: checking whether linux/joystick.h is broken" >&5
+echo "configure:2338: checking whether linux/joystick.h is broken" >&5
   if grep "#include" /usr/include/linux/joystick.h >/dev/null; then
     echo "$ac_t""yes" 1>&6
     BROKEN_JOYSTICK_H=1
-    grep -v "#include" /usr/include/linux/joystick.h >joystick.h
+    echo '#include <asm/types.h>' > joystick.h
+    grep -v "#include" /usr/include/linux/joystick.h >> joystick.h
   else
     echo "$ac_t""no" 1>&6
     BROKEN_JOYSTICK_H=0
@@ -2218,7 +2347,7 @@
 fi
 
 echo $ac_n "checking size of char""... $ac_c" 1>&6
-echo "configure:2222: checking size of char" >&5
+echo "configure:2351: checking size of char" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2226,7 +2355,7 @@
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 2230 "configure"
+#line 2359 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -2237,7 +2366,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:2241: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2370: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_char=`cat conftestval`
 else
@@ -2257,7 +2386,7 @@
 
 
 echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:2261: checking size of short" >&5
+echo "configure:2390: checking size of short" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2265,7 +2394,7 @@
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 2269 "configure"
+#line 2398 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -2276,7 +2405,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:2280: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_short=`cat conftestval`
 else
@@ -2296,7 +2425,7 @@
 
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:2300: checking size of int" >&5
+echo "configure:2429: checking size of int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2304,7 +2433,7 @@
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 2308 "configure"
+#line 2437 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -2315,7 +2444,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:2319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2448: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -2335,7 +2464,7 @@
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:2339: checking size of long" >&5
+echo "configure:2468: checking size of long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2343,7 +2472,7 @@
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 2347 "configure"
+#line 2476 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -2354,7 +2483,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:2358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -2374,7 +2503,7 @@
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:2378: checking size of long long" >&5
+echo "configure:2507: checking size of long long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2382,7 +2511,7 @@
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 2386 "configure"
+#line 2515 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -2393,7 +2522,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:2397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long_long=`cat conftestval`
 else
@@ -2414,12 +2543,12 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:2418: checking for working const" >&5
+echo "configure:2547: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2423 "configure"
+#line 2552 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -2468,7 +2597,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2472: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2601: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -2489,21 +2618,21 @@
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:2493: checking for inline" >&5
+echo "configure:2622: checking for inline" >&5
 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 2500 "configure"
+#line 2629 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:2507: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2636: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -2529,12 +2658,12 @@
 esac
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:2533: checking for mode_t" >&5
+echo "configure:2662: checking for mode_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2538 "configure"
+#line 2667 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2543,7 +2672,7 @@
 #endif
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "mode_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+  egrep "(^|[^a-zA-Z_0-9])mode_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_type_mode_t=yes
 else
@@ -2562,12 +2691,12 @@
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:2566: checking for off_t" >&5
+echo "configure:2695: checking for off_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2571 "configure"
+#line 2700 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2576,7 +2705,7 @@
 #endif
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+  egrep "(^|[^a-zA-Z_0-9])off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_type_off_t=yes
 else
@@ -2595,12 +2724,12 @@
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2599: checking for pid_t" >&5
+echo "configure:2728: checking for pid_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2604 "configure"
+#line 2733 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2609,7 +2738,7 @@
 #endif
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+  egrep "(^|[^a-zA-Z_0-9])pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_type_pid_t=yes
 else
@@ -2628,12 +2757,12 @@
 fi
 
 echo $ac_n "checking for st_blocks in struct stat""... $ac_c" 1>&6
-echo "configure:2632: checking for st_blocks in struct stat" >&5
+echo "configure:2761: checking for st_blocks in struct stat" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_st_blocks'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2637 "configure"
+#line 2766 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -2641,7 +2770,7 @@
 struct stat s; s.st_blocks;
 ; return 0; }
 EOF
-if { (eval echo configure:2645: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2774: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_st_blocks=yes
 else
@@ -2660,16 +2789,16 @@
 EOF
 
 else
-  LIBOBJS="$LIBOBJS fileblocks.o"
+  LIBOBJS="$LIBOBJS fileblocks.${ac_objext}"
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:2668: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:2797: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2673 "configure"
+#line 2802 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -2678,7 +2807,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:2682: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2811: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -2699,12 +2828,12 @@
 fi
 
 echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:2703: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:2832: checking whether struct tm is in sys/time.h or time.h" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2708 "configure"
+#line 2837 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -2712,7 +2841,7 @@
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:2716: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2845: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -2735,13 +2864,13 @@
 
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:2739: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:2868: checking whether ${CC-cc} needs -traditional" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
     ac_pattern="Autoconf.*'x'"
   cat > conftest.$ac_ext <<EOF
-#line 2745 "configure"
+#line 2874 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 Autoconf TIOCGETP
@@ -2759,7 +2888,7 @@
 
   if test $ac_cv_prog_gcc_traditional = no; then
     cat > conftest.$ac_ext <<EOF
-#line 2763 "configure"
+#line 2892 "configure"
 #include "confdefs.h"
 #include <termio.h>
 Autoconf TCGETA
@@ -2781,7 +2910,7 @@
 fi
 
 echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:2785: checking for 8-bit clean memcmp" >&5
+echo "configure:2914: checking for 8-bit clean memcmp" >&5
 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2789,7 +2918,7 @@
   ac_cv_func_memcmp_clean=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 2793 "configure"
+#line 2922 "configure"
 #include "confdefs.h"
 
 main()
@@ -2799,7 +2928,7 @@
 }
 
 EOF
-if { (eval echo configure:2803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2932: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_memcmp_clean=yes
 else
@@ -2814,15 +2943,15 @@
 fi
 
 echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6
-test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.o"
+test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:2821: checking return type of signal handlers" >&5
+echo "configure:2950: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2826 "configure"
+#line 2955 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -2839,7 +2968,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:2843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2972: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -2858,7 +2987,7 @@
 
 
 echo $ac_n "checking whether utime accepts a null argument""... $ac_c" 1>&6
-echo "configure:2862: checking whether utime accepts a null argument" >&5
+echo "configure:2991: checking whether utime accepts a null argument" >&5
 if eval "test \"`echo '$''{'ac_cv_func_utime_null'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2868,7 +2997,7 @@
   ac_cv_func_utime_null=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 2872 "configure"
+#line 3001 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -2879,7 +3008,7 @@
 && t.st_mtime - s.st_mtime < 120));
 }
 EOF
-if { (eval echo configure:2883: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_utime_null=yes
 else
@@ -2905,12 +3034,12 @@
 for ac_func in gettimeofday sigaction mkdir rmdir select strerror strstr statfs usleep
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2909: checking for $ac_func" >&5
+echo "configure:3038: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2914 "configure"
+#line 3043 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2933,7 +3062,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3066: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2974,14 +3103,28 @@
 
 
 echo $ac_n "checking which target to use""... $ac_c" 1>&6
-echo "configure:2978: checking which target to use" >&5
-if [ $HAVE_BEBOX = "y" ]; then
+echo "configure:3107: checking which target to use" >&5
+# Check whether --enable-ggi or --disable-ggi was given.
+if test "${enable_ggi+set}" = set; then
+  enableval="$enable_ggi"
+  USEGGI=$enableval
+else
+  USEGGI=$enableval
+fi
+
+if [ "$USEGGI" = "yes" ]; then
+  LIBRARIES="-lggi"
+  USE_GUI=no
+  echo "$ac_t""GGI" 1>&6
+  TARGET=ggi
+  CFLAGS="$CFLAGS -D__ggi__"
+else if [ "$HAVE_BEBOX" = "y" ]; then
   echo "$ac_t""BeBox" 1>&6
   TARGET=be
-else if [ $HAVE_AMIGA_LIB = "y" ]; then
+else if [ "$HAVE_AMIGA_LIB" = "y" ]; then
   echo "$ac_t""AmigaOS" 1>&6
   TARGET=amigaos
-else if [ x$no_x = "xyes" ]; then
+else if [ "x$no_x" = "xyes" ]; then
   if [ $HAVE_SVGA_LIB = "n" ]; then
     echo "$ac_t""Ummm...." 1>&6
     echo "Neither X nor SVGAlib found, don't know what target to use."
@@ -2996,11 +3139,12 @@
   echo "$ac_t""X Window System" 1>&6
   TARGET=x11
   USEDGA=no
-  CFLAGS="$CFLAGS -I$ac_cv_x_include"
+  CFLAGS="$CFLAGS -I$ac_cv_x_include -D__x11__"
     LIBRARIES="$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS"
 fi
 fi
 fi
+fi
 
 
 LINUXELF=n
@@ -3100,7 +3244,7 @@
 # Ultrix sh set writes to stderr and can't be redirected directly,
 # and sets the high bit in the cache file unless we assign to the vars.
 (set) 2>&1 |
-  case `(ac_space=' '; set) 2>&1` in
+  case `(ac_space=' '; set | grep ac_space) 2>&1` in
   *ac_space=\ *)
     # `set' does not quote correctly, so add quotes (double-quote substitution
     # turns \\\\ into \\, and sed turns \\ into \).
@@ -3167,7 +3311,7 @@
     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.12"
+    echo "$CONFIG_STATUS generated by autoconf version 2.13"
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
@@ -3186,9 +3330,11 @@
  s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
 $ac_vpsub
 $extrasub
+s%@SHELL@%$SHELL%g
 s%@CFLAGS@%$CFLAGS%g
 s%@CPPFLAGS@%$CPPFLAGS%g
 s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
 s%@DEFS@%$DEFS%g
 s%@LDFLAGS@%$LDFLAGS%g
 s%@LIBS@%$LIBS%g
diff -Nur orig/Frodo/Src/configure.in Frodo/Src/configure.in
--- orig/Frodo/Src/configure.in	Wed Aug  6 20:56:31 1997
+++ Frodo/Src/configure.in	Sat May 22 23:14:01 1999
@@ -28,6 +28,7 @@
 HAVE_BEBOX=n
 AC_CHECK_LIB(amiga, OpenLibrary, HAVE_AMIGA_LIB=y, HAVE_AMIGA_LIB=n)
 AC_CHECK_LIB(vga, vga_setmode, HAVE_SVGA_LIB=y, HAVE_SVGA_LIB=n)
+AC_CHECK_LIB(ggi, ggiResourceFastAcquire, HAVE_GGI_LIB=yes, HAVE_GGI_LIB=no)
 
 AC_PATH_XTRA
 AC_CONFIG_HEADER(sysconfig.h)
@@ -42,7 +43,8 @@
   if grep "#include" /usr/include/linux/joystick.h >/dev/null; then
     AC_MSG_RESULT(yes)
     BROKEN_JOYSTICK_H=1
-    grep -v "#include" /usr/include/linux/joystick.h >joystick.h
+    echo '#include <asm/types.h>' > joystick.h
+    grep -v "#include" /usr/include/linux/joystick.h >> joystick.h
   else
     AC_MSG_RESULT(no)
     BROKEN_JOYSTICK_H=0
@@ -90,13 +92,20 @@
 dnl fi
 
 AC_MSG_CHECKING(which target to use)
-if [[ $HAVE_BEBOX = "y" ]]; then
+AC_ARG_ENABLE(ggi,[  --enable-ggi            Use the GGI library],[USEGGI=$enableval],[USEGGI=$enableval])
+if [[ "$USEGGI" = "yes" ]]; then
+  LIBRARIES="-lggi"
+  USE_GUI=no
+  AC_MSG_RESULT(GGI)
+  TARGET=ggi
+  CFLAGS="$CFLAGS -D__ggi__"
+else if [[ "$HAVE_BEBOX" = "y" ]]; then
   AC_MSG_RESULT(BeBox)
   TARGET=be
-else if [[ $HAVE_AMIGA_LIB = "y" ]]; then
+else if [[ "$HAVE_AMIGA_LIB" = "y" ]]; then
   AC_MSG_RESULT(AmigaOS)
   TARGET=amigaos
-else if [[ x$no_x = "xyes" ]]; then
+else if [[ "x$no_x" = "xyes" ]]; then
   if [[ $HAVE_SVGA_LIB = "n" ]]; then
     AC_MSG_RESULT(Ummm....)
     echo "Neither X nor SVGAlib found, don't know what target to use."
@@ -111,7 +120,7 @@
   AC_MSG_RESULT(X Window System)
   TARGET=x11
   USEDGA=no
-  CFLAGS="$CFLAGS -I$ac_cv_x_include"
+  CFLAGS="$CFLAGS -I$ac_cv_x_include -D__x11__"
 dnl  AC_ARG_ENABLE(dga, --enable-dga      Use the DGA extension,[USEDGA=$enableval],[USEDGA=$enableval])
 dnl  if [[ x$USEDGA = "xyes" ]]; then
 dnl    TMP_SAVE_LIBS=$LIBS
@@ -126,6 +135,7 @@
 dnl  else
     LIBRARIES="$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS"
 dnl  fi
+fi
 fi
 fi
 fi
diff -Nur orig/Frodo/Src/joystick.h Frodo/Src/joystick.h
--- orig/Frodo/Src/joystick.h	Thu Jan  1 01:00:00 1970
+++ Frodo/Src/joystick.h	Sat May 22 23:22:05 1999
@@ -0,0 +1,296 @@
+#include <asm/types.h>
+#ifndef _LINUX_JOYSTICK_H
+#define _LINUX_JOYSTICK_H
+
+/*
+ * /usr/include/linux/joystick.h  Version 1.2
+ *
+ * Copyright (C) 1996-1998 Vojtech Pavlik
+ */
+
+/*
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or 
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * 
+ * Should you need to contact me, the author, you can do so either by
+ * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
+ * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
+ */
+
+
+/*
+ * Version
+ */
+
+#define JS_VERSION		0x01020d
+
+/*
+ * Types and constants for reading from /dev/js
+ */
+
+#define JS_EVENT_BUTTON		0x01	/* button pressed/released */
+#define JS_EVENT_AXIS		0x02	/* joystick moved */
+#define JS_EVENT_INIT		0x80	/* initial state of device */
+
+struct js_event {
+	__u32 time;	/* event timestamp in miliseconds */
+	__s16 value;	/* value */
+	__u8 type;	/* event type */
+	__u8 number;	/* axis/button number */
+};
+
+/*
+ * IOCTL commands for joystick driver
+ */
+
+#define JSIOCGVERSION		_IOR('j', 0x01, __u32)			/* get driver version */
+
+#define JSIOCGAXES		_IOR('j', 0x11, __u8)			/* get number of axes */
+#define JSIOCGBUTTONS		_IOR('j', 0x12, __u8)			/* get number of buttons */
+#define JSIOCGNAME(len)		_IOC(_IOC_READ, 'j', 0x13, len)         /* get identifier string */
+
+#define JSIOCSCORR		_IOW('j', 0x21, struct js_corr)		/* set correction values */
+#define JSIOCGCORR		_IOR('j', 0x22, struct js_corr)		/* get correction values */
+
+/*
+ * Types and constants for get/set correction
+ */
+
+#define JS_CORR_NONE		0x00	/* returns raw values */
+#define JS_CORR_BROKEN		0x01	/* broken line */
+
+struct js_corr {
+	__s32 coef[8];
+	__s16 prec;
+	__u16 type;
+};
+
+/*
+ * v0.x compatibility definitions
+ */
+
+#define JS_RETURN		sizeof(struct JS_DATA_TYPE)
+#define JS_TRUE			1
+#define JS_FALSE		0
+#define JS_X_0			0x01
+#define JS_Y_0			0x02
+#define JS_X_1			0x04
+#define JS_Y_1			0x08
+#define JS_MAX			2
+
+#define JS_DEF_TIMEOUT		0x1300
+#define JS_DEF_CORR		0
+#define JS_DEF_TIMELIMIT	10L
+
+#define JS_SET_CAL		1
+#define JS_GET_CAL		2
+#define JS_SET_TIMEOUT		3
+#define JS_GET_TIMEOUT		4
+#define JS_SET_TIMELIMIT	5
+#define JS_GET_TIMELIMIT	6
+#define JS_GET_ALL		7
+#define JS_SET_ALL		8
+
+struct JS_DATA_TYPE {
+	int buttons;
+	int x;
+	int y;
+};
+
+struct JS_DATA_SAVE_TYPE {
+	int JS_TIMEOUT;
+	int BUSY;
+	long JS_EXPIRETIME;
+	long JS_TIMELIMIT;
+	struct JS_DATA_TYPE JS_SAVE;
+	struct JS_DATA_TYPE JS_CORR;
+};
+
+/*
+ * Internal definitions
+ */
+
+#ifdef __KERNEL__
+
+#define JS_BUFF_SIZE		64		/* output buffer size */
+
+
+#ifndef KERNEL_VERSION
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#endif
+
+#ifndef LINUX_VERSION_CODE
+#error "You need to use at least 2.0 Linux kernel."
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,0,0)
+#error "You need to use at least 2.0 Linux kernel."
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
+#define JS_HAS_RDTSC (current_cpu_data.x86_capability & 0x10)
+#else
+#ifdef MODULE
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,0,35)
+#define JS_HAS_RDTSC (x86_capability & 0x10)
+#else
+#define JS_HAS_RDTSC 0
+#endif
+#else
+#define JS_HAS_RDTSC (x86_capability & 0x10)
+#endif
+#define __initdata
+#define __init
+#define __cli cli
+#define __save_flags(flags) save_flags(flags)
+#define __restore_flags(flags)	restore_flags(flags)
+#define spin_lock_irqsave(x, flags) do { save_flags(flags); cli(); } while (0)
+#define spin_unlock_irqrestore(x, flags) restore_flags(flags)
+#define spin_lock_init(x) do { } while (0)
+typedef struct { int something; } spinlock_t;
+#define SPIN_LOCK_UNLOCKED { 0 }
+#define MODULE_AUTHOR(x)
+#define MODULE_PARM(x,y)
+#define MODULE_SUPPORTED_DEVICE(x)
+#define signal_pending(x) (((x)->signal) & ~((x)->blocked))
+#endif
+
+/*
+ * Parport stuff
+ */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
+#define USE_PARPORT
+#endif
+
+#ifdef USE_PARPORT
+#define JS_PAR_DATA_IN(y)	parport_read_data(y->port)
+#define JS_PAR_DATA_OUT(x,y)	parport_write_data(y->port, x)
+#define JS_PAR_STATUS(y)	parport_read_status(y->port)
+#define JS_PAR_CTRL_IN(y)	parport_read_control(y->port)
+#define JS_PAR_CTRL_OUT(x,y)	parport_write_control(y->port, x)
+#define JS_PAR_ECTRL_OUT(x,y)	parport_write_econtrol(y->port, x)
+#else
+#define JS_PAR_DATA_IN(y)	inb(y)
+#define JS_PAR_DATA_OUT(x,y)	outb(x,y)
+#define JS_PAR_STATUS(y)	inb(y+1)
+#define JS_PAR_CTRL_IN(y)	inb(y+2)
+#define JS_PAR_CTRL_OUT(x,y)	outb(x,y+2)
+#define JS_PAR_ECTRL_OUT(x,y)	outb(x,y+0x402)
+#endif
+
+#define JS_PAR_STATUS_INVERT	(0x80)
+#define JS_PAR_CTRL_INVERT	(0x04)
+
+/*
+ * Internal types
+ */
+
+struct js_dev;
+
+typedef int (*js_read_func)(void *info, int **axes, int **buttons);
+typedef unsigned int (*js_time_func)(void);
+typedef int (*js_delta_func)(unsigned int x, unsigned int y);
+typedef int (*js_ops_func)(struct js_dev *dev);
+
+struct js_data {
+	int *axes;
+	int *buttons;
+};
+
+struct js_dev {
+	struct js_dev *next;
+	struct js_list *list;
+	struct js_port *port;
+	struct wait_queue *wait;
+	struct js_data cur;
+	struct js_data new;
+	struct js_corr *corr;
+	struct js_event buff[JS_BUFF_SIZE];
+	js_ops_func open;
+	js_ops_func close;
+	int ahead;
+	int bhead;
+	int tail;
+	int num_axes;
+	int num_buttons;
+	char *name;
+	devfs_handle_t devfs_handle;
+};
+
+struct js_list {
+	struct js_list *next;
+	struct js_dev *dev;
+	int tail;
+	int startup;
+};
+
+struct js_port {
+	struct js_port *next;
+	struct js_port *prev;
+	js_read_func read;
+	struct js_dev **devs;
+	int **axes;
+	int **buttons;
+	struct js_corr **corr;
+	void *info;
+	int ndevs;
+};
+
+/*
+ * Sub-module interface
+ */
+
+extern unsigned int js_time_speed;
+extern js_time_func js_get_time;
+extern js_delta_func js_delta;
+
+extern unsigned int js_time_speed_a;
+extern js_time_func js_get_time_a;
+extern js_delta_func js_delta_a;
+
+extern struct js_port *js_register_port(struct js_port *port, void *info,
+	int devs, int infos, js_read_func read);
+extern struct js_port *js_unregister_port(struct js_port *port);
+
+extern int js_register_device(struct js_port *port, int number, int axes,
+	int buttons, char *name, js_ops_func open, js_ops_func close);
+extern void js_unregister_device(struct js_dev *dev);
+
+/*
+ * Kernel interface
+ */
+
+extern int js_init(void);
+extern int js_am_init(void);
+extern int js_an_init(void);
+extern int js_as_init(void);
+extern int js_console_init(void);
+extern int js_db9_init(void);
+extern int js_gr_init(void);
+extern int js_l4_init(void);
+extern int js_lt_init(void);
+extern int js_sw_init(void);
+extern int js_tm_init(void);
+
+extern void js_am_setup(char *str, int *ints);
+extern void js_an_setup(char *str, int *ints);
+extern void js_as_setup(char *str, int *ints);
+extern void js_console_setup(char *str, int *ints);
+extern void js_db9_setup(char *str, int *ints);
+extern void js_l4_setup(char *str, int *ints);
+
+#endif /* __KERNEL__ */
+
+#endif /* _LINUX_JOYSTICK_H */
diff -Nur orig/Frodo/Src/sysconfig.h Frodo/Src/sysconfig.h
--- orig/Frodo/Src/sysconfig.h	Thu Jan  1 01:00:00 1970
+++ Frodo/Src/sysconfig.h	Sat May 22 23:21:49 1999
@@ -0,0 +1,150 @@
+/* sysconfig.h.  Generated automatically by configure.  */
+/* Src/sysconfig.h.in.  Generated automatically from configure.in by autoheader.  */
+
+/* Define if on AIX 3.
+   System headers sometimes define this.
+   We just want to avoid a redefinition error message.  */
+#ifndef _ALL_SOURCE
+/* #undef _ALL_SOURCE */
+#endif
+
+/* Define to empty if the keyword does not work.  */
+/* #undef const */
+
+/* Define if your struct stat has st_blocks.  */
+#define HAVE_ST_BLOCKS 1
+
+/* Define if utime(file, NULL) sets file's timestamp to the present.  */
+#define HAVE_UTIME_NULL 1
+
+/* Define as __inline if that's what the C compiler calls it.  */
+/* #undef inline */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef mode_t */
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #undef off_t */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef pid_t */
+
+/* Define if you need to in order for stat and other things to work.  */
+/* #undef _POSIX_SOURCE */
+
+/* Define as the return type of signal handlers (int or void).  */
+#define RETSIGTYPE void
+
+/* Define if you have the ANSI C header files.  */
+#define STDC_HEADERS 1
+
+/* Define if you can safely include both <sys/time.h> and <time.h>.  */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define if your <sys/time.h> declares struct tm.  */
+/* #undef TM_IN_SYS_TIME */
+
+/* The number of bytes in a char.  */
+#define SIZEOF_CHAR 1
+
+/* The number of bytes in a int.  */
+#define SIZEOF_INT 4
+
+/* The number of bytes in a long.  */
+#define SIZEOF_LONG 4
+
+/* The number of bytes in a long long.  */
+#define SIZEOF_LONG_LONG 8
+
+/* The number of bytes in a short.  */
+#define SIZEOF_SHORT 2
+
+/* Define if you have the gettimeofday function.  */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define if you have the mkdir function.  */
+#define HAVE_MKDIR 1
+
+/* Define if you have the rmdir function.  */
+#define HAVE_RMDIR 1
+
+/* Define if you have the select function.  */
+#define HAVE_SELECT 1
+
+/* Define if you have the sigaction function.  */
+#define HAVE_SIGACTION 1
+
+/* Define if you have the statfs function.  */
+#define HAVE_STATFS 1
+
+/* Define if you have the strerror function.  */
+#define HAVE_STRERROR 1
+
+/* Define if you have the strstr function.  */
+#define HAVE_STRSTR 1
+
+/* Define if you have the usleep function.  */
+#define HAVE_USLEEP 1
+
+/* Define if you have the <dirent.h> header file.  */
+#define HAVE_DIRENT_H 1
+
+/* Define if you have the <fcntl.h> header file.  */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <linux/joystick.h> header file.  */
+#define HAVE_LINUX_JOYSTICK_H 1
+
+/* Define if you have the <ncurses.h> header file.  */
+#define HAVE_NCURSES_H 1
+
+/* Define if you have the <ndir.h> header file.  */
+/* #undef HAVE_NDIR_H */
+
+/* Define if you have the <string.h> header file.  */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <strings.h> header file.  */
+#define HAVE_STRINGS_H 1
+
+/* Define if you have the <sys/dir.h> header file.  */
+/* #undef HAVE_SYS_DIR_H */
+
+/* Define if you have the <sys/mount.h> header file.  */
+#define HAVE_SYS_MOUNT_H 1
+
+/* Define if you have the <sys/ndir.h> header file.  */
+/* #undef HAVE_SYS_NDIR_H */
+
+/* Define if you have the <sys/param.h> header file.  */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define if you have the <sys/select.h> header file.  */
+#define HAVE_SYS_SELECT_H 1
+
+/* Define if you have the <sys/stat.h> header file.  */
+#define HAVE_SYS_STAT_H 1
+
+/* Define if you have the <sys/statfs.h> header file.  */
+#define HAVE_SYS_STATFS_H 1
+
+/* Define if you have the <sys/statvfs.h> header file.  */
+#define HAVE_SYS_STATVFS_H 1
+
+/* Define if you have the <sys/time.h> header file.  */
+#define HAVE_SYS_TIME_H 1
+
+/* Define if you have the <sys/types.h> header file.  */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define if you have the <sys/vfs.h> header file.  */
+#define HAVE_SYS_VFS_H 1
+
+/* Define if you have the <unistd.h> header file.  */
+#define HAVE_UNISTD_H 1
+
+/* Define if you have the <utime.h> header file.  */
+#define HAVE_UTIME_H 1
+
+/* Define if you have the <values.h> header file.  */
+#define HAVE_VALUES_H 1
