[comp.sources.x] v12i009: acm - X aerial combat simulation, Part04/09

riley@mipsdal.mips.com (Riley Rainey) (03/02/91)

Submitted-by: riley@mipsdal.mips.com (Riley Rainey)
Posting-number: Volume 12, Issue 9
Archive-name: acm/part04

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 4 (of 9)."
# Contents:  acm/V/test/Makefile acm/V/test/animate.c
#   acm/fsim/doRadar.c acm/fsim/newPlane.c acm/fsim/rwy
# Wrapped by riley@mipsdal on Thu Feb 14 10:09:18 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'acm/V/test/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'acm/V/test/Makefile'\"
else
echo shar: Extracting \"'acm/V/test/Makefile'\" \(7148 characters\)
sed "s/^X//" >'acm/V/test/Makefile' <<'END_OF_FILE'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $
X
X###########################################################################
X# X Window System Makefile generated from template file Imake.tmpl
X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
X#
X# Do not change the body of the imake template file.  Server-specific
X# parameters may be set in the appropriate .macros file; site-specific
X# parameters (but shared by all servers) may be set in site.def.  If you
X# make any changes, you'll need to rebuild the makefiles using
X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
X# the top level directory.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X# WARNING:  Imake.tmpl not configured; guessing at definitions!!!
X# This might mean that BOOTSTRAPCFLAGS wasn't set when building imake.
X
X###########################################################################
X# platform-specific configuration parameters - edit Guess.macros to change
X
X# platform:  $XConsortium: Guess.macros,v 1.30 88/10/23 11:00:33 jim Exp $
X
X               AR = ar clq
X  BOOTSTRAPCFLAGS =
X               CC = cc
X         COMPRESS = compress
X              CPP = /lib/cpp
X          INSTALL = install
X               LD = ld
X             LINT = lint
X      LINTLIBFLAG = -C
X         LINTOPTS = -axz
X               LN = ln -s
X               MV = mv
X           RANLIB = ranlib
X  RANLIBINSTFLAGS =
X               RM = rm -f
X  STD_CPP_DEFINES =			 */
X      STD_DEFINES =
XSYSLAST_LIBRARIES =
X             TAGS = ctags
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
X
X###########################################################################
X# definitions common to all Makefiles - do not edit
X
X          SHELL = 	/bin/sh
X
X        DESTDIR =
X      USRLIBDIR = $(DESTDIR)/usr/lib
X         BINDIR = $(DESTDIR)/usr/bin/X11
X         INCDIR = $(DESTDIR)/usr/include/X11
X         ADMDIR = $(DESTDIR)/usr/adm
X         LIBDIR = $(USRLIBDIR)/X11
X     LINTLIBDIR = $(USRLIBDIR)/lint
X        FONTDIR = $(LIBDIR)/fonts
X       XINITDIR = $(LIBDIR)/xinit
X         XDMDIR = $(LIBDIR)/xdm
X         UWMDIR = $(LIBDIR)/uwm
X         AWMDIR = $(LIBDIR)/awm
X         TWMDIR = $(LIBDIR)/twm
X        MANPATH = $(DESTDIR)/usr/man
X  MANSOURCEPATH = $(MANPATH)/man
X         MANDIR = $(MANSOURCEPATH)n
X      LIBMANDIR = $(MANSOURCEPATH)3
X    XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X   INSTBINFLAGS = -m 0755
X   INSTUIDFLAGS = -m 4755
X   INSTLIBFLAGS = -m 0664
X   INSTINCFLAGS = -m 0444
X   INSTMANFLAGS = -m 0444
X   INSTAPPFLAGS = -m 0444
X  INSTKMEMFLAGS = -m 4755
X        FCFLAGS = -t
X    CDEBUGFLAGS = -O
X
X        PATHSEP = /
X         DEPEND = $(DEPENDSRC)/makedepend
X          IMAKE = $(IMAKESRC)/imake
X            RGB = $(RGBSRC)/rgb
X             FC = $(BDFTOSNFSRC)/bdftosnf
X      MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir
X      MKDIRHIER = $(SCRIPTSSRC)/mkdirhier.sh
X
X         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
X      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
X        LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
X            TOP = /people/riley/R3
X      CLIENTSRC = $(TOP)/clients
X        DEMOSRC = $(TOP)/demos
X         LIBSRC = $(TOP)/lib
X        FONTSRC = $(TOP)/fonts
X     INCLUDESRC = $(TOP)/X11
X      SERVERSRC = $(TOP)/server
X        UTILSRC = $(TOP)/util
X     SCRIPTSSRC = $(UTILSRC)/scripts
X     EXAMPLESRC = $(TOP)/examples
X     CONTRIBSRC = $(TOP)/contrib
X         DOCSRC = $(TOP)/doc
X         RGBSRC = $(TOP)/rgb
X      DEPENDSRC = $(UTILSRC)/makedepend
X       IMAKESRC = $(UTILSRC)/imake
X       IRULESRC = $(UTILSRC)/imake.includes
X        XLIBSRC = $(LIBSRC)/X
X         XMUSRC = $(LIBSRC)/Xmu
X     TOOLKITSRC = $(LIBSRC)/Xt
X     AWIDGETSRC = $(LIBSRC)/Xaw
X     OLDXLIBSRC = $(LIBSRC)/oldX
X    BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X   MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X   EXTENSIONSRC = $(TOP)/extensions
X   EXTENSIONLIB = $(EXTENSIONSRC)/lib/libXext.a
X           XLIB = $(XLIBSRC)/libX11.a
X         XMULIB = $(XMUSRC)/libXmu.a
X        OLDXLIB = $(OLDXLIBSRC)/liboldX.a
X       XTOOLLIB = $(TOOLKITSRC)/libXt.a
X         XAWLIB = $(AWIDGETSRC)/libXaw.a
X       LINTXLIB = $(XLIBSRC)/llib-lX11.ln
X        LINTXMU = $(XMUSRC)/llib-lXmu.ln
X      LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln
X        LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln
X       INCLUDES = -I$(TOP)
X      MACROFILE = Guess.macros
X   ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
X			$(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
X  IMAKE_DEFINES =
X      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
X			-s Makefile $(IMAKE_DEFINES)
X         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
X			.emacs_* tags TAGS make.log MakeOut
X
X###########################################################################
X# rules:  $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
XCDEBUGFLAGS = -systype bsd43 -O
X
XSRCS=			animate.c app.c
XOBJS=			animate.o app.o
XSYS_LIBRARIES=		-L../lib -lV -lm -lX11
X
X        PROGRAM = animate
X
Xall:: animate
X
Xanimate: $(OBJS) $(LOCAL_LIBRARIES)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS) $(SYSLAST_LIBRARIES)
X
Xrelink::
X	$(RM) $(PROGRAM)
X	$(MAKE) $(MFLAGS) $(PROGRAM)
X
Xinstall:: animate
X	$(INSTALL) -c $(INSTALLFLAGS) animate $(BINDIR)
X
Xinstall.man:: animate.man
X	$(INSTALL) -c $(INSTMANFLAGS) animate.man $(MANDIR)/animate.n
X
Xdepend:: $(DEPEND)
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
X
X$(DEPEND):
X	@echo "making $@"; \
X	cd $(DEPENDSRC); $(MAKE)
X
Xclean::
X	$(RM) $(PROGRAM)
X
X###########################################################################
X# Imake.tmpl common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile:: $(IMAKE)
X
XMakefile:: Imakefile \
X	$(IRULESRC)/Imake.tmpl \
X	$(IRULESRC)/Imake.rules \
X	$(IRULESRC)/site.def \
X	$(IRULESRC)/$(MACROFILE)
X	-@if [ -f Makefile ]; then \
X		echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X		$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP)
X
X$(IMAKE):
X	@echo "making $@"; \
X	cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X	@echo "install done"
X
Xinstall.man::
X	@echo "install.man done"
X
XMakefiles::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_FILE
if test 7148 -ne `wc -c <'acm/V/test/Makefile'`; then
    echo shar: \"'acm/V/test/Makefile'\" unpacked with wrong size!
