mikew@wyse.wyse.com (Mike Wexler) (09/08/88)
Submitted-by: dana@thumper.bellcore.com (Dana A. Chee) Posting-number: Volume 1, Issue 18 Archive-name: xmille/part01 #! /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 1 (of 3)." # Contents: AUTHOR CHANGES MANIFEST Makefile README animate.c # background.h card.h cards color.h control end.c extern.c init.c # mille.c mille.h misc.c move.c patchlevel.h print.c roll.c save.c # table.c types.c ui.h varpush.c xmille.6 # Wrapped by mikew@x2 on Wed Sep 7 10:48:15 1988 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f AUTHOR -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"AUTHOR\" else echo shar: Extracting \"AUTHOR\" \(885 characters\) sed "s/^X//" >AUTHOR <<'END_OF_AUTHOR' X(Message inbox:101) XReturn-Path: dana@thumper.bellcore.com XReceived: from wyse by x2.wyse.com (5.58/Wyse client/5-13-88) X id AA00930; Tue, 16 Aug 88 06:00:24 PDT XReceived: by wyse.wyse.com (5.58/Wyse master/5-13-88) X id AA08304; Tue, 16 Aug 88 05:57:03 PDT XReceived: from thumper.bellcore.com by uunet.UU.NET (5.59/1.14) X id AA06360; Tue, 16 Aug 88 08:01:25 EDT XReceived: by thumper.bellcore.com (5.54/4.7) X id AA03992; Tue, 16 Aug 88 07:59:14 EDT XReceived: by dino.bellcore.com (4.12/4.7) X id AA01238; Tue, 16 Aug 88 07:58:10 edt XDate: Tue, 16 Aug 88 07:58:10 edt XFrom: dana@thumper.bellcore.com (Dana A. Chee) XMessage-Id: <8808161158.AA01238@dino.bellcore.com> XTo: mikew@wyse.wyse.com XSubject: xmille game for comp.sources.x X Xfollowing this message are the 18 shar files that make up the xmille Xgame. X X Dana Chee X Bellcore X MRE 2Q-250 X (201) 829-4488 X dana@bellcore.com END_OF_AUTHOR if test 885 -ne `wc -c <AUTHOR`; then echo shar: \"AUTHOR\" unpacked with wrong size! fi # end of overwriting check fi if test -f CHANGES -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"CHANGES\" else echo shar: Extracting \"CHANGES\" \(900 characters\) sed "s/^X//" >CHANGES <<'END_OF_CHANGES' X7/9/87 X Dave Lemke X lemke@sun.com X X Modified so that it works on B&W as well as color displays. X X Changed 'stop' and 'go' cards to be labeled. X X Fixed roll.c to work on Suns. X X Modified cardlib so the makfile would work properly on Suns, X which have a new feature (by at least OS 3.3) that builds X foo if foo.c exists. therefore rules of the form: X ace.o: ace ace_mask ace.c X which should create ace.o from ace.c, which includes ace and X ace_mask, first builds ace from ace.c (with cc -o ace ace.c). X this of course trashes the ace bitmap. solution was to name X change all the bitmap files so there wouldn't be a corresponding X .c file. there may be an easier way, but i don't know it. X X7/12/88 X Dana Chee X dana@bellcore.com X X Converted X10 version to run under X11. X X Animated mode no longer works correctly. X X The X10 fonts timrom12 and timrom12b are used, and their .bdf X files are included. END_OF_CHANGES if test 900 -ne `wc -c <CHANGES`; then echo shar: \"CHANGES\" unpacked with wrong size! fi # end of overwriting check fi if test -f MANIFEST -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"MANIFEST\" else echo shar: Extracting \"MANIFEST\" \(3878 characters\) sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST' X File Name Archive # Description X----------------------------------------------------------- X CHANGES 1 X MANIFEST 1 X Makefile 1 X README 1 X animate.c 2 X background.h 1 X card.h 1 X cards 1 X cards/100.c 1 X cards/200.c 1 X cards/25.c 1 X cards/50.c 1 X cards/75.c 1 X cards/Makefile 1 X cards/_100 5 X cards/_200 6 X cards/_25 4 X cards/_50 3 X cards/_75 4 X cards/_accident 11 X cards/_ace 4 X cards/_blank 7 X cards/_end 4 X cards/_extra 7 X cards/_flat 6 X cards/_gas 5 X cards/_go 3 X cards/_out 5 X cards/_puncture 11 X cards/_repairs 8 X cards/_right 7 X cards/_spare 7 X cards/_speed 8 X cards/_stop 6 X cards/accident.c 1 X cards/accident_both 16 X cards/accident_mask 16 X cards/ace.c 1 X cards/ace_both 9 X cards/ace_mask 9 X cards/background.h 1 X cards/blank.c 1 X cards/color.h 1 X cards/deck.c 1 X cards/deck_blue 12 X cards/deck_both 12 X cards/deck_mask 11 X cards/deck_red 9 X cards/display.c 2 X cards/end.c 1 X cards/end_both 10 X cards/end_mask 10 X cards/extra.c 1 X cards/extra_both 13 X cards/extra_mask 13 X cards/fill 5 X cards/flat.c 1 X cards/flat_both 12 X cards/flat_mask 11 X cards/gas.c 1 X cards/gas_mask 9 X cards/go.c 1 X cards/go_mask 8 X cards/makefile 1 X cards/miles 8 X cards/miles_both 13 X cards/miles_mask 13 X cards/out.c 1 X cards/out.h 1 X cards/out_both 10 X cards/out_mask 10 X cards/outline 6 X cards/puncture.c 1 X cards/puncture_both 16 X cards/puncture_mask 16 X cards/repairs.c 1 X cards/repairs_both 15 X cards/repairs_mask 15 X cards/right.c 1 X cards/right_both 14 X cards/right_mask 14 X cards/spare.c 1 X cards/spare_both 15 X cards/spare_mask 14 X cards/speed.c 1 X cards/speed_both 14 X cards/speed_mask 15 X cards/stop.c 1 X cards/stop_mask 12 X color.h 1 X comp.c 2 X control 1 X control/Makefile 1 X control/affirm.c 1 X control/button.c 2 X control/co_class.h 1 X control/control.h 1 X control/dispatch.c 1 X control/init.c 1 X control/prompted.c 2 X control/scrollbar.c 17 X curses_ui.c 3 X drawcard.c 2 X end.c 1 X extern.c 1 X fill 3 X init.c 1 X mille.c 1 X mille.h 1 X misc.c 1 X move.c 2 X print.c 1 X roll.c 1 X save.c 1 X table.c 1 X timrom12.bdf 17 X timrom12b.bdf 18 X types.c 1 X ui.c 17 X ui.h 1 X varpush.c 1 X xmille.6 1 END_OF_MANIFEST if test 3878 -ne `wc -c <MANIFEST`; then echo shar: \"MANIFEST\" unpacked with wrong size! fi # end of overwriting check fi if test -f Makefile -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"Makefile\" else echo shar: Extracting \"Makefile\" \(2121 characters\) sed "s/^X//" >Makefile <<'END_OF_Makefile' X# @(#)Makefile 1.2 ULTRIX 6/29/84 X# X# mille bourne game makefile X# X# @(#)Makefile 1.7 (Berkeley) 8/14/83 X# XDESTROOT= XHEADERS=mille.h XCFILES= comp.c end.c extern.c init.c mille.c misc.c move.c print.c \ X roll.c save.c types.c varpush.c ui.c drawcard.c animate.c XOBJS= comp.o end.o extern.o init.o mille.o misc.o move.o print.o \ X roll.o save.o types.o varpush.o ui.o drawcard.o animate.o XPOBJS= comp.po end.po extern.po init.po mille.po misc.po move.po \ X roll.po print.po save.po types.po varpush.po ui.po drawcard.po \ X animate.po XCRL= XL= control/control.a cards/cardlib.a -lX11 -lm XLIBS= ${CRL} ${L} XDEFS= XCFLAGS= -g ${DEFS} -I/usr/new/usr/include -L/usr/new/usr/lib X# CFLAGS= -g ${DEFS} -I/usr/local/pkg/X11/include -L/usr/local/pkg/X11/lib XBINDIR= ${DESTROOT}/usr/games X.SUFFIXES: .po .i X.PRECIOUS: cards/cardlib.a control/control.a X X.c.po: X rm -f x.c ; ln $*.c x.c X ${CC} ${CFLAGS} -p -c x.c X mv x.o $*.po X X.c.i: X ${CC} ${CFLAGS} -P $*.c X Xxmille: ${OBJS} ${CRL} control/control.a cards/cardlib.a X ${CC} -o $@ ${CFLAGS} ${OBJS} ${LIBS} X Xmille: ${OBJS} ${CRL} X ${CC} ${CFLAGS} -o mille ${OBJS} ${LIBS} X Xcontrol/control.a: always X cd control; make control.a X Xcards/cardlib.a: always X cd cards; make cardlib.a X Xalways: X Xinstall: mille X install -c -s mille ${BINDIR} X Xpmb: ${POBJS} ../pcrlib X ${CC} ${CFLAGS} -p -o pmb ${POBJS} ../pcrlib -ltermlib X Xmille.po: mille.c X rm -f x.c ; ln mille.c x.c X ${CC} ${CFLAGS} -DPROF -p -c x.c X mv x.o mille.po X Xtable: table.o extern.o X ${CC} ${CFLAGS} -i -o table table.o extern.o X Xanimate.o ui.o: ui.h X Xreaddump: readdump.o extern.o varpush.o X ${CC} ${CFLAGS} -i -o readdump readdump.o extern.o varpush.o X Xctags: X ctags ${HEADERS} ${CFILES} X ed - tags < :ctfix X sort tags -o tags X Xlint: X lint -hxb ${DEFS} ${CFILES} ${L} > lint.out X Xmille.ar: X ar ruv mille.ar Makefile tags ${HEADERS} ${CFILES} X Xtar: X tar rvf /dev/rmt0 Makefile tags :ctfix ${HEADERS} ${CFILES} X Xlpr: X pr Makefile ${HEADERS} ${CFILES} tags | lpr ; lpq X Xclean: X rm -f ${OBJS} ${POBJS} core ? a.out mille X Xclobber: clean X rm -f *.[ch] Makefile X Xsccsinfo: X sccs info X Xsccsget: X sccs get SCCS X X.DEFAULT: X sccs get $< END_OF_Makefile if test 2121 -ne `wc -c <Makefile`; then echo shar: \"Makefile\" unpacked with wrong size! fi # end of overwriting check fi if test -f README -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"README\" else echo shar: Extracting \"README\" \(736 characters\) sed "s/^X//" >README <<'END_OF_README' XNotes on porting xmille: X X The bitmaps in 'cards' are set up for a color display, they probably Xwill not be readable in monocrome without a bit of editing. Also, the Xcard display routines insist on color, so those will need fixing as well. X X The major porting headache of mille is roll.c. You'll probably Xhave to fix it for your machine, it's terrible now -- but that's what came Xwith it and it works on *my* machine... X X I'll cheerfully accept bug reports in xmille, and may even be Xwilling to maintain a current version; but I wash my hands of this mess by Xputting it into the public domain, I don't care what you do with it. X X May 28, 1987 X X keith packard X X keithp@copper.tek.com (at least for now) X X reed!dinadan!keith (at home) X END_OF_README if test 736 -ne `wc -c <README`; then echo shar: \"README\" unpacked with wrong size! fi # end of overwriting check fi if test -f animate.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"animate.c\" else echo shar: Extracting \"animate.c\" \(4801 characters\) sed "s/^X//" >animate.c <<'END_OF_animate.c' X/* X * animation X */ X X# include "mille.h" X# include "ui.h" X# include "card.h" X# include <math.h> X Xextern int iscolor; X Xanimate_move (player, orig_type, orig_arg, dest_type, dest_arg) X{ X#if 0 X int ox, oy, dx, dy; X X compute_position (player, orig_type, orig_arg, &ox, &oy); X compute_position (player, dest_type, dest_arg, &dx, &dy); X do_animate (ox, oy, dx, dy); X#endif X} X X# define abs(x) ((x) < 0 ? -(x) : (x)) X X# define SPEED_FACTOR (2.5) X# define accerate(v,r) ((v) + (0.1 * (r))) X Xstatic Xdo_animate (ox, oy, dx, dy) X{ X double x, y; X double xc, yc; X int xd, yd; X int xp, yp; X int x1, y1, x2, y2, x3, y3, x4, y4; X int ix, iy; X double dist; X double rx, ry; X X x = ox; X y = oy; X xd = dx - ox; X yd = dy - oy; X dist = sqrt ((double) xd * xd + yd * yd); X rx = (double) xd / dist; X ry = (double) yd / dist; X xc = SPEED_FACTOR * rx; X yc = SPEED_FACTOR * ry; X xp = yp = -32767; X XFlush (dpy); X while (abs(dx - x) > abs (xc) || abs(dy - y) > abs (yc)) { X ix = x; X iy = y; X if (xp == -32767) X draw_square (ix, iy, ix + WIDTH, iy + HEIGHT); X else { X if (xp < ix) { X x1 = xp + WIDTH; X x2 = ix + WIDTH; X x3 = ix; X x4 = ix + WIDTH; X } else if (xp > ix) { X x1 = ix; X x2 = xp; X x3 = ix; X x4 = ix + WIDTH; X } else { X x1 = -32767; X x2 = -32767; X x3 = ix; X x4 = ix + WIDTH; X } X if (yp < iy) { X y1 = iy; X y2 = yp + HEIGHT; X y3 = yp + HEIGHT; X y4 = iy + HEIGHT; X } else if (yp > iy) { X y1 = yp; X y2 = iy + HEIGHT; X y3 = iy; X y4 = yp; X } else { X y1 = iy; X y2 = iy + HEIGHT; X y3 = -32767; X y4 = -32767; X } X if (x1 != -32767 && y1 != -32767) X draw_square (x1, y1, x2, y2); X if (x3 != -32767 && y3 != -32767) X draw_square (x3, y3, x4, y4); X if (ix < xp) { X x1 = ix + WIDTH; X x2 = xp + WIDTH; X x3 = xp; X x4 = xp + WIDTH; X } else if (ix > xp) { X x1 = xp; X x2 = ix; X x3 = xp; X x4 = xp + WIDTH; X } else { X x1 = -32767; X x2 = -32767; X x3 = xp; X x4 = xp + WIDTH; X } X if (iy < yp) { X y1 = yp; X y2 = iy + HEIGHT; X y3 = iy + HEIGHT; X y4 = yp + HEIGHT; X } else if (iy > yp) { X y1 = iy; X y2 = yp + HEIGHT; X y3 = yp; X y4 = iy; X } else { X y1 = yp; X y2 = yp + HEIGHT; X y3 = -32767; X y4 = -32767; X } X if (x1 != -32767 && y1 != -32767) X draw_square (x1, y1, x2, y2); X if (x3 != -32767 && y3 != -32767) X draw_square (x3, y3, x4, y4); X } X xp = ix; X yp = iy; X if (abs (dx - x) > xc) X x += xc; X if (abs (dy - y) > yc) X y += yc; X xc = accerate(xc, rx); X yc = accerate(yc, ry); X } X draw_square (xp, yp, xp+WIDTH, yp+HEIGHT); X XFlush (dpy); X} X Xstatic Xdraw_square (x1, y1, x2, y2) X{ X XSetFunction(dpy, cheap_gc, GXxor); X XSetFillStyle(dpy, cheap_gc, FillSolid); X if (iscolor) X XSetForeground(dpy, cheap_gc, X BlackPixel(dpy, DefaultScreen(dpy))); X else X XSetForeground(dpy, cheap_gc, X WhitePixel(dpy, DefaultScreen(dpy))); X XFillRectangle (dpy, xwindow, cheap_gc, x1, y1, x2-x1, y2-y1); X} X Xstatic Xcompute_position (player, type, arg, xp, yp) Xint *xp, *yp; X{ X switch (type) { X case ANIMATE_HAND: X switch (player) { X case 0: X *xp = HUM_HAND_X + (WIDTH + PAD_CARD) * arg; X *yp = HUM_HAND_Y; X break; X case 1: X *xp = COMP_HAND_X + (WIDTH + PAD_CARD) * arg; X *yp = COMP_HAND_Y; X break; X } X break; X case ANIMATE_DECK: X *xp = DECK_X; X *yp = DECK_Y; X break; X case ANIMATE_DISC: X *xp = DISCARD_X; X *yp = DISCARD_Y; X break; X case ANIMATE_MILES: X switch (player) { X case 0: X *xp = HUM_PLAY_X + (WIDTH + PAD_CARD) * (2 + C_200 - arg); X *yp = HUM_PLAY_Y; X break; X case 1: X *xp = COMP_PLAY_X + (WIDTH + PAD_CARD) * (2 + C_200 - arg); X *yp = COMP_PLAY_Y; X break; X } X break; X case ANIMATE_BATTLE: X switch (player) { X case 0: X *xp = HUM_PLAY_X + WIDTH + PAD_CARD; X *yp = HUM_PLAY_Y; X break; X case 1: X *xp = COMP_PLAY_X + WIDTH + PAD_CARD; X *yp = COMP_PLAY_Y; X break; X } X break; X case ANIMATE_SPEED: X switch (player) { X case 0: X *xp = HUM_PLAY_X; X *yp = HUM_PLAY_Y; X break; X case 1: X *xp = COMP_PLAY_X; X *yp = COMP_PLAY_Y; X break; X } X break; X case ANIMATE_OBATTLE: X switch (1-player) { X case 0: X *xp = HUM_PLAY_X + WIDTH + PAD_CARD; X *yp = HUM_PLAY_Y; X break; X case 1: X *xp = COMP_PLAY_X + WIDTH + PAD_CARD; X *yp = COMP_PLAY_Y; X break; X } X break; X case ANIMATE_OSPEED: X switch (1-player) { X case 0: X *xp = HUM_PLAY_X; X *yp = HUM_PLAY_Y; X break; X case 1: X *xp = COMP_PLAY_X; X *yp = COMP_PLAY_Y; X break; X } X break; X case ANIMATE_SAFETY: X switch (player) { X case 0: X *xp = HUM_SAFE_X + safety_offsets[arg - S_CONV].x; X *yp = HUM_SAFE_Y + safety_offsets[arg - S_CONV].y; X break; X case 1: X *xp = COMP_SAFE_X + safety_offsets[arg - S_CONV].x; X *yp = COMP_SAFE_Y + safety_offsets[arg - S_CONV].y; X break; X } X break; X } X} END_OF_animate.c if test 4801 -ne `wc -c <animate.c`; then echo shar: \"animate.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f background.h -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"background.h\" else echo shar: Extracting \"background.h\" \(17 characters\) sed "s/^X//" >background.h <<'END_OF_background.h' X# include "fill" END_OF_background.h if test 17 -ne `wc -c <background.h`; then echo shar: \"background.h\" unpacked with wrong size! fi # end of overwriting check fi if test -f card.h -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"card.h\" else echo shar: Extracting \"card.h\" \(39 characters\) sed "s/^X//" >card.h <<'END_OF_card.h' X# define HEIGHT 150 X# define WIDTH 100 END_OF_card.h if test 39 -ne `wc -c <card.h`; then echo shar: \"card.h\" unpacked with wrong size! fi # end of overwriting check fi if test ! -d cards ; then echo shar: Creating directory \"cards\" mkdir cards fi if test -f color.h -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"color.h\" else echo shar: Extracting \"color.h\" \(299 characters\) sed "s/^X//" >color.h <<'END_OF_color.h' X/* X * color.h X * X * definitions for standard colors X */ X X# define BLACK_COLOR 0 X# define WHITE_COLOR 1 X# define RED_COLOR 2 X# define GREEN_COLOR 3 X# define GREY_COLOR 4 X# define BLUE_COLOR 5 X# define NUM_COLOR 6 X X Xstruct color { X char *name; X int pixel; X}; X Xextern struct color colorMap[NUM_COLOR]; END_OF_color.h if test 299 -ne `wc -c <color.h`; then echo shar: \"color.h\" unpacked with wrong size! fi # end of overwriting check fi if test ! -d control ; then echo shar: Creating directory \"control\" mkdir control fi if test -f end.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"end.c\" else echo shar: Extracting \"end.c\" \(2207 characters\) sed "s/^X//" >end.c <<'END_OF_end.c' X# include "mille.h" X X/* X * @(#)end.c 1.1 (Berkeley) 4/1/82 X */ X X/* X * print out the score as if it was final, and add the totals for X * the end-of-games points to the user who deserves it (if any). X */ Xfinalscore(pp) Xreg PLAY *pp; { X X reg int temp, tot, num; X X num = pp - Player; X for (tot = 4; tot <= 8; tot++) { X InScore (tot, num, " 0 "); X } X if (pp->mileage == End) { X InScore (4, num, " 400 "); X tot = SC_TRIP; X if (pp->nummiles[C_200] == 0) { X InScore (5, num, " 300 "); X tot = SC_TRIP + SC_SAFE; X } X if (Topcard <= Deck) { X InScore (6, num, " 300 "); X tot += SC_DELAY; X } X if (End == 1000) { X InScore (7, num, " 200 "); X tot += SC_EXTENSION; X } X if (Player[other(num)].mileage == 0) { X InScore (8, num, " 500 "); X tot += SC_SHUT_OUT; X } X pp->total += tot; X pp->hand_tot += tot; X } X} X X# ifdef EXTRAP Xstatic int Last_tot[2]; /* last tot used for extrapolate */ X X/* X * print out the score as if it was final, and add the totals for X * the end-of-games points to the user who deserves it (if any). X */ Xextrapolate(pp) Xreg PLAY *pp; { X X reg int x, num, tot, count; X X#ifdef NOTYET X num = pp - Player; X tot += SC_TRIP + SC_DELAY + SC_EXT; X x = num * 6 + 21 + 3; X for (tot = 5; tot <= 9; tot++) X mvaddch(tot, x, '0'); X x -= 2; X pp = &Player[other(num)]; X for (count = 0, tot = 0; tot < NUM_SAFE; tot++) X if (pp->safety[tot] != S_PLAYED) X count += SC_SAFE; X mvprintw(3, x, "%3d", count); X tot += count; X if (count == 400) { X mvaddstr(4, x, "30"); X tot += SC_ALL_SAFE; X } X pp = &Player[num]; X for (count = 0, tot = 0; tot < NUM_SAFE; tot++) X if (pp->safety[tot] != S_PLAYED) X count += SC_COUP / 10; X mvprintw(4, x - 1, "%3d", count); X tot += count; X tot += 1000 - pp->mileage; X mvaddstr(5, x, "40"); X mvaddstr(7, x, "30"); X mvaddstr(8, x, "20"); X if (pp->nummiles[C_200] == 0) { X mvaddstr(6, x, "30"); X tot = SC_TRIP + SC_SAFE; X } X if (Player[other(num)].mileage == 0) { X mvaddstr(9, x, "50"); X tot += SC_SHUT_OUT; X } X pp->total += tot; X pp->hand_tot += tot; X Last_tot[num] = tot; X#endif X} X Xundoex() { X X reg PLAY *pp; X reg int i; X X i = 0; X for (pp = Player; pp < &Player[2]; pp++) { X pp->total -= Last_tot[i]; X pp->hand_tot -= Last_tot[i++]; X } X} X# endif END_OF_end.c if test 2207 -ne `wc -c <end.c`; then echo shar: \"end.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f extern.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"extern.c\" else echo shar: Extracting \"extern.c\" \(2988 characters\) sed "s/^X//" >extern.c <<'END_OF_extern.c' X# include "mille.h" X X/* X * @(#)extern.c 1.1 (Berkeley) 4/1/82 X */ X Xbool Debug, /* set if debugging code on */ X Finished, /* set if current hand is finished */ X Next, /* set if changing players */ X On_exit, /* set if game saved on exiting */ X Order, /* set if hand should be sorted */ X Saved; /* set if game just saved */ X Xchar *Fromfile = NULL; /* startup file for game */ X Xint Card_no, /* Card number for current move */ X End, /* End value for current hand */ X Handstart = COMP, /* Player who starts hand */ X Movetype, /* Current move type */ X Play, /* Current player */ X Numgos, /* Number of Go cards used by computer */ X WIndow = W_SMALL, /* Current window wanted */ X Numseen[NUM_CARDS], /* Number of cards seen in current hand */ X Value[NUM_MILES] = { /* Value of mileage cards */ X 25, 50, 75, 100, 200 X }, X Numcards[NUM_CARDS] = { /* Number of cards in deck */ X 10, /* C_25 */ X 10, /* C_50 */ X 10, /* C_75 */ X 12, /* C_100 */ X 4, /* C_200 */ X 2, /* C_EMPTY */ X 2, /* C_FLAT */ X 2, /* C_CRASH */ X 4, /* C_STOP */ X 3, /* C_LIMIT */ X 6, /* C_GAS */ X 6, /* C_SPARE */ X 6, /* C_REPAIRS */ X 14, /* C_GO */ X 6, /* C_END_LIMIT */ X 1, /* C_GAS_SAFE */ X 1, /* C_SPARE_SAFE */ X 1, /* C_DRIVE_SAFE */ X 1, /* C_RIGHT_WAY */ X 0 /* C_INIT */ X }; X Numneed[NUM_CARDS] = { /* number of cards needed per hand */ X 0, /* C_25 */ X 0, /* C_50 */ X 0, /* C_75 */ X 0, /* C_100 */ X 0, /* C_200 */ X 2, /* C_EMPTY */ X 2, /* C_FLAT */ X 2, /* C_CRASH */ X 4, /* C_STOP */ X 3, /* C_LIMIT */ X 2, /* C_GAS */ X 2, /* C_SPARE */ X 2, /* C_REPAIRS */ X 10, /* C_GO */ X 3, /* C_END_LIMIT */ X 1, /* C_GAS_SAFE */ X 1, /* C_SPARE_SAFE */ X 1, /* C_DRIVE_SAFE */ X 1, /* C_RIGHT_WAY */ X 0 /* C_INIT */ X }; X XCARD Discard, /* Top of discard pile */ X *Topcard, /* Pointer to next card to be picked */ X Opposite[NUM_CARDS] = { /* Opposites of each card */ X C_25, C_50, C_75, C_100, C_200, C_GAS, C_SPARE, X C_REPAIRS, C_GO, C_END_LIMIT, C_EMPTY, C_FLAT, C_CRASH, X C_STOP, C_LIMIT, C_EMPTY, C_FLAT, C_CRASH, C_STOP, C_INIT X }, X Deck[DECK_SZ] = { /* Current deck */ X C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25, X C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50, X C_75, C_75, C_75, C_75, C_75, C_75, C_75, C_75, C_75, C_75, X C_100, C_100, C_100, C_100, C_100, C_100, C_100, C_100, C_100, X C_100, C_100, C_100, X C_200, C_200, C_200, C_200, X C_EMPTY, C_EMPTY, X C_FLAT, C_FLAT, X C_CRASH, C_CRASH, X C_STOP, C_STOP, C_STOP, C_STOP, X C_LIMIT, C_LIMIT, C_LIMIT, X C_GAS, C_GAS, C_GAS, C_GAS, C_GAS, C_GAS, X C_SPARE, C_SPARE, C_SPARE, C_SPARE, C_SPARE, C_SPARE, X C_REPAIRS, C_REPAIRS, C_REPAIRS, C_REPAIRS, C_REPAIRS, X C_REPAIRS, X C_END_LIMIT, C_END_LIMIT, C_END_LIMIT, C_END_LIMIT, C_END_LIMIT, X C_END_LIMIT, X C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, X C_GO, C_GO, C_GO, C_GO, X C_GAS_SAFE, C_SPARE_SAFE, C_DRIVE_SAFE, C_RIGHT_WAY X }; X XFILE *outf; X XPLAY Player[2]; /* Player descriptions */ END_OF_extern.c if test 2988 -ne `wc -c <extern.c`; then echo shar: \"extern.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f init.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"init.c\" else echo shar: Extracting \"init.c\" \(1198 characters\) sed "s/^X//" >init.c <<'END_OF_init.c' X# include "mille.h" X X/* X * @(#)init.c 1.1 (Berkeley) 4/1/82 X */ X Xinit() { X X reg PLAY *pp; X reg int i, j; X reg CARD card; X X for (j = 0; j < C_RIGHT_WAY; j++) X Numseen[j] = 0; X Numgos = 0; X X for (i = 0; i < 2; i++) { X pp = &Player[i]; X pp->hand[0] = C_INIT; X for (j = 0; j < NUM_SAFE; j++) { X pp->safety[j] = S_UNKNOWN; X pp->coups[j] = FALSE; X } X for (j = 1; j < HAND_SZ; j++) { X pp->hand[j] = *--Topcard; X if (i == COMP) { X account(card = *Topcard); X if (issafety(card)) X pp->safety[card - S_CONV] = S_IN_HAND; X } X } X pp->mileage = 0; X pp->hand_tot = 0; X pp->safescore = 0; X pp->coupscore = 0; X pp->can_go = FALSE; X pp->speed = C_INIT; X pp->battle = C_INIT; X pp->new_speed = FALSE; X pp->new_battle = FALSE; X for (j = 0; j < NUM_MILES; j++) X pp->nummiles[j] = 0; X } X if (Order) X sort(Player[PLAYER].hand); X Discard = C_INIT; X Finished = FALSE; X End = 700; X} X Xshuffle() { X X reg int i, r; X reg CARD temp; X X for (i = 0; i < DECK_SZ; i++) { X r = roll(1, DECK_SZ) - 1; X if (r < 0 || r > DECK_SZ - 1) { X fprintf(stderr, "shuffle: card no. error: %d\n", r); X die(); X } X temp = Deck[r]; X Deck[r] = Deck[i]; X Deck[i] = temp; X } X Topcard = &Deck[DECK_SZ]; X} END_OF_init.c if test 1198 -ne `wc -c <init.c`; then echo shar: \"init.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f mille.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"mille.c\" else echo shar: Extracting \"mille.c\" \(1936 characters\) sed "s/^X//" >mille.c <<'END_OF_mille.c' X# include "mille.h" X# include <signal.h> X# ifdef attron X# include <term.h> X# endif attron X X/* X * @(#)mille.c 1.3 (Berkeley) 5/10/83 X */ X Xint rub(); X Xchar _sobuf[BUFSIZ]; X Xmain(ac, av) Xreg int ac; Xreg char *av[]; { X X reg bool restore; X double avs[3]; X X if (strcmp(av[0], "a.out") == 0) { X outf = fopen("q", "w"); X setbuf(outf, 0); X Debug = TRUE; X } X restore = FALSE; X# ifdef pdp11 X if (geteuid() != ARNOLD) { X loadav(avs); X if (avs[2] > 9.0) { X printf("Sorry. The load average is too high.\n"); X printf("Please try again later\n"); X exit(1); X } X } X# endif X switch (ac) { X case 2: X rest_f(av[1]); X restore = TRUE; X case 1: X break; X default: X printf("usage: milles [ restore_file ]\n"); X exit(-1); X /* NOTREACHED */ X } X setbuf(stdout, _sobuf); X Play = PLAYER; X init_ui (); X# ifndef PROF X#ifdef sun X srandom(getpid()); X#else X srand(getpid()); X#endif X# else X srand(0); X# endif X signal(SIGINT, rub); X for (;;) { X if (!restore || (Player[PLAYER].total >= 5000 X || Player[COMP].total >= 5000)) { X if (Player[COMP].total < Player[PLAYER].total) X Player[PLAYER].games++; X else if (Player[COMP].total > Player[PLAYER].total) X Player[COMP].games++; X Player[COMP].total = 0; X Player[PLAYER].total = 0; X } X do { X if (!restore) X Handstart = Play = other(Handstart); X if (!restore || On_exit) { X shuffle(); X init(); X } X newboard(); X if (restore) X Error (Initstr); X prboard(); X do { X domove(); X if (Finished) X newscore(); X prboard(); X } while (!Finished); X check_more(); X restore = On_exit = FALSE; X } while (Player[COMP].total < 5000 X && Player[PLAYER].total < 5000); X } X} X X/* X * Routine to trap rubouts, and make sure they really want to X * quit. X */ Xrub() { X X signal(SIGINT, 1); X if (getyn("Really? ")) X die(); X signal(SIGINT, rub); X} X X/* X * Time to go beddy-by X */ Xdie() { X X signal(SIGINT, 1); X if (outf) X fflush(outf); X finish_ui (); X exit(1); X} END_OF_mille.c if test 1936 -ne `wc -c <mille.c`; then echo shar: \"mille.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f mille.h -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"mille.h\" else echo shar: Extracting \"mille.h\" \(3206 characters\) sed "s/^X//" >mille.h <<'END_OF_mille.h' X# include <ctype.h> X# include <stdio.h> X Xtypedef char bool; X# define reg register X# define TRUE 1 X# define FALSE 0 X X/* X * @(#)mille.h 1.1 (Berkeley) 4/1/82 X */ X X/* X * Miscellaneous constants X */ X X# define unsgn unsigned X# define CARD short X X# ifdef vax X# define ARNOLD 78 /* my uid */ X# else X# define ARNOLD 24601 /* my uid */ X# endif X X# define GURP 28672 /* bad uid */ X# define MAXUSERS 35 /* max # of users for startup */ X# define HAND_SZ 7 /* number of cards in a hand */ X# define DECK_SZ 101 /* number of cards in decks */ X# define NUM_SAFE 4 /* number of saftey cards */ X# define NUM_MILES 5 /* number of milestones types */ X# define NUM_CARDS 20 /* number of types of cards */ X X# define PLAYER 0 X# define COMP 1 X X# define W_SMALL 0 /* Small (initial) window */ X# define W_FULL 1 /* Full (final) window */ X X/* X * Move types X */ X X# define M_DISCARD 0 X# define M_DRAW 1 X# define M_PLAY 2 X# define M_ORDER 3 X# define M_REASONABLE 4 X X/* X * Scores X */ X X# define SC_SAFETY 100 X# define SC_ALL_SAFE 300 X# define SC_COUP 300 X# define SC_TRIP 400 X# define SC_SAFE 300 X# define SC_DELAY 300 X# define SC_EXTENSION 200 X# define SC_SHUT_OUT 500 X X/* X * safety descriptions X */ X X# define S_UNKNOWN 0 /* location of safety unknown */ X# define S_IN_HAND 1 /* safety in player's hand */ X# define S_PLAYED 2 /* safety has been played */ X# define S_GAS_SAFE 0 /* Gas safety card index */ X# define S_SPARE_SAFE 1 /* Tire safety card index */ X# define S_DRIVE_SAFE 2 /* Driveing safety card index */ X# define S_RIGHT_WAY 3 /* Right-of-Way card index */ X# define S_CONV 15 /* conversion from C_ to S_ */ X X/* X * card numbers X */ X X# define C_INIT -1 X# define C_25 0 X# define C_50 1 X# define C_75 2 X# define C_100 3 X# define C_200 4 X# define C_EMPTY 5 X# define C_FLAT 6 X# define C_CRASH 7 X# define C_STOP 8 X# define C_LIMIT 9 X# define C_GAS 10 X# define C_SPARE 11 X# define C_REPAIRS 12 X# define C_GO 13 X# define C_END_LIMIT 14 X# define C_GAS_SAFE 15 X# define C_SPARE_SAFE 16 X# define C_DRIVE_SAFE 17 X# define C_RIGHT_WAY 18 X Xtypedef struct { X bool coups[NUM_SAFE]; X bool can_go; X bool new_battle; X bool new_speed; X short safety[NUM_SAFE]; X short nummiles[NUM_MILES]; X CARD hand[HAND_SZ]; X CARD battle; X CARD speed; X int mileage; X int hand_tot; X int safescore; X int coupscore; X int total; X int games; X} PLAY; X X/* X * animation constants X */ X X# define ANIMATE X# define ANIMATE_HAND 0 X# define ANIMATE_DECK 1 X# define ANIMATE_DISC 2 X# define ANIMATE_MILES 3 X# define ANIMATE_BATTLE 4 X# define ANIMATE_SPEED 5 X# define ANIMATE_OBATTLE 6 X# define ANIMATE_OSPEED 7 X# define ANIMATE_SAFETY 8 X X/* X * macros X */ X X# define other(x) (1 - x) X# define nextplay() (Play = other(Play)) X# define nextwin(x) (1 - x) X# define opposite(x) (Opposite[x]) X# define issafety(x) (x >= C_GAS_SAFE) X X/* X * externals X */ X Xextern bool Debug, Finished, Next, On_exit, Order, Saved; X Xextern char *C_fmt, **C_name, *Fromfile, Initstr[]; X Xextern int Card_no, End, Handstart, Movetype, Numcards[], Numgos, X Numneed[], Numseen[NUM_CARDS], Play, Value[], WIndow; X Xextern CARD Deck[DECK_SZ], Discard, Opposite[NUM_CARDS], *Topcard; X Xextern FILE *outf; X Xextern PLAY Player[2]; X X/* X * functions X */ X XCARD getcard(); END_OF_mille.h if test 3206 -ne `wc -c <mille.h`; then echo shar: \"mille.h\" unpacked with wrong size! fi # end of overwriting check fi if test -f misc.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"misc.c\" else echo shar: Extracting \"misc.c\" \(1986 characters\) sed "s/^X//" >misc.c <<'END_OF_misc.c' X#include "mille.h" X# ifdef attron X# include <term.h> X# define _tty cur_term->Nttyb X# endif attron X X/* X * @(#)misc.c 1.3 (Berkeley) 7/2/83 X */ X X#define NUMSAFE 4 X X/* VARARGS1 */ Xerror(str, arg) Xchar *str; X{ X Error (str, arg); X Beep (); X update_ui (); X return FALSE; X} X Xcheck_ext(forcomp) Xreg bool forcomp; { X X X if (End == 700) X if (Play == PLAYER) { X if (getyn("Extension? ")) { Xextend: X if (!forcomp) X End = 1000; X return TRUE; X } X else { Xdone: X if (!forcomp) X Finished = TRUE; X return FALSE; X } X } X else { X reg PLAY *pp, *op; X reg int i, safe, miles; X X pp = &Player[COMP]; X op = &Player[PLAYER]; X for (safe = 0, i = 0; i < NUMSAFE; i++) X if (pp->safety[i] != S_UNKNOWN) X safe++; X if (safe < 2) X goto done; X if (op->mileage == 0 || onecard(op) X || (op->can_go && op->mileage >= 500)) X goto done; X for (miles = 0, i = 0; i < NUMSAFE; i++) X if (op->safety[i] != S_PLAYED X && pp->safety[i] == S_UNKNOWN) X miles++; X if (miles + safe == NUMSAFE) X goto extend; X for (miles = 0, i = 0; i < HAND_SZ; i++) X if ((safe = pp->hand[i]) <= C_200) X miles += Value[safe]; X if (miles + (Topcard - Deck) * 3 > 1000) X goto extend; X goto done; X } X else X goto done; X} X X/* X * Check to see if more games are desired. If not, and game X * came from a saved file, make sure that they don't want to restore X * it. Exit appropriately. X */ Xcheck_more() { X X FlushInput (); X X On_exit = TRUE; X if (Player[PLAYER].total >= 5000 || Player[COMP].total >= 5000) X if (getyn("Another game? ")) X return; X else { X /* X * must do accounting normally done in main() X */ X if (Player[PLAYER].total > Player[COMP].total) X Player[PLAYER].games++; X else if (Player[PLAYER].total < Player[COMP].total) X Player[COMP].games++; X Player[COMP].total = 0; X Player[PLAYER].total = 0; X } X else X if (getyn("Another hand? ")) X return; X if (!Saved && getyn("Save game? ")) X if (!save()) X return; X die(); X} END_OF_misc.c if test 1986 -ne `wc -c <misc.c`; then echo shar: \"misc.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f move.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"move.c\" else echo shar: Extracting \"move.c\" \(8310 characters\) sed "s/^X//" >move.c <<'END_OF_move.c' X#include "mille.h" X X/* X * @(#)move.c 1.3 (Berkeley) 7/2/83 X */ X X#ifdef CTRL X#undef CTRL X#endif X#define CTRL(c) (c - 'A' + 1) X Xchar *Movenames[] = { X "M_DISCARD", "M_DRAW", "M_PLAY", "M_ORDER" X }; X Xchar *playcard (), *sprint (); X Xdomove() X{ X reg PLAY *pp; X reg int i, j; X reg bool goodplay; X char *foo; X X pp = &Player[Play]; X if (Play == PLAYER) X getmove(); X else X calcmove(); X Next = FALSE; X goodplay = TRUE; X switch (Movetype) { X case M_DISCARD: Xtrydiscard: ; X if (haspicked(pp)) { X if (pp->hand[Card_no] == C_INIT) X if (Card_no == 6) X Finished = TRUE; X else X error("no card there"); X else { X Discard = pp->hand[Card_no]; X pp->hand[Card_no] = C_INIT; X#ifdef ANIMATE X animate_move (Play, ANIMATE_HAND, Card_no, X ANIMATE_DISC, Discard); X#endif X Next = TRUE; X if (Play == PLAYER) X account(Discard); X } X } X else X error("must pick first"); X break; X case M_REASONABLE: X case M_PLAY: X foo = playcard(pp); X if (foo) { X if (Movetype == M_REASONABLE) X goto trydiscard; X error (foo); X goodplay = 0; X } else X goodplay = 1; X break; X case M_DRAW: X Card_no = 0; X if (Topcard <= Deck) X error("no more cards"); X else if (haspicked(pp)) X error("already picked"); X else { X pp->hand[0] = *--Topcard; X#ifdef ANIMATE X animate_move (Play, ANIMATE_DECK, pp->hand[0], ANIMATE_HAND, 0); X#endif X if (Debug) X fprintf(outf, "DOMOVE: Draw %s\n", C_name[*Topcard]); Xacc: X if (Play == COMP) { X account(*Topcard); X if (issafety(*Topcard)) X pp->safety[*Topcard-S_CONV] = S_IN_HAND; X } X if (pp->hand[1] == C_INIT && Topcard > Deck) { X Card_no = 1; X pp->hand[1] = *--Topcard; X if (Debug) X fprintf(outf, "DOMOVE: Draw %s\n", C_name[*Topcard]); X goto acc; X } X pp->new_battle = FALSE; X pp->new_speed = FALSE; X } X break; X X case M_ORDER: X break; X } X /* X * move blank card to top by one of two methods. If the X * computer's hand was sorted, the randomness for picking X * between equally valued cards would be lost X */ X if (Order && Movetype != M_DRAW && goodplay && pp == &Player[PLAYER]) X sort(pp->hand); X else X for (i = 1; i < HAND_SZ; i++) X if (pp->hand[i] == C_INIT) { X for (j = 0; pp->hand[j] == C_INIT; j++) X if (j >= HAND_SZ) { X j = 0; X break; X } X pp->hand[i] = pp->hand[j]; X pp->hand[j] = C_INIT; X } X if (Topcard <= Deck) X check_go(); X if (Next) X nextplay(); X} X X/* X * Check and see if either side can go. If they cannot, X * the game is over X */ Xcheck_go() { X X reg CARD card; X reg PLAY *pp, *op; X reg int i; X X for (pp = Player; pp < &Player[2]; pp++) { X op = (pp == &Player[COMP] ? &Player[PLAYER] : &Player[COMP]); X for (i = 0; i < HAND_SZ; i++) { X card = pp->hand[i]; X if (issafety(card) || canplay(pp, op, card)) { X if (Debug) { X fprintf(outf, "CHECK_GO: can play %s (%d), ", C_name[card], card); X fprintf(outf, "issafety(card) = %d, ", issafety(card)); X fprintf(outf, "canplay(pp, op, card) = %d\n", canplay(pp, op, card)); X } X return; X } X else if (Debug) X fprintf(outf, "CHECK_GO: cannot play %s\n", X C_name[card]); X } X } X Finished = TRUE; X} X Xchar * Xplaycard(pp) Xreg PLAY *pp; X{ X reg int v; X reg CARD card; X X /* X * check and see if player has picked X */ X switch (pp->hand[Card_no]) { X default: X if (!haspicked(pp)) Xmustpick: X return ("must pick first"); X case C_GAS_SAFE: case C_SPARE_SAFE: X case C_DRIVE_SAFE: case C_RIGHT_WAY: X break; X } X X card = pp->hand[Card_no]; X if (Debug) X fprintf(outf, "PLAYCARD: Card = %s\n", C_name[card]); X Next = FALSE; X switch (card) { X case C_200: X if (pp->nummiles[C_200] == 2) X return ("only two 200's per hand"); X case C_100: case C_75: X if (pp->speed == C_LIMIT) X return ("limit of 50"); X case C_50: X if (pp->mileage + Value[card] > End) X return sprint ("puts you over %d", End); X case C_25: X if (!pp->can_go) X return ("cannot move now"); X#ifdef ANIMATE X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_MILES, card); X#endif X pp->nummiles[card]++; X v = Value[card]; X pp->total += v; X pp->hand_tot += v; X if ((pp->mileage += v) == End) X check_ext(FALSE); X break; X X case C_GAS: case C_SPARE: case C_REPAIRS: X if (pp->battle != opposite(card)) X return sprint ("can't play \"%s\"", C_name[card]); X#ifdef ANIMATE X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_BATTLE, card); X#endif X pp->battle = card; X if (pp->safety[S_RIGHT_WAY] == S_PLAYED) X pp->can_go = TRUE; X break; X X case C_GO: X if (pp->battle != C_INIT && pp->battle != C_STOP X && !isrepair(pp->battle)) X return sprint ("cannot play \"Go\" on a \"%s\"", X C_name[pp->battle]); X#ifdef ANIMATE X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_BATTLE, card); X#endif X pp->battle = C_GO; X pp->can_go = TRUE; X break; X X case C_END_LIMIT: X if (pp->speed != C_LIMIT) X return ("not limited"); X#ifdef ANIMATE X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_SPEED, card); X#endif X pp->speed = C_END_LIMIT; X break; X X case C_EMPTY: case C_FLAT: case C_CRASH: X case C_STOP: X pp = &Player[other(Play)]; X if (!pp->can_go) X return ("opponent cannot go"); X else if (pp->safety[safety(card) - S_CONV] == S_PLAYED) Xprotected: X return ("opponent is protected"); X#ifdef ANIMATE X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_OBATTLE, card); X#endif X pp->battle = card; X pp->new_battle = TRUE; X pp->can_go = FALSE; X pp = &Player[Play]; X break; X X case C_LIMIT: X pp = &Player[other(Play)]; X if (pp->speed == C_LIMIT) X return ("opponent has limit"); X if (pp->safety[S_RIGHT_WAY] == S_PLAYED) X goto protected; X#ifdef ANIMATE X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_OSPEED, card); X#endif X pp->speed = C_LIMIT; X pp->new_speed = TRUE; X pp = &Player[Play]; X break; X X case C_GAS_SAFE: case C_SPARE_SAFE: X case C_DRIVE_SAFE: case C_RIGHT_WAY: X if (pp->battle == opposite(card) X || (card == C_RIGHT_WAY && pp->speed == C_LIMIT)) { X if (!(card == C_RIGHT_WAY && !isrepair(pp->battle))) { X pp->battle = C_GO; X pp->can_go = TRUE; X } X if (card == C_RIGHT_WAY && pp->speed == C_LIMIT) X pp->speed = C_INIT; X if (pp->new_battle X || (pp->new_speed && card == C_RIGHT_WAY)) { X pp->coups[card - S_CONV] = TRUE; X pp->total += SC_COUP; X pp->hand_tot += SC_COUP; X pp->coupscore += SC_COUP; X } X } X /* X * if not coup, must pick first X */ X else if (pp->hand[0] == C_INIT && Topcard > Deck) X goto mustpick; X#ifdef ANIMATE X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_SAFETY, card); X#endif X pp->safety[card - S_CONV] = S_PLAYED; X pp->total += SC_SAFETY; X pp->hand_tot += SC_SAFETY; X if ((pp->safescore += SC_SAFETY) == NUM_SAFE * SC_SAFETY) { X pp->total += SC_ALL_SAFE; X pp->hand_tot += SC_ALL_SAFE; X } X if (card == C_RIGHT_WAY) { X if (pp->speed == C_LIMIT) X pp->speed = C_INIT; X if (pp->battle == C_STOP || pp->battle == C_INIT) { X pp->can_go = TRUE; X pp->battle = C_INIT; X } X if (!pp->can_go && isrepair(pp->battle)) X pp->can_go = TRUE; X } X Next = -1; X break; X X case C_INIT: X Next = -1; X return ("no card there"); X break; X } X if (pp == &Player[PLAYER]) X account(card); X pp->hand[Card_no] = C_INIT; X Next = (Next == -1 ? FALSE : TRUE); X return 0; X} X Xchar * Xsprint (string, arg) X{ X static char buf[512]; X X sprintf (buf, string, arg); X return buf; X} X X/* X * return whether or not the player has picked X */ Xhaspicked(pp) Xreg PLAY *pp; { X X reg int card; X X if (Topcard <= Deck) X return TRUE; X switch (pp->hand[Card_no]) { X case C_GAS_SAFE: case C_SPARE_SAFE: X case C_DRIVE_SAFE: case C_RIGHT_WAY: X card = 1; X break; X default: X card = 0; X break; X } X return (pp->hand[card] != C_INIT); X} X Xaccount(card) Xreg CARD card; { X X reg CARD oppos; X X if (card == C_INIT) X return; X ++Numseen[card]; X if (Play == COMP) X switch (card) { X case C_GAS_SAFE: X case C_SPARE_SAFE: X case C_DRIVE_SAFE: X oppos = opposite(card); X Numgos += Numcards[oppos] - Numseen[oppos]; X break; X case C_CRASH: X case C_FLAT: X case C_EMPTY: X case C_STOP: X Numgos++; X break; X } X} X Xsort(hand) Xreg CARD *hand; X{ X reg CARD *cp, *tp; X reg int j; X reg CARD temp; X X cp = hand; X hand += HAND_SZ; X for ( ; cp < &hand[-1]; cp++) X for (tp = cp + 1; tp < hand; tp++) X if (*cp > *tp) { X temp = *cp; X *cp = *tp; X *tp = temp; X } X} END_OF_move.c if test 8310 -ne `wc -c <move.c`; then echo shar: \"move.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f patchlevel.h -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"patchlevel.h\" else echo shar: Extracting \"patchlevel.h\" \(21 characters\) sed "s/^X//" >patchlevel.h <<'END_OF_patchlevel.h' X#define PATCHLEVEL 0 END_OF_patchlevel.h if test 21 -ne `wc -c <patchlevel.h`; then echo shar: \"patchlevel.h\" unpacked with wrong size! fi # end of overwriting check fi if test -f print.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"print.c\" else echo shar: Extracting \"print.c\" \(65 characters\) sed "s/^X//" >print.c <<'END_OF_print.c' X# include "mille.h" X X/* X * @(#)print.c 1.1 (Berkeley) 4/1/82 X */ END_OF_print.c if test 65 -ne `wc -c <print.c`; then echo shar: \"print.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f roll.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"roll.c\" else echo shar: Extracting \"roll.c\" \(658 characters\) sed "s/^X//" >roll.c <<'END_OF_roll.c' X/* X * This routine rolls ndie nside-sided dice. X * X * @(#)roll.c 1.1 (Berkeley) 4/1/82 X * X */ X X# define reg register X X# ifndef vax X# define MAXRAND 32767L X Xroll(ndie, nsides) Xint ndie, nsides; { X X reg long tot; X reg unsigned n, r; X X tot = 0; X n = ndie; X#ifndef sun X while (n--) X tot += rand(); X return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie; X#else X while (n--) X tot += random() % nsides + 1; X return tot; X#endif X} X X# else X Xroll(ndie, nsides) Xreg int ndie, nsides; { X X reg int tot, r; X reg double num_sides; X X num_sides = nsides; X tot = 0; X while (ndie--) X tot += (r = rand()) * (num_sides / 017777777777) + 1; X return tot; X} X# endif END_OF_roll.c if test 658 -ne `wc -c <roll.c`; then echo shar: \"roll.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f save.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"save.c\" else echo shar: Extracting \"save.c\" \(1815 characters\) sed "s/^X//" >save.c <<'END_OF_save.c' X#include "mille.h" X#include <sys/types.h> X#include <sys/stat.h> X#include <sys/time.h> X# ifdef attron X# include <term.h> X# define _tty cur_term->Nttyb X# endif attron X X/* X * @(#)save.c 1.4 (Berkeley) 7/3/83 X */ X Xtypedef struct stat Stat; Xtypedef struct tm Time; X Xchar *ctime(); X Xint read(), write(); X X/* X * This routine saves the current game for use at a later date X */ Xextern int errno; Xextern char *sys_errlist[]; X Xsave() { X X reg char *sp; X reg int outf; X reg Time *tp; X char buf[80]; X Time tme; X Stat junk; X X tp = &tme; X if (Fromfile && getyn("Same file? ")) X strcpy(buf, Fromfile); X else { Xover: X X strcpy (buf, GetpromptedInput ("file: ")); X sp = buf + strlen (buf); X } X X /* X * check for existing files, and confirm overwrite if needed X */ X X if (sp == buf || (!Fromfile && stat(buf, &junk) > -1 X && getyn("Overwrite File? ") == FALSE)) X return FALSE; X X if ((outf = creat(buf, 0644)) < 0) { X error(sys_errlist[errno]); X return FALSE; X } X Error (buf); X time(tp); /* get current time */ X strcpy(buf, ctime(tp)); X for (sp = buf; *sp != '\n'; sp++) X continue; X *sp = '\0'; X varpush(outf, write); X close(outf); X return TRUE; X} X X/* X * This does the actual restoring. It returns TRUE if the X * backup was made on exiting, in which case certain things must X * be cleaned up before the game starts. X */ Xrest_f(file) Xreg char *file; { X X reg char *sp; X reg int inf; X char buf[80]; X Stat sbuf; X X if ((inf = open(file, 0)) < 0) { X perror(file); X exit(1); X } X if (fstat(inf, &sbuf) < 0) { /* get file stats */ X perror(file); X exit(1); X } X varpush(inf, read); X close(inf); X strcpy(buf, ctime(&sbuf.st_mtime)); X for (sp = buf; *sp != '\n'; sp++) X continue; X *sp = '\0'; X /* X * initialize some necessary values X */ X sprintf(Initstr, "%s [%s]\n", file, buf); X Fromfile = file; X return !On_exit; X} END_OF_save.c if test 1815 -ne `wc -c <save.c`; then echo shar: \"save.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f table.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"table.c\" else echo shar: Extracting \"table.c\" \(431 characters\) sed "s/^X//" >table.c <<'END_OF_table.c' X# define DEBUG X X/* X * @(#)table.c 1.1 (Berkeley) 4/1/82 X */ X X# include "mille.h" X Xmain() { X X reg int i, j, count; X X printf(" %16s -> %5s %5s %4s %s\n", "Card", "cards", "count", "need", "opposite"); X for (i = 0; i < NUM_CARDS - 1; i++) { X for (j = 0, count = 0; j < DECK_SZ; j++) X if (Deck[j] == i) X count++; X printf("%2d %16s -> %5d %5d %4d %s\n", i, C_name[i], Numcards[i], count, Numneed[i], C_name[opposite(i)]); X } X} END_OF_table.c if test 431 -ne `wc -c <table.c`; then echo shar: \"table.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f types.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"types.c\" else echo shar: Extracting \"types.c\" \(597 characters\) sed "s/^X//" >types.c <<'END_OF_types.c' X# include "mille.h" X X/* X * @(#)types.c 1.1 (Berkeley) 4/1/82 X */ X Xisrepair(card) Xreg CARD card; { X X return card == C_GAS || card == C_SPARE || card == C_REPAIRS || card == C_INIT; X} X Xsafety(card) Xreg CARD card; { X X switch (card) { X case C_EMPTY: X case C_GAS: X case C_GAS_SAFE: X return C_GAS_SAFE; X case C_FLAT: X case C_SPARE: X case C_SPARE_SAFE: X return C_SPARE_SAFE; X case C_CRASH: X case C_REPAIRS: X case C_DRIVE_SAFE: X return C_DRIVE_SAFE; X case C_GO: X case C_STOP: X case C_RIGHT_WAY: X case C_LIMIT: X case C_END_LIMIT: X return C_RIGHT_WAY; X } X /* NOTREACHED */ X} END_OF_types.c if test 597 -ne `wc -c <types.c`; then echo shar: \"types.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f ui.h -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"ui.h\" else echo shar: Extracting \"ui.h\" \(3021 characters\) sed "s/^X//" >ui.h <<'END_OF_ui.h' X# include "color.h" X# include <X11/Xlib.h> X# include "control/control.h" X Xextern Display *dpy; Xextern int screen; Xextern Window xwindow; Xextern XFontStruct *font; Xextern Pixmap fill; Xextern GC black_gc, text_gc, blue_gc, cheap_gc; X Xstruct card { X Pixmap bits; X}; X Xextern struct card cards[]; Xextern struct card backside; Xextern struct card eraseCard; X X Xstruct safety_offset { X int x; X int y; X}; X Xextern struct safety_offset safety_offsets[4]; X X# define PAD_CARD (5) X# define MILE_OFFSET (5) X# define PAD_TEXT (20) X# define DIST_HEIGHT (15) X# define DIST_WIDTH ((WIDTH + PAD_CARD) * 5 - PAD_CARD) X# define DIST_MARK (4) X X# define COMP_HAND_X (PAD_CARD) X# define COMP_HAND_Y (-HEIGHT + font->descent) X# define COMP_DIST_TX (PAD_CARD + (WIDTH + PAD_CARD) * 2) X# define COMP_DIST_TY (PAD_CARD) X# define COMP_DIST_MX (COMP_DIST_TX) X# define COMP_DIST_MY (COMP_DIST_TY + PAD_TEXT) X# define COMP_DIST_X (COMP_DIST_MX) X# define COMP_DIST_Y (COMP_DIST_MY + DIST_MARK + 1) X X# define COMP_PLAY_X PAD_CARD X# define COMP_PLAY_Y (COMP_DIST_Y + DIST_HEIGHT + PAD_CARD) X X# define COMP_SAFE_X (COMP_PLAY_X + ((WIDTH + PAD_CARD) * 7)) X# define COMP_SAFE_Y COMP_PLAY_Y X X# define COMP_CARD_TX PAD_CARD X# define COMP_CARD_TY (COMP_PLAY_Y + HEIGHT + 6 * MILE_OFFSET + PAD_CARD) X# define COMP_CARD_X COMP_CARD_TX X# define COMP_CARD_Y (COMP_CARD_TY + PAD_TEXT) X X# define MESS_X (PAD_CARD) X# define MESS_Y (COMP_PLAY_Y + HEIGHT + 6 * MILE_OFFSET + PAD_CARD + PAD_TEXT) X# define MESS_W (150) X# define MESS_H (font->ascent + font->descent) X# define PROMPT_X MESS_X X# define PROMPT_Y (MESS_Y + PAD_TEXT) X# define PROMPT_W (MESS_W) X# define PROMPT_H (MESS_H) X# define ERROR_X PROMPT_X X# define ERROR_Y (PROMPT_Y + PAD_TEXT) X# define ERROR_W (MESS_W) X# define ERROR_H (MESS_H) X X# define QUIT_X (MESS_X) X# define QUIT_Y (ERROR_Y + PAD_TEXT + PAD_CARD) X# define SAVE_X (QUIT_X + 75) X# define SAVE_Y (QUIT_Y) X X# define DISCARD_TX (MESS_X + MESS_W + PAD_CARD) X# define DISCARD_TY (MESS_Y - PAD_TEXT) X# define DISCARD_X (DISCARD_TX) X# define DISCARD_Y (DISCARD_TY + PAD_TEXT) X X# define DECK_TX (DISCARD_X + WIDTH + PAD_CARD) X# define DECK_TY (DISCARD_TY) X# define DECK_X (DECK_TX) X# define DECK_Y (DISCARD_Y) X X# define SCORE_W (150) X# define SCORE_H (font->ascent + font->descent) X# define SCORE_N 13 X# define SCORE_X (DECK_X + WIDTH + PAD_CARD + SCORE_W) X# define SCORE_Y (DECK_TY) X X# define HUM_DIST_TX (COMP_DIST_TX) X# define HUM_DIST_TY (SCORE_Y + SCORE_N * SCORE_H + PAD_CARD) X# define HUM_DIST_MX (HUM_DIST_TX) X# define HUM_DIST_MY (HUM_DIST_TY + PAD_TEXT) X# define HUM_DIST_X (HUM_DIST_MX) X# define HUM_DIST_Y (HUM_DIST_MY + DIST_MARK + 1) X X# define HUM_PLAY_X PAD_CARD X# define HUM_PLAY_Y (HUM_DIST_Y + DIST_HEIGHT + PAD_CARD) X# define HUM_SAFE_X (HUM_PLAY_X + ((WIDTH + PAD_CARD) * 7)) X# define HUM_SAFE_Y (HUM_PLAY_Y) X X# define HUM_HAND_X PAD_CARD X# define HUM_HAND_Y (HUM_PLAY_Y + HEIGHT + 6 * MILE_OFFSET + PAD_CARD) X X# define WINDOW_WIDTH (HUM_SAFE_X + (WIDTH + PAD_CARD) * 2) X# define WINDOW_HEIGHT (HUM_HAND_Y + HEIGHT + PAD_CARD) END_OF_ui.h if test 3021 -ne `wc -c <ui.h`; then echo shar: \"ui.h\" unpacked with wrong size! fi # end of overwriting check fi if test -f varpush.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"varpush.c\" else echo shar: Extracting \"varpush.c\" \(1170 characters\) sed "s/^X//" >varpush.c <<'END_OF_varpush.c' X# include "mille.h" X X/* X * @(#)varpush.c 1.1 (Berkeley) 4/1/82 X */ X Xint read(), write(); X X/* X * push variables around via the routine func() on the file X * channel file. func() is either read or write. X */ Xvarpush(file, func) Xreg int file; Xreg int (*func)(); { X X int temp; X X (*func)(file, &Debug, sizeof Debug); X (*func)(file, &Finished, sizeof Finished); X (*func)(file, &Order, sizeof Order); X (*func)(file, &End, sizeof End); X (*func)(file, &On_exit, sizeof On_exit); X (*func)(file, &Handstart, sizeof Handstart); X (*func)(file, &Numgos, sizeof Numgos); X (*func)(file, Numseen, sizeof Numseen); X (*func)(file, &Play, sizeof Play); X (*func)(file, &WIndow, sizeof WIndow); X (*func)(file, Deck, sizeof Deck); X (*func)(file, &Discard, sizeof Discard); X (*func)(file, Player, sizeof Player); X if (func == read) { X read(file, &temp, sizeof temp); X Topcard = &Deck[temp]; X if (Debug) { X char buf[80]; Xover: X printf("Debug file:"); X gets(buf); X if ((outf = fopen(buf, "w")) == NULL) { X perror(buf); X goto over; X } X if (strcmp(buf, "/dev/null") != 0) X setbuf(outf, 0); X } X } X else { X temp = Topcard - Deck; X write(file, &temp, sizeof temp); X } X} END_OF_varpush.c if test 1170 -ne `wc -c <varpush.c`; then echo shar: \"varpush.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f xmille.6 -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"xmille.6\" else echo shar: Extracting \"xmille.6\" \(481 characters\) sed "s/^X//" >xmille.6 <<'END_OF_xmille.6' X.TH XMILLE 6 "July 1988" "X Version 11" X.SH NAME Xxmille \- X window mille bourne game X.SH SYNOPSIS X.B xmille X.RI [ restore-file ] X.SH DESCRIPTION X.I Xmille Xbrings up a window for a mille bourne game. XWhen selecting one of your cards, the left button plays the card, Xthe right button discards the card and the middle button chooses Xwhichever is appropriate, first trying to play the card, and then Xdiscarding it. X.SH AUTHOR XKeith Packard X.br XDave Lemke X.br XDana Chee X.SH "SEE ALSO" END_OF_xmille.6 if test 481 -ne `wc -c <xmille.6`; then echo shar: \"xmille.6\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 1 \(of 3\). cp /dev/null ark1isdone MISSING="" for I in 1 2 3 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 3 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Mike Wexler(wyse!mikew) Phone: (408)433-1000 x1330