riley@mipsdal.mips.com (Riley Rainey) (10/08/90)
Submitted-by: riley@mipsdal.mips.com (Riley Rainey) Posting-number: Volume 9, Issue 71 Archive-name: acm/part03 echo x - ./fsim/init.c sed 's/^X//' >./fsim/init.c <<'*-*-END-of-./fsim/init.c-*-*' 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 Xextern craftType *newCraft(); X Xint init () { X X FILE *f; X static VObject *o1, *o2; X int i; X craft *p; X X for ((i=0, p=stbl); i<MAXSURFACE; (++i, ++p)) X p->type = CT_FREE; X X for ((i=0, p=ptbl); i<MAXPLAYERS; (++i, ++p)) { X p->index = i; X p->type = CT_FREE; X } X X for ((i=0, p=mtbl); i<MAXPROJECTILES; (++i, ++p)) X p->type = CT_FREE; X X/* HUDColor = VAllocColor ("#ffc800"); */ X HUDColor = VAllocColor ("white"); X/* groundColor = VAllocColor ("#29350B"); */ X/* groundColor = VAllocColor ("#717844"); */ X groundColor = VAllocColor ("#879349"); X whiteColor = VAllocColor ("white"); X blackColor = VAllocColor ("black"); X X/* X * Read in the runway and place it. X */ X X f = fopen ("rwy", "r"); X stbl[1].type = CT_SURFACE; X stbl[1].cinfo = newCraft(); X stbl[1].cinfo->object = VReadObject(f); X fclose (f); X stbl[1].Sg.x = 0.0; X stbl[1].Sg.y = 0.0; X stbl[1].Sg.z = 0.0; X stbl[1].curHeading = stbl[1].curPitch = stbl[1].curRoll = 0.0; X X f = fopen ("rwy2", "r"); X stbl[0].type = CT_SURFACE; X stbl[0].cinfo = newCraft(); X stbl[0].cinfo->object = VReadObject(f); X fclose (f); X stbl[0].Sg.x = 4000.0; X stbl[0].Sg.y = 3000.0; X stbl[0].Sg.z = 0.0; X stbl[0].curHeading = 300.0 * 3.14159 / 180.0; X stbl[0].curPitch = stbl[0].curRoll = 0.0; X X f = fopen ("tower", "r"); X stbl[2].type = CT_SURFACE; X stbl[2].cinfo = newCraft(); X stbl[2].cinfo->object = VReadObject(f); X fclose (f); X stbl[2].Sg.x = 4000.0; X stbl[2].Sg.y = -700.0; X stbl[2].Sg.z = 0.0; X stbl[2].curHeading = stbl[2].curPitch = stbl[2].curRoll = 0.0; X X f = fopen ("mtn", "r"); X stbl[3].type = CT_SURFACE; X stbl[3].cinfo = newCraft(); X stbl[3].cinfo->object = VReadObject(f); X fclose (f); X stbl[3].Sg.x = 20.0 * NM; X stbl[3].Sg.y = 6.0 * NM; X stbl[3].Sg.z = 0.0; X stbl[3].curHeading = DEGtoRAD (30.0); X stbl[3].curPitch = stbl[3].curRoll = 0.0; X X stbl[4].type = CT_SURFACE; X stbl[4].cinfo = stbl[3].cinfo; X stbl[4].Sg.x = -2.0 * NM; X stbl[4].Sg.y = 40.0 * NM; X stbl[4].Sg.z = 0.0; X stbl[4].curHeading = DEGtoRAD (160.0); X stbl[4].curPitch = stbl[4].curRoll = 0.0; X X stbl[5].type = CT_SURFACE; X stbl[5].cinfo = stbl[3].cinfo; X stbl[5].Sg.x = -2.6 * NM; X stbl[5].Sg.y = 43.0 * NM; X stbl[5].Sg.z = 0.0; X stbl[5].curHeading = DEGtoRAD (160.0); X stbl[5].curPitch = stbl[4].curRoll = 0.0; X X stbl[6].type = CT_SURFACE; X stbl[6].cinfo = stbl[1].cinfo; X stbl[6].Sg.x = -0.6 * NM; X stbl[6].Sg.y = 49.0 * NM; X stbl[6].Sg.z = 0.0; X stbl[6].curHeading = DEGtoRAD (0.0); X stbl[6].curPitch = stbl[6].curRoll = 0.0; X X initf16(); X initmig23(); X initf16(); X initmig23(); X initaim9(); X initm61a1(); X X/* X * This next little hack insures that the color tables correctly include X * colors associated with the aircraft. X */ X X f = fopen ("mig23", "r"); X o2 = VReadObject (f); X fclose (f); X X/* X * Set time intervals. X */ X X deltaT = (double) UPDATE_INTERVAL / 1000000.0; X X halfDeltaTSquared = 0.5 * deltaT * deltaT; X X return 0; X} *-*-END-of-./fsim/init.c-*-* echo x - ./fsim/placeCraft.c sed 's/^X//' >./fsim/placeCraft.c <<'*-*-END-of-./fsim/placeCraft.c-*-*' 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 Xvoid placeCraft (obj, poly, cnt) Xcraft *obj; XVPolygon **poly; Xint *cnt; { X X int i, j, k, n; X VPoint *q, tmp; X VMatrix mtx; X VPolygon **p; X X j = *cnt; X X VIdentMatrix (&mtx); X if (obj->curRoll != 0.0) X VRotate (&mtx, XRotation, obj->curRoll); X if (obj->curPitch != 0.0) X VRotate (&mtx, YRotation, - obj->curPitch); X if (obj->curHeading != 0.0) X VRotate (&mtx, ZRotation, obj->curHeading); X VTranslatePoint (&mtx, obj->Sg); X X if (obj->cinfo->placeProc != NULL) { X (*obj->cinfo->placeProc)(obj, &mtx, poly, cnt); X return; X } X X n = obj->cinfo->object->numPolys; X p = obj->cinfo->object->polygon; X for (i=0; i<n; ++i) { X X poly[j] = VCopyPolygon(p[i]); X for ((k=0, q=poly[j]->vertex); k<poly[j]->numVtces; (++k, ++q)) { X VTransform(q, &mtx, &tmp); X *q = tmp; X } X ++j; X } X X *cnt = j; X} *-*-END-of-./fsim/placeCraft.c-*-* echo x - ./fsim/makefile sed 's/^X//' >./fsim/makefile <<'*-*-END-of-./fsim/makefile-*-*' X# X# Makefile for acm; Riley Rainey, 1990 X# XLDFLAGS = -L../V/lib XCFLAGS = -g -I../V/lib -systype bsd43 X XOBFILES = server.o \ X pm.o \ X flaps.o \ X droneCalculations.o\ X init.o \ X aim9m.o \ X m61a1.o \ X weapon.o \ X newPlayer.o \ X newPlane.o \ X missile.o \ X missileCalculations.o \ X update.o \ X doEvents.o \ X getStick.o \ X doViews.o \ X doRadar.o \ X placeCraft.o \ X transpose.o \ X doScale.o X Xall: acm acms X Xacm: acm.o X cc $(CFLAGS) $(LDFLAGS) -o acm acm.o X Xacms: $(OBFILES) X cc $(CFLAGS) $(LDFLAGS) -o acms $(OBFILES) -lV -lX11 -lm X Xclean: X -rm core *.o X Xclobber: X -rm acm acms *.o core X Xtar: X tar cv acm acms f16 mig23 aim-9 rwy rwy2 tower mtn bullet X XV2tgif: V2tgif.c X cc -O2 -L../V/lib -I../V/lib -o V2tgif V2tgif.c -lV -lX11 -lbsd -lm X Xmkdepend: makefile X mkdepend -c "cc $(CFLAGS)" -e "/include/d" makefile *.c X touch mkdepend X X# DO NOT DELETE THIS LINE -- make depend uses it XV2tgif.o: V2tgif.c ../V/lib/Vlib.h Xacm.o: acm.c manifest.h Xaim9m.o: aim9m.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h XdoEvents.o: doEvents.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h XdoRadar.o: doRadar.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h XdoScale.o: doScale.c scale.h XdoViews.o: doViews.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h XdroneCalculations.o: droneCalculations.c pm.h manifest.h eng.xbm \ X flaps0.xbm flaps1.xbm flaps2.xbm flaps3.xbm scale.h \ X ../V/lib/Vlib.h Xflaps.o: flaps.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h XgetStick.o: getStick.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h Xinit.o: init.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm flaps2.xbm \ X flaps3.xbm scale.h ../V/lib/Vlib.h Xm61a1.o: m61a1.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h Xmissile.o: missile.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h XmissileCalculations.o: missileCalculations.c pm.h manifest.h eng.xbm \ X flaps0.xbm flaps1.xbm flaps2.xbm flaps3.xbm scale.h \ X ../V/lib/Vlib.h XnewPlane.o: newPlane.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h XnewPlayer.o: newPlayer.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h XplaceCraft.o: placeCraft.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h Xpm.o: pm.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm flaps2.xbm \ X flaps3.xbm scale.h ../V/lib/Vlib.h Xserver.o: server.c manifest.h Xtranspose.o: transpose.c ../V/lib/Vlib.h Xupdate.o: update.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h Xweapon.o: weapon.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \ X flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h X# DO NOT DELETE THIS 2nd LINE -- make depend uses it *-*-END-of-./fsim/makefile-*-* echo x - ./fsim/newPlane.c sed 's/^X//' >./fsim/newPlane.c <<'*-*-END-of-./fsim/newPlane.c-*-*' 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 X#ifndef SYSV Xextern char * malloc(); X Xchar *strdup (s) Xchar *s; { X char *p; X X p = malloc (strlen(s)+1); X strcpy (p, s); X return p; X} X#endif 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 Xvoid initf16 () { X X int i; X FILE *f; X craftType *c; X X c = newCraft(); X c->name = strdup("f-16c"); X c->CLOrigin = 0.129871; X c->CLSlope = 3.24778; X c->CLNegStall = -17.0 * pi / 180.0; X c->CLPosStall = 26.0 * pi / 180.0; X X c->aspectRatio = 3.0; X X c->CDOrigin = 0.03642; 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.8; /* based on 60 ft^2 tail; CL = 1.0; Ivz = 4.0 ft */ 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; CL = 1.0; Ivx = 15 ft */ X X c->effElevator = 0.50; X c->effAileron = 0.70; X c->effRudder = 0.30; 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.02; /* 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] = 50000.0; X c->I.m[1][1] = 120000.0; X c->I.m[2][2] = 125000.0; X c->LDamp = 200000.0; X c->MDamp = 1000000.0; X c->NDamp = 3600000.0; X c->cmSlope = -1.88; X c->cmFactor = -1.00; X c->cnSlope = 1.00; X c->cnFactor = 0.50; X c->betaStall = 15.0 * pi / 180.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 = 100.0 * 6076.0 / 3600.0; X c->gearD1 = 13.5; X c->gearD2 = -2.5; X f = 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} X Xvoid initmig23 () { X X int i; 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.24778; 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->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->CMOrigin = 0.0; X c->CMFactor = -0.95; X X c->CNOrigin = 0.0; X c->CNFactor = -0.90; X X c->effElevator = 0.50; X c->effAileron = 0.70; X c->effRudder = 0.30; 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.02; /* 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] = 60000.0; X c->I.m[1][1] = 180000.0; X c->I.m[2][2] = 195000.0; X c->LDamp = 700000.0; X c->MDamp = 1000000.0; X c->NDamp = 1000000.0; X c->cmSlope = -1.88; X c->cmFactor = -1.00; X c->cnSlope = 1.00; X c->cnFactor = 0.50; X c->betaStall = 15.0 * pi / 180.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 = 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} 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 = 40.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 = 1024; 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] = malloc (32); X c->rightHUD[j] = malloc (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 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 = 400.0; X s.y = 30.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 = 1024; 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-./fsim/newPlane.c-*-* echo x - ./fsim/doEvents.c sed 's/^X//' >./fsim/doEvents.c <<'*-*-END-of-./fsim/doEvents.c-*-*' 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 <X11/Xutil.h> X#include <X11/keysym.h> X X#define MAX_MAPPED_STRING_LEN 10 X#define MAX_POPUP_STRING_LEN 40 X Xextern int cur; X Xvoid doEvents(c) Xcraft *c; X{ X X XEvent ev; X viewer *u; X int player; X double scale; X X/* X * Process events for each player and any "back seaters" X */ X X player = 1; X for (u=c->vl; u != (viewer *) NULL; u=u->next) { X X X#define mask KeyPressMask | ButtonPressMask | ButtonReleaseMask | \ X StructureNotifyMask X X if (cur % REDRAW_EVERY == 0) X getStick (c, u); X X while (XCheckWindowEvent (u->dpy, u->win, mask, &ev) == True) { X X switch (ev.type) { X X case KeyPress: X if (doKeyEvent (c, u, &ev, player) < 0) X return; X break; X X case ButtonPress: X if (doButtonEvent (c, u, &ev, player) < 0) X return; X break; X X case ButtonRelease: X if (doButtonReleaseEvent (c, u, &ev, player) < 0) X return; X break; X X case ConfigureNotify: X scale = (double) ev.xconfigure.height / X (double) FS_WINDOW_HEIGHT; X u->width = ev.xconfigure.width; X u->height = ev.xconfigure.height; X u->height = u->height * VIEW_WINDOW_HEIGHT / X FS_WINDOW_HEIGHT; X u->xCenter = u->width / 2; X u->yCenter = u->height / 2; X VResizeViewport (u->v, 12.0*25.4/1000.0, X 0.40, scale, u->width, u->height); X break; X X default: X break; X } X X } X X player = 0; X X } X} X Xint doButtonEvent (c, u, ev, player) Xcraft *c; Xviewer *u; XXEvent *ev; Xint player; { X X if (ev->xbutton.button == Button2) X fireWeapon (c); X X else if (ev->xbutton.button == Button3) X selectWeapon (c); X X return 0; X} X Xint doButtonReleaseEvent (c, u, ev, player) Xcraft *c; Xviewer *u; XXEvent *ev; Xint player; { X X if (ev->xbutton.button == Button2) X ceaseFireWeapon (c); X X return 0; X} X Xint doKeyEvent (c, u, ev, player) Xcraft *c; Xviewer *u; XXEvent *ev; Xint player; X{ X X KeySym keysym; X XComposeStatus compose; X char buffer[MAX_MAPPED_STRING_LEN]; X int buflen = MAX_MAPPED_STRING_LEN; X int count; X X count = XLookupString (ev, buffer, buflen, &keysym, &compose); X X if (player) { X X switch (keysym) { X X case XK_Left: X if (c->flags & FL_NWS) { X c->curNWDef = c->curNWDef - c->cinfo->NWIncr; X if (c->curNWDef < - c->cinfo->maxNWDef) X c->curNWDef = - c->cinfo->maxNWDef; X } X else { X c->Sa = c->Sa - 0.05; X } X break; X X case XK_Right: X if (c->flags & FL_NWS) { X c->curNWDef = c->curNWDef + c->cinfo->NWIncr; X if (c->curNWDef > c->cinfo->maxNWDef) X c->curNWDef = c->cinfo->maxNWDef; X } X else { X c->Sa = c->Sa + 0.05; X } X break; X X case XK_Up: X c->Se = c->Se - 0.01; X break; X X case XK_Down: X c->Se = c->Se + 0.01; X break; X X case XK_Home: X c->Se = 0.0; X c->Sr = 0.0; X c->Sa = 0.0; X break; X X case XK_y: X case XK_Y: X flapsUp (c); X break; X X case XK_h: X case XK_H: X flapsDown (c); X break; X X case XK_w: X case XK_W: X speedBrakeRetract (c); X break; X X case XK_s: X case XK_S: X speedBrakeExtend (c); X break; X X case XK_2: X case XK_KP_Subtract: X c->throttle = (c->throttle <= 1000) ? 1000 : X c->throttle - 512; X c->curThrust = calcThrust(c); X break; X X case XK_3: X case XK_KP_Add: X c->throttle = (c->throttle >= 32768) ? 32768 : X c->throttle + 512; X c->curThrust = calcThrust(c); X break; X X case XK_4: X case XK_Prior: X c->throttle = 32768; X c->curThrust = calcThrust(c); X break; X X case XK_1: X case XK_Next: X c->throttle = 3276; X c->curThrust = calcThrust(c); X break; X X case XK_A: X case XK_a: X c->flags ^= FL_AFTERBURNER; X c->curThrust = calcThrust(c); X break; X X case XK_B: X case XK_b: X c->flags ^= FL_BRAKES; X break; X X case XK_L: X case XK_l: X newDrone (c); X break; X X case XK_KP_8: 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 break; X X/* look right */ X X case XK_KP_6: X c->viewDirection.x = 0.0; X c->viewDirection.y = 1.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 break; X X/* look left */ X X case XK_KP_4: X c->viewDirection.x = 0.0; X c->viewDirection.y = -1.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 break; X X/* look back */ X X case XK_KP_2: 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 break; X X/* look up */ X X case XK_KP_5: X c->viewDirection.x = 0.0; X c->viewDirection.y = 0.0; X c->viewDirection.z = -1.0; X c->viewUp.x = -1.0; X c->viewUp.y = 0.0; X c->viewUp.z = 0.0; X break; X X case XK_Q: X case XK_q: X c->curRadarTarget = getRadarTarget (c, 1); X break; X X case XK_R: X case XK_r: X c->radarMode = (c->radarMode == RM_STANDBY) ? X RM_NORMAL : RM_STANDBY; X break; X X case XK_P: X case XK_p: X killPlayer (c); X return -1; X } X X } X X return 0; X} *-*-END-of-./fsim/doEvents.c-*-* echo x - ./fsim/doScale.c sed 's/^X//' >./fsim/doScale.c <<'*-*-END-of-./fsim/doScale.c-*-*' X#include <X11/Xlib.h> X#include "scale.h" X Xstatic char *skipBlanks (s) Xchar *s; { X X for (; *s == ' '; s++) ; X return s; X} X Xvoid doScale (dpy, win, gc, s, value, fth, ftw) XDisplay *dpy; XWindow win; XGC gc; XscaleControl *s; Xdouble value; Xint fth; Xint ftw; { X X XPoint p; X XSegment seg[32]; X int is = 0; X double vStart; X int top = s->yorg - s->length; X int y, w, v, n; X int ytick = (double) s->minorInterval / s->scale + 0.5; X int doMajor; X char str[16], *q; X X vStart = value - (double) (s->length / 2) * s->scale; X n = (int) vStart % s->minorInterval; X if (n > 0) X n = n - s->minorInterval; X y = s->yorg + (int) (n / s->scale); X if (vStart > 0.0) X v = (int) (vStart + s->minorInterval - 1.0); X else X v = (int) vStart; X v = v / s->minorInterval * s->minorInterval; X X/* X * Draw the index mark X */ X X seg[is].y1 = seg[is].y2 = s->yorg - ((double) s->length / 2.0); X if (s->orientation & orientRight) { X seg[is].x1 = s->xorg - 2; X seg[is].x2 = seg[is].x1 - s->indexSize; X } X else { X seg[is].x1 = s->xorg + 2; X seg[is].x2 = seg[is].x1 + s->indexSize; X } X ++ is; X X/* X * step through the doMajor and minor ticks X */ X X for (; y > top; (y -= ytick, v += s->minorInterval)) { X X/* we don't mark negative ticks */ X X if (v < 0) X continue; X X seg[is].x1 = s->xorg; X seg[is].y1 = seg[is].y2 = p.y = y; X X if ((v % s->majorInterval) == 0) { X doMajor = 1; X w = s->majorSize; X if (s->orientation & orientRight) X seg[is].x2 = s->xorg + w; X else X seg[is].x2 = s->xorg - w; X sprintf (str, s->format, (double) v / s->divisor); X q = skipBlanks (str); X p.y += 0.30 * (double) fth; X if (s->orientation & orientRight) { X p.x = seg[is].x2 + 3; X } X else { X p.x = seg[is].x2 - 3 - ftw * strlen(q); X } X } X else { X doMajor = 0; X w = s->minorSize; X if (s->orientation & orientRight) X seg[is].x2 = s->xorg + w; X else X seg[is].x2 = s->xorg - w; X } X X if (doMajor) X XDrawString (dpy, win, gc, p.x, p.y, q, X strlen (q)); X ++ is; X } X X XDrawSegments (dpy, win, gc, seg, is); X X} X Xvoid doCompassScale (dpy, win, gc, s, value, fth, ftw) XDisplay *dpy; XWindow win; XGC gc; XscaleControl *s; Xdouble value; Xint fth; Xint ftw; { X X XPoint p; X XSegment seg[32]; X int is = 0; X double vStart; X int top = s->xorg + s->length; X int x, w, v, n; X int xtick = (double) s->minorInterval / s->scale + 0.5; X int doMajor; X char str[16], *q; X X vStart = value - (double) (s->length / 2) * s->scale; X if (vStart <= 0.0) X vStart += 36000.0; X n = (int) vStart % s->minorInterval; X if (n > 0) X n = n - s->minorInterval; X x = s->xorg - (int) (n / s->scale); X if (vStart > 0.0) X v = (int) (vStart + s->minorInterval - 1.0); X else X v = (int) vStart; X v = v / s->minorInterval * s->minorInterval; X X/* X * Draw the index mark X */ X X seg[is].x1 = seg[is].x2 = s->xorg + (int) ((double) s->length / 2.0 + 0.5); X if (s->orientation & orientRight) { X seg[is].y1 = s->yorg - 2; X seg[is].y2 = seg[is].y1 - s->indexSize; X } X else { X seg[is].y1 = s->yorg + 2; X seg[is].y2 = seg[is].y1 + s->indexSize; X } X ++ is; X X/* X * step through the doMajor and minor ticks X */ X X for (; x < top; (x += xtick, v += s->minorInterval)) { X X if (v > 36000) X v -= 36000; X X seg[is].y1 = s->yorg; X seg[is].x1 = seg[is].x2 = p.x = x; X X if ((v % s->majorInterval) == 0) { X doMajor = 1; X w = s->majorSize; X if (s->orientation & orientRight) X seg[is].y2 = s->yorg + w; X else X seg[is].y2 = s->yorg - w; X sprintf (str, s->format, (double) v / s->divisor); X q = skipBlanks (str); X p.x -= (strlen(q) * ftw) / 2; X if (s->orientation & orientRight) { X p.y = seg[is].y2 + 3 + fth; X } X else { X p.y = seg[is].y2 - 3; X } X } X else { X doMajor = 0; X w = s->minorSize; X if (s->orientation & orientRight) X seg[is].y2 = s->yorg + w; X else X seg[is].y2 = s->yorg - w; X } X X if (doMajor) X XDrawString (dpy, win, gc, p.x, p.y, q, X strlen (q)); X ++ is; X } X X XDrawSegments (dpy, win, gc, seg, is); X X} *-*-END-of-./fsim/doScale.c-*-* echo x - ./fsim/rwy sed 's/^X//' >./fsim/rwy <<'*-*-END-of-./fsim/rwy-*-*' 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-./fsim/rwy-*-* echo x - ./fsim/mig23 sed 's/^X//' >./fsim/mig23 <<'*-*-END-of-./fsim/mig23-*-*' Xmig-23-wings-swept X88 10 X1 36.5891 0 0 X2 34.4368 0.86092 0 X3 30.9931 1.29138 0 X4 27.119 1.72184 0 X5 20.6621 1.72184 0 X6 18.9402 2.1523 0 X7 14.2052 3.01322 0 X8 -3.44368 2.58276 0 X9 -9.03966 2.1523 0 X10 -16.7879 0.86092 0 X11 -18.0793 0.43046 0 X12 -18.0793 0 0 X13 36.5891 0 0 X14 34.4368 -0.86092 0 X15 30.9931 -1.29138 0 X16 27.119 -1.72184 0 X17 20.6621 -1.72184 0 X18 18.9402 -2.1523 0 X19 14.2052 -3.01322 0 X20 -3.44368 -2.58276 0 X21 -9.03966 -2.1523 0 X22 -16.7879 -0.86092 0 X23 -18.0793 -0.43046 0 X24 -18.0793 0 0 X25 14.2052 3.01322 -3.01322 X26 4.73506 7.31782 -3.01322 X27 6.02644 8.6092 -3.01322 X28 -11.192 13.7747 -3.01322 X29 -12.0529 13.7747 -3.01322 X30 -14.2052 11.192 -3.01322 X31 -14.2052 10.7615 -3.01322 X32 -3.44368 2.58276 -3.01322 X33 14.2052 -3.01322 -3.01322 X34 4.73506 -7.31782 -3.01322 X35 6.02644 -8.6092 -3.01322 X36 -11.192 -13.7747 -3.01322 X37 -12.0529 -13.7747 -3.01322 X38 -14.2052 -11.192 -3.01322 X39 -14.2052 -10.7615 -3.01322 X40 -3.44368 -2.58276 -3.01322 X41 -18.9402 3.01322 -1.72184 X42 -20.2316 7.31782 -1.72184 X43 -18.5098 8.6092 -1.72184 X44 -9.03966 2.1523 -1.72184 X45 -16.7879 0.86092 -1.72184 X46 -18.9402 -3.01322 -1.72184 X47 -20.2316 -7.31782 -1.72184 X48 -18.5098 -8.6092 -1.72184 X49 -9.03966 -2.1523 -1.72184 X50 -16.7879 -0.86092 -1.72184 X51 36.5891 0 0 X52 33.1454 0 -1.29138 X53 30.1322 0 -2.1523 X54 25.8276 0 -2.58276 X55 22.3839 0 -3.87414 X56 18.0793 0 -4.3046 X57 9.47012 0 -3.87414 X58 -0.860918 0 -3.44368 X59 -8.6092 0 -6.02644 X60 -16.3575 0 -10.331 X61 -18.9402 0 -9.03966 X62 -18.0793 0 -3.87414 X63 -19.8012 0 -3.44368 X64 -17.2184 0 -1.72184 X65 -18.0793 0 -1.72184 X66 -18.0793 0 1.29138 X67 -15.4966 0 1.72184 X68 -6.4569 0 2.1523 X69 10.331 0 2.1523 X70 20.2316 0 1.72184 X71 28.8408 0 1.29138 X72 33.1454 0 0.86092 X73 -15.4966 0 1.72184 X74 -15.4966 0 4.3046 X75 -13.3443 0 5.16552 X76 -6.4569 0 2.1523 X77 20.6621 1.72184 -3.01322 X78 18.9402 2.1523 -3.01322 X79 14.2052 3.01322 -3.01322 X80 -3.44368 2.58276 -3.01322 X81 -3.44368 -2.58276 -3.01322 X82 14.2052 -3.01322 -3.01322 X83 18.9402 -2.1523 -3.01322 X84 20.6621 -1.72184 -3.01322 X85 -3.44368 2.58276 -3.01322 X86 -16.7879 0.86092 -1.72184 X87 -16.7879 -0.86092 -1.72184 X88 -3.44368 -2.58276 -3.01322 Xgray33 12 1 2 3 4 5 6 7 8 9 10 11 12 Xgray33 12 13 14 15 16 17 18 19 20 21 22 23 24 Xgray33 8 25 26 27 28 29 30 31 32 Xgray33 8 33 34 35 36 37 38 39 40 Xgray33 5 41 42 43 44 45 Xgray33 5 46 47 48 49 50 Xgray33 22 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 Xgray33 4 73 74 75 76 Xgray33 8 77 78 79 80 81 82 83 84 Xgray33 4 85 86 87 88 *-*-END-of-./fsim/mig23-*-* echo x - ./fsim/f16 sed 's/^X//' >./fsim/f16 <<'*-*-END-of-./fsim/f16-*-*' XF-16-fighter X130 12 X1 -18.165 0 0 X2 -18.165 -1.191 0 X3 -15.187 -2.085 0 X4 -13.698 -2.382 0 X5 -17.272 -2.382 0 X6 -17.272 -3.573 0 X7 -10.923 -3.573 0 X8 -4.169 -3.573 0 X9 -4.169 -4.765 0 X10 5.598 -4.765 0 X11 18.463 -2.144 0 X12 18.939 -1.787 0 X13 22.274 -1.489 0 X14 24.895 -1.191 0 X15 27.992 0 0 X16 -6.551 -3.573 0 X17 -6.551 -15.485 0 X18 0.357 -15.485 0 X19 0.357 -15.187 0 X20 -2.978 -15.008 0 X21 5.598 -4.765 0 X22 -4.169 -4.765 0 X23 -4.169 -3.573 0 X24 -17.272 -3.573 0 X25 -17.272 -8.934 0.893 X26 -15.187 -8.934 0.893 X27 -10.923 -3.573 0 X28 27.992 0 0 X29 24.895 1.191 0 X30 22.274 1.489 0 X31 18.939 1.787 0 X32 18.463 2.144 0 X33 5.598 4.765 0 X34 -4.169 4.765 0 X35 -4.169 3.573 0 X36 -10.923 3.573 0 X37 -17.272 3.573 0 X38 -17.272 2.382 0 X39 -13.698 2.382 0 X40 -15.187 2.085 0 X41 -18.165 1.191 0 X42 -18.165 0 0 X43 5.598 4.765 0 X44 -2.978 15.008 0 X45 0.357 15.187 0 X46 0.357 15.485 0 X47 -6.551 15.485 0 X48 -6.551 3.573 0 X49 -4.169 3.573 0 X50 -4.169 4.765 0 X51 -10.923 3.573 0 X52 -15.187 8.934 0.893 X53 -17.272 8.934 0.893 X54 -17.272 3.573 0 X55 27.992 0 0 X56 23.525 0 -1.191 X57 17.272 0 -2.382 X58 15.783 0 -3.812 X59 13.996 0 -4.169 X60 11.316 0 -4.05 X61 8.338 0 -3.335 X62 1.787 0 -2.382 X63 -4.169 0 -2.382 X64 -13.936 0 -1.906 X65 -15.128 0 -1.906 X66 -15.187 0 -1.787 X67 -18.165 0 -1.191 X68 -18.165 0 0 X69 -4.169 0 -2.382 X70 -10.125 0 -4.05 X71 -15.783 0 -10.482 X72 -19.654 0 -10.482 X73 -19.654 0 -9.529 X74 -19.654 0 -9.529 X75 -16.378 0 -3.573 X76 -16.378 0 -2.144 X77 -14.889 0 -2.382 X78 -13.936 0 -2.382 X79 -13.936 0 -1.906 X80 -18.165 0 0 X81 -18.165 0 1.191 X82 -15.187 0 2.085 X83 -13.698 0 2.263 X84 -2.68 0 2.382 X85 8.04 0 2.382 X86 12.507 0 2.263 X87 12.507 0 0.596 X88 19.952 0 0.596 X89 23.525 0 0.476 X90 27.992 0 0 X91 -3.551 0 -2.382 X92 -3.551 -3.871 -0.10 X93 -3.551 -15.485 0 X94 -3.551 -15.485 0.1065 X95 -3.551 -3.871 0.142 X96 -3.551 -2.58 0.2556 X97 -3.551 -2.387 1.818 X98 -3.551 -2.102 2.015 X99 -3.551 -1.03 2.251 X100 -3.551 0 2.282 X101 -3.551 1.03 2.251 X102 -3.551 2.102 2.015 X103 -3.551 2.387 1.818 X104 -3.551 2.58 0.2556 X105 -3.551 3.871 0.142 X106 -3.551 15.485 0.1065 X107 -3.551 15.485 0 X108 -3.551 3.871 -0.10 X109 13.996 0 -4.169 X110 13.996 -0.8932 -3.692 X111 13.996 -1.191 -2.978 X112 13.996 -1.251 -2.502 X113 13.996 -1.787 -1.311 X114 13.996 -3.054 0 X115 13.996 -1.583 0.3568 X116 13.996 0 0.596 X117 13.996 1.583 0.3568 X118 13.996 3.054 0 X119 13.996 1.787 -1.311 X120 13.996 1.251 -2.502 X121 13.996 1.191 -2.978 X122 13.996 0.8932 -3.692 X123 -18.165 1.191 0 X124 -18.165 0.842 0.842 X125 -18.165 0 1.191 X126 -18.165 -0.842 0.842 X127 -18.165 -1.191 0 X128 -18.165 -0.842 -0.842 X129 -18.165 0 -1.191 X130 -18.165 0.842 -0.842 Xgray33 14 109 110 111 112 113 114 115 116 117 118 119 120 121 122 Xgray33 18 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 Xgray33 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Xgray33 8 16 17 18 19 20 21 22 23 Xgray33 4 24 25 26 27 Xgray33 15 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 Xgray33 8 43 44 45 46 47 48 49 50 Xgray33 4 51 52 53 54 Xgray33 14 55 56 57 58 59 60 61 62 63 64 65 66 67 68 Xgray33 11 69 70 71 72 73 74 75 76 77 78 79 Xgray33 11 80 81 82 83 84 85 86 87 88 89 90 Xgray33 8 123 124 125 126 127 128 129 130 *-*-END-of-./fsim/f16-*-* echo x - ./fsim/transpose.c sed 's/^X//' >./fsim/transpose.c <<'*-*-END-of-./fsim/transpose.c-*-*' 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 <Vlib.h> X Xint transpose (m, r) XVMatrix *m, *r; { X X int i, j; X X for (i=0; i<4; ++i) X for (j=0; j<4; ++j) X r->m[i][j] = m->m[j][i]; X return 0; X} *-*-END-of-./fsim/transpose.c-*-* echo x - ./fsim/mtn sed 's/^X//' >./fsim/mtn <<'*-*-END-of-./fsim/mtn-*-*' X*mountain X5 4 X1 28000 0 0 X2 0 16000 0 X3 -35000 0 0 X4 0 -14000 0 X5 0 0 -8200 X#788b63 3 1 2 5 X#788b63 3 2 3 5 X#788b63 3 3 4 5 X#788b63 3 4 1 5 *-*-END-of-./fsim/mtn-*-* echo x - ./fsim/acm.c sed 's/^X//' >./fsim/acm.c <<'*-*-END-of-./fsim/acm.c-*-*' 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 "manifest.h" X#include <sys/types.h> X#include <stdio.h> X#include <pwd.h> X#include <signal.h> X#include <sys/socket.h> X#include <netinet/in.h> X#include <netdb.h> X#include <setjmp.h> X Xextern char *getenv (); Xextern struct servent *getservent(); X Xjmp_buf dead; X Xdone () { X longjmp (dead); X} X Xmain (argc, argv) Xint argc; Xchar *argv[]; { X X char *display; X char *username; X char *host; X char myhost[64]; X char args[128]; X int s, n = 1; X struct passwd *pwent, *getpwuid(); X struct servent *sp; X struct sockaddr_in sin; X struct hostent *h = (struct hostent *) NULL; X X if ((host = getenv("ACMSERVER")) == NULL) X if (argc >= 2) { X host = argv[1]; X n = 2; X } X else { X fprintf (stderr, "usage: %s server-hostname\n", argv[0]); X exit (1); X } X X if ((pwent = getpwuid(getuid())) == NULL) { X fprintf (stderr, "Yow!\n"); X exit (1); X } X X if ((display = getenv("DISPLAY")) == NULL) { X fprintf (stderr, "Excuse me, but you have no DISPLAY.\n\ XHow do you use X, anyway?\n"); X exit (1); X } X X/* X * Sometimes we end up with a DISPLAY value that won't jive on the X * network (e.g. ":0.0") -- fix these cases. X */ X X if (*display == ':') { X gethostname (myhost, sizeof(myhost)); X strcat (myhost, display); X display = myhost; X } X X if ((sin.sin_addr.s_addr = inet_addr (host)) != -1) { X sin.sin_family = AF_INET; X } X else if ((h = gethostbyname (host)) != 0) { X sin.sin_family = h->h_addrtype; X bcopy (h->h_addr, &sin.sin_addr, h->h_length); X } X else { X fprintf (stderr, "Unknown host \"%s\"\n", host); X exit (1); X } X X sin.sin_port = htons(ACM_PORT); X X signal (SIGPIPE, done); X X if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0) { X perror ("can't get a socket"); X exit (1); X } X X if (connect (s, (struct sockaddr *) &sin, sizeof (sin)) < 0) { X perror ("can't connect to server"); X close (s); X exit (1); X } X X if (argv[n] != (char *) NULL) X strcpy (args, argv[n++]); X else X strcpy (args, ""); X X for (; argv[n] != (char *) NULL; ++n) { X strcat (args, "|"); X strcat (args, argv[n]); X } X X if (setjmp (dead) == 0) X handshake (s, display, pwent->pw_name, args); X X exit (0); X} X Xhandshake (s, dpy, name, args) Xint s; Xchar *dpy, *name, *args; { X X char info[128]; X int n; X X sprintf (info, "%s %s %s\n", dpy, name, args); X write (s, info, strlen (info)); X while ((n = read (s, info, sizeof (info))) > 0) X write (fileno (stdout), info, n); X X return 0; X} *-*-END-of-./fsim/acm.c-*-* echo x - ./fsim/doRadar.c sed 's/^X//' >./fsim/doRadar.c <<'*-*-END-of-./fsim/doRadar.c-*-*' 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 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->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->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 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 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, j; X X for (i=0; i<MAXPLAYERS; ++i) X j = 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->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->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-./fsim/doRadar.c-*-* echo x - ./fsim/flaps3.xbm sed 's/^X//' >./fsim/flaps3.xbm <<'*-*-END-of-./fsim/flaps3.xbm-*-*' X#define flaps3_width 64 X#define flaps3_height 32 X#define flaps3_x_hot -1 X#define flaps3_y_hot -1 Xstatic char flaps3_bits[] = { X 0x00, 0xf0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xdd, 0xfd, X 0x1f, 0x00, 0x00, 0x00, 0x20, 0xef, 0xee, 0xee, 0xee, 0xff, 0x03, 0x00, X 0x30, 0x77, 0x77, 0x77, 0x77, 0xf7, 0x3f, 0x00, 0x38, 0xbb, 0xbb, 0xbb, X 0xbb, 0x7b, 0x00, 0x00, 0x28, 0xdf, 0xdd, 0xdd, 0xdd, 0x3d, 0x0c, 0x00, X 0x6c, 0xfe, 0xff, 0xff, 0xff, 0x1f, 0x3c, 0x00, 0x3c, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x38, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00}; *-*-END-of-./fsim/flaps3.xbm-*-* echo x - ./fsim/flaps0.xbm sed 's/^X//' >./fsim/flaps0.xbm <<'*-*-END-of-./fsim/flaps0.xbm-*-*' X#define flaps0_width 64 X#define flaps0_height 32 X#define flaps0_x_hot 4 X#define flaps0_y_hot 25 Xstatic char flaps0_bits[] = { X 0x00, 0xf0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0xdf, 0xdd, 0xfd, X 0x1f, 0x00, 0x00, 0x00, 0x60, 0xef, 0xee, 0xee, 0xee, 0x1f, 0x00, 0x00, X 0x70, 0x77, 0x77, 0x77, 0x77, 0xf7, 0x03, 0x00, 0x50, 0xbb, 0xbb, 0xbb, X 0xbb, 0x7b, 0x7f, 0x00, 0x50, 0xdf, 0xdd, 0xdd, 0xdd, 0xbd, 0xff, 0x07, X 0xe0, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00}; *-*-END-of-./fsim/flaps0.xbm-*-* echo x - ./fsim/exp.xbm sed 's/^X//' >./fsim/exp.xbm <<'*-*-END-of-./fsim/exp.xbm-*-*' X#define exp_width 64 X#define exp_height 64 Xstatic char exp_bits[] = { X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x01, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0xa8, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, X 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xc2, 0x61, 0x00, 0x03, X 0x00, 0x00, 0x00, 0x20, 0xc2, 0x21, 0x80, 0x03, 0x00, 0x00, 0x1c, 0x40, X 0xc0, 0x21, 0x80, 0x03, 0x00, 0x80, 0x30, 0x40, 0x80, 0x38, 0x80, 0x01, X 0x00, 0x80, 0x09, 0xa3, 0x82, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x11, 0x02, X 0xc2, 0x22, 0x40, 0x00, 0x00, 0x00, 0x86, 0x84, 0xc4, 0x00, 0x40, 0x00, X 0x00, 0x00, 0x80, 0x14, 0xc6, 0x02, 0x50, 0x00, 0xc0, 0x00, 0x0c, 0x8a, X 0xe9, 0x00, 0x00, 0x00, 0xc0, 0x01, 0xa8, 0x18, 0xd3, 0x75, 0x02, 0x08, X 0x80, 0x01, 0xe0, 0x04, 0x3e, 0x03, 0x01, 0x04, 0x00, 0x05, 0x10, 0x92, X 0x8a, 0x0e, 0x06, 0x07, 0x00, 0x5c, 0x81, 0xf1, 0xef, 0x1b, 0x00, 0x02, X 0x00, 0x18, 0x80, 0x0c, 0xcf, 0x0b, 0xa5, 0x00, 0x00, 0x60, 0x88, 0x17, X 0xef, 0x07, 0x87, 0x00, 0x00, 0xa0, 0x21, 0x79, 0xc7, 0x55, 0x23, 0x00, X 0x00, 0x90, 0x40, 0x3f, 0xeb, 0x1e, 0x07, 0x00, 0x00, 0x00, 0x40, 0x9f, X 0xef, 0xbc, 0x17, 0x00, 0x00, 0xa4, 0x05, 0x9e, 0x2f, 0x71, 0x06, 0x00, X 0x00, 0x08, 0x00, 0x6f, 0x5f, 0xbc, 0x02, 0x00, 0x00, 0x40, 0xf9, 0x3c, X 0x01, 0xbf, 0x03, 0x00, 0x00, 0x00, 0xac, 0xb3, 0x5f, 0xfd, 0x03, 0x00, X 0x00, 0x00, 0xfc, 0xbb, 0x4f, 0xa7, 0x0b, 0x10, 0x00, 0x00, 0xd7, 0xad, X 0xc2, 0x9a, 0x0d, 0x04, 0x00, 0x40, 0xfb, 0xc9, 0x98, 0x79, 0x11, 0x19, X 0x00, 0xc0, 0xfa, 0x8d, 0x18, 0xcb, 0x3b, 0x02, 0x00, 0x80, 0xdd, 0x0d, X 0x88, 0x0b, 0x5f, 0x08, 0x00, 0xc0, 0x2d, 0x39, 0x60, 0x1b, 0xfa, 0x00, X 0x00, 0xd0, 0x7e, 0x97, 0xc1, 0x73, 0x58, 0x03, 0x00, 0x6b, 0xb1, 0x0e, X 0x01, 0xfb, 0x1c, 0x02, 0x00, 0x80, 0xdf, 0x15, 0x81, 0x54, 0xec, 0x02, X 0x00, 0x00, 0xfe, 0xff, 0xa2, 0xd9, 0x3c, 0x00, 0x00, 0x80, 0x7f, 0xde, X 0xc2, 0xac, 0xb4, 0x02, 0x00, 0x00, 0x33, 0xde, 0xec, 0x0b, 0x3e, 0x02, X 0x00, 0xc0, 0x6c, 0x17, 0xe1, 0xe7, 0xbc, 0x03, 0x00, 0x50, 0x76, 0xfd, X 0xf7, 0xfe, 0xff, 0x00, 0x00, 0x1c, 0x5d, 0x9c, 0xfa, 0xba, 0xe9, 0x00, X 0x00, 0x05, 0x63, 0xcc, 0x0e, 0xec, 0x99, 0x00, 0x00, 0x46, 0x82, 0x94, X 0x80, 0xff, 0x3a, 0x00, 0x80, 0x03, 0xe3, 0xd7, 0x89, 0xcb, 0x27, 0x00, X 0x00, 0x80, 0x21, 0x8f, 0x84, 0xc9, 0x3f, 0x00, 0x00, 0x00, 0x04, 0xff, X 0xcc, 0xdb, 0xe3, 0x01, 0x00, 0xa0, 0x00, 0xa6, 0x7e, 0x0b, 0xb1, 0x07, X 0x00, 0x00, 0x00, 0x19, 0x6f, 0x6e, 0x8e, 0x00, 0x00, 0x00, 0x00, 0x9c, X 0xfa, 0x53, 0x06, 0x02, 0x00, 0x00, 0x00, 0x04, 0xe7, 0xa9, 0x00, 0x06, X 0x00, 0x00, 0x80, 0x43, 0x14, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, X 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x0c, 0x40, 0x00, 0x00, X 0x00, 0x00, 0x40, 0x05, 0x08, 0x20, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00, X 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x03, 0x00, X 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, X 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, X 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x14, 0x00, X 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x30, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00}; *-*-END-of-./fsim/exp.xbm-*-* -- Riley Rainey Internet: riley@mips.com MIPS Computer Systems Phone: +1 214 770-7979 Dallas, Texas dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.