summaryrefslogtreecommitdiff
path: root/games/quake/patches
diff options
context:
space:
mode:
authorwiz <wiz@pkgsrc.org>2000-02-01 02:30:29 +0000
committerwiz <wiz@pkgsrc.org>2000-02-01 02:30:29 +0000
commit4eb5e8ac6f755f486d4cade5e29c5176074d4f57 (patch)
tree313934adfc76b9f6e4fa635a0171b582ca797775 /games/quake/patches
parent08e833403e143dfa9357d623edda2a32c5401107 (diff)
downloadpkgsrc-4eb5e8ac6f755f486d4cade5e29c5176074d4f57.tar.gz
Quake now playable on NetBSD-1.4.x-i386. Heavily based on pkg/9270 by
Brad Spencer <brad@anduin.eldar.org>, with some modifications. Caveats: ELF builds fail; shareware WADs (level files) have to be gotten separately; playing audio from CDs seems to have problems (see pkg/9270); GLX Quakeworld client probably doesn't work; Quakeworld code perhaps triggers optimization bug? Committed mainly to avoid duplication of work, and for the 1.4.x/i386 users/gamers :-)
Diffstat (limited to 'games/quake/patches')
-rw-r--r--games/quake/patches/patch-aa636
-rw-r--r--games/quake/patches/patch-ab22
-rw-r--r--games/quake/patches/patch-ac49
-rw-r--r--games/quake/patches/patch-ad173
-rw-r--r--games/quake/patches/patch-ae114
-rw-r--r--games/quake/patches/patch-af13
-rw-r--r--games/quake/patches/patch-ag532
-rw-r--r--games/quake/patches/patch-ah14
-rw-r--r--games/quake/patches/patch-ai83
-rw-r--r--games/quake/patches/patch-aj167
-rw-r--r--games/quake/patches/patch-ak14
11 files changed, 1682 insertions, 135 deletions
diff --git a/games/quake/patches/patch-aa b/games/quake/patches/patch-aa
index 0c60d094de6..81f72f183a5 100644
--- a/games/quake/patches/patch-aa
+++ b/games/quake/patches/patch-aa
@@ -1,95 +1,547 @@
-$NetBSD: patch-aa,v 1.2 2000/01/13 00:35:05 wiz Exp $
+$NetBSD: patch-aa,v 1.3 2000/02/01 02:30:32 wiz Exp $
---- Makefile.Linux.orig Wed Apr 21 20:16:24 1999
-+++ Makefile.Linux Thu Jan 13 01:05:47 2000
-@@ -27,8 +27,6 @@
- RPMARCH=i386
- endif
+--- QW/client/cd_linux.c Tue Dec 21 18:58:58 1999
++++ ../work/QW/client/cd_linux.c Sun Jan 16 19:56:16 2000
+@@ -10,7 +10,7 @@
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+-See the included (GNU.txt) GNU General Public License for more details.
++See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+@@ -31,7 +31,19 @@
+ #include <time.h>
+ #include <errno.h>
--MAINDIR=/grog/Projects/QW
++#ifdef __linux__
+ #include <linux/cdrom.h>
++#endif
++
++#ifdef __NetBSD__
++#include <sys/cdio.h>
++
++/* resume seems to have some trouble right now. xcdplayer also can not resume
++ the drive correctly. It appears to play, but no audio is heard */
++
++#define PAUSE_BY_STOPPING 1
++
++#endif
+
+ #include "quakedef.h"
+
+@@ -46,165 +58,289 @@
+ static byte playTrack;
+ static byte maxTrack;
+
++#ifdef PAUSE_BY_STOPPING
++static qboolean t_playLooping;
++static byte t_playTrack;
++#endif
++
+ static int cdfile = -1;
++#ifdef __linux__
+ static char cd_dev[64] = "/dev/cdrom";
++#endif
++
++#ifdef __NetBSD__
++static char cd_dev[64] = "/dev/rcd0d";
++#endif
+
+ static void CDAudio_Eject(void)
+ {
+- if (cdfile == -1 || !enabled)
+- return; // no cd init'd
++#ifdef __NetBSD__
++ int arg=0;
++#endif
+
+- if ( ioctl(cdfile, CDROMEJECT) == -1 )
+- Con_DPrintf("ioctl cdromeject failed\n");
++ if (cdfile == -1 || !enabled)
++ return; // no cd init'd
++
++#ifdef __linux__
++ if ( ioctl(cdfile, CDROMEJECT) == -1 )
++ Con_DPrintf("ioctl cdromeject failed\n");
++#endif
++#ifdef __NetBSD__
++ if(ioctl(cdfile, DIOCLOCK, &arg) == -1)
++ Con_DPrintf("ioctl cdromunlock failed\n");
++ arg = 1;
++ if ( ioctl(cdfile, DIOCEJECT, &arg) == -1 )
++ Con_DPrintf("ioctl cdromeject failed\n");
++#endif
+ }
+
+
+ static void CDAudio_CloseDoor(void)
+ {
+- if (cdfile == -1 || !enabled)
+- return; // no cd init'd
++if (cdfile == -1 || !enabled)
++ return; // no cd init'd
+
+- if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 )
+- Con_DPrintf("ioctl cdromclosetray failed\n");
++#ifdef __linux__
++ if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 )
++ Con_DPrintf("ioctl cdromclosetray failed\n");
++#endif
++#ifdef __NetBSD__
++ if(ioctl(cdfile, CDIOCCLOSE, NULL) == -1) {
++ Con_DPrintf("ioctl cdromclosetray failed\n");
++ }
++#endif
+ }
+
+ static int CDAudio_GetAudioDiskInfo(void)
+ {
+- struct cdrom_tochdr tochdr;
++#ifdef __linux__
++struct cdrom_tochdr tochdr;
++#endif
++#ifdef __NetBSD__
++struct ioc_toc_header tochdr;
++#endif
+
+- cdValid = false;
++cdValid = false;
+
+- if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 )
+- {
+- Con_DPrintf("ioctl cdromreadtochdr failed\n");
+- return -1;
+- }
++#ifdef __linux
++if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 )
++{
++ Con_DPrintf("ioctl cdromreadtochdr failed\n");
++ return -1;
++}
++#endif
+
+- if (tochdr.cdth_trk0 < 1)
+- {
+- Con_DPrintf("CDAudio: no music tracks\n");
+- return -1;
+- }
++#ifdef __NetBSD__
++if ( ioctl(cdfile, CDIOREADTOCHEADER, &tochdr) == -1 )
++{
++ Con_DPrintf("ioctl cdromreadtochdr failed\n");
++ return -1;
++}
++#endif
+
+- cdValid = true;
+- maxTrack = tochdr.cdth_trk1;
++#ifdef __linux__
++if (tochdr.cdth_trk0 < 1)
++ {
++ Con_DPrintf("CDAudio: no music tracks\n");
++ return -1;
++ }
++#endif
++#ifdef __NetBSD__
++if (tochdr.starting_track < 1)
++ {
++ Con_DPrintf("CDAudio: no music tracks\n");
++ return -1;
++ }
++#endif
++
++cdValid = true;
++#ifdef __linux__
++maxTrack = tochdr.cdth_trk1;
++#endif
++#ifdef __NetBSD__
++maxTrack = tochdr.ending_track;
++#endif
+
+- return 0;
++return 0;
+ }
+
+
+ void CDAudio_Play(byte track, qboolean looping)
+ {
+- struct cdrom_tocentry entry;
+- struct cdrom_ti ti;
++#ifdef __linux__
++ struct cdrom_tocentry entry;
++ struct cdrom_ti ti;
++#endif
+
+- if (cdfile == -1 || !enabled)
+- return;
++#ifdef __NetBSD__
++ struct ioc_read_toc_entry entry;
++ struct ioc_play_track ti;
++ int arg=1;
++#endif
++
++ if (cdfile == -1 || !enabled)
++ return;
+
+- if (!cdValid)
+- {
+- CDAudio_GetAudioDiskInfo();
+- if (!cdValid)
+- return;
+- }
++ if (!cdValid)
++ {
++ CDAudio_GetAudioDiskInfo();
++ if (!cdValid)
++ return;
++ }
+
+- track = remap[track];
++ track = remap[track];
+
+- if (track < 1 || track > maxTrack)
+- {
+- Con_DPrintf("CDAudio: Bad track number %u.\n", track);
+- return;
+- }
++ if (track < 1 || track > maxTrack)
++ {
++ Con_DPrintf("CDAudio: Bad track number %u.\n", track);
++ return;
++ }
+
+- // don't try to play a non-audio track
+- entry.cdte_track = track;
+- entry.cdte_format = CDROM_MSF;
+- if ( ioctl(cdfile, CDROMREADTOCENTRY, &entry) == -1 )
+- {
+- Con_DPrintf("ioctl cdromreadtocentry failed\n");
+- return;
+- }
+- if (entry.cdte_ctrl == CDROM_DATA_TRACK)
+- {
+- Con_Printf("CDAudio: track %i is not audio\n", track);
+- return;
+- }
++#ifdef __linux__ /* Not sure what the equiv is for NetBSD */
++ /* don't try to play a non-audio track */
++ entry.cdte_track = track;
++ entry.cdte_format = CDROM_MSF;
++ if ( ioctl(cdfile, CDROMREADTOCENTRY, &entry) == -1 )
++ {
++ Con_DPrintf("ioctl cdromreadtocentry failed\n");
++ return;
++ }
++ if (entry.cdte_ctrl == CDROM_DATA_TRACK)
++ {
++ Con_Printf("CDAudio: track %i is not audio\n", track);
++ return;
++ }
+
+- if (playing)
+- {
+- if (playTrack == track)
+- return;
+- CDAudio_Stop();
+- }
++#endif
++
++ if (playing)
++ {
++ if (playTrack == track)
++ return;
++ CDAudio_Stop();
++ }
++
++#ifdef __linux__
++ ti.cdti_trk0 = track;
++ ti.cdti_trk1 = track;
++ ti.cdti_ind0 = 1;
++ ti.cdti_ind1 = 99;
++ if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 )
++ {
++ Con_DPrintf("ioctl cdromplaytrkind failed\n");
++ return;
++ }
+
+- ti.cdti_trk0 = track;
+- ti.cdti_trk1 = track;
+- ti.cdti_ind0 = 1;
+- ti.cdti_ind1 = 99;
++ if ( ioctl(cdfile, CDROMRESUME) == -1 )
++ Con_DPrintf("ioctl cdromresume failed\n");
++#endif
+
+- if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 )
++#ifdef __NetBSD__
++ ti.start_track = track;
++ ti.end_track = track;
++ ti.start_index = 1;
++ ti.end_index = 99;
++ if ( ioctl(cdfile, CDIOCPLAYTRACKS, &ti) == -1 )
+ {
+- Con_DPrintf("ioctl cdromplaytrkind failed\n");
+- return;
++ Con_DPrintf("ioctl cdromplaytrkind failed\n");
++ return;
+ }
+
+- if ( ioctl(cdfile, CDROMRESUME) == -1 )
+- Con_DPrintf("ioctl cdromresume failed\n");
++ if ( ioctl(cdfile, CDIOCRESUME, &arg) == -1 )
++ Con_DPrintf("ioctl cdromresume failed\n");
++#endif
+
+- playLooping = looping;
+- playTrack = track;
+- playing = true;
++ playLooping = looping;
++ playTrack = track;
++ playing = true;
+
+- if (cdvolume == 0.0)
+- CDAudio_Pause ();
++ if (cdvolume == 0.0)
++ CDAudio_Pause ();
+ }
+
+
+ void CDAudio_Stop(void)
+ {
+- if (cdfile == -1 || !enabled)
+- return;
++ if (cdfile == -1 || !enabled)
++ return;
+
+- if (!playing)
+- return;
++ if (!playing)
++ return;
+
+- if ( ioctl(cdfile, CDROMSTOP) == -1 )
+- Con_DPrintf("ioctl cdromstop failed (%d)\n", errno);
++#ifdef __linux__
++ if ( ioctl(cdfile, CDROMSTOP) == -1 )
++ Con_DPrintf("ioctl cdromstop failed (%d)\n", errno);
++#endif
++#ifdef __NetBSD__
++ if ( ioctl(cdfile, CDIOCSTOP) == -1 )
++ Con_DPrintf("ioctl cdromstop failed (%d)\n", errno);
++#endif
+
+- wasPlaying = false;
+- playing = false;
++ wasPlaying = false;
++ playing = false;
+ }
+
+ void CDAudio_Pause(void)
+ {
+- if (cdfile == -1 || !enabled)
+- return;
++#ifdef PAUSE_BY_STOPPING
++ qboolean t;
++#endif
+
+- if (!playing)
+- return;
++ if (cdfile == -1 || !enabled)
++ return;
+
+- if ( ioctl(cdfile, CDROMPAUSE) == -1 )
+- Con_DPrintf("ioctl cdrompause failed\n");
++ if (!playing)
++ return;
++
++#ifndef PAUSE_BY_STOPPING
++#ifdef __linux__
++ if ( ioctl(cdfile, CDROMPAUSE) == -1 )
++ Con_DPrintf("ioctl cdrompause failed\n");
++#endif
+
+- wasPlaying = playing;
+- playing = false;
++#ifdef __NetBSD__
++ if ( ioctl(cdfile, CDIOCPAUSE) == -1 )
++ Con_DPrintf("ioctl cdrompause failed\n");
++#endif
++#else
++ t_playLooping = playLooping;
++ t_playTrack=playTrack;
++ t=playing;
++ CDAudio_Stop();
++ playing=t;
++#endif
++
++ wasPlaying = playing;
++ playing = false;
+ }
+
+
+ void CDAudio_Resume(void)
+ {
+- if (cdfile == -1 || !enabled)
+- return;
++ if (cdfile == -1 || !enabled)
++ return;
+
+- if (!cdValid)
+- return;
++ if (!cdValid)
++ return;
+
+- if (!wasPlaying)
+- return;
++ if (!wasPlaying)
++ return;
+
+- if ( ioctl(cdfile, CDROMRESUME) == -1 )
+- Con_DPrintf("ioctl cdromresume failed\n");
+- playing = true;
++#ifndef PAUSE_BY_STOPPING
++#ifdef __linux__
++ if ( ioctl(cdfile, CDROMRESUME) == -1 )
++ Con_DPrintf("ioctl cdromresume failed\n");
++#endif
++
++#ifdef __NetBSD__
++ if ( ioctl(cdfile, CDIOCRESUME) == -1 )
++ Con_DPrintf("ioctl cdromresume failed\n");
++#endif
++#else
++ CDAudio_Play(t_playTrack, t_playLooping);
++#endif
++
++ playing = true;
+ }
+
+ static void CD_f (void)
+@@ -327,43 +463,72 @@
+
+ void CDAudio_Update(void)
+ {
+- struct cdrom_subchnl subchnl;
+- static time_t lastchk;
++#ifdef __linux__
++ struct cdrom_subchnl subchnl;
++#endif
++#ifdef __NetBSD__
++ struct ioc_read_subchannel subchnl;
++ struct cd_sub_channel_info data;
++#endif
++ static time_t lastchk;
+
+- if (!enabled)
+- return;
++ if (!enabled)
++ return;
+
+- if (bgmvolume.value != cdvolume)
++ if (bgmvolume.value != cdvolume)
++ {
++ if (cdvolume)
+ {
+- if (cdvolume)
+- {
+- Cvar_SetValue ("bgmvolume", 0.0);
+- cdvolume = bgmvolume.value;
+- CDAudio_Pause ();
+- }
+- else
+- {
+- Cvar_SetValue ("bgmvolume", 1.0);
+- cdvolume = bgmvolume.value;
+- CDAudio_Resume ();
+- }
++ Cvar_SetValue ("bgmvolume", 0.0);
++ cdvolume = bgmvolume.value;
++ CDAudio_Pause ();
+ }
-
- BUILD_DEBUG_DIR=debug$(ARCH)$(GLIBC)
- BUILD_RELEASE_DIR=release$(ARCH)$(GLIBC)
- CLIENT_DIR=$(MAINDIR)/client
-@@ -37,7 +35,8 @@
- MESA_DIR=/usr/local/src/Mesa-3.0
-
- CC=gcc
--BASE_CFLAGS=-Wall -Dstricmp=strcasecmp -I$(CLIENT_DIR) -I$(SERVER_DIR)
-+BASE_CFLAGS=-Wall -Dstricmp=strcasecmp -I$(CLIENT_DIR) -I$(SERVER_DIR) \
-+ ${CFLAGS} -I${X11BASE}/include
- DEBUG_CFLAGS=$(BASE_CFLAGS) -g
- ifeq ($(ARCH),axp)
- RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
-@@ -49,19 +48,21 @@
- endif
- GLCFLAGS=-DGLQUAKE -I/usr/local/src/Mesa-3.0/include -I/usr/include/glide
-
--LDFLAGS=-lm
-+LDFLAGS=-lm -lossaudio
- SVGALDFLAGS=-lvga
- XLDFLAGS=-L/usr/X11R6/lib -lX11 -lXext
--GL_SVGA_LDFLAGS=-L/usr/X11/lib -L/usr/local/src/Mesa-3.0/lib -lm -lMesaGL -lglide2x -lX11 -lXext -lvga
--GL_X11_LDFLAGS=-L/usr/X11/lib -L/usr/local/src/Mesa-3.0/lib -lm -lGL -lX11 -lXext
-+GL_SVGA_LDFLAGS=-L/usr/X11R6/lib -L/usr/local/src/Mesa-3.0/lib -lm -lMesaGL -lglide2x -lX11 -lXext -lvga
-+GL_X11_LDFLAGS=-L/usr/X11R6/lib -L/usr/local/src/Mesa-3.0/lib -lm -lGL -lX11 -lXext
-
- DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
- DO_O_CC=$(CC) -O $(CFLAGS) -o $@ -c $<
- DO_GL_CC=$(CC) $(CFLAGS) $(GLCFLAGS) -o $@ -c $<
- DO_SERVER_CC=$(CC) -DSERVERONLY $(CFLAGS) -o $@ -c $<
-
--DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
--DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
-+DO_AS=$(CC) $(CFLAGS) -DAOUT -x assembler-with-cpp -o $@ -c $<
-+#DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
-+DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -DAOUT -x assembler-with-cpp -o $@ -c $<
-+#DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
-
- #############################################################################
- # SETUP AND BUILD
-@@ -71,7 +72,7 @@
- TARGETS=$(BUILDDIR)/qwsv
- #$(BUILDDIR)/qwcl.x11
- else
--TARGETS=$(BUILDDIR)/qwsv $(BUILDDIR)/qwcl $(BUILDDIR)/qwcl.x11 $(BUILDDIR)/glqwcl $(BUILDDIR)/glqwcl.glx
-+TARGETS=$(BUILDDIR)/qwsv $(BUILDDIR)/qwcl.x11 $(BUILDDIR)/glqwcl.glx
- endif
-
- build_debug:
-@@ -269,7 +270,7 @@
- $(BUILDDIR)/client/view.o \
- $(BUILDDIR)/client/wad.o \
- $(BUILDDIR)/client/zone.o \
-- $(BUILDDIR)/client/cd_linux.o \
-+ $(BUILDDIR)/client/cd_null.o \
- $(BUILDDIR)/client/sys_linux.o \
- $(BUILDDIR)/client/snd_linux.o \
-
-@@ -485,7 +486,7 @@
- $(BUILDDIR)/client/zone.o : $(CLIENT_DIR)/zone.c
- $(DO_CC)
-
--$(BUILDDIR)/client/cd_linux.o : $(CLIENT_DIR)/cd_linux.c
-+$(BUILDDIR)/client/cd_null.o : $(CLIENT_DIR)/cd_null.c
- $(DO_CC)
-
- $(BUILDDIR)/client/sys_linux.o : $(CLIENT_DIR)/sys_linux.c
-@@ -590,7 +591,7 @@
- $(BUILDDIR)/glclient/view.o \
- $(BUILDDIR)/glclient/wad.o \
- $(BUILDDIR)/glclient/zone.o \
-- $(BUILDDIR)/glclient/cd_linux.o \
-+ $(BUILDDIR)/glclient/cd_null.o \
- $(BUILDDIR)/glclient/sys_linux.o \
- $(BUILDDIR)/glclient/snd_linux.o \
- \
-@@ -715,7 +716,7 @@
- $(BUILDDIR)/glclient/zone.o : $(CLIENT_DIR)/zone.c
- $(DO_GL_CC)
-
--$(BUILDDIR)/glclient/cd_linux.o : $(CLIENT_DIR)/cd_linux.c
-+$(BUILDDIR)/glclient/cd_null.o : $(CLIENT_DIR)/cd_null.c
- $(DO_GL_CC)
-
- $(BUILDDIR)/glclient/sys_linux.o : $(CLIENT_DIR)/sys_linux.c
+- if (playing && lastchk < time(NULL)) {
+- lastchk = time(NULL) + 2; //two seconds between chks
+- subchnl.cdsc_format = CDROM_MSF;
+- if (ioctl(cdfile, CDROMSUBCHNL, &subchnl) == -1 ) {
+- Con_DPrintf("ioctl cdromsubchnl failed\n");
+- playing = false;
+- return;
+- }
+- if (subchnl.cdsc_audiostatus != CDROM_AUDIO_PLAY &&
+- subchnl.cdsc_audiostatus != CDROM_AUDIO_PAUSED) {
+- playing = false;
+- if (playLooping)
+- CDAudio_Play(playTrack, true);
+- }
++ else
++ {
++ Cvar_SetValue ("bgmvolume", 1.0);
++ cdvolume = bgmvolume.value;
++ CDAudio_Resume ();
+ }
++ }
++
++
++ if (playing && lastchk < time(NULL)) {
++ lastchk = time(NULL) + 2; /* two seconds between chks */
++#ifdef __linux
++ subchnl.cdsc_format = CDROM_MSF;
++ if (ioctl(cdfile, CDROMSUBCHNL, &subchnl) == -1 ) {
++ Con_DPrintf("ioctl cdromsubchnl failed\n");
++ playing = false;
++ return;
++ }
++ if (subchnl.cdsc_audiostatus != CDROM_AUDIO_PLAY &&
++ subchnl.cdsc_audiostatus != CDROM_AUDIO_PAUSED) {
++ playing = false;
++ if (playLooping)
++ CDAudio_Play(playTrack, true);
++ }
++#endif
++#ifdef __NetBSD__
++ subchnl.address_format = CD_MSF_FORMAT;
++ subchnl.data_format = CD_CURRENT_POSITION;
++ subchnl.data_len = sizeof(data);
++ subchnl.track = playTrack;
++ subchnl.data = &data;
++
++ if (ioctl(cdfile, CDIOCREADSUBCHANNEL, &subchnl) == -1 ) {
++ Con_DPrintf("ioctl cdromsubchnl failed\n");
++ playing = false;
++ return;
++ }
++ if (subchnl.data->header.audio_status != CD_AS_PLAY_IN_PROGRESS &&
++ subchnl.data->header.audio_status != CD_AS_PLAY_PAUSED) {
++ playing = false;
++ if (playLooping)
++ CDAudio_Play(playTrack, true);
++ }
++#endif
++ }
++
+ }
+
+ int CDAudio_Init(void)
+@@ -375,6 +540,8 @@
+ return -1;
+ #endif
+
++ fprintf(stderr,"...... cdaudio_init .......\n");
++
+ if (COM_CheckParm("-nocdaudio"))
+ return -1;
+
+@@ -384,9 +551,9 @@
+ }
+
+ if ((cdfile = open(cd_dev, O_RDONLY)) == -1) {
+- Con_Printf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev, errno);
+- cdfile = -1;
+- return -1;
++ Con_Printf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev, errno);
++ cdfile = -1;
++ return -1;
+ }
+
+ for (i = 0; i < 100; i++)
diff --git a/games/quake/patches/patch-ab b/games/quake/patches/patch-ab
index 7222bc70e84..7ef1bcd4f35 100644
--- a/games/quake/patches/patch-ab
+++ b/games/quake/patches/patch-ab
@@ -1,13 +1,13 @@
-$NetBSD: patch-ab,v 1.1 2000/01/13 00:35:05 wiz Exp $
+$NetBSD: patch-ab,v 1.2 2000/02/01 02:30:32 wiz Exp $
---- server/sys_unix.c.orig Thu Jan 13 00:13:37 2000
-+++ server/sys_unix.c Thu Jan 13 00:13:58 2000
-@@ -24,7 +24,7 @@
- #include <libc.h>
+--- QW/client/gl_draw.c Tue Dec 21 15:46:06 1999
++++ ../work/QW/client/gl_draw.c Sat Jan 15 23:08:00 2000
+@@ -1367,7 +1367,7 @@
+ {
+ if (!gl_mtexable)
+ return;
+-#ifndef __linux__ // no multitexture under Linux yet
++#if !defined(__linux__) && !defined(__NetBSD__) // no multitexture under Linux yet
+ qglSelectTextureSGIS(target);
#endif
-
--#if defined(__linux__) || defined(sun)
-+#if defined(__linux__) || defined(sun) || defined(__NetBSD__)
- #include <sys/stat.h>
- #include <unistd.h>
- #include <sys/time.h>
+ if (target == oldtarget)
diff --git a/games/quake/patches/patch-ac b/games/quake/patches/patch-ac
index 7d4914a1bd8..432b85b8708 100644
--- a/games/quake/patches/patch-ac
+++ b/games/quake/patches/patch-ac
@@ -1,16 +1,43 @@
-$NetBSD: patch-ac,v 1.1 2000/01/13 00:35:06 wiz Exp $
+$NetBSD: patch-ac,v 1.2 2000/02/01 02:30:33 wiz Exp $
---- client/snd_linux.c.orig Mon Jul 7 20:08:00 1997
-+++ client/snd_linux.c Thu Jan 13 00:29:11 2000
-@@ -6,7 +6,11 @@
- #include <sys/mman.h>
- #include <sys/shm.h>
- #include <sys/wait.h>
+--- QW/client/gl_vidlinuxglx.c Tue Dec 21 18:45:54 1999
++++ ../work/QW/client/gl_vidlinuxglx.c Wed Jan 19 21:58:20 2000
+@@ -20,7 +20,6 @@
+ #include <termios.h>
+ #include <sys/ioctl.h>
+ #include <sys/stat.h>
+-#include <sys/vt.h>
+ #include <stdarg.h>
+ #include <stdio.h>
+ #include <signal.h>
+@@ -560,6 +559,9 @@
+
+ void VID_Init8bitPalette(void)
+ {
+#ifdef __NetBSD__
-+#include <soundcard.h>
++ return;
+#else
- #include <linux/soundcard.h>
+ // Check for 8bit Extensions and initialize them.
+ int i;
+ GLubyte table[256][4];
+@@ -580,6 +582,7 @@
+ }
+ gl3DfxSetPaletteEXT((GLuint *)table);
+ is8bit = true;
++#endif
+ }
+ #endif
+
+@@ -603,7 +606,12 @@
+ Window root;
+ XVisualInfo *visinfo;
+
++ /* For some reason this is called. It causes trouble for NetBSD
++ and sound won't work */
++
++#ifndef __NetBSD__
+ S_Init();
+#endif
- #include <stdio.h>
- #include "quakedef.h"
+ Cvar_RegisterVariable (&vid_mode);
+ Cvar_RegisterVariable (&gl_ztrick);
diff --git a/games/quake/patches/patch-ad b/games/quake/patches/patch-ad
index 3ebbd852c2d..9f29dc2dae9 100644
--- a/games/quake/patches/patch-ad
+++ b/games/quake/patches/patch-ad
@@ -1,14 +1,167 @@
-$NetBSD: patch-ad,v 1.1 2000/01/13 00:35:06 wiz Exp $
+$NetBSD: patch-ad,v 1.2 2000/02/01 02:30:33 wiz Exp $
---- client/cd_null.c~ Mon Jul 7 20:08:00 1997
-+++ client/cd_null.c Thu Jan 13 00:59:02 2000
-@@ -9,6 +9,9 @@
- {
- }
+--- QW/client/snd_linux.c Mon Jul 7 20:08:00 1997
++++ ../work/QW/client/snd_linux.c Sun Jan 16 19:35:45 2000
+@@ -6,15 +6,33 @@
+ #include <sys/mman.h>
+ #include <sys/shm.h>
+ #include <sys/wait.h>
++
++#ifdef __NetBSD__
++#include <soundcard.h>
++#endif
++
++#ifdef __linux__
+ #include <linux/soundcard.h>
++#endif
++
+ #include <stdio.h>
+ #include "quakedef.h"
+
+-int audio_fd;
++int audio_fd = -1;
+ int snd_inited;
-+void CDAudio_Pause(void)
-+{
-+}
+ static int tryrates[] = { 11025, 22051, 44100, 8000 };
- void CDAudio_Resume(void)
++#ifdef __linux__
++char *audio_device="/dev/dsp";
++#define MMAP_PROTECTION PROT_WRITE
++#endif
++
++#ifdef __NetBSD__
++char *audio_device="/dev/audio";
++#define MMAP_PROTECTION PROT_WRITE|PROT_READ
++#endif
++
+ qboolean SNDDMA_Init(void)
{
+
+@@ -28,28 +46,29 @@
+
+ snd_inited = 0;
+
+-// open /dev/dsp, confirm capability to mmap, and get size of dma buffer
++// open /dev/dsp or whatever, confirm capability to mmap, and get size of
++// dma buffer
+
+- audio_fd = open("/dev/dsp", O_RDWR);
++ audio_fd = open(audio_device, O_RDWR);
+ if (audio_fd < 0)
+ {
+- perror("/dev/dsp");
+- Con_Printf("Could not open /dev/dsp\n");
++ perror(audio_device);
++ Con_Printf("Could not open %s\n",audio_device);
+ return 0;
+ }
+
+ rc = ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
+- Con_Printf("Could not reset /dev/dsp\n");
++ perror(audio_device);
++ Con_Printf("Could not reset %s\n",audio_device);
+ close(audio_fd);
+ return 0;
+ }
+
+ if (ioctl(audio_fd, SNDCTL_DSP_GETCAPS, &caps)==-1)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Sound driver too old\n");
+ close(audio_fd);
+ return 0;
+@@ -111,11 +130,11 @@
+ // memory map the dma buffer
+
+ shm->buffer = (unsigned char *) mmap(NULL, info.fragstotal
+- * info.fragsize, PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);
++ * info.fragsize, MMAP_PROTECTION, MAP_FILE|MAP_SHARED, audio_fd, 0);
+ if (!shm->buffer)
+ {
+- perror("/dev/dsp");
+- Con_Printf("Could not mmap /dev/dsp\n");
++ perror(audio_device);
++ Con_Printf("Could not mmap %s\n",audio_device);
+ close(audio_fd);
+ return 0;
+ }
+@@ -126,8 +145,8 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
+- Con_Printf("Could not set /dev/dsp to stereo=%d", shm->channels);
++ perror(audio_device);
++ Con_Printf("Could not set %s to stereo=%d", audio_device, shm->channels);
+ close(audio_fd);
+ return 0;
+ }
+@@ -139,8 +158,8 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_SPEED, &shm->speed);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
+- Con_Printf("Could not set /dev/dsp speed to %d", shm->speed);
++ perror(audio_device);
++ Con_Printf("Could not set %s speed to %d", audio_device, shm->speed);
+ close(audio_fd);
+ return 0;
+ }
+@@ -151,7 +170,7 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETFMT, &rc);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Could not support 16-bit data. Try 8-bit.\n");
+ close(audio_fd);
+ return 0;
+@@ -163,7 +182,7 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETFMT, &rc);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Could not support 8-bit data.\n");
+ close(audio_fd);
+ return 0;
+@@ -171,7 +190,7 @@
+ }
+ else
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("%d-bit sound not supported.", shm->samplebits);
+ close(audio_fd);
+ return 0;
+@@ -183,7 +202,7 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Could not toggle.\n");
+ close(audio_fd);
+ return 0;
+@@ -192,7 +211,7 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Could not toggle.\n");
+ close(audio_fd);
+ return 0;
+@@ -214,7 +233,7 @@
+
+ if (ioctl(audio_fd, SNDCTL_DSP_GETOPTR, &count)==-1)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Uh, sound dead.\n");
+ close(audio_fd);
+ snd_inited = 0;
diff --git a/games/quake/patches/patch-ae b/games/quake/patches/patch-ae
index 7de0754d02a..b06d31dd498 100644
--- a/games/quake/patches/patch-ae
+++ b/games/quake/patches/patch-ae
@@ -1,12 +1,104 @@
-$NetBSD: patch-ae,v 1.1 2000/01/13 00:35:06 wiz Exp $
+$NetBSD: patch-ae,v 1.2 2000/02/01 02:30:33 wiz Exp $
---- client/gl_vidlinuxglx.c~ Tue Dec 21 18:45:54 1999
-+++ client/gl_vidlinuxglx.c Thu Jan 13 01:02:59 2000
-@@ -20,7 +20,6 @@
- #include <termios.h>
- #include <sys/ioctl.h>
- #include <sys/stat.h>
--#include <sys/vt.h>
- #include <stdarg.h>
- #include <stdio.h>
- #include <signal.h>
+--- QW/Makefile.Linux Wed Apr 21 20:16:24 1999
++++ ../work/QW/Makefile.Linux Wed Jan 19 21:37:30 2000
+@@ -27,41 +27,51 @@
+ RPMARCH=i386
+ endif
+
+-MAINDIR=/grog/Projects/QW
+-
+-BUILD_DEBUG_DIR=debug$(ARCH)$(GLIBC)
+-BUILD_RELEASE_DIR=release$(ARCH)$(GLIBC)
++#BUILD_DEBUG_DIR=debug$(ARCH)$(GLIBC)
++#BUILD_RELEASE_DIR=release$(ARCH)$(GLIBC)
++BUILD_DEBUG_DIR=debug_version
++BUILD_RELEASE_DIR=release_version
+ CLIENT_DIR=$(MAINDIR)/client
+ SERVER_DIR=$(MAINDIR)/server
+
+ MESA_DIR=/usr/local/src/Mesa-3.0
+
+ CC=gcc
+-BASE_CFLAGS=-Wall -Dstricmp=strcasecmp -I$(CLIENT_DIR) -I$(SERVER_DIR)
++BASE_CFLAGS=-Wall -Dstricmp=strcasecmp -I$(CLIENT_DIR) -I$(SERVER_DIR) \
++ ${CFLAGS} -I${X11BASE}/include -O0
+ DEBUG_CFLAGS=$(BASE_CFLAGS) -g
+ ifeq ($(ARCH),axp)
+ RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
+ -fomit-frame-pointer -fexpensive-optimizations
+ else
+-RELEASE_CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \
++# Optimizer bug?!?!?
++#RELEASE_CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \
++# -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
++# -malign-jumps=2 -malign-functions=2
++RELEASE_CFLAGS=$(BASE_CFLAGS) -m486 -ffast-math -funroll-loops \
+ -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
+ -malign-jumps=2 -malign-functions=2
+ endif
+ GLCFLAGS=-DGLQUAKE -I/usr/local/src/Mesa-3.0/include -I/usr/include/glide
+
+-LDFLAGS=-lm
++LDFLAGS=-lm -lossaudio
+ SVGALDFLAGS=-lvga
+ XLDFLAGS=-L/usr/X11R6/lib -lX11 -lXext
+-GL_SVGA_LDFLAGS=-L/usr/X11/lib -L/usr/local/src/Mesa-3.0/lib -lm -lMesaGL -lglide2x -lX11 -lXext -lvga
+-GL_X11_LDFLAGS=-L/usr/X11/lib -L/usr/local/src/Mesa-3.0/lib -lm -lGL -lX11 -lXext
++GL_SVGA_LDFLAGS=-L/usr/X11R6/lib -L/usr/local/src/Mesa-3.0/lib -lm -lMesaGL -lglide2x -lX11 -lXext -lvga
++GL_X11_LDFLAGS=-L/usr/X11R6/lib -L/usr/local/src/Mesa-3.0/lib -lm -lGL -lX11 -lXext
+
+ DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
+-DO_O_CC=$(CC) -O $(CFLAGS) -o $@ -c $<
++#DO_O_CC=$(CC) -O $(CFLAGS) -o $@ -c $<
++DO_O_CC=$(CC) $(CFLAGS) -o $@ -c $<
+ DO_GL_CC=$(CC) $(CFLAGS) $(GLCFLAGS) -o $@ -c $<
+ DO_SERVER_CC=$(CC) -DSERVERONLY $(CFLAGS) -o $@ -c $<
+
+-DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
+-DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
++DO_AS=$(CC) $(CFLAGS) -x assembler-with-cpp -o $@ -c $<
++#DO_AS=$(CC) $(CFLAGS) -DAOUT -x assembler-with-cpp -o $@ -c $<
++#DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
++DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -x assembler-with-cpp -o $@ -c $<
++#DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -DAOUT -x assembler-with-cpp -o $@ -c $<
++#DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
+
+ #############################################################################
+ # SETUP AND BUILD
+@@ -71,7 +81,7 @@
+ TARGETS=$(BUILDDIR)/qwsv
+ #$(BUILDDIR)/qwcl.x11
+ else
+-TARGETS=$(BUILDDIR)/qwsv $(BUILDDIR)/qwcl $(BUILDDIR)/qwcl.x11 $(BUILDDIR)/glqwcl $(BUILDDIR)/glqwcl.glx
++TARGETS=$(BUILDDIR)/qwsv $(BUILDDIR)/qwcl.x11 $(BUILDDIR)/glqwcl.glx
+ endif
+
+ build_debug:
+@@ -485,7 +495,7 @@
+ $(BUILDDIR)/client/zone.o : $(CLIENT_DIR)/zone.c
+ $(DO_CC)
+
+-$(BUILDDIR)/client/cd_linux.o : $(CLIENT_DIR)/cd_linux.c
++$(BUILDDIR)/client/cd_linux.o : $(CLIENT_DIR)/cd_linux.c
+ $(DO_CC)
+
+ $(BUILDDIR)/client/sys_linux.o : $(CLIENT_DIR)/sys_linux.c
+@@ -609,7 +619,7 @@
+ $(BUILDDIR)/glclient/math.o \
+ $(BUILDDIR)/glclient/snd_mixa.o \
+ $(BUILDDIR)/glclient/sys_dosa.o
+-
++
+ GLQWCL_SVGA_OBJS = $(BUILDDIR)/glclient/gl_vidlinux.o
+ GLQWCL_X11_OBJS = $(BUILDDIR)/glclient/gl_vidlinuxglx.o
+
+@@ -715,7 +725,7 @@
+ $(BUILDDIR)/glclient/zone.o : $(CLIENT_DIR)/zone.c
+ $(DO_GL_CC)
+
+-$(BUILDDIR)/glclient/cd_linux.o : $(CLIENT_DIR)/cd_linux.c
++$(BUILDDIR)/glclient/cd_linux.o : $(CLIENT_DIR)/cd_linux.c
+ $(DO_GL_CC)
+
+ $(BUILDDIR)/glclient/sys_linux.o : $(CLIENT_DIR)/sys_linux.c
diff --git a/games/quake/patches/patch-af b/games/quake/patches/patch-af
new file mode 100644
index 00000000000..6f3246b38d2
--- /dev/null
+++ b/games/quake/patches/patch-af
@@ -0,0 +1,13 @@
+$NetBSD: patch-af,v 1.1 2000/02/01 02:30:33 wiz Exp $
+
+--- QW/server/sys_unix.c Tue Dec 21 18:45:14 1999
++++ ../work/QW/server/sys_unix.c Sat Jan 15 23:02:46 2000
+@@ -24,7 +24,7 @@
+ #include <libc.h>
+ #endif
+
+-#if defined(__linux__) || defined(sun)
++#if defined(__linux__) || defined(sun) || defined(__NetBSD__)
+ #include <sys/stat.h>
+ #include <unistd.h>
+ #include <sys/time.h>
diff --git a/games/quake/patches/patch-ag b/games/quake/patches/patch-ag
new file mode 100644
index 00000000000..bef8e3539d4
--- /dev/null
+++ b/games/quake/patches/patch-ag
@@ -0,0 +1,532 @@
+$NetBSD: patch-ag,v 1.1 2000/02/01 02:30:34 wiz Exp $
+
+--- WinQuake/cd_linux.c Tue Dec 21 18:40:50 1999
++++ ../work/WinQuake/cd_linux.c Sat Jan 15 10:52:27 2000
+@@ -31,7 +31,19 @@
+ #include <time.h>
+ #include <errno.h>
+
++#ifdef __linux__
+ #include <linux/cdrom.h>
++#endif
++
++#ifdef __NetBSD__
++#include <sys/cdio.h>
++
++/* resume seems to have some trouble right now. xcdplayer also can not resume
++ the drive correctly. It appears to play, but no audio is heard */
++
++#define PAUSE_BY_STOPPING 1
++
++#endif
+
+ #include "quakedef.h"
+
+@@ -46,165 +58,289 @@
+ static byte playTrack;
+ static byte maxTrack;
+
++#ifdef PAUSE_BY_STOPPING
++static qboolean t_playLooping;
++static byte t_playTrack;
++#endif
++
+ static int cdfile = -1;
++#ifdef __linux__
+ static char cd_dev[64] = "/dev/cdrom";
++#endif
++
++#ifdef __NetBSD__
++static char cd_dev[64] = "/dev/rcd0d";
++#endif
+
+ static void CDAudio_Eject(void)
+ {
+- if (cdfile == -1 || !enabled)
+- return; // no cd init'd
+-
+- if ( ioctl(cdfile, CDROMEJECT) == -1 )
+- Con_DPrintf("ioctl cdromeject failed\n");
++#ifdef __NetBSD__
++ int arg=0;
++#endif
++
++ if (cdfile == -1 || !enabled)
++ return; // no cd init'd
++
++#ifdef __linux__
++ if ( ioctl(cdfile, CDROMEJECT) == -1 )
++ Con_DPrintf("ioctl cdromeject failed\n");
++#endif
++#ifdef __NetBSD__
++ if(ioctl(cdfile, DIOCLOCK, &arg) == -1)
++ Con_DPrintf("ioctl cdromunlock failed\n");
++ arg = 1;
++ if ( ioctl(cdfile, DIOCEJECT, &arg) == -1 )
++ Con_DPrintf("ioctl cdromeject failed\n");
++#endif
+ }
+
+
+ static void CDAudio_CloseDoor(void)
+ {
+- if (cdfile == -1 || !enabled)
+- return; // no cd init'd
++if (cdfile == -1 || !enabled)
++ return; // no cd init'd
+
+- if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 )
+- Con_DPrintf("ioctl cdromclosetray failed\n");
++#ifdef __linux__
++ if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 )
++ Con_DPrintf("ioctl cdromclosetray failed\n");
++#endif
++#ifdef __NetBSD__
++ if(ioctl(cdfile, CDIOCCLOSE, NULL) == -1) {
++ Con_DPrintf("ioctl cdromclosetray failed\n");
++ }
++#endif
+ }
+
+ static int CDAudio_GetAudioDiskInfo(void)
+ {
+- struct cdrom_tochdr tochdr;
++#ifdef __linux__
++struct cdrom_tochdr tochdr;
++#endif
++#ifdef __NetBSD__
++struct ioc_toc_header tochdr;
++#endif
+
+- cdValid = false;
++cdValid = false;
+
+- if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 )
+- {
+- Con_DPrintf("ioctl cdromreadtochdr failed\n");
+- return -1;
+- }
++#ifdef __linux
++if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 )
++{
++ Con_DPrintf("ioctl cdromreadtochdr failed\n");
++ return -1;
++}
++#endif
+
+- if (tochdr.cdth_trk0 < 1)
+- {
+- Con_DPrintf("CDAudio: no music tracks\n");
+- return -1;
+- }
++#ifdef __NetBSD__
++if ( ioctl(cdfile, CDIOREADTOCHEADER, &tochdr) == -1 )
++{
++ Con_DPrintf("ioctl cdromreadtochdr failed\n");
++ return -1;
++}
++#endif
+
+- cdValid = true;
+- maxTrack = tochdr.cdth_trk1;
++#ifdef __linux__
++if (tochdr.cdth_trk0 < 1)
++ {
++ Con_DPrintf("CDAudio: no music tracks\n");
++ return -1;
++ }
++#endif
++#ifdef __NetBSD__
++if (tochdr.starting_track < 1)
++ {
++ Con_DPrintf("CDAudio: no music tracks\n");
++ return -1;
++ }
++#endif
++
++cdValid = true;
++#ifdef __linux__
++maxTrack = tochdr.cdth_trk1;
++#endif
++#ifdef __NetBSD__
++maxTrack = tochdr.ending_track;
++#endif
+
+- return 0;
++return 0;
+ }
+
+
+ void CDAudio_Play(byte track, qboolean looping)
+ {
+- struct cdrom_tocentry entry;
+- struct cdrom_ti ti;
++#ifdef __linux__
++ struct cdrom_tocentry entry;
++ struct cdrom_ti ti;
++#endif
++
++#ifdef __NetBSD__
++ struct ioc_read_toc_entry entry;
++ struct ioc_play_track ti;
++ int arg=1;
++#endif
+
+- if (cdfile == -1 || !enabled)
+- return;
++ if (cdfile == -1 || !enabled)
++ return;
+
+- if (!cdValid)
+- {
+- CDAudio_GetAudioDiskInfo();
+- if (!cdValid)
+- return;
+- }
++ if (!cdValid)
++ {
++ CDAudio_GetAudioDiskInfo();
++ if (!cdValid)
++ return;
++ }
+
+- track = remap[track];
++ track = remap[track];
+
+- if (track < 1 || track > maxTrack)
+- {
+- Con_DPrintf("CDAudio: Bad track number %u.\n", track);
+- return;
+- }
++ if (track < 1 || track > maxTrack)
++ {
++ Con_DPrintf("CDAudio: Bad track number %u.\n", track);
++ return;
++ }
+
+- // don't try to play a non-audio track
+- entry.cdte_track = track;
+- entry.cdte_format = CDROM_MSF;
+- if ( ioctl(cdfile, CDROMREADTOCENTRY, &entry) == -1 )
+- {
+- Con_DPrintf("ioctl cdromreadtocentry failed\n");
+- return;
+- }
+- if (entry.cdte_ctrl == CDROM_DATA_TRACK)
+- {
+- Con_Printf("CDAudio: track %i is not audio\n", track);
+- return;
+- }
++#ifdef __linux__ /* Not sure what the equiv is for NetBSD */
++ /* don't try to play a non-audio track */
++ entry.cdte_track = track;
++ entry.cdte_format = CDROM_MSF;
++ if ( ioctl(cdfile, CDROMREADTOCENTRY, &entry) == -1 )
++ {
++ Con_DPrintf("ioctl cdromreadtocentry failed\n");
++ return;
++ }
++ if (entry.cdte_ctrl == CDROM_DATA_TRACK)
++ {
++ Con_Printf("CDAudio: track %i is not audio\n", track);
++ return;
++ }
+
+- if (playing)
+- {
+- if (playTrack == track)
+- return;
+- CDAudio_Stop();
+- }
++#endif
+
+- ti.cdti_trk0 = track;
+- ti.cdti_trk1 = track;
+- ti.cdti_ind0 = 1;
+- ti.cdti_ind1 = 99;
++ if (playing)
++ {
++ if (playTrack == track)
++ return;
++ CDAudio_Stop();
++ }
+
+- if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 )
++#ifdef __linux__
++ ti.cdti_trk0 = track;
++ ti.cdti_trk1 = track;
++ ti.cdti_ind0 = 1;
++ ti.cdti_ind1 = 99;
++ if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 )
+ {
+- Con_DPrintf("ioctl cdromplaytrkind failed\n");
+- return;
++ Con_DPrintf("ioctl cdromplaytrkind failed\n");
++ return;
+ }
+
+- if ( ioctl(cdfile, CDROMRESUME) == -1 )
+- Con_DPrintf("ioctl cdromresume failed\n");
++ if ( ioctl(cdfile, CDROMRESUME) == -1 )
++ Con_DPrintf("ioctl cdromresume failed\n");
++#endif
++
++#ifdef __NetBSD__
++ ti.start_track = track;
++ ti.end_track = track;
++ ti.start_index = 1;
++ ti.end_index = 99;
++ if ( ioctl(cdfile, CDIOCPLAYTRACKS, &ti) == -1 )
++ {
++ Con_DPrintf("ioctl cdromplaytrkind failed\n");
++ return;
++ }
+
+- playLooping = looping;
+- playTrack = track;
+- playing = true;
++ if ( ioctl(cdfile, CDIOCRESUME, &arg) == -1 )
++ Con_DPrintf("ioctl cdromresume failed\n");
++#endif
++
++ playLooping = looping;
++ playTrack = track;
++ playing = true;
+
+- if (cdvolume == 0.0)
+- CDAudio_Pause ();
++ if (cdvolume == 0.0)
++ CDAudio_Pause ();
+ }
+
+
+ void CDAudio_Stop(void)
+ {
+- if (cdfile == -1 || !enabled)
+- return;
++ if (cdfile == -1 || !enabled)
++ return;
+
+- if (!playing)
+- return;
++ if (!playing)
++ return;
+
+- if ( ioctl(cdfile, CDROMSTOP) == -1 )
+- Con_DPrintf("ioctl cdromstop failed (%d)\n", errno);
++#ifdef __linux__
++ if ( ioctl(cdfile, CDROMSTOP) == -1 )
++ Con_DPrintf("ioctl cdromstop failed (%d)\n", errno);
++#endif
++#ifdef __NetBSD__
++ if ( ioctl(cdfile, CDIOCSTOP) == -1 )
++ Con_DPrintf("ioctl cdromstop failed (%d)\n", errno);
++#endif
+
+- wasPlaying = false;
+- playing = false;
++ wasPlaying = false;
++ playing = false;
+ }
+
+ void CDAudio_Pause(void)
+ {
+- if (cdfile == -1 || !enabled)
+- return;
+-
+- if (!playing)
+- return;
++#ifdef PAUSE_BY_STOPPING
++ qboolean t;
++#endif
++
++ if (cdfile == -1 || !enabled)
++ return;
++
++ if (!playing)
++ return;
++
++#ifndef PAUSE_BY_STOPPING
++#ifdef __linux__
++ if ( ioctl(cdfile, CDROMPAUSE) == -1 )
++ Con_DPrintf("ioctl cdrompause failed\n");
++#endif
++
++#ifdef __NetBSD__
++ if ( ioctl(cdfile, CDIOCPAUSE) == -1 )
++ Con_DPrintf("ioctl cdrompause failed\n");
++#endif
++#else
++ t_playLooping = playLooping;
++ t_playTrack=playTrack;
++ t=playing;
++ CDAudio_Stop();
++ playing=t;
++#endif
+
+- if ( ioctl(cdfile, CDROMPAUSE) == -1 )
+- Con_DPrintf("ioctl cdrompause failed\n");
+-
+- wasPlaying = playing;
+- playing = false;
++ wasPlaying = playing;
++ playing = false;
+ }
+
+
+ void CDAudio_Resume(void)
+ {
+- if (cdfile == -1 || !enabled)
+- return;
++ if (cdfile == -1 || !enabled)
++ return;
+
+- if (!cdValid)
+- return;
++ if (!cdValid)
++ return;
+
+- if (!wasPlaying)
+- return;
++ if (!wasPlaying)
++ return;
+
+- if ( ioctl(cdfile, CDROMRESUME) == -1 )
+- Con_DPrintf("ioctl cdromresume failed\n");
+- playing = true;
++#ifndef PAUSE_BY_STOPPING
++#ifdef __linux__
++ if ( ioctl(cdfile, CDROMRESUME) == -1 )
++ Con_DPrintf("ioctl cdromresume failed\n");
++#endif
++
++#ifdef __NetBSD__
++ if ( ioctl(cdfile, CDIOCRESUME) == -1 )
++ Con_DPrintf("ioctl cdromresume failed\n");
++#endif
++#else
++ CDAudio_Play(t_playTrack, t_playLooping);
++#endif
++
++ playing = true;
+ }
+
+ static void CD_f (void)
+@@ -327,43 +463,72 @@
+
+ void CDAudio_Update(void)
+ {
+- struct cdrom_subchnl subchnl;
+- static time_t lastchk;
++#ifdef __linux__
++ struct cdrom_subchnl subchnl;
++#endif
++#ifdef __NetBSD__
++ struct ioc_read_subchannel subchnl;
++ struct cd_sub_channel_info data;
++#endif
++ static time_t lastchk;
+
+- if (!enabled)
+- return;
++ if (!enabled)
++ return;
+
+- if (bgmvolume.value != cdvolume)
++ if (bgmvolume.value != cdvolume)
++ {
++ if (cdvolume)
+ {
+- if (cdvolume)
+- {
+- Cvar_SetValue ("bgmvolume", 0.0);
+- cdvolume = bgmvolume.value;
+- CDAudio_Pause ();
+- }
+- else
+- {
+- Cvar_SetValue ("bgmvolume", 1.0);
+- cdvolume = bgmvolume.value;
+- CDAudio_Resume ();
+- }
++ Cvar_SetValue ("bgmvolume", 0.0);
++ cdvolume = bgmvolume.value;
++ CDAudio_Pause ();
+ }
+-
+- if (playing && lastchk < time(NULL)) {
+- lastchk = time(NULL) + 2; //two seconds between chks
+- subchnl.cdsc_format = CDROM_MSF;
+- if (ioctl(cdfile, CDROMSUBCHNL, &subchnl) == -1 ) {
+- Con_DPrintf("ioctl cdromsubchnl failed\n");
+- playing = false;
+- return;
+- }
+- if (subchnl.cdsc_audiostatus != CDROM_AUDIO_PLAY &&
+- subchnl.cdsc_audiostatus != CDROM_AUDIO_PAUSED) {
+- playing = false;
+- if (playLooping)
+- CDAudio_Play(playTrack, true);
+- }
++ else
++ {
++ Cvar_SetValue ("bgmvolume", 1.0);
++ cdvolume = bgmvolume.value;
++ CDAudio_Resume ();
+ }
++ }
++
++
++ if (playing && lastchk < time(NULL)) {
++ lastchk = time(NULL) + 2; /* two seconds between chks */
++#ifdef __linux
++ subchnl.cdsc_format = CDROM_MSF;
++ if (ioctl(cdfile, CDROMSUBCHNL, &subchnl) == -1 ) {
++ Con_DPrintf("ioctl cdromsubchnl failed\n");
++ playing = false;
++ return;
++ }
++ if (subchnl.cdsc_audiostatus != CDROM_AUDIO_PLAY &&
++ subchnl.cdsc_audiostatus != CDROM_AUDIO_PAUSED) {
++ playing = false;
++ if (playLooping)
++ CDAudio_Play(playTrack, true);
++ }
++#endif
++#ifdef __NetBSD__
++ subchnl.address_format = CD_MSF_FORMAT;
++ subchnl.data_format = CD_CURRENT_POSITION;
++ subchnl.data_len = sizeof(data);
++ subchnl.track = playTrack;
++ subchnl.data = &data;
++
++ if (ioctl(cdfile, CDIOCREADSUBCHANNEL, &subchnl) == -1 ) {
++ Con_DPrintf("ioctl cdromsubchnl failed\n");
++ playing = false;
++ return;
++ }
++ if (subchnl.data->header.audio_status != CD_AS_PLAY_IN_PROGRESS &&
++ subchnl.data->header.audio_status != CD_AS_PLAY_PAUSED) {
++ playing = false;
++ if (playLooping)
++ CDAudio_Play(playTrack, true);
++ }
++#endif
++ }
++
+ }
+
+ int CDAudio_Init(void)
+@@ -382,9 +547,9 @@
+ }
+
+ if ((cdfile = open(cd_dev, O_RDONLY)) == -1) {
+- Con_Printf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev, errno);
+- cdfile = -1;
+- return -1;
++ Con_Printf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev, errno);
++ cdfile = -1;
++ return -1;
+ }
+
+ for (i = 0; i < 100; i++)
diff --git a/games/quake/patches/patch-ah b/games/quake/patches/patch-ah
new file mode 100644
index 00000000000..2e5a97bad9b
--- /dev/null
+++ b/games/quake/patches/patch-ah
@@ -0,0 +1,14 @@
+$NetBSD: patch-ah,v 1.1 2000/02/01 02:30:34 wiz Exp $
+
+--- WinQuake/gl_vidlinuxglx.c Tue Dec 21 18:39:36 1999
++++ ../work/WinQuake/gl_vidlinuxglx.c Thu Jan 13 22:29:03 2000
+@@ -20,7 +20,9 @@
+ #include <termios.h>
+ #include <sys/ioctl.h>
+ #include <sys/stat.h>
++#ifdef __linux__
+ #include <sys/vt.h>
++#endif
+ #include <stdarg.h>
+ #include <stdio.h>
+ #include <signal.h>
diff --git a/games/quake/patches/patch-ai b/games/quake/patches/patch-ai
new file mode 100644
index 00000000000..0b47aaafdc3
--- /dev/null
+++ b/games/quake/patches/patch-ai
@@ -0,0 +1,83 @@
+$NetBSD: patch-ai,v 1.1 2000/02/01 02:30:34 wiz Exp $
+
+--- WinQuake/Makefile.linuxi386 Tue Apr 27 17:51:18 1999
++++ ../work/WinQuake/Makefile.linuxi386 Wed Jan 19 21:38:00 2000
+@@ -25,29 +25,32 @@
+ endif
+ NOARCH=noarch
+
+-MOUNT_DIR=/grog/Projects/WinQuake
++MOUNT_DIR=${WRKSRC}/WinQuake
+ MASTER_DIR=/grog/Projects/QuakeMaster
+-MESA_DIR=/usr/local/src/Mesa-2.6
++#MESA_DIR=/usr/local/src/Mesa-2.6
++MESA_DIR=${X11BASE}
+ TDFXGL_DIR = /home/zoid/3dfxgl
+
+-BUILD_DEBUG_DIR=debug$(ARCH)$(GLIBC)
+-BUILD_RELEASE_DIR=release$(ARCH)$(GLIBC)
++#BUILD_DEBUG_DIR=debug$(ARCH)$(GLIBC)
++#BUILD_RELEASE_DIR=release$(ARCH)$(GLIBC)
++BUILD_DEBUG_DIR=debug_version
++BUILD_RELEASE_DIR=release_version
+
+ EGCS=/usr/local/egcs-1.1.2/bin/gcc
+-CC=$(EGCS)
++#CC=$(EGCS)
+
+-BASE_CFLAGS=-Dstricmp=strcasecmp
++BASE_CFLAGS=-Dstricmp=strcasecmp -I${X11BASE}/include
+ RELEASE_CFLAGS=$(BASE_CFLAGS) -g -mpentiumpro -O6 -ffast-math -funroll-loops \
+ -fomit-frame-pointer -fexpensive-optimizations
+ DEBUG_CFLAGS=$(BASE_CFLAGS) -g
+-LDFLAGS=-lm
++LDFLAGS=-lm -lossaudio
+ SVGALDFLAGS=-lvga
+ XLDFLAGS=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga
+-XCFLAGS=-DX11
++XCFLAGS=-DX11 -I${X11BASE}/include
+
+-MESAGLLDFLAGS=-L/usr/X11/lib -L/usr/local/lib -L$(MESA_DIR)/lib -lMesaGL -lglide2x -lX11 -lXext -ldl
++MESAGLLDFLAGS=-L${X11BASE}/lib -L${LOCALBASE}/lib -L$(MESA_DIR)/lib -lMesaGL -lX11 -lXext
+ TDFXGLLDFLAGS=-L$(TDFXGL_DIR)/release$(ARCH)$(GLIBC) -l3dfxgl -lglide2x -ldl
+-GLLDFLAGS=-L/usr/X11/lib -L/usr/local/lib -lGL -lX11 -lXext -ldl -lXxf86dga -lXxf86vm -lm
++GLLDFLAGS=-L${X11BASE}/lib -L${LOCALBASE}/lib -lGL -lX11 -lXext -lXxf86dga -lXxf86vm -lm
+ GLCFLAGS=-DGLQUAKE -I$(MESA_DIR)/include -I/usr/include/glide
+
+ DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
+@@ -57,19 +60,28 @@
+ DO_X11_CC=$(CC) $(CFLAGS) $(XCFLAGS) -o $@ -c $<
+ DO_X11_DEBUG_CC=$(CC) $(DEBUG_CFLAGS) $(XCFLAGS) -o $@ -c $<
+ DO_O_CC=$(CC) -O $(CFLAGS) -o $@ -c $<
+-DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
+-DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
++#DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
++#DO_AS=$(CC) $(CFLAGS) -DAOUT -x assembler-with-cpp -o $@ -c $<
++DO_AS=$(CC) $(CFLAGS) -x assembler-with-cpp -o $@ -c $<
++#DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
++#DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -DAOUT -x assembler-with-cpp -o $@ -c $<
++DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -x assembler-with-cpp -o $@ -c $<
+
+ #############################################################################
+ # SETUP AND BUILD
+ #############################################################################
+
+-TARGETS=$(BUILDDIR)/bin/squake \
+- $(BUILDDIR)/bin/glquake \
+- $(BUILDDIR)/bin/glquake.glx \
+- $(BUILDDIR)/bin/glquake.3dfxgl \
+- $(BUILDDIR)/bin/quake.x11
++#TARGETS=$(BUILDDIR)/bin/squake \
++# $(BUILDDIR)/bin/glquake \
++# $(BUILDDIR)/bin/glquake.glx \
++# $(BUILDDIR)/bin/glquake.3dfxgl \
++# $(BUILDDIR)/bin/quake.x11
+ # $(BUILDDIR)/bin/unixded
++
++TARGETS=$(BUILDDIR)/bin/glquake.glx \
++ $(BUILDDIR)/bin/quake.x11
++
++#TARGETS=$(BUILDDIR)/bin/quake.x11
+
+ build_debug:
+ @-mkdir $(BUILD_DEBUG_DIR) \
diff --git a/games/quake/patches/patch-aj b/games/quake/patches/patch-aj
new file mode 100644
index 00000000000..2c58b3ecf77
--- /dev/null
+++ b/games/quake/patches/patch-aj
@@ -0,0 +1,167 @@
+$NetBSD: patch-aj,v 1.1 2000/02/01 02:30:35 wiz Exp $
+
+--- WinQuake/snd_linux.c Tue Dec 21 18:40:36 1999
++++ ../work/WinQuake/snd_linux.c Thu Jan 20 21:52:45 2000
+@@ -25,15 +6,33 @@
+ #include <sys/mman.h>
+ #include <sys/shm.h>
+ #include <sys/wait.h>
++
++#ifdef __NetBSD__
++#include <soundcard.h>
++#endif
++
++#ifdef __linux__
+ #include <linux/soundcard.h>
++#endif
++
+ #include <stdio.h>
+ #include "quakedef.h"
+
+-int audio_fd;
++int audio_fd = -1;
+ int snd_inited;
+
+ static int tryrates[] = { 11025, 22051, 44100, 8000 };
+
++#ifdef __linux__
++char *audio_device="/dev/dsp";
++#define MMAP_PROTECTION PROT_WRITE
++#endif
++
++#ifdef __NetBSD__
++char *audio_device="/dev/audio";
++#define MMAP_PROTECTION PROT_WRITE|PROT_READ
++#endif
++
+ qboolean SNDDMA_Init(void)
+ {
+
+@@ -47,28 +46,29 @@
+
+ snd_inited = 0;
+
+-// open /dev/dsp, confirm capability to mmap, and get size of dma buffer
++// open /dev/dsp or whatever, confirm capability to mmap, and get size of
++// dma buffer
+
+- audio_fd = open("/dev/dsp", O_RDWR);
++ audio_fd = open(audio_device, O_RDWR);
+ if (audio_fd < 0)
+ {
+- perror("/dev/dsp");
+- Con_Printf("Could not open /dev/dsp\n");
++ perror(audio_device);
++ Con_Printf("Could not open %s\n",audio_device);
+ return 0;
+ }
+
+ rc = ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
+- Con_Printf("Could not reset /dev/dsp\n");
++ perror(audio_device);
++ Con_Printf("Could not reset %s\n",audio_device);
+ close(audio_fd);
+ return 0;
+ }
+
+ if (ioctl(audio_fd, SNDCTL_DSP_GETCAPS, &caps)==-1)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Sound driver too old\n");
+ close(audio_fd);
+ return 0;
+@@ -130,11 +130,11 @@
+ // memory map the dma buffer
+
+ shm->buffer = (unsigned char *) mmap(NULL, info.fragstotal
+- * info.fragsize, PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);
++ * info.fragsize, MMAP_PROTECTION, MAP_FILE|MAP_SHARED, audio_fd, 0);
+ if (!shm->buffer || shm->buffer == (unsigned char *)-1)
+ {
+- perror("/dev/dsp");
+- Con_Printf("Could not mmap /dev/dsp\n");
++ perror(audio_device);
++ Con_Printf("Could not mmap %s\n",audio_device);
+ close(audio_fd);
+ return 0;
+ }
+@@ -145,8 +145,8 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
+- Con_Printf("Could not set /dev/dsp to stereo=%d", shm->channels);
++ perror(audio_device);
++ Con_Printf("Could not set %s to stereo=%d", audio_device, shm->channels);
+ close(audio_fd);
+ return 0;
+ }
+@@ -158,8 +158,8 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_SPEED, &shm->speed);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
+- Con_Printf("Could not set /dev/dsp speed to %d", shm->speed);
++ perror(audio_device);
++ Con_Printf("Could not set %s speed to %d", audio_device, shm->speed);
+ close(audio_fd);
+ return 0;
+ }
+@@ -170,7 +170,7 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETFMT, &rc);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Could not support 16-bit data. Try 8-bit.\n");
+ close(audio_fd);
+ return 0;
+@@ -182,7 +182,7 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETFMT, &rc);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Could not support 8-bit data.\n");
+ close(audio_fd);
+ return 0;
+@@ -190,7 +190,7 @@
+ }
+ else
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("%d-bit sound not supported.", shm->samplebits);
+ close(audio_fd);
+ return 0;
+@@ -202,7 +202,7 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Could not toggle.\n");
+ close(audio_fd);
+ return 0;
+@@ -211,7 +211,7 @@
+ rc = ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
+ if (rc < 0)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Could not toggle.\n");
+ close(audio_fd);
+ return 0;
+@@ -233,7 +233,7 @@
+
+ if (ioctl(audio_fd, SNDCTL_DSP_GETOPTR, &count)==-1)
+ {
+- perror("/dev/dsp");
++ perror(audio_device);
+ Con_Printf("Uh, sound dead.\n");
+ close(audio_fd);
+ snd_inited = 0;
diff --git a/games/quake/patches/patch-ak b/games/quake/patches/patch-ak
new file mode 100644
index 00000000000..9f9f5f238a2
--- /dev/null
+++ b/games/quake/patches/patch-ak
@@ -0,0 +1,14 @@
+$NetBSD: patch-ak,v 1.1 2000/02/01 02:30:35 wiz Exp $
+
+--- WinQuake/vid_x.c.orig Tue Dec 21 18:40:22 1999
++++ WinQuake/vid_x.c Fri Jan 28 23:34:06 2000
+@@ -711,6 +711,9 @@
+ void VID_Shutdown (void)
+ {
+ Con_Printf("VID_Shutdown\n");
++ /* if display hasn't been initialised, we don't have to close it */
++ if (!x_disp)
++ return;
+ XAutoRepeatOn(x_disp);
+ XCloseDisplay(x_disp);
+ }