--- xgalaga-2.0.34.orig/debian/postrm
+++ xgalaga-2.0.34/debian/postrm
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+
+OLDSCOREFILE=/var/games/xgalaga_scores
+
+# Remove old high score file on purge.
+if [ "$1" = "purge" ]; then
+	rm -f $OLDSCOREFILE
+fi
+
+#DEBHELPER#
--- xgalaga-2.0.34.orig/debian/menu
+++ xgalaga-2.0.34/debian/menu
@@ -0,0 +1,6 @@
+?package(xgalaga):needs="x11" section="Games/Action" title="Galaga" \
+	command="xgalaga" \
+	icon="/usr/share/pixmaps/xgalaga-icon.xpm"
+?package(xgalaga):needs="x11" section="Games/Action" title="Galaga:Hyperspace" \
+	command="xgalaga-hyperspace" \
+	icon="/usr/share/pixmaps/xgalaga-icon.xpm"
--- xgalaga-2.0.34.orig/debian/README.Debian
+++ xgalaga-2.0.34/debian/README.Debian
@@ -0,0 +1,7 @@
+The Debian xgalaga package is patched with joystick support. If you have a
+joystick and a kernel that speaks a new enough version of the joystick API
+(linux 2.2 or higher), then the joystick on /dev/js0 will be active when
+the keyboard controls are active.
+
+Some other improvements in the Debian package include full screen support
+and the xgalaga-hyperspace variant of the game.
--- xgalaga-2.0.34.orig/debian/changelog
+++ xgalaga-2.0.34/debian/changelog
@@ -0,0 +1,420 @@
+xgalaga (2.0.34-44) unstable; urgency=low
+
+  * Update menu file for new policy and de-hardcode paths.
+
+ -- Joey Hess <joeyh@debian.org>  Sun, 08 Jul 2007 16:47:29 -0400
+
+xgalaga (2.0.34-43) unstable; urgency=low
+
+  * Take config.sub and config.guess from autotools-dev.
+  * kFreeBSD porting. Closes: #415664
+  * Create a xgal.sndsrv.oss that will work on linux and, presumably, FreeBSD
+    (untested). The source file is left at xgal.sndsrv.linux.c since renaming
+    source files in a Debian diff is too ugly.
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 14 May 2007 18:29:49 -0400
+
+xgalaga (2.0.34-42) unstable; urgency=low
+
+  * Fix formatting of --help. Closes: #399985
+
+ -- Joey Hess <joeyh@debian.org>  Thu,  8 Feb 2007 18:31:16 -0500
+
+xgalaga (2.0.34-41) unstable; urgency=low
+
+  * No change upload to get buildds to rebuild it now that
+    linux-kernel-headers is fixed. Closes: #389324
+
+ -- Joey Hess <joeyh@debian.org>  Tue,  3 Oct 2006 15:34:13 -0400
+
+xgalaga (2.0.34-40) unstable; urgency=low
+
+  * Fix a fencepost error in gecos name retreival code spotted by
+    Thue Janus Kristensen. Closes: #386718
+
+ -- Joey Hess <joeyh@debian.org>  Sat,  9 Sep 2006 17:54:15 -0400
+
+xgalaga (2.0.34-39) unstable; urgency=low
+
+  * Revert last change, this was a linux-kernel-headers bug.
+
+ -- Joey Hess <joeyh@debian.org>  Thu,  7 Sep 2006 21:50:19 -0400
+
+xgalaga (2.0.34-38) unstable; urgency=low
+
+  * Include linux/types.h in linux-joystick.c to avoid a FTBFS when including
+    linux/joystick.h with the latest gcc.
+
+ -- Joey Hess <joeyh@debian.org>  Thu,  7 Sep 2006 21:35:49 -0400
+
+xgalaga (2.0.34-37) unstable; urgency=low
+
+  * Patch from Hans de Goede to make window size configurable at run time.
+    This includes fixes for the behavior in #369016 when running at
+    nonstandard window sizes, it also sets the default window size to 468x586
+    again.
+  * Finally removed the old xgal compatability symlink to xgalaga.
+
+ -- Joey Hess <joeyh@debian.org>  Wed, 31 May 2006 19:38:58 -0400
+
+xgalaga (2.0.34-36) unstable; urgency=low
+
+  * Set window size back to 400x500 which makes fullscreen not quite that but
+    avoids gameplay and display issues from changing the size. Closes: #369016
+
+ -- Joey Hess <joeyh@debian.org>  Fri, 26 May 2006 16:31:50 -0400
+
+xgalaga (2.0.34-35) unstable; urgency=low
+
+  * Patch from Hans de Goede <j.w.r.degoede@hhs.nl> of Fedora Extras to remove
+    all the build warnings.
+  * Patch from Hans de Goede to add fullscreen support. Note that full screen
+    mode is enabled by default.
+  * Update man page to document fullscreen support.
+  * Moved a lot of stuff to /usr/share.
+
+ -- Joey Hess <joeyh@debian.org>  Wed, 24 May 2006 18:13:41 -0400
+
+xgalaga (2.0.34-34) unstable; urgency=low
+
+  * Fix FTBFS due to xorg transition causing $x_libraries not to be set.
+    Closes: #365160
+
+ -- Joey Hess <joeyh@debian.org>  Fri, 28 Apr 2006 13:42:47 -0400
+
+xgalaga (2.0.34-33) unstable; urgency=low
+
+  * Minor improvement to man page. Closes: #349647 
+
+ -- Joey Hess <joeyh@debian.org>  Tue, 24 Jan 2006 13:03:39 -0500
+
+xgalaga (2.0.34-32) unstable; urgency=low
+
+  * Debhelper v5.
+  * Move away from xlibs-dev.
+  * Current policy.
+
+ -- Joey Hess <joeyh@debian.org>  Wed, 30 Nov 2005 20:35:07 -0500
+
+xgalaga (2.0.34-31) unstable; urgency=low
+
+  * Build with -O2 not -O3 so it's debuggable.
+  * Add NO_GLOBAL_SCORES define that rips out all support for global score
+    file. The old global score file is not deleted until xgalaga is purged,
+    but it will not be used anymore.
+  * Remove insecure sgid bit. Closes: #319686
+
+ -- Joey Hess <joeyh@debian.org>  Sat, 23 Jul 2005 20:18:10 -0400
+
+xgalaga (2.0.34-30) unstable; urgency=low
+
+  * Patch from Andreas Jochens to support building with gcc 4.
+    Closes: #300374
+
+ -- Joey Hess <joeyh@debian.org>  Sat, 19 Mar 2005 11:47:18 -0500
+
+xgalaga (2.0.34-29) unstable; urgency=low
+
+  * Add support for building a xgalaga-hyperspace binary,
+    based on a patch by Paul Telford. Closes: #280975
+
+ -- Joey Hess <joeyh@debian.org>  Fri, 12 Nov 2004 18:02:02 -0500
+
+xgalaga (2.0.34-28) unstable; urgency=low
+
+  * Fix non-POSIX chown call in postinst. Closes: #236524
+  * And one in the rules file.
+  * Quote all strings in menu file.
+
+ -- Joey Hess <joeyh@debian.org>  Sat,  6 Mar 2004 12:44:45 -0900
+
+xgalaga (2.0.34-27) unstable; urgency=low
+
+  * Make the sound server deal with any buffer size the sound card returns.
+    Thanks to Chris Capoccia for helping to track this down. See #196979,
+    which is not all fixed, since larger buffer sizes make xgalagas sound
+    effects lose sync.
+
+ -- Joey Hess <joeyh@debian.org>  Sun, 15 Jun 2003 19:09:43 -0400
+
+xgalaga (2.0.34-26) unstable; urgency=low
+
+  * Joystick patch fix for when two buttons are pressed and one released.
+
+ -- Joey Hess <joeyh@debian.org>  Fri,  6 Jun 2003 16:24:14 -0400
+
+xgalaga (2.0.34-25) unstable; urgency=low
+
+  * Joystick support patch from Wouter Verhelst <wouter@debian.org>, also
+    sent upstream. Closes: #190241
+  * Add README.Debian with info about the joystick patch. Also update man
+    page.
+  * Fixed icon to use Debian icon color map.
+
+ -- Joey Hess <joeyh@debian.org>  Thu, 24 Apr 2003 12:28:24 -0400
+
+xgalaga (2.0.34-24) unstable; urgency=low
+
+  * Updated config.sub and config.guess so they know about
+    parisc64-unknown-linux-gnu host system type. Closes: #174786
+
+ -- Joey Hess <joeyh@debian.org>  Mon,  3 Feb 2003 14:06:53 -0500
+
+xgalaga (2.0.34-23) unstable; urgency=medium
+
+  * More paranioa: When writing the ~/.xgalscores, first drop the games gid
+    so the program opens the file with only the perms of the user who ran it,
+    to protect against numerous attacks (like setting HOME, or using a 
+    symlink..) that let the caller trick xgalaga into overwriting any file
+    writable by group games.
+
+ -- Joey Hess <joeyh@debian.org>  Sun, 29 Dec 2002 21:25:35 -0500
+
+xgalaga (2.0.34-22) unstable; urgency=low
+
+  * Passing xgalaga a huge HOME variable could crash it. Patch from Steve Kemp
+    to make it use snprintf. Closes: #174624
+
+ -- Joey Hess <joeyh@debian.org>  Sun, 29 Dec 2002 12:29:56 -0500
+
+xgalaga (2.0.34-21) unstable; urgency=low
+
+  * If a huge initial level was given, read_level() would recurse backwards
+    looking for a real level. After a few hundred recusions, it would overflow
+    the stack of course. I don't think this is exploitable, but I have changed
+    it to use a loop looking backward for the level so there is no stack
+    overflow. It will still take a _very_ long time to start from level
+    11111111111 or so. Closes: #154291
+
+ -- Joey Hess <joeyh@debian.org>  Thu, 25 Jul 2002 17:50:53 -0400
+
+xgalaga (2.0.34-20) unstable; urgency=low
+
+  * Debhelper v4.
+  * Fixed man page section.
+
+ -- Joey Hess <joeyh@debian.org>  Thu, 13 Jun 2002 17:25:54 -0400
+
+xgalaga (2.0.34-19) unstable; urgency=low
+
+  * make k a signed char in xgal.sndsrv.linux.c; chars do not default to
+    signed on all arches.
+
+ -- Joey Hess <joeyh@debian.org>  Fri, 28 Dec 2001 23:07:07 -0500
+
+xgalaga (2.0.34-18) unstable; urgency=low
+
+  * Makefile.in: if there is no sound server, don't try to install one.
+    For the Hurd. Closes: #107995
+
+ -- Joey Hess <joeyh@debian.org>  Wed,  8 Aug 2001 15:28:25 -0400
+
+xgalaga (2.0.34-17) unstable; urgency=low
+
+  * printf is a macro in gcc 3.0, which broke an internally #ifdef'd printf
+    (sigh). Patched.
+  * Updated config.* files for PARISC, Closes: #97379
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 14 May 2001 15:36:05 -0400
+
+xgalaga (2.0.34-16) unstable; urgency=low
+
+  * Fixed three bugs relating to pausing the program, patch from
+    Rune Broberg <mihtjel@myplace.dk>, Closes: #89254
+    Also sent upstream.
+  * (This upload slightly delayed by accident.)
+
+ -- Joey Hess <joeyh@debian.org>  Sun, 11 Mar 2001 15:21:18 -0800
+
+xgalaga (2.0.34-15) unstable; urgency=low
+
+  * No changes, Closes: #92689 (which I long ago fixed in CVS, but didn't
+    consider RC..)
+
+ -- Joey Hess <joeyh@debian.org>  Tue,  3 Apr 2001 13:30:03 -0700
+
+xgalaga (2.0.34-14) unstable; urgency=low
+
+  * statoverride transition
+
+ -- Joey Hess <joeyh@debian.org>  Wed, 10 Jan 2001 15:09:20 -0800
+
+xgalaga (2.0.34-13) unstable; urgency=low
+
+  * Added a menu icon, Closes: #75767
+  * The icon is by Robert Cleaver Ancell <neutronium@clear.net.nz>, and is GPL.
+
+ -- Joey Hess <joeyh@debian.org>  Fri,  5 Jan 2001 17:38:18 -0800
+
+xgalaga (2.0.34-12) unstable; urgency=low
+
+  * Made -nosound mode not try to open the sound device. Closes: #78734
+    Fix sent upstream.
+
+ -- Joey Hess <joeyh@debian.org>  Thu,  4 Jan 2001 16:08:40 -0800
+
+xgalaga (2.0.34-11) unstable; urgency=low
+
+  * Updated to fhs /var/games.
+  * Remove score file on purge.
+
+ -- Joey Hess <joeyh@debian.org>  Sun,  5 Nov 2000 23:05:39 -0800
+
+xgalaga (2.0.34-10) unstable; urgency=low
+
+  * Build deps.
+
+ -- Joey Hess <joeyh@debian.org>  Sat,  4 Dec 1999 18:24:58 -0800
+
+xgalaga (2.0.34-9) unstable; urgency=low
+
+  * README, debian/copyright, title.c: Home page change, Closes: #51569
+  * debian/changelog, debian/control: removed 'master'
+  * libsprite/data.c, libsprite/data.h, libsprite/defs.h, libsprite/init.c:
+    Patch from Kevin Ryde <user42@zip.com.au> to fix the numlock problem.
+    Closes: #50903
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 29 Nov 1999 15:03:32 -0800
+
+xgalaga (2.0.34-8) unstable; urgency=low
+
+  * Patch from Kevin Ryde <user42@zip.com.au>, to improve smoothness and
+    speed in xgalaga, especially on slower video cards.
+
+ -- Joey Hess <joeyh@debian.org>  Tue,  5 Oct 1999 12:34:03 -0700
+
+xgalaga (2.0.34-7) unstable; urgency=low
+
+  * FHS
+
+ -- Joey Hess <joeyh@debian.org>  Mon,  6 Sep 1999 18:41:48 -0700
+
+xgalaga (2.0.34-6) unstable; urgency=low
+
+  * Modified the sound server to just exit if there is no sound support.
+    xgalaga seems to handle this ok now, without crashing as it used to. The
+    sound server was sleeping and blocking the SIGTERM signal that was supposed
+    to kill it, resulting in it not quitting when the game quit. (#37165)
+
+ -- Joey Hess <joeyh@debian.org>  Tue,  4 May 1999 16:26:32 -0700
+
+xgalaga (2.0.34-5) unstable; urgency=low
+
+  * Actually xgalaga doesn't accept -f at all so removed it from man page.
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 28 Dec 1998 19:42:18 -0800
+
+xgalaga (2.0.34-4) unstable; urgency=low
+
+  * xgal.6x: no they arn't fishes, they are enemy spaceships. (#31203)
+
+ -- Joey Hess <joeyh@debian.org>  Sun, 27 Dec 1998 23:20:57 -0500
+
+xgalaga (2.0.34-3) unstable; urgency=low
+
+  * glibc 2.1 strdup fix. (#29542).
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 16 Nov 1998 12:12:07 -0800
+
+xgalaga (2.0.34-2) unstable; urgency=low
+
+  * Rebuilt with latest debhelper to change how sgid binary is registered.
+
+ -- Joey Hess <joeyh@debian.org>  Tue, 27 Oct 1998 22:29:42 -0800
+
+xgalaga (2.0.34-1) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 11 May 1998 08:16:08 -0700
+
+xgalaga (2.0-1) unstable; urgency=low
+
+  * New upstream release.
+    - fixes bug #11296, now works on systems w/o sound support.
+  * Covered by the GPL now, it is now free!
+
+ -- Joey Hess <joeyh@debian.org>  Thu, 30 Apr 1998 00:32:39 -0700
+
+xgalaga (1.6c-11) unstable; urgency=low
+
+  * Moved xgal.sndsrv.linux to /usr/lib/games/xgalaga/, so I don't need to
+    write a man page for it.
+  * Moved xgalaga to /usr/games, and it's man page to /usr/man/man6.
+
+ -- Joey Hess <joeyh@debian.org>  Sat, 21 Feb 1998 23:13:30 -0800
+
+xgalaga (1.6c-10) unstable; urgency=low
+
+  * Rebuilt with debhelper 0.60 to fix mode 444 files.
+  * Updated standards-version.
+
+ -- Joey Hess <joeyh@debian.org>  Mon,  9 Feb 1998 13:08:56 -0800
+
+xgalaga (1.6c-9) unstable; urgency=low
+
+  * Use debhelper.
+
+ -- Joey Hess <joeyh@debian.org>  Sat,  7 Feb 1998 20:26:30 -0800
+
+xgalaga (1.6c-8) unstable; urgency=low
+
+  * Rebuilt to use xpm4g (#12942).
+
+ -- Joey Hess <joeyh@debian.org>  Sun, 14 Sep 1997 20:12:17 -0400
+
+xgalaga (1.6c-7) unstable; urgency=low
+
+  * New maintainer.
+  * Changed it to use my generic debian/rules file.
+  * Changed the description.
+  * Updated url to home page in copyright file, and trimmed out some other
+    non-copyright info from that file (same info was duplicated in the 
+    README). Added libsprite copyright info. Updated author's mailing
+    address.
+  * Got rid of shlibs.local.
+  * Added a menu file.
+
+ -- Joey Hess <joeyh@debian.org>  Tue,  9 Sep 1997 15:31:17 -0400
+
+xgalaga (1.6c-6) non-free; urgency=low
+
+  * Rebuilt with libc6.
+  * Orphaned the package.
+  * Cosmetic change (fix bug #9675).
+
+ -- Vincent Renardias <vincent@waw.com>  Fri, 9 May 1997 14:41:58 +0200
+
+xgalaga (1.6c-5) non-free; urgency=low
+
+  * Fixed problem with soundfiles (Bug #6991).
+  * Removed empty directory /var/lib/games (Bug #6992).
+  * Changed some src code to get rid of compilation warnings.
+
+ -- Vincent Renardias <vincent@waw.com>  Sat, 1 Feb 1997 18:01:05 +0100
+
+xgalaga (1.6c-4) non-free; urgency=low
+
+  * Wrote manpage (Corrects Bug #5593)
+
+ -- Vincent Renardias <vincent@waw.com>  Tue, 17 Dec 1996 23:19:13 +0100
+
+xgalaga (1.6c-3) non-free; urgency=low
+
+  * Changed location and mode of scorefile (Bug #5876)
+
+ -- Vincent Renardias <vincent@waw.com>  Tue, 10 Dec 1996 23:33:33 +0100
+
+xgalaga (1.6c-2) non-free; urgency=low
+
+  * Maintainer changed
+  * No man page: added link to undocumented.7
+  * Tuned compile options
+
+ -- Vincent Renardias <vincent@waw.com>  Sat, 19 Oct 1996 04:49:33 +0200
+
+xgalaga (1.6c-1) non-free; urgency=low
+
+  * Initial Release
+
+ -- Christoph Lameter <clameter@waterf.org>  Thu, 01 Sep 1996 15:37:25 +0100
--- xgalaga-2.0.34.orig/debian/compat
+++ xgalaga-2.0.34/debian/compat
@@ -0,0 +1 @@
+4
--- xgalaga-2.0.34.orig/debian/control
+++ xgalaga-2.0.34/debian/control
@@ -0,0 +1,16 @@
+Source: xgalaga
+Section: games
+Priority: optional
+Build-Depends: debhelper (>= 5), libx11-dev, libxmu-dev, libxpm-dev, x-dev, dpkg-dev (>= 1.9.0), libxxf86vm-dev, libxxf86dga-dev, autotools-dev
+Maintainer: Joey Hess <joeyh@debian.org>
+Standards-Version: 3.7.2
+XS-Vcs-Svn: svn://svn.kitenet.net/joey/trunk/src/packages/xgalaga
+
+Package: xgalaga
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Conflicts: suidmanager (<< 0.50)
+Description: X11 version of the famous Galaga game
+ A clone of the classic game Galaga for the X Window System. 
+ Xgalaga is a space-invader like game with additional features to produce
+ a more interesting game.
--- xgalaga-2.0.34.orig/debian/copyright
+++ xgalaga-2.0.34/debian/copyright
@@ -0,0 +1,21 @@
+This is a Debian prepackaged version of the xgalaga video game.
+
+The source to this package can be found on the xgalaga home page, 
+http://rumsey.org/xgal.html, or at ftp://ftp.netcom.com/pub/og/ogre/games/
+
+Xgalaga is Copyright (c) 1995 Joe Rumsey <mrogre@mediaone.net>
+
+Xgalaga is licensed under the GNU Public License GPL. On Debian systems the
+complete text of the GPL is in /usr/share/common-licenses/GPL
+ 
+Xgalaga contains the libsprite library, with the following copyright:
+  
+/*
+        Copyright 1989          Kevin P. Smith
+                                Scott Silvey
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies.
+*/
--- xgalaga-2.0.34.orig/debian/rules
+++ xgalaga-2.0.34/debian/rules
@@ -0,0 +1,57 @@
+#!/usr/bin/make -f
+
+export CFLAGS=-O2 -g -DXF86VIDMODE
+export LDFLAGS=-lXxf86vm
+
+build: build-stamp
+build-stamp:
+	dh_testdir
+	ln -sf /usr/share/misc/config.sub
+	ln -sf /usr/share/misc/config.guess
+	./configure \
+		--prefix=/usr/share/games/xgalaga \
+		--exec-prefix=/usr/games
+	$(MAKE)
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp
+	-$(MAKE) -i distclean
+	dh_clean xgal.sndsrv.oss config.k.bak config.sub config.guess
+
+binary-indep: build
+
+binary-arch: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs var/games usr/lib/games/xgalaga usr/games usr/share/man/man6
+	$(MAKE) DESTDIR=`pwd`/debian/xgalaga install
+	install -m0644 xgal.6x debian/xgalaga/usr/share/man/man6/xgalaga.6x
+	# move the sound-server binary out of usr/share
+	mv debian/xgalaga/usr/share/games/xgalaga/xgal.sndsrv.oss \
+		debian/xgalaga/usr/lib/games/xgalaga
+	dh_link usr/lib/games/xgalaga/xgal.sndsrv.oss \
+		usr/share/games/xgalaga/xgal.sndsrv.oss
+	dh_install xgalaga-icon.xpm usr/share/pixmaps/
+	dh_installman
+	dh_link usr/share/man/man6/xgalaga.6x usr/share/man/man6/xgalaga-hyperspace.6x
+	dh_installdocs README* libsprite/README.libsprite
+	dh_installexamples
+	dh_installmenu
+	dh_installchangelogs CHANGES
+	dh_strip
+	dh_compress
+	chmod 644 debian/xgalaga/usr/share/games/xgalaga/levels/* \
+		debian/xgalaga/usr/share/games/xgalaga/sounds/*
+	dh_fixperms
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary
--- xgalaga-2.0.34.orig/libsprite/Wlib.h
+++ xgalaga-2.0.34/libsprite/Wlib.h
@@ -91,6 +91,22 @@
 
 extern int autoPoint, W_KeyDepth, animPointers, useWorkbench;
 extern unsigned long w_socket;
+
+/* For XF86VIDMODE Support */
+#ifdef XF86VIDMODE
+#include <X11/extensions/xf86dga.h>
+#include <X11/extensions/xf86vmode.h>   
+
+struct xf86vidmode_data {
+  int vidmode_available;
+  XF86VidModeModeInfo orig_mode;
+  int orig_viewport_x;
+  int orig_viewport_y;
+};
+
+extern struct xf86vidmode_data XF86VidModeData;
+#endif
+
 #endif	/* AMIGA */
 
 #if 0
--- xgalaga-2.0.34.orig/libsprite/Wproto.h
+++ xgalaga-2.0.34/libsprite/Wproto.h
@@ -63,6 +63,7 @@
 W_Window W_MakeTextWindow(char *name, int x, int y, int width, int height, W_Window parent, char *cursname, int border);
 W_Window W_MakeScrollingWindow(char *name, int x, int y, int width, int height, W_Window parent, char *cursname, int border);
 void W_SetIconWindow(W_Window win, W_Window icon);
+void W_ToggleFullscreen(W_Window win);
 /* point.c */
 void W_DrawPoint(W_Window window, int x, int y, W_Color color);
 void FlushPointCache(Window win, int color);
--- xgalaga-2.0.34.orig/libsprite/data.c
+++ xgalaga-2.0.34/libsprite/data.c
@@ -61,7 +61,7 @@
 /* GC used for drawing the borders [BDyess] */
 GC borderGC;
 int     controlkey = 0;
-#define	BillsScrewyAltMask	(Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
+unsigned BillsScrewyAltMask = Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask;
 int     altkey = 0;
 int     W_FastClear = 0;
 #ifdef CONTINUOUS_MOUSE
@@ -79,8 +79,9 @@
 W_Color W_White = WHITE, W_Black = BLACK, W_Red = RED, W_Green = GREEN;
 W_Color W_Yellow = YELLOW, W_Cyan = CYAN, W_Grey = LIGHT_GREY, W_DarkGrey = DARK_GREY;
 int     W_Textwidth, W_Textheight, W_BigTextwidth, W_BigTextheight;
+#ifndef strdup
 char   *strdup();
-
+#endif
 int     W_in_message = 0;	/* jfy -- for Jerry's warp message hack */
 
 #ifdef RJC
@@ -147,7 +148,7 @@
 
 int forceMono = 0;
 
-int xpm = 1, useOR = 1;
+int xpm = 1, useOR = 1, useClipMask = 1;
 
 int backColor;
 
@@ -157,3 +158,6 @@
 
 int useBuffered = 1;
 
+#ifdef XF86VIDMODE
+struct xf86vidmode_data XF86VidModeData = { 1, { 0 }, 0, 0 };
+#endif
--- xgalaga-2.0.34.orig/libsprite/data.h
+++ xgalaga-2.0.34/libsprite/data.h
@@ -20,6 +20,7 @@
 
 #include "Wlib.h"
 #include "defs.h"
+#include "struct.h"
 
 extern int	nplanes;
 extern int	xpmORplanes ;
@@ -80,7 +81,7 @@
 extern unsigned char solid[];
 
 extern int forceMono;
-extern int xpm, useOR;
+extern int xpm, useOR, useClipMask;
 extern int backColor;
 
 extern char *imagedir;
@@ -88,4 +89,6 @@
 
 extern int useBuffered;
 
+extern unsigned BillsScrewyAltMask;
+
 #endif /* _data_h_ */
--- xgalaga-2.0.34.orig/libsprite/defs.h
+++ xgalaga-2.0.34/libsprite/defs.h
@@ -106,7 +106,4 @@
 }
 #endif		/* ABORT_ON_ERROR */
 
-#define	BillsScrewyAltMask	(Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
-
-
 #endif /* _defs_h_ */
--- xgalaga-2.0.34.orig/libsprite/image.c
+++ xgalaga-2.0.34/libsprite/image.c
@@ -210,7 +210,7 @@
     if(image->compiled_in) {
       if(image->xbmdata) {
 	image->clipmask = XCreateBitmapFromData(W_Display, W_Root, 
-	                  image->xbmdata, image->width, image->height);
+	                  (char *)image->xbmdata, image->width, image->height);
         ErrorStatus = BitmapSuccess;
       } else {
         ErrorStatus = !BitmapSuccess;
@@ -402,18 +402,22 @@
   width = image->width;
   if(xpm && !useOR) {
     if(image->xpm) {
-      XSetClipOrigin(W_Display, colortable[color].contexts[BITMASKGC], x,
-		     (int)(y - (height * frame)));
-      XSetClipMask(W_Display, colortable[color].contexts[BITMASKGC],
-		   image->clipmask);
+      if (useClipMask) {
+        XSetClipOrigin(W_Display, colortable[color].contexts[BITMASKGC], x,
+		       (int)(y - (height * frame)));
+        XSetClipMask(W_Display, colortable[color].contexts[BITMASKGC],
+		     image->clipmask);
+      }
       XCopyArea(W_Display, image->pixmap, W_Void2Window(window)->drawable,
 	 colortable[color].contexts[BITMASKGC], 0,
 	 (int)(height * frame), width, height, x, y);
     } else {
-      XSetClipOrigin(W_Display, colortable[color].contexts[BITMASKGC], x, 
-		     (int)(y - (height * frame)));
-      XSetClipMask(W_Display, colortable[color].contexts[BITMASKGC], 
-		   image->clipmask);
+      if (useClipMask) {
+        XSetClipOrigin(W_Display, colortable[color].contexts[BITMASKGC], x, 
+		       (int)(y - (height * frame)));
+        XSetClipMask(W_Display, colortable[color].contexts[BITMASKGC], 
+		     image->clipmask);
+      }
       XCopyPlane(W_Display, image->pixmap, W_Void2Window(window)->drawable,
 	   colortable[color].contexts[BITMASKGC], 0, 
 	   (int)(height * frame), 
--- xgalaga-2.0.34.orig/libsprite/init.c
+++ xgalaga-2.0.34/libsprite/init.c
@@ -326,6 +326,61 @@
     XSetForeground(W_Display, maskGC, 0);
 }
 
+/* Any of Mod1 through Mod5 that are generated by XK_Num_Lock or
+ * XK_Scroll_Lock are excluded from BillsScrewyAltMask.
+ */
+static void
+GetAltMask()
+{
+    XModifierKeymap *m;
+    int     i, j;
+    KeySym  k;
+
+    m = XGetModifierMapping(W_Display);
+    if (m == NULL) {
+        printf("Not enough memory\n");
+        exit(1);
+    }
+
+    for (i = 3; i < 8; i++) {
+        for (j = 0; j < m->max_keypermod; j++) {
+            k = XKeycodeToKeysym(W_Display,
+                m->modifiermap [i*m->max_keypermod + j], 0);
+            if (k == XK_Num_Lock || k == XK_Scroll_Lock) {
+                BillsScrewyAltMask &= ~(1 << i);
+                break;
+            }
+        }
+    }
+
+    XFreeModifiermap(m);
+}
+
+#ifdef XF86VIDMODE
+static void
+xf86_vidmode_init ( void )
+{
+  int i,j;
+  XF86VidModeModeLine *l = (XF86VidModeModeLine *)((char *)
+    &XF86VidModeData.orig_mode + sizeof XF86VidModeData.orig_mode.dotclock);
+  
+  if (!XF86VidModeQueryVersion(W_Display, &i, &j))
+    XF86VidModeData.vidmode_available = 0;
+  else if (!XF86VidModeQueryExtension(W_Display, &i, &j))
+    XF86VidModeData.vidmode_available = 0;
+  else if (!XF86VidModeGetModeLine(W_Display, W_Screen,
+            (int *)&XF86VidModeData.orig_mode.dotclock, l))
+    XF86VidModeData.vidmode_available = 0;
+  else if (!XF86VidModeGetViewPort(W_Display, W_Screen,
+            &XF86VidModeData.orig_viewport_x,
+            &XF86VidModeData.orig_viewport_y))
+    XF86VidModeData.vidmode_available = 0;
+  
+  if (!XF86VidModeData.vidmode_available)
+    fprintf(stderr, "Warning: XF86VidMode not available\n");
+}
+#endif
+
 void
 W_Initialize(str)
     char   *str;
@@ -362,7 +417,12 @@
 */
     GetFonts();
     GetColors();
+    GetAltMask();
 
     backColor = W_Black;
+    
+#ifdef XF86VIDMODE
+    xf86_vidmode_init();
+#endif
 }
 
--- xgalaga-2.0.34.orig/libsprite/makewindow.c
+++ xgalaga-2.0.34/libsprite/makewindow.c
@@ -4,20 +4,20 @@
 #define tiny_height 3
 #define tiny_x_hot 1
 #define tiny_y_hot 1
-static unsigned char tiny_bits[] = {
+static char tiny_bits[] = {
   0x05, 0x02, 0x05, };
-static unsigned char tinymask_bits[] = {
+static char tinymask_bits[] = {
   0x05, 0x02, 0x05, };
 
 #define cross_width 16
 #define cross_height 16
 #define cross_x_hot 7
 #define cross_y_hot 7
-static unsigned char cross_bits[] = {
+static char cross_bits[] = {
     0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xc0, 0x01, 0x80, 0x00,
     0x10, 0x04, 0x3f, 0x7e, 0x10, 0x04, 0x80, 0x00, 0xc0, 0x01, 0x80, 0x00,
 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00};
-static unsigned char crossmask_bits[] = {
+static char crossmask_bits[] = {
     0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xd0, 0x05,
     0xbf, 0x7e, 0x7f, 0x7f, 0xbf, 0x7e, 0xd0, 0x05, 0xe0, 0x03, 0xc0, 0x01,
 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
@@ -236,6 +236,10 @@
     neww->type = type;
     neww->mapped = 0;
     neww->insensitive = 0;
+#ifdef XF86VIDMODE
+    neww->wm_window = NULL;
+    neww->fs_window = None;
+#endif
     addToHash(neww);
     return (neww);
 }
@@ -454,6 +458,22 @@
     int     border;
     W_Color color;
 {
+    /* When creating a toplevel window create a real toplevel
+       window and a child window of the same dimensions. Then when switching
+       fullscreen we can create a fullscreen window and reparent the child
+       window to the fullscreen window and back again when switching to
+       windowed mode again. */
+    if(parent == NULL)
+    {
+      W_Window wm_window = w_MakeWindow(name, x, y, width, height, 0,
+                              cursname, border, color, WIN_GRAPH);
+      struct window *child_window = (struct window *)w_MakeWindow(
+                                      name, x, y, width, height,
+                                      wm_window, cursname, border, color,
+                                      WIN_GRAPH);
+      child_window->wm_window = wm_window;
+      return (W_Window)child_window;
+    }
     return w_MakeWindow(name, x, y, width, height, parent,
 			cursname, border, color, WIN_GRAPH);
 }
@@ -498,5 +518,197 @@
     XSetWMHints(W_Display, W_Void2Window(win)->window, &hints);
 }
 
+#ifdef XF86VIDMODE
+/* qsort comparison function for sorting the modes */
+static int cmpmodes(const void *va, const void *vb)
+{
+    const XF86VidModeModeInfo *a = *(const XF86VidModeModeInfo **)va;
+    const XF86VidModeModeInfo *b = *(const XF86VidModeModeInfo **)vb;
+    if ( a->hdisplay == b->hdisplay )
+        return b->vdisplay - a->vdisplay;  
+    else
+        return b->hdisplay - a->hdisplay;
+}
+#endif
 
+void W_ToggleFullscreen(_win)
+    W_Window _win;
+{
+#ifdef XF86VIDMODE      
+  int i;
+  XF86VidModeModeLine mode;
+  XF86VidModeModeInfo **modes;
+  int mode_count;
+#endif
+  struct window *win = (struct window *)_win;
+  static int mouse_grabbed = 0;
+  static int keyboard_grabbed = 0;
 
+  /* Check we get a nested toplevel WIN_GRAPH window passed */
+  if (win->wm_window == NULL)
+    return;
+  
+  /* If there is no fullscreen window enter fullscreen mode, otherwise exit
+     fullscreen mode */
+  if (win->fs_window == None)
+  {
+    XEvent event;
+    XSetWindowAttributes setattr;
+    /* local width and height vars used for fullscreen window size and for
+       storing the video_mode size which is then used to center the window */
+    int fs_width  = DisplayWidth(W_Display, W_Screen);
+    int fs_height = DisplayHeight(W_Display, W_Screen);
+
+    /* Create the fullscreen window */
+    setattr.override_redirect = True;
+    setattr.background_pixel = XBlackPixel(W_Display, W_Screen);
+    setattr.border_pixel = XBlackPixel(W_Display, W_Screen);
+    setattr.event_mask = StructureNotifyMask;
+    setattr.colormap = W_Colormap;
+    win->fs_window = XCreateWindow(W_Display, W_Root,
+                                 0, 0, fs_width, fs_height, 0,
+                                 CopyFromParent, InputOutput,
+                                 CopyFromParent, CWOverrideRedirect |
+                                 CWBackPixel | CWColormap | CWBorderPixel |
+                                 CWEventMask, &setattr);
+
+    /* Map the fullscreen window */
+    XMapRaised(W_Display, win->fs_window);
+    /* wait until we are mapped. (shamelessly borrowed from SDL) */
+    do {
+      XMaskEvent(W_Display, StructureNotifyMask, &event); 
+    } while ( (event.type != MapNotify) || 
+              (event.xmap.event != win->fs_window) );
+    /* Make sure we got to the top of the window stack */
+    XRaiseWindow(W_Display, win->fs_window);
+    
+    /* Reparent the real window */
+    XReparentWindow(W_Display, win->window, win->fs_window, 0, 0);
+
+    /* Grab the keyboard and mouse.  */
+    if (XGrabKeyboard(W_Display, win->window, False, GrabModeAsync,
+          GrabModeAsync, CurrentTime) != GrabSuccess)
+      fprintf(stderr, "Warning can not grab keyboard\n");
+    else
+      keyboard_grabbed = 1;
+    
+    if (XGrabPointer(W_Display, win->window, False,
+          PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
+          GrabModeAsync, GrabModeAsync, win->window, None,
+          CurrentTime) != GrabSuccess)
+      fprintf(stderr, "Warning can not grab mouse\n");
+    else
+      mouse_grabbed = 1;
+
+#ifdef XF86VIDMODE      
+    /* Try to switch video mode. This must be done after the pointer is
+       grabbed, because otherwise it can be outside the window negating the
+       XF86VidModeSetViewPort. */
+    if (XF86VidModeGetModeLine(W_Display, W_Screen, &i, &mode))
+    {
+      fs_width  = mode.hdisplay;
+      fs_height = mode.vdisplay;
+    }
+    else   /* If we can't get the currentmode force setting of a new mode. */
+      mode.hdisplay = 0;
+      
+    /* Get list of modelines.  */
+    if (!XF86VidModeGetAllModeLines(W_Display, W_Screen, &mode_count, &modes))
+            mode_count = 0;
+       
+    /* Search for an exact matching video mode.  */
+    for (i = 0; i < mode_count; i++) {
+       if ((modes[i]->hdisplay == win->width) && 
+           (modes[i]->vdisplay == win->height))
+         break;
+    }
+
+    /* Search for a non exact match (smallest bigger res). */
+    if (i == mode_count) {
+      int best_width = 0, best_height = 0;
+      qsort(modes, mode_count, sizeof(void *), cmpmodes);
+      for (i = mode_count-1; i > 0; i--) {
+         if ( ! best_width ) {
+            if ( (modes[i]->hdisplay >= win->width) &&
+                 (modes[i]->vdisplay >= win->height) ) {
+               best_width = modes[i]->hdisplay;
+               best_height = modes[i]->vdisplay;
+            }
+         } else {
+            if ( (modes[i]->hdisplay != best_width) ||
+                 (modes[i]->vdisplay != best_height) ) {
+               i++;
+               break;
+            }
+         }
+      }
+    }
+        
+    /* Switch video mode.  */
+    if (((modes[i]->hdisplay != mode.hdisplay) ||
+         (modes[i]->vdisplay != mode.vdisplay)) &&
+        XF86VidModeSwitchToMode(W_Display, W_Screen, modes[i]))
+    {
+      fs_width  = modes[i]->hdisplay;
+      fs_height = modes[i]->vdisplay;
+    }
+     
+    /* Lock mode switching.  */
+    XF86VidModeLockModeSwitch(W_Display, W_Screen, True);
+           
+    /* Set viewport. */
+    XF86VidModeSetViewPort(W_Display, W_Screen, 0, 0);
+#endif
+    
+    /* Center the window (if nescesarry) */
+    if ((fs_width != win->width) || (fs_height != win->height))
+      XMoveWindow(W_Display, win->window, (fs_width - win->width) / 2,
+                   (fs_height - win->height) / 2);
+                   
+    /* And last blank the cursor */
+    W_BlankCursor(_win);
+  }
+  else
+  {
+    struct window *wm_window = (struct window *)win->wm_window;
+    
+    if (mouse_grabbed) {
+      XUngrabPointer(W_Display, CurrentTime);
+      mouse_grabbed = 0;
+    }
+    if (keyboard_grabbed) {
+      XUngrabKeyboard(W_Display, CurrentTime);
+      keyboard_grabbed = 0;
+    }
+
+#ifdef XF86VIDMODE
+    /* Unlock mode switching.  */
+    XF86VidModeLockModeSwitch(W_Display, W_Screen, False);
+
+    if (!XF86VidModeGetModeLine(W_Display, W_Screen, &i, &mode) ||
+        (mode.hdisplay != XF86VidModeData.orig_mode.hdisplay) ||
+        (mode.vdisplay != XF86VidModeData.orig_mode.vdisplay))
+    {
+      if (!XF86VidModeSwitchToMode(W_Display, W_Screen,
+            &XF86VidModeData.orig_mode))
+        fprintf(stderr, "XF86VidMode couldnot restore original resolution\n");
+    }
+    if (XF86VidModeData.orig_viewport_x || XF86VidModeData.orig_viewport_y)
+    {
+      if (!XF86VidModeSetViewPort(W_Display, W_Screen,
+            XF86VidModeData.orig_viewport_x,
+            XF86VidModeData.orig_viewport_y))
+        fprintf(stderr, "XF86VidMode couldnot restore original viewport\n");
+    }
+    XSync(W_Display, False);
+#endif
+    /* Reparent the real window! */
+    XReparentWindow(W_Display, win->window, wm_window->window, 0, 0);
+    XUnmapWindow(W_Display, win->fs_window);
+    XDestroyWindow(W_Display, win->fs_window);
+    win->fs_window = None;
+
+    /* And last unblank the cursor */
+    W_RevertCursor(_win);
+  }
+}
--- xgalaga-2.0.34.orig/libsprite/line.c
+++ xgalaga-2.0.34/libsprite/line.c
@@ -37,7 +37,7 @@
     W_Window window;
 {
     Window  win = W_Void2Window(window)->drawable;
-    register i;
+    int i;
     for (i = 0; i < NCOLORS; i++) {
 	if (_lcache_index[i])
 	    FlushLineCache(win, i);
--- xgalaga-2.0.34.orig/libsprite/mapwindow.c
+++ xgalaga-2.0.34/libsprite/mapwindow.c
@@ -13,6 +13,8 @@
     if(win->type != WIN_BORDER && win->borderwin) {
       W_MapWindow(win->borderwin);
     }
+    if (win->wm_window)
+      W_MapWindow(win->wm_window);
     if (win->mapped)
 	return;
     win->mapped = 1;
@@ -36,6 +38,8 @@
     if(win->type != WIN_BORDER && win->borderwin) {
       W_UnmapWindow(win->borderwin);
     }
+    if (win->wm_window)
+      W_UnmapWindow(win->wm_window);
 }
 
 int
@@ -75,17 +79,25 @@
     W_Window window;
 {
     struct window *win;
-
+    W_Window wm_window;
 #ifdef DEBUG
     printf("Destroying %d\n", window);
 #endif
     win = W_Void2Window(window);
+    wm_window = win->wm_window;
+    
+    if(win->fs_window != None)
+      W_ToggleFullscreen(window);
+    
     deleteWindow(win);
     XDestroyWindow(W_Display, win->window);
     if(win->buffer) XFreePixmap(W_Display, win->buffer);
     if(win->type != WIN_BORDER && win->borderwin) 
       W_DestroyWindow(win->borderwin);
     free((char *) win);
+    
+    if (wm_window)
+      W_DestroyWindow(wm_window);
 }
 
 void
--- xgalaga-2.0.34.orig/libsprite/point.c
+++ xgalaga-2.0.34/libsprite/point.c
@@ -49,7 +49,7 @@
     W_Window window;
 {
     Window  win = W_Void2Window(window)->drawable;
-    register i;
+    int i;
     for (i = 0; i < NCOLORS; i++) {
 	if (_pcache_index[i])
 	    FlushPointCache(win, i);
--- xgalaga-2.0.34.orig/libsprite/scroll.c
+++ xgalaga-2.0.34/libsprite/scroll.c
@@ -9,12 +9,11 @@
     char   *str;
     int     len;
 {
-    struct stringList **strings;
     char   *newstring;
-    int     count;
+    char  **p = & (win->data);
+    struct stringList **strings = (struct stringList **)p ;
+    int count = 0;
 
-    strings = (struct stringList **) & (win->data);
-    count = 0;
     while ((*strings) != NULL) {
 	count++;
 	strings = &((*strings)->next);
--- xgalaga-2.0.34.orig/libsprite/struct.h
+++ xgalaga-2.0.34/libsprite/struct.h
@@ -55,6 +55,8 @@
     W_Callback handle_button;
     W_Callback handle_expose;
 #endif				/* 0 */
+    W_Window wm_window;
+    Window fs_window;
 };
 
 struct stringList {
--- xgalaga-2.0.34.orig/Makefile.in
+++ xgalaga-2.0.34/Makefile.in
@@ -17,8 +17,8 @@
 @SET_MAKE@
 
 SOUNDSRV = @SOUNDSERVER@
-SOUNDOBJS = @SOUNDSERVER@.o
-SOUNDSRCS = @SOUNDSERVER@.c
+SOUNDOBJS = xgal.sndsrv.linux.o
+SOUNDSRCS = xgal.sndsrv.linux.c
 
 SOUNDDEFS = -DSOUNDSERVER=\"@prefix@/@SOUNDSERVER@\"
 
@@ -30,29 +30,34 @@
 INSTALL = @INSTALL@
 
 OBJS = main.o images.o data.o paths.o pathfile.o title.o explosions.o \
-	score.o highscore.o prize.o sound.o nas_sound.o
+	score.o highscore.o prize.o sound.o nas_sound.o frate.o linux-joystick.o
+OBJS_HYPER = $(patsubst %.o,%.o.hyper,$(OBJS))
 SRCS = `echo $(OBJS) | sed -e 's/\.o/.c/g'`
 
 TARGET = xgalaga
+TARGET2 = xgalaga-hyperspace
 
 SUBDIRS = libsprite
 
-all: $(TARGET) $(SOUNDSRV)
+all: $(TARGET) $(TARGET2) $(SOUNDSRV)
 
 $(SOUNDSRV): $(SOUNDOBJS)
 	$(CC) $(LDFLAGS) -o $(SOUNDSRV) $(SOUNDOBJS) $(SOUNDLIBS)
 
 install: all
-	./mkinstalldirs $(bindir)
-	./mkinstalldirs $(prefix)
-	$(INSTALL) $(TARGET) $(bindir)/$(TARGET)
-	$(INSTALL) $(SOUNDSRV) $(prefix)/$(SOUNDSRV)
-	./mkinstalldirs $(prefix)/sounds
-	./mkinstalldirs $(prefix)/levels
-	for i in levels/*.xgl; do $(INSTALL) $$i $(prefix)/$$i ; done
-	for i in sounds/*.raw; do $(INSTALL) $$i $(prefix)/$$i ; done
-	touch $(prefix)/scores
-	chmod 666 $(prefix)/scores
+	./mkinstalldirs $(DESTDIR)/$(bindir)
+	./mkinstalldirs $(DESTDIR)/$(prefix)
+	$(INSTALL) $(TARGET) $(DESTDIR)/$(bindir)/$(TARGET)
+	$(INSTALL) $(TARGET2) $(DESTDIR)/$(bindir)/$(TARGET2)
+	if test ! "$(SOUNDSRV)" = ""; then \
+		$(INSTALL) $(SOUNDSRV) $(DESTDIR)/$(prefix)/$(SOUNDSRV); \
+	fi
+	./mkinstalldirs $(DESTDIR)/$(prefix)/sounds
+	./mkinstalldirs $(DESTDIR)/$(prefix)/levels
+	for i in levels/*.xgl; do $(INSTALL) $$i $(DESTDIR)/$(prefix)/$$i ; done
+	for i in sounds/*.raw; do $(INSTALL) $$i $(DESTDIR)/$(prefix)/$$i ; done
+#	touch $(prefix)/scores
+#	chmod 666 $(prefix)/scores
 
 subdirs:
 	for i in $(SUBDIRS); do cd $$i ; make ; done
@@ -61,8 +66,20 @@
 	$(RM) $(TARGET)
 	$(CC) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
 
+$(TARGET2): subdirs $(OBJS_HYPER)
+	$(RM) $(TARGET2)
+	$(CC) $(LDFLAGS) -o $(TARGET2) $(OBJS_HYPER) $(LIBS)
+
+%.o: %.c
+	$(CC) $(CFLAGS) -DORIGINAL_XGALAGA -c $< -o $@
+
+%.o.hyper: %.c
+	$(CC) $(CFLAGS) -UORIGINAL_XGALAGA -c $< -o $@
+
+
+
 clean:
-	$(RM) core *.o $(OBJS) $(TARGET)
+	$(RM) core *.o $(OBJS) $(OBJS_HYPER) $(TARGET) $(TARGET2)
 
 dist: clean
 	cd libsprite;make clean
@@ -78,4 +95,4 @@
 	cd libsprite;$(MAKE) distclean
 
 depend:
-	makedepend $(CFLAGS) $(SRCS)
\ No newline at end of file
+	makedepend $(CFLAGS) $(SRCS)
--- xgalaga-2.0.34.orig/README
+++ xgalaga-2.0.34/README
@@ -3,7 +3,7 @@
 
 		  Copyright (c) 1995-1998 Joe Rumsey
 			<mrogre@mediaone.net>
-      XGalaga Home Page: http://ogresoft.dyn.ml.org/xgalaga.html
+      XGalaga Home Page: http://rumsey.org/xgal.html
 
   Please see the file INSTALL for installation instructions.
 
--- xgalaga-2.0.34.orig/Wlib.h
+++ xgalaga-2.0.34/Wlib.h
@@ -91,6 +91,22 @@
 
 extern int autoPoint, W_KeyDepth, animPointers, useWorkbench;
 extern unsigned long w_socket;
+
+/* For XF86VIDMODE Support */
+#ifdef XF86VIDMODE
+#include <X11/extensions/xf86dga.h>
+#include <X11/extensions/xf86vmode.h>   
+
+struct xf86vidmode_data {
+  int vidmode_available;
+  XF86VidModeModeInfo orig_mode;
+  int orig_viewport_x;
+  int orig_viewport_y;
+};
+
+extern struct xf86vidmode_data XF86VidModeData;
+#endif
+
 #endif	/* AMIGA */
 
 #if 0
--- xgalaga-2.0.34.orig/Wproto.h
+++ xgalaga-2.0.34/Wproto.h
@@ -63,6 +63,7 @@
 W_Window W_MakeTextWindow(char *name, int x, int y, int width, int height, W_Window parent, char *cursname, int border);
 W_Window W_MakeScrollingWindow(char *name, int x, int y, int width, int height, W_Window parent, char *cursname, int border);
 void W_SetIconWindow(W_Window win, W_Window icon);
+void W_ToggleFullscreen(W_Window win);
 /* point.c */
 void W_DrawPoint(W_Window window, int x, int y, W_Color color);
 void FlushPointCache(Window win, int color);
--- xgalaga-2.0.34.orig/linux-joystick.c
+++ xgalaga-2.0.34/linux-joystick.c
@@ -0,0 +1,85 @@
+/*
+ * Support for joysticks under Linux
+ *
+ * Wouter Verhelst <wouter@debian.org>, 2003
+ *
+ * Distribute under the terms of the GPL.
+ */
+#ifdef __linux__
+#include <linux/joystick.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "data.h"
+#include "struct.h"
+#include "defs.h"
+
+struct js_state js_curstate;
+int js_device;
+
+/* make struct js_state be up-to-date */
+void update_curstate() {
+  struct js_event event;
+  int npval;
+
+  while(read(js_device,&event,sizeof(struct js_event))>0) {
+    npval=event.type&JS_EVENT_INIT?0:-1;
+    event.type &= ~JS_EVENT_INIT;
+    if(event.type==JS_EVENT_BUTTON) {
+      js_curstate.but+=event.value?1:npval;
+    } else if(event.type==JS_EVENT_AXIS) {
+      if(event.number%2==0) {
+	js_curstate.dir=event.value;
+      }
+    }
+  }
+  if (errno !=EAGAIN) {
+    perror("reading joystick device");
+    return;
+  }
+}
+
+/*
+ * Initialize the joystick device
+ */
+void init_joystick() {
+  int ioc=0;
+  js_device = open("/dev/js0",O_RDONLY|O_NONBLOCK);
+  if(js_device<0) {
+//    perror("open(/dev/js0)");
+    close(js_device);
+    js_device=0;
+  }
+  else if(ioctl(js_device,JSIOCGVERSION,&ioc)==-1) {
+    /* Driver too old */
+    fprintf(stderr,"Can't read joystick: driver too old\n");
+    close(js_device);
+    js_device=0;
+  }
+  else {
+    update_curstate();
+  }
+}
+
+void do_joystick(int* x, int* y, int* but) {
+  if (js_device>0 && !mouseControl) {
+    update_curstate();
+    *but=(js_curstate.but?W_LBUTTON:0);
+    if(*but && gameOver) {
+      gameOver=0;
+    }
+    if (js_curstate.dir>0 && !mouseControl)
+      *x = WINWIDTH;
+    else if(js_curstate.dir<0)
+      *x = 0;
+    else
+      *x=plx;
+  }
+}
+#else
+js_device=0;
+#endif /* __linux__ */
--- xgalaga-2.0.34.orig/configure.in
+++ xgalaga-2.0.34/configure.in
@@ -24,7 +24,9 @@
   AC_MSG_ERROR([Can't find X, you need X!])
 else
   INCS="$INCS -I$x_includes"
-  LIBS="-L$x_libraries"
+  if test -n "$x_libraries"; then
+    LIBS="-L$x_libraries"
+  fi
 
   if test -n "$xpm_lib"; then
     LIBS="$LIBS -L$xpm_lib"
@@ -33,7 +35,7 @@
 
 if test -n "$sound-type"; then
   case $host_alias in
-    *linux*) 
+    *linux* | *k*bsd*)
 	sound_type=native
 	;;
     *freebsd*)
@@ -54,13 +56,13 @@
 case $sound_type in
   native)
     case $host_alias in
-      *linux*)
-        SOUNDSERVER=xgal.sndsrv.linux
+      *linux* | *k*bsd*)
+        SOUNDSERVER=xgal.sndsrv.oss
 	AC_DEFINE(SOUNDDEV,"/dev/dsp")
 	AC_DEFINE(SOUND)
 	;;
       *freebsd*)
-        SOUNDSERVER=xgal.sndsrv.freebsd
+        SOUNDSERVER=xgal.sndsrv.oss
 	AC_DEFINE(SOUNDDEV,"/dev/dsp")
 	AC_DEFINE(SOUND)
 	;;
--- xgalaga-2.0.34.orig/configure
+++ xgalaga-2.0.34/configure
@@ -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
@@ -56,6 +56,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
 
@@ -339,7 +340,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-*)
@@ -509,9 +510,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
@@ -552,26 +555,26 @@
 
 
 # Make sure we can run config.sub.
-if $ac_config_sub sun4 >/dev/null 2>&1; then :
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
 else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:561: checking host system type" >&5
+echo "configure:564: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
 NONE)
   case $nonopt in
   NONE)
-    if host_alias=`$ac_config_guess`; then :
+    if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
     else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
     fi ;;
   *) host_alias=$nonopt ;;
   esac ;;
 esac
 
-host=`$ac_config_sub $host_alias`
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
 host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
@@ -581,15 +584,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:585: checking for $ac_word" >&5
+echo "configure:588: 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"
@@ -610,16 +614,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:614: checking for $ac_word" >&5
+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="${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
@@ -654,25 +659,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:669: 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:662: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:701: 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 672 "configure"
+cat > conftest.$ac_ext << EOF
+
+#line 712 "configure"
 #include "confdefs.h"
+
 main(){return(0);}
 EOF
-if { (eval echo configure:676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:717: \"$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
@@ -686,18 +727,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:696: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:743: 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:701: checking whether we are using GNU C" >&5
+echo "configure:748: 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
@@ -706,7 +753,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:710: \"$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:757: \"$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
@@ -717,11 +764,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:725: 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:776: 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
@@ -736,20 +787,24 @@
 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
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:753: checking how to run the C preprocessor" >&5
+echo "configure:808: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -764,14 +819,14 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 768 "configure"
+#line 823 "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:774: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:829: \"$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
@@ -781,14 +836,31 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 785 "configure"
+#line 840 "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:846: \"$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 857 "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:791: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:863: \"$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
@@ -801,6 +873,8 @@
 rm -f conftest*
 fi
 rm -f conftest*
+fi
+rm -f conftest*
   ac_cv_prog_CPP="$CPP"
 fi
   CPP="$ac_cv_prog_CPP"
@@ -816,28 +890,30 @@
 # SunOS /usr/etc/install
 # IRIX /sbin/install
 # AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:824: checking for a BSD compatible install" >&5
+echo "configure:899: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-    IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+    IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS=":"
   for ac_dir in $PATH; do
     # Account for people who put trailing slashes in PATH elements.
     case "$ac_dir/" in
     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
     *)
       # OSF1 and SCO ODT 3.0 have their own names for install.
-      for ac_prog in ginstall installbsd scoinst install; do
+      # Don't use installbsd from OSF since it installs stuff as root
+      # by default.
+      for ac_prog in ginstall scoinst install; do
         if test -f $ac_dir/$ac_prog; then
 	  if test $ac_prog = install &&
             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
 	    # AIX install.  It has an incompatible calling convention.
-	    # OSF/1 installbsd also uses dspmsg, but is usable.
 	    :
 	  else
 	    ac_cv_path_install="$ac_dir/$ac_prog -c"
@@ -867,10 +943,12 @@
 # It thinks the first close brace ends the variable substitution.
 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
 
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:874: checking whether ln -s works" >&5
+echo "configure:952: checking whether ln -s works" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -891,7 +969,7 @@
 fi
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:895: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:973: 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
@@ -920,15 +998,16 @@
 # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:924: checking for $ac_word" >&5
+echo "configure:1002: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # 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_RANLIB="ranlib"
@@ -965,7 +1044,7 @@
 # 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:969: checking for X" >&5
+echo "configure:1048: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -1027,13 +1106,13 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 1031 "configure"
+#line 1110 "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:1036: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1115: \"$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.
@@ -1101,14 +1180,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1105 "configure"
+#line 1184 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:1112: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1191: \"$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.
@@ -1214,17 +1293,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:1218: checking whether -R must be followed by a space" >&5
+echo "configure:1297: 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 1221 "configure"
+#line 1300 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1228: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -1240,14 +1319,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 1244 "configure"
+#line 1323 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1251: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1330: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -1279,7 +1358,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:1283: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:1362: 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
@@ -1287,7 +1366,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1291 "configure"
+#line 1370 "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
@@ -1298,7 +1377,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:1302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1381: \"$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
@@ -1320,7 +1399,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:1324: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:1403: 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
@@ -1328,7 +1407,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1332 "configure"
+#line 1411 "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
@@ -1339,7 +1418,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:1343: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1422: \"$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
@@ -1368,12 +1447,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:1372: checking for gethostbyname" >&5
+echo "configure:1451: 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 1377 "configure"
+#line 1456 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -1396,7 +1475,7 @@
 
 ; 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:1479: \"$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
@@ -1417,7 +1496,7 @@
 
     if test $ac_cv_func_gethostbyname = no; then
       echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:1421: checking for gethostbyname in -lnsl" >&5
+echo "configure:1500: 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
@@ -1425,7 +1504,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1429 "configure"
+#line 1508 "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
@@ -1436,7 +1515,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:1440: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1519: \"$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 +1545,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:1470: checking for connect" >&5
+echo "configure:1549: 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 1475 "configure"
+#line 1554 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -1494,7 +1573,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:1577: \"$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
@@ -1515,7 +1594,7 @@
 
     if test $ac_cv_func_connect = no; then
       echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:1519: checking for connect in -lsocket" >&5
+echo "configure:1598: 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
@@ -1523,7 +1602,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1527 "configure"
+#line 1606 "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 +1613,7 @@
 connect()
 ; 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:1617: \"$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
@@ -1558,12 +1637,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:1562: checking for remove" >&5
+echo "configure:1641: 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 1567 "configure"
+#line 1646 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -1586,7 +1665,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1590: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1669: \"$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
@@ -1607,7 +1686,7 @@
 
     if test $ac_cv_func_remove = no; then
       echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:1611: checking for remove in -lposix" >&5
+echo "configure:1690: 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
@@ -1615,7 +1694,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lposix  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1619 "configure"
+#line 1698 "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
@@ -1626,7 +1705,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:1630: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1709: \"$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
@@ -1650,12 +1729,12 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:1654: checking for shmat" >&5
+echo "configure:1733: 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 1659 "configure"
+#line 1738 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -1678,7 +1757,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1761: \"$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
@@ -1699,7 +1778,7 @@
 
     if test $ac_cv_func_shmat = no; then
       echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:1703: checking for shmat in -lipc" >&5
+echo "configure:1782: 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
@@ -1707,7 +1786,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lipc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1711 "configure"
+#line 1790 "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
@@ -1718,7 +1797,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:1722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1801: \"$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
@@ -1751,15 +1830,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:1755: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:1834: 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 1763 "configure"
+#line 1842 "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
@@ -1770,7 +1849,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:1774: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1853: \"$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
@@ -1798,7 +1877,9 @@
   { echo "configure: error: Can't find X, you need X!" 1>&2; exit 1; }
 else
   INCS="$INCS -I$x_includes"
-  LIBS="-L$x_libraries"
+  if test -n "$x_libraries"; then
+    LIBS="-L$x_libraries"
+  fi
 
   if test -n "$xpm_lib"; then
     LIBS="$LIBS -L$xpm_lib"
@@ -1807,7 +1888,7 @@
 
 if test -n "$sound-type"; then
   case $host_alias in
-    *linux*) 
+    *linux* | *k*bsd*)
 	sound_type=native
 	;;
     *freebsd*)
@@ -1828,8 +1909,8 @@
 case $sound_type in
   native)
     case $host_alias in
-      *linux*)
-        SOUNDSERVER=xgal.sndsrv.linux
+      *linux* | *k*bsd*)
+        SOUNDSERVER=xgal.sndsrv.oss
 	cat >> confdefs.h <<\EOF
 #define SOUNDDEV "/dev/dsp"
 EOF
@@ -1840,7 +1921,7 @@
 
 	;;
       *freebsd*)
-        SOUNDSERVER=xgal.sndsrv.freebsd
+        SOUNDSERVER=xgal.sndsrv.oss
 	cat >> confdefs.h <<\EOF
 #define SOUNDDEV "/dev/dsp"
 EOF
@@ -1911,7 +1992,7 @@
 
 
 echo $ac_n "checking for main in -lX11""... $ac_c" 1>&6
-echo "configure:1915: checking for main in -lX11" >&5
+echo "configure:1994: checking for main in -lX11" >&5
 ac_lib_var=`echo X11'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1919,14 +2000,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lX11  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1923 "configure"
+#line 2002 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:1930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2009: \"$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
@@ -1947,7 +2028,7 @@
 fi
 
 echo $ac_n "checking for main in -lXmu""... $ac_c" 1>&6
-echo "configure:1951: checking for main in -lXmu" >&5
+echo "configure:2030: checking for main in -lXmu" >&5
 ac_lib_var=`echo Xmu'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1955,14 +2036,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXmu -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1959 "configure"
+#line 2038 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:1966: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2045: \"$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
@@ -1983,7 +2064,7 @@
 fi
 
 echo $ac_n "checking for main in -lXt""... $ac_c" 1>&6
-echo "configure:1987: checking for main in -lXt" >&5
+echo "configure:2066: checking for main in -lXt" >&5
 ac_lib_var=`echo Xt'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1991,14 +2072,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXt -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1995 "configure"
+#line 2074 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:2002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2081: \"$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
@@ -2019,7 +2100,7 @@
 fi
 
 echo $ac_n "checking for main in -lXext""... $ac_c" 1>&6
-echo "configure:2023: checking for main in -lXext" >&5
+echo "configure:2102: checking for main in -lXext" >&5
 ac_lib_var=`echo Xext'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2027,14 +2108,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2031 "configure"
+#line 2110 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:2038: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2117: \"$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
@@ -2055,7 +2136,7 @@
 fi
 
 echo $ac_n "checking for main in -lXExExt""... $ac_c" 1>&6
-echo "configure:2059: checking for main in -lXExExt" >&5
+echo "configure:2138: checking for main in -lXExExt" >&5
 ac_lib_var=`echo XExExt'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2063,14 +2144,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXExExt -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2067 "configure"
+#line 2146 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:2074: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2153: \"$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
@@ -2091,7 +2172,7 @@
 fi
 
 echo $ac_n "checking for main in -lXpm""... $ac_c" 1>&6
-echo "configure:2095: checking for main in -lXpm" >&5
+echo "configure:2174: checking for main in -lXpm" >&5
 ac_lib_var=`echo Xpm'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2099,14 +2180,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXpm -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2103 "configure"
+#line 2182 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:2110: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2189: \"$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
@@ -2129,12 +2210,12 @@
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:2133: checking for ANSI C header files" >&5
+echo "configure:2212: 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 2138 "configure"
+#line 2217 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -2142,8 +2223,8 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2146: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:2225: \"$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
@@ -2159,7 +2240,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 2163 "configure"
+#line 2242 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -2177,7 +2258,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 2181 "configure"
+#line 2260 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -2198,7 +2279,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 2202 "configure"
+#line 2281 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -2209,7 +2290,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:2213: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2292: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -2236,18 +2317,18 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2240: checking for $ac_hdr" >&5
+echo "configure:2319: 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 2245 "configure"
+#line 2324 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2250: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:2329: \"$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"
@@ -2274,12 +2355,12 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:2278: checking for working const" >&5
+echo "configure:2357: 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 2283 "configure"
+#line 2362 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -2328,7 +2409,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2332: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2411: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -2349,12 +2430,12 @@
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:2353: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:2432: 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 2358 "configure"
+#line 2437 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -2363,7 +2444,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:2367: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2446: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -2386,13 +2467,13 @@
 
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:2390: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:2469: 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 2396 "configure"
+#line 2475 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 Autoconf TIOCGETP
@@ -2410,7 +2491,7 @@
 
   if test $ac_cv_prog_gcc_traditional = no; then
     cat > conftest.$ac_ext <<EOF
-#line 2414 "configure"
+#line 2493 "configure"
 #include "confdefs.h"
 #include <termio.h>
 Autoconf TCGETA
@@ -2432,12 +2513,12 @@
 fi
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:2436: checking return type of signal handlers" >&5
+echo "configure:2515: 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 2441 "configure"
+#line 2520 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -2454,7 +2535,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:2458: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2537: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -2475,12 +2556,12 @@
 for ac_func in gettimeofday select random lrand48
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2479: checking for $ac_func" >&5
+echo "configure:2558: 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 2484 "configure"
+#line 2563 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2503,7 +2584,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2507: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2586: \"$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
@@ -2551,7 +2632,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 \).
@@ -2618,7 +2699,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 ;;
@@ -2638,9 +2719,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
@@ -2667,6 +2750,7 @@
 s%@CC@%$CC%g
 s%@CPP@%$CPP%g
 s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
 s%@INSTALL_DATA@%$INSTALL_DATA%g
 s%@LN_S@%$LN_S%g
 s%@SET_MAKE@%$SET_MAKE%g
--- xgalaga-2.0.34.orig/data.c
+++ xgalaga-2.0.34/data.c
@@ -10,7 +10,7 @@
 
 int buttonDown = 0;
 
-W_Window baseWin;
+W_Window shellWin, baseWin;
 
 W_Image *playerShip, *playerTorp, *enemyTorp, *shieldImage;
 
@@ -30,6 +30,11 @@
 int counter;
 
 int mouseControl = 0;
+int wantStars = 1;
+
+/* Modified slightly to better fit on 800x600 in fullscreen mode */
+int winwidth  = 468; /* was 400 */
+int winheight = 596; /* was 511 */
 
 int alien_shape[ALIENSHAPES] = {
     I_ALIEN1,
@@ -55,6 +60,7 @@
 int maxtorps = 4, numtorps = 0;
 
 int plx = 200;
+int pldead = 0;
 
 int movespeed = MINSPEED;
 
@@ -67,6 +73,8 @@
 #endif
 
 int plshield = 0;
+int shieldsleft = 0;
+int shieldon = 0;
 
 int title_page=0, pagetimer=300;
 
--- xgalaga-2.0.34.orig/data.h
+++ xgalaga-2.0.34/data.h
@@ -1,11 +1,12 @@
 #include "Wlib.h"
+#include "struct.h"
 
-extern W_Window gal, baseWin;
+extern W_Window gal, shellWin, baseWin;
 
 extern char *imagedir;
 extern int verbose_image_loading;
 extern int forceMono;
-extern int xpm, useOR;
+extern int xpm, useOR, useClipMask, useBuffered;
 
 extern W_Color backColor;
 
@@ -18,6 +19,8 @@
 extern int paused;
 
 extern int ships;
+extern int shieldsleft;
+extern int shieldon;
 
 extern int level, metaLevel;
 extern int startLevel;
@@ -30,6 +33,10 @@
 extern int counter;
 
 extern int mouseControl;
+extern int wantStars;
+
+extern int winwidth;
+extern int winheight;
 
 extern int alien_shape[];
 
@@ -37,6 +44,7 @@
 extern int maxtorps, numtorps;
 
 extern int plx;
+extern int pldead;
 
 extern int movespeed;
 
@@ -55,3 +63,6 @@
 extern int gotlemon;
 
 extern struct alien aliens[];
+
+extern struct js_state js_curstate;
+extern int js_device;
--- xgalaga-2.0.34.orig/defs.h
+++ xgalaga-2.0.34/defs.h
@@ -1,5 +1,20 @@
 #define VERSION "2.0.34"
 
+/* Area for setting flags to enable changes by Bryce and Neelix */
+
+/* #define ORIGINAL_XGALAGA  */
+
+
+#ifndef ORIGINAL_XGALAGA
+# define ENABLE_SHIP_WRAP
+# define ENABLE_SPREAD_SHOT
+# define ENABLE_MACHINE_GUN
+# define DISABLE_RESET_ON_DEATH
+# define ACTIVATED_SHIELD
+# define SHOW_SHIELD_BAR
+# define NO_PRIZE_WHILE_DEAD
+#endif
+
 #define MAXTORPS 10
 #define MINTORPS 3
 #define TORPSPEED 12
@@ -11,8 +26,8 @@
 
 #define TORPDELAY 5
 
-#define WINWIDTH 400
-#define WINHEIGHT 500
+#define WINWIDTH  winwidth  /* was 400 */
+#define WINHEIGHT winheight /* was 500 */
 
 #define NUMSTARS 30
 
@@ -38,15 +53,29 @@
 # endif
 #endif
 
-#define NUMWEAPONS 3
+#define NUMWEAPONS 3 + ENABLE_SPREAD_SHOT + ENABLE_MACHINE_GUN
 #define SINGLESHOT 0
 #define DOUBLESHOT 1
 #define TRIPLESHOT 2
+#define SPREADSHOT 3
+#define MACHINEGUN 4
 
-#define PRIZECHANCE 30
+#ifdef ORIGINAL_XGALAGA
+# define PRIZECHANCE 30
+#else
+# define PRIZECHANCE 25
+#endif
 
 #define TORPCHANCE 60
 
-#define SHIELDTIME 300
+#ifdef ORIGINAL_XGALAGA
+# define SHIELDTIME 300
+#else
+# define STARTSHIELDS 0
+# define MAXSHIELDS 800
+# define SHIELDTIME 200
+#endif
+
+
 
 #define ALIENSHAPES 17
--- xgalaga-2.0.34.orig/frate.c
+++ xgalaga-2.0.34/frate.c
@@ -0,0 +1,205 @@
+/* frate.c -- Frame rate code. */
+
+#include "config.h"
+
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include "defs.h"
+
+
+#define FPS  30
+
+
+/*****************************************************************************/
+#if defined(linux)
+
+/* ITIMER_REAL is used for the time base, in a "one-shot" mode.  SIGALRM is
+   generated when it expires, but this signal is held blocked.  sigsuspend()
+   waits for SIGALRM to go off, or lets it go immediately if it's already
+   pending.  Then a new ITIMER_REAL is started.  If for any reason the main
+   loop takes longer than the desired time, no catch-ups are attempted,
+   further loops just run normal times.
+
+   The time desired for each loop varies.  A normal kernel runs the clock at
+   10 milliseconds, so to get 30 frames per second loops are run in the
+   pattern 30, 30, 40 milliseconds for an average 33.3ms.  The pattern is
+   generated based on sysconf(_SC_CLK_TCK) and FPS, and it should work for
+   any values of those settings.  Essentially, CLK_TCK ticks per second are
+   divided up into FPS many buckets, as evenly as possible.
+
+   Linux ITIMER_REAL does the traditional Unix timing thing which is to
+   round up the requested delay to get clock ticks, and add this to the
+   current tick.  For example if "jiffies" tick is 12345 and an interval of
+   35ms is requested the interval is converted to 4 ticks and the alarm goes
+   off when jiffies tick 12349 is reached.  This pays no attention to how
+   much of the current tick has elapsed when the request is made.
+
+   select(), poll(), usleep() and nanosleep() do it differently, they don't
+   start counting time until the end of the current tick (by adding one tick
+   to the requested time).  See /usr/src/linux/kernel/sched.c
+   sys_nanosleep() where it adds "(t.tv_sec || t.tv_nsec)".  In the example
+   the alarm would go off at jiffies tick 12350.  As far as I can tell it's
+   impossible for those functions to do a delay that goes only to the next
+   tick boundary, and because that could well be wanted on a slowish system,
+   ITIMER_REAL is used instead.
+
+   An alternative to the code here, for x86 PCs at least, would be /dev/rtc,
+   which can be set to give high resolution timer interrupts that can be
+   counted and blocked on (with read()).  See
+   /usr/src/linux/Documentation/rtc.txt.
+
+ */
+
+static struct itimerval  table[FPS];
+static int               upto = 0;
+static sigset_t          alrmonly;
+
+
+static void sigalrm(int signum)
+{
+}
+
+void init_framerate(void)
+{
+  /* create table[] times */
+  {
+    long  clktck, period, quot, rem, r, t;
+    int   i;
+
+    clktck = sysconf (_SC_CLK_TCK);
+    if (clktck == -1)
+      {
+        perror ("sysconf _SC_CLK_TCK");
+        exit (1);
+      }
+    period = 1000000 / clktck;
+
+    quot = clktck / FPS;
+    rem = clktck % FPS;
+    r = 0;
+    for (i = 0; i < FPS; i++)
+      {
+        t = quot;
+        r += rem;
+        if (r >= FPS)
+          {
+            t++;
+            r -= FPS;
+          }
+
+        /* The actual tv_usec set up is just under "t" ticks because the
+           kernel will round up the requested value. */
+        table[i].it_value.tv_usec = t*period - period/2;
+
+        /* printf ("table[%d] = %ld\n", i, table[i].it_value.tv_usec); */
+      }
+  }
+
+  /* make SIGALRM blocked */
+  {
+    sigset_t  set;
+    sigemptyset (&set);
+    sigaddset (&set, SIGALRM);
+    sigprocmask (SIG_BLOCK, &set, NULL);
+  }
+
+  /* install dummy SIGALRM handler */
+  {
+    struct sigaction  act;
+    act.sa_handler = sigalrm;
+    sigemptyset (&act.sa_mask);
+    act.sa_flags = SA_RESTART;
+    sigaction (SIGALRM, &act, NULL);
+  }
+
+  /* sigset with only SIGALRM unmasked */
+  sigfillset (&alrmonly);
+  sigdelset (&alrmonly, SIGALRM); 
+
+  /* start initial timer */
+  setitimer (ITIMER_REAL, &table[0], NULL);
+}
+
+void do_framerate(void)
+{
+  /* wait for SIGALRM */
+  sigsuspend (&alrmonly);
+
+  /* new timer */
+  setitimer (ITIMER_REAL, &table[upto], NULL);
+  if (++upto >= FPS)
+    upto = 0;
+
+  /* Enable this code to print how long each loop is taking.  Redirect
+     output to a file so results aren't affected by the time taken to draw
+     the screen.  First print is bogus because "t" starts out zero.  */
+#if 0
+  {
+    static struct timeval  t;
+    struct timeval n;
+    long   d;
+    gettimeofday (&n, NULL);
+    d = 1000000*(n.tv_sec-t.tv_sec) + n.tv_usec-t.tv_usec;
+    t = n;
+
+    printf ("%ld\n", d);
+    /* if (d < 29000 || d > 41000) printf ("BAD %ld\n", d); */
+  }
+#endif
+}
+
+
+/*****************************************************************************/
+#else /* !defined(linux) */
+
+/* Old code, using select(). */
+
+
+static struct timeval  otv;
+
+void init_framerate(void)
+{
+  gettimeofday(&otv, 0);
+}
+
+void do_framerate(void)
+{
+  static struct timeval  ut;
+  struct timeval  tv;
+
+  gettimeofday(&tv, 0);
+  ut.tv_usec = UTIMER
+    - (1000000 * (tv.tv_sec - otv.tv_sec) + (tv.tv_usec - otv.tv_usec));
+
+  /* Checking u<2*UTIMER guards against a hang if the system time changes. */
+  if (ut.tv_usec > 0 && ut.tv_usec < 2*UTIMER)
+    (void) select (0, 0, 0, 0, &ut);
+
+  gettimeofday(&otv, 0);
+
+  /* Enable this code to print how long each loop is taking.  Redirect
+     output to a file so results aren't affected by the time taken to draw
+     the screen.  First print is bogus because "t" starts out zero.  */
+#if 0
+  {
+    static struct timeval  t;
+    struct timeval n;
+    long   d;
+    gettimeofday (&n, 0);
+    d = 1000000*(n.tv_sec-t.tv_sec) + n.tv_usec-t.tv_usec;
+    t = n;
+
+    printf ("%ld\n", d);
+  }
+#endif
+}
+
+#endif
--- xgalaga-2.0.34.orig/highscore.c
+++ xgalaga-2.0.34/highscore.c
@@ -31,7 +31,13 @@
 #include "proto.h"
 #include "data.h"
 
+/* Global score file is insecure and rather useless today. */
+#define NO_GLOBAL_SCORES 1
+#ifdef NO_GLOBAL_SCORES
+#define NUM_GLOBAL_SCORES 0
+#else
 #define NUM_GLOBAL_SCORES 20
+#endif
 #define NUM_MY_SCORES 10
 
 static char new_name[20];
@@ -45,12 +51,16 @@
     char name[20];
     long score;
     long level;
-} global_scores[NUM_GLOBAL_SCORES], my_scores[NUM_MY_SCORES];
+} 
+#ifndef NO_GLOBAL_SCORES
+	global_scores[NUM_GLOBAL_SCORES],
+#endif
+	my_scores[NUM_MY_SCORES];
 
 void undo_name()
 {
     W_ClearArea(baseWin, 
-		WINWIDTH/2-(20*W_Textwidth), 200,
+		WINWIDTH/2-(20*W_Textwidth), 250,
 		(40*W_Textwidth), W_Textheight*2);
 }
 
