-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+ X for (i = 0; i < particles; ++i) X `7B X path = &paths`5Bi`5D; X toy = path->old_y; X tox = path->old_x; X if (LEGAL_YX(toy, tox)) X mvwaddch(screen, SCR_ADJ(toy), tox, old_chs`5Btoy`5D` V5Btox`5D); X `7D X wrefresh(screen); X `7D X`20 X#if defined(RAND_BSD) Xstatic long lrand48() X`20 X `7B X long random(); X`20 X return random(); X `7D X`20 Xstatic void srand48(seed) X`20 Xlong seed; X`20 X `7B X srandom((int) seed); X `7D X`20 X#define PERIOD (4096 - 1) X`20 Xstatic double drand48() X`20 X `7B X return random() % PERIOD / (double) PERIOD; X `7D X#endif $ CALL UNPACK LAND.C;1 184687562 $ create 'f' Xsys$library:vaxcrtl/share $ CALL UNPACK LAND.OPT;1 1377640302 $ create 'f' X$ if p1 .nes. "C" then goto l1 X$ cc land X$ cc move X$ cc score X$ cc screen X$ l1: X$ link land,move,score,screen,land.opt/opt X$ exit $ CALL UNPACK LAND1.COM;1 1094336625 $ create 'f' X.TH Lander 6l X.SH NAME Xlander \- the arcade game X.SH DESCRIPTION X.I Lander Xis an implementation of the ancient `60`60lunar lander'' arcade Xgame. X.PP XThe object of the game is to gently land a lunar module on Xthe lunar surface. Landing with a vertical velocity greater Xthan 5 metres per second will generally result in fragmentation of the Xlander and loss of cabin pressure! X.PP XScoring is based on which landing pad you choose, how much Xfuel you conserved during landing and the difficulty factor Xof landing from higher entry velocities as the game progresses. X.PP XOperating instructions are provided on the initial screen of X.I lander. XA high score file is maintained. X.SH BUGS XNone known, but please send bug reports to `7Butzoo,utcsri,lsuc`7D!hcr!stace Vy. X.SH AUTHOR XStacey Campbell \- HCR Corporation, Toronto, Canada, 1989. X.SH DISCLAIMER XLander is copyright 1989 by HCR Corporation, Toronto, Ontario, Canada. XPermission to use, copy, modify, and distribute this software and Xits documentation for any purpose and without fee is hereby Xgranted, provided that the above copyright notice appear in all Xcopies. X.PP XHCR Corporation disclaims all warranties with regard to Xthis software. Use at your own risk. $ CALL UNPACK LANDER.6;1 437264703 $ create 'f' X# Lander Makefile X`20 X# System 5.3 X# X# OSV=SYS5_3 X# LIBS= -lcurses -lm X# RAND_L=RAND_SYS5 X`20 X# BSD Unix X# XOSV=BSD XLIBS= -lcurses -ltermcap -lm XRAND_L=RAND_BSD X`20 X# System 5.2 or earlier (untested but should work) X# X# OSV=BSD X# LIBS= -lcurses -lm X# RAND_L=RAND_SYS5 X`20 X# high score file name - change for your system XHSFILE= /usr/games/lib/lander.hs X`20 XOBJS= land.o screen.o move.o score.o XSRC= land.c screen.c move.c score.c XINC= consts.h funcs.h XBIN= $(HOME)/bin XOPT= -O XHSSTRING='"$(HSFILE)"' XCFLAGS= $(OPT) -D$(RAND_L) -DHS_FILE=$(HSSTRING) -D$(OSV) X`20 Xlander: $(OBJS) X cc -o lander $(CFLAGS) $(OBJS) $(LIBS) X`20 X$(OBJS): consts.h X`20 Xshar: X xshar README lander.6 Makefile $(SRC) $(INC) > lander.shar X`20 Xlint: X lint $(CFLAGS) $(SRC) X`20 Xinstall: lander X rm -f $(BIN)/lander X cp lander $(BIN) $ CALL UNPACK MAKEFILE.;1 942420303 $ create 'f' X#ifdef VMS X#include X#else X#include X#endif X#include X#include X#include X#include X#include "consts.h" X#include "funcs.h" X`20 X#if defined(BSD) && ! defined(O_NDELAY) X#define NO_INP -1 X#else X#define NO_INP EOF X#endif X`20 X#define FABS_M(x) ((x) >= -1.0 ? 1.0 : -(x)) X#define FUEL_INIT 5000.0 X#define FUEL_DRAIN 450.0 X#define FUEL_MIN 100.0 X`20 Xdouble Fuel; Xdouble FuelDec = 0.0; X`20 Xstatic double Power; Xstatic double PowerSet`5B`5D = `7B0.0, 0.01, 0.1, 0.5, 1.0, 2.0, 5.0, 10.0, X 15.0, 20.0`7D; Xstatic double att1p, att2p, att3p; X`20 Xvoid InitMoves(screen) X`20 XWINDOW *screen; X`20 X `7B X att1p = 0.0; X att2p = 0.0; X att3p = 0.0; X Power = 0.0; X Fuel = FUEL_INIT - FuelDec; X if (Fuel < FUEL_MIN) X Fuel = FUEL_MIN; X FuelDec += FUEL_DRAIN; X nodelay(screen, TRUE); X `7D X`20 Xvoid GetMove(screen, y_delta, x_delta) X`20 XWINDOW *screen; Xdouble *y_delta, *x_delta; X`20 X `7B X int ch, index; X double y_delta_inc; X`20 X if (Fuel > 0.0) X `7B X wrefresh(screen); X while ((ch = mygetch()) != NO_INP) X `7B X#ifdef BSD X ch &= 0x7F; X#endif X if (isdigit(ch)) X `7B X index = ch - '0'; X Power = PowerSet`5Bindex`5D; X `7D X else X switch (ch) X `7B X case 'z' : X att1p = Power; X break; X case 'x' : X att2p = Power; X break; X case 'c' : X att3p = Power; X break; X default : X flash(); X break; X `7D X `7D X *x_delta += att1p; X y_delta_inc = att2p * (log10(FABS_M(*y_delta)) / GRAVITY); X *y_delta += y_delta_inc; X *x_delta -= att3p; X Fuel -= att3p + att2p + att1p; X if (Fuel < 0.0) X att3p = att2p = att1p = Power = Fuel = 0.0; X `7D X wmove(screen, LINES - 1, 0); X wclrtoeol(screen); X wprintw(screen, X "Thrust - L: %5.2f vert: %7.4f R: %5.2f Pow: %5.2f Fuel: %7.2f", X att1p, att2p, att3p, Power, Fuel); X wrefresh(screen); X `7D X X X X#include X#include X#include X#include X#include X Xstruct `7B /* terminal mode buffers */ X int page_width; X int basic_term; X int ext_term; X `7D modebuf, savemode; X Xint getch_chan = 0; X Xint mygetch() X`7B Xstatic $DESCRIPTOR(tname,"SYS$INPUT"); Xchar c; Xint typeahdcnt; Xint sys$qiow(); X X if (!getch_chan) X `7B sys$assign(&tname,&getch_chan,0,0); X sys$qiow(0,getch_chan,IO$_SENSEMODE,0,0,0,&modebuf,12,0,0,0,0); X savemode = modebuf; X modebuf.basic_term = modebuf.basic_term & `7ETT$M_WRAP; X modebuf.ext_term = modebuf.ext_term & `7ETT2$M_APP_KEYPAD; X sys$qiow(0,getch_chan,IO$_SETMODE,0,0,0,&modebuf,12,0,0,0,0); X `7D X X sys$qiow(0,getch_chan,IO$_SENSEMODE`7CIO$M_TYPEAHDCNT, X 0,0,0,&typeahdcnt,4,0,0,0,0); X typeahdcnt &= 0xffff; X if (!typeahdcnt) return NO_INP; X X sys$qiow(0,getch_chan,IO$_READVBLK `7C IO$M_NOECHO `7C IO$M_NOFILTR, X 0,0,0,&c,1,0,0,0,0); X if (c == EOF) exit(1); X return c; X`7D $ CALL UNPACK MOVE.C;1 1343837115 $ create 'f' XThis is a C implementation of the old `60`60lunar lander'' Xgame seen in amusement arcades in the mid-seventies. X`20 XThis version has been ported to various System 5.3 Xsystems, namely 386/ix and HCR's port of System 5.3 to Xa VAX. It has also been ported to a version of BSD. X`20 XLander utilises some of the nifty SysV.3 curses capabilities Xsuch as line drawing. Anyone using an ANSI compatible Xterminal should see the full effect. Assorted Visual Xterminals will give the same results with a decent terminfo Xfile. BSD people are stuck with their implementation Xof curses, but it still looks kind of okay. X`20 XLander uses a high score file that is writable by Xall users running the program, please edit the Makefile to Xensure a valid name is used. Lander will attempt to Xcreate the HS file the first time the game is run and Xa successful landing is completed. X`20 XPlease read the copyright info at the bottom of the man page. X`20 X`20 XControlling the Lander X---------------------- X`20 XThe lander is fitted with three rockets; X`20 X /`7E\ X `7C `7C X left -+++- right X `7C X vert. thrust X`20 XPress keys '0' - '9' to set the default power level, Xwhere '0' == no power and '9' == full power. X`20 XPressing 'z' sets the power output of the left rocket Xto the default, this has the effect of pushing the lander Xto the right (if the default power level is > 0). X`20 XPressing 'c' sets the power output of the right rocket Xto the default, this has the effect of pushing the lander Xto the left. X`20 XPressing 'x' sets the vertical thrust of the middle rocket Xto the default level, if this is non zero it will slow the Xrate of descent of the lander. If it sets it to zero the Xlander will drop like a brick! X`20 XWhat's on the Screen X-------------------- X`20 XThe top of the screen reads; X`20 Xalt: X: dY: dX: Score: X`20 X'alt' - is the current altitude from "sea level" in metres X'X' - is how far you have moved horizontally (in meters) X'dY' - is your rate of change of vertical movement, (e.g. -10.0 X means you fell 10 meters in the previous second) X'dX' - is your rate of change of horizonal movement, (e.g. -10.0 X means you moved left 10 metres in the previous second) X'Score' - is your current score. X`20 XAt the bottom of the screen; X`20 XThrust - L: vert: R: pow: Fuel: X`20 X'L' - is thrust from the left rocket (pushes you to the right) X'R' - is thrust from the right rocket (pushes you to the left) X Both 'L' and 'R' alter the 'dX' value. X'vert' - is thrust from the vertical rocket (slows the lander's X rate of descent i.e. alters 'dY') X'pow' - is the default power setting that will be used when you X press 'z', 'x' or 'c' X'Fuel' - the amount of fuel left, when this reaches zero all thrust X from rockets ceases. X`20 XThe two rules for landing are; X 1. Try to get dY >= -5 metres per second, anything faster X than -5 will cause the lander to explode. X 2. Make sure you are landing on a pad. X XVMS notes (inserted 06/21/92 - WWB): X X1) Before compiling, change the constant HS_FILE in CONSTS.H to where the X score file will reside. X X2) Before running, create a blank score file with the name given by HS_FILE. $ CALL UNPACK README.;1 1162937075 $ create 'f' X#include X#include X#include "consts.h" X#include "funcs.h" X`20 X#define HEADER "Scores" X#define NAME_LEN 20 X#define HS_ENTRIES 10 X#define SC_WIN_LEN 16 X#define SPC_LINE (SC_WIN_LEN - 2) X`20 Xtypedef struct score_pad_t `7B X int y; X int start_x; X int end_x; X `7D score_pad_t; Xtypedef struct score_t `7B X int score; X char name`5BNAME_LEN`5D; X `7D score_t; X`20 Xextern double Fuel; Xextern int PadScore`5B`5D; Xextern int BSLandings, Landings; Xextern char *Template`5B`5D; Xextern int LastLegalY, LastLegalX; X Xscore_pad_t ScorePad`5BMAX_PADS`5D; Xint Score; Xint BestScore = 0; X`20 Xstatic char *HSFile = HS_FILE; Xstatic int TotalPads; X`20 Xvoid ScDisplayErr(); Xint ScCmp(); X`20 Xvoid ScReadDisplay(back_win) X`20 XWINDOW *back_win; X`20 X `7B X int old_y, old_x, items, i; X WINDOW *score_win; X FILE *fp; X score_t score_pad`5BHS_ENTRIES`5D; X`20 X if ((fp = fopen(HSFile, "r")) == NULL) X `7B X ScDisplayErr(back_win, "Unable to display HS file."); X`09 fclose(fp); X return; X `7D X getyx(back_win, old_y, old_x); X wmove(back_win, 0, 0); X wrefresh(back_win); X score_win = newwin(SC_WIN_LEN, 25, 2, 5); X werase(score_win); X box(score_win, 0, 0); X items = fread((char *)score_pad, sizeof(score_t), HS_ENTRIES, fp); X fclose(fp); X if (items == 0) X `7B X mvwaddstr(score_win, 5, 1, "HS file empty."); X PressSpace(back_win, old_y, old_x, score_win, SPC_LINE, 1); X return; X `7D X mvwaddstr(score_win, 1, (25 - sizeof(HEADER)) / 2, HEADER); X wrefresh(score_win); X for (i = 0; i < items; ++i) X `7B X wmove(score_win, 3 + i, 1); X wprintw(score_win, "%4d %s", score_pad`5Bi`5D.score, X score_pad`5Bi`5D.name); X `7D X PressSpace(back_win, old_y, old_x, score_win, SPC_LINE, 1); X `7D X`20 Xvoid ScWrite(back_win) X`20 XWINDOW *back_win; X`20 X `7B X int items; X FILE *fp; X char *user; X score_t score_pad`5BHS_ENTRIES + 1`5D; X void qsort(); X char *getenv(); X`20 X if (Score == 0) X return; X if ((fp = fopen(HSFile, "r")) == NULL) X `7B X ScDisplayErr(back_win, "Unable to read HS file."); X ScDisplayErr(back_win, "Attempting to create HS file."); X if (creat(HSFile, 0777) == -1) X `7B X ScDisplayErr(back_win, X "Unable to create HS file, check pathname."); X`09`09 fclose(fp); X return; X `7D X `7D X fclose(fp); X if ((fp = fopen(HSFile, "r")) == NULL) X `7B X ScDisplayErr(back_win, "Unable to read new HS file."); X`09 fclose(fp); X return; X `7D X items = fread((char *)score_pad, sizeof(score_t), HS_ENTRIES, fp); X fclose(fp); X if ((user = getenv("USER")) == NULL) X `7B X ScDisplayErr(back_win, "Environment var USER must be set"); X return; X `7D X strcpy(score_pad`5Bitems`5D.name, user); +-+-+-+-+-+-+-+- END OF PART 2 +-+-+-+-+-+-+-+-