fi
# end of 'acm/V/test/Makefile'
fi
if test -f 'acm/V/test/animate.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'acm/V/test/animate.c'\"
else
echo shar: Extracting \"'acm/V/test/animate.c'\" \(7198 characters\)
sed "s/^X//" >'acm/V/test/animate.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X
Xstatic char *id = "V library animation test -- Riley Rainey";
X
X#define STRING	"Double Buffered Animation"
X#define BORDER	1
X#define FONT	"fixed"
X#define	ARG_FONT		"font"
X#define	ARG_BORDER_COLOR	"borderColor"
X#define	ARG_BACKGROUND		"background"
X#define ARG_BORDER		"borderWidth"
X#define	ARG_GEOMETRY		"geometry"
X#define DEFAULT_BACKGROUND	"#29350B"
X#define DEFAULT_BORDER		"black"
X
X#define SW_BORDER	1
X#define SW_BG		3
X#define SW_GEOM		4
X
Xstruct {
X	char	*sw;
X	int	value;
X	}	switches[] = {
X	"-bw", SW_BORDER,
X	"-bg", SW_BG,
X	"-geometry", SW_GEOM,
X	NULL, 0}, *swp;
X
Xchar *background = NULL, *filename;
Xint  borderWidth = 1;
Xint  mono;
X
X
X/*
X * This structure forms the WM_HINTS property of the window,
X * letting the window manager know how to handle this window.
X * See Section 9.1 of the Xlib manual.
X */
XXWMHints	xwmh = {
X    (InputHint|StateHint),	/* flags */
X    False,			/* input */
X    NormalState,		/* initial_state */
X    0,				/* icon pixmap */
X    0,				/* icon window */
X    0, 0,			/* icon location */
X    0,				/* icon mask */
X    0,				/* Window group */
X};
X
XDisplay		*dpy;		/* X server connection */
XWindow		win;		/* Window ID */
XGC		gc;		/* GC to draw with */
XXGCValues	gcv;
XXSizeHints	xsh;		/* Size hints for window manager */
XColormap	cmap;
X
Xstatic unsigned long	planemask [6];	/* plane masks from XAllocColorCells */
Xstatic unsigned long   pixels [16];	/* pixel values from XAllocColorCells */
XGC		curGC;
X
Xmain(argc,argv)
X    int argc;
X    char **argv;
X{
X    char       *fontName;	/* Name of font for string */
X    XFontStruct *fontstruct;	/* Font descriptor */
X    unsigned long ftw, fth, pad;/* Font size parameters */
X    unsigned long bg, bd;	/* Pixel values */
X    unsigned long bw;		/* Border width */
X    char       *tempstr;	/* Temporary string */
X    XColor      color;		/* Temporary color */
X    char       *geomSpec = NULL;/* Window geometry string */
X    XSetWindowAttributes xswa;	/* Temporary Set Window Attribute struct */
X    char	**c;
X
X/*
X *  Parse command line
X */
X
X    for (c= &argv[1]; *c != (char *) NULL; ++c)
X	if (**c == '-') {
X	    for (swp= &switches[0]; swp->value != 0; ++swp)
X		if (strcmp (swp->sw, *c) == 0) {
X			switch (swp->value) {
X			case SW_GEOM: 
X				geomSpec = *(++c);
X				break;
X			case SW_BG:
X				background = *(++c);
X				break;
X			case SW_BORDER:
X				borderWidth = atoi (*(++c));
X				break;
X			}
X		        break;
X		}
X	    if (swp->value == 0) {
X		fprintf (stderr, "%s: invalid switch %s", argv[0], *c);
X		exit (1);
X	    }
X	}
X	else
X	    filename = *c;
X
X    /*
X     * Open the display using the $DISPLAY environment variable to locate
X     * the X server.  See Section 2.1.
X     */
X    if ((dpy = XOpenDisplay(NULL)) == NULL) {
X	fprintf(stderr, "%s: can't open %s\n", argv[0], XDisplayName(NULL));
X	exit(1);
X    }
X
X    mono = (DisplayPlanes(dpy, 0) < 2) ? 1 : 0;
X
X    /*
X     * Load the font to use.  See Sections 10.2 & 6.5.1
X     */
X    if ((fontName = XGetDefault(dpy, argv[0], ARG_FONT)) == NULL) {
X	fontName = FONT;
X    }
X    if ((fontstruct = XLoadQueryFont(dpy, fontName)) == NULL) {
X	fprintf(stderr, "%s: display %s doesn't know font %s\n",
X		argv[0], DisplayString(dpy), fontName);
X	exit(1);
X    }
X    fth = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent;
X    ftw = fontstruct->max_bounds.width;
X
X    /*
X     * Select colors for the border,  the window background,  and the
X     * foreground.  We use the default colormap to allocate the colors in.
X     * See Sections 2.2.1, 5.1.2, & 10.4.
X     */
X
X    cmap = DefaultColormap(dpy, DefaultScreen(dpy));
X
X    if ((tempstr = XGetDefault(dpy, argv[0], ARG_BORDER_COLOR)) == NULL)
X	tempstr = DEFAULT_BORDER;
X    if (XParseColor(dpy, cmap, tempstr, &color) == 0) {
X	fprintf (stderr, "Can't get border color %s\n", tempstr);
X	exit (1);
X    }
X	bd = color.pixel;
X
X/*
X *  Allocate Color Planes and one extra cell for the border color.
X */
X
X    if (mono == 0)
X    if (XAllocColorCells (dpy, cmap, False, planemask, 0, pixels, 1) == 0) {
X	fprintf (stderr, "Cannot allocate color cells\n");
X	exit (1);
X    }
X    bg = WhitePixel (dpy, 0);
X
X/*
X *  Store border color
X */
X
X    if (mono)
X	bd = BlackPixel (dpy, 0);
X    else {
X    	bd = color.pixel = pixels [0];
X    	XStoreColor (dpy, cmap, &color);
X    }
X
X/*
X *  Background Color (pixels [0] defines this).
X */
X
X    if (background == NULL)
X	background = XGetDefault (dpy, argv[0], ARG_BACKGROUND);
X    if (background == NULL)
X	background = DEFAULT_BACKGROUND;
X
X    /*
X     * Set the border width of the window,  and the gap between the text
X     * and the edge of the window, "pad".
X     */
X    pad = BORDER;
X    if ((tempstr = XGetDefault(dpy, argv[0], ARG_BORDER)) == NULL)
X	bw = 1;
X    else
X	bw = atoi(tempstr);
X
X    /*
X     * Deal with providing the window with an initial position & size.
X     * Fill out the XSizeHints struct to inform the window manager. See
X     * Sections 9.1.6 & 10.3.
X     */
X    if (geomSpec == NULL)
X        geomSpec = XGetDefault(dpy, argv[0], ARG_GEOMETRY);
X
X    if (geomSpec == NULL) {
X	/*
X	 * The defaults database doesn't contain a specification of the
X	 * initial size & position - fit the window to the text and locate
X	 * it in the center of the screen.
X	 */
X	xsh.flags = (PPosition | PSize);
X	xsh.height = 800;
X	xsh.width = 1000;
X	xsh.x = (DisplayWidth(dpy, DefaultScreen(dpy)) - xsh.width) / 2;
X	xsh.y = (DisplayHeight(dpy, DefaultScreen(dpy)) - xsh.height) / 2;
X    }
X    else {
X	int         bitmask;
X
X	bzero(&xsh, sizeof(xsh));
X	bitmask = XGeometry(dpy, DefaultScreen(dpy), geomSpec, geomSpec,
X			    bw, ftw, fth, pad, pad, &(xsh.x), &(xsh.y),
X			    &(xsh.width), &(xsh.height));
X	if (bitmask & (XValue | YValue)) {
X	    xsh.flags |= USPosition;
X	}
X	if (bitmask & (WidthValue | HeightValue)) {
X	    xsh.flags |= USSize;
X	}
X    }
X
X    /*
X     * Create the Window with the information in the XSizeHints, the
X     * border width,  and the border & background pixels. See Section 3.3.
X     */
X    win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
X			      xsh.x, xsh.y, xsh.width, xsh.height,
X			      bw, bd, bg);
X
X    /*
X     * Set the standard properties for the window managers. See Section
X     * 9.1.
X     */
X    XSetStandardProperties(dpy, win, STRING, STRING, None, argv, argc, &xsh);
X    XSetWMHints(dpy, win, &xwmh);
X
X    /*
X     * Ensure that the window's colormap field points to the default
X     * colormap,  so that the window manager knows the correct colormap to
X     * use for the window.  See Section 3.2.9. Also,  set the window's Bit
X     * Gravity to reduce Expose events.
X     */
X    xswa.colormap = DefaultColormap(dpy, DefaultScreen(dpy));
X    xswa.bit_gravity = NorthWestGravity;
X    XChangeWindowAttributes(dpy, win, (CWColormap | CWBitGravity), &xswa);
X
X    /*
X     * Create the GC for drawing the picture.
X     */
X    gcv.font = fontstruct->fid;
X    curGC = XCreateGC(dpy, win, GCFont, &gcv);
X
X    /*
X     * Specify the event types we're interested in - only Exposures.  See
X     * Sections 8.5 & 8.4.5.1
X     */
X    XSelectInput(dpy, win, ExposureMask);
X
X    /*
X     * Map the window to make it visible.  See Section 3.5.
X     */
X    XMapWindow(dpy, win);
X
X    app(background);
X
X    exit(1);
X}
X
END_OF_FILE
if test 7198 -ne `wc -c <'acm/V/test/animate.c'`; then
    echo shar: \"'acm/V/test/animate.c'\" unpacked with wrong size!