@@ -64,9 +74,9 @@
 	nnpos = strlen(new_name);
 	init = 1;
     }
-    center_text("Great score! Enter your name:", 200, W_Red);
+    center_text("Great score! Enter your name:", 250, W_Red);
     sprintf(buf, "%s_", new_name);
-    center_text(buf, 200 + W_Textheight, W_Cyan);
+    center_text(buf, 250 + W_Textheight, W_Cyan);
 }
 
 char *getUsersFullName()
@@ -115,7 +125,7 @@
     }
 
     /* shorten to 20 chars */
-    fullname[20] = 0;
+    fullname[19] = 0;
 
     /* Return their name without any trailing stuff */
     return(fullname);
@@ -127,12 +137,13 @@
     int hsf;
     long x;
     char my_file_name [256], *home;
-
+#ifndef NO_GLOBAL_SCORES
     hsf = open(SCOREFILE, O_WRONLY | O_TRUNC | O_CREAT, 0666);
     if(hsf < 0) {
 	printf("Couldn't write scores file %s\n", SCOREFILE);
 	return;
     }
+
     for(i=0;i<NUM_GLOBAL_SCORES;i++) {
 #ifdef NOSCOREHOGS
         x=htonl(global_scores[i].uid);
@@ -149,10 +160,23 @@
 	    goto error;
     }
     close(hsf);
