summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorblymn <blymn@pkgsrc.org>2002-09-24 12:49:10 +0000
committerblymn <blymn@pkgsrc.org>2002-09-24 12:49:10 +0000
commite7f30874f4b520b1c67bc84d1347680969fd0801 (patch)
tree11a5be3c5fc7fd7844908e64a2dfef06e167d263 /games
parent0e2ecc2fd06989721c28ddf379d45a4b5df5ebb7 (diff)
downloadpkgsrc-e7f30874f4b520b1c67bc84d1347680969fd0801.tar.gz
bzflag is an OpenGL based multiplayer tank game.
Diffstat (limited to 'games')
-rw-r--r--games/bzflag/DESCR2
-rw-r--r--games/bzflag/Makefile29
-rw-r--r--games/bzflag/PLIST58
-rw-r--r--games/bzflag/distinfo17
-rw-r--r--games/bzflag/patches/patch-aa20
-rw-r--r--games/bzflag/patches/patch-ab123
-rw-r--r--games/bzflag/patches/patch-ac219
-rw-r--r--games/bzflag/patches/patch-ad57
-rw-r--r--games/bzflag/patches/patch-ae482
-rw-r--r--games/bzflag/patches/patch-af84
-rw-r--r--games/bzflag/patches/patch-ag67
-rw-r--r--games/bzflag/patches/patch-ah44
-rw-r--r--games/bzflag/patches/patch-ai45
-rw-r--r--games/bzflag/patches/patch-aj30
-rw-r--r--games/bzflag/patches/patch-ak17
-rw-r--r--games/bzflag/patches/patch-al21
-rw-r--r--games/bzflag/patches/patch-am25
17 files changed, 1340 insertions, 0 deletions
diff --git a/games/bzflag/DESCR b/games/bzflag/DESCR
new file mode 100644
index 00000000000..d79bac96df5
--- /dev/null
+++ b/games/bzflag/DESCR
@@ -0,0 +1,2 @@
+bzflag is a classic OpenGL tank game that originated on SGI machines now
+it is open for all to enjoy. Pick up flags and shoot other tanks.
diff --git a/games/bzflag/Makefile b/games/bzflag/Makefile
new file mode 100644
index 00000000000..a5217923405
--- /dev/null
+++ b/games/bzflag/Makefile
@@ -0,0 +1,29 @@
+# $NetBSD: Makefile,v 1.1.1.1 2002/09/24 12:49:10 blymn Exp $
+
+DISTNAME= bzflag-1.7e6
+PKGNAME= ${DISTNAME:S/e/.5./}
+CATEGORIES= games x11
+MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=bzflag/}
+EXTRACT_SUFX= .tgz
+
+MAINTAINER= blymn@baea.com.au
+HOMEPAGE= http://www.bzflag.org/
+COMMENT= OpenGL tank game
+
+USE_X11BASE= yes
+USE_BUILDLINK2= yes
+USE_GMAKE= yes
+MAKE_ENV+= X11BASE=${X11BASE} INSTALL_PREFIX=${X11PREFIX}
+
+ALL_TARGET= netbsd default
+
+do-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/bin/bzflag ${PREFIX}/bin
+ ${INSTALL_PROGRAM} ${WRKSRC}/bin/bzfls ${PREFIX}/bin
+ ${INSTALL_PROGRAM} ${WRKSRC}/bin/bzfrelay ${PREFIX}/bin
+ ${INSTALL_PROGRAM} ${WRKSRC}/bin/bzfs ${PREFIX}/bin
+ ${INSTALL_DATA_DIR} ${PREFIX}/share/bzflag
+ ${CP} ${WRKSRC}/data/* ${PREFIX}/share/bzflag
+
+.include "../../graphics/Mesa/buildlink2.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/games/bzflag/PLIST b/games/bzflag/PLIST
new file mode 100644
index 00000000000..94bdc5377c7
--- /dev/null
+++ b/games/bzflag/PLIST
@@ -0,0 +1,58 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2002/09/24 12:49:10 blymn Exp $
+bin/bzflag
+bin/bzfls
+bin/bzfrelay
+bin/bzfs
+share/bzflag/Bzflag.fti
+share/bzflag/Bzflag.ftr
+share/bzflag/Bzfs.fti
+share/bzflag/bbolt.rgb
+share/bzflag/blaser.rgb
+share/bzflag/boom.wav
+share/bzflag/boxwall.rgb
+share/bzflag/caution.rgb
+share/bzflag/clouds.rgb
+share/bzflag/explode1.rgb
+share/bzflag/explosion.wav
+share/bzflag/fire.wav
+share/bzflag/fixedbr.rgb
+share/bzflag/fixedmr.rgb
+share/bzflag/flag.rgb
+share/bzflag/flag_alert.wav
+share/bzflag/flag_drop.wav
+share/bzflag/flag_grab.wav
+share/bzflag/flag_lost.wav
+share/bzflag/flag_won.wav
+share/bzflag/flage.rgb
+share/bzflag/gbolt.rgb
+share/bzflag/glaser.rgb
+share/bzflag/ground.rgb
+share/bzflag/helvbi.rgb
+share/bzflag/helvbr.rgb
+share/bzflag/jump.wav
+share/bzflag/killteam.wav
+share/bzflag/land.wav
+share/bzflag/laser.wav
+share/bzflag/lock.wav
+share/bzflag/missile.rgb
+share/bzflag/missile.wav
+share/bzflag/mountain.rgb
+share/bzflag/panel.rgb
+share/bzflag/pbolt.rgb
+share/bzflag/phantom.wav
+share/bzflag/plaser.rgb
+share/bzflag/pop.wav
+share/bzflag/pyrwall.rgb
+share/bzflag/rbolt.rgb
+share/bzflag/ricochet.wav
+share/bzflag/rlaser.rgb
+share/bzflag/roof.rgb
+share/bzflag/shock.wav
+share/bzflag/teleport.wav
+share/bzflag/timesbi.rgb
+share/bzflag/timesbr.rgb
+share/bzflag/title.rgb
+share/bzflag/wall.rgb
+share/bzflag/ybolt.rgb
+share/bzflag/ylaser.rgb
+@dirrm share/bzflag
diff --git a/games/bzflag/distinfo b/games/bzflag/distinfo
new file mode 100644
index 00000000000..3b0b5e5b85b
--- /dev/null
+++ b/games/bzflag/distinfo
@@ -0,0 +1,17 @@
+$NetBSD: distinfo,v 1.1.1.1 2002/09/24 12:49:10 blymn Exp $
+
+SHA1 (bzflag-1.7e6.tgz) = 283a5f4eae87c43a1a7772e9ca40048df0e84bda
+Size (bzflag-1.7e6.tgz) = 2428811 bytes
+SHA1 (patch-aa) = b96af1e1a6a5ecbf1cde1007fc4fd06f7d005c42
+SHA1 (patch-ab) = 3a28e7be95b39ffbe25c27d77e01b87926ec3d26
+SHA1 (patch-ac) = 81d06903bd4e7cf433b070562647069247c04b8a
+SHA1 (patch-ad) = 1393333c31a1be69a8a24f7d18e01539651356f8
+SHA1 (patch-ae) = 9c6f5df5f85c5aa8dcd12506bd7129dfbac38acf
+SHA1 (patch-af) = e604489f687ba6858ed7916eed9f63e2d068929b
+SHA1 (patch-ag) = e5f539e70cfb527d0faa05bfe2afb777242df6bb
+SHA1 (patch-ah) = c997a123696e7a26ef8f39950f8bea4a7eaf6ebc
+SHA1 (patch-ai) = 50bfe81735a71abb69b203272d28312a93c0eaaf
+SHA1 (patch-aj) = 2c88ce8add674a9a28d686bd5f7b1d2958f3084f
+SHA1 (patch-ak) = abdef8fe4c4efe622540b3f2da0b6153dbf5cdab
+SHA1 (patch-al) = 586abdf3c690162adb861a00147038bdce4b5543
+SHA1 (patch-am) = f82c2fa9ad22beec209e789ecb463caf58272004
diff --git a/games/bzflag/patches/patch-aa b/games/bzflag/patches/patch-aa
new file mode 100644
index 00000000000..53d50162146
--- /dev/null
+++ b/games/bzflag/patches/patch-aa
@@ -0,0 +1,20 @@
+$NetBSD: patch-aa,v 1.1.1.1 2002/09/24 12:49:10 blymn Exp $
+
+--- Makefile.orig Sun Sep 22 22:24:02 2002
++++ Makefile
+@@ -33,6 +33,7 @@ AVAILTARGETS = \
+ linux-ppc \
+ solaris-cc \
+ solaris-gcc \
++ netbsd \
+ $(NULL)
+
+ config-sys:
+@@ -42,6 +43,7 @@ config-sys:
+ @echo " make linux"
+ @echo " make linux-i386"
+ @echo " make linux-ppc"
++ @echo " make netbsd"
+ @echo " make solaris-cc"
+ @echo " make solaris-gcc"
+ @echo " make win32"
diff --git a/games/bzflag/patches/patch-ab b/games/bzflag/patches/patch-ab
new file mode 100644
index 00000000000..ff8f3819b41
--- /dev/null
+++ b/games/bzflag/patches/patch-ab
@@ -0,0 +1,123 @@
+$NetBSD: patch-ab,v 1.1.1.1 2002/09/24 12:49:11 blymn Exp $
+
+--- configs/config-netbsd.orig Mon Sep 23 15:26:33 2002
++++ configs/config-netbsd
+@@ -0,0 +1,118 @@
++# bzflag
++# Copyright (c) 1993 - 2002 Tim Riker
++#
++# This package is free software; you can redistribute it and/or
++# modify it under the terms of the license found in the file
++# named LICENSE that should have accompanied this file.
++#
++# THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++
++#
++# configuration for generic netbsd
++#
++CONFIG = netbsd
++
++#
++# use XF86 vidmode extension (comment out to disable)
++#
++XF86VIDMODE_DEF = -DXF86VIDMODE_EXT
++XF86VIDMODE_LIB = -lXxf86vm
++
++#
++# use XInput extension for joystick support (comment out to disable)
++#
++JOYSTICK_DEF = -DXIJOYSTICK
++JOYSTICK_LIB = -lXi
++
++#
++# accumulate extension definitions and libs
++#
++XEXT_DEF = $(XF86VIDMODE_DEF) $(JOYSTICK_DEF)
++XEXT_LIB = $(XF86VIDMODE_LIB) $(JOYSTICK_LIB)
++
++#
++# install locations
++#
++INSTALL_DATA_DIR = $(X11PREFIX)/share/bzflag
++
++#
++# tools
++#
++AR = /usr/bin/ar cru
++CC = /usr/bin/gcc
++CXX = /usr/bin/g++
++CD = cd
++CP = /bin/cp
++LD = /usr/bin/ld
++MKDIR = /bin/mkdir
++NROFF = /usr/bin/nroff
++RM = /bin/rm -f
++RMR = $(RM) -r
++SHELL = /bin/sh
++ECHO = echo
++
++#
++# compiler definitions
++#
++PCDEFS = -D_BSD_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -DHALF_RATE_AUDIO $(XEXT_DEF)
++PCXXDEFS = -D_BSD_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -DHALF_RATE_AUDIO $(XEXT_DEF)
++
++#
++# compiler options
++#
++PCOPTS = -Wall -W -ansi $(ACOPTS)
++PCXXOPTS = -Wall -W -fno-exceptions -fno-rtti $(ACXXOPTS)
++COPT = -DNDEBUG -O2
++CXXOPT = -DNDEBUG -O2 -ffast-math -fomit-frame-pointer -fnonnull-objects \
++ -fexpensive-optimizations
++CDEBUG = -DDEBUG -g
++CXXDEBUG = -DDEBUG -g
++CWOFF =
++CXXWOFF =
++
++#
++# search paths
++#
++PCINCS = -I/usr/include -I$(X11BASE)/include
++PCXXINCS = -I/usr/include -I$(X11BASE)/include
++
++#
++# linker options
++#
++PLDOPTS = -L$(X11BASE)/lib -Wl,-R$(X11BASE)/lib
++
++#
++# dirt
++#
++PDIRT = *.[eou] a.out core ar.tmp.*
++
++#
++# libraries
++#
++AUDIO_LIBS = \
++ $(NULL)
++
++DISPLAY_LIBS = \
++ $(NULL)
++
++GL_LIBS = \
++ -lGLU \
++ -lGL \
++ $(NULL)
++
++IMAGE_LIBS = \
++ $(NULL)
++
++NETWORK_LIBS = \
++ $(NULL)
++
++WINDOW_LIBS = \
++ $(XEXT_LIB) \
++ -lXext \
++ -lX11 \
++ -lossaudio \
++ -lm \
++ $(NULL)
++
diff --git a/games/bzflag/patches/patch-ac b/games/bzflag/patches/patch-ac
new file mode 100644
index 00000000000..a444080ffcd
--- /dev/null
+++ b/games/bzflag/patches/patch-ac
@@ -0,0 +1,219 @@
+$NetBSD: patch-ac,v 1.1.1.1 2002/09/24 12:49:12 blymn Exp $
+
+--- src/platform/NetBSDDisplay.cxx.orig Sun Sep 22 22:29:02 2002
++++ src/platform/NetBSDDisplay.cxx
+@@ -0,0 +1,214 @@
++/* bzflag
++ * Copyright (c) 1993 - 2002 Tim Riker
++ *
++ * This package is free software; you can redistribute it and/or
++ * modify it under the terms of the license found in the file
++ * named LICENSE that should have accompanied this file.
++ *
++ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
++#include "NetBSDDisplay.h"
++#include "XWindow.h"
++
++#if defined(USE_XF86VIDMODE_EXT)
++#include <stdio.h>
++
++// evaluates to the (approximate) vertical retrace speed of modeinfo _r
++#define getRetrace(_r) ((int)(0.5f + (1000.0f * (_r)->dotclock) / \
++ ((_r)->htotal * (_r)->vtotal)))
++
++static int resolutionCompare(const void* _a, const void* _b)
++{
++ const XF86VidModeModeInfo* a = *((const XF86VidModeModeInfo**)_a);
++ const XF86VidModeModeInfo* b = *((const XF86VidModeModeInfo**)_b);
++
++ // test the stuff we actually care about
++ if (a->hdisplay < b->hdisplay) return -1;
++ if (a->hdisplay > b->hdisplay) return 1;
++ if (a->vdisplay < b->vdisplay) return -1;
++ if (a->vdisplay > b->vdisplay) return 1;
++ if (getRetrace(a) < getRetrace(b)) return -1;
++ if (getRetrace(a) > getRetrace(b)) return 1;
++
++ // other info can be ordered arbitrarily
++ return 0;
++}
++
++//
++// NetBSDDisplayMode
++//
++
++NetBSDDisplayMode::NetBSDDisplayMode() : display(NULL),
++ numResolutions(0),
++ lastResolution(-1),
++ resolutions(NULL),
++ origNumResolutions(0),
++ origResolutions(NULL)
++{
++ // do nothing
++}
++
++NetBSDDisplayMode::~NetBSDDisplayMode()
++{
++ delete[] resolutions;
++ if (origResolutions)
++ XFree(origResolutions);
++}
++
++XDisplayMode::ResInfo** NetBSDDisplayMode::init(XDisplay* _display,
++ int& numModes, int& currentMode)
++{
++ int i, eventbase, errorbase;
++
++ // save display for later
++ display = _display;
++
++ // Check if we have the XF86 vidmode extension
++ if (!XF86VidModeQueryExtension(display->getRep()->getDisplay(),
++ &eventbase, &errorbase))
++ return NULL;
++
++ // get available resolutions
++ if (!XF86VidModeGetAllModeLines(display->getRep()->getDisplay(),
++ display->getRep()->getScreen(),
++ &numResolutions, &origResolutions))
++ return NULL;
++
++ // get current resolution
++ int dotclock;
++ XF86VidModeModeLine mode;
++ XF86VidModeGetModeLine(display->getRep()->getDisplay(),
++ display->getRep()->getScreen(),
++ &dotclock, &mode);
++
++ // make a copy of the original data
++ origNumResolutions = numResolutions;
++ resolutions = new XF86VidModeModeInfo*[numResolutions];
++ for (i = 0; i < numResolutions; i++)
++ resolutions[i] = origResolutions[i];
++
++ // sort resolutions
++ qsort(resolutions, numResolutions, sizeof(resolutions[0]), resolutionCompare);
++
++ // find current resolution in the available resolution list
++ int current;
++ for (current = 0; current < numResolutions; current++) {
++ const XF86VidModeModeInfo* r = resolutions[current];
++ if (dotclock == (int)r->dotclock &&
++ mode.hdisplay == r->hdisplay &&
++ mode.hsyncstart == r->hsyncstart &&
++ mode.hsyncend == r->hsyncend &&
++ mode.htotal == r->htotal &&
++ mode.vdisplay == r->vdisplay &&
++ mode.vsyncstart == r->vsyncstart &&
++ mode.vsyncend == r->vsyncend &&
++ mode.vtotal == r->vtotal &&
++ mode.flags == r->flags)
++ break;
++ }
++
++ // no switching if current mode not found
++ if (current == numResolutions)
++ return NULL;
++
++ // compress out modes that are (effectively) duplicates. never
++ // remove the current mode.
++ for (i = 0; i < numResolutions - 1; ) {
++ if (resolutionCompare(resolutions + i, resolutions + i + 1) == 0) {
++ // is next resolution the current mode? if so then move it down
++ // so we don't blow it away.
++ if (current == i + 1)
++ resolutions[i] = resolutions[i + 1];
++
++ // move remaining resolutions down (overwriting the one after i)
++ for (int j = i + 2; j < numResolutions; j++)
++ resolutions[j - 1] = resolutions[j];
++
++ // do we move the current resolution down too?
++ if (current > i)
++ current--;
++
++ // now one less resolution
++ numResolutions--;
++ }
++ else {
++ i++;
++ }
++ }
++
++ // make ResInfo list
++ char name[80];
++ ResInfo** resInfo = new ResInfo*[numResolutions];
++ for (i = 0; i < numResolutions; i++) {
++ const XF86VidModeModeInfo* r = resolutions[i];
++ sprintf(name, "%dx%d @%d", r->hdisplay, r->vdisplay, getRetrace(r));
++ resInfo[i] = new ResInfo(name, r->hdisplay, r->vdisplay, getRetrace(r));
++ }
++
++ // return modes
++ numModes = numResolutions;
++ currentMode = current;
++ lastResolution = current;
++ return resInfo;
++}
++
++boolean NetBSDDisplayMode::set(int index)
++{
++ return doSet(index, True);
++}
++
++boolean NetBSDDisplayMode::setDefault(int index)
++{
++ return doSet(index, False);
++}
++
++boolean NetBSDDisplayMode::doSet(int index, boolean position)
++{
++ // ignore attempts to set video format to current format.
++ // normally this only happens when restoring the default
++ // format, when BzfDisplay deliberately forces the change.
++ // that's useful for win32 where the OS knows the right
++ // format and will ignore calls to switch the current
++ // format. however, irix isn't so clever and may cause
++ // the display to flicker even when the format isn't
++ // really changing.
++ if (index == lastResolution || numResolutions <= 1)
++ return True;
++
++ // deactivate windows before resolution change. if we don't do this
++ // then the app will almost certainly crash in the OpenGL driver.
++ XWindow::deactivateAll();
++
++ // change resolution
++ if (XF86VidModeSwitchToMode(display->getRep()->getDisplay(),
++ display->getRep()->getScreen(),
++ resolutions[index])) {
++ if (position) {
++ // kludge for accelerated GLX. when we set the view port after
++ // changing the resolution just before quiting, GLX does not
++ // release the display to X server control. or something like
++ // that. the effect is that you see the game window still on
++ // the screen but maybe shifted around and you can't see any of
++ // the other windows. without this code, a workaround for the
++ // problem is ctrl_alt_+ or ctrl_alt_- to force a resize.
++ XF86VidModeSetViewPort(display->getRep()->getDisplay(),
++ display->getRep()->getScreen(), 0, 0);
++ }
++ XSync(display->getRep()->getDisplay(), False);
++ lastResolution = index;
++
++ // reactivate previously deactivated window after change
++ XWindow::reactivateAll();
++ return True;
++ }
++
++ // reactivate previously deactivated window after change
++ XWindow::reactivateAll();
++ return False;
++}
++
++#endif
++// ex: shiftwidth=2 tabstop=8
diff --git a/games/bzflag/patches/patch-ad b/games/bzflag/patches/patch-ad
new file mode 100644
index 00000000000..401c58a4300
--- /dev/null
+++ b/games/bzflag/patches/patch-ad
@@ -0,0 +1,57 @@
+$NetBSD: patch-ad,v 1.1.1.1 2002/09/24 12:49:12 blymn Exp $
+
+--- src/platform/NetBSDDisplay.h.orig Sun Sep 22 22:29:02 2002
++++ src/platform/NetBSDDisplay.h
+@@ -0,0 +1,52 @@
++/* bzflag
++ * Copyright (c) 1993 - 2002 Tim Riker
++ *
++ * This package is free software; you can redistribute it and/or
++ * modify it under the terms of the license found in the file
++ * named LICENSE that should have accompanied this file.
++ *
++ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
++/* NetBSDDisplay:
++ * An X display with XFree86 vidmode extension
++ */
++
++#ifndef BZF_NETBSDDISPLAY_H
++#define BZF_NETBSDDISPLAY_H
++
++#include "XDisplay.h"
++#if defined(XF86VIDMODE_EXT)
++#define USE_XF86VIDMODE_EXT
++#define private c_private
++#include <X11/extensions/xf86vmode.h>
++#undef private
++#endif
++
++class NetBSDDisplayMode : public XDisplayMode {
++ public:
++#if defined(USE_XF86VIDMODE_EXT)
++ NetBSDDisplayMode();
++ ~NetBSDDisplayMode();
++
++ ResInfo** init(XDisplay* owner, int& num, int& current);
++ boolean set(int);
++ boolean setDefault(int);
++
++ private:
++ boolean doSet(int, boolean position);
++
++ private:
++ XDisplay* display;
++ int numResolutions;
++ int lastResolution;
++ XF86VidModeModeInfo** resolutions;
++ int origNumResolutions;
++ XF86VidModeModeInfo** origResolutions;
++#endif
++};
++
++#endif // BZF_NETBSDDISPLAY_H
++// ex: shiftwidth=2 tabstop=8
diff --git a/games/bzflag/patches/patch-ae b/games/bzflag/patches/patch-ae
new file mode 100644
index 00000000000..7683bae27b5
--- /dev/null
+++ b/games/bzflag/patches/patch-ae
@@ -0,0 +1,482 @@
+$NetBSD: patch-ae,v 1.1.1.1 2002/09/24 12:49:13 blymn Exp $
+
+--- src/platform/NetBSDMedia.cxx.orig Sun Sep 22 22:29:02 2002
++++ src/platform/NetBSDMedia.cxx
+@@ -0,0 +1,477 @@
++/* bzflag
++ * Copyright (c) 1993 - 2002 Tim Riker
++ *
++ * This package is free software; you can redistribute it and/or
++ * modify it under the terms of the license found in the file
++ * named LICENSE that should have accompanied this file.
++ *
++ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
++#include "NetBSDMedia.h"
++#include <math.h>
++#include <fcntl.h>
++#ifdef BSD
++#include <machine/endian.h>
++#else
++#ifdef __NetBSD__
++#include <sys/endian.h>
++#else
++#include <endian.h>
++#endif
++#endif
++#include <sys/time.h>
++#include <sys/types.h>
++#include <unistd.h>
++#include <sys/wait.h>
++#include "bzsignal.h"
++#ifdef __NetBSD__
++#include <soundcard.h>
++#else
++#include <sys/soundcard.h>
++#endif
++#include <sys/ioctl.h>
++#include <TimeKeeper.h>
++#include <errno.h>
++#include <string.h>
++
++#ifdef HALF_RATE_AUDIO
++static const int defaultAudioRate=11025;
++#else
++static const int defaultAudioRate=22050;
++#endif
++
++//
++// NetBSDMedia
++//
++
++NetBSDMedia::NetBSDMedia() : BzfMedia(), audioReady(False),
++ audioPortFd(-1),
++ queueIn(-1), queueOut(-1),
++ outputBuffer(NULL),
++ childProcID(0),
++ audio8Bit(False),
++ getospaceBroken(False)
++{
++ // do nothing
++}
++
++NetBSDMedia::~NetBSDMedia()
++{
++ // do nothing
++}
++
++double NetBSDMedia::getTime()
++{
++ struct timeval tv;
++ gettimeofday(&tv, 0);
++ return (double)tv.tv_sec + 1.0e-6 * (double)tv.tv_usec;
++}
++
++double NetBSDMedia::stopwatch(boolean start)
++{
++ if (start) {
++ stopwatchTime = getTime();
++ return 0.0;
++ }
++ return getTime() - stopwatchTime;
++}
++
++void NetBSDMedia::sleep(float timeInSeconds)
++{
++ struct timeval tv;
++ tv.tv_sec = (long)timeInSeconds;
++ tv.tv_usec = (long)(1.0e6 * (timeInSeconds - tv.tv_sec));
++ select(0, NULL, NULL, NULL, &tv);
++}
++
++boolean NetBSDMedia::openAudio()
++{
++ // don't re-initialize
++ if (audioReady) return False;
++
++ // check for and open audio hardware
++ if (!checkForAudioHardware() || !openAudioHardware()) return False;
++
++ // open communication channel (FIFO pipe). close on exec.
++ int fd[2];
++ if (pipe(fd)<0) {
++ closeAudio();
++ return False;
++ }
++ queueIn = fd[1];
++ queueOut = fd[0];
++ fcntl(queueIn, F_SETFL, fcntl(queueIn, F_GETFL, 0) | O_NDELAY);
++ fcntl(queueOut, F_SETFL, fcntl(queueOut, F_GETFL, 0) | O_NDELAY);
++ fcntl(queueIn, F_SETFD, fcntl(queueIn, F_GETFD, 0) | FD_CLOEXEC);
++ fcntl(queueOut, F_SETFD, fcntl(queueOut, F_GETFD, 0) | FD_CLOEXEC);
++
++ // compute maxFd for use in select() call
++ maxFd = queueOut;
++ if (maxFd<audioPortFd) maxFd = audioPortFd;
++ maxFd++;
++
++ // make an output buffer
++ outputBuffer = new short[audioBufferSize];
++
++ // Set default no thread
++ childProcID=0;
++
++ // ready to go
++ audioReady = True;
++ return True;
++}
++
++boolean NetBSDMedia::checkForAudioHardware()
++{
++ boolean flag=False;
++ if (!access("/dev/audio", W_OK)) flag=True;
++ if (!access("/dev/sound", W_OK)) flag=True;
++ return flag;
++}
++
++boolean NetBSDMedia::openIoctl(
++ int cmd, void* value, boolean req)
++{
++ if (audioPortFd == -1)
++ return False;
++
++ if (ioctl(audioPortFd, cmd, value) < 0) {
++ fprintf(stderr, "audio ioctl failed (cmd %x, err %d)... ", cmd, errno);
++ if (req) {
++ close(audioPortFd);
++ audioPortFd = -1;
++ fprintf(stderr, "giving up on audio\n");
++ }
++ else {
++ fprintf(stderr, "ignored\n");
++ }
++ return False;
++ }
++ return True;
++}
++
++static const int NumChunks = 4;
++
++boolean NetBSDMedia::openAudioHardware()
++{
++ int format, n;
++
++ // what's the audio format?
++#if BYTE_ORDER == BIG_ENDIAN
++ format = AFMT_S16_BE;
++#else
++ format = AFMT_S16_LE;
++#endif
++
++ // what the frequency?
++ audioOutputRate = defaultAudioRate;
++
++ // how big a fragment to use? we want to hold at around 1/10th of
++ // a second.
++ int fragmentSize = (int)(0.08f * (float)audioOutputRate);
++ n = 0;
++ while ((1 << n) < fragmentSize)
++ ++n;
++
++ // samples are two bytes each and we're in stereo so quadruple the size
++ fragmentSize = n + 2;
++
++ // now how many fragments and what's the low water mark (in fragments)?
++ int fragmentInfo = (NumChunks << 16) | fragmentSize;
++ audioLowWaterMark = 2;
++
++ // open device (but don't wait for it)
++ audioPortFd = open("/dev/audio", O_WRONLY | O_NDELAY, 0);
++ if (audioPortFd == -1) {
++ audioPortFd = open("/dev/sound", O_WRONLY | O_NDELAY, 0);
++ if (audioPortFd == -1) {
++ fprintf(stderr, "Failed to open audio device /dev/audio or /dev/sound (%d)\n", errno);
++ return False;
++ }
++ }
++
++ // back to blocking I/O
++ fcntl(audioPortFd, F_SETFL, fcntl(audioPortFd, F_GETFL, 0) & ~O_NDELAY);
++
++ /* close audio on exec so launched server doesn't hold sound device */
++ fcntl(audioPortFd, F_SETFD, fcntl(audioPortFd, F_GETFD) | FD_CLOEXEC);
++
++ // initialize device
++ openIoctl(SNDCTL_DSP_RESET, 0);
++ n = fragmentInfo;
++ noSetFragment = false;
++ if (!openIoctl(SNDCTL_DSP_SETFRAGMENT, &n, False)) {
++ // this is not good. we can't set the size of the fragment
++ // buffers. we'd like something short to minimize latencies
++ // and the default is probably too long. we've got two
++ // options here: accept the latency or try to force the
++ // driver to play partial fragments. we'll try the later
++ // unless BZF_AUDIO_NOPOST is in the environment
++ if (!getenv("BZF_AUDIO_NOPOST"))
++ noSetFragment = true;
++ }
++ n = format;
++ openIoctl(SNDCTL_DSP_SETFMT, &n, False);
++ if (n != format) {
++ audio8Bit = True;
++ n = AFMT_U8;
++ openIoctl(SNDCTL_DSP_SETFMT, &n);
++ }
++ n = 1;
++ openIoctl(SNDCTL_DSP_STEREO, &n);
++ n = defaultAudioRate;
++ openIoctl(SNDCTL_DSP_SPEED, &n);
++
++ // set audioBufferSize, which is the number of samples (not bytes)
++ // in each fragment. there are two bytes per sample so divide the
++ // fragment size by two unless we're in audio8Bit mode. also, if
++ // we couldn't set the fragment size then force the buffer size to
++ // the size we would've asked for. we'll force the buffer to be
++ // flushed after we write that much data to keep latency low.
++ if (noSetFragment ||
++ !openIoctl(SNDCTL_DSP_GETBLKSIZE, &audioBufferSize, False) ||
++ audioBufferSize > (1 << fragmentSize)) {
++ audioBufferSize = 1 << fragmentSize;
++ noSetFragment = true;
++ }
++ if (!audio8Bit)
++ audioBufferSize >>= 1;
++
++ // SNDCTL_DSP_GETOSPACE not supported on all platforms. check if
++ // it fails here and, if so, do a workaround by using the wall
++ // clock. *shudder*
++ if (audioPortFd != -1) {
++ audio_buf_info info;
++ if (!openIoctl(SNDCTL_DSP_GETOSPACE, &info, False)) {
++ getospaceBroken = True;
++ chunksPending = 0;
++ chunksPerSecond = (double)getAudioOutputRate() /
++ (double)getAudioBufferChunkSize();
++ }
++ }
++
++ return (audioPortFd != -1);
++}
++
++void NetBSDMedia::closeAudio()
++{
++ delete [] outputBuffer;
++ if (audioPortFd>=0) close(audioPortFd);
++ if (queueIn!=-1) close(queueIn);
++ if (queueOut!=-1) close(queueOut);
++ audioReady=False;
++ audioPortFd=-1;
++ queueIn=-1;
++ queueOut=-1;
++ outputBuffer=0;
++}
++
++boolean NetBSDMedia::startAudioThread(
++ void (*proc)(void*), void* data)
++{
++ // if no audio thread then just call proc and return
++ if (!hasAudioThread()) {
++ proc(data);
++ return True;
++ }
++
++ // has an audio thread so fork and call proc
++ if (childProcID) return True;
++ if ((childProcID=fork()) > 0) {
++ close(queueOut);
++ close(audioPortFd);
++ return True;
++ }
++ else if (childProcID < 0) {
++ return False;
++ }
++ close(queueIn);
++ proc(data);
++ exit(0);
++}
++
++void NetBSDMedia::stopAudioThread()
++{
++ if (childProcID != 0) kill(childProcID, SIGTERM);
++ childProcID=0;
++}
++
++boolean NetBSDMedia::hasAudioThread() const
++{
++#if defined(NO_AUDIO_THREAD)
++ return False;
++#else
++ return True;
++#endif
++}
++
++void NetBSDMedia::audioThreadInit(void*)
++{
++}
++
++void NetBSDMedia::writeSoundCommand(const void* cmd, int len)
++{
++ if (!audioReady) return;
++ write(queueIn, cmd, len);
++}
++
++boolean NetBSDMedia::readSoundCommand(void* cmd, int len)
++{
++ return (read(queueOut, cmd, len)==len);
++}
++
++int NetBSDMedia::getAudioOutputRate() const
++{
++ return audioOutputRate;
++}
++
++int NetBSDMedia::getAudioBufferSize() const
++{
++ return NumChunks*(audioBufferSize>>1);
++}
++
++int NetBSDMedia::getAudioBufferChunkSize() const
++{
++ return audioBufferSize>>1;
++}
++
++boolean NetBSDMedia::isAudioTooEmpty() const
++{
++ if (getospaceBroken) {
++ if (chunksPending > 0) {
++ // get time elapsed since chunkTime
++ const double dt = getTime() - chunkTime;
++
++ // how many chunks could've played in the elapsed time?
++ const int numChunks = (int)(dt * chunksPerSecond);
++
++ // remove pending chunks
++ NetBSDMedia* self = (NetBSDMedia*)this;
++ self->chunksPending -= numChunks;
++ if (chunksPending < 0)
++ self->chunksPending = 0;
++ else
++ self->chunkTime += (double)numChunks / chunksPerSecond;
++ }
++ return chunksPending < audioLowWaterMark;
++ }
++ else {
++ audio_buf_info info;
++ if (ioctl(audioPortFd, SNDCTL_DSP_GETOSPACE, &info) < 0)
++ return False;
++ return info.fragments > info.fragstotal - audioLowWaterMark;
++ }
++}
++
++void NetBSDMedia::writeAudioFrames8Bit(
++ const float* samples, int numFrames)
++{
++ int numSamples = 2 * numFrames;
++ int limit;
++ char *smOutputBuffer;
++
++ smOutputBuffer=(char*)outputBuffer;
++ while (numSamples > 0) {
++ if (numSamples>audioBufferSize) limit=audioBufferSize;
++ else limit=numSamples;
++ for (int j = 0; j < limit; j++) {
++ if (samples[j] <= -32767.0) smOutputBuffer[j] = 0;
++ else if (samples[j] >= 32767.0) smOutputBuffer[j] = 255;
++ else smOutputBuffer[j] = char((samples[j]+32767)/257);
++ }
++
++ // fill out the chunk (we never write a partial chunk)
++ if (limit < audioBufferSize) {
++ for (int j = limit; j < audioBufferSize; ++j)
++ smOutputBuffer[j] = 127;
++ limit = audioBufferSize;
++ }
++
++ write(audioPortFd, smOutputBuffer, limit);
++ samples += limit;
++ numSamples -= limit;
++ }
++}
++
++void NetBSDMedia::writeAudioFrames16Bit(
++ const float* samples, int numFrames)
++{
++ int numSamples = 2 * numFrames;
++ int limit;
++
++ while (numSamples > 0) {
++ if (numSamples>audioBufferSize) limit=audioBufferSize;
++ else limit=numSamples;
++ for (int j = 0; j < limit; j++) {
++ if (samples[j] < -32767.0) outputBuffer[j] = -32767;
++ else if (samples[j] > 32767.0) outputBuffer[j] = 32767;
++ else outputBuffer[j] = short(samples[j]);
++ }
++
++ // fill out the chunk (we never write a partial chunk)
++ if (limit < audioBufferSize) {
++ for (int j = limit; j < audioBufferSize; ++j)
++ outputBuffer[j] = 0;
++ limit = audioBufferSize;
++ }
++
++ write(audioPortFd, outputBuffer, 2*limit);
++ samples += limit;
++ numSamples -= limit;
++ }
++}
++
++void NetBSDMedia::writeAudioFrames(
++ const float* samples, int numFrames)
++{
++ if (audio8Bit) writeAudioFrames8Bit(samples, numFrames);
++ else writeAudioFrames16Bit(samples, numFrames);
++
++ // if we couldn't set the fragment size then force the driver
++ // to play the short buffer.
++ if (noSetFragment) {
++ int dummy = 0;
++ ioctl(audioPortFd, SNDCTL_DSP_POST, &dummy);
++ }
++
++ if (getospaceBroken) {
++ if (chunksPending == 0)
++ chunkTime = getTime();
++ chunksPending += (numFrames + getAudioBufferChunkSize() - 1) /
++ getAudioBufferChunkSize();
++ }
++}
++
++void NetBSDMedia::audioSleep(
++ boolean checkLowWater, double endTime)
++{
++ fd_set commandSelectSet;
++ struct timeval tv;
++
++ // To do both these operations at once, we need to poll.
++ if (checkLowWater) {
++ // start looping
++ TimeKeeper start = TimeKeeper::getCurrent();
++ do {
++ // break if buffer has drained enough
++ if (isAudioTooEmpty()) break;
++ FD_ZERO(&commandSelectSet);
++ FD_SET(queueOut, &commandSelectSet);
++ tv.tv_sec=0;
++ tv.tv_usec=50000;
++ if (select(maxFd, &commandSelectSet, 0, 0, &tv)) break;
++
++ } while (endTime<0.0 || (TimeKeeper::getCurrent()-start)<endTime);
++ } else {
++ FD_ZERO(&commandSelectSet);
++ FD_SET(queueOut, &commandSelectSet);
++ tv.tv_sec=int(endTime);
++ tv.tv_usec=int(1.0e6*(endTime-floor(endTime)));
++
++ select(maxFd, &commandSelectSet, 0, 0, (endTime>=0.0)?&tv : 0);
++ }
++}
++// ex: shiftwidth=2 tabstop=8
diff --git a/games/bzflag/patches/patch-af b/games/bzflag/patches/patch-af
new file mode 100644
index 00000000000..026b85ea883
--- /dev/null
+++ b/games/bzflag/patches/patch-af
@@ -0,0 +1,84 @@
+$NetBSD: patch-af,v 1.1.1.1 2002/09/24 12:49:13 blymn Exp $
+
+--- src/platform/NetBSDMedia.h.orig Sun Sep 22 22:29:02 2002
++++ src/platform/NetBSDMedia.h
+@@ -0,0 +1,79 @@
++/* bzflag
++ * Copyright (c) 1993 - 2002 Tim Riker
++ *
++ * This package is free software; you can redistribute it and/or
++ * modify it under the terms of the license found in the file
++ * named LICENSE that should have accompanied this file.
++ *
++ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
++/* NetBSDMedia:
++ * Media I/O on NetBSD
++ */
++
++#ifndef BZF_NETBSDMEDIA_H
++#define BZF_NETBSDMEDIA_H
++
++#include "BzfMedia.h"
++#include <stdio.h>
++#include <unistd.h>
++
++class NetBSDMedia : public BzfMedia {
++ public:
++ NetBSDMedia();
++ ~NetBSDMedia();
++
++ double stopwatch(boolean);
++ void sleep(float);
++ boolean openAudio();
++ void closeAudio();
++ boolean startAudioThread(void (*)(void*), void*);
++ void stopAudioThread();
++ boolean hasAudioThread() const;
++ void writeSoundCommand(const void*, int);
++ boolean readSoundCommand(void*, int);
++ int getAudioOutputRate() const;
++ int getAudioBufferSize() const;
++ int getAudioBufferChunkSize() const;
++ boolean isAudioTooEmpty() const;
++ void writeAudioFrames(const float* samples, int numFrames);
++ void audioSleep(boolean checkLowWater, double maxTime);
++
++ private:
++ boolean checkForAudioHardware();
++ boolean openAudioHardware();
++ boolean openIoctl(int cmd, void* value, boolean req = True);
++ static void audioThreadInit(void*);
++
++ void writeAudioFrames8Bit(
++ const float* samples, int numFrames);
++ void writeAudioFrames16Bit(
++ const float* samples, int numFrames);
++
++ static double getTime();
++
++ private:
++ boolean audioReady;
++ int audioOutputRate;
++ int audioBufferSize;
++ int audioLowWaterMark;
++ int maxFd;
++ int audioPortFd;
++ int queueIn, queueOut;
++ short* outputBuffer;
++ pid_t childProcID;
++ double stopwatchTime;
++ boolean audio8Bit;
++
++ boolean noSetFragment;
++ boolean getospaceBroken;
++ int chunksPending;
++ double chunkTime;
++ double chunksPerSecond;
++};
++
++#endif // BZF_NETBSDMEDIA_H
++// ex: shiftwidth=2 tabstop=8
diff --git a/games/bzflag/patches/patch-ag b/games/bzflag/patches/patch-ag
new file mode 100644
index 00000000000..f552031bfb1
--- /dev/null
+++ b/games/bzflag/patches/patch-ag
@@ -0,0 +1,67 @@
+$NetBSD: patch-ag,v 1.1.1.1 2002/09/24 12:49:13 blymn Exp $
+
+--- src/platform/NetBSDPlatformFactory.cxx.orig Sun Sep 22 22:29:02 2002
++++ src/platform/NetBSDPlatformFactory.cxx
+@@ -0,0 +1,62 @@
++/* bzflag
++ * Copyright (c) 1993 - 2002 Tim Riker
++ *
++ * This package is free software; you can redistribute it and/or
++ * modify it under the terms of the license found in the file
++ * named LICENSE that should have accompanied this file.
++ *
++ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
++#include "NetBSDPlatformFactory.h"
++#include "NetBSDDisplay.h"
++#include "XVisual.h"
++#include "XWindow.h"
++#include "NetBSDMedia.h"
++
++PlatformFactory* PlatformFactory::getInstance()
++{
++ if (!instance) instance = new NetBSDPlatformFactory;
++ return instance;
++}
++
++NetBSDPlatformFactory::NetBSDPlatformFactory()
++{
++ // do nothing
++}
++
++NetBSDPlatformFactory::~NetBSDPlatformFactory()
++{
++ // do nothing
++}
++
++BzfDisplay* NetBSDPlatformFactory::createDisplay(
++ const char* name, const char*)
++{
++ XDisplay* display = new XDisplay(name, new NetBSDDisplayMode);
++ if (!display || !display->isValid()) {
++ delete display;
++ return NULL;
++ }
++ return display;
++}
++
++BzfVisual* NetBSDPlatformFactory::createVisual(
++ const BzfDisplay* display)
++{
++ return new XVisual((const XDisplay*)display);
++}
++
++BzfWindow* NetBSDPlatformFactory::createWindow(
++ const BzfDisplay* display, BzfVisual* visual)
++{
++ return new XWindow((const XDisplay*)display, (XVisual*)visual);
++}
++
++BzfMedia* NetBSDPlatformFactory::createMedia()
++{
++ return new NetBSDMedia;
++}
++// ex: shiftwidth=2 tabstop=8
diff --git a/games/bzflag/patches/patch-ah b/games/bzflag/patches/patch-ah
new file mode 100644
index 00000000000..0b82193ada1
--- /dev/null
+++ b/games/bzflag/patches/patch-ah
@@ -0,0 +1,44 @@
+$NetBSD: patch-ah,v 1.1.1.1 2002/09/24 12:49:13 blymn Exp $
+
+--- src/platform/NetBSDPlatformFactory.h.orig Sun Sep 22 22:29:02 2002
++++ src/platform/NetBSDPlatformFactory.h
+@@ -0,0 +1,39 @@
++/* bzflag
++ * Copyright (c) 1993 - 2002 Tim Riker
++ *
++ * This package is free software; you can redistribute it and/or
++ * modify it under the terms of the license found in the file
++ * named LICENSE that should have accompanied this file.
++ *
++ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
++/* NetBSDPlatformFactory:
++ * Factory for NetBSD platform stuff.
++ */
++
++#ifndef BZF_NETBSD_PLATFORM_FACTORY_H
++#define BZF_NETBSD_PLATFORM_FACTORY_H
++
++#include "PlatformFactory.h"
++
++class NetBSDPlatformFactory : public PlatformFactory {
++ public:
++ NetBSDPlatformFactory();
++ ~NetBSDPlatformFactory();
++
++ BzfDisplay* createDisplay(const char* name, const char*);
++ BzfVisual* createVisual(const BzfDisplay*);
++ BzfWindow* createWindow(const BzfDisplay*, BzfVisual*);
++
++ private:
++ NetBSDPlatformFactory(const NetBSDPlatformFactory&);
++ NetBSDPlatformFactory& operator=(const NetBSDPlatformFactory&);
++
++ BzfMedia* createMedia();
++};
++
++#endif // BZF_NETBSD_PLATFORM_FACTORY_H
++// ex: shiftwidth=2 tabstop=8
diff --git a/games/bzflag/patches/patch-ai b/games/bzflag/patches/patch-ai
new file mode 100644
index 00000000000..745ab48345a
--- /dev/null
+++ b/games/bzflag/patches/patch-ai
@@ -0,0 +1,45 @@
+$NetBSD: patch-ai,v 1.1.1.1 2002/09/24 12:49:13 blymn Exp $
+
+--- include/common.h.orig Sun Sep 22 22:36:51 2002
++++ include/common.h
+@@ -22,6 +22,22 @@
+ #include <sys/param.h>
+ #endif
+
++#ifdef __NetBSD__
++typedef unsigned long u_long;
++typedef unsigned short u_short;
++#include <sys/endian.h>
++#include <sys/types.h>
++#include <strings.h>
++#define O_NDELAY O_NONBLOCK /* compat */
++
++__BEGIN_DECLS
++int inet_aton(const char *, struct in_addr *);
++const char *hstrerror(int);
++int setenv(const char *, const char *, int);
++void unsetenv(const char *);
++__END_DECLS
++#endif
++
+ #if defined(_WIN32)
+ // turn off bogus `this used in base member initialization list'
+ #pragma warning(disable: 4355)
+@@ -57,7 +73,7 @@ const boolean False = 0;
+ const boolean True = !False;
+
+ // some platforms don't have float versions of the math library
+-#if defined(_old_linux_) || defined(_MACOSX_) || defined(sun)
++#if defined(_old_linux_) || defined(_MACOSX_) || defined(sun) || defined(__NetBSD__)
+ #define asinf (float)asin
+ #define atanf (float)atan
+ #define atan2f (float)atan2
+@@ -82,7 +98,7 @@ const boolean True = !False;
+
+ #if !defined(_WIN32) & !defined(macintosh)
+
+-#ifndef BSD
++#if !defined(BSD) && !defined(__NetBSD__)
+ #include <values.h>
+ #endif
+ #include <sys/types.h>
diff --git a/games/bzflag/patches/patch-aj b/games/bzflag/patches/patch-aj
new file mode 100644
index 00000000000..9b3507e772e
--- /dev/null
+++ b/games/bzflag/patches/patch-aj
@@ -0,0 +1,30 @@
+$NetBSD: patch-aj,v 1.1.1.1 2002/09/24 12:49:13 blymn Exp $
+
+--- include/network.h.orig Sun Sep 22 22:37:32 2002
++++ include/network.h
+@@ -38,10 +38,13 @@
+ #undef TCP_NODELAY
+ #undef TCP_MAXSEG
+ #endif
++#ifdef __NetBSD__
++#include <sys/endian.h>
++#endif
+ #include <netinet/tcp.h>
+ #include <arpa/inet.h>
+ #include <netdb.h>
+-#if defined(_old_linux_) || (!defined(__linux__) && !defined(sun) && !defined(__FreeBSD__) && !defined(macintosh))
++#if defined(_old_linux_) || (!defined(__linux__) && !defined(sun) && !defined(__FreeBSD__) && !defined(macintosh) && !defined(__NetBSD__))
+ #include <bstring.h>
+ #endif
+
+@@ -69,6 +72,10 @@
+
+ #if defined(__FreeBSD__) && !defined(_MACOSX_)
+ #define AddrLen socklen_t
++#endif
++
++#if defined(__NetBSD__)
++#define AddrLen socklen_t
+ #endif
+
+ #if defined(sun)
diff --git a/games/bzflag/patches/patch-ak b/games/bzflag/patches/patch-ak
new file mode 100644
index 00000000000..5c10b06e919
--- /dev/null
+++ b/games/bzflag/patches/patch-ak
@@ -0,0 +1,17 @@
+$NetBSD: patch-ak,v 1.1.1.1 2002/09/24 12:49:13 blymn Exp $
+
+--- src/bzfrelay/bzfrelay.c.orig Sun Sep 22 22:41:45 2002
++++ src/bzfrelay/bzfrelay.c
+@@ -16,6 +16,12 @@
+ * note that this program does not depend on any other bzflag files.
+ */
+
++#ifdef __NetBSD__
++typedef unsigned long u_long;
++typedef unsigned short u_short;
++#define O_NDELAY O_NONBLOCK /* compat */
++#endif
++
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stdarg.h>
diff --git a/games/bzflag/patches/patch-al b/games/bzflag/patches/patch-al
new file mode 100644
index 00000000000..b9a58b7ebe4
--- /dev/null
+++ b/games/bzflag/patches/patch-al
@@ -0,0 +1,21 @@
+$NetBSD: patch-al,v 1.1.1.1 2002/09/24 12:49:13 blymn Exp $
+
+--- src/bzflag/bzflag.cxx.orig Sun Sep 22 22:45:49 2002
++++ src/bzflag/bzflag.cxx
+@@ -473,14 +473,14 @@ static void parse(int argc, char** argv
+ resources.addValue("window", "");
+ }
+ else if (strcmp(argv[i], "-3dfx") == 0 || strcmp(argv[i], "-3Dfx") == 0) {
+-#if !defined(__linux__)
++#if !defined(__linux__) && !defined(__NetBSD__)
+ putenv("MESA_GLX_FX=fullscreen");
+ #else
+ setenv("MESA_GLX_FX", "fullscreen", 1);
+ #endif
+ }
+ else if (strcmp(argv[i], "-no3dfx") == 0 || strcmp(argv[i], "-no3Dfx") == 0) {
+-#if !defined(__linux__)
++#if !defined(__linux__) && !defined(__NetBSD__)
+ putenv("MESA_GLX_FX=");
+ #else
+ unsetenv("MESA_GLX_FX");
diff --git a/games/bzflag/patches/patch-am b/games/bzflag/patches/patch-am
new file mode 100644
index 00000000000..d1269803a41
--- /dev/null
+++ b/games/bzflag/patches/patch-am
@@ -0,0 +1,25 @@
+$NetBSD: patch-am,v 1.1.1.1 2002/09/24 12:49:13 blymn Exp $
+
+--- src/platform/Make-netbsd.orig Sun Sep 22 22:29:15 2002
++++ src/platform/Make-netbsd
+@@ -0,0 +1,20 @@
++# bzflag
++# Copyright (c) 1993 - 2002 Tim Riker
++#
++# This package is free software; you can redistribute it and/or
++# modify it under the terms of the license found in the file
++# named LICENSE that should have accompanied this file.
++#
++# THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++
++PCXXFILES = \
++ NetBSDPlatformFactory.cxx \
++ XDisplay.cxx \
++ XVisual.cxx \
++ XWindow.cxx \
++ NetBSDDisplay.cxx \
++ NetBSDMedia.cxx \
++ usbjoy.cxx \
++ $(NULL)