fi
# end of 'acm/V/test/animate.c'
fi
if test -f 'acm/fsim/doRadar.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'acm/fsim/doRadar.c'\"
else
echo shar: Extracting \"'acm/fsim/doRadar.c'\" \(9804 characters\)
sed "s/^X//" >'acm/fsim/doRadar.c' <<'END_OF_FILE'
X/*
X *	xflight : an aerial combat simulator for X
X *
X *	Written by Riley Rainey,  riley@mips.com
X *
X *	Permission to use, copy, modify and distribute (without charge) this
X *	software, documentation, images, etc. is granted, provided that this 
X *	comment and the author's name is retained.
X *
X */
X 
X#include "pm.h"
X#include <stdio.h>
X#include <math.h>
X
X#define scanSlope 	2.1445
X
Xvoid plotPrimaryTarget(), plotNormalTarget();
X
Xstatic char *thirty = "30";
X
X/*
X *  We'll build an array that contains the amount of radar radiation that each
X *  craft can "see" coming from another player.  This is used to build each players
X *  radar threat display.
X *
X *  rval[i][j] will represent the amount of radar energy that player j sees coming from
X *  player i.
X *
X *  For neatness, the rval array has been moved to the ptbl vector.
X */
X
Xchar *ItoA (n, s)
Xint	n;
Xchar	*s; {
X
X	if (abs(n) > 999) {
X		sprintf (s, "%d,%3.3d", n/1000, abs(n) % 1000);
X	}
X	else 
X		sprintf (s, "%d", n);
X
X	return s;
X}
X
Xint doRadar (c, u)
Xcraft *c;
Xviewer *u; {
X
X	register craft *p;
X	register int	i, t, x, y;
X	register int	xc, yc;
X	register double	xs, ys;
X	char		*buf;
X
X	t = c->curRadarTarget = getRadarTarget (c, 0);
X	xc = (u->radarWidth + 1) / 2;
X	yc = (u->radarHeight + 1) / 2;
X
X/*
X *  Set drawing colors and font
X */
X
X	XSetForeground (u->dpy, u->gc, u->v->flags & VPMono ?
X			BlackPixel(u->v->dpy, u->v->screen) :
X			u->v->pixel[blackPixel]);
X	XFillRectangle (u->dpy, u->rwin, u->gc, 0, 0,
X		 u->radarWidth, u->radarHeight);
X	XSetForeground (u->dpy, u->gc, u->v->flags & VPMono ?
X			WhitePixel(u->v->dpy, u->v->screen) :
X			u->v->pixel[whitePixel]);
X	XSetFont (u->dpy, u->gc, u->rfont->fid);
X
X/*
X *  Draw reference "thing"
X */
X
X	XDrawLine (u->dpy, u->rwin, u->gc, xc, yc, xc - 5, yc + 5);
X	XDrawLine (u->dpy, u->rwin, u->gc, xc - 10, yc, xc - 5, yc + 5);
X	XDrawLine (u->dpy, u->rwin, u->gc, xc - 10, yc, xc - 18, yc);
X	XDrawLine (u->dpy, u->rwin, u->gc, xc, yc, xc + 5, yc + 5);
X	XDrawLine (u->dpy, u->rwin, u->gc, xc + 10, yc, xc + 5, yc + 5);
X	XDrawLine (u->dpy, u->rwin, u->gc, xc + 10, yc, xc + 18, yc);
X	XDrawLine (u->dpy, u->rwin, u->gc, 0, 0, u->radarWidth-1, 0);
X	XDrawLine (u->dpy, u->rwin, u->gc, u->radarWidth-1, 0,
X		u->radarWidth-1, u->radarHeight-1);
X	XDrawLine (u->dpy, u->rwin, u->gc, 0, u->radarHeight-1,
X		u->radarWidth-1, u->radarHeight-1);
X	XDrawLine (u->dpy, u->rwin, u->gc, 0, u->radarHeight, 0, 0);
X
X/*
X *  Radar dead?
X */
X
X	if (isFunctioning (c, SYS_RADAR) == 0)
X		return 0;
X
X/*
X *  Radar off?
X */
X
X	if (c->radarMode <= RM_STANDBY) {
X		if (c->radarMode == RM_OFF)
X			buf = "RADAR OFF";
X		else
X			buf = "RADAR STBY";
X		c->curRadarTarget = -1;
X		XDrawString (u->dpy, u->rwin, u->gc, u->rftw * 4,
X			u->fth * 2, buf, strlen(buf));
X		return 0;
X	}
X
X/*
X *  Plot reference lines
X */
X
X	i = (u->radarWidth + 3) / 4;
X	y = u->rfth + 3;
X	XDrawLine (u->dpy, u->rwin, u->gc, xc, y, xc, y+4);
X	y = u->radarHeight - 5 - u->rfth;
X	XDrawLine (u->dpy, u->rwin, u->gc, xc, y, xc, y+4);
X
X	x = xc - i;
X	y = u->rfth + 6;
X	XDrawLine (u->dpy, u->rwin, u->gc, x, y, x, y+4);
X	y = u->radarHeight - 6 - u->rfth;
X	XDrawLine (u->dpy, u->rwin, u->gc, x, y, x, y+4);
X	XDrawString (u->dpy, u->rwin, u->gc, x-u->rftw, y+2+u->rfth,
X		thirty, 2);
X
X	x = xc + i;
X	y = u->rfth + 6;
X	XDrawLine (u->dpy, u->rwin, u->gc, x, y, x, y+4);
X	y = u->radarHeight - 6 - u->rfth;
X	XDrawLine (u->dpy, u->rwin, u->gc, x, y, x, y+4);
X	XDrawString (u->dpy, u->rwin, u->gc, x-u->rftw, y+2+u->rfth,
X		thirty, 2);
X
X	i = (u->radarHeight + 3) / 4;
X	x = 2;
X	XDrawLine (u->dpy, u->rwin, u->gc, x, yc, x+4, yc);
X	x = u->radarWidth - 6;
X	XDrawLine (u->dpy, u->rwin, u->gc, x, yc, x+4, yc);
X
X	x = 5 + 2 * u->rftw;
X	y = yc - i;
X	XDrawLine (u->dpy, u->rwin, u->gc, x, y, x+4, y);
X	x = 3;
X	XDrawString (u->dpy, u->rwin, u->gc, x, y+u->rfth/3,
X		thirty, 2);
X	x = u->radarWidth - 6;
X	XDrawLine (u->dpy, u->rwin, u->gc, x, y, x+4, y);
X
X	x = 5 + 2 * u->rftw;
X	y = yc + i;
X	XDrawLine (u->dpy, u->rwin, u->gc, x, y, x+4, y);
X	x = 3;
X	XDrawString (u->dpy, u->rwin, u->gc, x, y+u->rfth/3,
X		thirty, 2);
X	x = u->radarWidth - 6;
X	XDrawLine (u->dpy, u->rwin, u->gc, x, y, x+4, y);
X	
X/*
X *  Now plot all targets visible to the radar system.
X */
X
X	for ((i=0, p=ptbl); i<MAXPLAYERS; (++i, ++p)) {
X		if (c->relValid[i] > 0 && c->relPos[i].x >= 0.0) {
X
X			xs = c->relPos[i].y / c->relPos[i].x / scanSlope;
X			ys = c->relPos[i].z / c->relPos[i].x / scanSlope;
X			if (fabs(xs) <= 1.0 && fabs(ys) <= 1.0) {
X				x = xs * (double) xc + xc;
X				y = ys * (double) yc + yc;
X				if (t == i)
X					plotPrimaryTarget (c, u, i, x, y);
X				else
X					plotNormalTarget (u, x, y);
X			}
X		}
X	}
X	return 0;
X}
X
Xint isRadarVisible (c, i)
Xcraft *c;
Xint	i; {
X
X	register double d, xs, ys;
X	VPoint	r1;
X
X	if (ptbl[i].type == CT_FREE || i == c->index)
X		return 0;
X
X/*
X *  Is the set on ?
X */
X
X	if (c->radarMode <= RM_STANDBY ||
X		isFunctioning (c, SYS_RADAR) == 0) {
X		ptbl[i].rval[c->index] = 0.0;
X		return 0;
X	}
X
X/*
X *  Calculate the coordinates of the target relative to the craft's frame.
X */
X
X	r1.x = ptbl[i].Sg.x - c->Sg.x;
X	r1.y = ptbl[i].Sg.y - c->Sg.y;
X	r1.z = ptbl[i].Sg.z - c->Sg.z;
X	VTransform (&r1, &(c->Itrihedral), &(c->relPos[i]));
X
X	ptbl[i].rval[c->index] = 0.0;
X
X	if (c->relPos[i].x <= 0.0)
X		return 0;
X
X	d = c->relPos[i].x * scanSlope;
X	xs = c->relPos[i].y / d;
X	ys = c->relPos[i].z / d;
X
X/*
X *  if the absolute values of xs and ys are both less than 1.0, then
X *  we are painting this target with radar energy.  Estimate the value of
X *  the energy that the target sees.
X */
X
X	if ((fabs(xs) <= 1.0) && (fabs(ys) <= 1.0)) {
X		d = mag(c->relPos[i]);
X		ptbl[i].rval[c->index] = c->cinfo->radarOutput / (d * d);
X		if (d >= c->cinfo->radarDRange)
X			return 0;
X		else if (d >= c->cinfo->radarTRange)
X			return 1;
X		else
X			return 2;
X	}
X	else
X		return 0;
X
X}
X
Xint getRadarTarget (c, new)
Xcraft 	*c;
Xint	new; {
X
X	register int	i, minID;
X	register double minD, d;
X
X	for (i=0; i<MAXPLAYERS; ++i)
X		c->relValid[i] = isRadarVisible(c, i);
X
X	if (new == 0) {
X		i = c->curRadarTarget;
X		if (i != -1 && c->relValid[i] != 0)
X			return i;
X	}
X
X	minD = 1000.0 * NM;
X	minID = -1;
X	for (i=0; i<MAXPLAYERS; ++i) {
X		if (c->relValid[i] == 2) {
X			if (new == 1 && i == c->curRadarTarget)
X				continue;
X			d = mag (c->relPos[i]);
X			if (d < minD) {
X				minD = d;
X				minID = i;
X			}
X		}
X	}
X
X	return minID;
X}
X
Xvoid doDroneRadar (c)
Xcraft *c; {
X
X	register int i;
X
X	for (i=0; i<MAXPLAYERS; ++i)
X		(void) isRadarVisible(c, i);
X}
X
Xvoid plotNormalTarget (u, x, y)
Xviewer *u;
Xint	x, y; {
X
X	XDrawLine (u->dpy, u->rwin, u->gc, x-2, y-2, x-2, y+2);
X	XDrawLine (u->dpy, u->rwin, u->gc, x-2, y+2, x+2, y+2);
X	XDrawLine (u->dpy, u->rwin, u->gc, x+2, y+2, x+2, y-2);
X	XDrawLine (u->dpy, u->rwin, u->gc, x+2, y-2, x-2, y-2);
X}
X
Xextern double heading();
X
Xvoid plotPrimaryTarget (c, u, i, x, y)
Xcraft  *c;
Xviewer *u;
Xint	i;
Xint	x, y; {
X
X	int	xp, yp;
X	char	s[16];
X	VPoint	rel, deltaV;
X	double	d, cl;
X
X	xp = 150 * u->radarWidth / RADAR_WINDOW_WIDTH;
X	yp = 150 * u->radarHeight / RADAR_WINDOW_HEIGHT;
X
X	XFillRectangle (u->dpy, u->rwin, u->gc, x-3, y-3, 7, 7);
X
X/*
X *  Heading of target
X */
X
X	sprintf (s, "  %3.3d \007", (int) (RADtoDEG(ptbl[i].curHeading)));
X	XDrawString (u->dpy, u->rwin, u->gc, xp, yp, s, strlen(s));
X
X/*
X *  Relative heading to target.
X */
X
X	rel.x = ptbl[i].Sg.x - c->Sg.x;
X	rel.y = ptbl[i].Sg.y - c->Sg.y;
X	rel.z = ptbl[i].Sg.z - c->Sg.z;
X	sprintf (s, "  %3.3d R", (int) RADtoDEG(heading(&rel)));
X	XDrawString (u->dpy, u->rwin, u->gc, xp, yp+u->rfth, s, strlen(s));
X
X/*
X *  Closure rate
X */
X
X	deltaV.x = ptbl[i].Cg.x - c->Cg.x;
X	deltaV.y = ptbl[i].Cg.y - c->Cg.y;
X	deltaV.z = ptbl[i].Cg.z - c->Cg.z;
X	d = mag (rel);
X	cl = - (deltaV.x * rel.x + deltaV.y * rel.y + deltaV.z + rel.z) /
X		d / NM * 3600.0;
X	c->targetDistance = d;
X	c->targetClosure = cl;
X	sprintf (s, "%5d C", (int)cl);
X	XDrawString (u->dpy, u->rwin, u->gc, xp, yp+2*u->rfth, s, strlen(s));
X
X/*
X *  Range to target
X */
X
X	xp = 40 * u->radarWidth / RADAR_WINDOW_WIDTH;
X	yp = u->rfth + 4;	
X	sprintf (s, "%d", (int) (d / NM));
X	XDrawString (u->dpy, u->rwin, u->gc, xp, yp, s, strlen(s));
X
X/*
X *  Altitude of target
X */
X
X	xp = 150 * u->radarWidth / RADAR_WINDOW_WIDTH;
X	yp = u->rfth + 4;	
X	sprintf (s, "%d", (int) (- ptbl[i].Sg.z / 1000.0));
X	XDrawString (u->dpy, u->rwin, u->gc, xp, yp, s, strlen(s));
X}
X
X/*
X *  doTEWS :  update the threat display for player i.
X */
X
Xvoid doTEWS (c, u)
Xcraft	*c;
Xviewer	*u; {
X
X	register int	i, x, y;
X	VPoint	rel, tmp;
X	double	m, unit;
X
X	XSetForeground (u->dpy, u->gc, u->v->flags & VPMono ?
X			BlackPixel(u->v->dpy, u->v->screen) :
X			u->v->pixel[blackPixel]);
X	XFillRectangle (u->dpy, u->win, u->gc, u->TEWSx-u->TEWSSize/2,
X		u->TEWSy-u->TEWSSize/2, u->TEWSSize, u->TEWSSize);
X	XSetForeground (u->dpy, u->gc, u->v->flags & VPMono ?
X			WhitePixel(u->v->dpy, u->v->screen) :
X			u->v->pixel[whitePixel]);
X
X	XDrawArc(u->dpy, u->win, u->gc, u->TEWSx-u->TEWSSize/2,
X		u->TEWSy-u->TEWSSize/2, u->TEWSSize, u->TEWSSize,
X		0, 360*64);
X
X	for (i=0; i<MAXPLAYERS; ++i) {
X
X		if (c->index == i)
X			continue;
X
X		if (c->rval[i] > c->cinfo->TEWSThreshold) {
X			tmp.x = ptbl[i].Sg.x - c->Sg.x;
X			tmp.y = ptbl[i].Sg.y - c->Sg.y;
X			tmp.z = ptbl[i].Sg.z - c->Sg.z;
X			VTransform (&tmp, &(c->Itrihedral), &(rel));
X			m = mag(rel);
X			rel.x /= m;
X			rel.y /= m;
X			rel.z /= m;
X			unit = sqrt (rel.x * rel.x + rel.y * rel.y);
X			if (unit == 0.0) {
X				rel.x = 1.0;
X				rel.y = 0.0;
X			}
X			x = u->TEWSx + (int) (rel.y * u->TEWSSize * 0.4 / unit);
X			y = u->TEWSy - (int) (rel.x * u->TEWSSize * 0.4 / unit);
X			if (c->team == ptbl[i].team) {
X				XDrawLine (u->dpy, u->win, u->gc, x-2, y-2, x-2, y+2);
X				XDrawLine (u->dpy, u->win, u->gc, x-2, y+2, x+2, y+2);
X				XDrawLine (u->dpy, u->win, u->gc, x+2, y+2, x+2, y-2);
X				XDrawLine (u->dpy, u->win, u->gc, x+2, y-2, x-2, y-2);
X			}
X			else
X				XFillRectangle (u->dpy, u->win, u->gc, x-3, y-3, 7, 7);
X		}
X	}
X}
END_OF_FILE
if test 9804 -ne `wc -c <'acm/fsim/doRadar.c'`; then
    echo shar: \"'acm/fsim/doRadar.c'\" unpacked with wrong size!