-
+#endif /* NO_GLOBAL_SCORES */
     if((home = getenv("HOME"))) {
-	sprintf(my_file_name, "%s/.xgalscores", home);
+#ifndef NO_GLOBAL_SCORES
+	gid_t my_egid = getegid();
+	if (setgid(getgid()) != 0) {
+		perror("setgid");
+		return;
+	}
+#endif
+	snprintf(my_file_name, sizeof(my_file_name)-1, "%s/.xgalscores", home);
 	hsf = open(my_file_name, O_WRONLY | O_TRUNC | O_CREAT, 0644);
+#ifndef NO_GLOBAL_SCORES
+	if (setgid(my_egid) != 0) {
+		perror("setgid back");
+		exit(1);
+	}
+#endif
 	if(hsf < 0) {
 	    printf("Couldn't write scores file %s\n", my_file_name);
 	    return;
@@ -167,13 +191,15 @@
 	    if(write(hsf, &x, sizeof(long)) < sizeof(long))
 		goto error2;
 	}
+        close(hsf);
     }
-    close(hsf);
 	
     return;
+#ifndef NO_GLOBAL_SCORES
   error:
     printf("Error saving high scores file %s\n", SCOREFILE);
     return;
+#endif
   error2:
     printf("Error saving high scores file %s\n", my_file_name);
     return;