fi
# end of 'acm/fsim/doRadar.c'
fi
if test -f 'acm/fsim/newPlane.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'acm/fsim/newPlane.c'\"
else
echo shar: Extracting \"'acm/fsim/newPlane.c'\" \(9352 characters\)
sed "s/^X//" >'acm/fsim/newPlane.c' <<'END_OF_FILE'
X/*
X *	xflight : an aerial combat simulator for X
X *
X *	Written by Riley Rainey,  riley@mips.com
X *
X *	Permission to use, copy, modify and distribute (without charge) this
X *	software, documentation, images, etc. is granted, provided that this 
X *	comment and the author's name is retained.
X *
X */
X 
X#include "pm.h"
X#include <stdio.h>
X#include <string.h>
X
Xstatic craftType ctype[MAXCRAFTTYPES];
X
Xextern FILE * acm_fopen ();
X
XcraftType *lookupCraft (name)
Xchar * name; 
X{
X	int	i;
X
X	for (i=0; i<MAXCRAFTTYPES; ++i)
X	    if (ctype[i].name != (char *) NULL)
X		if (strcmp(name, ctype[i].name) == 0)
X			return &ctype[i];
X
X	return (craftType *) NULL;
X}
X
XcraftType *newCraft () {
X
X	int	i;
X	
X	for (i=0; i<MAXCRAFTTYPES; ++i)
X		if (ctype[i].name == (char *) NULL) {
X			ctype[i].name = "*allocated*";
X			return &ctype[i];
X		}
X
X	return (craftType *) NULL;
X}
X
Xstatic struct {
X	double mach;
X	double Cdi;
X	} *p, cdTable[] = {
X		{ 0.0, 0.02 },
X		{ 0.2, 0.02 },
X		{ 0.95, 0.015},
X		{ 1.05, 0.045},
X		{ 2.0,  0.03 },
X		{ 10.0, 0.03 }
X	};
X
Xstatic double CDi (c)
Xcraft *c; {
X
X	register double	b, deltaMach;
X
X	for (p=cdTable; c->mach>(p+1)->mach; ++p) ;
X	deltaMach = (p+1)->mach - p->mach;
X	b = ((p+1)->Cdi - p->Cdi) / deltaMach;
X	return p->Cdi + b * (c->mach - p->mach);
X}
X
Xvoid initf16 () {
X
X	FILE    	*f;
X	craftType	*c;
X
X	c = newCraft();
X	c->name = strdup("f-16c");
X	c->CLOrigin = 0.129871;
X
X	c->CLSlope = 4.0;
X
X	c->CLNegStall = DEGtoRAD (-17.0);
X	c->CLPosStall = DEGtoRAD (30.0);
X
X	c->aspectRatio = 3.0;
X
X	c->CDOrigin = 0.03642;
X	c->CDi = CDi;
X	c->CDFactor = -2.54200;
X	c->CDPhase = 0.0349066;
X
X	c->CDBOrigin = 1.0;
X	c->CDBFactor = -1.0;
X	c->CDBPhase = 0.0;
X
X	c->CLbeta = -0.2;
X
X	c->CMOrigin = 0.0;
X	c->CMFactor = -0.95;
X
X	c->CNOrigin = 0.0;
X	c->CNFactor = -7.50;	/* based on 60 ft^2 tail; CLa = 1.0; Ivx = 15 ft */
X
X	c->CYbeta = -1.5;
X
X	c->effElevator = 0.40;
X	c->effAileron = 0.20;
X	c->effRudder = 0.35;
X
X	c->maxFlap = DEGtoRAD (40.0);	/* 40 degree maximum flap setting */
X	c->cFlap = 0.64279;		/* yields Clift of 1.0 at max extension */
X	c->cFlapDrag = 0.0467;		/* yields 0.03 of extra drag at max ext */
X	c->flapRate = 0.1745;		/* about 4 seconds to fully extend flaps */
X
X	c->maxSpeedBrake = DEGtoRAD (80.0);
X	c->cSpeedBrake = 0.03;		/* drag coefficient added by speed brakes */
X	c->speedBrakeRate = DEGtoRAD (40.0); /* about 2.0 seconds to fully extend */
X	c->speedBrakeIncr = DEGtoRAD (80.0); /* one keystoke means full extension */
X
X	VIdentMatrix(&(c->I));
X
X	c->I.m[0][0] =  7240.7;
X	c->I.m[1][1] = 49785.9;
X	c->I.m[2][2] = 54389.5;
X
X	c->LDamp = 40000.0;
X	c->MDamp = -0.6;
X	c->NDamp = -0.6;
X
X	c->cmSlope = -2.00;
X	c->cmFactor = -1.30;
X	c->cnSlope = -1.30;
X	c->cnFactor = -1.00;
X	c->betaStall = DEGtoRAD (15.0);
X
X	c->wingS = 300.0;
X	c->emptyWeight = 14576.0;
X	c->maxFuel = 6972.0;
X
X/*
X * Engine data for F100-PW-100
X * source "Modern Combat Aircraft Design", Klaus Huenecke
X */
X
X	c->maxThrust = 14080.0;
X	c->maxABThrust = 23540.0;
X	c->spFuelConsump = 0.68;
X	c->spABFuelConsump = 2.55;
X
X	c->groundingPoint.x = 0.0;
X	c->groundingPoint.y = 0.0;
X	c->groundingPoint.z = 6.0;
X	c->viewPoint.x = 12.5;
X	c->viewPoint.y = 0.0;
X	c->viewPoint.z = -3.0;
X	c->crashC = 90.0;
X
X	c->sCount = 3;
X	c->wStation[0].x = 7.0;
X	c->wStation[0].y = -4.0;
X	c->wStation[0].z = 0.0;
X	c->wStation[1].x = 0.357;
X	c->wStation[1].y = 15.6;
X	c->wStation[1].z = 0.0;
X	c->wStation[2].x = 0.357;
X	c->wStation[2].y = -15.6;
X	c->wStation[2].z = 0.0;
X
X	c->muStatic = 0.08;
X	c->muKinetic = 0.05;
X	c->muBStatic = 0.7;
X	c->muBKinetic = 0.6;
X
X	c->maxNWDef = 1.27; /* 72.7 degrees */
X	c->NWIncr = 1.27 / 32.0;
X	c->maxNWS = 85.0 * 6076.0 / 3600.0;
X	c->gearD1 = 13.5;
X	c->gearD2 = -2.5;
X	f = acm_fopen ("f16", "r");
X	c->object = VReadObject(f);
X	fclose (f);
X
X	c->TEWSThreshold = 0.0;		/* zero, for now */
X	c->radarOutput = 15000.0;	/* estimated */
X	c->radarDRange = 80.0 * NM;
X	c->radarTRange = 60.0 * NM;
X
X	c->placeProc = NULL;
X
X	c->damageBits = SYS_NODAMAGE;
X	c->damageBits &= ~ SYS_ENGINE2;
X	c->structurePts = 15;
X
X}
X
Xvoid initmig23 () {
X
X	FILE    	*f;
X	craftType	*c;
X
X	c = newCraft();
X	c->name = strdup("mig-23");
X	c->CLOrigin = 0.129871;
X	c->CLSlope = 3.9;
X	c->CLNegStall = -17.0 * pi / 180.0;
X	c->CLPosStall =  26.0 * pi / 180.0;
X
X	c->aspectRatio = 2.27;
X
X	c->CDOrigin = 0.03642;
X	c->CDi = CDi;
X	c->CDFactor = -2.54200;
X	c->CDPhase = 0.0349066;
X
X	c->CDBOrigin = 1.0;
X	c->CDBFactor = -1.0;
X	c->CDBPhase = 0.0;
X
X	c->CLbeta = -0.2;
X
X	c->CMOrigin = 0.0;
X	c->CMFactor = -0.95;
X
X	c->CNOrigin = 0.0;
X	c->CNFactor = -0.90;
X
X	c->CYbeta = -1.3;
X
X	c->effElevator = 0.40;
X	c->effAileron = 0.20;
X	c->effRudder = 0.35;
X
X	c->maxFlap = 40.0 * pi / 180.0;	/* 40 degree maximum flap setting */
X	c->cFlap = 0.64279;		/* yields Clift of 1.0 at max extension */
X	c->flapRate = 0.1745;		/* about 4 seconds to fully extend flaps */
X
X	c->maxSpeedBrake = DEGtoRAD (80.0);
X	c->cSpeedBrake = 0.03;		/* drag coefficient added by speed brakes */
X	c->speedBrakeRate = DEGtoRAD (40.0); /* about 0.25 seconds to fully extend */
X	c->speedBrakeIncr = DEGtoRAD (80.0); /* one keystoke means full extension */
X
X	VIdentMatrix(&(c->I));
X	c->I.m[0][0] =  9000.0;
X	c->I.m[1][1] = 75000.0;
X	c->I.m[2][2] = 95000.0;
X
X	c->LDamp =  50000.0;
X	c->MDamp = -0.2;
X	c->NDamp = -0.4;
X
X	c->cmSlope = -1.80;
X	c->cmFactor = -1.30;
X	c->cnSlope = -1.30;
X	c->cnFactor = -1.00;
X	c->betaStall = DEGtoRAD (15.0);
X
X	c->wingS = 325.0;
X	c->emptyWeight = 25000.0;
X	c->maxFuel = 9914.0;
X/*
X * Engine data for Tumansky R-29B
X * source "Modern Fighter Combat"
X */
X
X	c->maxThrust = 17635.0;
X	c->maxABThrust = 25350.0;
X	c->spFuelConsump = 0.68;
X	c->spABFuelConsump = 2.55;
X
X	c->groundingPoint.x = 0.0;
X	c->groundingPoint.y = 0.0;
X	c->groundingPoint.z = 6.0;
X	c->viewPoint.x = 12.5;
X	c->viewPoint.y = 0.0;
X	c->viewPoint.z = -3.0;
X	c->crashC = 90.0;
X
X	c->sCount = 3;
X	c->wStation[0].x = 7.0;
X	c->wStation[0].y = -4.0;
X	c->wStation[0].z = 0.0;
X	c->wStation[1].x = 0.357;
X	c->wStation[1].y = 15.6;
X	c->wStation[1].z = 0.0;
X	c->wStation[2].x = 0.357;
X	c->wStation[2].y = -15.6;
X	c->wStation[2].z = 0.0;
X
X	c->muStatic = 0.08;
X	c->muKinetic = 0.05;
X	c->muBStatic = 0.7;
X	c->muBKinetic = 0.6;
X
X	c->maxNWDef = 1.27; /* 72.7 degrees */
X	c->NWIncr = 1.27 / 32.0;
X	c->maxNWS = 100.0 * 6076.0 / 3600.0;
X	c->gearD1 = 13.5;
X	c->gearD2 = -2.5;
X	f = acm_fopen ("mig23", "r");
X	c->object = VReadObject(f);
X	fclose (f);
X	
X	c->TEWSThreshold = 0.0;		/* zero, for now */
X	c->radarOutput = 15000.0;	/* estimated */
X	c->radarDRange = 80.0 * NM;
X	c->radarTRange = 30.0 * NM;
X
X	c->placeProc = NULL;
X
X	c->damageBits = SYS_NODAMAGE;
X	c->damageBits &= ~ SYS_ENGINE2;
X	c->structurePts = 19;
X
X}
X
Xextern void initPanel();
X
Xint newPlane(planeType)
Xchar *planeType; {
X
X	int     i, j;
X	craft	*c;
X
X	for (i=0; i<MAXPLAYERS; ++i) {
X		if (ptbl[i].type == CT_FREE) {
X
X			c = &ptbl[i];
X			c->type = CT_PLANE;
X			c->cinfo = lookupCraft (planeType);
X			c->fuel = c->cinfo->maxFuel;
X
X			c->Cg.x = 0.0;
X			c->Cg.y = 0.0;
X			c->Cg.z = 0.0;
X			c->Sg.x = 90.0;
X			c->Sg.y = 0.0;
X			c->Sg.z = - c->cinfo->groundingPoint.z;
X			c->prevSg = c->Sg;
X
X			c->p = c->q = c->r = 0.0;
X			c->Se = c->Sr = c->Sa = 0.0;
X
X			c->throttle = 8192;
X			c->curThrust = calcThrust (c);
X			c->curFlap = 0.0;
X			c->flapSetting = 0.0;
X			c->curSpeedBrake = 0.0;
X			c->speedBrakeSetting = 0.0;
X			c->curHeading = c->curPitch = c->curRoll = 0.0;
X			VIdentMatrix(&(c->trihedral));
X			c->Itrihedral = c->trihedral;
X			c->groundContact = 1;
X			c->curNWDef = 0.0;
X			c->flags = FL_NWS;
X			c->radarMode = RM_NORMAL;
X			c->curRadarTarget = -1;
X			c->viewDirection.x = 1.0;
X			c->viewDirection.y = 0.0;
X			c->viewDirection.z = 0.0;
X			c->viewUp.x = 0.0;
X			c->viewUp.y = 0.0;
X			c->viewUp.z = -1.0;
X			for (j=0; j<3; ++j) {
X				c->leftHUD[j] = Vmalloc (32);
X				c->rightHUD[j] = Vmalloc (32);
X			}
X
X			c->curWeapon = WEAPONTYPES - 1;
X			selectWeapon (c);
X
X/* a trick to select a valid weapon */
X
X/*
X * give the player 8 Sidewinders and a cannon.
X */
X
X			c->station[0].type = WK_M61A1;
X			c->station[0].info = 500;
X			c->station[0].info2 = 0;
X			c->station[0].info3 = 0;
X			c->station[1].type = WK_AIM9M;
X			c->station[2].type = WK_AIM9M;
X			c->station[3].type = WK_AIM9M;
X			c->station[4].type = WK_AIM9M;
X			c->station[5].type = WK_AIM9M;
X			c->station[6].type = WK_AIM9M;
X			c->station[7].type = WK_AIM9M;
X			c->station[8].type = WK_AIM9M;
X			initDamage (c);
X			initPanel (c);
X			break;			
X		}
X	}
X
X	if (i == MAXPLAYERS)
X		return -1;
X
X	return i;
X}
X
Xint newDrone(p)
Xcraft *p; {
X
X
X	int     i, j;
X	craft	*c;
X	VPoint	s;
X
X	for (i=0; i<MAXPLAYERS; ++i) {
X		if (ptbl[i].type == CT_FREE) {
X
X			c = &ptbl[i];
X			*c = *p;
X
X			c->index = i;
X			c->team = i;
X
X			c->vl = NULL;
X			c->type = CT_DRONE;
X			c->cinfo = lookupCraft ("f-16c");
X
X/*
X *  Position the drone 200 feet ahead of the player's craft.
X */
X
X			s.x = 5400.0;
X			s.y = 2030.0;
X			s.z = 0.0;
X			VTransform (&s, &(p->trihedral), &(c->Sg));
X			c->Sg.x += p->Sg.x;
X			c->Sg.y += p->Sg.y;
X			c->Sg.z += p->Sg.z;
X			c->prevSg = c->Sg;
X
X/*			c->p = c->q = c->r = 0.0;
X			c->Se = c->Sr = c->Sa = 0.0;
X
X			c->throttle = 8192;
X			c->curThrust = calcThrust (c);
X			c->curHeading = c->curPitch = c->curRoll = 0.0;
X			VIdentMatrix(&(c->trihedral));
X			c->Itrihedral = c->trihedral;
X*/
X			c->groundContact = 0;
X			c->curNWDef = 0.0;
X			c->flags = 0;
X			c->radarMode = RM_NORMAL;
X
X			for (j=0; j<3; ++j) 
X				c->leftHUD[j] = c->rightHUD[j] = NULL;
X
X			break;			
X		}
X	}
X
X	if (i == MAXPLAYERS)
X		return -1;
X
X	return i;
X}
END_OF_FILE
if test 9352 -ne `wc -c <'acm/fsim/newPlane.c'`; then
    echo shar: \"'acm/fsim/newPlane.c'\" unpacked with wrong size!