@@ -181,12 +207,13 @@
 
 void add_score(char *name, int score)
 {
-    int i,j,k;
+    int i,j ; /* ,k; */
 
     thisplace = my_thisplace = -1;
 
     load_scores();
 
+#ifndef NO_GLOBAL_SCORES
 #ifdef NOSCOREHOGS
     /* /lib 27jul95: want to allow only one global high-score per person,
      * by uid (getuid)
@@ -239,6 +266,7 @@
 	}
     }
 #endif /* NOSCOREHOGS */
+#endif /* NO_GLOBAL_SCORES */
 
     for(i=0;i<NUM_MY_SCORES;i++) {
 	if(score > my_scores[i].score) {
@@ -299,6 +327,7 @@
     int i;
 
     load_scores(); /* in case someone else has gotten a high score */
+#ifndef NO_GLOBAL_SCORES
     for(i=0;i<NUM_GLOBAL_SCORES;i++) {
 	if(score > global_scores[i].score) {
 	    return 1;
@@ -309,7 +338,7 @@
  	}
 #endif
     }
-
+#endif /* NO_GLOBAL_SCORES */
     for(i=0;i<NUM_MY_SCORES;i++) {
 	if(score > my_scores[i].score)
 	    return 1;
@@ -332,6 +361,7 @@
     color = W_DarkGrey;
 
     
+#ifndef NO_GLOBAL_SCORES
     center_text("Global high scores", 90, W_Yellow);
     sprintf(buf, "Rank  Name                      Score   Level");
     center_text(buf, 100, W_Yellow);
@@ -342,7 +372,8 @@
 		global_scores[i].name, global_scores[i].score,global_scores[i].level);
 	center_text(buf, 112+i*W_Textheight, (i==thisplace ? color : W_Grey));
     }
-
+#endif
+    
     center_text("Your high scores", 112+NUM_GLOBAL_SCORES*W_Textheight, W_Yellow);
     sprintf(buf, "Rank  Name                      Score   Level");
     center_text(buf, 112+(NUM_GLOBAL_SCORES+1)*W_Textheight, W_Yellow);
@@ -362,6 +393,7 @@
     int hsf;
     char my_file_name[256], *home;
 
+#ifndef NO_GLOBAL_SCORES
     hsf = open(SCOREFILE, O_RDONLY);
     if(hsf <0 ) {
 	printf("Trouble opening high scores file '%s'\n", SCOREFILE);
@@ -393,9 +425,10 @@
 	}
     }
     close(hsf);
+#endif /* NO_GLOBAL_SCORES */
 
     if((home = getenv("HOME"))) {
-	sprintf(my_file_name, "%s/.xgalscores", home);
+	snprintf(my_file_name, sizeof(my_file_name)-1, "%s/.xgalscores", home);
 	hsf = open(my_file_name, O_RDONLY);
 	if(hsf <0 ) {
 	    printf("Trouble opening high scores file '%s'\n", my_file_name);
@@ -426,6 +459,7 @@
 	}
     }
     return;
+#ifndef NO_GLOBAL_SCORES
   error:
     if(i>0)
 	printf("Error reading high scores file '%s'\n", SCOREFILE);
@@ -439,6 +473,7 @@
     }
     close(hsf);
     return;
+#endif
   error2:
     if(i>0)
 	printf("Error reading high scores file '%s'\n", my_file_name);
@@ -454,6 +489,7 @@
     int i;
     
     load_scores();
+#ifndef NO_GLOBAL_SCORES
     printf("\nGlobal High Scores:\n");
     printf("-----------------------------------------------\n");
     printf("%8s %-20s %8s %8s\n", "uid", "name", "score", "level");
@@ -471,6 +507,7 @@
 	       global_scores[i].level);
 #endif
     }
+#endif /* NO_GLOBAL_SCORES */
     printf("-----------------------------------------------\n");
     printf("\nYour High Scores:\n");
     printf("--------------------------------------\n");
--- xgalaga-2.0.34.orig/images.c
+++ xgalaga-2.0.34/images.c
@@ -6576,6 +6576,27 @@
 " .... OOO XXX. ",
 "  ....   ....  "};
 
+#ifndef ORIGINAL_XGALAGA
+/* XPM */
+static char * pr_machine_xpm[] = {
+"15 10 5 1",
+" 	c None",
+".	c #868600000000",
+"X	c #aaaa00000000",
+"o	c #FFFF00000000",
+"=	c #ffffffffffff",
+"  .XoooooooX.  ",
+" XXo  oooooooX ",
+"XXX == oooooooX",
+"XXo == oooooooo",
+"XXX == oo  oooo",
+"XXXo  oo == ooo",
+"XXXooooo == ooo",
+"XXXXXooo == ooX",
+" XXXXXooo  ooX ",
+"  .XXXXXXXXX.  "};
+#endif
+
 /* XPM */
 static char * pr_shield_xpm[] = {
 "15 10 5 1",
@@ -6632,6 +6653,26 @@
 " ....    XXXX. ",
 "  ...........  "};
 