fi
# end of 'acm/fsim/newPlane.c'
fi
if test -f 'acm/fsim/rwy' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'acm/fsim/rwy'\"
else
echo shar: Extracting \"'acm/fsim/rwy'\" \(8674 characters\)
sed "s/^X//" >'acm/fsim/rwy' <<'END_OF_FILE'
X*runway-with-lines
X216 54
X1 0.000000 -75.000000 0.000000
X2 12000.000000 -75.000000 0.000000
X3 12000.000000 75.000000 0.000000
X4 0.000000 75.000000 0.000000
X5 0.000000 -75.000000 0.000000
X6 12000.000000 -75.000000 0.000000
X7 12000.000000 -72.000000 0.000000
X8 0.000000 -72.000000 0.000000
X9 0.000000 75.000000 0.000000
X10 12000.000000 75.000000 0.000000
X11 12000.000000 72.000000 0.000000
X12 0.000000 72.000000 0.000000
X13 1000.000000 -68.000000 0.000000
X14 1125.000000 -68.000000 0.000000
X15 1125.000000 -45.500000 0.000000
X16 1000.000000 -45.500000 0.000000
X17 1000.000000 68.000000 0.000000
X18 1125.000000 68.000000 0.000000
X19 1125.000000 45.500000 0.000000
X20 1000.000000 45.500000 0.000000
X21 11000.000000 -68.000000 0.000000
X22 10875.000000 -68.000000 0.000000
X23 10875.000000 -45.500000 0.000000
X24 11000.000000 -45.500000 0.000000
X25 11000.000000 68.000000 0.000000
X26 10875.000000 68.000000 0.000000
X27 10875.000000 45.500000 0.000000
X28 11000.000000 45.500000 0.000000
X29 4.000000 -68.000000 0.000000
X30 129.000000 -68.000000 0.000000
X31 129.000000 -56.444443 0.000000
X32 4.000000 -56.444443 0.000000
X33 4.000000 -52.444443 0.000000
X34 129.000000 -52.444443 0.000000
X35 129.000000 -40.888889 0.000000
X36 4.000000 -40.888889 0.000000
X37 4.000000 -36.888889 0.000000
X38 129.000000 -36.888889 0.000000
X39 129.000000 -25.333334 0.000000
X40 4.000000 -25.333334 0.000000
X41 4.000000 -21.333334 0.000000
X42 129.000000 -21.333334 0.000000
X43 129.000000 -9.777778 0.000000
X44 4.000000 -9.777778 0.000000
X45 4.000000 9.777778 0.000000
X46 129.000000 9.777778 0.000000
X47 129.000000 21.333334 0.000000
X48 4.000000 21.333334 0.000000
X49 4.000000 25.333334 0.000000
X50 129.000000 25.333334 0.000000
X51 129.000000 36.888889 0.000000
X52 4.000000 36.888889 0.000000
X53 4.000000 40.888889 0.000000
X54 129.000000 40.888889 0.000000
X55 129.000000 52.444443 0.000000
X56 4.000000 52.444443 0.000000
X57 4.000000 56.444443 0.000000
X58 129.000000 56.444443 0.000000
X59 129.000000 68.000000 0.000000
X60 4.000000 68.000000 0.000000
X61 11996.000000 -68.000000 0.000000
X62 11871.000000 -68.000000 0.000000
X63 11871.000000 -56.444443 0.000000
X64 11996.000000 -56.444443 0.000000
X65 11996.000000 -52.444443 0.000000
X66 11871.000000 -52.444443 0.000000
X67 11871.000000 -40.888889 0.000000
X68 11996.000000 -40.888889 0.000000
X69 11996.000000 -36.888889 0.000000
X70 11871.000000 -36.888889 0.000000
X71 11871.000000 -25.333334 0.000000
X72 11996.000000 -25.333334 0.000000
X73 11996.000000 -21.333334 0.000000
X74 11871.000000 -21.333334 0.000000
X75 11871.000000 -9.777778 0.000000
X76 11996.000000 -9.777778 0.000000
X77 11996.000000 9.777778 0.000000
X78 11871.000000 9.777778 0.000000
X79 11871.000000 21.333334 0.000000
X80 11996.000000 21.333334 0.000000
X81 11996.000000 25.333334 0.000000
X82 11871.000000 25.333334 0.000000
X83 11871.000000 36.888889 0.000000
X84 11996.000000 36.888889 0.000000
X85 11996.000000 40.888889 0.000000
X86 11871.000000 40.888889 0.000000
X87 11871.000000 52.444443 0.000000
X88 11996.000000 52.444443 0.000000
X89 11996.000000 56.444443 0.000000
X90 11871.000000 56.444443 0.000000
X91 11871.000000 68.000000 0.000000
X92 11996.000000 68.000000 0.000000
X93 258.000000 -2.000000 0.000000
X94 383.000000 -2.000000 0.000000
X95 383.000000 2.000000 0.000000
X96 258.000000 2.000000 0.000000
X97 633.000000 -2.000000 0.000000
X98 758.000000 -2.000000 0.000000
X99 758.000000 2.000000 0.000000
X100 633.000000 2.000000 0.000000
X101 1008.000000 -2.000000 0.000000
X102 1133.000000 -2.000000 0.000000
X103 1133.000000 2.000000 0.000000
X104 1008.000000 2.000000 0.000000
X105 1383.000000 -2.000000 0.000000
X106 1508.000000 -2.000000 0.000000
X107 1508.000000 2.000000 0.000000
X108 1383.000000 2.000000 0.000000
X109 1758.000000 -2.000000 0.000000
X110 1883.000000 -2.000000 0.000000
X111 1883.000000 2.000000 0.000000
X112 1758.000000 2.000000 0.000000
X113 2133.000000 -2.000000 0.000000
X114 2258.000000 -2.000000 0.000000
X115 2258.000000 2.000000 0.000000
X116 2133.000000 2.000000 0.000000
X117 2508.000000 -2.000000 0.000000
X118 2633.000000 -2.000000 0.000000
X119 2633.000000 2.000000 0.000000
X120 2508.000000 2.000000 0.000000
X121 2883.000000 -2.000000 0.000000
X122 3008.000000 -2.000000 0.000000
X123 3008.000000 2.000000 0.000000
X124 2883.000000 2.000000 0.000000
X125 3258.000000 -2.000000 0.000000
X126 3383.000000 -2.000000 0.000000
X127 3383.000000 2.000000 0.000000
X128 3258.000000 2.000000 0.000000
X129 3633.000000 -2.000000 0.000000
X130 3758.000000 -2.000000 0.000000
X131 3758.000000 2.000000 0.000000
X132 3633.000000 2.000000 0.000000
X133 4008.000000 -2.000000 0.000000
X134 4133.000000 -2.000000 0.000000
X135 4133.000000 2.000000 0.000000
X136 4008.000000 2.000000 0.000000
X137 4383.000000 -2.000000 0.000000
X138 4508.000000 -2.000000 0.000000
X139 4508.000000 2.000000 0.000000
X140 4383.000000 2.000000 0.000000
X141 4758.000000 -2.000000 0.000000
X142 4883.000000 -2.000000 0.000000
X143 4883.000000 2.000000 0.000000
X144 4758.000000 2.000000 0.000000
X145 5133.000000 -2.000000 0.000000
X146 5258.000000 -2.000000 0.000000
X147 5258.000000 2.000000 0.000000
X148 5133.000000 2.000000 0.000000
X149 5508.000000 -2.000000 0.000000
X150 5633.000000 -2.000000 0.000000
X151 5633.000000 2.000000 0.000000
X152 5508.000000 2.000000 0.000000
X153 5883.000000 -2.000000 0.000000
X154 6008.000000 -2.000000 0.000000
X155 6008.000000 2.000000 0.000000
X156 5883.000000 2.000000 0.000000
X157 6258.000000 -2.000000 0.000000
X158 6383.000000 -2.000000 0.000000
X159 6383.000000 2.000000 0.000000
X160 6258.000000 2.000000 0.000000
X161 6633.000000 -2.000000 0.000000
X162 6758.000000 -2.000000 0.000000
X163 6758.000000 2.000000 0.000000
X164 6633.000000 2.000000 0.000000
X165 7008.000000 -2.000000 0.000000
X166 7133.000000 -2.000000 0.000000
X167 7133.000000 2.000000 0.000000
X168 7008.000000 2.000000 0.000000
X169 7383.000000 -2.000000 0.000000
X170 7508.000000 -2.000000 0.000000
X171 7508.000000 2.000000 0.000000
X172 7383.000000 2.000000 0.000000
X173 7758.000000 -2.000000 0.000000
X174 7883.000000 -2.000000 0.000000
X175 7883.000000 2.000000 0.000000
X176 7758.000000 2.000000 0.000000
X177 8133.000000 -2.000000 0.000000
X178 8258.000000 -2.000000 0.000000
X179 8258.000000 2.000000 0.000000
X180 8133.000000 2.000000 0.000000
X181 8508.000000 -2.000000 0.000000
X182 8633.000000 -2.000000 0.000000
X183 8633.000000 2.000000 0.000000
X184 8508.000000 2.000000 0.000000
X185 8883.000000 -2.000000 0.000000
X186 9008.000000 -2.000000 0.000000
X187 9008.000000 2.000000 0.000000
X188 8883.000000 2.000000 0.000000
X189 9258.000000 -2.000000 0.000000
X190 9383.000000 -2.000000 0.000000
X191 9383.000000 2.000000 0.000000
X192 9258.000000 2.000000 0.000000
X193 9633.000000 -2.000000 0.000000
X194 9758.000000 -2.000000 0.000000
X195 9758.000000 2.000000 0.000000
X196 9633.000000 2.000000 0.000000
X197 10008.000000 -2.000000 0.000000
X198 10133.000000 -2.000000 0.000000
X199 10133.000000 2.000000 0.000000
X200 10008.000000 2.000000 0.000000
X201 10383.000000 -2.000000 0.000000
X202 10508.000000 -2.000000 0.000000
X203 10508.000000 2.000000 0.000000
X204 10383.000000 2.000000 0.000000
X205 10758.000000 -2.000000 0.000000
X206 10883.000000 -2.000000 0.000000
X207 10883.000000 2.000000 0.000000
X208 10758.000000 2.000000 0.000000
X209 11133.000000 -2.000000 0.000000
X210 11258.000000 -2.000000 0.000000
X211 11258.000000 2.000000 0.000000
X212 11133.000000 2.000000 0.000000
X213 11508.000000 -2.000000 0.000000
X214 11633.000000 -2.000000 0.000000
X215 11633.000000 2.000000 0.000000
X216 11508.000000 2.000000 0.000000
X#b7b19f 4  1 2 3 4
Xwhite 4  5 6 7 8
Xwhite 4  9 10 11 12
Xwhite 4  13 14 15 16
Xwhite 4  17 18 19 20
Xwhite 4  21 22 23 24
Xwhite 4  25 26 27 28
Xwhite 4  29 30 31 32
Xwhite 4  33 34 35 36
Xwhite 4  37 38 39 40
Xwhite 4  41 42 43 44
Xwhite 4  45 46 47 48
Xwhite 4  49 50 51 52
Xwhite 4  53 54 55 56
Xwhite 4  57 58 59 60
Xwhite 4  61 62 63 64
Xwhite 4  65 66 67 68
Xwhite 4  69 70 71 72
Xwhite 4  73 74 75 76
Xwhite 4  77 78 79 80
Xwhite 4  81 82 83 84
Xwhite 4  85 86 87 88
Xwhite 4  89 90 91 92
Xwhite 4  93 94 95 96
Xwhite 4  97 98 99 100
Xwhite 4  101 102 103 104
Xwhite 4  105 106 107 108
Xwhite 4  109 110 111 112
Xwhite 4  113 114 115 116
Xwhite 4  117 118 119 120
Xwhite 4  121 122 123 124
Xwhite 4  125 126 127 128
Xwhite 4  129 130 131 132
Xwhite 4  133 134 135 136
Xwhite 4  137 138 139 140
Xwhite 4  141 142 143 144
Xwhite 4  145 146 147 148
Xwhite 4  149 150 151 152
Xwhite 4  153 154 155 156
Xwhite 4  157 158 159 160
Xwhite 4  161 162 163 164
Xwhite 4  165 166 167 168
Xwhite 4  169 170 171 172
Xwhite 4  173 174 175 176
Xwhite 4  177 178 179 180
Xwhite 4  181 182 183 184
Xwhite 4  185 186 187 188
Xwhite 4  189 190 191 192
Xwhite 4  193 194 195 196
Xwhite 4  197 198 199 200
Xwhite 4  201 202 203 204
Xwhite 4  205 206 207 208
Xwhite 4  209 210 211 212
Xwhite 4  213 214 215 216
END_OF_FILE
if test 8674 -ne `wc -c <'acm/fsim/rwy'`; then
    echo shar: \"'acm/fsim/rwy'\" unpacked with wrong size!
fi
# end of 'acm/fsim/rwy'
fi
echo shar: End of archive 4 \(of 9\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 9 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Riley Rainey			Internet: riley@mips.com
MIPS Computer Systems		Phone:    +1 214 770-7979
Dallas, Texas