+#ifndef ORIGINAL_XGALAGA
+/* XPM */
+static char * pr_spread_xpm[] = {
+"15 10 4 1",
+" 	c None",
+".	c #00009f",
+"X	c #0000ff",
+"o	c #ffffff",
+"  ..XXXXXXX..  ",
+" ..XXXXXXXXXX. ",
+"...XXXXXXXXXXX.",
+"..ooXXXXXXXooXX",
+"..  oXXXXXo  XX",
+"...X oXXXo XXXX",
+"....X oXo XXXXX",
+".....X o XXXXX.",
+" .....X XXXXX. ",
+"  ...........  "};
+#endif
+
 /* XPM */
 static char * pr_trip_xpm[] = {
 "15 10 4 1",
@@ -6830,9 +6871,15 @@
    {0, 0, 0, 0, "/pr_doub", 0, I_DEFAULT, 0, 1, NULL, (char**)pr_doub_xpm, 0, 0},
    {0, 0, 0, 0, "/pr_extrabullet", 0, I_DEFAULT, 0, 1, NULL, (char**)pr_extrabullet_xpm, 0, 0},
    {0, 0, 0, 0, "/pr_lemon", 0, I_DEFAULT, 0, 1, NULL, (char**)pr_lemon_xpm, 0, 0},
+#ifndef ORIGINAL_XGALAGA
+   {0, 0, 0, 0, "/pr_machine", 0, I_DEFAULT, 0, 1, NULL, (char**)pr_machine_xpm, 0, 0},
+#endif
    {0, 0, 0, 0, "/pr_shield", 0, I_DEFAULT, 0, 1, NULL, (char**)pr_shield_xpm, 0, 0},
    {0, 0, 0, 0, "/pr_sing", 0, I_DEFAULT, 0, 1, NULL, (char**)pr_sing_xpm, 0, 0},
    {0, 0, 0, 0, "/pr_speed", 0, I_DEFAULT, 0, 1, NULL, (char**)pr_speed_xpm, 0, 0},
+#ifndef ORIGINAL_XGALAGA
+   {0, 0, 0, 0, "/pr_spread", 0, I_DEFAULT, 0, 1, NULL, (char**)pr_spread_xpm, 0, 0},
+#endif
    {0, 0, 0, 0, "/pr_trip", 0, I_DEFAULT, 0, 1, NULL, (char**)pr_trip_xpm, 0, 0},
    {0, 0, 0, 0, "/s1000", 0, I_DEFAULT, 0, 1, NULL, (char**)s1000_xpm, 0, 0},
    {0, 0, 0, 0, "/s2000", 0, I_DEFAULT, 0, 1, NULL, (char**)s2000_xpm, 0, 0},
--- xgalaga-2.0.34.orig/images.h
+++ xgalaga-2.0.34/images.h
@@ -41,6 +41,22 @@
 #define I_PR_DOUB              29
 #define I_PR_EXTRABULLET       30
 #define I_PR_LEMON             31
+
+#ifndef ORIGINAL_XGALAGA
+#define I_PR_MACHINE           32
+#define I_PR_SHIELD            33
+#define I_PR_SING              34
+#define I_PR_SPEED             35
+#define I_PR_SPREAD            36
+#define I_PR_TRIP              37
+#define I_S1000                38
+#define I_S2000                39
+#define I_S4000                40
+#define I_S500                 41
+#define I_SHIELD               42
+#define I_TITLE                43
+#define I_LAST                 44
+#else
 #define I_PR_SHIELD            32
 #define I_PR_SING              33
 #define I_PR_SPEED             34
@@ -51,4 +67,6 @@
 #define I_S500                 39
 #define I_SHIELD               40
 #define I_TITLE                41
-#define I_LAST                 41
+#define I_LAST                 42
+#endif /* ORIGINAL_XGALAGA */
+
--- xgalaga-2.0.34.orig/main.c
+++ xgalaga-2.0.34/main.c
@@ -31,45 +31,59 @@
 static int starspeed = 1;
 static int attacking = 0, maxattacking, entering=0;
 static int maxetorps = 5, numetorps=0;
-static int pldead = 0;
 static int plflash = 50;
+static int fullscreen = 0;
+#ifndef ORIGINAL_XGALAGA
+static int shots = 0;
+static int hits = 0;
+#endif
 
 #define convoy_x_pos(i) (convoyx+(20 * (i - 10 * (i/10))))
 #define convoy_y_pos(i) (20 + (20*(i/10)))
 
 static int moves[16][2] = {
-    0,-4,
-    1,-4,
-    3,-3,
-    4,-1,
-    4,0,
-    4,1,
-    3,3,
-    1,4,
-    0,4,
-    -1,4,
-    -3,3,
-    -4,1,
-    -4,0,
-    -4,-1,
-    -3,-3,
-    -1,-4
+    {0,-4},
+    {1,-4},
+    {3,-3},
+    {4,-1},
+    {4,0},
+    {4,1},
+    {3,3},
+    {1,4},
+    {0,4},
+    {-1,4},
+    {-3,3},
+    {-4,1},
+    {-4,0},
+    {-4,-1},
+    {-3,-3},
+    {-1,-4}
 };
 
 void
 xgal_exit(int v)
 {
     /*    W_AutoRepeatOn();*/
+    /* Destroy our main window so the fullscreen mode gets unset if we're
+       running fullscreen. (We should really clean up much more here!) */
+    W_DestroyWindow(shellWin);
 #ifdef SOUND
     kill_sound();
 #endif
     /*    sleep(1);*/ /* Without this, the auto-repeat request fails on my machine... */
+    /* Note if we ever need this autorepeat thingie again, the sleep can and should be replaced by a call to XSync() */
     exit(v);
 }
 
 
 static void print_usage()
 {
+#ifdef SOUND 
+#define PRINT_SOUND	"-nosound             Turn sound OFF\n"
+#else
+#define PRINT_SOUND	""
+#endif
+
     printf("\
 XGalaga v%s\n\
 Copyright (c) 1995-1998 Joe Rumsey\n\
@@ -80,6 +94,8 @@
 -mouse               Use mouse control (same as 'm' at the title screen)\n\
 -keyboard            Use keyboard control (same as 'k')\n%s\
 -level <number>      Choose starting level (>= 1)\n\
+-window              Start in windowed mode instead of fullscreen\n\
+-winsize <WxH>       Window size (default 468 x 596)\n\
 -b                   turn buffered mode off, use this if it runs\n\
 too slowly.  Will cause flicker, maybe lots,\n\
 maybe only a little.\n\
@@ -96,12 +112,9 @@
 p - pauses\n\
 q - end this game\n\
 b - Toggle buffering (flicker vs. speed.)\n\
-o - Toggle OR mode.  Don't use this, it sucks.\n", VERSION,
-#ifdef SOUND
-           "  -nosound             Turn sound OFF\n"
-#else
-           ""
-#endif
+o - Toggle OR mode.  Don't use this, it sucks.\n\
+alt + enter - Toggle fullscreen - window\n", VERSION,
+	PRINT_SOUND
            );
 }
 
@@ -140,8 +153,10 @@
 {
     int i;
     
-    for(i=0;i<NUMSTARS;i++) {
-        W_DrawPoint(baseWin, stars[i].x, stars[i].y, W_Black);
+    if(wantStars) {
+        for(i=0;i<NUMSTARS;i++) {
+            W_DrawPoint(baseWin, stars[i].x, stars[i].y, W_Black);
+        }
     }
     if(drewlevel) {
         W_ClearArea(baseWin, WINWIDTH/2 - (W_StringWidth("LEVEL 000", W_BigFont)/2), WINHEIGHT/2-W_BigTextheight/2,
@@ -154,39 +169,78 @@
 {
     int i;
     
-    for(i=0;i<NUMSTARS;i++) {
-        if(!paused)
-            stars[i].y+=stars[i].speed*((starspeed < 20) ? ABS(starspeed) : 20);
-        if(stars[i].y >= WINHEIGHT) {
-            stars[i].y-=WINHEIGHT+starspeed;
-            stars[i].x = random() % WINWIDTH;
-            switch(random()%5) {
-            case 0:
-                stars[i].color = W_White;
-                break;
-            case 1:
-                stars[i].color = W_Green;
-                break;
-            case 2:
-                stars[i].color = W_Cyan;
-                break;
-            case 3:
-                stars[i].color = W_Red;
-                break;
-            default:
-                stars[i].color = W_Yellow;
-                break;
+    if(wantStars) {
+        for(i=0;i<NUMSTARS;i++) {
+            if(!paused)
+                stars[i].y+=stars[i].speed*((starspeed < 20) ? ABS(starspeed) : 20);
+            if(stars[i].y >= WINHEIGHT) {
+                stars[i].y-=WINHEIGHT+starspeed;
+                stars[i].x = random() % WINWIDTH;
+                switch(random()%5) {
+                case 0:
+                    stars[i].color = W_White;
+                    break;
+                case 1:
+                    stars[i].color = W_Green;
+                    break;
+                case 2:
+                    stars[i].color = W_Cyan;
+                    break;
+                case 3:
+                    stars[i].color = W_Red;
+                    break;
+                default:
+                    stars[i].color = W_Yellow;
+                    break;
+                }
             }
+            W_DrawPoint(baseWin, stars[i].x, stars[i].y, stars[i].color);
         }
-        W_DrawPoint(baseWin, stars[i].x, stars[i].y, stars[i].color);
+#ifdef SHOW_SHIELD_BAR
+	    if ((plshield > 0) || (shieldsleft > 0)) { 
+		int shieldcount = 0;
+		int total_shields = (plshield + shieldsleft) * 19 / SHIELDTIME + 1;
+		while (total_shields > 0) {
+			shieldcount++;
+			total_shields -= 19;
+			W_DrawImage(baseWin, WINWIDTH - 20 * shieldcount, 0, 0, shieldImage, W_Cyan);
+		}
+		while (total_shields < 0) {
+			int column;
+			column = WINWIDTH - 20 * shieldcount - total_shields++;
+			W_MakeLine(baseWin, column, 0, column, 20, W_Black);
+			W_MakeLine(baseWin, column - 1, 0, column - 1, 20, W_Black);
+		}
+       	    }
+#endif /* SHOW_SHIELD_BAR */
+
+
     }
     if(starspeed != 1) {
         char buf[20];
+#ifndef ORIGINAL_XGALAGA
+	int y;
+#endif
     
         drewlevel = 1;
         sprintf(buf, "LEVEL %d", level+1);
-        W_MaskText(baseWin, WINWIDTH/2 - (W_StringWidth(buf, W_BigFont)/2), WINHEIGHT/2-W_BigTextheight/2,
-                   W_Red, buf, strlen(buf), W_BigFont);
+#ifndef ORIGINAL_XGALAGA
+	y = WINHEIGHT/2-W_BigTextheight/2;
+#endif
+        W_MaskText(baseWin, WINWIDTH/2 - (W_StringWidth(buf, W_BigFont)/2), WINHEIGHT/2-W_BigTextheight/2, W_Red, buf, strlen(buf), W_BigFont);
+#ifndef ORIGINAL_XGALAGA
+	if (shots > 0) {
+		int x = WINWIDTH/2 - 14 * W_Textwidth;
+		y += W_BigTextheight + 20;
+	
+		sprintf(buf, "Torps: %d  Hits: %d", shots, hits);
+		W_MaskText(baseWin, x, y, W_Yellow, buf, strlen(buf), W_RegularFont);
+	
+		x += 23 * W_Textwidth;
+		sprintf(buf, "(%d%%)", 100 * hits / shots);
+		W_MaskText(baseWin, x, y, W_Green, buf, strlen(buf), W_RegularFont);
+	}
+#endif
     }
 }
 
@@ -424,8 +478,8 @@
         if(convoyx <= 0) {
             convoyx=0;
             convoymove = -convoymove;
-        } else if(convoyx >= WINWIDTH/2) {
-            convoyx = WINWIDTH/2;
+        } else if(convoyx >= (WINWIDTH-180)) {
+            convoyx = WINWIDTH - 180;
             convoymove = -convoymove;
         }
     }
@@ -576,7 +630,7 @@
             }
         }
     }
-    if(livecount == 0) {
+    if(livecount == 0 && !paused) {
         starspeed++;
 #ifdef SOUND
         if(starspeed == 2)
@@ -769,10 +823,13 @@
                      playerShip->width, h);
 }
 
-static void do_player()
+static void do_player(mx, my, but)
+int mx, my, but;
 {
-    int mx, my, but;
     static int torpok;
+#ifdef ENABLE_MACHINE_GUN
+    static int shotside = 0;
+#endif
     W_Event wev;
     static int keys = 0;
 
@@ -795,6 +852,14 @@
                 case 'm':
                     mouseControl = 2;
                     break;
+                case '\r'+256:
+                    W_ToggleFullscreen(shellWin);
+                    fullscreen = !fullscreen;
+                    if (fullscreen)
+                        W_BlankCursor(baseWin);
+                    else
+                        W_RevertCursor(baseWin);
+                    break;
 		default:
 		    break;
                 }
@@ -809,6 +874,12 @@
                     weapon = 0;
                     movespeed = MINSPEED;
                     ships=2;
+#ifdef ACTIVATED_SHIELD
+		    shieldsleft = STARTSHIELDS;
+		    shieldon = 0;
+#else
+		    shieldsleft = 0;
+#endif
                     level=startLevel;  /* change made here */
                     init_aliens(level);
                     gotlemon = 0;
@@ -819,6 +890,10 @@
                     W_ClearWindow(baseWin);
                 }
                 break;
+            case W_EV_EXPOSE:
+	    	if (wev.Window == shellWin)
+		    draw_score();
+		break;
             }
         }
         return;
@@ -839,6 +914,13 @@
             case ' ':
                 keys &= ~(FIREKEY);
                 break;
+#ifdef ACTIVATED_SHIELD
+	    case 'x':
+		shieldsleft += plshield;
+		plshield = 0;
+		shieldon = 0;
+		break;
+#endif
             }
             break;
         case W_EV_KEY:
@@ -860,8 +942,15 @@
                 mouseControl = 1;
                 W_GrabPointer(baseWin);
                 break;
+#ifdef ACTIVATED_SHIELD
+	    case 'x':
+		plshield += shieldsleft;
+		shieldsleft = 0;
+		shieldon = 1;
+		break;
+#endif
             case 'q':
-                if(!pldead) {
+                if(!pldead  && !paused) {
                     new_explosion(plx, WINHEIGHT - ((playerShip->height)/2), 2);
                     ships = 0;
                     pldead = 1;
@@ -924,20 +1013,29 @@
                     maxtorps = MINTORPS;
                 break;
 #endif /* IM_A_BIG_FAT_CHEATER */
+            case '\r'+256:
+                W_ToggleFullscreen(shellWin);
+                fullscreen = !fullscreen;
+                if (fullscreen)
+                    W_BlankCursor(baseWin);
+                else
+                    W_RevertCursor(baseWin);
+                break;
             default:
                 break;
             }
+        case W_EV_EXPOSE:
+	    if (wev.Window == shellWin)
+	    	draw_score();
+	    break;
         }
     }
 
     if(!paused) {
         torpok--;
 
-	W_GetMouse(baseWin, &mx, &my, &but);
-        if(!mouseControl) {
-	    /*            W_GetMouse(baseWin, &mx, &my, &but);
-        } else {
-	*/
+        if((!mouseControl && ! js_device) ||
+	   (js_device && mx == plx && but == 0)) {
             if(keys & LEFTKEY)
                 mx = 0;
             else if(keys & RIGHTKEY)
@@ -966,10 +1064,51 @@
 #endif
                     }
                 } else {
+#ifdef DISABLE_RESET_ON_DEATH
+                    ships--;
+                    maxtorps--;
+                    if (maxtorps < MINTORPS)
+                    	maxtorps = MINTORPS;
+                    switch (weapon)
+                    {
+                    	case SINGLESHOT:
+                    		if (maxtorps < 3)
+                    		{
+                    			maxtorps = 3;
+                    			weapon = SINGLESHOT;
+                    		}
+                    		break;
+                    	case DOUBLESHOT:
+	                    	if (maxtorps < 4)
+                    		{
+                    			maxtorps = 4;
+                    		}
+        					break;
+                   		case SPREADSHOT:
+                    		if (maxtorps < 5)
+                    		{
+                    			maxtorps = 5;
+                    		}
+                    		break;
+						case TRIPLESHOT:
+							if (maxtorps < 6)
+                    		{
+                    			maxtorps = 6;
+                    		}
+                    		break;
+                    	case MACHINEGUN:
+                    		if (maxtorps < 3)
+                    		{
+                    			maxtorps = 3;
+                    		}
+                    		break;
+		}
+#else
                     ships--;
                     maxtorps = MINTORPS;
                     weapon = 0;
                     movespeed = MINSPEED;
+#endif /* DISABLE_RESET_ON_DEATH */
                     pldead = 0;
                     plflash = 50;
                     plx = WINWIDTH/2;
@@ -983,11 +1122,13 @@
             case SINGLESHOT:
                 if(numtorps < maxtorps)
                     new_torp(plx, WINHEIGHT - playerShip->height, 0, -TORPSPEED);
+		    torpok = TORPDELAY;
                 break;
             case DOUBLESHOT:
                 if(numtorps < maxtorps-1) {
                     new_torp(plx-5, WINHEIGHT - playerShip->height, 0, -TORPSPEED);
                     new_torp(plx+5, WINHEIGHT - playerShip->height, 0, -TORPSPEED);
+		    torpok = TORPDELAY;
                 }
                 break;
             case TRIPLESHOT:
@@ -995,11 +1136,62 @@
                     new_torp(plx-5, WINHEIGHT - playerShip->height, -2, 1-TORPSPEED);
                     new_torp(plx,   WINHEIGHT - playerShip->height, 0,   -TORPSPEED);
                     new_torp(plx+5, WINHEIGHT - playerShip->height, 2, 1-TORPSPEED);
+		    torpok = TORPDELAY;
                 }
                 break;
-            }
-            torpok = TORPDELAY;
-        }
+#ifdef ENABLE_SPREAD_SHOT
+            case SPREADSHOT:
+            	if (numtorps == 0)
+                {
+			if ((maxtorps % 2) == 1)
+				new_torp(plx, WINHEIGHT - playerShip->height, 0, -TORPSPEED*1.15);
+			else
+			{
+				new_torp(plx - 5, WINHEIGHT - playerShip->height, 0, -TORPSPEED*1.15);
+				new_torp(plx + 5, WINHEIGHT - playerShip->height, 0, -TORPSPEED*1.15);
+			}
+			if (maxtorps > 2)
+			{
+				new_torp(plx, WINHEIGHT - playerShip->height - 15, -2, -TORPSPEED*1.15);
+				new_torp(plx, WINHEIGHT - playerShip->height - 15, 2, -TORPSPEED*1.15);
+			}
+			if (maxtorps > 4)
+			{
+				new_torp(plx, WINHEIGHT - playerShip->height - 25, -4, -TORPSPEED*1.15);
+				new_torp(plx, WINHEIGHT - playerShip->height - 25, 4, -TORPSPEED*1.15);
+			}
+			if (maxtorps > 6)
+			{
+				new_torp(plx, WINHEIGHT - playerShip->height - 35, -6, -TORPSPEED*1.15);
+				new_torp(plx, WINHEIGHT - playerShip->height - 35, 6, -TORPSPEED*1.15);
+			}
+			if (maxtorps > 8)
+			{
+				new_torp(plx, WINHEIGHT - playerShip->height - 50, -8, -TORPSPEED*1.15);    
+				new_torp(plx, WINHEIGHT - playerShip->height - 50, 8, -TORPSPEED*1.15);
+			}
+			if (maxtorps > 10)
+			{
+				new_torp(plx, WINHEIGHT - playerShip->height - 60, -10, -TORPSPEED*1.15);
+				new_torp(plx, WINHEIGHT - playerShip->height - 60, 10, -TORPSPEED*1.15);
+                        }
+                        torpok = TORPDELAY;
+                 }
+		 break;
+#endif /* ENABLE_SPREAD_SHOT */
+#ifdef ENABLE_MACHINE_GUN
+            case MACHINEGUN:
+                 if(numtorps < maxtorps)
+                 {
+			shotside = (shotside == -15) ? 15 : -15;
+			new_torp(plx + shotside, WINHEIGHT - playerShip->height, 0, -TORPSPEED * 1.3);
+			torpok = TORPDELAY - 2;
+		}
+		break;
+#endif /* ENABLE_MACHINE_GUN */
+	    }
+	}
+
 
         if(!but)
             torpok=0;
@@ -1008,11 +1200,20 @@
             plx+=movespeed;
         else if((mx/movespeed) < (plx/movespeed))
             plx-=movespeed;
+#ifdef ENABLE_SHIP_WRAP
+
+        if(plx < 10)
+        	plx=WINWIDTH - 10;
+        if(plx > WINWIDTH - 10)
+			plx=10;
+#else
+  
     
         if(plx < playerShip->width/2)
             plx=playerShip->width/2;
         if(plx> WINWIDTH - playerShip->width/2)
             plx=WINWIDTH - playerShip->width/2;
+#endif
     
         if(plflash > 0)
             plflash--;
@@ -1024,7 +1225,7 @@
             W_DrawImage(baseWin, plx-(shieldImage->width/2), WINHEIGHT - shieldImage->height - 3, 0, shieldImage,
                         W_Cyan);
         }
-    } else { /* paused */
+    } else if (!pldead) { /* paused */
         W_DrawImage(baseWin, plx-(playerShip->width/2), WINHEIGHT - playerShip->height, counter, playerShip, W_Red);
     }
 }
@@ -1036,12 +1237,12 @@
 {
     int ac;
     char *dpyname = 0;
-    struct timeval tv, otv;
-    long ut;
+    int mx, my, but;
+    int start_fullscreen = 1;
    
-    gettimeofday(&otv, 0);
     for(ac = 1; ac < argc; ac++) {
         if(*argv[ac] == '-') {
+            int w, h;
             if(strcmp(argv[ac], "-scores") == 0) {
                 print_scores();
                 exit(0);
@@ -1049,10 +1250,8 @@
             if(strcmp(argv[ac], "-display") == 0 && (ac+1 < argc)) {
                 dpyname = argv[ac+1];
                 ac++;
-#if 0
             } else if (strcmp(argv[ac], "-b") == 0) {
                 useBuffered = !useBuffered;
-#endif
             } else if (strcmp(argv[ac], "-keyboard") == 0) {
                 mouseControl = 0;
             } else if (strcmp(argv[ac], "-mouse") == 0) {
@@ -1066,6 +1265,18 @@
                        && atoi(argv[ac+1]) >= 1) {
                 startLevel = atoi(argv[ac+1]);
                 ac++;
+            } else if (strcmp(argv[ac], "-nostars") == 0) {
+                wantStars = 0;
+            } else if (strcmp(argv[ac], "-nouseor") == 0) {
+                useOR = 0;
+            } else if (strcmp(argv[ac], "-noclipmask") == 0) {
+                useClipMask = 0;
+            } else if (strcmp(argv[ac], "-window") == 0) {
+                start_fullscreen = 0;
+            } else if ((strcmp(argv[ac], "-winsize") == 0) && (++ac < argc) &&
+                       (sscanf(argv[ac], "%dx%d", &w, &h) == 2)) {
+                WINWIDTH  = w;
+                WINHEIGHT = h;
             } else {
                 print_usage();
                 exit(0);
@@ -1079,8 +1290,18 @@
     W_Initialize(dpyname);
 
     backColor = W_Black;
-    baseWin = W_MakeWindow("XGalaga", 0, 0, WINWIDTH, WINHEIGHT, 0, "tiny", 0, W_White);
+    WINHEIGHT -= (W_Textheight+1);
+    shellWin = W_MakeWindow("XGalaga", 0, 0, WINWIDTH, WINHEIGHT + W_Textheight+1, 0, "tiny", 0, W_White);
+    baseWin = W_MakeWindow("", 0, W_Textheight+1, WINWIDTH, WINHEIGHT, shellWin, "tiny", 0, W_White);
+    W_Buffer(shellWin, 0);
+    W_MapWindow(shellWin);
     W_MapWindow(baseWin);
+    if (start_fullscreen)
+    {
+      W_ToggleFullscreen(shellWin);
+      W_BlankCursor(baseWin);
+      fullscreen = 1;
+    }
 
     /*    W_AutoRepeatOff();*/
 
@@ -1106,59 +1327,62 @@
     init_sound();
 #endif
     init_aliens(level);
+    init_framerate();
+#ifdef __linux__
+    init_joystick();
+#endif
 
     ships = 2;
     nextBonus = 20000;
 
     while(1) {
         counter++;
-        if(gameOver && getting_name)
-            undo_name();
 
-        undo_score();
+	/* For the benefit of unbuffered mode, the most important things are
+	 * erased/redrawn closest together so they spend the least time blanked.
+	 * player, aliens and etorps are most important for game play.
+	 * pause, title and name are important in their modes and aren't done
+	 * otherwise.
+	 *
+	 * The title, name, pause and score "extra ship" want to overlay
+	 * everything else drawn, so they come last.
+	 */
+	undo_stars();
         undo_explosions();
-        undo_stars();
-        undo_aliens();
         undo_prizes();
-        undo_etorps();
         undo_torps();
+        undo_etorps();
+        undo_aliens();
         undo_player();
-
-        if(paused)
-            undo_pause();
+        if(gameOver && getting_name) undo_name();
+        if(paused) undo_pause();
+        undo_score();
 
         W_FlushClearAreaCache(baseWin);
 
-        if(paused)
-            do_pause();
-
-        do_stars();
-        do_player();
-        do_torps();
         do_etorps();
-        do_prizes();
+        do_player(mx, my, but);
         do_aliens();
+        do_torps();
+        do_prizes();
         do_explosions();
+ 	do_stars();
         do_score();
-        if(gameOver) {
-            do_title();
-            if(getting_name)
-                do_name();
-        }
+        if(gameOver) { do_title(); if(getting_name) do_name(); }
+        if(paused) do_pause();
+
         W_DisplayBuffer(baseWin);
-        W_Flush();
-        gettimeofday(&tv, 0);
-        if(tv.tv_sec > otv.tv_sec)
-            tv.tv_usec += (tv.tv_sec - otv.tv_sec) * 1000000;
-        ut = tv.tv_usec - otv.tv_usec;
-        if(UTIMER - ut > 0) {
-            struct timeval tv;
-            unsigned long usecs = UTIMER - ut;
-            tv.tv_sec  = usecs / 1000000L;
-            tv.tv_usec = usecs % 1000000L;
-            (void) select (0, 0, 0, 0, &tv);
-	}
 
-        gettimeofday(&otv, 0);
+	/* This is an XSync style round trip to the server with the bonus of
+	 * getting the mouse position.
+	 * If the server can't draw at the UTIMER frame rate then this will be
+	 * the only delay in the loop.
+	 */
+	W_GetMouse(baseWin, &mx, &my, &but);
+#ifdef __linux__
+	do_joystick(&mx, &my, &but);
+#endif
+
+        do_framerate();
     }
 }
--- xgalaga-2.0.34.orig/xgal.sndsrv.linux.c
+++ xgalaga-2.0.34/xgal.sndsrv.linux.c
@@ -1,7 +1,7 @@
 /*
  * xgal.sndsrv.c - VoxWare(tm) Compatible Sound - Apr. 1995
  *                 PC Speaker  Compatible Sound 
- *                 This server is Linux Specific.
+ *                 This server is OSS Specific.
  *
  * Copyright 1994-1995 Sujal M. Patel (smpatel@wam.umd.edu)
  * Conditions in "copyright.h"
@@ -10,13 +10,14 @@
 /* $Id: xgal.sndsrv.linux.c,v 1.3 1998/05/11 06:37:20 mrogre Exp $ */
 #include <config.h>
 
+#include <time.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
-#include <linux/soundcard.h>
-/*#include "linux_pcsp.h"      /* /usr/include/linux/pcsp.h      */
+#include <sys/soundcard.h>
+/*#include "linux_pcsp.h"       /usr/include/linux/pcsp.h      */
 #include <sys/time.h>
 #include <signal.h>
 #include <string.h>
@@ -38,7 +39,7 @@
 
 #define NUM_SOUNDS	(sizeof(FILENAME)/sizeof(char*))
 
-signed char *sound_buffer[NUM_SOUNDS];
+char *sound_buffer[NUM_SOUNDS];
 int sound_size[NUM_SOUNDS];
 int fragsize;
 
@@ -55,7 +56,7 @@
 {
   int i;
   char s[1024];
-
+  
   if (argc != 3)
   {
     printf ("This program is only executed by xgal\n");
@@ -74,7 +75,7 @@
     sound_size[i]=0;
   }
 
-  signal(SIGTERM, quit);   /* Setup Terminate Signal Handler */
+  signal(SIGTERM, quit);  /* Setup Terminate Signal Handler */
 }
 
 
@@ -136,17 +137,6 @@
   return dsp;
 }
 
-/*
-   This just keeps the pipe from breaking...
-   Eventually I'll look at the xgal signal handlers and
-   just trap this.
-*/
-int do_nothing(void)
-{
-    fprintf(stderr,"xgal.sndsrv: Sound not available\n");
-    while(1)  sleep (5);
-}
-
 int read_sound(int k)
 {
   int i,fd,size;
@@ -171,10 +161,12 @@
     return(0);
   };
   lseek(fd,0,SEEK_SET);
-  read(fd,sound_buffer[k],size);
+  size = read(fd,sound_buffer[k],size);
   close(fd);
-  for(i=0;i<size;i++)  sound_buffer[k][i]^=0x80;
-  memset(sound_buffer[k]+size,0,sound_size[k]*fragsize-size);
+  if (size) {
+    for(i=0;i<size;i++)  sound_buffer[k][i]^=0x80;
+    memset(sound_buffer[k]+size,0,sound_size[k]*fragsize-size);
+  }
   
   /*fprintf(stderr,"sound has been loaded, %d bytes\n",size);*/ /*DEBUG*/
   return(1);
@@ -183,14 +175,14 @@
 
 void do_everything (int dsp, int is_pcsp)
 {
-  char k;
+  signed char k;
   int i, j ;
   int terminate = -1;             /* Which Sound to Terminate                              */
   int playing[16];                /* Sound numbers that we are playing                     */
   int position[16];		  /* Current position in each sound file */
   int playnum = 0;                /* Number of sounds currently being played               */
-  unsigned char final[512];       /* Final Mixing Buffer                                   */
-  int premix[512];
+  unsigned char final[fragsize];       /* Final Mixing Buffer                                   */
+  int premix[fragsize];           /* Use fragsize in case sound card sets it big. -- JEH */
   char *sample;
 
   for(;;)  {
@@ -249,7 +241,7 @@
         */
         memset(final,128,sizeof(final));
     };
-    write (dsp, final, fragsize);
+    i = write (dsp, final, fragsize);
     /*
        The sound server is in a tight loop, EXCEPT for this
        write which blocks.  Any optimizations in the above
@@ -261,7 +253,7 @@
 
 
 
-void main (argc, argv)
+int main (argc, argv)
 int argc;
 char **argv;
 {
@@ -271,7 +263,8 @@
   init (argc, argv);
   dsp = setup_dsp (argv[2],&is_pcsp);
 
-  if (dsp<0) do_nothing();
-
+  if (dsp<0) exit(1);
+  
   do_everything (dsp, is_pcsp);
+  return 0;
 }
--- xgalaga-2.0.34.orig/nas_sound.c
+++ xgalaga-2.0.34/nas_sound.c
@@ -60,6 +60,10 @@
     int         i;
     char       *displayname = XDisplayString(W_Display);
 
+    /* Do not initialize sound if it is not going to be used -- JEH */
+    if (!playSounds)
+	    return;
+    
     if(unixSoundPath[0] == '?')  {
 	return;
     };
--- xgalaga-2.0.34.orig/pathfile.c
+++ xgalaga-2.0.34/pathfile.c
@@ -319,9 +319,18 @@
     sprintf(filename, "%s/level%d.xgl", real_level_path, lev);
     lf = fopen(filename, "r");
     if(!lf) {
+	/* Dont use recursion, to avoid stack overflow if start level is
+	 * very high (or the game is played for a _very_ long time. :-) 
+	 * -- JEH */
+	for (lev = lev - maxLevel; lev > 0 && ! lf ;lev = lev - maxLevel) {
+		metaLevel++;
+		/* real_level_path is already set, so.. */
+		sprintf(filename, "%s/level%d.xgl", real_level_path, lev);
+		lf = fopen(filename, "r");
+	}
+	
         //fprintf(stderr, "Can't open level file %s\n", filename);
-	metaLevel++;
-	return read_level(lev - maxLevel);
+	//return read_level(lev - maxLevel);
     }
 
     if(lev > maxLevel)
@@ -378,8 +387,8 @@
 
 void get_xy(int anum, int* x, int* y)
 {
-    *x = pathinfo[al_paths[anum]].startx;
-    *y = pathinfo[al_paths[anum]].starty;
+    *x = (WINWIDTH  * pathinfo[al_paths[anum]].startx) / 400;
+    *y = (WINHEIGHT * pathinfo[al_paths[anum]].starty) / 500;
 }
 
 int get_delay(int anum)
--- xgalaga-2.0.34.orig/paths.c
+++ xgalaga-2.0.34/paths.c
@@ -159,6 +159,8 @@
     { 6,80, -1,-1, },
 };	
 
+/* These aren't used anymore! (see filepath.c) Maybe we should nuke them? */
+#if 0
 /* enter_paths are for new ships.  consists of starting co-ordinates, number of frames
    to wait at the start (presumably offscreen) and a path to follow.
    path -1 means this ship is not used on this level
@@ -1159,6 +1161,8 @@
     },
 };
 
+#endif /* This isn't used anymore! Maybe we should nuke it */
+
 void path_dir(int path, int pos, int *dir, int *steer)
 {
     *dir =   paths[path][pos][0];
@@ -1197,8 +1201,6 @@
 
 void new_alien(int level, int anum, struct alien *al)
 {
-    int l = (level-1) % NUMLEVELS;
-
     if(get_shape(anum) >= 0) {
 	al->alive = 1;
 	al->dying = 0;
--- xgalaga-2.0.34.orig/prize.c
+++ xgalaga-2.0.34/prize.c
@@ -20,7 +20,27 @@
 #define PR_SMART 5
 #define PR_LEMON 6
 #define PR_EXTRABULLET 7
-#define NUMPRIZES 8
+
+#ifdef ENABLE_SPREAD_SHOT
+#define PR_SPREAD 8
+#endif
+
+#ifdef ENABLE_MACHINE_GUN
+# ifdef ENABLE_SPREAD_SHOT
+#  define PR_MACHINE 9
+#  define NUMPRIZES 10
+# else
+#  define PR_MACHINE 8
+#  define NUMPRIZES 9
+# endif /* ENABLE_SPREAD_SHOT */
+#else
+# ifdef ENABLE_SPREAD_SHOT
+#  define PR_SPREAD 8
+#  define NUMPRIZES 9
+# else
+#  define NUMPRIZES 8
+# endif /* ENABLE_SPREAD_SHOT */
+#endif /* ENABLE_MACHINE_GUN */
 
 #define PRIZESPEED 3
 
@@ -41,6 +61,13 @@
     prizeImages[5] = getImage(I_PR_BRAIN);
     prizeImages[6] = getImage(I_PR_LEMON);
     prizeImages[7] = getImage(I_PR_EXTRABULLET);
+#ifdef ENABLE_SPREAD_SHOT
+    prizeImages[8] = getImage(I_PR_SPREAD);
+#endif
+
+#ifdef ENABLE_MACHINE_GUN
+    prizeImages[NUMPRIZES - 1] = getImage(I_PR_MACHINE);
+#endif 
 }
     
 void new_prize(int x, int y)
@@ -97,7 +124,11 @@
 		    p->x-prizeImages[p->type]->width/2, p->y-prizeImages[p->type]->width/2,
 		    0, prizeImages[p->type], W_Green);
 
-	if(p->y > (WINHEIGHT-20) && (ABS(p->x - plx) < 15)) {
+	if(p->y > (WINHEIGHT-20) && (ABS(p->x - plx) < 15)
+#ifdef NO_PRIZE_WHILE_DEAD
+		&& !pldead
+#endif
+	  ) {
 	    p->dying = 1;
 #ifdef SOUND
 	    play_sound(SND_DDLOO);
@@ -131,11 +162,51 @@
 		if(movespeed < MAXSPEED)
 		    movespeed++;
 		break;
+#ifdef ENABLE_SPREAD_SHOT
+              case PR_SPREAD:
+                if (weapon == SPREADSHOT)
+                    maxtorps++;
+                else {
+                    weapon = SPREADSHOT;
+                    if (maxtorps < 5)
+                       maxtorps = 5;
+		}
+		break;
+#endif /* ENABLE_SPREAD_SHOT */
+#ifdef ENABLE_MACHINE_GUN
+              case PR_MACHINE:
+                if (weapon == MACHINEGUN)
+                   maxtorps++;
+                else {
+                   weapon = MACHINEGUN;
+                   if (maxtorps < 3)
+                      maxtorps = 3;
+                }
+                break;
+#endif /* ENABLE_MACHINE_GUN */
 	      case PR_SHIELD:
+#ifdef ACTIVATED_SHIELD
+		if (shieldon)
+		  plshield += SHIELDTIME;
+		else
+		  shieldsleft += SHIELDTIME;
+		  if (shieldsleft + plshield > MAXSHIELDS)
+		  {
+			if (shieldon)
+			{
+				shieldsleft = 0;
+				plshield = MAXSHIELDS;
+			} else {
+				shieldsleft = MAXSHIELDS;
+				plshield = 0;
+			}
+		  }
+#else
 		plshield = SHIELDTIME;
 #ifdef SOUND
 		play_sound(SND_SHIELD);
-#endif
+#endif /* SOUND */
+#endif /* ACTIVATED_SHIELD */
 		break;
 	      case PR_SMART:
 #ifdef SOUND
--- xgalaga-2.0.34.orig/proto.h
+++ xgalaga-2.0.34/proto.h
@@ -1,3 +1,5 @@
+#include <string.h>
+
 /* main.c */
 void xgal_exit(int v);
 int main(int argc, char **argv);
@@ -27,6 +29,7 @@
 /* score.c */
 void undo_score(void);
 void do_score(void);
+void draw_score(void);
 void init_score(void);
 /* highscore.c */
 void undo_name(void);
@@ -57,3 +60,9 @@
 int get_duration(int, int);
 int get_shape(int);
 int read_level(int);
+/* frate.c */
+void init_framerate(void);
+void do_framerate(void);
+/* linux-joystick.c */
+void init_joystick(void);
+void do_joystick(int* x, int* y, int* but);
--- xgalaga-2.0.34.orig/score.c
+++ xgalaga-2.0.34/score.c
@@ -17,13 +17,6 @@
 
 void undo_score()
 {
-    int basex;
-
-    basex = WINWIDTH/2 - ((strlen(scorestr)/2)*W_Textwidth);
-    W_ClearArea(baseWin, basex, 0, strlen(scorestr) * W_Textwidth + 1, W_Textheight + 1);
-    W_ClearArea(baseWin, 0, 0, (miniship->width+2)*6, miniship->height);
-    basex = 6*(miniship->width+2) + 2;
-    W_ClearArea(baseWin, basex, 0, strlen(shipstr) * W_Textwidth + 1, W_Textheight + 1);
     if(drawExtra)
 	W_ClearArea(baseWin, extrax-(extraImage->width/2), extray-(extraImage->height/2), 
 		    extraImage->width, extraImage->height);
@@ -31,24 +24,8 @@
 
 void do_score()
 {
-    int basex;
-    int i;
-    static int lastscore;
+    static int lastscore, lastlevel, lastships;
 
-    sprintf(scorestr, "Score: %07d     Level: %02d", score, level);
-    basex = WINWIDTH/2 - ((strlen(scorestr)/2)*W_Textwidth);
-    W_MaskText(baseWin, basex, 1, W_Grey, scorestr, strlen(scorestr), W_RegularFont);
-    W_MaskText(baseWin, basex+1, 0, W_Yellow, scorestr, strlen(scorestr), W_RegularFont);
-
-    for(i=0;i<((ships < 6) ? ships : 6);i++) {
-	W_DrawImage(baseWin, i*(miniship->width+2), 0, 0, miniship, W_White);
-    }
-    if(ships>6) {
-	sprintf(shipstr, "%d", ships);
-	basex = 6*(miniship->width+2) + 2;
-	W_MaskText(baseWin, basex, 1, W_Grey, shipstr, strlen(shipstr), W_RegularFont);
-	W_MaskText(baseWin, basex+1, 0, W_Yellow, shipstr, strlen(shipstr), W_RegularFont);
-    }
     if(lastscore != score) {
 	if((score > 0) && (score >= nextBonus)) {
 	    ships++;
@@ -60,8 +37,16 @@
 	    else
 		nextBonus += BONUSSHIPSCORE;
 	}
+    }
+
+    if(lastscore != score || lastlevel != level || lastships != ships) {
+    	W_ClearArea(shellWin, 0, 0, WINWIDTH, W_Textheight + 1);
+	draw_score();
 	lastscore=score;
+	lastlevel=level;
+	lastships=ships;
     }
+
     if(drawExtra) {
 	extrax += 10;
 	W_DrawImage(baseWin, extrax-(extraImage->width/2), extray-(extraImage->height/2), 0, extraImage, W_White);
@@ -70,6 +55,29 @@
     }
 }
 
+void draw_score()
+{
+    int basex;
+    int i;
+
+    sprintf(scorestr, "Score: %07d     Level: %02d", score, level);
+
+    basex = WINWIDTH/2 - ((strlen(scorestr)/2)*W_Textwidth);
+    W_MaskText(shellWin, basex, 1, W_Grey, scorestr, strlen(scorestr), W_RegularFont);
+    W_MaskText(shellWin, basex+1, 0, W_Yellow, scorestr, strlen(scorestr), W_RegularFont);
+
+    for(i=0;i<((ships < 6) ? ships : 6);i++) {
+	W_DrawImage(shellWin, i*(miniship->width+2), 0, 0, miniship, W_White);
+    }
+
+    if(ships>6) {
+	sprintf(shipstr, "%d", ships);
+	basex = 6*(miniship->width+2) + 2;
+	W_MaskText(shellWin, basex, 1, W_Grey, shipstr, strlen(shipstr), W_RegularFont);
+	W_MaskText(shellWin, basex+1, 0, W_Yellow, shipstr, strlen(shipstr), W_RegularFont);
+    }
+}
+
 void init_score()
 {
     miniship = getImage(I_MINISHIP);
--- xgalaga-2.0.34.orig/sound.c
+++ xgalaga-2.0.34/sound.c
@@ -40,6 +40,11 @@
   char *argv[4];
   char filename[512];
 
+
+  /* Do not initialize sound if it is not going to be used -- JEH */
+  if (! playSounds)
+	  return;
+  
   signal(SIGCHLD, SIG_IGN);
 
   if(unixSoundPath[0] == '?')  {
@@ -49,7 +54,10 @@
 
   /*  Create a pipe, set the write end to close when we exec the sound server,
       and set both (is the write end necessary?) ends to non-blocking   */
-  pipe(fd);
+  if (pipe(fd)) {
+      audioOK = 0;
+      return;
+  }
   soundfd=fd[1];
 
   if( !(child=fork()) )  {
@@ -83,7 +91,9 @@
   char c;
 
   c = k;
-  if ((playSounds) && (audioOK)) write (soundfd, &c, sizeof (c));
+  if ((playSounds) && (audioOK))
+    if(write (soundfd, &c, sizeof (c)) != sizeof (c))
+      audioOK = 0;
 }
 
 
@@ -98,7 +108,9 @@
   sound_flags[k] |= 1;
 
   c = (unsigned char)(k);
-  if ((playSounds) && (audioOK)) write (soundfd, &c, sizeof (c));
+  if ((playSounds) && (audioOK))
+    if(write (soundfd, &c, sizeof (c)) != sizeof (c))
+      audioOK = 0;
 }
 
 
@@ -116,7 +128,9 @@
   char c;
 
   c = -1;               
-  if ((playSounds) && (audioOK)) write (soundfd, &c, sizeof (c));
+  if ((playSounds) && (audioOK))
+    if(write (soundfd, &c, sizeof (c)) != sizeof (c))
+      audioOK = 0;
 }
 
 #endif /* SOUND */
--- xgalaga-2.0.34.orig/struct.h
+++ xgalaga-2.0.34/struct.h
@@ -1,3 +1,6 @@
+#ifndef STRUCT_H
+#define STRUCT_H
+
 #include "Wlib.h"
 
 struct torp {
@@ -38,3 +41,10 @@
     int count;
     W_Image *shape;
 };
+
+struct js_state {
+    signed short but;
+    signed long dir;
+};
+
+#endif
--- xgalaga-2.0.34.orig/title.c
+++ xgalaga-2.0.34/title.c
@@ -73,7 +73,7 @@
 
 static void show_help()
 {
-    int top = 220;
+    int top = 270;
 
     center_text("         Keyboard controls           ", top, W_Red);
     center_text("  left/right arrow   move            ", top+10, W_Yellow);
@@ -83,12 +83,15 @@
     center_text("  Q                  quick quit      ", top+50, W_Cyan);
     center_text("  k                  keyboard control", top+60, W_Cyan);
     center_text("  m                  mouse control   ", top+70, W_Cyan);
+#ifndef ORIGINAL_XGALAGA
+    center_text("  x                  toggle shields  ", top+80, W_Cyan);
+#endif
 #ifdef SOUND
-    center_text("  s                  toggle sound    ", top+80, W_Cyan);
+    center_text("  s                  toggle sound    ", top+90, W_Cyan);
 #endif
 	  
-    center_text("Bonus ships at 20,000, 50,000, then every 50,000.", top+100, W_Green);
-    center_text("XGalaga Home page: http://ogresoft.dyn.ml.org/xgalaga.html",
+    center_text("Bonus ships at 20,000, 50,000, then every 50,000.", top+120, W_Green);
+    center_text("XGalaga Home page: http://rumsey.org/xgal.html",
 		top+150, W_Cyan);
 }
 void do_title()
@@ -107,7 +110,12 @@
       case 0:
 	center_text("Copyright (c) 1995-1998   Joe Rumsey", ty, W_Green); ty+= W_Textheight;
 	center_text("<mrogre@mediaone.net>", ty, W_Green); ty+= 2*W_Textheight;
-
+#ifndef ORIGINAL_XGALAGA
+	center_text("XGalaga: Hyperspace 0.9", ty, W_Green); ty+= W_Textheight;
+	center_text("Modifications by:", ty, W_Green); ty+= W_Textheight;
+	center_text("Bryce Wagner - John Strickland - David Enderson", ty, W_Green); ty+= 2*W_Textheight;
+#endif
+	
 	center_text("This game is free software, covered by the GPL", ty, W_Yellow); ty += W_Textheight;
 	center_text("If you enjoy it, visit http://www.gnu.org and help", ty, W_Yellow); ty+= W_Textheight;
 	center_text("support the Free Software Foundation", ty, W_Yellow);ty+= W_Textheight;
@@ -122,6 +130,11 @@
 	break;
     }
 
+#ifdef __linux__
+    if (js_device)
+	    center_text("Press k for keyboard or joystick control, m for mouse", WINHEIGHT - 2*W_Textheight, W_Yellow);
+    else /* no joystick, so use message below */
+#endif
     center_text("Press k for keyboard control, m for mouse", WINHEIGHT - 2*W_Textheight, W_Yellow);
     center_text("Or q to quit", WINHEIGHT - W_Textheight, W_Yellow);
     pagetimer--;
--- xgalaga-2.0.34.orig/xgal.6x
+++ xgalaga-2.0.34/xgal.6x
@@ -0,0 +1,91 @@
+.TH XGALAGA 6x "23 April 2003" "2.0.34"
+.SH NAME
+xgalaga \- X11 version of the famous Galaga game
+.SH SYNOPSIS
+.B xgalaga
+[-scores] [-display display] [-mouse] [-keyboard] [-nosound] [-b]
+[-window] [-winsize widthxheight] [-b] [-noclipmask] [-nouseor] [-nostars]
+.P
+.B xgalaga-hyperspace
+[-scores] [-display display] [-mouse] [-keyboard] [-nosound] [-b]
+[-window] [-winsize widthxheight] [-b] [-noclipmask] [-nouseor] [-nostars]
+.SH INSTRUCTIONS
+.LP
+It's Galaga, you know how to play Galaga, stop bothering me.
+(Ship follows the mouse, button fires.  Auto-fire by holding it
+down, so no-one accuses me of breaking their mouse!)
+.P
+The xgalaga-hyperspace version features some new weapons and different
+gameplay.
+.SH OPTIONS
+.TP 8
+.B \-scores
+Prints out the high score file and exits
+.TP 8
+.B \-display \fIhost:dpy\fP
+Set your display
+.TP 8
+.B \-mouse
+Use mouse control (same as 'm').
+.TP 8
+.B \-keyboard
+Use keyboard control (same as 'k').
+If you have a joystick it can also be used if you select keyboard control.
+.TP 8
+.B \-nosound
+Turn sound OFF
+.TP 8
+.B \-level \fIlvl\fP
+Choose starting level (>= 1)
+.TP 8
+.B \-window
+Run in a window, not full screen. Full screen is the default.
+.TP 8
+.B \-winsize \fIwidthxheight\fP
+Set windowsize, default 468x596.
+.TP 8
+.B \-b
+Turn buffered mode off, use this if it runs too slowly.  Will cause 
+flicker, maybe lots, maybe only a little.
+.TP 8
+.B \-noclipmask
+Don't use clip masks for drawing (affects unbuffered mode only).
+.TP 8
+.B \-nouseor
+Don't draw using OR mode.
+.TP 8
+.B \-nostars
+Don't draw stars in the background.
+.P
+Combinations of the last four options can be used to get faster
+drawing if the video card can't keep up with the required 30
+frames/sec.  The fastest drawing will come from
+.IP
+xgalaga -b -noclipmask -nouseor -nostars
+.SH KEYBOARD COMMANDS
+.TP 8
+p - pauses
+.TP 8
+q - end this game
+.TP 8
+b - Toggle buffering (flicker vs. speed.)
+.TP 8
+o - Toggle OR mode.  Don't use this, it sucks.
+.TP 8
+m - Use mouse control. Note that you may switch in mid-game.
+.TP 8
+k - Use keyboard control
+.TP 8
+x - use your shields (xgalaga-hyperspace only)
+.TP 8
+alt-enter - Toggle full screen node.
+.SH "SEE ALSO"
+Xgalaga home page
+.RI < http://rumsey.org/xgal.html >
+.SH AUTHORS
+Joe Rumsey, <\fIjoe@rumsey.org\fP> (Original author)
+.LP
+Vincent Renardias <\fIvincent@waw.com\fP> (man page)
+.LP
+Send bugs (or their reports, or fixes) here:
+.RI < http://www.debian.org/Bugs/ >.
--- xgalaga-2.0.34.orig/xgalaga-icon.xpm
+++ xgalaga-2.0.34/xgalaga-icon.xpm
@@ -0,0 +1,55 @@
+/* XPM */
+static char *xgalaga-icon[] = {
+/* columns rows colors chars-per-pixel */
+"32 32 17 1",
+"  c None",
+". c #191919",
+"X c #00007F",
+"o c #7F0000",
+"O c #7F7F00",
+"+ c #4C4C4C",
+"@ c gray50",
+"# c blue",
+"$ c green",
+"% c red",
+"& c yellow",
+"* c gray60",
+"= c #B2B2B2",
+"- c gray80",
+"; c gray90",
+": c gray100",
+"> c None",
+/* pixels */
+"                 O-O            ",
+"                 %o&            ",
+"        :       &O  O           ",
+"                                ",
+"                          $     ",
+"                                ",
+"                                ",
+"  .oO  O                        ",
+"    &%OO.                       ",
+"    O;o                         ",
+"   OOo%                         ",
+"  .O  O&       .                ",
+"              .o%o.             ",
+"              oOO%o             ",
+"             .%%XOO.            ",
+"             oOo%o%o            ",
+"               o;o.             ",
+"           @   @;@   @          ",
+"          +;+ .@-@  +;+      .  ",
+"          @;@ .@;*  @;@     OO  ",
+"          @;@@ @;@.@@-@   Oo%&  ",
+"          @;@--=;===@;@   .O-O  ",
+"      %   @;=@@@-*@@=-@    %O%O ",
+"          @;@@+@-@+@@;@   &Oo   ",
+"          @;@. *-*  @-*         ",
+"          +*+  +;+  +*+         ",
+"          X#X   @   X#X         ",
+"          X#X       X#X         ",
+"          X#X       X#X         ",
+"          XXX       XXX         ",
+"                                ",
+"                                "
+};
