summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1994-09-04 04:03:31 +0000
committerjkh <jkh@FreeBSD.org>1994-09-04 04:03:31 +0000
commitd8a265c292730d37ead16d6333be10451286af8a (patch)
treecb4c99719941e9adcca318e58d903337a369d49f
downloadFreeBSD-src-d8a265c292730d37ead16d6333be10451286af8a.zip
FreeBSD-src-d8a265c292730d37ead16d6333be10451286af8a.tar.gz
Bring in the 4.4 Lite games directory, modulo man page changes and segregation
of the x11 based games. I'm not going to tag the originals with bsd_44_lite and do this in two stages since it's just not worth it for this collection, and I've got directory renames to deal with that way. Bleah. Submitted by: jkh
-rw-r--r--games/ching/Makefile12
-rw-r--r--games/ching/ching.h42
-rw-r--r--games/ching/cno/Makefile8
-rw-r--r--games/ching/cno/ching.cno.c120
-rw-r--r--games/ching/phx/Makefile8
-rw-r--r--games/ching/phx/ching.phx.c315
-rw-r--r--games/ching/phx/pathnames.h36
-rw-r--r--games/factor/Makefile10
-rw-r--r--games/factor/factor.6116
-rw-r--r--games/factor/factor.c201
-rw-r--r--games/hack/hack.onames.h227
-rw-r--r--games/monop/Makefile26
-rw-r--r--games/monop/brd.dat78
-rw-r--r--games/monop/cards.c208
-rw-r--r--games/monop/cards.inp122
-rw-r--r--games/monop/deck.h48
-rw-r--r--games/monop/execute.c262
-rw-r--r--games/monop/getinp.c116
-rw-r--r--games/monop/houses.c269
-rw-r--r--games/monop/initdeck.c184
-rw-r--r--games/monop/jail.c127
-rw-r--r--games/monop/misc.c272
-rw-r--r--games/monop/mon.dat44
-rw-r--r--games/monop/monop.6188
-rw-r--r--games/monop/monop.c162
-rw-r--r--games/monop/monop.def123
-rw-r--r--games/monop/monop.ext57
-rw-r--r--games/monop/monop.h137
-rw-r--r--games/monop/morg.c209
-rw-r--r--games/monop/pathnames.h36
-rw-r--r--games/monop/print.c192
-rw-r--r--games/monop/prop.c211
-rw-r--r--games/monop/prop.dat58
-rw-r--r--games/monop/rent.c92
-rw-r--r--games/monop/roll.c74
-rw-r--r--games/monop/spec.c86
-rw-r--r--games/monop/trade.c306
-rw-r--r--games/number/Makefile6
-rw-r--r--games/number/number.660
-rw-r--r--games/number/number.c291
-rw-r--r--games/phantasia/COPYRIGHT24
-rw-r--r--games/phantasia/Makefile30
-rw-r--r--games/phantasia/OWNER6
-rw-r--r--games/phantasia/README82
-rw-r--r--games/phantasia/convert.c210
-rw-r--r--games/phantasia/fight.c1688
-rw-r--r--games/phantasia/gamesupport.c722
-rw-r--r--games/phantasia/include.h17
-rw-r--r--games/phantasia/interplayer.c1208
-rw-r--r--games/phantasia/io.c436
-rw-r--r--games/phantasia/macros.h16
-rw-r--r--games/phantasia/main.c1288
-rw-r--r--games/phantasia/map.c160
-rw-r--r--games/phantasia/misc.c1703
-rw-r--r--games/phantasia/monsters.asc100
-rw-r--r--games/phantasia/oldplayer.h54
-rw-r--r--games/phantasia/pathnames.h44
-rw-r--r--games/phantasia/phantasia.61220
-rw-r--r--games/phantasia/phantdefs.h139
-rw-r--r--games/phantasia/phantglobs.c113
-rw-r--r--games/phantasia/phantglobs.h86
-rw-r--r--games/phantasia/phantstruct.h124
-rw-r--r--games/phantasia/setup.c261
-rw-r--r--games/pig/Makefile6
-rw-r--r--games/pig/pig.648
-rw-r--r--games/pig/pig.c126
-rw-r--r--games/primes/Makefile9
-rw-r--r--games/primes/pattern.c440
-rw-r--r--games/primes/pr_tbl.c546
-rw-r--r--games/primes/primes.c332
-rw-r--r--games/primes/primes.h52
-rw-r--r--games/quiz/Makefile16
-rw-r--r--games/quiz/datfiles/africa43
-rw-r--r--games/quiz/datfiles/america27
-rw-r--r--games/quiz/datfiles/areas124
-rw-r--r--games/quiz/datfiles/arith45
-rw-r--r--games/quiz/datfiles/asia41
-rw-r--r--games/quiz/datfiles/babies21
-rw-r--r--games/quiz/datfiles/bard228
-rw-r--r--games/quiz/datfiles/chinese12
-rw-r--r--games/quiz/datfiles/collectives105
-rw-r--r--games/quiz/datfiles/ed84
-rw-r--r--games/quiz/datfiles/elements103
-rw-r--r--games/quiz/datfiles/europe33
-rw-r--r--games/quiz/datfiles/flowers45
-rw-r--r--games/quiz/datfiles/greek7
-rw-r--r--games/quiz/datfiles/inca12
-rw-r--r--games/quiz/datfiles/index32
-rw-r--r--games/quiz/datfiles/latin157
-rw-r--r--games/quiz/datfiles/locomotive11
-rw-r--r--games/quiz/datfiles/midearth10
-rw-r--r--games/quiz/datfiles/morse26
-rw-r--r--games/quiz/datfiles/mult99
-rw-r--r--games/quiz/datfiles/murders25
-rw-r--r--games/quiz/datfiles/poetry184
-rw-r--r--games/quiz/datfiles/posneg50
-rw-r--r--games/quiz/datfiles/pres38
-rw-r--r--games/quiz/datfiles/province13
-rw-r--r--games/quiz/datfiles/seq-easy14
-rw-r--r--games/quiz/datfiles/seq-hard15
-rw-r--r--games/quiz/datfiles/sexes26
-rw-r--r--games/quiz/datfiles/sov42
-rw-r--r--games/quiz/datfiles/spell2
-rw-r--r--games/quiz/datfiles/state50
-rw-r--r--games/quiz/datfiles/trek19
-rw-r--r--games/quiz/datfiles/ucc127
-rw-r--r--games/quiz/pathnames.h37
-rw-r--r--games/quiz/quiz.6119
-rw-r--r--games/quiz/quiz.c383
-rw-r--r--games/quiz/quiz.h61
-rw-r--r--games/quiz/rxp.c313
-rw-r--r--games/x11/xneko/Makefile9
-rw-r--r--games/x11/xneko/bitmaps/awake.xbm14
-rw-r--r--games/x11/xneko/bitmaps/cursor.xbm8
-rw-r--r--games/x11/xneko/bitmaps/cursor_mask.xbm6
-rw-r--r--games/x11/xneko/bitmaps/down1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/down2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/dtogi1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/dtogi2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/dwleft1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/dwleft2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/dwright1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/dwright2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/icon.xbm14
-rw-r--r--games/x11/xneko/bitmaps/jare2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/kaki1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/kaki2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/left1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/left2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/ltogi1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/ltogi2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/mati2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/mati3.xbm14
-rw-r--r--games/x11/xneko/bitmaps/right1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/right2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/rtogi1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/rtogi2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/sleep1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/sleep2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/space.xbm14
-rw-r--r--games/x11/xneko/bitmaps/up1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/up2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/upleft1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/upleft2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/upright1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/upright2.xbm14
-rw-r--r--games/x11/xneko/bitmaps/utogi1.xbm14
-rw-r--r--games/x11/xneko/bitmaps/utogi2.xbm14
-rw-r--r--games/x11/xneko/xneko.684
-rw-r--r--games/x11/xneko/xneko.c1762
-rw-r--r--games/x11/xroach/Makefile10
-rw-r--r--games/x11/xroach/bitmaps/roach000.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach015.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach030.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach045.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach060.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach075.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach090.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach105.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach120.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach135.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach150.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach165.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach180.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach195.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach210.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach225.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach240.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach255.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach270.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach285.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach300.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach315.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach330.xbm30
-rw-r--r--games/x11/xroach/bitmaps/roach345.xbm30
-rw-r--r--games/x11/xroach/roachmap.h65
-rw-r--r--games/x11/xroach/xroach.675
-rw-r--r--games/x11/xroach/xroach.c602
178 files changed, 23045 insertions, 0 deletions
diff --git a/games/ching/Makefile b/games/ching/Makefile
new file mode 100644
index 0000000..51f850d
--- /dev/null
+++ b/games/ching/Makefile
@@ -0,0 +1,12 @@
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
+
+SUBDIR= cno phx
+MAN6= ching.6
+
+beforeinstall:
+ install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${.CURDIR}/ching.sh ${DESTDIR}/usr/games/ching
+ install -c -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/hexagrams \
+ ${.CURDIR}/macros ${DESTDIR}/usr/share/games/ching
+
+.include <bsd.prog.mk>
diff --git a/games/ching/ching.h b/games/ching/ching.h
new file mode 100644
index 0000000..2809051
--- /dev/null
+++ b/games/ching/ching.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Guy Harris.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ching.h 8.1 (Berkeley) 5/31/93
+ */
+
+#define OYIN 6 /* yin (broken) moving to yang (solid) */
+#define YYANG 7 /* yang (solid) */
+#define YYIN 8 /* yin (broken) */
+#define OYANG 9 /* yang (solid) moving to yin (broken) */
diff --git a/games/ching/cno/Makefile b/games/ching/cno/Makefile
new file mode 100644
index 0000000..64e6a98
--- /dev/null
+++ b/games/ching/cno/Makefile
@@ -0,0 +1,8 @@
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
+
+PROG= ching.cno
+BINDIR= /usr/games
+CFLAGS+=-I${.CURDIR}/..
+NOMAN= noman
+
+.include <bsd.prog.mk>
diff --git a/games/ching/cno/ching.cno.c b/games/ching/cno/ching.cno.c
new file mode 100644
index 0000000..ff03c85
--- /dev/null
+++ b/games/ching/cno/ching.cno.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Guy Harris.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1988, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)ching.cno.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+/*
+ * cno - Read a question, cast a change, and output the line values to the
+ * standard output for processing by "phx".
+ */
+#include <stdio.h>
+#include "ching.h"
+
+long now; /* current time */
+
+unsigned seed; /* seed for random number generator */
+unsigned getrand();
+
+char *change();
+char string[6+1]; /* where the actual change string is put */
+
+int table[2][2][2] = {
+ { { OYIN, YYANG,}, { YYANG, YYIN,} },
+ { { YYANG, YYIN,}, { YYIN, OYANG,} },
+};
+
+main()
+{
+ FILE *logf;
+
+ time(&now);
+ seed = (int)now + getquest() + getgid() + getuid() + getpid(); /* randomize */
+ printf("%s\n", change());
+}
+
+/*
+ * Hash the question by adding all the characters together.
+ */
+int
+getquest()
+{
+ int result;
+ register int c;
+
+ result = 0;
+ while ((c = getchar()) != EOF)
+ result += c;
+ return(result);
+}
+
+/*
+ * Get a set of six lines making up a change.
+ */
+char *
+change()
+{
+ register int i;
+
+ for (i = 0; i < 6; i++)
+ string[i] = table[getrnum()&01][getrnum()&01][getrnum()&01] + '0';
+ string[i] = '\0';
+ return(string);
+}
+
+/*
+ * Get a number more random than what getrand() gives.
+ */
+getrnum()
+{
+ return((getrand())>>(getrand()%17));
+}
+
+/*
+ * Get a random number.
+ */
+unsigned
+getrand()
+{
+ return(seed = (seed*13077) + 6925);
+}
diff --git a/games/ching/phx/Makefile b/games/ching/phx/Makefile
new file mode 100644
index 0000000..4b2de4d
--- /dev/null
+++ b/games/ching/phx/Makefile
@@ -0,0 +1,8 @@
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
+
+PROG= ching.phx
+CFLAGS+=-I${.CURDIR}/..
+BINDIR= /usr/games
+NOMAN= noman
+
+.include <bsd.prog.mk>
diff --git a/games/ching/phx/ching.phx.c b/games/ching/phx/ching.phx.c
new file mode 100644
index 0000000..c67d054
--- /dev/null
+++ b/games/ching/phx/ching.phx.c
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Guy Harris.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1988, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)ching.phx.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+/*
+ * phx - Print NROFF/TROFF source of change, given the line values.
+ */
+#include <stdio.h>
+#include "ching.h"
+#include "pathnames.h"
+
+struct {
+ int lines; /* encoded value of lines */
+ int trinum; /* trigram number */
+} table[] = {
+ { 777, 0 }, /* 1 */
+ { 887, 1 }, /* 4 */
+ { 878, 2 }, /* 6 */
+ { 788, 3 }, /* 7 */
+ { 888, 4 }, /* 8 */
+ { 778, 5 }, /* 5 */
+ { 787, 6 }, /* 3 */
+ { 877, 7 }, /* 2 */
+};
+
+/*
+ * Gives hexagram number from two component trigrams.
+ */
+int crosstab[8][8] = {
+ 1, 34, 5, 26, 11, 9, 14, 43,
+ 25, 51, 3, 27, 24, 42, 21, 17,
+ 6, 40, 29, 4, 7, 59, 64, 47,
+ 33, 62, 39, 52, 15, 53, 56, 31,
+ 12, 16, 8, 23, 2, 20, 35, 45,
+ 44, 32, 48, 18, 46, 57, 50, 28,
+ 13, 55, 63, 22, 36, 37, 30, 49,
+ 10, 54, 60, 41, 19, 61, 38, 58,
+};
+
+int trigrams[6];
+int moving[6];
+
+FILE *chingf; /* stream to read the hexagram file */
+
+char *gets();
+
+main(argc, argv)
+int argc;
+char **argv;
+{
+ register int hexagram; /* hexagram number */
+ register char *hexptr; /* pointer to string of lines */
+ char hexstr[6+1]; /* buffer for reading lines in */
+ register int i;
+
+ if (argc < 2)
+ hexptr = gets(hexstr);
+ else
+ hexptr = argv[1];
+ if (hexptr == (char *)NULL || strlen(hexptr) != 6) {
+ fprintf(stderr, "What kind of a change is THAT?!?\n");
+ exit(1);
+ }
+ for (i = 0; i < 6; i++) {
+ trigrams[i] = hexptr[i] - '0';
+ if (trigrams[i] == 6 || trigrams[i] == 9)
+ moving[i] = 1;
+ else
+ moving[i] = 0;
+ }
+ if ((chingf = fopen(_PATH_HEX, "r")) == (FILE *)NULL) {
+ fprintf(stderr, "ching: can't read %s\n", _PATH_HEX);
+ exit(2);
+ }
+ phx(doahex(), 0);
+ if (changes())
+ phx(doahex(), 1);
+}
+
+/*
+ * Compute the hexagram number, given the trigrams.
+ */
+int
+doahex()
+{
+ int lower, upper; /* encoded values of lower and upper trigrams */
+ int lnum, unum; /* indices of upper and lower trigrams */
+ register int i;
+
+ lower = codem(0);
+ upper = codem(3);
+ for (i = 0; i < 8; i++) {
+ if (table[i].lines == lower)
+ lnum = table[i].trinum;
+ if (table[i].lines == upper)
+ unum = table[i].trinum;
+ }
+ return(crosstab[lnum][unum]);
+}
+
+/*
+ * Encode a trigram as a 3-digit number; the digits, from left to right,
+ * represent the lines. 7 is a solid (yang) line, 8 is a broken (yin) line.
+ */
+codem(a)
+int a;
+{
+ register int code, i;
+ int factor[3];
+
+ factor[0] = 1;
+ factor[1] = 10;
+ factor[2] = 100;
+ code = 0;
+
+ for (i = a; i < a + 3; i++) {
+ switch(trigrams[i]) {
+
+ case YYANG:
+ case OYANG:
+ code += factor[i%3]*7;
+ break;
+
+ case OYIN:
+ case YYIN:
+ code += factor[i%3]*8;
+ break;
+ }
+ }
+ return(code);
+}
+
+/*
+ * Compute the changes based on moving lines; return 1 if any lines moved,
+ * 0 if no lines moved.
+ */
+changes()
+{
+ register int cflag;
+ register int i;
+
+ cflag = 0;
+ for (i = 0; i < 6; i++) {
+ if (trigrams[i] == OYIN) {
+ trigrams[i] = YYANG;
+ cflag++;
+ } else if (trigrams[i] == OYANG) {
+ trigrams[i] = YYIN;
+ cflag++;
+ }
+ }
+ return(cflag);
+}
+
+/*
+ * Print the NROFF/TROFF source of a hexagram, given the hexagram number;
+ * if flag is 0, print the entire source; if flag is 1, ignore the meanings
+ * of the lines.
+ */
+phx(hexagram, flag)
+int hexagram;
+int flag;
+{
+ char textln[128+1]; /* buffer for text line */
+ register char *lp; /* pointer into buffer */
+ register int thishex; /* number of hexagram just read */
+ int lineno; /* number of line read in */
+ int allmoving; /* 1 if all lines are moving */
+ register int i;
+
+ /*
+ * Search for the hexagram; it begins with a line of the form
+ * .H <hexagram number> <other data>.
+ */
+ rewind(chingf);
+ for (;;) {
+ if (fgets(textln, sizeof(textln), chingf) == (char *)NULL) {
+ fprintf(stderr, "ching: Hexagram %d missing\n",
+ hexagram);
+ exit(3);
+ }
+ lp = &textln[0];
+ if (*lp++ != '.' || *lp++ != 'H')
+ continue;
+ while (*lp++ == ' ')
+ ;
+ lp--;
+ thishex = atoi(lp);
+ if (thishex < 1 || thishex > 64)
+ continue;
+ if (thishex == hexagram)
+ break;
+ }
+
+ /*
+ * Print up to the line commentary, which ends with a line of the form
+ * .L <position> <value>
+ */
+ fputs(textln, stdout);
+ for (;;) {
+ if (fgets(textln, sizeof(textln), chingf) == (char *)NULL) {
+ fprintf(stderr, "ching: Hexagram %d malformed\n",
+ hexagram);
+ exit(3);
+ }
+ lp = &textln[0];
+ if (*lp++ == '.') {
+ if (*lp++ == 'L')
+ break;
+ }
+ fputs(textln, stdout);
+ }
+
+ /*
+ * Now print the line commentaries, if this is the first hexagram.
+ */
+ if (flag)
+ return;
+
+ /*
+ * If a line is moving, print its commentary.
+ * The text of the commentary ends with a line either of the form
+ * .L <position> <value>
+ * or of the form
+ * .LA <value>
+ * or of the form
+ * .H <hexagram number> <other arguments>
+ */
+ allmoving = 1;
+ for (i = 0; i < 6; i++) {
+ while (*lp++ == ' ')
+ ;
+ lp--;
+ lineno = atoi(lp);
+ if (i + 1 != lineno) {
+ fprintf(stderr, "ching: Hexagram %d malformed\n",
+ hexagram);
+ exit(3);
+ }
+ if (moving[i])
+ fputs(textln, stdout);
+ else
+ allmoving = 0;
+ for (;;) {
+ if (fgets(textln, sizeof(textln), chingf) == (char *)NULL)
+ break;
+ lp = &textln[0];
+ if (*lp++ == '.' && (*lp == 'L' || *lp == 'H')) {
+ lp++;
+ break;
+ }
+ if (moving[i])
+ fputs(textln, stdout);
+ }
+ }
+
+ /*
+ * If all the lines are moving, print the commentary for that; it
+ * ends with a line of the form
+ * .H <hexagram number> <other arguments>
+ */
+ if (*lp == 'A' && allmoving) {
+ fputs(textln, stdout);
+ for (;;) {
+ if (fgets(textln, sizeof(textln), chingf) == (char *)NULL)
+ break;
+ lp = &textln[0];
+ if (*lp++ == '.' || *lp++ == 'H')
+ break;
+ fputs(textln, stdout);
+ }
+ }
+}
diff --git a/games/ching/phx/pathnames.h b/games/ching/phx/pathnames.h
new file mode 100644
index 0000000..d4ed881
--- /dev/null
+++ b/games/ching/phx/pathnames.h
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)pathnames.h 8.1 (Berkeley) 5/31/93
+ */
+
+#define _PATH_HEX "/usr/share/games/ching/hexagrams"
diff --git a/games/factor/Makefile b/games/factor/Makefile
new file mode 100644
index 0000000..0189952
--- /dev/null
+++ b/games/factor/Makefile
@@ -0,0 +1,10 @@
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
+
+PROG= factor
+SRCS= factor.c pr_tbl.c
+CFLAGS+=-I${.CURDIR}/../primes
+MAN6= factor.6
+MLINKS+=factor.6 primes.6
+.PATH: ${.CURDIR}/../primes
+
+.include <bsd.prog.mk>
diff --git a/games/factor/factor.6 b/games/factor/factor.6
new file mode 100644
index 0000000..7a9ea12
--- /dev/null
+++ b/games/factor/factor.6
@@ -0,0 +1,116 @@
+.\" Copyright (c) 1989, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Landon Curt Noll.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)factor.6 8.1 (Berkeley) 5/31/93
+.\"
+.\"
+.\" By: Landon Curt Noll chongo@toad.com, ...!{sun,tolsoft}!hoptoad!chongo
+.\"
+.\" chongo <for a good prime call: 391581 * 2^216193 - 1> /\oo/\
+.\"
+.TH FACTOR 6 "May 31, 1993"
+.UC 7
+.SH NAME
+factor, primes \- factor a number, generate primes
+.SH SYNOPSIS
+.B factor
+[ number ] ...
+.PP
+.B primes
+[ start [ stop ]]
+.SH DESCRIPTION
+The
+.I factor
+utility will factor integers between -2147483648 and 2147483647 inclusive.
+When a number is factored, it is printed, followed by a ``:'',
+and the list of factors on a single line.
+Factors are listed in ascending order, and are preceded by a space.
+If a factor divides a value more than once, it will be printed
+more than once.
+.PP
+When
+.I factor
+is invoked with one or more arguments,
+each argument will be factored.
+.PP
+When
+.I factor
+is invoked with no arguments,
+.I factor
+reads numbers, one per line, from standard input, until end of file or error.
+Leading white-space and empty lines are ignored.
+Numbers may be preceded by a single - or +.
+Numbers are terminated by a non-digit character (such as a newline).
+After a number is read, it is factored.
+Input lines must not be longer than 255 characters.
+.PP
+The
+.I primes
+utility prints primes in ascending order, one per line, starting at or above
+.B start
+and continuing until, but not including
+.B stop.
+The
+.B start
+value must be at least 0 and not greater than
+.B stop.\&
+The
+.B stop
+value must not be greater than 4294967295.
+The default value of
+.B stop
+is 4294967295.
+.PP
+When the
+.I primes
+utility is invoked with no arguments,
+.B start
+is read from standard input.
+.B Stop
+is taken to be 4294967295.
+The
+.B start
+value may be preceded by a single +.
+The
+.B start
+value is terminated by a non-digit character (such as a newline).
+The input line must not be longer than 255 characters.
+.SH DIAGNOSTICS
+Out of range or invalid input results in `ouch' being
+written to standard error.
+.SH BUGS
+.I Factor
+cannot handle the ``10 most wanted'' factor list,
+.I primes
+won't get you a world record.
diff --git a/games/factor/factor.c b/games/factor/factor.c
new file mode 100644
index 0000000..562e4b2
--- /dev/null
+++ b/games/factor/factor.c
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Landon Curt Noll.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1989, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)factor.c 8.3 (Berkeley) 3/30/94";
+#endif /* not lint */
+
+/*
+ * factor - factor a number into primes
+ *
+ * By: Landon Curt Noll chongo@toad.com, ...!{sun,tolsoft}!hoptoad!chongo
+ *
+ * chongo <for a good prime call: 391581 * 2^216193 - 1> /\oo/\
+ *
+ * usage:
+ * factor [number] ...
+ *
+ * The form of the output is:
+ *
+ * number: factor1 factor1 factor2 factor3 factor3 factor3 ...
+ *
+ * where factor1 < factor2 < factor3 < ...
+ *
+ * If no args are given, the list of numbers are read from stdin.
+ */
+
+#include <err.h>
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "primes.h"
+
+/*
+ * prime[i] is the (i-1)th prime.
+ *
+ * We are able to sieve 2^32-1 because this byte table yields all primes
+ * up to 65537 and 65537^2 > 2^32-1.
+ */
+extern ubig prime[];
+extern ubig *pr_limit; /* largest prime in the prime array */
+
+void pr_fact __P((ubig)); /* print factors of a value */
+void usage __P((void));
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ ubig val;
+ int ch;
+ char *p, buf[100]; /* > max number of digits. */
+
+ while ((ch = getopt(argc, argv, "")) != EOF)
+ switch (ch) {
+ case '?':
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ /* No args supplied, read numbers from stdin. */
+ if (argc == 0)
+ for (;;) {
+ if (fgets(buf, sizeof(buf), stdin) == NULL) {
+ if (ferror(stdin))
+ err(1, "stdin");
+ exit (0);
+ }
+ for (p = buf; isblank(*p); ++p);
+ if (*p == '\n' || *p == '\0')
+ continue;
+ if (*p == '-')
+ errx(1, "negative numbers aren't permitted.");
+ errno = 0;
+ val = strtoul(buf, &p, 10);
+ if (errno)
+ err(1, "%s", buf);
+ if (*p != '\n')
+ errx(1, "%s: illegal numeric format.", buf);
+ pr_fact(val);
+ }
+ /* Factor the arguments. */
+ else
+ for (; *argv != NULL; ++argv) {
+ if (argv[0][0] == '-')
+ errx(1, "negative numbers aren't permitted.");
+ errno = 0;
+ val = strtoul(argv[0], &p, 10);
+ if (errno)
+ err(1, "%s", argv[0]);
+ if (*p != '\0')
+ errx(1, "%s: illegal numeric format.", argv[0]);
+ pr_fact(val);
+ }
+ exit(0);
+}
+
+/*
+ * pr_fact - print the factors of a number
+ *
+ * If the number is 0 or 1, then print the number and return.
+ * If the number is < 0, print -1, negate the number and continue
+ * processing.
+ *
+ * Print the factors of the number, from the lowest to the highest.
+ * A factor will be printed numtiple times if it divides the value
+ * multiple times.
+ *
+ * Factors are printed with leading tabs.
+ */
+void
+pr_fact(val)
+ ubig val; /* Factor this value. */
+{
+ ubig *fact; /* The factor found. */
+
+ /* Firewall - catch 0 and 1. */
+ if (val == 0) /* Historical practice; 0 just exits. */
+ exit(0);
+ if (val == 1) {
+ (void)printf("1: 1\n");
+ return;
+ }
+
+ /* Factor value. */
+ (void)printf("%lu:", val);
+ for (fact = &prime[0]; val > 1; ++fact) {
+ /* Look for the smallest factor. */
+ do {
+ if (val % (long)*fact == 0)
+ break;
+ } while (++fact <= pr_limit);
+
+ /* Watch for primes larger than the table. */
+ if (fact > pr_limit) {
+ (void)printf(" %lu", val);
+ break;
+ }
+
+ /* Divide factor out until none are left. */
+ do {
+ (void)printf(" %lu", *fact);
+ val /= (long)*fact;
+ } while ((val % (long)*fact) == 0);
+
+ /* Let the user know we're doing something. */
+ (void)fflush(stdout);
+ }
+ (void)putchar('\n');
+}
+
+void
+usage()
+{
+ (void)fprintf(stderr, "usage: factor [value ...]\n");
+ exit (0);
+}
diff --git a/games/hack/hack.onames.h b/games/hack/hack.onames.h
new file mode 100644
index 0000000..c0fe81e
--- /dev/null
+++ b/games/hack/hack.onames.h
@@ -0,0 +1,227 @@
+#define STRANGE_OBJECT 0
+#define AMULET_OF_YENDOR 1
+#define FOOD_RATION 2
+#define TRIPE_RATION 3
+#define PANCAKE 4
+#define DEAD_LIZARD 5
+#define FORTUNE_COOKIE 6
+#define CARROT 7
+#define TIN 8
+#define ORANGE 9
+#define APPLE 10
+#define PEAR 11
+#define MELON 12
+#define BANANA 13
+#define CANDY_BAR 14
+#define EGG 15
+#define CLOVE_OF_GARLIC 16
+#define LUMP_OF_ROYAL_JELLY 17
+#define DEAD_HUMAN 18
+#define DEAD_GIANT_ANT 19
+#define DEAD_GIANT_BAT 20
+#define DEAD_CENTAUR 21
+#define DEAD_DRAGON 22
+#define DEAD_FLOATING_EYE 23
+#define DEAD_FREEZING_SPHERE 24
+#define DEAD_GNOME 25
+#define DEAD_HOBGOBLIN 26
+#define DEAD_STALKER 27
+#define DEAD_JACKAL 28
+#define DEAD_KOBOLD 29
+#define DEAD_LEPRECHAUN 30
+#define DEAD_MIMIC 31
+#define DEAD_NYMPH 32
+#define DEAD_ORC 33
+#define DEAD_PURPLE_WORM 34
+#define DEAD_QUASIT 35
+#define DEAD_RUST_MONSTER 36
+#define DEAD_SNAKE 37
+#define DEAD_TROLL 38
+#define DEAD_UMBER_HULK 39
+#define DEAD_VAMPIRE 40
+#define DEAD_WRAITH 41
+#define DEAD_XORN 42
+#define DEAD_YETI 43
+#define DEAD_ZOMBIE 44
+#define DEAD_ACID_BLOB 45
+#define DEAD_GIANT_BEETLE 46
+#define DEAD_COCKATRICE 47
+#define DEAD_DOG 48
+#define DEAD_ETTIN 49
+#define DEAD_FOG_CLOUD 50
+#define DEAD_GELATINOUS_CUBE 51
+#define DEAD_HOMUNCULUS 52
+#define DEAD_IMP 53
+#define DEAD_JAGUAR 54
+#define DEAD_KILLER_BEE 55
+#define DEAD_LEOCROTTA 56
+#define DEAD_MINOTAUR 57
+#define DEAD_NURSE 58
+#define DEAD_OWLBEAR 59
+#define DEAD_PIERCER 60
+#define DEAD_QUIVERING_BLOB 61
+#define DEAD_GIANT_RAT 62
+#define DEAD_GIANT_SCORPION 63
+#define DEAD_TENGU 64
+#define DEAD_UNICORN 65
+#define DEAD_VIOLET_FUNGI 66
+#define DEAD_LONG_WORM 67
+#define DEAD_XAN 68
+#define DEAD_YELLOW_LIGHT 69
+#define DEAD_ZRUTY 70
+#define ARROW 71
+#define SLING_BULLET 72
+#define CROSSBOW_BOLT 73
+#define DART 74
+#define ROCK 75
+#define BOOMERANG 76
+#define MACE 77
+#define AXE 78
+#define FLAIL 79
+#define LONG_SWORD 80
+#define TWO_HANDED_SWORD 81
+#define DAGGER 82
+#define WORM_TOOTH 83
+#define CRYSKNIFE 84
+#define SPEAR 85
+#define BOW 86
+#define SLING 87
+#define CROSSBOW 88
+#define WHISTLE 89
+#define MAGIC_WHISTLE 90
+#define EXPENSIVE_CAMERA 91
+#define ICE_BOX 92
+#define PICK_AXE 93
+#define CAN_OPENER 94
+#define HEAVY_IRON_BALL 95
+#define IRON_CHAIN 96
+#define ENORMOUS_ROCK 97
+#define HELMET 98
+#define PLATE_MAIL 99
+#define SPLINT_MAIL 100
+#define BANDED_MAIL 101
+#define CHAIN_MAIL 102
+#define SCALE_MAIL 103
+#define RING_MAIL 104
+#define STUDDED_LEATHER_ARMOR 105
+#define LEATHER_ARMOR 106
+#define ELVEN_CLOAK 107
+#define SHIELD 108
+#define PAIR_OF_GLOVES 109
+#define POT_RESTORE_STRENGTH 110
+#define POT_BOOZE 111
+#define POT_INVISIBILITY 112
+#define POT_FRUIT_JUICE 113
+#define POT_HEALING 114
+#define POT_PARALYSIS 115
+#define POT_MONSTER_DETECTION 116
+#define POT_OBJECT_DETECTION 117
+#define POT_SICKNESS 118
+#define POT_CONFUSION 119
+#define POT_GAIN_STRENGTH 120
+#define POT_SPEED 121
+#define POT_BLINDNESS 122
+#define POT_GAIN_LEVEL 123
+#define POT_EXTRA_HEALING 124
+#define POT_LEVITATION 125
+#define SCR_MAIL 130
+#define SCR_ENCHANT_ARMOR 131
+#define SCR_DESTROY_ARMOR 132
+#define SCR_CONFUSE_MONSTER 133
+#define SCR_SCARE_MONSTER 134
+#define SCR_BLANK_PAPER 135
+#define SCR_REMOVE_CURSE 136
+#define SCR_ENCHANT_WEAPON 137
+#define SCR_DAMAGE_WEAPON 138
+#define SCR_CREATE_MONSTER 139
+#define SCR_TAMING 140
+#define SCR_GENOCIDE 141
+#define SCR_LIGHT 142
+#define SCR_TELEPORTATION 143
+#define SCR_GOLD_DETECTION 144
+#define SCR_FOOD_DETECTION 145
+#define SCR_IDENTIFY 146
+#define SCR_MAGIC_MAPPING 147
+#define SCR_AMNESIA 148
+#define SCR_FIRE 149
+#define SCR_PUNISHMENT 150
+#define WAN_LIGHT 155
+#define WAN_SECRET_DOOR_DETECTION 156
+#define WAN_CREATE_MONSTER 157
+#define WAN_WISHING 158
+#define WAN_STRIKING 159
+#define WAN_SLOW_MONSTER 160
+#define WAN_SPEED_MONSTER 161
+#define WAN_UNDEAD_TURNING 162
+#define WAN_POLYMORPH 163
+#define WAN_CANCELLATION 164
+#define WAN_TELEPORTATION 165
+#define WAN_MAKE_INVISIBLE 166
+#define WAN_DIGGING 167
+#define WAN_MAGIC_MISSILE 168
+#define WAN_FIRE 169
+#define WAN_SLEEP 170
+#define WAN_COLD 171
+#define WAN_DEATH 172
+#define Adornment u.uprops[0].p_flgs
+#define RIN_ADORNMENT 176
+#define Teleportation u.uprops[1].p_flgs
+#define RIN_TELEPORTATION 177
+#define Regeneration u.uprops[2].p_flgs
+#define RIN_REGENERATION 178
+#define Searching u.uprops[3].p_flgs
+#define RIN_SEARCHING 179
+#define See_invisible u.uprops[4].p_flgs
+#define RIN_SEE_INVISIBLE 180
+#define Stealth u.uprops[5].p_flgs
+#define RIN_STEALTH 181
+#define Levitation u.uprops[6].p_flgs
+#define RIN_LEVITATION 182
+#define Poison_resistance u.uprops[7].p_flgs
+#define RIN_POISON_RESISTANCE 183
+#define Aggravate_monster u.uprops[8].p_flgs
+#define RIN_AGGRAVATE_MONSTER 184
+#define Hunger u.uprops[9].p_flgs
+#define RIN_HUNGER 185
+#define Fire_resistance u.uprops[10].p_flgs
+#define RIN_FIRE_RESISTANCE 186
+#define Cold_resistance u.uprops[11].p_flgs
+#define RIN_COLD_RESISTANCE 187
+#define Protection_from_shape_changers u.uprops[12].p_flgs
+#define RIN_PROTECTION_FROM_SHAPE_CHANGERS 188
+#define Conflict u.uprops[13].p_flgs
+#define RIN_CONFLICT 189
+#define Gain_strength u.uprops[14].p_flgs
+#define RIN_GAIN_STRENGTH 190
+#define Increase_damage u.uprops[15].p_flgs
+#define RIN_INCREASE_DAMAGE 191
+#define Protection u.uprops[16].p_flgs
+#define RIN_PROTECTION 192
+#define Warning u.uprops[17].p_flgs
+#define RIN_WARNING 193
+#define Teleport_control u.uprops[18].p_flgs
+#define RIN_TELEPORT_CONTROL 194
+#define DIAMOND 197
+#define RUBY 198
+#define SAPPHIRE 199
+#define EMERALD 200
+#define TURQUOISE 201
+#define AQUAMARINE 202
+#define TOURMALINE 203
+#define TOPAZ 204
+#define OPAL 205
+#define GARNET 206
+#define AMETHYST 207
+#define AGATE 208
+#define ONYX 209
+#define JASPER 210
+#define JADE 211
+/* #define WORTHLESS_PIECE_OF_BLUE_GLASS 212 */
+/* #define WORTHLESS_PIECE_OF_RED_GLASS 213 */
+/* #define WORTHLESS_PIECE_OF_YELLOW_GLASS 214 */
+/* #define WORTHLESS_PIECE_OF_GREEN_GLASS 215 */
+
+#define CORPSE DEAD_HUMAN
+#define LAST_GEM (JADE+1)
+#define LAST_RING 19
+#define NROFOBJECTS 215
diff --git a/games/monop/Makefile b/games/monop/Makefile
new file mode 100644
index 0000000..a1e8f2d
--- /dev/null
+++ b/games/monop/Makefile
@@ -0,0 +1,26 @@
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
+
+PROG= monop
+SRCS= monop.c cards.c execute.c getinp.c houses.c jail.c misc.c morg.c \
+ print.c prop.c rent.c roll.c spec.c trade.c
+MAN6= monop.6
+DPADD= ${LIBCOMPAT}
+LDADD= -lcompat
+HIDEGAME=hidegame
+CLEANFILES+=initdeck cards.pck
+
+all: ${PROG} ${MAN6}
+
+monop: cards.pck
+
+cards.pck: initdeck
+ ./initdeck ${.CURDIR}/cards.inp
+
+initdeck: initdeck.c
+ ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/initdeck.c
+
+beforeinstall:
+ install -c -o ${BINOWN} -g ${BINGRP} -m 444 cards.pck \
+ ${DESTDIR}/usr/share/games
+
+.include <bsd.prog.mk>
diff --git a/games/monop/brd.dat b/games/monop/brd.dat
new file mode 100644
index 0000000..ff8498d
--- /dev/null
+++ b/games/monop/brd.dat
@@ -0,0 +1,78 @@
+/*-
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)brd.dat 5.5 (Berkeley) 5/31/93
+ */
+
+/* name (COLOR) owner type desc cost */
+
+{"=== GO ===", -1, SAFE, 0 },
+{"Mediterranean ave. (P)", -1, PRPTY, &prop[0], 60 },
+{"Community Chest i", -1, CC, },
+{"Baltic ave. (P)", -1, PRPTY, &prop[1], 60 },
+{"Income Tax", -1, INC_TAX, },
+{"Reading RR", -1, RR, &rr[0], 200 },
+{"Oriental ave. (L)", -1, PRPTY, &prop[2], 100 },
+{"Chance i", -1, CHANCE, },
+{"Vermont ave. (L)", -1, PRPTY, &prop[3], 100 },
+{"Connecticut ave. (L)", -1, PRPTY, &prop[4], 120 },
+{"Just Visiting", -1, SAFE, 0 },
+{"St. Charles pl. (V)", -1, PRPTY, &prop[5], 140 },
+{"Electric Co.", -1, UTIL, &util[0], 150 },
+{"States ave. (V)", -1, PRPTY, &prop[6], 140 },
+{"Virginia ave. (V)", -1, PRPTY, &prop[7], 160 },
+{"Pennsylvania RR", -1, RR, &rr[1], 200 },
+{"St. James pl. (O)", -1, PRPTY, &prop[8], 180 },
+{"Community Chest ii", -1, CC, },
+{"Tennessee ave. (O)", -1, PRPTY, &prop[9], 180 },
+{"New York ave. (O)", -1, PRPTY, &prop[10], 200 },
+{"Free Parking", -1, SAFE, 0 },
+{"Kentucky ave. (R)", -1, PRPTY, &prop[11], 220 },
+{"Chance ii", -1, CHANCE, },
+{"Indiana ave. (R)", -1, PRPTY, &prop[12], 220 },
+{"Illinois ave. (R)", -1, PRPTY, &prop[13], 240 },
+{"B&O RR", -1, RR, &rr[2], 200 },
+{"Atlantic ave. (Y)", -1, PRPTY, &prop[14], 260 },
+{"Ventnor ave. (Y)", -1, PRPTY, &prop[15], 260 },
+{"Water Works", -1, UTIL, &util[1], 150 },
+{"Marvin Gardens (Y)", -1, PRPTY, &prop[16], 280 },
+{"GO TO JAIL", -1, GOTO_J, },
+{"Pacific ave. (G)", -1, PRPTY, &prop[17], 300 },
+{"N. Carolina ave. (G)", -1, PRPTY, &prop[18], 300 },
+{"Community Chest iii", -1, CC, },
+{"Pennsylvania ave. (G)", -1, PRPTY, &prop[19], 320 },
+{"Short Line RR", -1, RR, &rr[3], 200 },
+{"Chance iii", -1, CHANCE, },
+{"Park place (D)", -1, PRPTY, &prop[20], 350 },
+{"Luxury Tax", -1, LUX_TAX, },
+{"Boardwalk (D)", -1, PRPTY, &prop[21], 400 },
+{"JAIL", -1, IN_JAIL, }
diff --git a/games/monop/cards.c b/games/monop/cards.c
new file mode 100644
index 0000000..7424820
--- /dev/null
+++ b/games/monop/cards.c
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.ext"
+# include "pathnames.h"
+
+/*
+ * These routine deal with the card decks
+ */
+
+# define GOJF 'F' /* char for get-out-of-jail-free cards */
+
+# ifndef DEV
+static char *cardfile = _PATH_CARDS;
+# else
+static char *cardfile = "cards.pck";
+# endif
+
+static FILE *deckf;
+
+/*
+ * This routine initializes the decks from the data file,
+ * which it opens.
+ */
+init_decks() {
+
+ if ((deckf=fopen(cardfile, "r")) == NULL) {
+file_err:
+ perror(cardfile);
+ exit(1);
+ }
+ if (fread(deck, sizeof (DECK), 2, deckf) != 2)
+ goto file_err;
+ set_up(&CC_D);
+ set_up(&CH_D);
+}
+/*
+ * This routine sets up the offset pointers for the given deck.
+ */
+set_up(dp)
+DECK *dp; {
+
+ reg int r1, r2;
+ int i;
+
+ dp->offsets = (long *) calloc(sizeof (long), dp->num_cards);
+ if (fread(dp->offsets, sizeof(long), dp->num_cards, deckf) != dp->num_cards) {
+ perror(cardfile);
+ exit(1);
+ }
+ dp->last_card = 0;
+ dp->gojf_used = FALSE;
+ for (i = 0; i < dp->num_cards; i++) {
+ reg long temp;
+
+ r1 = roll(1, dp->num_cards) - 1;
+ r2 = roll(1, dp->num_cards) - 1;
+ temp = dp->offsets[r2];
+ dp->offsets[r2] = dp->offsets[r1];
+ dp->offsets[r1] = temp;
+ }
+}
+/*
+ * This routine draws a card from the given deck
+ */
+get_card(dp)
+DECK *dp; {
+
+ reg char type_maj, type_min;
+ reg int num;
+ int i, per_h, per_H, num_h, num_H;
+ OWN *op;
+
+ do {
+ fseek(deckf, dp->offsets[dp->last_card], 0);
+ dp->last_card = ++(dp->last_card) % dp->num_cards;
+ type_maj = getc(deckf);
+ } while (dp->gojf_used && type_maj == GOJF);
+ type_min = getc(deckf);
+ num = getw(deckf);
+ printmes();
+ switch (type_maj) {
+ case '+': /* get money */
+ if (type_min == 'A') {
+ for (i = 0; i < num_play; i++)
+ if (i != player)
+ play[i].money -= num;
+ num = num * (num_play - 1);
+ }
+ cur_p->money += num;
+ break;
+ case '-': /* lose money */
+ if (type_min == 'A') {
+ for (i = 0; i < num_play; i++)
+ if (i != player)
+ play[i].money += num;
+ num = num * (num_play - 1);
+ }
+ cur_p->money -= num;
+ break;
+ case 'M': /* move somewhere */
+ switch (type_min) {
+ case 'F': /* move forward */
+ num -= cur_p->loc;
+ if (num < 0)
+ num += 40;
+ break;
+ case 'J': /* move to jail */
+ goto_jail();
+ return;
+ case 'R': /* move to railroad */
+ spec = TRUE;
+ num = (int)((cur_p->loc + 5)/10)*10 + 5 - cur_p->loc;
+ break;
+ case 'U': /* move to utility */
+ spec = TRUE;
+ if (cur_p->loc >= 12 && cur_p->loc < 28)
+ num = 28 - cur_p->loc;
+ else {
+ num = 12 - cur_p->loc;
+ if (num < 0)
+ num += 40;
+ }
+ break;
+ case 'B':
+ num = -num;
+ break;
+ }
+ move(num);
+ break;
+ case 'T': /* tax */
+ if (dp == &CC_D) {
+ per_h = 40;
+ per_H = 115;
+ }
+ else {
+ per_h = 25;
+ per_H = 100;
+ }
+ num_h = num_H = 0;
+ for (op = cur_p->own_list; op; op = op->next)
+ if (op->sqr->type == PRPTY)
+ if (op->sqr->desc->houses == 5)
+ ++num_H;
+ else
+ num_h += op->sqr->desc->houses;
+ num = per_h * num_h + per_H * num_H;
+ printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
+ if (num == 0)
+ lucky("");
+ else
+ cur_p->money -= num;
+ break;
+ case GOJF: /* get-out-of-jail-free card */
+ cur_p->num_gojf++;
+ dp->gojf_used = TRUE;
+ break;
+ }
+ spec = FALSE;
+}
+/*
+ * This routine prints out the message on the card
+ */
+printmes() {
+
+ reg char c;
+
+ printline();
+ fflush(stdout);
+ while ((c = getc(deckf)) != '\0')
+ putchar(c);
+ printline();
+ fflush(stdout);
+}
diff --git a/games/monop/cards.inp b/games/monop/cards.inp
new file mode 100644
index 0000000..1867e87
--- /dev/null
+++ b/games/monop/cards.inp
@@ -0,0 +1,122 @@
+FF
+>> GET OUT OF JAIL FREE <<
+Keep this card until needed or sold
+%%
+++25
+Receive for Services $25.
+%%
+++200
+Bank Error in Your Favor.
+Collect $200.
+%%
+++20
+Income Tax Refund.
+Collect $20.
+%%
+--100
+Pay Hospital $100
+%%
+++100
+Life Insurance Matures.
+Collect $100
+%%
+++45
+From sale of Stock You get $45.
+%%
+TX
+You are Assessed for street repairs.
+ $40 per House
+ $115 per Hotel
+%%
+++100
+X-mas Fund Matures.
+Collect $100.
+%%
+++11
+You have won Second Prize in a Beauty Contest
+Collect $11
+%%
+MF0
+Advance to GO
+(Collect $200)
+%%
+++100
+You inherit $100
+%%
+--150
+Pay School Tax of $150.
+%%
+MJ
+ >> GO TO JAIL <<
+Go Directly to Jail. Do not pass GO Do not collect $200.
+%%
++A50
+ >> GRAND OPERA OPENING <<
+Collect $50 from each player for opening night seats.
+%%
+--50
+Doctor's Fee: Pay $50.
+%-
+FF
+>> GET OUT OF JAIL FREE <<
+Keep this card until needed or sold
+%%
+MR
+Advance to the nearest Railroad, and pay owner
+Twice the rental to which he is otherwise entitled.
+If Railroad is unowned you may buy it from the bank
+%%
+MU
+Advance to the nearest Utility.
+If unowned, you may buy it from the bank.
+If owned, throw dice and pay oner a total of ten times
+the amount thrown.
+%%
+MB3
+Go Back 3 Spaces
+%%
+MR
+Advance to the nearest Railroad, and pay owner
+Twice the rental to which he is otherwise entitled.
+If Railroad is unowned you may buy it from the bank
+%%
+MJ
+ >> GO DIRECTLY TO JAIL <<
+Do not pass GO, Do not Collect $200.
+%%
+MF5
+Take a Ride on the Reading.
+If you pass GO, collect $200.
+%%
+MF39
+Take a Walk on the Board Walk.
+ (Advance To Board Walk)
+%%
+MF24
+Advance to Illinos Ave.
+%%
+MF0
+Advance to Go
+%%
+MF11
+Advance to St. Charles Place.
+If you pass GO, collect $200.
+%%
+TX
+Make general repairs on all of your Property.
+For Each House pay $25.
+For Each Hotel pay $100.
+%%
+-A50
+You have been elected Chairman of the Board.
+Pay each player $50.
+%%
+--15
+Pay Poor Tax of $15
+%%
+++50
+Bank pays you Dividend of $50.
+%%
+++150
+Your Building and Loan Matures.
+Collect $150.
diff --git a/games/monop/deck.h b/games/monop/deck.h
new file mode 100644
index 0000000..604937d
--- /dev/null
+++ b/games/monop/deck.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)deck.h 8.1 (Berkeley) 5/31/93
+ */
+
+# define bool char
+
+# define CC_D deck[0]
+# define CH_D deck[1]
+
+struct dk_st { /* deck description structure */
+ int num_cards; /* number of cards in deck */
+ int last_card; /* number of last card picked */
+ bool gojf_used; /* set if gojf card out of deck */
+ long *offsets; /* offests for start of cards */
+};
+
+typedef struct dk_st DECK;
diff --git a/games/monop/execute.c b/games/monop/execute.c
new file mode 100644
index 0000000..f770432
--- /dev/null
+++ b/games/monop/execute.c
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)execute.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.ext"
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <sys/time.h>
+
+# define SEGSIZE 8192
+
+typedef struct stat STAT;
+typedef struct tm TIME;
+
+extern char etext[], /* end of text space */
+ rub();
+
+static char buf[257],
+ *yn_only[] = { "yes", "no"};
+
+static bool new_play; /* set if move on to new player */
+
+/*
+ * This routine executes the given command by index number
+ */
+execute(com_num)
+reg int com_num; {
+
+ new_play = FALSE; /* new_play is true if fixing */
+ (*func[com_num])();
+ notify();
+ force_morg();
+ if (new_play)
+ next_play();
+ else if (num_doub)
+ printf("%s rolled doubles. Goes again\n", cur_p->name);
+}
+/*
+ * This routine moves a piece around.
+ */
+do_move() {
+
+ reg int r1, r2;
+ reg bool was_jail;
+
+ new_play = was_jail = FALSE;
+ printf("roll is %d, %d\n", r1=roll(1, 6), r2=roll(1, 6));
+ if (cur_p->loc == JAIL) {
+ was_jail++;
+ if (!move_jail(r1, r2)) {
+ new_play++;
+ goto ret;
+ }
+ }
+ else {
+ if (r1 == r2 && ++num_doub == 3) {
+ printf("That's 3 doubles. You go to jail\n");
+ goto_jail();
+ new_play++;
+ goto ret;
+ }
+ move(r1+r2);
+ }
+ if (r1 != r2 || was_jail)
+ new_play++;
+ret:
+ return;
+}
+/*
+ * This routine moves a normal move
+ */
+move(rl)
+reg int rl; {
+
+ reg int old_loc;
+
+ old_loc = cur_p->loc;
+ cur_p->loc = (cur_p->loc + rl) % N_SQRS;
+ if (cur_p->loc < old_loc && rl > 0) {
+ cur_p->money += 200;
+ printf("You pass %s and get $200\n", board[0].name);
+ }
+ show_move();
+}
+/*
+ * This routine shows the results of a move
+ */
+show_move() {
+
+ reg SQUARE *sqp;
+
+ sqp = &board[cur_p->loc];
+ printf("That puts you on %s\n", sqp->name);
+ switch (sqp->type) {
+ case SAFE:
+ printf("That is a safe place\n");
+ break;
+ case CC:
+ cc(); break;
+ case CHANCE:
+ chance(); break;
+ case INC_TAX:
+ inc_tax(); break;
+ case GOTO_J:
+ goto_jail(); break;
+ case LUX_TAX:
+ lux_tax(); break;
+ case PRPTY:
+ case RR:
+ case UTIL:
+ if (sqp->owner < 0) {
+ printf("That would cost $%d\n", sqp->cost);
+ if (getyn("Do you want to buy? ") == 0) {
+ buy(player, sqp);
+ cur_p->money -= sqp->cost;
+ }
+ else if (num_play > 2)
+ bid(sqp);
+ }
+ else if (sqp->owner == player)
+ printf("You own it.\n");
+ else
+ rent(sqp);
+ }
+}
+/*
+ * This routine saves the current game for use at a later date
+ */
+save() {
+
+ reg char *sp;
+ reg int outf, num;
+ time_t t;
+ int *dat_end;
+ struct stat sb;
+ unsgn start, end;
+
+ printf("Which file do you wish to save it in? ");
+ sp = buf;
+ while ((*sp++=getchar()) != '\n')
+ continue;
+ *--sp = '\0';
+
+ /*
+ * check for existing files, and confirm overwrite if needed
+ */
+
+ if (stat(buf, &sb) > -1
+ && getyn("File exists. Do you wish to overwrite? ", yn_only) > 0)
+ return;
+
+ if ((outf=creat(buf, 0644)) < 0) {
+ perror(buf);
+ return;
+ }
+ printf("\"%s\" ", buf);
+ time(&t); /* get current time */
+ strcpy(buf, ctime(&t));
+ for (sp = buf; *sp != '\n'; sp++)
+ continue;
+ *sp = '\0';
+# if 0
+ start = (((int) etext + (SEGSIZE-1)) / SEGSIZE ) * SEGSIZE;
+# else
+ start = 0;
+# endif
+ end = sbrk(0);
+ while (start < end) { /* write out entire data space */
+ num = start + 16 * 1024 > end ? end - start : 16 * 1024;
+ write(outf, start, num);
+ start += num;
+ }
+ close(outf);
+ printf("[%s]\n", buf);
+}
+/*
+ * This routine restores an old game from a file
+ */
+restore() {
+
+ reg char *sp;
+
+ printf("Which file do you wish to restore from? ");
+ for (sp = buf; (*sp=getchar()) != '\n'; sp++)
+ continue;
+ *sp = '\0';
+ rest_f(buf);
+}
+/*
+ * This does the actual restoring. It returns TRUE if the
+ * backup was successful, else false.
+ */
+rest_f(file)
+reg char *file; {
+
+ reg char *sp;
+ reg int inf, num;
+ char buf[80];
+ unsgn start, end;
+ STAT sbuf;
+
+ if ((inf=open(file, 0)) < 0) {
+ perror(file);
+ return FALSE;
+ }
+ printf("\"%s\" ", file);
+ if (fstat(inf, &sbuf) < 0) { /* get file stats */
+ perror(file);
+ exit(1);
+ }
+# if 0
+ start = (((int) etext + (SEGSIZE-1)) / SEGSIZE ) * SEGSIZE;
+# else
+ start = 0;
+# endif
+ brk(end = start + sbuf.st_size);
+ while (start < end) { /* write out entire data space */
+ num = start + 16 * 1024 > end ? end - start : 16 * 1024;
+ read(inf, start, num);
+ start += num;
+ }
+ close(inf);
+ strcpy(buf, ctime(&sbuf.st_mtime));
+ for (sp = buf; *sp != '\n'; sp++)
+ continue;
+ *sp = '\0';
+ printf("[%s]\n", buf);
+ return TRUE;
+}
diff --git a/games/monop/getinp.c b/games/monop/getinp.c
new file mode 100644
index 0000000..3a4b9d7
--- /dev/null
+++ b/games/monop/getinp.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)getinp.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include <stdio.h>
+# include <ctype.h>
+
+# define reg register
+
+# define LINE 70
+
+static char buf[257];
+
+getinp(prompt, list)
+char *prompt, *list[]; {
+
+ reg int i, n_match, match;
+ char *sp;
+ int plen;
+ static int comp();
+
+ for (;;) {
+inter:
+ printf(prompt);
+ for (sp = buf; (*sp=getchar()) != '\n'; )
+ if (*sp == -1) /* check for interupted system call */
+ goto inter;
+ else if (sp != buf || *sp != ' ')
+ sp++;
+ if (buf[0] == '?' && buf[1] == '\n') {
+ printf("Valid inputs are: ");
+ for (i = 0, match = 18; list[i]; i++) {
+ if ((match+=(n_match=strlen(list[i]))) > LINE) {
+ printf("\n\t");
+ match = n_match + 8;
+ }
+ if (*list[i] == '\0') {
+ match += 8;
+ printf("<RETURN>");
+ }
+ else
+ printf(list[i]);
+ if (list[i+1])
+ printf(", ");
+ else
+ putchar('\n');
+ match += 2;
+ }
+ continue;
+ }
+ *sp = '\0';
+ for (sp = buf; *sp; sp++)
+ if (isupper(*sp))
+ *sp = tolower(*sp);
+ for (i = n_match = 0; list[i]; i++)
+ if (comp(list[i])) {
+ n_match++;
+ match = i;
+ }
+ if (n_match == 1)
+ return match;
+ else if (buf[0] != '\0')
+ printf("Illegal response: \"%s\". Use '?' to get list of valid answers\n", buf);
+ }
+}
+
+static
+comp(s1)
+char *s1; {
+
+ reg char *sp, *tsp, c;
+
+ if (buf[0] != '\0')
+ for (sp = buf, tsp = s1; *sp; ) {
+ c = isupper(*tsp) ? tolower(*tsp) : *tsp;
+ tsp++;
+ if (c != *sp++)
+ return 0;
+ }
+ else if (*s1 != '\0')
+ return 0;
+ return 1;
+}
diff --git a/games/monop/houses.c b/games/monop/houses.c
new file mode 100644
index 0000000..5134c20
--- /dev/null
+++ b/games/monop/houses.c
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)houses.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.ext"
+
+static char *names[N_MON+2],
+ cur_prop[80];
+
+static MON *monops[N_MON];
+
+/*
+ * These routines deal with buying and selling houses
+ */
+buy_houses() {
+
+ reg int num_mon;
+ reg MON *mp;
+ reg OWN *op;
+ bool good,got_morg;
+ int i,p;
+
+over:
+ num_mon = 0;
+ good = TRUE;
+ got_morg = FALSE;
+ for (op = cur_p->own_list; op && op->sqr->type != PRPTY; op = op->next)
+ continue;
+ while (op)
+ if (op->sqr->desc->monop) {
+ mp = op->sqr->desc->mon_desc;
+ names[num_mon] = (monops[num_mon]=mp)->name;
+ num_mon++;
+ got_morg = good = FALSE;
+ for (i = 0; i < mp->num_in; i++) {
+ if (op->sqr->desc->morg)
+ got_morg++;
+ if (op->sqr->desc->houses != 5)
+ good++;
+ op = op->next;
+ }
+ if (!good || got_morg)
+ --num_mon;
+ }
+ else
+ op = op->next;
+ if (num_mon == 0) {
+ if (got_morg)
+ printf("You can't build on mortgaged monopolies.\n");
+ else if (!good)
+ printf("You can't build any more.\n");
+ else
+ printf("But you don't have any monopolies!!\n");
+ return;
+ }
+ if (num_mon == 1)
+ buy_h(monops[0]);
+ else {
+ names[num_mon++] = "done";
+ names[num_mon--] = 0;
+ if ((p=getinp("Which property do you wish to buy houses for? ", names)) == num_mon)
+ return;
+ buy_h(monops[p]);
+ goto over;
+ }
+}
+
+buy_h(mnp)
+MON *mnp; {
+
+ reg int i;
+ reg MON *mp;
+ reg int price;
+ shrt input[3],temp[3];
+ int tot;
+ PROP *pp;
+
+ mp = mnp;
+ price = mp->h_cost * 50;
+blew_it:
+ list_cur(mp);
+ printf("Houses will cost $%d\n", price);
+ printf("How many houses do you wish to buy for\n");
+ for (i = 0; i < mp->num_in; i++) {
+ pp = mp->sq[i]->desc;
+over:
+ if (pp->houses == 5) {
+ printf("%s (H):\n", mp->sq[i]->name);
+ input[i] = 0;
+ temp[i] = 5;
+ continue;
+ }
+ (void)sprintf(cur_prop, "%s (%d): ",
+ mp->sq[i]->name, pp->houses);
+ input[i] = get_int(cur_prop);
+ temp[i] = input[i] + pp->houses;
+ if (temp[i] > 5) {
+ printf("That's too many. The most you can buy is %d\n",
+ 5 - pp->houses);
+ goto over;
+ }
+ }
+ if (mp->num_in == 3 && (abs(temp[0] - temp[1]) > 1 ||
+ abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
+err: printf("That makes the spread too wide. Try again\n");
+ goto blew_it;
+ }
+ else if (mp->num_in == 2 && abs(temp[0] - temp[1]) > 1)
+ goto err;
+ for (tot = i = 0; i < mp->num_in; i++)
+ tot += input[i];
+ if (tot) {
+ printf("You asked for %d houses for $%d\n", tot, tot * price);
+ if (getyn("Is that ok? ", yn) == 0) {
+ cur_p->money -= tot * price;
+ for (tot = i = 0; i < mp->num_in; i++)
+ mp->sq[i]->desc->houses = temp[i];
+ }
+ }
+}
+
+/*
+ * This routine sells houses.
+ */
+sell_houses() {
+
+ reg int num_mon;
+ reg MON *mp;
+ reg OWN *op;
+ bool good;
+ int p;
+
+over:
+ num_mon = 0;
+ good = TRUE;
+ for (op = cur_p->own_list; op; op = op->next)
+ if (op->sqr->type == PRPTY && op->sqr->desc->monop) {
+ mp = op->sqr->desc->mon_desc;
+ names[num_mon] = (monops[num_mon]=mp)->name;
+ num_mon++;
+ good = 0;
+ do
+ if (!good && op->sqr->desc->houses != 0)
+ good++;
+ while (op->next && op->sqr->desc->mon_desc == mp
+ && (op=op->next));
+ if (!good)
+ --num_mon;
+ }
+ if (num_mon == 0) {
+ printf("You don't have any houses to sell!!\n");
+ return;
+ }
+ if (num_mon == 1)
+ sell_h(monops[0]);
+ else {
+ names[num_mon++] = "done";
+ names[num_mon--] = 0;
+ if ((p=getinp("Which property do you wish to sell houses from? ", names)) == num_mon)
+ return;
+ sell_h(monops[p]);
+ notify();
+ goto over;
+ }
+}
+
+sell_h(mnp)
+MON *mnp; {
+
+ reg int i;
+ reg MON *mp;
+ reg int price;
+ shrt input[3],temp[3];
+ int tot;
+ PROP *pp;
+
+ mp = mnp;
+ price = mp->h_cost * 25;
+blew_it:
+ printf("Houses will get you $%d apiece\n", price);
+ list_cur(mp);
+ printf("How many houses do you wish to sell from\n");
+ for (i = 0; i < mp->num_in; i++) {
+ pp = mp->sq[i]->desc;
+over:
+ if (pp->houses == 0) {
+ printf("%s (0):\n", mp->sq[i]->name);
+ input[i] = temp[i] = 0;
+ continue;
+ }
+ if (pp->houses < 5)
+ (void)sprintf(cur_prop,"%s (%d): ",
+ mp->sq[i]->name,pp->houses);
+ else
+ (void)sprintf(cur_prop,"%s (H): ",mp->sq[i]->name);
+ input[i] = get_int(cur_prop);
+ temp[i] = pp->houses - input[i];
+ if (temp[i] < 0) {
+ printf("That's too many. The most you can sell is %d\n", pp->houses);
+ goto over;
+ }
+ }
+ if (mp->num_in == 3 && (abs(temp[0] - temp[1]) > 1 ||
+ abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) {
+err: printf("That makes the spread too wide. Try again\n");
+ goto blew_it;
+ }
+ else if (mp->num_in == 2 && abs(temp[0] - temp[1]) > 1)
+ goto err;
+ for (tot = i = 0; i < mp->num_in; i++)
+ tot += input[i];
+ if (tot) {
+ printf("You asked to sell %d houses for $%d\n",tot,tot * price);
+ if (getyn("Is that ok? ", yn) == 0) {
+ cur_p->money += tot * price;
+ for (tot = i = 0; i < mp->num_in; i++)
+ mp->sq[i]->desc->houses = temp[i];
+ }
+ }
+}
+
+list_cur(mp)
+reg MON *mp; {
+
+ reg int i;
+ reg SQUARE *sqp;
+
+ for (i = 0; i < mp->num_in; i++) {
+ sqp = mp->sq[i];
+ if (sqp->desc->houses == 5)
+ printf("%s (H) ", sqp->name);
+ else
+ printf("%s (%d) ", sqp->name, sqp->desc->houses);
+ }
+ putchar('\n');
+}
diff --git a/games/monop/initdeck.c b/games/monop/initdeck.c
new file mode 100644
index 0000000..87b64f4
--- /dev/null
+++ b/games/monop/initdeck.c
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1980, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)initdeck.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include <stdio.h>
+# include "deck.h"
+
+/*
+ * This program initializes the card files for monopoly.
+ * It reads in a data file with Com. Chest cards, followed by
+ * the Chance card. The two are seperated by a line of "%-".
+ * All other cards are seperated by lines of "%%". In the front
+ * of the file is the data for the decks in the same order.
+ * This includes the seek pointer for the start of each card.
+ * All cards start with their execution code, followed by the
+ * string to print, terminated with a null byte.
+ */
+
+# define TRUE 1
+# define FALSE 0
+
+# define bool char
+# define reg register
+
+char *infile = "cards.inp", /* input file */
+ *outfile = "cards.pck"; /* "packed" file */
+
+extern long ftell();
+extern char *calloc();
+
+DECK deck[2];
+
+FILE *inf, *outf;
+
+main(ac, av)
+int ac;
+char *av[]; {
+
+ getargs(ac, av);
+ if ((inf = fopen(infile, "r")) == NULL) {
+ perror(infile);
+ exit(1);
+ }
+ count();
+ /*
+ * allocate space for pointers.
+ */
+ CC_D.offsets = (long *)calloc(CC_D.num_cards + 1, sizeof (long));
+ CH_D.offsets = (long *)calloc(CH_D.num_cards + 1, sizeof (long));
+ fseek(inf, 0L, 0);
+ if ((outf = fopen(outfile, "w")) == NULL) {
+ perror(outfile);
+ exit(0);
+ }
+
+ fwrite(deck, sizeof (DECK), 2, outf);
+ fwrite(CC_D.offsets, sizeof (long), CC_D.num_cards, outf);
+ fwrite(CH_D.offsets, sizeof (long), CH_D.num_cards, outf);
+ putem();
+
+ fclose(inf);
+ fseek(outf, 0, 0L);
+ fwrite(deck, sizeof (DECK), 2, outf);
+ fwrite(CC_D.offsets, sizeof (long), CC_D.num_cards, outf);
+ fwrite(CH_D.offsets, sizeof (long), CH_D.num_cards, outf);
+ fclose(outf);
+ printf("There were %d com. chest and %d chance cards\n", CC_D.num_cards, CH_D.num_cards);
+ exit(0);
+}
+
+getargs(ac, av)
+int ac;
+char *av[]; {
+
+ if (ac > 1)
+ infile = av[1];
+ if (ac > 2)
+ outfile = av[2];
+}
+
+/*
+ * count the cards
+ */
+count() {
+
+ reg bool newline;
+ reg DECK *in_deck;
+ reg char c;
+
+ newline = TRUE;
+ in_deck = &CC_D;
+ while ((c=getc(inf)) != EOF)
+ if (newline && c == '%') {
+ newline = FALSE;
+ in_deck->num_cards++;
+ if (getc(inf) == '-')
+ in_deck = &CH_D;
+ }
+ else
+ newline = (c == '\n');
+ in_deck->num_cards++;
+}
+/*
+ * put strings in the file
+ */
+putem() {
+
+ reg bool newline;
+ reg DECK *in_deck;
+ reg char c;
+ reg int num;
+
+ in_deck = &CC_D;
+ CC_D.num_cards = 1;
+ CH_D.num_cards = 0;
+ CC_D.offsets[0] = ftell(outf);
+ putc(getc(inf), outf);
+ putc(getc(inf), outf);
+ for (num = 0; (c=getc(inf)) != '\n'; )
+ num = num * 10 + (c - '0');
+ putw(num, outf);
+ newline = FALSE;
+ while ((c=getc(inf)) != EOF)
+ if (newline && c == '%') {
+ putc('\0', outf);
+ newline = FALSE;
+ if (getc(inf) == '-')
+ in_deck = &CH_D;
+ while (getc(inf) != '\n')
+ continue;
+ in_deck->offsets[in_deck->num_cards++] = ftell(outf);
+ if ((c=getc(inf)) == EOF)
+ break;
+ putc(c, outf);
+ putc(c = getc(inf), outf);
+ for (num = 0; (c=getc(inf)) != EOF && c != '\n'; )
+ num = num * 10 + (c - '0');
+ putw(num, outf);
+ }
+ else {
+ putc(c, outf);
+ newline = (c == '\n');
+ }
+ putc('\0', outf);
+}
diff --git a/games/monop/jail.c b/games/monop/jail.c
new file mode 100644
index 0000000..e0334c5
--- /dev/null
+++ b/games/monop/jail.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)jail.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.ext"
+
+/*
+ * This routine uses a get-out-of-jail-free card to get the
+ * player out of jail.
+ */
+card() {
+
+ if (cur_p->loc != JAIL) {
+ printf("But you're not IN Jail\n");
+ return;
+ }
+ if (cur_p->num_gojf == 0) {
+ printf("But you don't HAVE a get out of jail free card\n");
+ return;
+ }
+ ret_card(cur_p);
+ cur_p->loc = 10; /* just visiting */
+ cur_p->in_jail = 0;
+}
+/*
+ * This routine returns the players get-out-of-jail-free card
+ * to a deck.
+ */
+ret_card(plr)
+reg PLAY *plr; {
+
+ plr->num_gojf--;
+ if (CC_D.gojf_used)
+ CC_D.gojf_used = FALSE;
+ else
+ CH_D.gojf_used = FALSE;
+}
+/*
+ * This routine deals with paying your way out of jail.
+ */
+pay() {
+
+ if (cur_p->loc != JAIL) {
+ printf("But you're not IN Jail\n");
+ return;
+ }
+ cur_p->loc = 10;
+ cur_p->money -= 50;
+ cur_p->in_jail = 0;
+ printf("That cost you $50\n");
+}
+/*
+ * This routine deals with a move in jail
+ */
+move_jail(r1, r2)
+reg int r1, r2; {
+
+ if (r1 != r2) {
+ printf("Sorry, that doesn't get you out\n");
+ if (++(cur_p->in_jail) == 3) {
+ printf("It's your third turn and you didn't roll doubles. You have to pay $50\n");
+ cur_p->money -= 50;
+moveit:
+ cur_p->loc = 10;
+ cur_p->in_jail = 0;
+ move(r1+r2);
+ r1 = r2 - 1; /* kludge: stop new roll w/doub */
+ return TRUE;
+ }
+ return FALSE;
+ }
+ else {
+ printf("Double roll gets you out.\n");
+ goto moveit;
+ }
+}
+printturn() {
+
+ if (cur_p->loc != JAIL)
+ return;
+ printf("(This is your ");
+ switch (cur_p->in_jail) {
+ case 0:
+ printf("1st");
+ break;
+ case 1:
+ printf("2nd");
+ break;
+ case 2:
+ printf("3rd (and final)");
+ break;
+ }
+ printf(" turn in JAIL)\n");
+}
diff --git a/games/monop/misc.c b/games/monop/misc.c
new file mode 100644
index 0000000..ed26534
--- /dev/null
+++ b/games/monop/misc.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.ext"
+# include <ctype.h>
+# include <signal.h>
+
+/*
+ * This routine executes a truncated set of commands until a
+ * "yes or "no" answer is gotten.
+ */
+getyn(prompt)
+reg char *prompt; {
+
+ reg int com;
+
+ for (;;)
+ if ((com=getinp(prompt, yn)) < 2)
+ return com;
+ else
+ (*func[com-2])();
+}
+/*
+ * This routine tells the player if he's out of money.
+ */
+notify() {
+
+ if (cur_p->money < 0)
+ printf("That leaves you $%d in debt\n", -cur_p->money);
+ else if (cur_p->money == 0)
+ printf("that leaves you broke\n");
+ else if (fixing && !told_em && cur_p->money > 0) {
+ printf("-- You are now Solvent ---\n");
+ told_em = TRUE;
+ }
+}
+/*
+ * This routine switches to the next player
+ */
+next_play() {
+
+ player = ++player % num_play;
+ cur_p = &play[player];
+ num_doub = 0;
+}
+/*
+ * This routine gets an integer from the keyboard after the
+ * given prompt.
+ */
+get_int(prompt)
+reg char *prompt; {
+
+ reg int num;
+ reg char *sp;
+ char buf[257];
+
+ for (;;) {
+inter:
+ printf(prompt);
+ num = 0;
+ for (sp = buf; (*sp=getchar()) != '\n'; sp++)
+ if (*sp == -1) /* check for interrupted system call */
+ goto inter;
+ if (sp == buf)
+ continue;
+ for (sp = buf; isspace(*sp); sp++)
+ continue;
+ for (; isdigit(*sp); sp++)
+ num = num * 10 + *sp - '0';
+ if (*sp == '\n')
+ return num;
+ else
+ printf("I can't understand that\n");
+ }
+}
+/*
+ * This routine sets the monopoly flag from the list given.
+ */
+set_ownlist(pl)
+int pl; {
+
+ reg int num; /* general counter */
+ reg MON *orig; /* remember starting monop ptr */
+ reg OWN *op; /* current owned prop */
+ OWN *orig_op; /* origianl prop before loop */
+
+ op = play[pl].own_list;
+#ifdef DEBUG
+ printf("op [%d] = play[pl [%d] ].own_list;\n", op, pl);
+#endif
+ while (op) {
+#ifdef DEBUG
+ printf("op->sqr->type = %d\n", op->sqr->type);
+#endif
+ switch (op->sqr->type) {
+ case UTIL:
+#ifdef DEBUG
+ printf(" case UTIL:\n");
+#endif
+ for (num = 0; op && op->sqr->type == UTIL; op = op->next)
+ num++;
+ play[pl].num_util = num;
+#ifdef DEBUG
+ printf("play[pl].num_util = num [%d];\n", num);
+#endif
+ break;
+ case RR:
+#ifdef DEBUG
+ printf(" case RR:\n");
+#endif
+ for (num = 0; op && op->sqr->type == RR; op = op->next) {
+#ifdef DEBUG
+ printf("iter: %d\n", num);
+ printf("op = %d, op->sqr = %d, op->sqr->type = %d\n", op, op->sqr, op->sqr->type);
+#endif
+ num++;
+ }
+ play[pl].num_rr = num;
+#ifdef DEBUG
+ printf("play[pl].num_rr = num [%d];\n", num);
+#endif
+ break;
+ case PRPTY:
+#ifdef DEBUG
+ printf(" case PRPTY:\n");
+#endif
+ orig = op->sqr->desc->mon_desc;
+ orig_op = op;
+ num = 0;
+ while (op && op->sqr->desc->mon_desc == orig) {
+#ifdef DEBUG
+ printf("iter: %d\n", num);
+#endif
+ num++;
+#ifdef DEBUG
+ printf("op = op->next ");
+#endif
+ op = op->next;
+#ifdef DEBUG
+ printf("[%d];\n", op);
+#endif
+ }
+#ifdef DEBUG
+ printf("num = %d\n");
+#endif
+ if (orig == 0) {
+ printf("panic: bad monopoly descriptor: orig = %d\n", orig);
+ printf("player # %d\n", pl+1);
+ printhold(pl);
+ printf("orig_op = %d\n", orig_op);
+ printf("orig_op->sqr->type = %d (PRPTY)\n", op->sqr->type);
+ printf("orig_op->next = %d\n", op->next);
+ printf("orig_op->sqr->desc = %d\n", op->sqr->desc);
+ printf("op = %d\n", op);
+ printf("op->sqr->type = %d (PRPTY)\n", op->sqr->type);
+ printf("op->next = %d\n", op->next);
+ printf("op->sqr->desc = %d\n", op->sqr->desc);
+ printf("num = %d\n", num);
+ }
+#ifdef DEBUG
+ printf("orig->num_in = %d\n", orig->num_in);
+#endif
+ if (num == orig->num_in)
+ is_monop(orig, pl);
+ else
+ isnot_monop(orig);
+ break;
+ }
+ }
+}
+/*
+ * This routine sets things up as if it is a new monopoly
+ */
+is_monop(mp, pl)
+reg MON *mp;
+int pl; {
+
+ reg char *sp;
+ reg int i;
+
+ mp->owner = pl;
+ mp->num_own = mp->num_in;
+ for (i = 0; i < mp->num_in; i++)
+ mp->sq[i]->desc->monop = TRUE;
+ mp->name = mp->mon_n;
+}
+/*
+ * This routine sets things up as if it is no longer a monopoly
+ */
+isnot_monop(mp)
+reg MON *mp; {
+
+ reg char *sp;
+ reg int i;
+
+ mp->owner = -1;
+ for (i = 0; i < mp->num_in; i++)
+ mp->sq[i]->desc->monop = FALSE;
+ mp->name = mp->not_m;
+}
+/*
+ * This routine gives a list of the current player's routine
+ */
+list() {
+
+ printhold(player);
+}
+/*
+ * This routine gives a list of a given players holdings
+ */
+list_all() {
+
+ reg int pl;
+
+ while ((pl=getinp("Whose holdings do you want to see? ", name_list)) < num_play)
+ printhold(pl);
+}
+/*
+ * This routine gives the players a chance before it exits.
+ */
+void
+quit() {
+
+ putchar('\n');
+ if (getyn("Do you all really want to quit? ", yn) == 0)
+ exit(0);
+ signal(SIGINT, quit);
+}
+/*
+ * This routine copies one structure to another
+ */
+cpy_st(s1, s2, size)
+reg int *s1, *s2, size; {
+
+ size /= 2;
+ while (size--)
+ *s1++ = *s2++;
+}
diff --git a/games/monop/mon.dat b/games/monop/mon.dat
new file mode 100644
index 0000000..8d5ab4d
--- /dev/null
+++ b/games/monop/mon.dat
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)mon.dat 5.4 (Berkeley) 5/31/93
+ */
+
+/* name owner num_in num_own h_cost not_m mon_n sq */
+{0, -1, 2, 0, 1, "Purple", "PURPLE", {1,3}},
+{0, -1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6,8,9}},
+{0, -1, 3, 0, 2, "Violet", "VIOLET", {11,13,14}},
+{0, -1, 3, 0, 2, "Orange", "ORANGE", {16,18,19}},
+{0, -1, 3, 0, 3, "Red", "RED", {21,23,24}},
+{0, -1, 3, 0, 3, "Yellow", "YELLOW", {26,27,29}},
+{0, -1, 3, 0, 4, "Green", "GREEN", {31,32,34}},
+{0, -1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37,39}}
diff --git a/games/monop/monop.6 b/games/monop/monop.6
new file mode 100644
index 0000000..35b2e8d
--- /dev/null
+++ b/games/monop/monop.6
@@ -0,0 +1,188 @@
+.\" Copyright (c) 1980 The Regents of the University of California.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)monop.6 6.5 (Berkeley) 3/25/93
+.\"
+.de Sc \" start command list macro
+.ie n .PD 0
+.el .PD 0.5
+.sp
+..
+.de Cm \" define command macro
+.TP 10
+.ie t .BR "\\$1" :
+.el .IR "\\$1" :
+..
+.de Ec \" end command macro
+.PD 1
+..
+.TH MONOP 6 "March 25, 1993"
+.UC 4
+.SH NAME
+monop \- Monopoly game
+.SH SYNOPSIS
+.B /usr/games/monop
+[ file ]
+.SH DESCRIPTION
+.I Monop
+is reminiscent of the Parker Brother's game Monopoly, and
+monitors a game between 1 to 9 users.
+It is assumed that the rules of Monopoly are known.
+The game follows the standard rules, with the exception that,
+if a property goes up for auction and there are only two solvent players,
+no auction is held and the property remains unowned.
+.PP
+The game, in effect, lends the player money,
+so it is possible to buy something which you cannot afford.
+However, as soon as a person goes into debt,
+he must \*(lqfix the problem\*(rq,
+.IR i.e. ,
+make himself solvent, before play can continue.
+If this is not possible, the player's property reverts to his debtee,
+either a player or the bank.
+A player can resign at any time to any person or the bank,
+which puts the property back on the board, unowned.
+.PP
+Any time that the response to a question is a
+.IR string ,
+e.g., a name, place or person, you can type `?' to get a list of valid answers.
+It is not possible to input a negative number, nor is it ever necessary.
+.Sc
+.IR "A Summary of Commands" :
+.Cm quit
+quit game: This allows you to quit the game. It asks you if you're sure.
+.Cm print
+print board: This prints out the current board.
+The columns have the following meanings (column headings are the same for the
+.BR where ,
+.BR "own holdings" ,
+and
+.B holdings
+commands):
+.PP
+.RS 10
+.TP "\w'Name\ \ 'u"
+Name
+The first ten characters of the name of the square
+.TP
+Own
+The \fInumber\fR of the owner of the property.
+.TP
+Price
+The cost of the property (if any)
+.TP
+Mg
+This field has a `*' in it if the property is mortgaged
+.TP
+#
+If the property is a Utility or Railroad, this is the number
+of such owned by the owner.
+If the property is land, this is the number of houses on it.
+.TP
+Rent
+Current rent on the property. If it is not owned, there is no rent.
+.RE
+.Cm where
+where players are: Tells you where all the players are.
+A `*' indicates the current player.
+.Cm "own\ holdings"
+List your own holdings,
+.IR i.e. ,
+money, get-out-of-jail-free cards, and property.
+.Cm holdings
+holdings list: Look at anyone's holdings.
+It will ask you whose holdings you wish to look at.
+When you are finished, type \*(lqdone\*(rq.
+.Cm mortgage
+mortgage property:
+Sets up a list of mortgageable property, and asks which you wish to mortgage.
+.Cm unmortgage
+unmortgage property:
+Unmortgage mortgaged property.
+.Cm buy
+buy houses:
+Sets up a list of monopolies on which you can buy houses.
+If there is more than one, it asks you which you want to buy for.
+It then asks you how many for each piece of property,
+giving the current amount in parentheses after the property name.
+If you build in an unbalanced manner
+(a disparity of more than one house within the same monopoly),
+it asks you to re-input things.
+.Cm sell
+sell houses:
+Sets up a list of monopolies from which you can sell houses.
+It operates in an analogous manner to
+.I buy.
+.Cm card
+card for jail:
+Use a get-out-of-jail-free card to get out of jail.
+If you're not in jail, or you don't have one, it tells you so.
+.Cm pay
+pay for jail:
+Pay $50 to get out of jail, from whence you are put on Just Visiting.
+Difficult to do if you're not there.
+.Cm trade
+This allows you to trade with another player.
+It asks you whom you wish to trade with,
+and then asks you what each wishes to give up.
+You can get a summary at the end, and, in all cases,
+it asks for confirmation of the trade before doing it.
+.Cm resign
+Resign to another player or the bank.
+If you resign to the bank, all property reverts to its virgin state,
+and get-out-of-jail free cards revert to the deck.
+.Cm save
+save game:
+Save the current game in a file for later play.
+You can continue play after saving,
+either by adding the file in which you saved the game after the
+.I monop
+command, or by using the
+.I restore
+command (see below).
+It will ask you which file you wish to save it in,
+and, if the file exists, confirm that you wish to overwrite it.
+.Cm restore
+restore game:
+Read in a previously saved game from a file.
+It leaves the file intact.
+.Cm roll
+Roll the dice and move forward to your new location.
+If you simply hit the <RETURN> key instead of a command,
+it is the same as typing
+.IR roll .
+.Ec
+.SH AUTHOR
+Ken Arnold
+.SH FILES
+/usr/games/lib/cards.pck Chance and Community Chest cards
+.SH BUGS
+No command can be given an argument instead of a response to a query.
diff --git a/games/monop/monop.c b/games/monop/monop.c
new file mode 100644
index 0000000..2b39e70
--- /dev/null
+++ b/games/monop/monop.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1980, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.def"
+
+/*
+ * This program implements a monopoly game
+ */
+main(ac, av)
+reg int ac;
+reg char *av[]; {
+
+
+ srand(getpid());
+ if (ac > 1) {
+ if (!rest_f(av[1]))
+ restore();
+ }
+ else {
+ getplayers();
+ init_players();
+ init_monops();
+ }
+ num_luck = sizeof lucky_mes / sizeof (char *);
+ init_decks();
+ signal(2, quit);
+ for (;;) {
+ printf("\n%s (%d) (cash $%d) on %s\n", cur_p->name, player + 1,
+ cur_p->money, board[cur_p->loc].name);
+ printturn();
+ force_morg();
+ execute(getinp("-- Command: ", comlist));
+ }
+}
+/*
+ * This routine gets the names of the players
+ */
+getplayers() {
+
+ reg char *sp;
+ reg int i, j;
+ char buf[257];
+
+blew_it:
+ for (;;) {
+ if ((num_play=get_int("How many players? ")) <= 0 ||
+ num_play > MAX_PL)
+ printf("Sorry. Number must range from 1 to 9\n");
+ else
+ break;
+ }
+ cur_p = play = (PLAY *) calloc(num_play, sizeof (PLAY));
+ for (i = 0; i < num_play; i++) {
+over:
+ printf("Player %d's name: ", i + 1);
+ for (sp = buf; (*sp=getchar()) != '\n'; sp++)
+ continue;
+ if (sp == buf)
+ goto over;
+ *sp++ = '\0';
+ strcpy(name_list[i]=play[i].name=(char *)calloc(1,sp-buf),buf);
+ play[i].money = 1500;
+ }
+ name_list[i++] = "done";
+ name_list[i] = 0;
+ for (i = 0; i < num_play; i++)
+ for (j = i + 1; j < num_play; j++)
+ if (strcasecmp(name_list[i], name_list[j]) == 0) {
+ if (i != num_play - 1)
+ printf("Hey!!! Some of those are IDENTICAL!! Let's try that again....\n");
+ else
+ printf("\"done\" is a reserved word. Please try again\n");
+ for (i = 0; i < num_play; i++)
+ cfree(play[i].name);
+ cfree(play);
+ goto blew_it;
+ }
+}
+/*
+ * This routine figures out who goes first
+ */
+init_players() {
+
+ reg int i, rl, cur_max;
+ bool over;
+ int max_pl;
+
+again:
+ putchar('\n');
+ for (cur_max = i = 0; i < num_play; i++) {
+ printf("%s (%d) rolls %d\n", play[i].name, i+1, rl=roll(2, 6));
+ if (rl > cur_max) {
+ over = FALSE;
+ cur_max = rl;
+ max_pl = i;
+ }
+ else if (rl == cur_max)
+ over++;
+ }
+ if (over) {
+ printf("%d people rolled the same thing, so we'll try again\n",
+ over + 1);
+ goto again;
+ }
+ player = max_pl;
+ cur_p = &play[max_pl];
+ printf("%s (%d) goes first\n", cur_p->name, max_pl + 1);
+}
+/*
+ * This routine initalizes the monopoly structures.
+ */
+init_monops() {
+
+ reg MON *mp;
+ reg int i;
+
+ for (mp = mon; mp < &mon[N_MON]; mp++) {
+ mp->name = mp->not_m;
+ for (i = 0; i < mp->num_in; i++)
+ mp->sq[i] = &board[mp->sqnums[i]];
+ }
+}
diff --git a/games/monop/monop.def b/games/monop/monop.def
new file mode 100644
index 0000000..89e933d
--- /dev/null
+++ b/games/monop/monop.def
@@ -0,0 +1,123 @@
+/*-
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)monop.def 5.5 (Berkeley) 5/31/93
+ */
+
+# include "monop.h"
+# include "deck.h"
+
+bool fixing, /* set if fixing up debt */
+ trading, /* set if in process of trading */
+ told_em, /* set if told user he's out of debt */
+ spec; /* set if moving by card to RR or UTIL */
+
+char *name_list[MAX_PL+2], /* list of players' names */
+ *comlist[] = { /* list of normal commands */
+ "quit", /* 0 */ "print", /* 1 */
+ "where", /* 2 */ "own holdings", /* 3 */
+ "holdings", /* 4 */ "mortgage", /* 5 */
+ "unmortgage", /* 6 */ "buy houses", /* 7 */
+ "sell houses", /* 8 */ "card", /* 9 */
+ "pay", /* 10 */ "trade", /* 11 */
+ "resign", /* 12 */ "save", /* 13 */
+ "restore", /* 14 */ "roll", /* 15 */
+ "", /* 16 */
+ 0
+ },
+ *yn[] = { /* list of commands for yes/no answers */
+ "yes", /* 0 */ "no", /* 1 */
+ "quit", /* 2 */ "print", /* 3 */
+ "where", /* 4 */ "own holdings", /* 5 */
+ "holdings", /* 6 */
+ 0
+ },
+ *lucky_mes[] = { /* "got lucky" messages */
+ "You lucky stiff", "You got lucky",
+ "What a lucky person!", "You must have a 4-leaf clover",
+ "My, my! Aren't we lucky!", "Luck smiles upon you",
+ "You got lucky this time", "Lucky person!",
+ "Your karma must certainly be together",
+ "How beautifully Cosmic", "Wow, you must be really with it"
+ /* "I want your autograph", -- Save for later */
+ };
+
+int player, /* current player number */
+ num_play, /* current number of players */
+ num_doub, /* # of doubles current player rolled */
+ /* # of "got lucky" messages */
+ num_luck = sizeof lucky_mes / sizeof (char *),
+ /* list of command functions */
+ buy_houses(), card(), do_move(), do_move(), list(), list_all(),
+ mortgage(), pay(), printboard(), quit(), resign(), restore(),
+ rub(), save(), sell_houses(), trade(),
+ unmortgage(), where(),
+ (*func[])() = { /* array of function calls for commands */
+ quit, /* quit game |* 0 *| */
+ printboard, /* print board |* 1 *| */
+ where, /* where players are |* 2 *| */
+ list, /* own holdings |* 3 *| */
+ list_all, /* holdings list |* 4 *| */
+ mortgage, /* mortgage property |* 5 *| */
+ unmortgage, /* unmortgage property |* 6 *| */
+ buy_houses, /* buy houses |* 7 *| */
+ sell_houses, /* sell houses |* 8 *| */
+ card, /* card for jail |* 9 *| */
+ pay, /* pay for jail |* 10 *| */
+ trade, /* trade |* 11 *| */
+ resign, /* resign |* 12 *| */
+ save, /* save game |* 13 *| */
+ restore, /* restore game |* 14 *| */
+ do_move, /* roll |* 15 *| */
+ do_move /* "" |* 16 *| */
+ };
+
+DECK deck[2]; /* Chance and Community Chest */
+
+PLAY *play, /* player structure array ("calloc"ed) */
+ *cur_p; /* pointer to current player's struct */
+
+RR_S rr[N_RR]; /* raildroad descriptions */
+
+UTIL_S util[2]; /* utility descriptions */
+
+MON mon[N_MON] = { /* monopoly descriptions */
+# include "mon.dat"
+};
+
+PROP prop[N_PROP] = { /* typical properties */
+# include "prop.dat"
+};
+
+SQUARE board[N_SQRS+1] = { /* board itself (+1 for Jail) */
+# include "brd.dat"
+};
diff --git a/games/monop/monop.ext b/games/monop/monop.ext
new file mode 100644
index 0000000..a5fc616
--- /dev/null
+++ b/games/monop/monop.ext
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)monop.ext 5.4 (Berkeley) 5/31/93
+ */
+
+# include "monop.h"
+# include "deck.h"
+
+extern bool trading, spec, fixing, told_em;
+
+extern char *yn[], *comlist[], *name_list[], *lucky_mes[];
+
+extern int num_play, player, num_doub, num_luck, (*func[])();
+
+extern DECK deck[2];
+
+extern MON mon[];
+
+extern PLAY *play, *cur_p;
+
+extern PROP prop[];
+
+extern RR_S rr[];
+
+extern SQUARE board[];
+
+extern UTIL_S util[];
diff --git a/games/monop/monop.h b/games/monop/monop.h
new file mode 100644
index 0000000..744732c
--- /dev/null
+++ b/games/monop/monop.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)monop.h 8.1 (Berkeley) 5/31/93
+ */
+
+# include <stdio.h>
+
+# define reg register
+# define shrt char
+# define bool char
+# define unsgn unsigned
+
+# define TRUE (1)
+# define FALSE (0)
+
+# define N_MON 8 /* number of monopolies */
+# define N_PROP 22 /* number of normal property squares */
+# define N_RR 4 /* number of railroads */
+# define N_UTIL 2 /* number of utilities */
+# define N_SQRS 40 /* number of squares on board */
+# define MAX_PL 9 /* maximum number of players */
+# define MAX_PRP (N_PROP+N_RR+N_UTIL) /* max # ownable property */
+
+ /* square type numbers */
+# define PRPTY 0 /* normal property */
+# define RR 1 /* railroad */
+# define UTIL 2 /* water works - electric co */
+# define SAFE 3 /* safe spot */
+# define CC 4 /* community chest */
+# define CHANCE 5 /* chance (surprise!!!) */
+# define INC_TAX 6 /* Income tax */
+# define GOTO_J 7 /* Go To Jail! */
+# define LUX_TAX 8 /* Luxury tax */
+# define IN_JAIL 9 /* In jail */
+
+# define JAIL 40 /* JAIL square number */
+
+# define lucky(str) printf("%s%s\n",str,lucky_mes[roll(1,num_luck)-1])
+# define printline() printf("------------------------------\n")
+# define sqnum(sqp) (sqp - board)
+# define swap(A1,A2) if ((A1) != (A2)) { \
+ (A1) ^= (A2); \
+ (A2) ^= (A1); \
+ (A1) ^= (A2); \
+ }
+
+struct sqr_st { /* structure for square */
+ char *name; /* place name */
+ shrt owner; /* owner number */
+ shrt type; /* place type */
+ struct prp_st *desc; /* description struct */
+ int cost; /* cost */
+};
+
+typedef struct sqr_st SQUARE;
+
+struct mon_st { /* monopoly description structure */
+ char *name; /* monop. name (color) */
+ shrt owner; /* owner of monopoly */
+ shrt num_in; /* # in monopoly */
+ shrt num_own; /* # owned (-1: not poss. monop)*/
+ shrt h_cost; /* price of houses */
+ char *not_m; /* name if not monopoly */
+ char *mon_n; /* name if a monopoly */
+ char sqnums[3]; /* Square numbers (used to init)*/
+ SQUARE *sq[3]; /* list of squares in monop */
+};
+
+typedef struct mon_st MON;
+
+/*
+ * This struct describes a property. For railroads and utilities, only
+ * the "morg" member is used.
+ */
+struct prp_st { /* property description structure */
+ bool morg; /* set if mortgaged */
+ bool monop; /* set if monopoly */
+ shrt square; /* square description */
+ shrt houses; /* number of houses */
+ MON *mon_desc; /* name of color */
+ int rent[6]; /* rents */
+};
+
+struct own_st { /* element in list owned things */
+ SQUARE *sqr; /* pointer to square */
+ struct own_st *next; /* next in list */
+};
+
+typedef struct own_st OWN;
+
+struct plr_st { /* player description structure */
+ char *name; /* owner name */
+ shrt num_gojf; /* # of get-out-of-jail-free's */
+ shrt num_rr; /* # of railroads owned */
+ shrt num_util; /* # of water works/elec. co. */
+ shrt loc; /* location on board */
+ shrt in_jail; /* count of turns in jail */
+ int money; /* amount of money */
+ OWN *own_list; /* start of propery list */
+};
+
+typedef struct plr_st PLAY;
+typedef struct prp_st PROP;
+typedef struct prp_st RR_S;
+typedef struct prp_st UTIL_S;
+
+int cc(), chance(), lux_tax(), goto_jail(), inc_tax();
diff --git a/games/monop/morg.c b/games/monop/morg.c
new file mode 100644
index 0000000..d88fa34
--- /dev/null
+++ b/games/monop/morg.c
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)morg.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.ext"
+
+/*
+ * These routines deal with mortgaging.
+ */
+
+static char *names[MAX_PRP+2],
+ *morg_coms[] = {
+ "quit", /* 0 */
+ "print", /* 1 */
+ "where", /* 2 */
+ "own holdings", /* 3 */
+ "holdings", /* 4 */
+ "mortgage", /* 5 */
+ "unmortgage", /* 6 */
+ "buy", /* 7 */
+ "sell", /* 8 */
+ "card", /* 9 */
+ "pay", /* 10 */
+ "trade", /* 11 */
+ "resign", /* 12 */
+ "save game", /* 13 */
+ "restore game", /* 14 */
+ 0
+ };
+
+static shrt square[MAX_PRP+2];
+
+static int num_good,got_houses;
+
+/*
+ * This routine is the command level response the mortgage command.
+ * it gets the list of mortgageable property and asks which are to
+ * be mortgaged.
+ */
+mortgage() {
+
+ reg int prop;
+
+ for (;;) {
+ if (set_mlist() == 0) {
+ if (got_houses)
+ printf("You can't mortgage property with houses on it.\n");
+ else
+ printf("You don't have any un-mortgaged property.\n");
+ return;
+ }
+ if (num_good == 1) {
+ printf("Your only mortageable property is %s\n",names[0]);
+ if (getyn("Do you want to mortgage it? ") == 0)
+ m(square[0]);
+ return;
+ }
+ prop = getinp("Which property do you want to mortgage? ",names);
+ if (prop == num_good)
+ return;
+ m(square[prop]);
+ notify(cur_p);
+ }
+}
+/*
+ * This routine sets up the list of mortgageable property
+ */
+set_mlist() {
+
+ reg OWN *op;
+
+ num_good = 0;
+ for (op = cur_p->own_list; op; op = op->next)
+ if (!op->sqr->desc->morg)
+ if (op->sqr->type == PRPTY && op->sqr->desc->houses)
+ got_houses++;
+ else {
+ names[num_good] = op->sqr->name;
+ square[num_good++] = sqnum(op->sqr);
+ }
+ names[num_good++] = "done";
+ names[num_good--] = 0;
+ return num_good;
+}
+/*
+ * This routine actually mortgages the property.
+ */
+m(prop)
+reg int prop; {
+
+ reg int price;
+
+ price = board[prop].cost/2;
+ board[prop].desc->morg = TRUE;
+ printf("That got you $%d\n",price);
+ cur_p->money += price;
+}
+/*
+ * This routine is the command level repsponse to the unmortgage
+ * command. It gets the list of mortgaged property and asks which are
+ * to be unmortgaged.
+ */
+unmortgage() {
+
+ reg int prop;
+
+ for (;;) {
+ if (set_umlist() == 0) {
+ printf("You don't have any mortgaged property.\n");
+ return;
+ }
+ if (num_good == 1) {
+ printf("Your only mortaged property is %s\n",names[0]);
+ if (getyn("Do you want to unmortgage it? ") == 0)
+ unm(square[0]);
+ return;
+ }
+ prop = getinp("Which property do you want to unmortgage? ",names);
+ if (prop == num_good)
+ return;
+ unm(square[prop]);
+ }
+}
+/*
+ * This routine sets up the list of mortgaged property
+ */
+set_umlist() {
+
+ reg OWN *op;
+
+ num_good = 0;
+ for (op = cur_p->own_list; op; op = op->next)
+ if (op->sqr->desc->morg) {
+ names[num_good] = op->sqr->name;
+ square[num_good++] = sqnum(op->sqr);
+ }
+ names[num_good++] = "done";
+ names[num_good--] = 0;
+ return num_good;
+}
+/*
+ * This routine actually unmortgages the property
+ */
+unm(prop)
+reg int prop; {
+
+ reg int price;
+
+ price = board[prop].cost/2;
+ board[prop].desc->morg = FALSE;
+ price += price/10;
+ printf("That cost you $%d\n",price);
+ cur_p->money -= price;
+ set_umlist();
+}
+/*
+ * This routine forces the indebted player to fix his
+ * financial woes.
+ */
+force_morg() {
+
+ told_em = fixing = TRUE;
+ while (cur_p->money <= 0)
+ fix_ex(getinp("How are you going to fix it up? ",morg_coms));
+ fixing = FALSE;
+}
+/*
+ * This routine is a special execute for the force_morg routine
+ */
+fix_ex(com_num)
+reg int com_num; {
+
+ told_em = FALSE;
+ (*func[com_num])();
+ notify();
+}
diff --git a/games/monop/pathnames.h b/games/monop/pathnames.h
new file mode 100644
index 0000000..60c0988
--- /dev/null
+++ b/games/monop/pathnames.h
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)pathnames.h 8.1 (Berkeley) 5/31/93
+ */
+
+#define _PATH_CARDS "/usr/share/games/cards.pck"
diff --git a/games/monop/print.c b/games/monop/print.c
new file mode 100644
index 0000000..121f79e
--- /dev/null
+++ b/games/monop/print.c
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.ext"
+
+static char buf[80], /* output buffer */
+ *header = "Name Own Price Mg # Rent";
+
+/*
+ * This routine prints out the current board
+ */
+printboard() {
+
+ reg int i;
+
+ printf("%s\t%s\n", header, header);
+ for (i = 0; i < N_SQRS/2; i++) {
+ printsq(i, FALSE);
+ putchar('\t');
+ printsq(i+N_SQRS/2, TRUE);
+ }
+}
+/*
+ * This routine lists where each player is.
+ */
+where() {
+
+ reg int i;
+ char *bsp;
+
+ printf("%s Player\n", header);
+ for (i = 0; i < num_play; i++) {
+ printsq(play[i].loc, FALSE);
+ printf(" %s (%d)", play[i].name, i+1);
+ if (cur_p == &play[i])
+ printf(" *");
+ putchar('\n');
+ }
+}
+/*
+ * This routine prints out an individual square
+ */
+printsq(sqn, eoln)
+int sqn;
+reg bool eoln; {
+
+ reg int rnt;
+ reg PROP *pp;
+ reg SQUARE *sqp;
+ int i;
+
+ sqp = &board[sqn];
+ printf("%-10.10s", sqp->name);
+ switch (sqp->type) {
+ case SAFE:
+ case CC:
+ case CHANCE:
+ case INC_TAX:
+ case GOTO_J:
+ case LUX_TAX:
+ case IN_JAIL:
+spec:
+ if (!eoln)
+ printf(" ");
+ break;
+ case PRPTY:
+ pp = sqp->desc;
+ if (sqp->owner < 0) {
+ printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost);
+ if (!eoln)
+ printf(" ");
+ break;
+ }
+ printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name,
+ sqp->cost);
+ printmorg(sqp);
+ if (pp->monop) {
+ if (pp->houses < 5)
+ if (pp->houses > 0)
+ printf("%d %4d", pp->houses,
+ pp->rent[pp->houses]);
+ else
+ printf("0 %4d", pp->rent[0] * 2);
+ else
+ printf("H %4d", pp->rent[5]);
+ }
+ else
+ printf(" %4d", pp->rent[0]);
+ break;
+ case UTIL:
+ if (sqp->owner < 0) {
+ printf(" - 150");
+ if (!eoln)
+ printf(" ");
+ break;
+ }
+ printf(" %d 150", sqp->owner+1);
+ printmorg(sqp);
+ printf("%d", play[sqp->owner].num_util);
+ if (!eoln)
+ printf(" ");
+ break;
+ case RR:
+ if (sqp->owner < 0) {
+ printf(" - Railroad 200");
+ if (!eoln)
+ printf(" ");
+ break;
+ }
+ printf(" %d Railroad 200", sqp->owner+1);
+ printmorg(sqp);
+ rnt = 25;
+ rnt <<= play[sqp->owner].num_rr - 1;
+ printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1));
+ break;
+ }
+ if (eoln)
+ putchar('\n');
+}
+/*
+ * This routine prints out the mortgage flag.
+ */
+printmorg(sqp)
+reg SQUARE *sqp; {
+
+ if (sqp->desc->morg)
+ printf(" * ");
+ else
+ printf(" ");
+}
+/*
+ * This routine lists the holdings of the player given
+ */
+printhold(pl)
+reg int pl; {
+
+ reg OWN *op;
+ reg PLAY *pp;
+ char *bsp;
+
+ pp = &play[pl];
+ printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1,
+ pp->money + prop_worth(pp));
+ printf("\t$%d", pp->money);
+ if (pp->num_gojf) {
+ printf(", %d get-out-of-jail-free card", pp->num_gojf);
+ if (pp->num_gojf > 1)
+ putchar('s');
+ }
+ putchar('\n');
+ if (pp->own_list) {
+ printf("\t%s\n", header);
+ for (op = pp->own_list; op; op = op->next) {
+ putchar('\t');
+ printsq(sqnum(op->sqr), TRUE);
+ }
+ }
+}
diff --git a/games/monop/prop.c b/games/monop/prop.c
new file mode 100644
index 0000000..0feb498
--- /dev/null
+++ b/games/monop/prop.c
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)prop.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.ext"
+
+extern char *calloc();
+
+/*
+ * This routine deals with buying property, setting all the
+ * appropriate flags.
+ */
+buy(player, sqrp)
+reg int player;
+reg SQUARE *sqrp; {
+
+ trading = FALSE;
+ sqrp->owner = player;
+ add_list(player, &(play[player].own_list), cur_p->loc);
+}
+/*
+ * This routine adds an item to the list.
+ */
+add_list(plr, head, op_sqr)
+int plr;
+OWN **head;
+int op_sqr; {
+
+ reg int val;
+ reg OWN *tp, *last_tp;
+ MON *mp;
+ OWN *op;
+
+ op = (OWN *)calloc(1, sizeof (OWN));
+ op->sqr = &board[op_sqr];
+ val = value(op->sqr);
+ last_tp = NULL;
+ for (tp = *head; tp && value(tp->sqr) < val; tp = tp->next)
+ if (val == value(tp->sqr)) {
+ cfree(op);
+ return;
+ }
+ else
+ last_tp = tp;
+ op->next = tp;
+ if (last_tp != NULL)
+ last_tp->next = op;
+ else
+ *head = op;
+ if (!trading)
+ set_ownlist(plr);
+}
+/*
+ * This routine deletes property from the list.
+ */
+del_list(plr, head, op_sqr)
+int plr;
+OWN **head;
+shrt op_sqr; {
+
+ reg int i;
+ reg OWN *op, *last_op;
+
+ switch (board[op_sqr].type) {
+ case PRPTY:
+ board[op_sqr].desc->mon_desc->num_own--;
+ break;
+ case RR:
+ play[plr].num_rr--;
+ break;
+ case UTIL:
+ play[plr].num_util--;
+ break;
+ }
+ last_op = NULL;
+ for (op = *head; op; op = op->next)
+ if (op->sqr == &board[op_sqr])
+ break;
+ else
+ last_op = op;
+ if (last_op == NULL)
+ *head = op->next;
+ else {
+ last_op->next = op->next;
+ cfree(op);
+ }
+}
+/*
+ * This routine calculates the value for sorting of the
+ * given square.
+ */
+value(sqp)
+reg SQUARE *sqp; {
+
+ reg int sqr;
+
+ sqr = sqnum(sqp);
+ switch (sqp->type) {
+ case SAFE:
+ return 0;
+ default: /* Specials, etc */
+ return 1;
+ case UTIL:
+ if (sqr == 12)
+ return 2;
+ else
+ return 3;
+ case RR:
+ return 4 + sqr/10;
+ case PRPTY:
+ return 8 + (sqp->desc) - prop;
+ }
+}
+/*
+ * This routine accepts bids for the current peice
+ * of property.
+ */
+bid() {
+
+ static bool in[MAX_PL];
+ reg int i, num_in, cur_max;
+ char buf[80];
+ int cur_bid;
+
+ printf("\nSo it goes up for auction. Type your bid after your name\n");
+ for (i = 0; i < num_play; i++)
+ in[i] = TRUE;
+ i = -1;
+ cur_max = 0;
+ num_in = num_play;
+ while (num_in > 1 || (cur_max == 0 && num_in > 0)) {
+ i = ++i % num_play;
+ if (in[i]) {
+ do {
+ (void)sprintf(buf, "%s: ", name_list[i]);
+ cur_bid = get_int(buf);
+ if (cur_bid == 0) {
+ in[i] = FALSE;
+ if (--num_in == 0)
+ break;
+ }
+ else if (cur_bid <= cur_max) {
+ printf("You must bid higher than %d to stay in\n", cur_max);
+ printf("(bid of 0 drops you out)\n");
+ }
+ } while (cur_bid != 0 && cur_bid <= cur_max);
+ cur_max = (cur_bid ? cur_bid : cur_max);
+ }
+ }
+ if (cur_max != 0) {
+ while (!in[i])
+ i = ++i % num_play;
+ printf("It goes to %s (%d) for $%d\n",play[i].name,i+1,cur_max);
+ buy(i, &board[cur_p->loc]);
+ play[i].money -= cur_max;
+ }
+ else
+ printf("Nobody seems to want it, so we'll leave it for later\n");
+}
+/*
+ * This routine calculates the value of the property
+ * of given player.
+ */
+prop_worth(plp)
+reg PLAY *plp; {
+
+ reg OWN *op;
+ reg int worth;
+
+ worth = 0;
+ for (op = plp->own_list; op; op = op->next) {
+ if (op->sqr->type == PRPTY && op->sqr->desc->monop)
+ worth += op->sqr->desc->mon_desc->h_cost * 50 *
+ op->sqr->desc->houses;
+ worth += op->sqr->cost;
+ }
+ return worth;
+}
diff --git a/games/monop/prop.dat b/games/monop/prop.dat
new file mode 100644
index 0000000..f9fc072
--- /dev/null
+++ b/games/monop/prop.dat
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)prop.dat 5.4 (Berkeley) 5/31/93
+ */
+
+/* morg monop square houses mon_desc rent */
+{0, 0, 1, 0, &mon[0], { 2, 10, 30, 90, 160, 250} },
+{0, 0, 3, 0, &mon[0], { 4, 20, 60, 180, 320, 450} },
+{0, 0, 6, 0, &mon[1], { 6, 30, 90, 270, 400, 550} },
+{0, 0, 7, 0, &mon[1], { 6, 30, 90, 270, 400, 550} },
+{0, 0, 9, 0, &mon[1], { 8, 40,100, 300, 450, 600} },
+{0, 0, 11, 0, &mon[2], {10, 50,150, 450, 625, 750} },
+{0, 0, 13, 0, &mon[2], {10, 50,150, 450, 625, 750} },
+{0, 0, 14, 0, &mon[2], {12, 60,180, 500, 700, 900} },
+{0, 0, 16, 0, &mon[3], {14, 70,200, 550, 750, 950} },
+{0, 0, 17, 0, &mon[3], {14, 70,200, 550, 750, 950} },
+{0, 0, 19, 0, &mon[3], {16, 80,220, 600, 800,1000} },
+{0, 0, 21, 0, &mon[4], {18, 90,250, 700, 875,1050} },
+{0, 0, 23, 0, &mon[4], {18, 90,250, 700, 875,1050} },
+{0, 0, 24, 0, &mon[4], {20,100,300, 750, 925,1100} },
+{0, 0, 26, 0, &mon[5], {22,110,330, 800, 975,1150} },
+{0, 0, 27, 0, &mon[5], {22,110,330, 800, 975,1150} },
+{0, 0, 29, 0, &mon[5], {24,120,360, 850,1025,1200} },
+{0, 0, 31, 0, &mon[6], {26,130,390, 900,1100,1275} },
+{0, 0, 32, 0, &mon[6], {26,130,390, 900,1100,1275} },
+{0, 0, 34, 0, &mon[6], {28,150,450,1000,1200,1400} },
+{0, 0, 37, 0, &mon[7], {35,175,500,1100,1300,1500} },
+{0, 0, 39, 0, &mon[7], {50,200,600,1400,1700,2000} }
diff --git a/games/monop/rent.c b/games/monop/rent.c
new file mode 100644
index 0000000..4954279
--- /dev/null
+++ b/games/monop/rent.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)rent.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.ext"
+
+/*
+ * This routine has the player pay rent
+ */
+rent(sqp)
+reg SQUARE *sqp; {
+
+ reg int rnt;
+ reg PROP *pp;
+ PLAY *plp;
+
+ plp = &play[sqp->owner];
+ printf("Owned by %s\n", plp->name);
+ if (sqp->desc->morg) {
+ lucky("The thing is mortgaged. ");
+ return;
+ }
+ switch (sqp->type) {
+ case PRPTY:
+ pp = sqp->desc;
+ if (pp->monop)
+ if (pp->houses == 0)
+ printf("rent is %d\n", rnt=pp->rent[0] * 2);
+ else if (pp->houses < 5)
+ printf("with %d houses, rent is %d\n",
+ pp->houses, rnt=pp->rent[pp->houses]);
+ else
+ printf("with a hotel, rent is %d\n",
+ rnt=pp->rent[pp->houses]);
+ else
+ printf("rent is %d\n", rnt = pp->rent[0]);
+ break;
+ case RR:
+ rnt = 25;
+ rnt <<= (plp->num_rr - 1);
+ if (spec)
+ rnt <<= 1;
+ printf("rent is %d\n", rnt);
+ break;
+ case UTIL:
+ rnt = roll(2, 6);
+ if (plp->num_util == 2 || spec) {
+ printf("rent is 10 * roll (%d) = %d\n", rnt, rnt * 10);
+ rnt *= 10;
+ }
+ else {
+ printf("rent is 4 * roll (%d) = %d\n", rnt, rnt * 4);
+ rnt *= 4;
+ }
+ break;
+ }
+ cur_p->money -= rnt;
+ plp->money += rnt;
+}
diff --git a/games/monop/roll.c b/games/monop/roll.c
new file mode 100644
index 0000000..633dfea
--- /dev/null
+++ b/games/monop/roll.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)roll.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+/*
+ * This routine rolls ndie nside-sided dice.
+ */
+
+# define reg register
+
+# if defined(pdp11)
+# define MAXRAND 32767L
+
+roll(ndie, nsides)
+int ndie, nsides; {
+
+ reg long tot;
+ reg unsigned n, r;
+
+ tot = 0;
+ n = ndie;
+ while (n--)
+ tot += rand();
+ return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie;
+}
+
+# else
+
+roll(ndie, nsides)
+reg int ndie, nsides; {
+
+ reg int tot, r;
+ reg double num_sides;
+
+ num_sides = nsides;
+ tot = 0;
+ while (ndie--)
+ tot += (r = rand()) * (num_sides / 017777777777) + 1;
+ return tot;
+}
+# endif
diff --git a/games/monop/spec.c b/games/monop/spec.c
new file mode 100644
index 0000000..958ce61
--- /dev/null
+++ b/games/monop/spec.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)spec.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.ext"
+
+static char *perc[] = {
+ "10%", "ten percent", "%", "$200", "200", 0
+ };
+
+inc_tax() { /* collect income tax */
+
+ reg int worth, com_num;
+
+ com_num = getinp("Do you wish to lose 10%% of your total worth or $200? ", perc);
+ worth = cur_p->money + prop_worth(cur_p);
+ printf("You were worth $%d", worth);
+ worth /= 10;
+ if (com_num > 2) {
+ if (worth < 200)
+ printf(". Good try, but not quite.\n");
+ else if (worth > 200)
+ lucky(".\nGood guess. ");
+ cur_p->money -= 200;
+ }
+ else {
+ printf(", so you pay $%d", worth);
+ if (worth > 200)
+ printf(" OUCH!!!!.\n");
+ else if (worth < 200)
+ lucky("\nGood guess. ");
+ cur_p->money -= worth;
+ }
+ if (worth == 200)
+ lucky("\nIt makes no difference! ");
+}
+goto_jail() { /* move player to jail */
+
+ cur_p->loc = JAIL;
+}
+lux_tax() { /* landing on luxury tax */
+
+ printf("You lose $75\n");
+ cur_p->money -= 75;
+}
+cc() { /* draw community chest card */
+
+ get_card(&CC_D);
+}
+chance() { /* draw chance card */
+
+ get_card(&CH_D);
+}
diff --git a/games/monop/trade.c b/games/monop/trade.c
new file mode 100644
index 0000000..4c356a8
--- /dev/null
+++ b/games/monop/trade.c
@@ -0,0 +1,306 @@
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)trade.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+# include "monop.ext"
+
+struct trd_st { /* how much to give to other player */
+ int trader; /* trader number */
+ int cash; /* amount of cash */
+ int gojf; /* # get-out-of-jail-free cards */
+ OWN *prop_list; /* property list */
+};
+
+typedef struct trd_st TRADE;
+
+static char *list[MAX_PRP+2];
+
+static int used[MAX_PRP];
+
+static TRADE trades[2];
+
+trade() {
+
+ reg int tradee, i;
+
+ trading = TRUE;
+ for (i = 0; i < 2; i++) {
+ trades[i].cash = 0;
+ trades[i].gojf = FALSE;
+ trades[i].prop_list = NULL;
+ }
+over:
+ if (num_play == 1) {
+ printf("There ain't no-one around to trade WITH!!\n");
+ return;
+ }
+ if (num_play > 2) {
+ tradee = getinp("Which player do you wish to trade with? ",
+ name_list);
+ if (tradee == num_play)
+ return;
+ if (tradee == player) {
+ printf("You can't trade with yourself!\n");
+ goto over;
+ }
+ }
+ else
+ tradee = 1 - player;
+ get_list(0, player);
+ get_list(1, tradee);
+ if (getyn("Do you wish a summary? ") == 0)
+ summate();
+ if (getyn("Is the trade ok? ") == 0)
+ do_trade();
+}
+/*
+ * This routine gets the list of things to be trader for the
+ * player, and puts in the structure given.
+ */
+get_list(struct_no, play_no)
+int struct_no, play_no; {
+
+ reg int sn, pn;
+ reg PLAY *pp;
+ int numin, prop, num_prp;
+ OWN *op;
+ TRADE *tp;
+
+ for (numin = 0; numin < MAX_PRP; numin++)
+ used[numin] = FALSE;
+ sn = struct_no, pn = play_no;
+ pp = &play[pn];
+ tp = &trades[sn];
+ tp->trader = pn;
+ printf("player %s (%d):\n", pp->name, pn+1);
+ if (pp->own_list) {
+ numin = set_list(pp->own_list);
+ for (num_prp = numin; num_prp; ) {
+ prop = getinp("Which property do you wish to trade? ",
+ list);
+ if (prop == numin)
+ break;
+ else if (used[prop])
+ printf("You've already allocated that.\n");
+ else {
+ num_prp--;
+ used[prop] = TRUE;
+ for (op = pp->own_list; prop--; op = op->next)
+ continue;
+ add_list(pn, &(tp->prop_list), sqnum(op->sqr));
+ }
+ }
+ }
+ if (pp->money > 0) {
+ printf("You have $%d. ", pp->money);
+ tp->cash = get_int("How much are you trading? ");
+ }
+ if (pp->num_gojf > 0) {
+once_more:
+ printf("You have %d get-out-of-jail-free cards. ",pp->num_gojf);
+ tp->gojf = get_int("How many are you trading? ");
+ if (tp->gojf > pp->num_gojf) {
+ printf("You don't have that many. Try again.\n");
+ goto once_more;
+ }
+ }
+}
+/*
+ * This routine sets up the list of tradable property.
+ */
+set_list(the_list)
+reg OWN *the_list; {
+
+ reg int i;
+ reg OWN *op;
+
+ i = 0;
+ for (op = the_list; op; op = op->next)
+ if (!used[i])
+ list[i++] = op->sqr->name;
+ list[i++] = "done";
+ list[i--] = 0;
+ return i;
+}
+/*
+ * This routine summates the trade.
+ */
+summate() {
+
+ reg bool some;
+ reg int i;
+ reg TRADE *tp;
+ OWN *op;
+
+ for (i = 0; i < 2; i++) {
+ tp = &trades[i];
+ some = FALSE;
+ printf("Player %s (%d) gives:\n", play[tp->trader].name,
+ tp->trader+1);
+ if (tp->cash > 0)
+ printf("\t$%d\n", tp->cash), some++;
+ if (tp->gojf > 0)
+ printf("\t%d get-out-of-jail-free card(s)\n", tp->gojf),
+ some++;
+ if (tp->prop_list) {
+ for (op = tp->prop_list; op; op = op->next)
+ putchar('\t'), printsq(sqnum(op->sqr), TRUE);
+ some++;
+ }
+ if (!some)
+ printf("\t-- Nothing --\n");
+ }
+}
+/*
+ * This routine actually executes the trade.
+ */
+do_trade() {
+
+ move_em(&trades[0], &trades[1]);
+ move_em(&trades[1], &trades[0]);
+}
+/*
+ * This routine does a switch from one player to another
+ */
+move_em(from, to)
+TRADE *from, *to; {
+
+ reg PLAY *pl_fr, *pl_to;
+ reg OWN *op;
+
+ pl_fr = &play[from->trader];
+ pl_to = &play[to->trader];
+
+ pl_fr->money -= from->cash;
+ pl_to->money += from->cash;
+ pl_fr->num_gojf -= from->gojf;
+ pl_to->num_gojf += from->gojf;
+ for (op = from->prop_list; op; op = op->next) {
+ add_list(to->trader, &(pl_to->own_list), sqnum(op->sqr));
+ op->sqr->owner = to->trader;
+ del_list(from->trader, &(pl_fr->own_list), sqnum(op->sqr));
+ }
+ set_ownlist(to->trader);
+}
+/*
+ * This routine lets a player resign
+ */
+resign() {
+
+ reg int i, new_own;
+ reg OWN *op;
+ SQUARE *sqp;
+
+ if (cur_p->money <= 0) {
+ switch (board[cur_p->loc].type) {
+ case UTIL:
+ case RR:
+ case PRPTY:
+ new_own = board[cur_p->loc].owner;
+ break;
+ default: /* Chance, taxes, etc */
+ new_own = num_play;
+ break;
+ }
+ if (new_own == num_play)
+ printf("You would resign to the bank\n");
+ else
+ printf("You would resign to %s\n", name_list[new_own]);
+ }
+ else if (num_play == 1) {
+ new_own = num_play;
+ printf("You would resign to the bank\n");
+ }
+ else {
+ name_list[num_play] = "bank";
+ do {
+ new_own = getinp("Who do you wish to resign to? ",
+ name_list);
+ if (new_own == player)
+ printf("You can't resign to yourself!!\n");
+ } while (new_own == player);
+ name_list[num_play] = "done";
+ }
+ if (getyn("Do you really want to resign? ", yn) != 0)
+ return;
+ if (num_play == 1) {
+ printf("Then NOBODY wins (not even YOU!)\n");
+ exit(0);
+ }
+ if (new_own < num_play) { /* resign to player */
+ printf("resigning to player\n");
+ trades[0].trader = new_own;
+ trades[0].cash = trades[0].gojf = 0;
+ trades[0].prop_list = NULL;
+ trades[1].trader = player;
+ trades[1].cash = cur_p->money > 0 ? cur_p->money : 0;
+ trades[1].gojf = cur_p->num_gojf;
+ trades[1].prop_list = cur_p->own_list;
+ do_trade();
+ }
+ else { /* resign to bank */
+ printf("resigning to bank\n");
+ for (op = cur_p->own_list; op; op = op->next) {
+ sqp = op->sqr;
+ sqp->owner = -1;
+ sqp->desc->morg = FALSE;
+ if (sqp->type == PRPTY) {
+ isnot_monop(sqp->desc->mon_desc);
+ sqp->desc->houses = 0;
+ }
+ }
+ if (cur_p->num_gojf)
+ ret_card(cur_p);
+ }
+ for (i = player; i < num_play; i++) {
+ name_list[i] = name_list[i+1];
+ if (i + 1 < num_play)
+ cpy_st(&play[i], &play[i+1], sizeof (PLAY));
+ }
+ name_list[num_play--] = 0;
+ for (i = 0; i < N_SQRS; i++)
+ if (board[i].owner > player)
+ --board[i].owner;
+ player = --player < 0 ? num_play - 1 : player;
+ next_play();
+ if (num_play < 2) {
+ printf("\nThen %s WINS!!!!!\n", play[0].name);
+ printhold(0);
+ printf("That's a grand worth of $%d.\n",
+ play[0].money+prop_worth(&play[0]));
+ exit(0);
+ }
+}
diff --git a/games/number/Makefile b/games/number/Makefile
new file mode 100644
index 0000000..dd18edb
--- /dev/null
+++ b/games/number/Makefile
@@ -0,0 +1,6 @@
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
+
+PROG= number
+MAN6= number.6
+
+.include <bsd.prog.mk>
diff --git a/games/number/number.6 b/games/number/number.6
new file mode 100644
index 0000000..15eb700
--- /dev/null
+++ b/games/number/number.6
@@ -0,0 +1,60 @@
+.\" Copyright (c) 1989, 1993, 1994
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)number.6 8.2 (Berkeley) 3/31/94
+.\"
+.Dd March 31, 1994
+.Dt NUMBER 6
+.Os
+.Sh NAME
+number \- convert Arabic numerals to English
+.Sh SYNOPSIS
+.Nm number
+.Op Fl l
+.Op Ar \&# ...
+.Sh DESCRIPTION
+The
+.Nm number
+utility prints the English equivalent of the number to the standard
+output, with each 10^3 magnitude displayed on a separate line.
+If no argument is specified,
+.Nm number
+reads lines from the standard input.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl l
+Display the number on a single line.
+.El
+.Sh BUGS
+Although
+.Nm number
+understand fractions, it doesn't understand exponents.
diff --git a/games/number/number.c b/games/number/number.c
new file mode 100644
index 0000000..13d139b
--- /dev/null
+++ b/games/number/number.c
@@ -0,0 +1,291 @@
+/*
+ * Copyright (c) 1988, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1988, 1993, 1994\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)number.c 8.2 (Berkeley) 3/31/94";
+#endif /* not lint */
+
+#include <sys/types.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <err.h>
+
+#define MAXNUM 65 /* Biggest number we handle. */
+
+static char *name1[] = {
+ "", "one", "two", "three",
+ "four", "five", "six", "seven",
+ "eight", "nine", "ten", "eleven",
+ "twelve", "thirteen", "fourteen", "fifteen",
+ "sixteen", "seventeen", "eighteen", "nineteen",
+},
+ *name2[] = {
+ "", "ten", "twenty", "thirty",
+ "forty", "fifty", "sixty", "seventy",
+ "eighty", "ninety",
+},
+ *name3[] = {
+ "hundred", "thousand", "million", "billion",
+ "trillion", "quadrillion", "quintillion", "sextillion",
+ "septillion", "octillion", "nonillion", "decillion",
+ "undecillion", "duodecillion", "tredecillion", "quattuordecillion",
+ "quindecillion", "sexdecillion",
+ "septendecillion", "octodecillion",
+ "novemdecillion", "vigintillion",
+};
+
+void convert __P((char *));
+int number __P((char *, int));
+void pfract __P((int));
+void toobig __P((void));
+int unit __P((int, char *));
+void usage __P((void));
+
+int lflag;
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ int ch, first;
+ char line[256];
+
+ lflag = 0;
+ while ((ch = getopt(argc, argv, "l")) != EOF)
+ switch (ch) {
+ case 'l':
+ lflag = 1;
+ break;
+ case '?':
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (*argv == NULL)
+ for (first = 1;
+ fgets(line, sizeof(line), stdin) != NULL; first = 0) {
+ if (strchr(line, '\n') == NULL)
+ errx(1, "line too long.");
+ if (!first)
+ (void)printf("...\n");
+ convert(line);
+ }
+ else
+ for (first = 1; *argv != NULL; first = 0, ++argv) {
+ if (!first)
+ (void)printf("...\n");
+ convert(*argv);
+ }
+ exit(0);
+}
+
+void
+convert(line)
+ char *line;
+{
+ register flen, len, rval;
+ register char *p, *fraction;
+
+ fraction = NULL;
+ for (p = line; *p != '\0' && *p != '\n'; ++p) {
+ if (isblank(*p)) {
+ if (p == line) {
+ ++line;
+ continue;
+ }
+ goto badnum;
+ }
+ if (isdigit(*p))
+ continue;
+ switch (*p) {
+ case '.':
+ if (fraction != NULL)
+ goto badnum;
+ fraction = p + 1;
+ *p = '\0';
+ break;
+ case '-':
+ if (p == line)
+ break;
+ /* FALLTHROUGH */
+ default:
+badnum: errx(1, "illegal number: %s", line);
+ break;
+ }
+ }
+ *p = '\0';
+
+ if ((len = strlen(line)) > MAXNUM ||
+ fraction != NULL && (flen = strlen(fraction)) > MAXNUM)
+ errx(1, "number too large, max %d digits.", MAXNUM);
+
+ if (*line == '-') {
+ (void)printf("minus%s", lflag ? " " : "\n");
+ ++line;
+ }
+
+ rval = len > 0 ? unit(len, line) : 0;
+ if (fraction != NULL && flen != 0)
+ for (p = fraction; *p != '\0'; ++p)
+ if (*p != '0') {
+ if (rval)
+ (void)printf("%sand%s",
+ lflag ? " " : "",
+ lflag ? " " : "\n");
+ if (unit(flen, fraction)) {
+ if (lflag)
+ (void)printf(" ");
+ pfract(flen);
+ rval = 1;
+ }
+ break;
+ }
+ if (!rval)
+ (void)printf("zero%s", lflag ? "" : ".\n");
+ if (lflag)
+ (void)printf("\n");
+}
+
+int
+unit(len, p)
+ register int len;
+ register char *p;
+{
+ register int off, rval;
+
+ rval = 0;
+ if (len > 3) {
+ if (len % 3) {
+ off = len % 3;
+ len -= off;
+ if (number(p, off)) {
+ rval = 1;
+ (void)printf(" %s%s",
+ name3[len / 3], lflag ? " " : ".\n");
+ }
+ p += off;
+ }
+ for (; len > 3; p += 3) {
+ len -= 3;
+ if (number(p, 3)) {
+ rval = 1;
+ (void)printf(" %s%s",
+ name3[len / 3], lflag ? " " : ".\n");
+ }
+ }
+ }
+ if (number(p, len)) {
+ if (!lflag)
+ (void)printf(".\n");
+ rval = 1;
+ }
+ return (rval);
+}
+
+int
+number(p, len)
+ register char *p;
+ int len;
+{
+ register int val, rval;
+
+ rval = 0;
+ switch (len) {
+ case 3:
+ if (*p != '0') {
+ rval = 1;
+ (void)printf("%s hundred", name1[*p - '0']);
+ }
+ ++p;
+ /* FALLTHROUGH */
+ case 2:
+ val = (p[1] - '0') + (p[0] - '0') * 10;
+ if (val) {
+ if (rval)
+ (void)printf(" ");
+ if (val < 20)
+ (void)printf("%s", name1[val]);
+ else {
+ (void)printf("%s", name2[val / 10]);
+ if (val % 10)
+ (void)printf("-%s", name1[val % 10]);
+ }
+ rval = 1;
+ }
+ break;
+ case 1:
+ if (*p != '0') {
+ rval = 1;
+ (void)printf("%s", name1[*p - '0']);
+ }
+ }
+ return (rval);
+}
+
+void
+pfract(len)
+ int len;
+{
+ static char *pref[] = { "", "ten-", "hundred-" };
+
+ switch(len) {
+ case 1:
+ (void)printf("tenths.\n");
+ break;
+ case 2:
+ (void)printf("hundredths.\n");
+ break;
+ default:
+ (void)printf("%s%sths.\n", pref[len % 3], name3[len / 3]);
+ break;
+ }
+}
+
+void
+usage()
+{
+ (void)fprintf(stderr, "usage: number [# ...]\n");
+ exit(1);
+}
diff --git a/games/phantasia/COPYRIGHT b/games/phantasia/COPYRIGHT
new file mode 100644
index 0000000..71a58b3
--- /dev/null
+++ b/games/phantasia/COPYRIGHT
@@ -0,0 +1,24 @@
+This entire subtree is explicitly not copyrighted.
+The following notice applies to all files found here. None of
+these files contain AT&T proprietary source code.
+_____________________________________________________________________________
+
+/* DISCLAIMER:
+ *
+ * This game is distributed for free as is. It is not guaranteed to work
+ * in every conceivable environment. It is not even guaranteed to work
+ * in ANY environment.
+ *
+ * This game is distributed without notice of copyright, therefore it
+ * may be used in any manner the recipient sees fit. However, the
+ * author assumes no responsibility for maintaining or revising this
+ * game, in its original form, or any derivitives thereof.
+ *
+ * The author shall not be responsible for any loss, cost, or damage,
+ * including consequential damage, caused by reliance on this material.
+ *
+ * The author makes no warranties, express or implied, including warranties
+ * of merchantability or fitness for a particular purpose or use.
+ *
+ * AT&T is in no way connected with this game.
+ */
diff --git a/games/phantasia/Makefile b/games/phantasia/Makefile
new file mode 100644
index 0000000..da4264f
--- /dev/null
+++ b/games/phantasia/Makefile
@@ -0,0 +1,30 @@
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
+
+PROG= phantasia
+SRCS= main.c fight.c io.c interplayer.c gamesupport.c misc.c phantglobs.c
+DPADD= ${LIBM} ${LIBCURSES} ${LIBTERM} ${LIBCOMPAT}
+LDADD= -lm -lcurses -ltermlib -lcompat
+HIDEGAME=hidegame
+MAN6= phantasia.6
+CLEANFILES+=map setup setup.o
+
+all: setup phantasia ${MAN6}
+
+setup: phantglobs.o setup.o monsters.asc ${LIBM}
+ ${CC} phantglobs.o setup.o -o ${.TARGET} -lm
+
+beforeinstall:
+ ./setup -m ${.CURDIR}/monsters.asc
+ chown games.bin /var/games/phantasia/*
+
+# Make Phantasia map. Change the map commands reflect your installation.
+# PLOTDEVICE is used for plotting the map. Change as appropriate.
+
+map: map.c
+ ${CC} -O ${.CURDIR}/map.c -lplot -o ${.TARGET}
+ ./map | plot > /dev/tty
+
+phantasia.0: phantasia.6
+ tbl ${.CURDIR}/phantasia.6 | nroff -man > ${.TARGET}
+
+.include <bsd.prog.mk>
diff --git a/games/phantasia/OWNER b/games/phantasia/OWNER
new file mode 100644
index 0000000..28387fe
--- /dev/null
+++ b/games/phantasia/OWNER
@@ -0,0 +1,6 @@
+ Edward Estes
+ AT&T
+ 5555 Touhy Ave.
+ Skokie, IL 60077
+ (312) 982-3969
+ ihnp4!ttrde!estes
diff --git a/games/phantasia/README b/games/phantasia/README
new file mode 100644
index 0000000..d56a621
--- /dev/null
+++ b/games/phantasia/README
@@ -0,0 +1,82 @@
+June 25, 1986
+
+
+This is a much modified version of Phantasia. It is intended to fix
+all reported bug fixes, enhance the game, and speed up the game.
+
+I have to thank Chris Robertson for many ideas which have made the game
+faster, and more user-friendly. Most of her changes/additions are
+incorporated in this latest versions, although perhaps not in the exact
+manner of her design. I left out a few items which were not in keeping
+with the spirit of the game. (For example, I didn't like the extra lives
+and the pausing of the game. I think it's too easy even WITHOUT that stuff.)
+
+CHANGES:
+
+ - Wormholes have been deleted (I never liked them anyway).
+ - The source code has been greatly enhanced for speed, size, readability,
+ and maintainability.
+ fight.c should no longer cause optimizers to run out of space.
+ - A few loopholes have been tightened to make the game more enjoyable.
+ (Except for those who are in the habit of exercising those loopholes.)
+ - Chris' map is enclosed.
+ - The "charac" file is not compatible with older versions of Phantasia
+ (3.3.1 and 3.3.1+). A 'convert' program is provided to convert your
+ old file to the new format. See Makefile for details.
+ - Movements can be made with HJKL for WSNE, respectively.
+ - Players may examine others while playing ('x') option.
+ - Monsters are now stored in a binary data base, to speed calling
+ monsters, and to ease formatting of monster listings.
+ - Taxes are collected on all gold and gems.
+ - Dead players can be resurrected by the 'wizard'.
+ - 'setup' is smarter, although not as smart as it should be.
+ - Players can change their names and passwords
+
+PORTABILTY:
+
+ I have tried to make this as non-machine/system specific as possible.
+
+ All identifiers are unique to 7 characters or less, dual case.
+
+ The code WILL NOT fit on a 16-bit machine without separate I/D.
+
+ Stdio MUST support fopen() with mode "r+". I think this is true
+ for all Version 7 and later.
+
+ 'curses' library functions are required.
+
+ All problems/solutions with portability should be reported to me,
+ and fixes will be included in subsequent versions of this software.
+
+
+Please send me any bugs, (of which I am sure there are many), you may find,
+but PLEASE be specific. I cannot correct a bug which is described as:
+
+ "When I choose a character type, it blows up."
+
+ (What blows up? What exactly was printed at the terminal?
+ Which character type was chosen? Etc. . . ?)
+
+Also, please tell me which version of UN*X you are running, and upon
+which type of hardware.
+
+I will also do my best to help anyone with problems just trying to
+get the game running. Again, I need to know which version of UN*X
+and what type of CPU. Also, a copy of the output from 'make'
+would be extremely useful.
+
+Any and all ideas/suggestions/additions are more than welcome. If
+you feel strongly enough about it, write the change and send it to me,
+and I will do my best to incorporate it in the next version of Phantasia.
+Otherwise, I will give serious thought to adding it myself.
+
+Follow the directions in the Makefile CAREFULLY to set up the game.
+Read the comments at the beginning of 'main.c', if you haven't already.
+
+Enjoy.
+
+Ted Estes
+AT&T Information Systems
+Skokie, IL 60077
+
+...!ihnp4!ttrdc!ttrda!estes
diff --git a/games/phantasia/convert.c b/games/phantasia/convert.c
new file mode 100644
index 0000000..f46343f
--- /dev/null
+++ b/games/phantasia/convert.c
@@ -0,0 +1,210 @@
+/*
+ * Convert Phantasia 3.3.1 and 3.3.1+ characs file format to 3.3.2
+ *
+ */
+
+#include "include.h"
+#include "oldplayer.h"
+
+struct oldplayer Oldplayer; /* old format structure */
+struct player Newplayer; /* new format structure */
+
+char Oldpfile[] = DEST/characs"; /* old format file */
+char Newpfile[] = DEST/newcharacs"; /* new format file */
+
+/************************************************************************
+/
+/ FUNCTION NAME: main()
+/
+/ FUNCTION: convert old Phantasia player file to new format
+/
+/ AUTHOR: C. Robertson, 9/1/85 E. A. Estes, 3/12/86
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: time(), exit(), fread(), fopen(), srandom(), floor(),
+/ random(), strcmp(), fwrite(), strcpy(), fclose(), fprintf()
+/
+/ GLOBAL INPUTS: _iob[], Oldplayer, Newplayer
+/
+/ GLOBAL OUTPUTS: Oldplayer, Newplayer
+/
+/ DESCRIPTION:
+/ Read in old player structures and write out to new file in
+/ new format.
+/ Old player file is unmodified.
+/ New file is "DEST/newcharacs".
+/ #define PHANTPLUS to convert from 3.3.1+.
+/
+/************************************************************************/
+
+main()
+{
+FILE *oldcharac, *newcharac; /* to open old and new files */
+
+ if ((oldcharac = fopen(Oldpfile, "r")) == NULL)
+ {
+ fprintf(stderr, "Cannot open original character file!\n");
+ exit(1);
+ }
+
+ if ((newcharac = fopen(Newpfile, "w")) == NULL)
+ {
+ fprintf(stderr, "Cannot create new character file!\n");
+ exit(1);
+ }
+
+ srandom((unsigned) time((long *) NULL)); /* prime random numbers */
+
+ while (fread((char *) &Oldplayer, sizeof(struct oldplayer), 1, oldcharac) == 1)
+ /* read and convert old structures into new */
+ {
+ Newplayer.p_experience = Oldplayer.o_experience;
+ Newplayer.p_level = (double) Oldplayer.o_level;
+ Newplayer.p_strength = Oldplayer.o_strength;
+ Newplayer.p_sword = Oldplayer.o_sword;
+ Newplayer.p_might = 0.0; /* game will calculate */
+ Newplayer.p_energy = Oldplayer.o_energy;
+ Newplayer.p_maxenergy = Oldplayer.o_maxenergy;
+ Newplayer.p_shield = Oldplayer.o_shield;
+ Newplayer.p_quickness = (double) Oldplayer.o_quickness;
+ Newplayer.p_quksilver = (double) Oldplayer.o_quksilver;
+ Newplayer.p_speed = 0.0; /* game will calculate */
+ Newplayer.p_magiclvl = Oldplayer.o_magiclvl;
+ Newplayer.p_mana = Oldplayer.o_mana;
+ Newplayer.p_brains = Oldplayer.o_brains;
+ Newplayer.p_poison = Oldplayer.o_poison;
+ Newplayer.p_gold = Oldplayer.o_gold;
+ Newplayer.p_gems = Oldplayer.o_gems;
+ Newplayer.p_sin = Oldplayer.o_sin;
+ Newplayer.p_x = Oldplayer.o_x;
+ Newplayer.p_y = Oldplayer.o_y;
+ Newplayer.p_1scratch = Oldplayer.o_1scratch;
+ Newplayer.p_2scratch = Oldplayer.o_2scratch;
+
+ Newplayer.p_ring.ring_type = Oldplayer.o_ring.ring_type;
+ Newplayer.p_ring.ring_duration = Oldplayer.o_ring.ring_duration;
+ Newplayer.p_ring.ring_inuse = FALSE;
+
+ Newplayer.p_age = (long) Oldplayer.o_degenerated * N_AGE;
+
+ Newplayer.p_degenerated = Oldplayer.o_degenerated + 1;
+
+ /* convert character type into character type and special type */
+
+ if (Oldplayer.o_type < 0)
+ /* player with crown */
+ Oldplayer.o_type = -Oldplayer.o_type;
+
+ if (Oldplayer.o_type == 99)
+ /* valar */
+ {
+ Newplayer.p_specialtype = SC_VALAR;
+ Newplayer.p_type = (short) ROLL(C_MAGIC, C_EXPER - C_MAGIC + 1);
+ Newplayer.p_lives = Oldplayer.o_ring.ring_duration;
+ }
+ else if (Oldplayer.o_type == 90)
+ /* ex-valar */
+ {
+ Newplayer.p_specialtype = SC_EXVALAR;
+ Newplayer.p_type = (short) ROLL(C_MAGIC, C_EXPER - C_MAGIC + 1);
+ Newplayer.p_lives = 0;
+ }
+ else if (Oldplayer.o_type > 20)
+ /* council of wise */
+ {
+ Newplayer.p_specialtype = SC_COUNCIL;
+ Newplayer.p_type = Oldplayer.o_type - 20;
+ Newplayer.p_lives = Oldplayer.o_ring.ring_duration;
+ }
+ else if (Oldplayer.o_type > 10)
+ /* king */
+ {
+ Newplayer.p_specialtype = SC_KING;
+ Newplayer.p_type = Oldplayer.o_type - 10;
+ Newplayer.p_lives = 0;
+ }
+ else
+ /* normal player */
+ {
+ Newplayer.p_specialtype = SC_NONE;
+ Newplayer.p_type = Oldplayer.o_type;
+ Newplayer.p_lives = 0;
+ }
+
+ Newplayer.p_lives = 0;
+ Newplayer.p_crowns = Oldplayer.o_crowns;
+ Newplayer.p_charms = Oldplayer.o_charms;
+ Newplayer.p_amulets = Oldplayer.o_amulets;
+ Newplayer.p_holywater = Oldplayer.o_holywater;
+ Newplayer.p_lastused = Oldplayer.o_lastused;
+
+ /* convert status and name into status */
+
+ Newplayer.p_status = Oldplayer.o_status + S_OFF;
+ if (strcmp(Oldplayer.m_name, "<null>") == 0)
+ /* unused recored */
+ Newplayer.p_status = S_NOTUSED;
+ if (Oldplayer.o_quickness < 0)
+ /* hung up player */
+ {
+ Newplayer.p_quickness = (double) Oldplayer.o_tampered;
+ Oldplayer.o_tampered = T_OFF;
+ Newplayer.p_status = S_HUNGUP;
+ }
+
+ Newplayer.p_tampered = Oldplayer.o_tampered + T_OFF;
+ Newplayer.p_istat = I_OFF;
+
+ Newplayer.p_palantir = Oldplayer.o_palantir;
+ Newplayer.p_blessing = Oldplayer.o_blessing;
+ Newplayer.p_virgin = Oldplayer.o_virgin;
+ Newplayer.p_blindness = Oldplayer.o_blindness;
+
+ strcpy(Newplayer.p_name, Oldplayer.o_name);
+ strcpy(Newplayer.p_password, Oldplayer.o_password);
+ strcpy(Newplayer.p_login, Oldplayer.o_login);
+
+ /* write new structure */
+ fwrite((char *) &Newplayer, sizeof(Newplayer), 1, newcharac);
+ }
+
+ fclose(oldcharac); /* close files */
+ fclose(newcharac);
+
+ exit(0);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: drandom()
+/
+/ FUNCTION: return a random number between 0.0 < 1.0
+/
+/ AUTHOR: E. A. Estes, 2/7/86
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: random number
+/
+/ MODULES CALLED: random()
+/
+/ GLOBAL INPUTS: none
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Return a random number.
+/
+/************************************************************************/
+
+double
+drandom()
+{
+ if (sizeof(int) != 2)
+ return((double) (random() & 0x7fff) / 32768.0);
+ else
+ return((double) random() / 32768.0);
+}
diff --git a/games/phantasia/fight.c b/games/phantasia/fight.c
new file mode 100644
index 0000000..4038d1d
--- /dev/null
+++ b/games/phantasia/fight.c
@@ -0,0 +1,1688 @@
+/*
+ * fight.c Phantasia monster fighting routines
+ */
+
+#include "include.h"
+
+/************************************************************************
+/
+/ FUNCTION NAME: encounter()
+/
+/ FUNCTION: monster battle routine
+/
+/ AUTHOR: E. A. Estes, 2/20/86
+/
+/ ARGUMENTS:
+/ int particular - particular monster to fight if >= 0
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: monsthits(), playerhits(), readmessage(), callmonster(),
+/ writerecord(), pickmonster(), displaystats(), pow(), cancelmonster(),
+/ awardtreasure(), more(), death(), wmove(), setjmp(), drandom(), printw(),
+/ longjmp(), wrefresh(), mvprintw(), wclrtobot()
+/
+/ GLOBAL INPUTS: Curmonster, Whichmonster, LINES, Lines, Circle, Shield,
+/ Player, *stdscr, Fileloc, Fightenv[], *Enemyname
+/
+/ GLOBAL OUTPUTS: Curmonster, Whichmonster, Lines, Shield, Player, Luckout
+/
+/ DESCRIPTION:
+/ Choose a monster and check against some special types.
+/ Arbitrate between monster and player. Watch for either
+/ dying.
+/
+/************************************************************************/
+
+encounter(particular)
+int particular;
+{
+bool firsthit = Player.p_blessing; /* set if player gets the first hit */
+int flockcnt = 1; /* how many time flocked */
+
+ /* let others know what we are doing */
+ Player.p_status = S_MONSTER;
+ writerecord(&Player, Fileloc);
+
+#ifdef SYS5
+ flushinp();
+#endif
+
+ Shield = 0.0; /* no shield up yet */
+
+ if (particular >= 0)
+ /* monster is specified */
+ Whichmonster = particular;
+ else
+ /* pick random monster */
+ Whichmonster = pickmonster();
+
+ setjmp(Fightenv); /* this is to enable changing fight state */
+
+ move(6, 0);
+ clrtobot(); /* clear bottom area of screen */
+
+ Lines = 9;
+ callmonster(Whichmonster); /* set up monster to fight */
+
+ Luckout = FALSE; /* haven't tried to luckout yet */
+
+ if (Curmonster.m_type == SM_MORGOTH)
+ mvprintw(4, 0, "You've encountered %s, Bane of the Council and Valar.\n",
+ Enemyname);
+
+ if (Curmonster.m_type == SM_UNICORN)
+ {
+ if (Player.p_virgin)
+ {
+ printw("You just subdued %s, thanks to the virgin.\n", Enemyname);
+ Player.p_virgin = FALSE;
+ }
+ else
+ {
+ printw("You just saw %s running away!\n", Enemyname);
+ Curmonster.m_experience = 0.0;
+ Curmonster.m_treasuretype = 0;
+ }
+ }
+ else
+ /* not a special monster */
+ for (;;)
+ /* print header, and arbitrate between player and monster */
+ {
+ mvprintw(6, 0, "You are being attacked by %s, EXP: %.0f (Size: %.0f)\n",
+ Enemyname, Curmonster.m_experience, Circle);
+
+ displaystats();
+ mvprintw(1, 26, "%20.0f", Player.p_energy + Shield); /* overprint energy */
+ readmessage();
+
+ if (Curmonster.m_type == SM_DARKLORD
+ && Player.p_blessing
+ && Player.p_charms > 0)
+ /* overpower Dark Lord with blessing and charm */
+ {
+ mvprintw(7, 0, "You just overpowered %s!", Enemyname);
+ Lines = 8;
+ Player.p_blessing = FALSE;
+ --Player.p_charms;
+ break;
+ }
+
+ /* allow paralyzed monster to wake up */
+ Curmonster.m_speed = MIN(Curmonster.m_speed + 1.0, Curmonster.m_maxspeed);
+
+ if (drandom() * Curmonster.m_speed > drandom() * Player.p_speed
+ /* monster is faster */
+ && Curmonster.m_type != SM_DARKLORD
+ /* not D. L. */
+ && Curmonster.m_type != SM_SHRIEKER
+ /* not mimic */
+ && !firsthit)
+ /* monster gets a hit */
+ monsthits();
+ else
+ /* player gets a hit */
+ {
+ firsthit = FALSE;
+ playerhits();
+ }
+
+ refresh();
+
+ if (Lines > LINES - 2)
+ /* near bottom of screen - pause */
+ {
+ more(Lines);
+ move(Lines = 8, 0);
+ clrtobot();
+ }
+
+ if (Player.p_energy <= 0.0)
+ /* player died */
+ {
+ more(Lines);
+ death(Enemyname);
+ cancelmonster();
+ break; /* fight ends if the player is saved from death */
+ }
+
+ if (Curmonster.m_energy <= 0.0)
+ /* monster died */
+ break;
+ }
+
+ /* give player credit for killing monster */
+ Player.p_experience += Curmonster.m_experience;
+
+ if (drandom() < Curmonster.m_flock / 100.0)
+ /* monster flocks */
+ {
+ more(Lines);
+ ++flockcnt;
+ longjmp(Fightenv, 0);
+ /*NOTREACHED*/
+ }
+ else if (Circle > 1.0
+ && Curmonster.m_treasuretype > 0
+ && drandom() > 0.2 + pow(0.4, (double) (flockcnt / 3 + Circle / 3.0)))
+ /* monster has treasure; this takes # of flocks and size into account */
+ {
+ more(Lines);
+ awardtreasure();
+ }
+
+ /* pause before returning */
+ getyx(stdscr, Lines, flockcnt);
+ more(Lines + 1);
+
+ Player.p_ring.ring_inuse = FALSE; /* not using ring */
+
+ /* clean up the screen */
+ move(4, 0);
+ clrtobot();
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: pickmonster()
+/
+/ FUNCTION: choose a monster based upon where we are
+/
+/ AUTHOR: E. A. Estes, 2/20/86
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: monster number to call
+/
+/ MODULES CALLED: floor(), drandom()
+/
+/ GLOBAL INPUTS: Marsh, Circle, Player
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Certain monsters can be found in certain areas of the grid.
+/ We take care of rolling them here.
+/ Unfortunately, this routine assumes that the monster data
+/ base is arranged in a particular order. If the data base
+/ is altered (to add monsters, or make them tougher), this
+/ routine may also need to be changed.
+/
+/************************************************************************/
+
+pickmonster()
+{
+ if (Player.p_specialtype == SC_VALAR)
+ /* even chance of any monster */
+ return((int) ROLL(0.0, 100.0));
+
+ if (Marsh)
+ /* water monsters */
+ return((int) ROLL(0.0, 15.0));
+
+ else if (Circle > 24)
+ /* even chance of all non-water monsters */
+ return((int) ROLL(14.0, 86.0));
+
+ else if (Circle > 15)
+ /* chance of all non-water monsters, weighted toward middle */
+ return((int) (ROLL(0.0, 50.0) + ROLL(14.0, 37.0)));
+
+ else if (Circle > 8)
+ /* not all non-water monsters, weighted toward middle */
+ return((int) (ROLL(0.0, 50.0) + ROLL(14.0, 26.0)));
+
+ else if (Circle > 3)
+ /* even chance of some tamer non-water monsters */
+ return((int) ROLL(14.0, 50.0));
+
+ else
+ /* even chance of some of the tamest non-water monsters */
+ return((int) ROLL(14.0, 25.0));
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: playerhits()
+/
+/ FUNCTION: prompt player for action in monster battle, and process
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: hitmonster(), throwspell(), inputoption(), cancelmonster(),
+/ floor(), wmove(), drandom(), altercoordinates(), waddstr(), mvprintw(),
+/ wclrtoeol(), wclrtobot()
+/
+/ GLOBAL INPUTS: Curmonster, Lines, Player, *stdscr, Luckout, *Enemyname
+/
+/ GLOBAL OUTPUTS: Curmonster, Lines, Player, Luckout
+/
+/ DESCRIPTION:
+/ Process all monster battle options.
+/
+/************************************************************************/
+
+playerhits()
+{
+double inflict; /* damage inflicted */
+int ch; /* input */
+
+ mvaddstr(7, 0, "1:Melee 2:Skirmish 3:Evade 4:Spell 5:Nick ");
+
+ if (!Luckout)
+ /* haven't tried to luckout yet */
+ if (Curmonster.m_type == SM_MORGOTH)
+ /* cannot luckout against Morgoth */
+ addstr("6:Ally ");
+ else
+ addstr("6:Luckout ");
+
+ if (Player.p_ring.ring_type != R_NONE)
+ /* player has a ring */
+ addstr("7:Use Ring ");
+ else
+ clrtoeol();
+
+ ch = inputoption();
+
+ move(8, 0);
+ clrtobot(); /* clear any messages from before */
+ Lines = 9;
+ mvaddstr(4, 0, "\n\n"); /* clear status area */
+
+ switch (ch)
+ {
+ case 'T': /* timeout; lose turn */
+ break;
+
+ case ' ':
+ case '1': /* melee */
+ /* melee affects monster's energy and strength */
+ inflict = ROLL(Player.p_might / 2.0 + 5.0, 1.3 * Player.p_might)
+ + (Player.p_ring.ring_inuse ? Player.p_might : 0.0);
+
+ Curmonster.m_melee += inflict;
+ Curmonster.m_strength = Curmonster.m_o_strength
+ - Curmonster.m_melee / Curmonster.m_o_energy
+ * Curmonster.m_o_strength / 4.0;
+ hitmonster(inflict);
+ break;
+
+ case '2': /* skirmish */
+ /* skirmish affects monter's energy and speed */
+ inflict = ROLL(Player.p_might / 3.0 + 3.0, 1.1 * Player.p_might)
+ + (Player.p_ring.ring_inuse ? Player.p_might : 0.0);
+
+ Curmonster.m_skirmish += inflict;
+ Curmonster.m_maxspeed = Curmonster.m_o_speed
+ - Curmonster.m_skirmish / Curmonster.m_o_energy
+ * Curmonster.m_o_speed / 4.0;
+ hitmonster(inflict);
+ break;
+
+ case '3': /* evade */
+ /* use brains and speed to try to evade */
+ if ((Curmonster.m_type == SM_DARKLORD
+ || Curmonster.m_type == SM_SHRIEKER
+ /* can always run from D. L. and shrieker */
+ || drandom() * Player.p_speed * Player.p_brains
+ > drandom() * Curmonster.m_speed * Curmonster.m_brains)
+ && (Curmonster.m_type != SM_MIMIC))
+ /* cannot run from mimic */
+ {
+ mvaddstr(Lines++, 0, "You got away!");
+ cancelmonster();
+ altercoordinates(0.0, 0.0, A_NEAR);
+ }
+ else
+ mvprintw(Lines++, 0, "%s is still after you!", Enemyname);
+
+ break;
+
+ case 'M':
+ case '4': /* magic spell */
+ throwspell();
+ break;
+
+ case '5': /* nick */
+ /* hit 1 plus sword; give some experience */
+ inflict = 1.0 + Player.p_sword;
+ Player.p_experience += floor(Curmonster.m_experience / 10.0);
+ Curmonster.m_experience *= 0.92;
+ /* monster gets meaner */
+ Curmonster.m_maxspeed += 2.0;
+ Curmonster.m_speed = (Curmonster.m_speed < 0.0) ? 0.0 : Curmonster.m_speed + 2.0;
+ if (Curmonster.m_type == SM_DARKLORD)
+ /* Dark Lord; doesn't like to be nicked */
+ {
+ mvprintw(Lines++, 0,
+ "You hit %s %.0f times, and made him mad!", Enemyname, inflict);
+ Player.p_quickness /= 2.0;
+ altercoordinates(0.0, 0.0, A_FAR);
+ cancelmonster();
+ }
+ else
+ hitmonster(inflict);
+ break;
+
+ case 'B':
+ case '6': /* luckout */
+ if (Luckout)
+ mvaddstr(Lines++, 0, "You already tried that.");
+ else
+ {
+ Luckout = TRUE;
+ if (Curmonster.m_type == SM_MORGOTH)
+ /* Morgoth; ally */
+ {
+ if (drandom() < Player.p_sin / 100.0)
+ {
+ mvprintw(Lines++, 0, "%s accepted!", Enemyname);
+ cancelmonster();
+ }
+ else
+ mvaddstr(Lines++, 0, "Nope, he's not interested.");
+ }
+ else
+ /* normal monster; use brains for success */
+ {
+ if ((drandom() + 0.333) * Player.p_brains
+ < (drandom() + 0.333) * Curmonster.m_brains)
+ mvprintw(Lines++, 0, "You blew it, %s.", Player.p_name);
+ else
+ {
+ mvaddstr(Lines++, 0, "You made it!");
+ Curmonster.m_energy = 0.0;
+ }
+ }
+ }
+ break;
+
+ case '7': /* use ring */
+ if (Player.p_ring.ring_type != R_NONE)
+ {
+ mvaddstr(Lines++, 0, "Now using ring.");
+ Player.p_ring.ring_inuse = TRUE;
+ if (Player.p_ring.ring_type != R_DLREG)
+ /* age ring */
+ --Player.p_ring.ring_duration;
+ }
+ break;
+ }
+
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: monsthits()
+/
+/ FUNCTION: process a monster hitting the player
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: cancelmonster(), scramblestats(), more(), floor(), wmove(),
+/ drandom(), altercoordinates(), longjmp(), waddstr(), mvprintw(),
+/ getanswer()
+/
+/ GLOBAL INPUTS: Curmonster, Lines, Circle, Shield, Player, *stdscr,
+/ Fightenv[], *Enemyname
+/
+/ GLOBAL OUTPUTS: Curmonster, Whichmonster, Lines, Shield, Player,
+/ *Enemyname
+/
+/ DESCRIPTION:
+/ Handle all special monsters here. If the monster is not a special
+/ one, simply roll a hit against the player.
+/
+/************************************************************************/
+
+monsthits()
+{
+double inflict; /* damage inflicted */
+int ch; /* input */
+
+ switch (Curmonster.m_type)
+ /* may be a special monster */
+ {
+ case SM_DARKLORD:
+ /* hits just enough to kill player */
+ inflict = (Player.p_energy + Shield) * 1.02;
+ goto SPECIALHIT;
+
+ case SM_SHRIEKER:
+ /* call a big monster */
+ mvaddstr(Lines++, 0,
+ "Shrieeeek!! You scared it, and it called one of its friends.");
+ more(Lines);
+ Whichmonster = (int) ROLL(70.0, 30.0);
+ longjmp(Fightenv, 0);
+ /*NOTREACHED*/
+
+ case SM_BALROG:
+ /* take experience away */
+ inflict = ROLL(10.0, Curmonster.m_strength);
+ inflict = MIN(Player.p_experience, inflict);
+ mvprintw(Lines++, 0,
+ "%s took away %.0f experience points.", Enemyname, inflict);
+ Player.p_experience -= inflict;
+ return;
+
+ case SM_FAERIES:
+ if (Player.p_holywater > 0)
+ /* holy water kills when monster tries to hit */
+ {
+ mvprintw(Lines++, 0, "Your holy water killed it!");
+ --Player.p_holywater;
+ Curmonster.m_energy = 0.0;
+ return;
+ }
+ break;
+
+ case SM_NONE:
+ /* normal hit */
+ break;
+
+ default:
+ if (drandom() > 0.2)
+ /* normal hit */
+ break;
+
+ /* else special things */
+ switch (Curmonster.m_type)
+ {
+ case SM_LEANAN:
+ /* takes some of the player's strength */
+ inflict = ROLL(1.0, (Circle - 1.0) / 2.0);
+ inflict = MIN(Player.p_strength, inflict);
+ mvprintw(Lines++, 0, "%s sapped %0.f of your strength!",
+ Enemyname, inflict);
+ Player.p_strength -= inflict;
+ Player.p_might -= inflict;
+ break;
+
+ case SM_SARUMAN:
+ if (Player.p_palantir)
+ /* take away palantir */
+ {
+ mvprintw(Lines++, 0, "Wormtongue stole your palantir!");
+ Player.p_palantir = FALSE;
+ }
+ else if (drandom() > 0.5)
+ /* gems turn to gold */
+ {
+ mvprintw(Lines++, 0,
+ "%s transformed your gems into gold!", Enemyname);
+ Player.p_gold += Player.p_gems;
+ Player.p_gems = 0.0;
+ }
+ else
+ /* scramble some stats */
+ {
+ mvprintw(Lines++, 0, "%s scrambled your stats!", Enemyname);
+ scramblestats();
+ }
+ break;
+
+ case SM_THAUMATURG:
+ /* transport player */
+ mvprintw(Lines++, 0, "%s transported you!", Enemyname);
+ altercoordinates(0.0, 0.0, A_FAR);
+ cancelmonster();
+ break;
+
+ case SM_VORTEX:
+ /* suck up some mana */
+ inflict = ROLL(0, 7.5 * Circle);
+ inflict = MIN(Player.p_mana, floor(inflict));
+ mvprintw(Lines++, 0,
+ "%s sucked up %.0f of your mana!", Enemyname, inflict);
+ Player.p_mana -= inflict;
+ break;
+
+ case SM_NAZGUL:
+ /* try to take ring if player has one */
+ if (Player.p_ring.ring_type != R_NONE)
+ /* player has a ring */
+ {
+ mvaddstr(Lines++, 0, "Will you relinguish your ring ? ");
+ ch = getanswer("YN", FALSE);
+ if (ch == 'Y')
+ /* take ring away */
+ {
+ Player.p_ring.ring_type = R_NONE;
+ Player.p_ring.ring_inuse = FALSE;
+ cancelmonster();
+ break;
+ }
+ }
+
+ /* otherwise, take some brains */
+ mvprintw(Lines++, 0,
+ "%s neutralized 1/5 of your brain!", Enemyname);
+ Player.p_brains *= 0.8;
+ break;
+
+ case SM_TIAMAT:
+ /* take some gold and gems */
+ mvprintw(Lines++, 0,
+ "%s took half your gold and gems and flew off.", Enemyname);
+ Player.p_gold /= 2.0;
+ Player.p_gems /= 2.0;
+ cancelmonster();
+ break;
+
+ case SM_KOBOLD:
+ /* steal a gold piece and run */
+ mvprintw(Lines++, 0,
+ "%s stole one gold piece and ran away.", Enemyname);
+ Player.p_gold = MAX(0.0, Player.p_gold - 1.0);
+ cancelmonster();
+ break;
+
+ case SM_SHELOB:
+ /* bite and (medium) poison */
+ mvprintw(Lines++, 0,
+ "%s has bitten and poisoned you!", Enemyname);
+ Player.p_poison -= 1.0;
+ break;
+
+ case SM_LAMPREY:
+ /* bite and (small) poison */
+ mvprintw(Lines++, 0, "%s bit and poisoned you!", Enemyname);
+ Player.p_poison += 0.25;
+ break;
+
+ case SM_BONNACON:
+ /* fart and run */
+ mvprintw(Lines++, 0, "%s farted and scampered off.", Enemyname);
+ Player.p_energy /= 2.0; /* damage from fumes */
+ cancelmonster();
+ break;
+
+ case SM_SMEAGOL:
+ if (Player.p_ring.ring_type != R_NONE)
+ /* try to steal ring */
+ {
+ mvprintw(Lines++, 0,
+ "%s tried to steal your ring, ", Enemyname);
+ if (drandom() > 0.1)
+ addstr("but was unsuccessful.");
+ else
+ {
+ addstr("and ran away with it!");
+ Player.p_ring.ring_type = R_NONE;
+ cancelmonster();
+ }
+ }
+ break;
+
+ case SM_SUCCUBUS:
+ /* inflict damage through shield */
+ inflict = ROLL(15.0, Circle * 10.0);
+ inflict = MIN(inflict, Player.p_energy);
+ mvprintw(Lines++, 0, "%s sapped %.0f of your energy.",
+ Enemyname, inflict);
+ Player.p_energy -= inflict;
+ break;
+
+ case SM_CERBERUS:
+ /* take all metal treasures */
+ mvprintw(Lines++, 0,
+ "%s took all your metal treasures!", Enemyname);
+ Player.p_crowns = 0;
+ Player.p_sword =
+ Player.p_shield =
+ Player.p_gold = 0.0;
+ cancelmonster();
+ break;
+
+ case SM_UNGOLIANT:
+ /* (large) poison and take a quickness */
+ mvprintw(Lines++, 0,
+ "%s poisoned you, and took one quik.", Enemyname);
+ Player.p_poison += 5.0;
+ Player.p_quickness -= 1.0;
+ break;
+
+ case SM_JABBERWOCK:
+ /* fly away, and leave either a Jubjub bird or Bonnacon */
+ mvprintw(Lines++, 0,
+ "%s flew away, and left you to contend with one of its friends.",
+ Enemyname);
+ Whichmonster = 55 + (drandom() > 0.5) ? 22 : 0;
+ longjmp(Fightenv, 0);
+ /*NOTREACHED*/
+
+ case SM_TROLL:
+ /* partially regenerate monster */
+ mvprintw(Lines++, 0,
+ "%s partially regenerated his energy.!", Enemyname);
+ Curmonster.m_energy +=
+ floor((Curmonster.m_o_energy - Curmonster.m_energy) / 2.0);
+ Curmonster.m_strength = Curmonster.m_o_strength;
+ Curmonster.m_melee = Curmonster.m_skirmish = 0.0;
+ Curmonster.m_maxspeed = Curmonster.m_o_speed;
+ break;
+
+ case SM_WRAITH:
+ if (!Player.p_blindness)
+ /* make blind */
+ {
+ mvprintw(Lines++, 0, "%s blinded you!", Enemyname);
+ Player.p_blindness = TRUE;
+ Enemyname = "A monster";
+ }
+ break;
+ }
+ return;
+ }
+
+ /* fall through to here if monster inflicts a normal hit */
+ inflict = drandom() * Curmonster.m_strength + 0.5;
+SPECIALHIT:
+ mvprintw(Lines++, 0, "%s hit you %.0f times!", Enemyname, inflict);
+
+ if ((Shield -= inflict) < 0)
+ {
+ Player.p_energy += Shield;
+ Shield = 0.0;
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: cancelmonster()
+/
+/ FUNCTION: mark current monster as no longer active
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: none
+/
+/ GLOBAL INPUTS: none
+/
+/ GLOBAL OUTPUTS: Curmonster
+/
+/ DESCRIPTION:
+/ Clear current monster's energy, experience, treasure type, and
+/ flock. This is the same as having the monster run away.
+/
+/************************************************************************/
+
+cancelmonster()
+{
+ Curmonster.m_energy = 0.0;
+ Curmonster.m_experience = 0.0;
+ Curmonster.m_treasuretype = 0;
+ Curmonster.m_flock = 0.0;
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: hitmonster()
+/
+/ FUNCTION: inflict damage upon current monster
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ double inflict - damage to inflict upon monster
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: monsthits(), wmove(), strcmp(), waddstr(), mvprintw()
+/
+/ GLOBAL INPUTS: Curmonster, Lines, Player, *stdscr, *Enemyname
+/
+/ GLOBAL OUTPUTS: Curmonster, Lines
+/
+/ DESCRIPTION:
+/ Hit monster specified number of times. Handle when monster dies,
+/ and a few special monsters.
+/
+/************************************************************************/
+
+hitmonster(inflict)
+double inflict;
+{
+ mvprintw(Lines++, 0, "You hit %s %.0f times!", Enemyname, inflict);
+ Curmonster.m_energy -= inflict;
+ if (Curmonster.m_energy > 0.0)
+ {
+ if (Curmonster.m_type == SM_DARKLORD || Curmonster.m_type == SM_SHRIEKER)
+ /* special monster didn't die */
+ monsthits();
+ }
+ else
+ /* monster died. print message. */
+ {
+ if (Curmonster.m_type == SM_MORGOTH)
+ mvaddstr(Lines++, 0, "You have defeated Morgoth, but he may return. . .");
+ else
+ /* all other types of monsters */
+ {
+ mvprintw(Lines++, 0, "You killed it. Good work, %s.", Player.p_name);
+
+ if (Curmonster.m_type == SM_MIMIC
+ && strcmp(Curmonster.m_name, "A Mimic") != 0
+ && !Player.p_blindness)
+ mvaddstr(Lines++, 0, "The body slowly changes into the form of a mimic.");
+ }
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: throwspell()
+/
+/ FUNCTION: throw a magic spell
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: hitmonster(), cancelmonster(), sqrt(), floor(), wmove(),
+/ drandom(), altercoordinates(), longjmp(), infloat(), waddstr(), mvprintw(),
+/ getanswer()
+/
+/ GLOBAL INPUTS: Curmonster, Whichmonster, Nomana[], Player, *stdscr,
+/ Fightenv[], Illspell[], *Enemyname
+/
+/ GLOBAL OUTPUTS: Curmonster, Whichmonster, Shield, Player
+/
+/ DESCRIPTION:
+/ Prompt player and process magic spells.
+/
+/************************************************************************/
+
+throwspell()
+{
+double inflict; /* damage inflicted */
+double dtemp; /* for dtemporary calculations */
+int ch; /* input */
+
+ mvaddstr(7, 0, "\n\n"); /* clear menu area */
+
+ if (Player.p_magiclvl >= ML_ALLORNOTHING)
+ mvaddstr(7, 0, "1:All or Nothing ");
+ if (Player.p_magiclvl >= ML_MAGICBOLT)
+ addstr("2:Magic Bolt ");
+ if (Player.p_magiclvl >= ML_FORCEFIELD)
+ addstr("3:Force Field ");
+ if (Player.p_magiclvl >= ML_XFORM)
+ addstr("4:Transform ");
+ if (Player.p_magiclvl >= ML_INCRMIGHT)
+ addstr("5:Increase Might\n");
+ if (Player.p_magiclvl >= ML_INVISIBLE)
+ mvaddstr(8, 0, "6:Invisibility ");
+ if (Player.p_magiclvl >= ML_XPORT)
+ addstr("7:Transport ");
+ if (Player.p_magiclvl >= ML_PARALYZE)
+ addstr("8:Paralyze ");
+ if (Player.p_specialtype >= SC_COUNCIL)
+ addstr("9:Specify");
+ mvaddstr(4, 0, "Spell ? ");
+
+ ch = getanswer(" ", TRUE);
+
+ mvaddstr(7, 0, "\n\n"); /* clear menu area */
+
+ if (Curmonster.m_type == SM_MORGOTH && ch != '3')
+ /* can only throw force field against Morgoth */
+ ILLSPELL();
+ else
+ switch (ch)
+ {
+ case '1': /* all or nothing */
+ if (drandom() < 0.25)
+ /* success */
+ {
+ inflict = Curmonster.m_energy * 1.01 + 1.0;
+
+ if (Curmonster.m_type == SM_DARKLORD)
+ /* all or nothing doesn't quite work against D. L. */
+ inflict *= 0.9;
+ }
+ else
+ /* failure -- monster gets stronger and quicker */
+ {
+ Curmonster.m_o_strength = Curmonster.m_strength *= 2.0;
+ Curmonster.m_maxspeed *= 2.0;
+ Curmonster.m_o_speed *= 2.0;
+
+ /* paralyzed monsters wake up a bit */
+ Curmonster.m_speed = MAX(1.0, Curmonster.m_speed * 2.0);
+ }
+
+ if (Player.p_mana >= MM_ALLORNOTHING)
+ /* take a mana if player has one */
+ Player.p_mana -= MM_ALLORNOTHING;
+
+ hitmonster(inflict);
+ break;
+
+ case '2': /* magic bolt */
+ if (Player.p_magiclvl < ML_MAGICBOLT)
+ ILLSPELL();
+ else
+ {
+ do
+ /* prompt for amount to expend */
+ {
+ mvaddstr(4, 0, "How much mana for bolt? ");
+ dtemp = floor(infloat());
+ }
+ while (dtemp < 0.0 || dtemp > Player.p_mana);
+
+ Player.p_mana -= dtemp;
+
+ if (Curmonster.m_type == SM_DARKLORD)
+ /* magic bolts don't work against D. L. */
+ inflict = 0.0;
+ else
+ inflict = dtemp * ROLL(15.0, sqrt(Player.p_magiclvl / 3.0 + 1.0));
+ mvaddstr(5, 0, "Magic Bolt fired!\n");
+ hitmonster(inflict);
+ }
+ break;
+
+ case '3': /* force field */
+ if (Player.p_magiclvl < ML_FORCEFIELD)
+ ILLSPELL();
+ else if (Player.p_mana < MM_FORCEFIELD)
+ NOMANA();
+ else
+ {
+ Player.p_mana -= MM_FORCEFIELD;
+ Shield = (Player.p_maxenergy + Player.p_shield) * 4.2 + 45.0;
+ mvaddstr(5, 0, "Force Field up.\n");
+ }
+ break;
+
+ case '4': /* transform */
+ if (Player.p_magiclvl < ML_XFORM)
+ ILLSPELL();
+ else if (Player.p_mana < MM_XFORM)
+ NOMANA();
+ else
+ {
+ Player.p_mana -= MM_XFORM;
+ Whichmonster = (int) ROLL(0.0, 100.0);
+ longjmp(Fightenv, 0);
+ /*NOTREACHED*/
+ }
+ break;
+
+ case '5': /* increase might */
+ if (Player.p_magiclvl < ML_INCRMIGHT)
+ ILLSPELL();
+ else if (Player.p_mana < MM_INCRMIGHT)
+ NOMANA();
+ else
+ {
+ Player.p_mana -= MM_INCRMIGHT;
+ Player.p_might +=
+ (1.2 * (Player.p_strength + Player.p_sword)
+ + 5.0 - Player.p_might) / 2.0;
+ mvprintw(5, 0, "New strength: %.0f\n", Player.p_might);
+ }
+ break;
+
+ case '6': /* invisible */
+ if (Player.p_magiclvl < ML_INVISIBLE)
+ ILLSPELL();
+ else if (Player.p_mana < MM_INVISIBLE)
+ NOMANA();
+ else
+ {
+ Player.p_mana -= MM_INVISIBLE;
+ Player.p_speed +=
+ (1.2 * (Player.p_quickness + Player.p_quksilver)
+ + 5.0 - Player.p_speed) / 2.0;
+ mvprintw(5, 0, "New quickness: %.0f\n", Player.p_speed);
+ }
+ break;
+
+ case '7': /* transport */
+ if (Player.p_magiclvl < ML_XPORT)
+ ILLSPELL();
+ else if (Player.p_mana < MM_XPORT)
+ NOMANA();
+ else
+ {
+ Player.p_mana -= MM_XPORT;
+ if (Player.p_brains + Player.p_magiclvl
+ < Curmonster.m_experience / 200.0 * drandom())
+ {
+ mvaddstr(5, 0, "Transport backfired!\n");
+ altercoordinates(0.0, 0.0, A_FAR);
+ cancelmonster();
+ }
+ else
+ {
+ mvprintw(5, 0, "%s is transported.\n", Enemyname);
+ if (drandom() < 0.3)
+ /* monster didn't drop its treasure */
+ Curmonster.m_treasuretype = 0;
+
+ Curmonster.m_energy = 0.0;
+ }
+ }
+ break;
+
+ case '8': /* paralyze */
+ if (Player.p_magiclvl < ML_PARALYZE)
+ ILLSPELL();
+ else if (Player.p_mana < MM_PARALYZE)
+ NOMANA();
+ else
+ {
+ Player.p_mana -= MM_PARALYZE;
+ if (Player.p_magiclvl >
+ Curmonster.m_experience / 1000.0 * drandom())
+ {
+ mvprintw(5, 0, "%s is held.\n", Enemyname);
+ Curmonster.m_speed = -2.0;
+ }
+ else
+ mvaddstr(5, 0, "Monster unaffected.\n");
+ }
+ break;
+
+ case '9': /* specify */
+ if (Player.p_specialtype < SC_COUNCIL)
+ ILLSPELL();
+ else if (Player.p_mana < MM_SPECIFY)
+ NOMANA();
+ else
+ {
+ Player.p_mana -= MM_SPECIFY;
+ mvaddstr(5, 0, "Which monster do you want [0-99] ? ");
+ Whichmonster = (int) infloat();
+ Whichmonster = MAX(0, MIN(99, Whichmonster));
+ longjmp(Fightenv, 0);
+ /*NOTREACHED*/
+ }
+ break;
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: callmonster()
+/
+/ FUNCTION: read monster from file, and fill structure
+/
+/ AUTHOR: E. A. Estes, 2/25/86
+/
+/ ARGUMENTS:
+/ int which - which monster to call
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: truncstring(), fread(), fseek(), floor(), drandom(),
+/ strcpy()
+/
+/ GLOBAL INPUTS: Curmonster, Circle, Player, *Monstfp
+/
+/ GLOBAL OUTPUTS: Curmonster, Player, *Enemyname
+/
+/ DESCRIPTION:
+/ Read specified monster from monster database and fill up
+/ current monster structure.
+/ Adjust statistics based upon current size.
+/ Handle some special monsters.
+/
+/************************************************************************/
+
+callmonster(which)
+int which;
+{
+struct monster Othermonster; /* to find a name for mimics */
+
+ which = MIN(which, 99); /* make sure within range */
+
+ /* fill structure */
+ fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, 0);
+ fread((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp);
+
+ /* handle some special monsters */
+ if (Curmonster.m_type == SM_MODNAR)
+ {
+ if (Player.p_specialtype < SC_COUNCIL)
+ /* randomize some stats */
+ {
+ Curmonster.m_strength *= drandom() + 0.5;
+ Curmonster.m_brains *= drandom() + 0.5;
+ Curmonster.m_speed *= drandom() + 0.5;
+ Curmonster.m_energy *= drandom() + 0.5;
+ Curmonster.m_experience *= drandom() + 0.5;
+ Curmonster.m_treasuretype =
+ (int) ROLL(0.0, (double) Curmonster.m_treasuretype);
+ }
+ else
+ /* make Modnar into Morgoth */
+ {
+ strcpy(Curmonster.m_name, "Morgoth");
+ Curmonster.m_strength = drandom() * (Player.p_maxenergy + Player.p_shield) / 1.4
+ + drandom() * (Player.p_maxenergy + Player.p_shield) / 1.5;
+ Curmonster.m_brains = Player.p_brains;
+ Curmonster.m_energy = Player.p_might * 30.0;
+ Curmonster.m_type = SM_MORGOTH;
+ Curmonster.m_speed = Player.p_speed * 1.1
+ + (Player.p_specialtype == SC_EXVALAR) ? Player.p_speed : 0.0;
+ Curmonster.m_flock = 0.0;
+ Curmonster.m_treasuretype = 0;
+ Curmonster.m_experience = 0.0;
+ }
+ }
+ else if (Curmonster.m_type == SM_MIMIC)
+ /* pick another name */
+ {
+ which = (int) ROLL(0.0, 100.0);
+ fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, 0);
+ fread(&Othermonster, SZ_MONSTERSTRUCT, 1, Monstfp);
+ strcpy(Curmonster.m_name, Othermonster.m_name);
+ }
+
+ truncstring(Curmonster.m_name);
+
+ if (Curmonster.m_type != SM_MORGOTH)
+ /* adjust stats based on which circle player is in */
+ {
+ Curmonster.m_strength *= (1.0 + Circle / 2.0);
+ Curmonster.m_brains *= Circle;
+ Curmonster.m_speed += Circle * 1.e-9;
+ Curmonster.m_energy *= Circle;
+ Curmonster.m_experience *= Circle;
+ }
+
+ if (Player.p_blindness)
+ /* cannot see monster if blind */
+ Enemyname = "A monster";
+ else
+ Enemyname = Curmonster.m_name;
+
+ if (Player.p_speed <= 0.0)
+ /* make Player.p_speed positive */
+ {
+ Curmonster.m_speed += -Player.p_speed;
+ Player.p_speed = 1.0;
+ }
+
+ /* fill up the rest of the structure */
+ Curmonster.m_o_strength = Curmonster.m_strength;
+ Curmonster.m_o_speed = Curmonster.m_maxspeed = Curmonster.m_speed;
+ Curmonster.m_o_energy = Curmonster.m_energy;
+ Curmonster.m_melee = Curmonster.m_skirmish = 0.0;
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: awardtreasure()
+/
+/ FUNCTION: select a treasure
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: pickmonster(), collecttaxes(), more(), cursedtreasure(),
+/ floor(), wmove(), drandom(), sscanf(), printw(), altercoordinates(),
+/ longjmp(), infloat(), waddstr(), getanswer(), getstring(), wclrtobot()
+/
+/ GLOBAL INPUTS: Somebetter[], Curmonster, Whichmonster, Circle, Player,
+/ *stdscr, Databuf[], *Statptr, Fightenv[]
+/
+/ GLOBAL OUTPUTS: Whichmonster, Shield, Player
+/
+/ DESCRIPTION:
+/ Roll up a treasure based upon monster type and size, and
+/ certain player statistics.
+/ Handle cursed treasure.
+/
+/************************************************************************/
+
+awardtreasure()
+{
+register int whichtreasure; /* calculated treasure to grant */
+int temp; /* temporary */
+int ch; /* input */
+double treasuretype; /* monster's treasure type */
+double gold = 0.0; /* gold awarded */
+double gems = 0.0; /* gems awarded */
+double dtemp; /* for temporary calculations */
+
+ whichtreasure = (int) ROLL(1.0, 3.0); /* pick a treasure */
+ treasuretype = (double) Curmonster.m_treasuretype;
+
+ move(4, 0);
+ clrtobot();
+ move(6, 0);
+
+ if (drandom() > 0.65)
+ /* gold and gems */
+ {
+ if (Curmonster.m_treasuretype > 7)
+ /* gems */
+ {
+ gems = ROLL(1.0, (treasuretype - 7.0)
+ * (treasuretype - 7.0) * (Circle - 1.0) / 4.0);
+ printw("You have discovered %.0f gems!", gems);
+ }
+ else
+ /* gold */
+ {
+ gold = ROLL(treasuretype * 10.0, treasuretype
+ * treasuretype * 10.0 * (Circle - 1.0));
+ printw("You have found %.0f gold pieces.", gold);
+ }
+
+ addstr(" Do you want to pick them up ? ");
+ ch = getanswer("NY", FALSE);
+ addstr("\n\n");
+
+ if (ch == 'Y')
+ if (drandom() < treasuretype / 35.0 + 0.04)
+ /* cursed */
+ {
+ addstr("They were cursed!\n");
+ cursedtreasure();
+ }
+ else
+ collecttaxes(gold, gems);
+
+ return;
+ }
+ else
+ /* other treasures */
+ {
+ addstr("You have found some treasure. Do you want to inspect it ? ");
+ ch = getanswer("NY", FALSE);
+ addstr("\n\n");
+
+ if (ch != 'Y')
+ return;
+ else
+ if (drandom() < 0.08 && Curmonster.m_treasuretype != 4)
+ {
+ addstr("It was cursed!\n");
+ cursedtreasure();
+ return;
+ }
+ else
+ switch (Curmonster.m_treasuretype)
+ {
+ case 1: /* treasure type 1 */
+ switch (whichtreasure)
+ {
+ case 1:
+ addstr("You've discovered a power booster!\n");
+ Player.p_mana += ROLL(Circle * 4.0, Circle * 30.0);
+ break;
+
+ case 2:
+ addstr("You have encountered a druid.\n");
+ Player.p_experience +=
+ ROLL(0.0, 2000.0 + Circle * 400.0);
+ break;
+
+ case 3:
+ addstr("You have found a holy orb.\n");
+ Player.p_sin = MAX(0.0, Player.p_sin - 0.25);
+ break;
+ }
+ break;
+ /* end treasure type 1 */
+
+ case 2: /* treasure type 2 */
+ switch (whichtreasure)
+ {
+ case 1:
+ addstr("You have found an amulet.\n");
+ ++Player.p_amulets;
+ break;
+
+ case 2:
+ addstr("You've found some holy water!\n");
+ ++Player.p_holywater;
+ break;
+
+ case 3:
+ addstr("You've met a hermit!\n");
+ Player.p_sin *= 0.75;
+ Player.p_mana += 12.0 * Circle;
+ break;
+ }
+ break;
+ /* end treasure type 2 */
+
+ case 3: /* treasure type 3 */
+ switch (whichtreasure)
+ {
+ case 1:
+ dtemp = ROLL(7.0, 30.0 + Circle / 10.0);
+ printw("You've found a +%.0f shield!\n", dtemp);
+ if (dtemp >= Player.p_shield)
+ Player.p_shield = dtemp;
+ else
+ SOMEBETTER();
+ break;
+
+ case 2:
+ addstr("You have rescued a virgin. Will you be honorable ? ");
+ ch = getanswer("NY", FALSE);
+ addstr("\n\n");
+ if (ch == 'Y')
+ Player.p_virgin = TRUE;
+ else
+ {
+ Player.p_experience += 2000.0 * Circle;
+ ++Player.p_sin;
+ }
+ break;
+
+ case 3:
+ addstr("You've discovered some athelas!\n");
+ --Player.p_poison;
+ break;
+ }
+ break;
+ /* end treasure type 3 */
+
+ case 4: /* treasure type 4 */
+ addstr("You've found a scroll. Will you read it ? ");
+ ch = getanswer("NY", FALSE);
+ addstr("\n\n");
+
+ if (ch == 'Y')
+ switch ((int) ROLL(1, 6))
+ {
+ case 1:
+ addstr("It throws up a shield for you next monster.\n");
+ getyx(stdscr, whichtreasure, ch);
+ more(whichtreasure);
+ Shield =
+ (Player.p_maxenergy + Player.p_energy) * 5.5 + Circle * 50.0;
+ Whichmonster = pickmonster();
+ longjmp(Fightenv, 0);
+ /*NOTREACHED*/
+
+ case 2:
+ addstr("It makes you invisible for you next monster.\n");
+ getyx(stdscr, whichtreasure, ch);
+ more(whichtreasure);
+ Player.p_speed = 1e6;
+ Whichmonster = pickmonster();
+ longjmp(Fightenv, 0);
+ /*NOTREACHED*/
+
+ case 3:
+ addstr("It increases your strength ten fold to fight your next monster.\n");
+ getyx(stdscr, whichtreasure, ch);
+ more(whichtreasure);
+ Player.p_might *= 10.0;
+ Whichmonster = pickmonster();
+ longjmp(Fightenv, 0);
+ /*NOTREACHED*/
+
+ case 4:
+ addstr("It is a general knowledge scroll.\n");
+ Player.p_brains += ROLL(2.0, Circle);
+ Player.p_magiclvl += ROLL(1.0, Circle / 2.0);
+ break;
+
+ case 5:
+ addstr("It tells you how to pick your next monster.\n");
+ addstr("Which monster do you want [0-99] ? ");
+ Whichmonster = (int) infloat();
+ Whichmonster = MIN(99, MAX(0, Whichmonster));
+ longjmp(Fightenv, 0);
+
+ case 6:
+ addstr("It was cursed!\n");
+ cursedtreasure();
+ break;
+ }
+ break;
+ /* end treasure type 4 */
+
+ case 5: /* treasure type 5 */
+ switch (whichtreasure)
+ {
+ case 1:
+ dtemp = ROLL(Circle / 4.0 + 5.0, Circle / 2.0 + 9.0);
+ printw("You've discovered a +%.0f dagger.\n", dtemp);
+ if (dtemp >= Player.p_sword)
+ Player.p_sword = dtemp;
+ else
+ SOMEBETTER();
+ break;
+
+ case 2:
+ dtemp = ROLL(7.5 + Circle * 3.0, Circle * 2.0 + 160.0);
+ printw("You have found some +%.0f armour!\n", dtemp);
+ if (dtemp >= Player.p_shield)
+ Player.p_shield = dtemp;
+ else
+ SOMEBETTER();
+ break;
+
+ case 3:
+ addstr("You've found a tablet.\n");
+ Player.p_brains += 4.5 * Circle;
+ break;
+ }
+ break;
+ /* end treasure type 5 */
+
+ case 6: /* treasure type 6 */
+ switch (whichtreasure)
+ {
+ case 1:
+ addstr("You've found a priest.\n");
+ Player.p_energy = Player.p_maxenergy + Player.p_shield;
+ Player.p_sin /= 2.0;
+ Player.p_mana += 24.0 * Circle;
+ Player.p_brains += Circle;
+ break;
+
+ case 2:
+ addstr("You have come upon Robin Hood!\n");
+ Player.p_shield += Circle * 2.0;
+ Player.p_strength += Circle / 2.5 + 1.0;
+ break;
+
+ case 3:
+ dtemp = ROLL(2.0 + Circle / 4.0, Circle / 1.2 + 10.0);
+ printw("You have found a +%.0f axe!\n", dtemp);
+ if (dtemp >= Player.p_sword)
+ Player.p_sword = dtemp;
+ else
+ SOMEBETTER();
+ break;
+ }
+ break;
+ /* end treasure type 6 */
+
+ case 7: /* treasure type 7 */
+ switch (whichtreasure)
+ {
+ case 1:
+ addstr("You've discovered a charm!\n");
+ ++Player.p_charms;
+ break;
+
+ case 2:
+ addstr("You have encountered Merlyn!\n");
+ Player.p_brains += Circle + 5.0;
+ Player.p_magiclvl += Circle / 3.0 + 5.0;
+ Player.p_mana += Circle * 10.0;
+ break;
+
+ case 3:
+ dtemp = ROLL(5.0 + Circle / 3.0, Circle / 1.5 + 20.0);
+ printw("You have found a +%.0f war hammer!\n", dtemp);
+ if (dtemp >= Player.p_sword)
+ Player.p_sword = dtemp;
+ else
+ SOMEBETTER();
+ break;
+ }
+ break;
+ /* end treasure type 7 */
+
+ case 8: /* treasure type 8 */
+ switch (whichtreasure)
+ {
+ case 1:
+ addstr("You have found a healing potion.\n");
+ Player.p_poison = MIN(-2.0, Player.p_poison - 2.0);
+ break;
+
+ case 2:
+ addstr("You have discovered a transporter. Do you wish to go anywhere ? ");
+ ch = getanswer("NY", FALSE);
+ addstr("\n\n");
+ if (ch == 'Y')
+ {
+ double x, y;
+
+ addstr("X Y Coordinates ? ");
+ getstring(Databuf, SZ_DATABUF);
+ sscanf(Databuf, "%lf %lf", &x, &y);
+ altercoordinates(x, y, A_FORCED);
+ }
+ break;
+
+ case 3:
+ dtemp = ROLL(10.0 + Circle / 1.2, Circle * 3.0 + 30.0);
+ printw("You've found a +%.0f sword!\n", dtemp);
+ if (dtemp >= Player.p_sword)
+ Player.p_sword = dtemp;
+ else
+ SOMEBETTER();
+ break;
+ }
+ break;
+ /* end treasure type 8 */
+
+ case 10:
+ case 11:
+ case 12:
+ case 13: /* treasure types 10 - 13 */
+ if (drandom() < 0.33)
+ {
+ if (Curmonster.m_treasuretype == 10)
+ {
+ addstr("You've found a pair of elven boots!\n");
+ Player.p_quickness += 2.0;
+ break;
+ }
+ else if (Curmonster.m_treasuretype == 11
+ && !Player.p_palantir)
+ {
+ addstr("You've acquired Saruman's palantir.\n");
+ Player.p_palantir = TRUE;
+ break;
+ }
+ else if (Player.p_ring.ring_type == R_NONE
+ && Player.p_specialtype < SC_COUNCIL
+ && (Curmonster.m_treasuretype == 12
+ || Curmonster.m_treasuretype == 13))
+ /* roll up a ring */
+ {
+ if (drandom() < 0.8)
+ /* regular rings */
+ {
+ if (Curmonster.m_treasuretype == 12)
+ {
+ whichtreasure = R_NAZREG;
+ temp = 35;
+ }
+ else
+ {
+ whichtreasure = R_DLREG;
+ temp = 0;
+ }
+ }
+ else
+ /* bad rings */
+ {
+ whichtreasure = R_BAD;
+ temp = 15 + Statptr->c_ringduration + (int) ROLL(0,5);
+ }
+
+ addstr("You've discovered a ring. Will you pick it up ? ");
+ ch = getanswer("NY", FALSE);
+ addstr("\n\n");
+
+ if (ch == 'Y')
+ {
+ Player.p_ring.ring_type = whichtreasure;
+ Player.p_ring.ring_duration = temp;
+ }
+
+ break;
+ }
+ }
+ /* end treasure types 10 - 13 */
+ /* fall through to treasure type 9 if no treasure from above */
+
+ case 9: /* treasure type 9 */
+ switch (whichtreasure)
+ {
+ case 1:
+ if (Player.p_level <= 1000.0
+ && Player.p_crowns <= 3
+ && Player.p_level >= 10.0)
+ {
+ addstr("You have found a golden crown!\n");
+ ++Player.p_crowns;
+ break;
+ }
+ /* fall through otherwise */
+
+ case 2:
+ addstr("You've been blessed!\n");
+ Player.p_blessing = TRUE;
+ Player.p_sin /= 3.0;
+ Player.p_energy = Player.p_maxenergy + Player.p_shield;
+ Player.p_mana += 100.0 * Circle;
+ break;
+
+ case 3:
+ dtemp = ROLL(1.0, Circle / 5.0 + 5.0);
+ dtemp = MIN(dtemp, 99.0);
+ printw("You have discovered some +%.0f quicksilver!\n",dtemp);
+ if (dtemp >= Player.p_quksilver)
+ Player.p_quksilver = dtemp;
+ else
+ SOMEBETTER();
+ break;
+ }
+ break;
+ /* end treasure type 9 */
+ }
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: cursedtreasure()
+/
+/ FUNCTION: take care of cursed treasure
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: waddstr()
+/
+/ GLOBAL INPUTS: Player, *stdscr
+/
+/ GLOBAL OUTPUTS: Player
+/
+/ DESCRIPTION:
+/ Handle cursed treasure. Look for amulets and charms to save
+/ the player from the curse.
+/
+/************************************************************************/
+
+cursedtreasure()
+{
+ if (Player.p_charms > 0)
+ {
+ addstr("But your charm saved you!\n");
+ --Player.p_charms;
+ }
+ else if (Player.p_amulets > 0)
+ {
+ addstr("But your amulet saved you!\n");
+ --Player.p_amulets;
+ }
+ else
+ {
+ Player.p_energy = (Player.p_maxenergy + Player.p_shield) / 10.0;
+ Player.p_poison += 0.25;
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: scramblestats()
+/
+/ FUNCTION: scramble some selected statistics
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: floor(), drandom()
+/
+/ GLOBAL INPUTS: Player
+/
+/ GLOBAL OUTPUTS: Player
+/
+/ DESCRIPTION:
+/ Swap a few player statistics randomly.
+/
+/************************************************************************/
+
+scramblestats()
+{
+double dbuf[6]; /* to put statistic in */
+double dtemp1, dtemp2; /* for swapping values */
+register int first, second; /* indices for swapping */
+register double *dptr; /* pointer for filling and emptying buf[] */
+
+ /* fill buffer */
+ dptr = &dbuf[0];
+ *dptr++ = Player.p_strength;
+ *dptr++ = Player.p_mana;
+ *dptr++ = Player.p_brains;
+ *dptr++ = Player.p_magiclvl;
+ *dptr++ = Player.p_energy;
+ *dptr = Player.p_sin;
+
+ /* pick values to swap */
+ first = (int) ROLL(0, 5);
+ second = (int) ROLL(0, 5);
+
+ /* swap values */
+ dptr = &dbuf[0];
+ dtemp1 = dptr[first];
+ /* this expression is split to prevent a compiler loop on some compilers */
+ dtemp2 = dptr[second];
+ dptr[first] = dtemp2;
+ dptr[second] = dtemp1;
+
+ /* empty buffer */
+ Player.p_strength = *dptr++;
+ Player.p_mana = *dptr++;
+ Player.p_brains = *dptr++;
+ Player.p_magiclvl = *dptr++;
+ Player.p_energy = *dptr++;
+ Player.p_sin = *dptr;
+}
diff --git a/games/phantasia/gamesupport.c b/games/phantasia/gamesupport.c
new file mode 100644
index 0000000..c7481ef7
--- /dev/null
+++ b/games/phantasia/gamesupport.c
@@ -0,0 +1,722 @@
+/*
+ * gamesupport.c - auxiliary routines for support of Phantasia
+ */
+
+#include "include.h"
+
+/************************************************************************
+/
+/ FUNCTION NAME: changestats()
+/
+/ FUNCTION: examine/change statistics for a player
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ bool ingameflag - set if called while playing game (Wizard only)
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: freerecord(), writerecord(), descrstatus(), truncstring(),
+/ time(), more(), wmove(), wclear(), strcmp(), printw(), strcpy(),
+/ infloat(), waddstr(), cleanup(), findname(), userlist(), mvprintw(),
+/ localtime(), getanswer(), descrtype(), getstring()
+/
+/ GLOBAL INPUTS: LINES, *Login, Other, Wizard, Player, *stdscr, Databuf[],
+/ Fileloc
+/
+/ GLOBAL OUTPUTS: Echo
+/
+/ DESCRIPTION:
+/ Prompt for player name to examine/change.
+/ If the name is NULL, print a list of all players.
+/ If we are called from within the game, check for the
+/ desired name being the same as the current player's name.
+/ Only the 'Wizard' may alter players.
+/ Items are changed only if a non-zero value is specified.
+/ To change an item to 0, use 0.1; it will be truncated later.
+/
+/ Players may alter their names and passwords, if the following
+/ are true:
+/ - current login matches the character's logins
+/ - the password is known
+/ - the player is not in the middle of the game (ingameflag == FALSE)
+/
+/ The last condition is imposed for two reasons:
+/ - the game could possibly get a bit hectic if a player were
+/ continually changing his/her name
+/ - another player structure would be necessary to check for names
+/ already in use
+/
+/************************************************************************/
+
+changestats(ingameflag)
+bool ingameflag;
+{
+static char flag[2] = /* for printing values of bools */
+ {'F', 'T'};
+register struct player *playerp;/* pointer to structure to alter */
+register char *prompt; /* pointer to prompt string */
+int c; /* input */
+int today; /* day of year of today */
+int temp; /* temporary variable */
+long loc; /* location in player file */
+long now; /* time now */
+double dtemp; /* temporary variable */
+bool *bptr; /* pointer to bool item to change */
+double *dptr; /* pointer to double item to change */
+short *sptr; /* pointer to short item to change */
+
+ clear();
+
+ for (;;)
+ /* get name of player to examine/alter */
+ {
+ mvaddstr(5, 0, "Which character do you want to look at ? ");
+ getstring(Databuf, SZ_DATABUF);
+ truncstring(Databuf);
+
+ if (Databuf[0] == '\0')
+ userlist(ingameflag);
+ else
+ break;
+ }
+
+ loc = -1L;
+
+ if (!ingameflag)
+ /* use 'Player' structure */
+ playerp = &Player;
+ else if (strcmp(Databuf, Player.p_name) == 0)
+ /* alter/examine current player */
+ {
+ playerp = &Player;
+ loc = Fileloc;
+ }
+ else
+ /* use 'Other' structure */
+ playerp = &Other;
+
+ /* find player on file */
+ if (loc < 0L && (loc = findname(Databuf, playerp)) < 0L)
+ /* didn't find player */
+ {
+ clear();
+ mvaddstr(11, 0, "Not found.");
+ return;
+ }
+
+ time(&now);
+ today = localtime(&now)->tm_yday;
+
+ clear();
+
+ for (;;)
+ /* print player structure, and prompt for action */
+ {
+ mvprintw(0, 0,"A:Name %s\n", playerp->p_name);
+
+ if (Wizard)
+ printw("B:Password %s\n", playerp->p_password);
+ else
+ addstr("B:Password XXXXXXXX\n");
+
+ printw(" :Login %s\n", playerp->p_login);
+
+ printw("C:Experience %.0f\n", playerp->p_experience);
+ printw("D:Level %.0f\n", playerp->p_level);
+ printw("E:Strength %.0f\n", playerp->p_strength);
+ printw("F:Sword %.0f\n", playerp->p_sword);
+ printw(" :Might %.0f\n", playerp->p_might);
+ printw("G:Energy %.0f\n", playerp->p_energy);
+ printw("H:Max-Energy %.0f\n", playerp->p_maxenergy);
+ printw("I:Shield %.0f\n", playerp->p_shield);
+ printw("J:Quickness %.0f\n", playerp->p_quickness);
+ printw("K:Quicksilver %.0f\n", playerp->p_quksilver);
+ printw(" :Speed %.0f\n", playerp->p_speed);
+ printw("L:Magic Level %.0f\n", playerp->p_magiclvl);
+ printw("M:Mana %.0f\n", playerp->p_mana);
+ printw("N:Brains %.0f\n", playerp->p_brains);
+
+ if (Wizard || playerp->p_specialtype != SC_VALAR)
+ mvaddstr(0, 40, descrstatus(playerp));
+
+ mvprintw(1, 40, "O:Poison %0.3f\n", playerp->p_poison);
+ mvprintw(2, 40, "P:Gold %.0f\n", playerp->p_gold);
+ mvprintw(3, 40, "Q:Gem %.0f\n", playerp->p_gems);
+ mvprintw(4, 40, "R:Sin %0.3f\n", playerp->p_sin);
+ if (Wizard)
+ {
+ mvprintw(5, 40, "S:X-coord %.0f\n", playerp->p_x);
+ mvprintw(6, 40, "T:Y-coord %.0f\n", playerp->p_y);
+ }
+ else
+ {
+ mvaddstr(5, 40, "S:X-coord ?\n");
+ mvaddstr(6, 40, "T:Y-coord ?\n");
+ }
+
+ mvprintw(7, 40, "U:Age %ld\n", playerp->p_age);
+ mvprintw(8, 40, "V:Degenerated %d\n", playerp->p_degenerated);
+
+ mvprintw(9, 40, "W:Type %d (%s)\n",
+ playerp->p_type, descrtype(playerp, FALSE) + 1);
+ mvprintw(10, 40, "X:Special Type %d\n", playerp->p_specialtype);
+ mvprintw(11, 40, "Y:Lives %d\n", playerp->p_lives);
+ mvprintw(12, 40, "Z:Crowns %d\n", playerp->p_crowns);
+ mvprintw(13, 40, "0:Charms %d\n", playerp->p_charms);
+ mvprintw(14, 40, "1:Amulets %d\n", playerp->p_amulets);
+ mvprintw(15, 40, "2:Holy Water %d\n", playerp->p_holywater);
+
+ temp = today - playerp->p_lastused;
+ if (temp < 0)
+ /* last year */
+ temp += 365;
+ mvprintw(16, 40, "3:Lastused %d (%d)\n", playerp->p_lastused, temp);
+
+ mvprintw(18, 8, "4:Palantir %c 5:Blessing %c 6:Virgin %c 7:Blind %c",
+ flag[playerp->p_palantir],
+ flag[playerp->p_blessing],
+ flag[playerp->p_virgin],
+ flag[playerp->p_blindness]);
+
+ if (!Wizard)
+ mvprintw(19, 8, "8:Ring %c",
+ flag[playerp->p_ring.ring_type != R_NONE]);
+ else
+ mvprintw(19, 8, "8:Ring %d 9:Duration %d",
+ playerp->p_ring.ring_type, playerp->p_ring.ring_duration);
+
+ if (!Wizard
+ /* not wizard */
+ && (ingameflag || strcmp(Login, playerp->p_login) != 0))
+ /* in game or not examining own character */
+ {
+ if (ingameflag)
+ {
+ more(LINES - 1);
+ clear();
+ return;
+ }
+ else
+ cleanup(TRUE);
+ /*NOTREACHED*/
+ }
+
+ mvaddstr(20, 0, "!:Quit ?:Delete");
+ mvaddstr(21, 0, "What would you like to change ? ");
+
+ if (Wizard)
+ c = getanswer(" ", TRUE);
+ else
+ /* examining own player; allow to change name and password */
+ c = getanswer("!BA", FALSE);
+
+ switch (c)
+ {
+ case 'A': /* change name */
+ case 'B': /* change password */
+ if (!Wizard)
+ /* prompt for password */
+ {
+ mvaddstr(23, 0, "Password ? ");
+ Echo = FALSE;
+ getstring(Databuf, 9);
+ Echo = TRUE;
+ if (strcmp(Databuf, playerp->p_password) != 0)
+ continue;
+ }
+
+ if (c == 'A')
+ /* get new name */
+ {
+ mvaddstr(23, 0, "New name: ");
+ getstring(Databuf, SZ_NAME);
+ truncstring(Databuf);
+ if (Databuf[0] != '\0')
+ if (Wizard || findname(Databuf, &Other) < 0L)
+ strcpy(playerp->p_name, Databuf);
+ }
+ else
+ /* get new password */
+ {
+ if (!Wizard)
+ Echo = FALSE;
+
+ do
+ /* get two copies of new password until they match */
+ {
+ /* get first copy */
+ mvaddstr(23, 0, "New password ? ");
+ getstring(Databuf, SZ_PASSWORD);
+ if (Databuf[0] == '\0')
+ break;
+
+ /* get second copy */
+ mvaddstr(23, 0, "One more time ? ");
+ getstring(playerp->p_password, SZ_PASSWORD);
+ }
+ while (strcmp(playerp->p_password, Databuf) != 0);
+
+ Echo = TRUE;
+ }
+
+ continue;
+
+ case 'C': /* change experience */
+ prompt = "experience";
+ dptr = &playerp->p_experience;
+ goto DALTER;
+
+ case 'D': /* change level */
+ prompt = "level";
+ dptr = &playerp->p_level;
+ goto DALTER;
+
+ case 'E': /* change strength */
+ prompt = "strength";
+ dptr = &playerp->p_strength;
+ goto DALTER;
+
+ case 'F': /* change swords */
+ prompt = "sword";
+ dptr = &playerp->p_sword;
+ goto DALTER;
+
+ case 'G': /* change energy */
+ prompt = "energy";
+ dptr = &playerp->p_energy;
+ goto DALTER;
+
+ case 'H': /* change maximum energy */
+ prompt = "max energy";
+ dptr = &playerp->p_maxenergy;
+ goto DALTER;
+
+ case 'I': /* change shields */
+ prompt = "shield";
+ dptr = &playerp->p_shield;
+ goto DALTER;
+
+ case 'J': /* change quickness */
+ prompt = "quickness";
+ dptr = &playerp->p_quickness;
+ goto DALTER;
+
+ case 'K': /* change quicksilver */
+ prompt = "quicksilver";
+ dptr = &playerp->p_quksilver;
+ goto DALTER;
+
+ case 'L': /* change magic */
+ prompt = "magic level";
+ dptr = &playerp->p_magiclvl;
+ goto DALTER;
+
+ case 'M': /* change mana */
+ prompt = "mana";
+ dptr = &playerp->p_mana;
+ goto DALTER;
+
+ case 'N': /* change brains */
+ prompt = "brains";
+ dptr = &playerp->p_brains;
+ goto DALTER;
+
+ case 'O': /* change poison */
+ prompt = "poison";
+ dptr = &playerp->p_poison;
+ goto DALTER;
+
+ case 'P': /* change gold */
+ prompt = "gold";
+ dptr = &playerp->p_gold;
+ goto DALTER;
+
+ case 'Q': /* change gems */
+ prompt = "gems";
+ dptr = &playerp->p_gems;
+ goto DALTER;
+
+ case 'R': /* change sin */
+ prompt = "sin";
+ dptr = &playerp->p_sin;
+ goto DALTER;
+
+ case 'S': /* change x coord */
+ prompt = "x";
+ dptr = &playerp->p_x;
+ goto DALTER;
+
+ case 'T': /* change y coord */
+ prompt = "y";
+ dptr = &playerp->p_y;
+ goto DALTER;
+
+ case 'U': /* change age */
+ mvprintw(23, 0, "age = %ld; age = ", playerp->p_age);
+ dtemp = infloat();
+ if (dtemp != 0.0)
+ playerp->p_age = (long) dtemp;
+ continue;
+
+ case 'V': /* change degen */
+ mvprintw(23, 0, "degen = %d; degen = ", playerp->p_degenerated);
+ dtemp = infloat();
+ if (dtemp != 0.0)
+ playerp->p_degenerated = (int) dtemp;
+ continue;
+
+ case 'W': /* change type */
+ prompt = "type";
+ sptr = &playerp->p_type;
+ goto SALTER;
+
+ case 'X': /* change special type */
+ prompt = "special type";
+ sptr = &playerp->p_specialtype;
+ goto SALTER;
+
+ case 'Y': /* change lives */
+ prompt = "lives";
+ sptr = &playerp->p_lives;
+ goto SALTER;
+
+ case 'Z': /* change crowns */
+ prompt = "crowns";
+ sptr = &playerp->p_crowns;
+ goto SALTER;
+
+ case '0': /* change charms */
+ prompt = "charm";
+ sptr = &playerp->p_charms;
+ goto SALTER;
+
+ case '1': /* change amulet */
+ prompt = "amulet";
+ sptr = &playerp->p_amulets;
+ goto SALTER;
+
+ case '2': /* change holy water */
+ prompt = "holy water";
+ sptr = &playerp->p_holywater;
+ goto SALTER;
+
+ case '3': /* change last-used */
+ prompt = "last-used";
+ sptr = &playerp->p_lastused;
+ goto SALTER;
+
+ case '4': /* change palantir */
+ prompt = "palantir";
+ bptr = &playerp->p_palantir;
+ goto BALTER;
+
+ case '5': /* change blessing */
+ prompt = "blessing";
+ bptr = &playerp->p_blessing;
+ goto BALTER;
+
+ case '6': /* change virgin */
+ prompt = "virgin";
+ bptr = &playerp->p_virgin;
+ goto BALTER;
+
+ case '7': /* change blindness */
+ prompt = "blindness";
+ bptr = &playerp->p_blindness;
+ goto BALTER;
+
+ case '8': /* change ring type */
+ prompt = "ring-type";
+ sptr = &playerp->p_ring.ring_type;
+ goto SALTER;
+
+ case '9': /* change ring duration */
+ prompt = "ring-duration";
+ sptr = &playerp->p_ring.ring_duration;
+ goto SALTER;
+
+ case '!': /* quit, update */
+ if (Wizard &&
+ (!ingameflag || playerp != &Player))
+ /* turn off status if not modifying self */
+ {
+ playerp->p_status = S_OFF;
+ playerp->p_tampered = T_OFF;
+ }
+
+ writerecord(playerp, loc);
+ clear();
+ return;
+
+ case '?': /* delete player */
+ if (ingameflag && playerp == &Player)
+ /* cannot delete self */
+ continue;
+
+ freerecord(playerp, loc);
+ clear();
+ return;
+
+ default:
+ continue;
+ }
+DALTER:
+ mvprintw(23, 0, "%s = %f; %s = ", prompt, *dptr, prompt);
+ dtemp = infloat();
+ if (dtemp != 0.0)
+ *dptr = dtemp;
+ continue;
+
+SALTER:
+ mvprintw(23, 0, "%s = %d; %s = ", prompt, *sptr, prompt);
+ dtemp = infloat();
+ if (dtemp != 0.0)
+ *sptr = (short) dtemp;
+ continue;
+
+BALTER:
+ mvprintw(23, 0, "%s = %c; %s = ", prompt, flag[*bptr], prompt);
+ c = getanswer("\nTF", TRUE);
+ if (c == 'T')
+ *bptr = TRUE;
+ else if (c == 'F')
+ *bptr = FALSE;
+ continue;
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: monstlist()
+/
+/ FUNCTION: print a monster listing
+/
+/ AUTHOR: E. A. Estes, 2/27/86
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: puts(), fread(), fseek(), printf()
+/
+/ GLOBAL INPUTS: Curmonster, *Monstfp
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Read monster file, and print a monster listing on standard output.
+/
+/************************************************************************/
+
+monstlist()
+{
+register int count = 0; /* count in file */
+
+ puts(" #) Name Str Brain Quick Energy Exper Treas Type Flock%\n");
+ fseek(Monstfp, 0L, 0);
+ while (fread((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp) == 1)
+ printf("%2d) %-20.20s%4.0f %4.0f %2.0f %5.0f %5.0f %2d %2d %3.0f\n", count++,
+ Curmonster.m_name, Curmonster.m_strength, Curmonster.m_brains,
+ Curmonster.m_speed, Curmonster.m_energy, Curmonster.m_experience,
+ Curmonster.m_treasuretype, Curmonster.m_type, Curmonster.m_flock);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: scorelist()
+/
+/ FUNCTION: print player score board
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: fread(), fopen(), printf(), fclose()
+/
+/ GLOBAL INPUTS:
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Read the scoreboard file and print the contents.
+/
+/************************************************************************/
+
+scorelist()
+{
+struct scoreboard sbuf; /* for reading entries */
+register FILE *fp; /* to open the file */
+
+ if ((fp = fopen(_PATH_SCORE, "r")) != NULL)
+ {
+ while (fread((char *) &sbuf, SZ_SCORESTRUCT, 1, fp) == 1)
+ printf("%-20s (%-9s) Level: %6.0f Type: %s\n",
+ sbuf.sb_name, sbuf.sb_login, sbuf.sb_level, sbuf.sb_type);
+ fclose(fp);
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: activelist()
+/
+/ FUNCTION: print list of active players to standard output
+/
+/ AUTHOR: E. A. Estes, 3/7/86
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: descrstatus(), fread(), fseek(), printf(), descrtype()
+/
+/ GLOBAL INPUTS: Other, *Playersfp
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Read player file, and print list of active records to standard output.
+/
+/************************************************************************/
+
+activelist()
+{
+ fseek(Playersfp, 0L, 0);
+ printf("Current characters on file are:\n\n");
+
+ while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
+ if (Other.p_status != S_NOTUSED)
+ printf("%-20s (%-9s) Level: %6.0f %s (%s)\n",
+ Other.p_name, Other.p_login, Other.p_level,
+ descrtype(&Other, FALSE), descrstatus(&Other));
+
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: purgeoldplayers()
+/
+/ FUNCTION: purge inactive players from player file
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: freerecord(), time(), fread(), fseek(), localtime()
+/
+/ GLOBAL INPUTS: Other, *Playersfp
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Delete characters which have not been used with the last
+/ three weeks.
+/
+/************************************************************************/
+
+purgeoldplayers()
+{
+int today; /* day of year for today */
+int daysold; /* how many days since the character has been used */
+long ltime; /* time in seconds */
+long loc = 0L; /* location in file */
+
+ time(&ltime);
+ today = localtime(&ltime)->tm_yday;
+
+ for (;;)
+ {
+ fseek(Playersfp, loc, 0);
+ if (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) != 1)
+ break;
+
+ daysold = today - Other.p_lastused;
+ if (daysold < 0)
+ daysold += 365;
+
+ if (daysold > N_DAYSOLD)
+ /* player hasn't been used in a while; delete */
+ freerecord(&Other, loc);
+
+ loc += SZ_PLAYERSTRUCT;
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: enterscore()
+/
+/ FUNCTION: enter player into scoreboard
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: fread(), fseek(), fopen(), error(), strcmp(), fclose(),
+/ strcpy(), fwrite(), descrtype()
+/
+/ GLOBAL INPUTS: Player
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ The scoreboard keeps track of the highest character on a
+/ per-login basis.
+/ Search the scoreboard for an entry for the current login,
+/ if an entry is found, and it is lower than the current player,
+/ replace it, otherwise create an entry.
+/
+/************************************************************************/
+
+enterscore()
+{
+struct scoreboard sbuf; /* buffer to read in scoreboard entries */
+FILE *fp; /* to open scoreboard file */
+long loc = 0L; /* location in scoreboard file */
+bool found = FALSE; /* set if we found an entry for this login */
+
+ if ((fp = fopen(_PATH_SCORE, "r+")) != NULL)
+ {
+ while (fread((char *) &sbuf, SZ_SCORESTRUCT, 1, fp) == 1)
+ if (strcmp(Player.p_login, sbuf.sb_login) == 0)
+ {
+ found = TRUE;
+ break;
+ }
+ else
+ loc += SZ_SCORESTRUCT;
+ }
+ else
+ {
+ error(_PATH_SCORE);
+ /*NOTREACHED*/
+ }
+
+ /*
+ * At this point, 'loc' will either indicate a point beyond
+ * the end of file, or the place where the previous entry
+ * was found.
+ */
+
+ if ((!found) || Player.p_level > sbuf.sb_level)
+ /* put new entry in for this login */
+ {
+ strcpy(sbuf.sb_login, Player.p_login);
+ strcpy(sbuf.sb_name, Player.p_name);
+ sbuf.sb_level = Player.p_level;
+ strcpy(sbuf.sb_type, descrtype(&Player, TRUE));
+ }
+
+ /* update entry */
+ fseek(fp, loc, 0);
+ fwrite((char *) &sbuf, SZ_SCORESTRUCT, 1, fp);
+ fclose(fp);
+}
diff --git a/games/phantasia/include.h b/games/phantasia/include.h
new file mode 100644
index 0000000..bfaa8a7
--- /dev/null
+++ b/games/phantasia/include.h
@@ -0,0 +1,17 @@
+/*
+ * include.h - includes all important files for Phantasia
+ */
+
+#include <ctype.h>
+#include <curses.h>
+#include <math.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <time.h>
+#include <errno.h>
+
+#include "macros.h"
+#include "phantdefs.h"
+#include "phantstruct.h"
+#include "phantglobs.h"
+#include "pathnames.h"
diff --git a/games/phantasia/interplayer.c b/games/phantasia/interplayer.c
new file mode 100644
index 0000000..0c923f0
--- /dev/null
+++ b/games/phantasia/interplayer.c
@@ -0,0 +1,1208 @@
+/*
+ * interplayer.c - player to player routines for Phantasia
+ */
+
+#include "include.h"
+
+/************************************************************************
+/
+/ FUNCTION NAME: checkbattle()
+/
+/ FUNCTION: check to see if current player should battle another
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: battleplayer(), fread(), fseek()
+/
+/ GLOBAL INPUTS: Other, Users, Player, Fileloc, *Playersfp
+/
+/ GLOBAL OUTPUTS: Users
+/
+/ DESCRIPTION:
+/ Seach player file for a foe at the same coordinates as the
+/ current player.
+/ Also update user count.
+/
+/************************************************************************/
+
+checkbattle()
+{
+long foeloc = 0L; /* location in file of person to fight */
+
+ Users = 0;
+ fseek(Playersfp, 0L, 0);
+
+ while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
+ {
+ if (Other.p_status != S_OFF
+ && Other.p_status != S_NOTUSED
+ && Other.p_status != S_HUNGUP
+ && (Other.p_status != S_CLOAKED || Other.p_specialtype != SC_VALAR))
+ /* player is on and not a cloaked valar */
+ {
+ ++Users;
+
+ if (Player.p_x == Other.p_x
+ && Player.p_y == Other.p_y
+ /* same coordinates */
+ && foeloc != Fileloc
+ /* not self */
+ && Player.p_status == S_PLAYING
+ && (Other.p_status == S_PLAYING || Other.p_status == S_INBATTLE)
+ /* both are playing */
+ && Other.p_specialtype != SC_VALAR
+ && Player.p_specialtype != SC_VALAR)
+ /* neither is valar */
+ {
+ battleplayer(foeloc);
+ return;
+ }
+ }
+ foeloc += SZ_PLAYERSTRUCT;
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: battleplayer()
+/
+/ FUNCTION: inter-terminal battle with another player
+/
+/ AUTHOR: E. A. Estes, 2/15/86
+/
+/ ARGUMENTS:
+/ long foeplace - location in player file of person to battle
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: readrecord(), readmessage(), writerecord(), collecttaxes(),
+/ displaystats(), fabs(), more(), death(), sleep(), wmove(), waddch(), printw(),
+/ myturn(), altercoordinates(), waddstr(), wrefresh(), mvprintw(),
+/ getanswer(), wclrtoeol(), wclrtobot()
+/
+/ GLOBAL INPUTS: Foestrikes, LINES, Lines, Other, Shield, Player, *stdscr,
+/ Fileloc, *Enemyname
+/
+/ GLOBAL OUTPUTS: Foestrikes, Lines, Shield, Player, Luckout, *Enemyname
+/
+/ DESCRIPTION:
+/ Inter-terminal battle is a very fragile and slightly klugy thing.
+/ At any time, one player is master and the other is slave.
+/ We pick who is master first by speed and level. After that,
+/ the slave waits for the master to relinquish its turn, and
+/ the slave becomes master, and so on.
+/
+/ The items in the player structure which control the handshake are:
+/ p_tampered:
+/ master increments this to relinquish control
+/ p_istat:
+/ master sets this to specify particular action
+/ p_1scratch:
+/ set to total damage inflicted so far; changes to indicate action
+/
+/************************************************************************/
+
+battleplayer(foeplace)
+long foeplace;
+{
+double dtemp; /* for temporary calculations */
+double oldhits = 0.0; /* previous damage inflicted by foe */
+register int loop; /* for timing out */
+int ch; /* input */
+short oldtampered; /* old value of foe's p_tampered */
+
+ Lines = 8;
+ Luckout = FALSE;
+ mvaddstr(4, 0, "Preparing for battle!\n");
+ refresh();
+
+#ifdef SYS5
+ flushinp();
+#endif
+
+ /* set up variables, file, etc. */
+ Player.p_status = S_INBATTLE;
+ Shield = Player.p_energy;
+
+ /* if p_tampered is not 0, someone else may try to change it (king, etc.) */
+ Player.p_tampered = oldtampered = 1;
+ Player.p_1scratch = 0.0;
+ Player.p_istat = I_OFF;
+
+ readrecord(&Other, foeplace);
+ if (fabs(Player.p_level - Other.p_level) > 20.0)
+ /* see if players are greatly mismatched */
+ {
+ dtemp = (Player.p_level - Other.p_level) / MAX(Player.p_level, Other.p_level);
+ if (dtemp < -0.5)
+ /* foe outweighs this one */
+ Player.p_speed *= 2.0;
+ }
+
+ writerecord(&Player, Fileloc); /* write out all our info */
+
+ if (Player.p_blindness)
+ Enemyname = "someone";
+ else
+ Enemyname = Other.p_name;
+
+ mvprintw(6, 0, "You have encountered %s Level: %.0f\n", Enemyname, Other.p_level);
+ refresh();
+
+ for (loop = 0; Other.p_status != S_INBATTLE && loop < 30; ++loop)
+ /* wait for foe to respond */
+ {
+ readrecord(&Other, foeplace);
+ sleep(1);
+ }
+
+ if (Other.p_status != S_INBATTLE)
+ /* foe did not respond */
+ {
+ mvprintw(5, 0, "%s is not responding.\n", Enemyname);
+ goto LEAVE;
+ }
+ /* else, we are ready to battle */
+
+ move(4, 0);
+ clrtoeol();
+
+ /*
+ * determine who is first master
+ * if neither player is faster, check level
+ * if neither level is greater, battle is not allowed
+ * (this should never happen, but we have to handle it)
+ */
+ if (Player.p_speed > Other.p_speed)
+ Foestrikes = FALSE;
+ else if (Other.p_speed > Player.p_speed)
+ Foestrikes = TRUE;
+ else if (Player.p_level > Other.p_level)
+ Foestrikes = FALSE;
+ else if (Other.p_level > Player.p_level)
+ Foestrikes = TRUE;
+ else
+ /* no one is faster */
+ {
+ printw("You can't fight %s yet.", Enemyname);
+ goto LEAVE;
+ }
+
+ for (;;)
+ {
+ displaystats();
+ readmessage();
+ mvprintw(1, 26, "%20.0f", Shield); /* overprint energy */
+
+ if (!Foestrikes)
+ /* take action against foe */
+ myturn();
+ else
+ /* wait for foe to take action */
+ {
+ mvaddstr(4, 0, "Waiting...\n");
+ clrtoeol();
+ refresh();
+
+ for (loop = 0; loop < 20; ++loop)
+ /* wait for foe to act */
+ {
+ readrecord(&Other, foeplace);
+ if (Other.p_1scratch != oldhits)
+ /* p_1scratch changes to indicate action */
+ break;
+ else
+ /* wait and try again */
+ {
+ sleep(1);
+ addch('.');
+ refresh();
+ }
+ }
+
+ if (Other.p_1scratch == oldhits)
+ {
+ /* timeout */
+ mvaddstr(22, 0, "Timeout: waiting for response. Do you want to wait ? ");
+ ch = getanswer("NY", FALSE);
+ move(22, 0);
+ clrtobot();
+ if (ch == 'Y')
+ continue;
+ else
+ break;
+ }
+ else
+ /* foe took action */
+ {
+ switch (Other.p_istat)
+ {
+ case I_RAN: /* foe ran away */
+ mvprintw(Lines++, 0, "%s ran away!", Enemyname);
+ break;
+
+ case I_STUCK: /* foe tried to run, but couldn't */
+ mvprintw(Lines++, 0, "%s tried to run away.", Enemyname);
+ break;
+
+ case I_BLEWIT: /* foe tried to luckout, but didn't */
+ mvprintw(Lines++, 0, "%s tried to luckout!", Enemyname);
+ break;
+
+ default:
+ dtemp = Other.p_1scratch - oldhits;
+ mvprintw(Lines++, 0, "%s hit you %.0f times!", Enemyname, dtemp);
+ Shield -= dtemp;
+ break;
+ }
+
+ oldhits = Other.p_1scratch; /* keep track of old hits */
+
+ if (Other.p_tampered != oldtampered)
+ /* p_tampered changes to relinquish turn */
+ {
+ oldtampered = Other.p_tampered;
+ Foestrikes = FALSE;
+ }
+ }
+ }
+
+ /* decide what happens next */
+ refresh();
+ if (Lines > LINES - 2)
+ {
+ more(Lines);
+ move(Lines = 8, 0);
+ clrtobot();
+ }
+
+ if (Other.p_istat == I_KILLED || Shield < 0.0)
+ /* we died */
+ {
+ Shield = -2.0; /* insure this value is negative */
+ break;
+ }
+
+ if (Player.p_istat == I_KILLED)
+ /* we killed foe; award treasre */
+ {
+ mvprintw(Lines++, 0, "You killed %s!", Enemyname);
+ Player.p_experience += Other.p_experience;
+ Player.p_crowns += (Player.p_level < 1000.0) ? Other.p_crowns : 0;
+ Player.p_amulets += Other.p_amulets;
+ Player.p_charms += Other.p_charms;
+ collecttaxes(Other.p_gold, Other.p_gems);
+ Player.p_sword = MAX(Player.p_sword, Other.p_sword);
+ Player.p_shield = MAX(Player.p_shield, Other.p_shield);
+ Player.p_quksilver = MAX(Player.p_quksilver, Other.p_quksilver);
+ if (Other.p_virgin && !Player.p_virgin)
+ {
+ mvaddstr(Lines++, 0, "You have rescued a virgin. Will you be honorable ? ");
+ if ((ch = getanswer("YN", FALSE)) == 'Y')
+ Player.p_virgin = TRUE;
+ else
+ {
+ ++Player.p_sin;
+ Player.p_experience += 8000.0;
+ }
+ }
+ sleep(3); /* give other person time to die */
+ break;
+ }
+ else if (Player.p_istat == I_RAN || Other.p_istat == I_RAN)
+ /* either player ran away */
+ break;
+ }
+
+LEAVE:
+ /* clean up things and leave */
+ writerecord(&Player, Fileloc); /* update a final time */
+ altercoordinates(0.0, 0.0, A_NEAR); /* move away from battle site */
+ Player.p_energy = Shield; /* set energy to actual value */
+ Player.p_tampered = T_OFF; /* clear p_tampered */
+
+ more(Lines); /* pause */
+
+ move(4, 0);
+ clrtobot(); /* clear bottom area of screen */
+
+ if (Player.p_energy < 0.0)
+ /* we are dead */
+ death("Interterminal battle");
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: myturn()
+/
+/ FUNCTION: process players action against foe in battle
+/
+/ AUTHOR: E. A. Estes, 2/7/86
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: writerecord(), inputoption(), floor(), wmove(), drandom(),
+/ waddstr(), wrefresh(), mvprintw(), wclrtoeol(), wclrtobot()
+/
+/ GLOBAL INPUTS: Lines, Other, Player, *stdscr, Fileloc, Luckout,
+/ *Enemyname
+/
+/ GLOBAL OUTPUTS: Foestrikes, Lines, Player, Luckout
+/
+/ DESCRIPTION:
+/ Take action action against foe, and decide who is master
+/ for next iteration.
+/
+/************************************************************************/
+
+myturn()
+{
+double dtemp; /* for temporary calculations */
+int ch; /* input */
+
+ mvaddstr(7, 0, "1:Fight 2:Run Away! 3:Power Blast ");
+ if (Luckout)
+ clrtoeol();
+ else
+ addstr("4:Luckout ");
+
+ ch = inputoption();
+ move(Lines = 8, 0);
+ clrtobot();
+
+ switch (ch)
+ {
+ default: /* fight */
+ dtemp = ROLL(2.0, Player.p_might);
+HIT:
+ mvprintw(Lines++, 0, "You hit %s %.0f times!", Enemyname, dtemp);
+ Player.p_sin += 0.5;
+ Player.p_1scratch += dtemp;
+ Player.p_istat = I_OFF;
+ break;
+
+ case '2': /* run away */
+ Player.p_1scratch -= 1.0; /* change this to indicate action */
+ if (drandom() > 0.25)
+ {
+ mvaddstr(Lines++, 0, "You got away!");
+ Player.p_istat = I_RAN;
+ }
+ else
+ {
+ mvprintw(Lines++, 0, "%s is still after you!", Enemyname);
+ Player.p_istat = I_STUCK;
+ }
+ break;
+
+ case '3': /* power blast */
+ dtemp = MIN(Player.p_mana, Player.p_level * 5.0);
+ Player.p_mana -= dtemp;
+ dtemp *= (drandom() + 0.5) * Player.p_magiclvl * 0.2 + 2.0;
+ mvprintw(Lines++, 0, "You blasted %s !", Enemyname);
+ goto HIT;
+
+ case '4': /* luckout */
+ if (Luckout || drandom() > 0.1)
+ {
+ if (Luckout)
+ mvaddstr(Lines++, 0, "You already tried that!");
+ else
+ {
+ mvaddstr(Lines++, 0, "Not this time . . .");
+ Luckout = TRUE;
+ }
+
+ Player.p_1scratch -= 1.0;
+ Player.p_istat = I_BLEWIT;
+ }
+ else
+ {
+ mvaddstr(Lines++, 0, "You just lucked out!");
+ Player.p_1scratch = Other.p_energy * 1.1;
+ }
+ break;
+ }
+
+ refresh();
+ Player.p_1scratch = floor(Player.p_1scratch); /* clean up any mess */
+
+ if (Player.p_1scratch > Other.p_energy)
+ Player.p_istat = I_KILLED;
+ else if (drandom() * Player.p_speed < drandom() * Other.p_speed)
+ /* relinquish control */
+ {
+ ++Player.p_tampered;
+ Foestrikes = TRUE;
+ }
+
+ writerecord(&Player, Fileloc); /* let foe know what we did */
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: checktampered()
+/
+/ FUNCTION: check if current player has been tampered with
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: readrecord(), fread(), fseek(), tampered(), writevoid()
+/
+/ GLOBAL INPUTS: *Energyvoidfp, Other, Player, Fileloc, Enrgyvoid
+/
+/ GLOBAL OUTPUTS: Enrgyvoid
+/
+/ DESCRIPTION:
+/ Check for energy voids, holy grail, and tampering by other
+/ players.
+/
+/************************************************************************/
+
+checktampered()
+{
+long loc = 0L; /* location in energy void file */
+
+ /* first check for energy voids */
+ fseek(Energyvoidfp, 0L, 0);
+ while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1)
+ if (Enrgyvoid.ev_active
+ && Enrgyvoid.ev_x == Player.p_x
+ && Enrgyvoid.ev_y == Player.p_y)
+ /* sitting on one */
+ {
+ if (loc > 0L)
+ /* not the holy grail; inactivate energy void */
+ {
+ Enrgyvoid.ev_active = FALSE;
+ writevoid(&Enrgyvoid, loc);
+ tampered(T_NRGVOID, 0.0, 0.0);
+ }
+ else if (Player.p_status != S_CLOAKED)
+ /* holy grail */
+ tampered(T_GRAIL, 0.0, 0.0);
+ break;
+ }
+ else
+ loc += SZ_VOIDSTRUCT;
+
+ /* now check for other things */
+ readrecord(&Other, Fileloc);
+ if (Other.p_tampered != T_OFF)
+ tampered(Other.p_tampered, Other.p_1scratch, Other.p_2scratch);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: tampered()
+/
+/ FUNCTION: take care of tampering by other players
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ int what - what type of tampering
+/ double arg1, arg2 - rest of tampering info
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: writerecord(), more(), fread(), death(), fseek(), sleep(),
+/ floor(), wmove(), waddch(), drandom(), printw(), altercoordinates(),
+/ waddstr(), wrefresh(), encounter(), writevoid()
+/
+/ GLOBAL INPUTS: Other, Player, *stdscr, Enrgyvoid, *Playersfp
+/
+/ GLOBAL OUTPUTS: Other, Player, Changed, Enrgyvoid
+/
+/ DESCRIPTION:
+/ Take care of energy voids, holy grail, decree and intervention
+/ action on current player.
+/
+/************************************************************************/
+
+tampered(what, arg1, arg2)
+int what;
+double arg1;
+double arg2;
+{
+long loc; /* location in file of other players */
+
+ Changed = TRUE;
+ move(4,0);
+
+ Player.p_tampered = T_OFF; /* no longer tampered with */
+
+ switch (what)
+ {
+ case T_NRGVOID:
+ addstr("You've hit an energy void !\n");
+ Player.p_mana /= 3.0;
+ Player.p_energy /= 2.0;
+ Player.p_gold = floor(Player.p_gold/1.25) + 0.1;
+ altercoordinates(0.0, 0.0, A_NEAR);
+ break;
+
+ case T_TRANSPORT:
+ addstr("The king transported you ! ");
+ if (Player.p_charms > 0)
+ {
+ addstr("But your charm saved you. . .\n");
+ --Player.p_charms;
+ }
+ else
+ {
+ altercoordinates(0.0, 0.0, A_FAR);
+ addch('\n');
+ }
+ break;
+
+ case T_BESTOW:
+ printw("The king has bestowed %.0f gold pieces on you !\n", arg1);
+ Player.p_gold += arg1;
+ break;
+
+ case T_CURSED:
+ addstr("You've been cursed ! ");
+ if (Player.p_blessing)
+ {
+ addstr("But your blessing saved you. . .\n");
+ Player.p_blessing = FALSE;
+ }
+ else
+ {
+ addch('\n');
+ Player.p_poison += 2.0;
+ Player.p_energy = 10.0;
+ Player.p_maxenergy *= 0.95;
+ Player.p_status = S_PLAYING; /* no longer cloaked */
+ }
+ break;
+
+ case T_VAPORIZED:
+ addstr("You have been vaporized!\n");
+ more(7);
+ death("Vaporization");
+ break;
+
+ case T_MONSTER:
+ addstr("The Valar zapped you with a monster!\n");
+ more(7);
+ encounter((int) arg1);
+ return;
+
+ case T_BLESSED:
+ addstr("The Valar has blessed you!\n");
+ Player.p_energy = (Player.p_maxenergy *= 1.05) + Player.p_shield;
+ Player.p_mana += 500.0;
+ Player.p_strength += 0.5;
+ Player.p_brains += 0.5;
+ Player.p_magiclvl += 0.5;
+ Player.p_poison = MIN(0.5, Player.p_poison);
+ break;
+
+ case T_RELOCATE:
+ addstr("You've been relocated. . .\n");
+ altercoordinates(arg1, arg2, A_FORCED);
+ break;
+
+ case T_HEAL:
+ addstr("You've been healed!\n");
+ Player.p_poison -= 0.25;
+ Player.p_energy = Player.p_maxenergy + Player.p_shield;
+ break;
+
+ case T_EXVALAR:
+ addstr("You are no longer Valar!\n");
+ Player.p_specialtype = SC_COUNCIL;
+ break;
+
+ case T_GRAIL:
+ addstr("You have found The Holy Grail!!\n");
+ if (Player.p_specialtype < SC_COUNCIL)
+ /* must be council of wise to behold grail */
+ {
+ addstr("However, you are not experienced enough to behold it.\n");
+ Player.p_sin *= Player.p_sin;
+ Player.p_mana += 1000;
+ }
+ else if (Player.p_specialtype == SC_VALAR
+ || Player.p_specialtype == SC_EXVALAR)
+ {
+ addstr("You have made it to the position of Valar once already.\n");
+ addstr("The Grail is of no more use to you now.\n");
+ }
+ else
+ {
+ addstr("It is now time to see if you are worthy to behold it. . .\n");
+ refresh();
+ sleep(4);
+
+ if (drandom() / 2.0 < Player.p_sin)
+ {
+ addstr("You have failed!\n");
+ Player.p_strength =
+ Player.p_mana =
+ Player.p_energy =
+ Player.p_maxenergy =
+ Player.p_magiclvl =
+ Player.p_brains =
+ Player.p_experience =
+ Player.p_quickness = 1.0;
+
+ altercoordinates(1.0, 1.0, A_FORCED);
+ Player.p_level = 0.0;
+ }
+ else
+ {
+ addstr("You made to position of Valar!\n");
+ Player.p_specialtype = SC_VALAR;
+ Player.p_lives = 5;
+ fseek(Playersfp, 0L, 0);
+ loc = 0L;
+ while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
+ /* search for existing valar */
+ if (Other.p_specialtype == SC_VALAR
+ && Other.p_status != S_NOTUSED)
+ /* found old valar */
+ {
+ Other.p_tampered = T_EXVALAR;
+ writerecord(&Other, loc);
+ break;
+ }
+ else
+ loc += SZ_PLAYERSTRUCT;
+ }
+ }
+
+ /* move grail to new location */
+ Enrgyvoid.ev_active = TRUE;
+ Enrgyvoid.ev_x = ROLL(-1.0e6, 2.0e6);
+ Enrgyvoid.ev_y = ROLL(-1.0e6, 2.0e6);
+ writevoid(&Enrgyvoid, 0L);
+ break;
+ }
+ refresh();
+ sleep(2);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: userlist()
+/
+/ FUNCTION: print list of players and locations
+/
+/ AUTHOR: E. A. Estes, 2/28/86
+/
+/ ARGUMENTS:
+/ bool ingameflag - set if called while playing
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: descrstatus(), descrlocation(), more(), fread(), fseek(),
+/ floor(), wmove(), printw(), waddstr(), distance(), wrefresh(),
+/ descrtype(), wclrtobot()
+/
+/ GLOBAL INPUTS: LINES, Other, Circle, Wizard, Player, *stdscr, *Playersfp
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ We can only see the coordinate of those closer to the origin
+/ from us.
+/ Kings and council of the wise can see and can be seen by everyone.
+/ Palantirs are good for seeing everyone; and the valar can use
+/ one to see through a 'cloak' spell.
+/ The valar has no coordinates, and is completely invisible if
+/ cloaked.
+/
+/************************************************************************/
+
+userlist(ingameflag)
+bool ingameflag;
+{
+register int numusers = 0; /* number of users on file */
+
+ if (ingameflag && Player.p_blindness)
+ {
+ mvaddstr(8, 0, "You cannot see anyone.\n");
+ return;
+ }
+
+ fseek(Playersfp, 0L, 0);
+ mvaddstr(8, 0,
+ "Name X Y Lvl Type Login Status\n");
+
+ while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
+ {
+ if (Other.p_status == S_NOTUSED
+ /* record is unused */
+ || (Other.p_specialtype == SC_VALAR && Other.p_status == S_CLOAKED))
+ /* cloaked valar */
+ {
+ if (!Wizard)
+ /* wizard can see everything on file */
+ continue;
+ }
+
+ ++numusers;
+
+ if (ingameflag &&
+ /* must be playing for the rest of these conditions */
+ (Player.p_specialtype >= SC_KING
+ /* kings and higher can see others */
+ || Other.p_specialtype >= SC_KING
+ /* kings and higher can be seen by others */
+ || Circle >= CIRCLE(Other.p_x, Other.p_y)
+ /* those nearer the origin can be seen */
+ || Player.p_palantir)
+ /* palantir enables one to see others */
+ && (Other.p_status != S_CLOAKED
+ || (Player.p_specialtype == SC_VALAR && Player.p_palantir))
+ /* not cloaked; valar can see through cloak with a palantir */
+ && Other.p_specialtype != SC_VALAR)
+ /* not a valar */
+ /* coordinates should be printed */
+ printw("%-20s %8.0f %8.0f ",
+ Other.p_name, Other.p_x, Other.p_y);
+ else
+ /* cannot see player's coordinates */
+ printw("%-20s %19.19s ",
+ Other.p_name, descrlocation(&Other, TRUE));
+
+ printw("%6.0f %s %-9.9s%s\n", Other.p_level, descrtype(&Other, TRUE),
+ Other.p_login, descrstatus(&Other));
+
+ if ((numusers % (LINES - 10)) == 0)
+ {
+ more(LINES - 1);
+ move(9, 0);
+ clrtobot();
+ }
+ }
+
+ printw("Total players on file = %d\n", numusers);
+ refresh();
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: throneroom()
+/
+/ FUNCTION: king stuff upon entering throne
+/
+/ AUTHOR: E. A. Estes, 12/16/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: writerecord(), fread(), fseek(), fopen(), wmove(), fclose(),
+/ fwrite(), altercoordinates(), waddstr(), fprintf()
+/
+/ GLOBAL INPUTS: *Energyvoidfp, Other, Player, *stdscr,
+/ Enrgyvoid, *Playersfp
+/
+/ GLOBAL OUTPUTS: Other, Player, Changed
+/
+/ DESCRIPTION:
+/ If player is not already king, make him/her so if the old king
+/ is not playing.
+/ Clear energy voids with new king.
+/ Print 'decree' prompt.
+/
+/************************************************************************/
+
+throneroom()
+{
+FILE *fp; /* to clear energy voids */
+long loc = 0L; /* location of old king in player file */
+
+ if (Player.p_specialtype < SC_KING)
+ /* not already king -- assumes crown */
+ {
+ fseek(Playersfp, 0L, 0);
+ while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
+ if (Other.p_specialtype == SC_KING && Other.p_status != S_NOTUSED)
+ /* found old king */
+ {
+ if (Other.p_status != S_OFF)
+ /* old king is playing */
+ {
+ mvaddstr( 4, 0, "The king is playing, so you cannot steal his throne\n");
+ altercoordinates(0.0, 0.0, A_NEAR);
+ move(6, 0);
+ return;
+ }
+ else
+ /* old king is not playing - remove him/her */
+ {
+ Other.p_specialtype = SC_NONE;
+ if (Other.p_crowns)
+ --Other.p_crowns;
+ writerecord(&Other, loc);
+ break;
+ }
+ }
+ else
+ loc += SZ_PLAYERSTRUCT;
+
+ /* make player new king */
+ Changed = TRUE;
+ Player.p_specialtype = SC_KING;
+ mvaddstr(4, 0, "You have become king!\n");
+
+ /* let everyone else know */
+ fp = fopen(_PATH_MESS, "w");
+ fprintf(fp, "All hail the new king!");
+ fclose(fp);
+
+ /* clear all energy voids; retain location of holy grail */
+ fseek(Energyvoidfp, 0L, 0);
+ fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp);
+ fp = fopen(_PATH_VOID, "w");
+ fwrite((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, fp);
+ fclose(fp);
+ }
+
+ mvaddstr(6, 0, "0:Decree ");
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: dotampered()
+/
+/ FUNCTION: king and valar special options
+/
+/ AUTHOR: E. A. Estes, 2/28/86
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: writerecord(), truncstring(), fread(), fseek(), fopen(),
+/ floor(), wmove(), drandom(), fclose(), fwrite(), sscanf(), strcmp(),
+/ infloat(), waddstr(), findname(), distance(), userlist(), mvprintw(),
+/ allocvoid(), getanswer(), getstring(), wclrtoeol(), writevoid()
+/
+/ GLOBAL INPUTS: *Energyvoidfp, Other, Illcmd[], Wizard, Player, *stdscr,
+/ Databuf[], Enrgyvoid
+/
+/ GLOBAL OUTPUTS: Other, Player, Enrgyvoid
+/
+/ DESCRIPTION:
+/ Tamper with other players. Handle king/valar specific options.
+/
+/************************************************************************/
+
+dotampered()
+{
+short tamper; /* value for tampering with other players */
+char *option; /* pointer to option description */
+double temp1 = 0.0, temp2 = 0.0; /* other tampering values */
+int ch; /* input */
+long loc; /* location in energy void file */
+FILE *fp; /* for opening gold file */
+
+ move(6, 0);
+ clrtoeol();
+ if (Player.p_specialtype < SC_COUNCIL && !Wizard)
+ /* king options */
+ {
+ addstr("1:Transport 2:Curse 3:Energy Void 4:Bestow 5:Collect Taxes ");
+
+ ch = getanswer(" ", TRUE);
+ move(6, 0);
+ clrtoeol();
+ move(4, 0);
+ switch (ch)
+ {
+ case '1': /* transport someone */
+ tamper = T_TRANSPORT;
+ option = "transport";
+ break;
+
+ case '2': /* curse another */
+ tamper = T_CURSED;
+ option = "curse";
+ break;
+
+ case '3': /* create energy void */
+ if ((loc = allocvoid()) > 20L * SZ_VOIDSTRUCT)
+ /* can only have 20 void active at once */
+ mvaddstr(5, 0, "Sorry, void creation limit reached.\n");
+ else
+ {
+ addstr("Enter the X Y coordinates of void ? ");
+ getstring(Databuf, SZ_DATABUF);
+ sscanf(Databuf, "%lf %lf", &temp1, &temp2);
+ Enrgyvoid.ev_x = floor(temp1);
+ Enrgyvoid.ev_y = floor(temp2);
+ Enrgyvoid.ev_active = TRUE;
+ writevoid(&Enrgyvoid, loc);
+ mvaddstr(5, 0, "It is done.\n");
+ }
+ return;
+
+ case '4': /* bestow gold to subject */
+ tamper = T_BESTOW;
+ addstr("How much gold to bestow ? ");
+ temp1 = infloat();
+ if (temp1 > Player.p_gold || temp1 < 0)
+ {
+ mvaddstr(5, 0, "You don't have that !\n");
+ return;
+ }
+
+ /* adjust gold after we are sure it will be given to someone */
+ option = "give gold to";
+ break;
+
+ case '5': /* collect accumulated taxes */
+ if ((fp = fopen(_PATH_GOLD, "r+")) != NULL)
+ /* collect taxes */
+ {
+ fread((char *) &temp1, sizeof(double), 1, fp);
+ fseek(fp, 0L, 0);
+ /* clear out value */
+ temp2 = 0.0;
+ fwrite((char *) &temp2, sizeof(double), 1, fp);
+ fclose(fp);
+ }
+
+ mvprintw(4, 0, "You have collected %.0f in gold.\n", temp1);
+ Player.p_gold += floor(temp1);
+ return;
+
+ default:
+ return;
+ }
+ /* end of king options */
+ }
+ else
+ /* council of wise, valar, wizard options */
+ {
+ addstr("1:Heal ");
+ if (Player.p_palantir || Wizard)
+ addstr("2:Seek Grail ");
+ if (Player.p_specialtype == SC_VALAR || Wizard)
+ addstr("3:Throw Monster 4:Relocate 5:Bless ");
+ if (Wizard)
+ addstr("6:Vaporize ");
+
+ ch = getanswer(" ", TRUE);
+ if (!Wizard)
+ {
+ if (ch > '2' && Player.p_specialtype != SC_VALAR)
+ {
+ ILLCMD();
+ return;
+ }
+
+ if (Player.p_mana < MM_INTERVENE)
+ {
+ mvaddstr(5, 0, "No mana left.\n");
+ return;
+ }
+ else
+ Player.p_mana -= MM_INTERVENE;
+ }
+
+ switch (ch)
+ {
+ case '1': /* heal another */
+ tamper = T_HEAL;
+ option = "heal";
+ break;
+
+ case '2': /* seek grail */
+ if (Player.p_palantir)
+ /* need a palantir to seek */
+ {
+ fseek(Energyvoidfp, 0L, 0);
+ fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp);
+ temp1 = distance(Player.p_x, Enrgyvoid.ev_x, Player.p_y, Enrgyvoid.ev_y);
+ temp1 += ROLL(-temp1 / 10.0, temp1 / 5.0); /* add some error */
+ mvprintw(5, 0, "The palantir says the Grail is about %.0f away.\n", temp1);
+ }
+ else
+ /* no palantir */
+ mvaddstr(5, 0, "You need a palantir to seek the Grail.\n");
+ return;
+
+ case '3': /* lob monster at someone */
+ mvaddstr(4, 0, "Which monster [0-99] ? ");
+ temp1 = infloat();
+ temp1 = MAX(0.0, MIN(99.0, temp1));
+ tamper = T_MONSTER;
+ option = "throw a monster at";
+ break;
+
+ case '4': /* move another player */
+ mvaddstr(4, 0, "New X Y coordinates ? ");
+ getstring(Databuf, SZ_DATABUF);
+ sscanf(Databuf, "%lf %lf", &temp1, &temp2);
+ tamper = T_RELOCATE;
+ option = "relocate";
+ break;
+
+ case '5': /* bless a player */
+ tamper = T_BLESSED;
+ option = "bless";
+ break;
+
+ case '6': /* kill off a player */
+ if (Wizard)
+ {
+ tamper = T_VAPORIZED;
+ option = "vaporize";
+ break;
+ }
+ else
+ return;
+
+ default:
+ return;
+ }
+
+ /* adjust age after we are sure intervention will be done */
+ /* end of valar, etc. options */
+ }
+
+ for (;;)
+ /* prompt for player to affect */
+ {
+ mvprintw(4, 0, "Who do you want to %s ? ", option);
+ getstring(Databuf, SZ_DATABUF);
+ truncstring(Databuf);
+
+ if (Databuf[0] == '\0')
+ userlist(TRUE);
+ else
+ break;
+ }
+
+ if (strcmp(Player.p_name, Databuf) != 0)
+ /* name other than self */
+ {
+ if ((loc = findname(Databuf, &Other)) >= 0L)
+ {
+ if (Other.p_tampered != T_OFF)
+ {
+ mvaddstr(5, 0, "That person has something pending already.\n");
+ return;
+ }
+ else
+ {
+ if (tamper == T_RELOCATE
+ && CIRCLE(temp1, temp2) < CIRCLE(Other.p_x, Other.p_y)
+ && !Wizard)
+ mvaddstr(5, 0, "Cannot move someone closer to the Lord's Chamber.\n");
+ else
+ {
+ if (tamper == T_BESTOW) Player.p_gold -= floor(temp1);
+ if (!Wizard && (tamper == T_HEAL || tamper == T_MONSTER ||
+ tamper == T_RELOCATE || tamper == T_BLESSED))
+ Player.p_age += N_AGE; /* age penalty */
+ Other.p_tampered = tamper;
+ Other.p_1scratch = floor(temp1);
+ Other.p_2scratch = floor(temp2);
+ writerecord(&Other, loc);
+ mvaddstr(5, 0, "It is done.\n");
+ }
+ return;
+ }
+ }
+ else
+ /* player not found */
+ mvaddstr(5, 0, "There is no one by that name.\n");
+ }
+ else
+ /* self */
+ mvaddstr(5, 0, "You may not do it to yourself!\n");
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: writevoid()
+/
+/ FUNCTION: update energy void entry in energy void file
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ struct energyvoid *vp - pointer to structure to write to file
+/ long loc - location in file to update
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: fseek(), fwrite(), fflush()
+/
+/ GLOBAL INPUTS: *Energyvoidfp
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Write out energy void structure at specified location.
+/
+/************************************************************************/
+
+writevoid(vp, loc)
+register struct energyvoid *vp;
+long loc;
+{
+
+ fseek(Energyvoidfp, loc, 0);
+ fwrite((char *) vp, SZ_VOIDSTRUCT, 1, Energyvoidfp);
+ fflush(Energyvoidfp);
+ fseek(Energyvoidfp, 0L, 0);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: allocvoid()
+/
+/ FUNCTION: allocate space for a new energy void
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: location of new energy void space
+/
+/ MODULES CALLED: fread(), fseek()
+/
+/ GLOBAL INPUTS: *Energyvoidfp, Enrgyvoid
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Search energy void file for an inactive entry and return its
+/ location.
+/ If no inactive ones are found, return one more than last location.
+/
+/************************************************************************/
+
+long
+allocvoid()
+{
+long loc = 0L; /* location of new energy void */
+
+ fseek(Energyvoidfp, 0L, 0);
+ while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1)
+ if (Enrgyvoid.ev_active)
+ loc += SZ_VOIDSTRUCT;
+ else
+ break;
+
+ return(loc);
+}
diff --git a/games/phantasia/io.c b/games/phantasia/io.c
new file mode 100644
index 0000000..addf1c9
--- /dev/null
+++ b/games/phantasia/io.c
@@ -0,0 +1,436 @@
+/*
+ * io.c - input/output routines for Phantasia
+ */
+
+#include "include.h"
+
+/************************************************************************
+/
+/ FUNCTION NAME: getstring()
+/
+/ FUNCTION: read a string from operator
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ char *cp - pointer to buffer area to fill
+/ int mx - maximum number of characters to put in buffer
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: wmove(), _filbuf(), clearok(), waddstr(), wrefresh(),
+/ wclrtoeol()
+/
+/ GLOBAL INPUTS: Echo, _iob[], Wizard, *stdscr
+/
+/ GLOBAL OUTPUTS: _iob[]
+/
+/ DESCRIPTION:
+/ Read a string from the keyboard.
+/ This routine is specially designed to:
+/
+/ - strip non-printing characters (unless Wizard)
+/ - echo, if desired
+/ - redraw the screen if CH_REDRAW is entered
+/ - read in only 'mx - 1' characters or less characters
+/ - nul-terminate string, and throw away newline
+/
+/ 'mx' is assumed to be at least 2.
+/
+/************************************************************************/
+
+getstring(cp, mx)
+register char *cp;
+register int mx;
+{
+register char *inptr; /* pointer into string for next string */
+int x, y; /* original x, y coordinates on screen */
+int ch; /* input */
+
+ getyx(stdscr, y, x); /* get coordinates on screen */
+ inptr = cp;
+ *inptr = '\0'; /* clear string to start */
+ --mx; /* reserve room in string for nul terminator */
+
+ do
+ /* get characters and process */
+ {
+ if (Echo)
+ mvaddstr(y, x, cp); /* print string on screen */
+ clrtoeol(); /* clear any data after string */
+ refresh(); /* update screen */
+
+ ch = getchar(); /* get character */
+
+ switch (ch)
+ {
+ case CH_ERASE: /* back up one character */
+ if (inptr > cp)
+ --inptr;
+ break;
+
+ case CH_KILL: /* back up to original location */
+ inptr = cp;
+ break;
+
+ case CH_NEWLINE: /* terminate string */
+ break;
+
+ case CH_REDRAW: /* redraw screen */
+ clearok(stdscr, TRUE);
+ continue;
+
+ default: /* put data in string */
+ if (ch >= ' ' || Wizard)
+ /* printing char; put in string */
+ *inptr++ = ch;
+ }
+
+ *inptr = '\0'; /* terminate string */
+ }
+ while (ch != CH_NEWLINE && inptr < cp + mx);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: more()
+/
+/ FUNCTION: pause and prompt player
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ int where - line on screen on which to pause
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: wmove(), waddstr(), getanswer()
+/
+/ GLOBAL INPUTS: *stdscr
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Print a message, and wait for a space character.
+/
+/************************************************************************/
+
+more(where)
+int where;
+{
+ mvaddstr(where, 0, "-- more --");
+ getanswer(" ", FALSE);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: infloat()
+/
+/ FUNCTION: input a floating point number from operator
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: floating point number from operator
+/
+/ MODULES CALLED: sscanf(), getstring()
+/
+/ GLOBAL INPUTS: Databuf[]
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Read a string from player, and scan for a floating point
+/ number.
+/ If no valid number is found, return 0.0.
+/
+/************************************************************************/
+
+double
+infloat()
+{
+double result; /* return value */
+
+ getstring(Databuf, SZ_DATABUF);
+ if (sscanf(Databuf, "%lf", &result) < 1)
+ /* no valid number entered */
+ result = 0.0;
+
+ return(result);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: inputoption()
+/
+/ FUNCTION: input an option value from player
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: floor(), drandom(), getanswer()
+/
+/ GLOBAL INPUTS: Player
+/
+/ GLOBAL OUTPUTS: Player
+/
+/ DESCRIPTION:
+/ Age increases with every move.
+/ Refresh screen, and get a single character option from player.
+/ Return a random value if player's ring has gone bad.
+/
+/************************************************************************/
+
+inputoption()
+{
+ ++Player.p_age; /* increase age */
+
+ if (Player.p_ring.ring_type != R_SPOILED)
+ /* ring ok */
+ return(getanswer("T ", TRUE));
+ else
+ /* bad ring */
+ {
+ getanswer(" ", TRUE);
+ return((int) ROLL(0.0, 5.0) + '0');
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: interrupt()
+/
+/ FUNCTION: handle interrupt from operator
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: fork(), exit(), wait(), death(), alarm(), execl(), wmove(),
+/ getgid(), signal(), getenv(), wclear(), setuid(), getuid(), setgid(),
+/ crmode(), clearok(), waddstr(), cleanup(), wrefresh(), leavegame(),
+/ getanswer()
+/
+/ GLOBAL INPUTS: Player, *stdscr
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Allow player to quit upon hitting the interrupt key.
+/ If the player wants to quit while in battle, he/she automatically
+/ dies.
+/
+/************************************************************************/
+
+interrupt()
+{
+char line[81]; /* a place to store data already on screen */
+register int loop; /* counter */
+int x, y; /* coordinates on screen */
+int ch; /* input */
+unsigned savealarm; /* to save alarm value */
+
+#ifdef SYS3
+ signal(SIGINT, SIG_IGN);
+#endif
+#ifdef SYS5
+ signal(SIGINT, SIG_IGN);
+#endif
+
+ savealarm = alarm(0); /* turn off any alarms */
+
+ getyx(stdscr, y, x); /* save cursor location */
+
+ for (loop = 0; loop < 80; ++loop) /* save line on screen */
+ {
+ move(4, loop);
+ line[loop] = inch();
+ }
+ line[80] = '\0'; /* nul terminate */
+
+ if (Player.p_status == S_INBATTLE || Player.p_status == S_MONSTER)
+ /* in midst of fighting */
+ {
+ mvaddstr(4, 0, "Quitting now will automatically kill your character. Still want to ? ");
+ ch = getanswer("NY", FALSE);
+ if (ch == 'Y')
+ death("Bailing out");
+ /*NOTREACHED*/
+ }
+ else
+ {
+ mvaddstr(4, 0, "Do you really want to quit ? ");
+ ch = getanswer("NY", FALSE);
+ if (ch == 'Y')
+ leavegame();
+ /*NOTREACHED*/
+ }
+
+ mvaddstr(4, 0, line); /* restore data on screen */
+ move(y, x); /* restore cursor */
+ refresh();
+
+#ifdef SYS3
+ signal(SIGINT, interrupt);
+#endif
+#ifdef SYS5
+ signal(SIGINT, interrupt);
+#endif
+
+ alarm(savealarm); /* restore alarm */
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: getanswer()
+/
+/ FUNCTION: get an answer from operator
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ char *choices - string of (upper case) valid choices
+/ bool def - set if default answer
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: alarm(), wmove(), waddch(), signal(), setjmp(), strchr(),
+/ _filbuf(), clearok(), toupper(), wrefresh(), mvprintw(), wclrtoeol()
+/
+/ GLOBAL INPUTS: catchalarm(), Echo, _iob[], _ctype[], *stdscr, Timeout,
+/ Timeoenv[]
+/
+/ GLOBAL OUTPUTS: _iob[]
+/
+/ DESCRIPTION:
+/ Get a single character answer from operator.
+/ Timeout waiting for response. If we timeout, or the
+/ answer in not in the list of valid choices, print choices,
+/ and wait again, otherwise return the first character in ths
+/ list of choices.
+/ Give up after 3 tries.
+/
+/************************************************************************/
+
+getanswer(choices, def)
+char *choices;
+bool def;
+{
+int ch; /* input */
+int loop; /* counter */
+int oldx, oldy; /* original coordinates on screen */
+
+ getyx(stdscr, oldy, oldx);
+ alarm(0); /* make sure alarm is off */
+
+ for (loop = 3; loop; --loop)
+ /* try for 3 times */
+ {
+ if (setjmp(Timeoenv) != 0)
+ /* timed out waiting for response */
+ {
+ if (def || loop <= 1)
+ /* return default answer */
+ break;
+ else
+ /* prompt, and try again */
+ goto YELL;
+ }
+ else
+ /* wait for response */
+ {
+ clrtoeol();
+ refresh();
+#ifdef BSD41
+ sigset(SIGALRM, catchalarm);
+#else
+ signal(SIGALRM, catchalarm);
+#endif
+ /* set timeout */
+ if (Timeout)
+ alarm(7); /* short */
+ else
+ alarm(600); /* long */
+
+ ch = getchar();
+
+ alarm(0); /* turn off timeout */
+
+ if (ch < 0)
+ /* caught some signal */
+ {
+ ++loop;
+ continue;
+ }
+ else if (ch == CH_REDRAW)
+ /* redraw screen */
+ {
+ clearok(stdscr, TRUE); /* force clear screen */
+ ++loop; /* don't count this input */
+ continue;
+ }
+ else if (Echo)
+ {
+ addch(ch); /* echo character */
+ refresh();
+ }
+
+ if (islower(ch))
+ /* convert to upper case */
+ ch = toupper(ch);
+
+ if (def || strchr(choices, ch) != NULL)
+ /* valid choice */
+ return(ch);
+ else if (!def && loop > 1)
+ /* bad choice; prompt, and try again */
+ {
+YELL: mvprintw(oldy + 1, 0, "Please choose one of : [%s]\n", choices);
+ move(oldy, oldx);
+ clrtoeol();
+ continue;
+ }
+ else
+ /* return default answer */
+ break;
+ }
+ }
+
+ return(*choices);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: catchalarm()
+/
+/ FUNCTION: catch timer when waiting for input
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: longjmp()
+/
+/ GLOBAL INPUTS: Timeoenv[]
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Come here when the alarm expires while waiting for input.
+/ Simply longjmp() into getanswer().
+/
+/************************************************************************/
+
+void
+catchalarm()
+{
+ longjmp(Timeoenv, 1);
+}
diff --git a/games/phantasia/macros.h b/games/phantasia/macros.h
new file mode 100644
index 0000000..e232742
--- /dev/null
+++ b/games/phantasia/macros.h
@@ -0,0 +1,16 @@
+/*
+ * macros.h - macro definitions for Phantasia
+ */
+
+#define ROLL(BASE,INTERVAL) floor((BASE) + (INTERVAL) * drandom())
+#define SGN(X) ((X) < 0 ? -1 : 1)
+#define CIRCLE(X, Y) floor(distance(X, 0.0, Y, 0.0) / 125.0 + 1)
+#define MAX(A, B) ((A) > (B) ? (A) : (B))
+#define MIN(A, B) ((A) < (B) ? (A) : (B))
+#define ILLCMD() mvaddstr(5, 0, Illcmd)
+#define MAXMOVE() (Player.p_level * 1.5 + 1)
+#define ILLMOVE() mvaddstr(5, 0, Illmove)
+#define ILLSPELL() mvaddstr(5, 0, Illspell)
+#define NOMANA() mvaddstr(5, 0, Nomana)
+#define SOMEBETTER() addstr(Somebetter)
+#define NOBETTER() mvaddstr(17, 0, Nobetter)
diff --git a/games/phantasia/main.c b/games/phantasia/main.c
new file mode 100644
index 0000000..89d56e8
--- /dev/null
+++ b/games/phantasia/main.c
@@ -0,0 +1,1288 @@
+/*
+ * Phantasia 3.3.2 -- Interterminal fantasy game
+ *
+ * Edward A. Estes
+ * AT&T, March 12, 1986
+ */
+
+/* DISCLAIMER:
+ *
+ * This game is distributed for free as is. It is not guaranteed to work
+ * in every conceivable environment. It is not even guaranteed to work
+ * in ANY environment.
+ *
+ * This game is distributed without notice of copyright, therefore it
+ * may be used in any manner the recipient sees fit. However, the
+ * author assumes no responsibility for maintaining or revising this
+ * game, in its original form, or any derivitives thereof.
+ *
+ * The author shall not be responsible for any loss, cost, or damage,
+ * including consequential damage, caused by reliance on this material.
+ *
+ * The author makes no warranties, express or implied, including warranties
+ * of merchantability or fitness for a particular purpose or use.
+ *
+ * AT&T is in no way connected with this game.
+ */
+
+#include <sys/types.h>
+#include <pwd.h>
+
+/*
+ * The program allocates as much file space as it needs to store characters,
+ * so the possibility exists for the character file to grow without bound.
+ * The file is purged upon normal entry to try to avoid that problem.
+ * A similar problem exists for energy voids. To alleviate the problem here,
+ * the void file is cleared with every new king, and a limit is placed
+ * on the size of the energy void file.
+ */
+
+/*
+ * Put one line of text into the file 'motd' for announcements, etc.
+ */
+
+/*
+ * The scoreboard file is updated when someone dies, and keeps track
+ * of the highest character to date for that login.
+ * Being purged from the character file does not cause the scoreboard
+ * to be updated.
+ */
+
+/*
+ * All source files are set up for 'vi' with shiftwidth=4, tabstop=8.
+ */
+
+/* */
+
+/*
+ * main.c Main routines for Phantasia
+ */
+
+#include "include.h"
+
+/***************************************************************************
+/ FUNCTION NAME: main()
+/
+/ FUNCTION: initialize state, and call main process
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ int argc - argument count
+/ char **argv - argument vector
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: monstlist(), checkenemy(), activelist(),
+/ throneroom(), checkbattle(), readmessage(), changestats(), writerecord(),
+/ tradingpost(), adjuststats(), recallplayer(), displaystats(), checktampered(),
+/ fabs(), rollnewplayer(), time(), exit(), sqrt(), floor(), wmove(),
+/ signal(), strcat(), purgeoldplayers(), getuid(), isatty(), wclear(),
+/ strcpy(), system(), altercoordinates(), cleanup(), waddstr(), procmain(),
+/ playinit(), leavegame(), localtime(), getanswer(), neatstuff(), initialstate(),
+/ scorelist(), titlelist()
+/
+/ GLOBAL INPUTS: *Login, Throne, Wizard, Player, *stdscr, Changed, Databuf[],
+/ Fileloc, Stattable[]
+/
+/ GLOBAL OUTPUTS: Wizard, Player, Changed, Fileloc, Timeout, *Statptr
+/
+/ DESCRIPTION:
+/ Process arguments, initialize program, and loop forever processing
+/ player input.
+/
+/***************************************************************************/
+
+main(argc, argv)
+int argc;
+char **argv;
+{
+bool noheader = FALSE; /* set if don't want header */
+bool headeronly = FALSE; /* set if only want header */
+bool examine = FALSE; /* set if examine a character */
+long seconds; /* for time of day */
+double dtemp; /* for temporary calculations */
+
+ initialstate(); /* init globals */
+
+ /* process arguments */
+ while (--argc && (*++argv)[0] == '-')
+ switch ((*argv)[1])
+ {
+ case 's': /* short */
+ noheader = TRUE;
+ break;
+
+ case 'H': /* Header */
+ headeronly = TRUE;
+ break;
+
+ case 'a': /* all users */
+ activelist();
+ cleanup(TRUE);
+ /*NOTREACHED*/
+
+ case 'p': /* purge old players */
+ purgeoldplayers();
+ cleanup(TRUE);
+ /*NOTREACHED*/
+
+ case 'S': /* set 'Wizard' */
+ Wizard = !getuid();
+ break;
+
+ case 'x': /* examine */
+ examine = TRUE;
+ break;
+
+ case 'm': /* monsters */
+ monstlist();
+ cleanup(TRUE);
+ /*NOTREACHED*/
+
+ case 'b': /* scoreboard */
+ scorelist();
+ cleanup(TRUE);
+ /*NOTREACHED*/
+ }
+
+ if (!isatty(0)) /* don't let non-tty's play */
+ cleanup(TRUE);
+ /*NOTREACHED*/
+
+ playinit(); /* set up to catch signals, init curses */
+
+ if (examine)
+ {
+ changestats(FALSE);
+ cleanup(TRUE);
+ /*NOTREACHED*/
+ }
+
+ if (!noheader)
+ {
+ titlelist();
+ purgeoldplayers(); /* clean up old characters */
+ }
+
+ if (headeronly)
+ cleanup(TRUE);
+ /*NOTREACHED*/
+
+ do
+ /* get the player structure filled */
+ {
+ Fileloc = -1L;
+
+ mvaddstr(22, 17, "Do you have a character to run [Q = Quit] ? ");
+
+ switch (getanswer("NYQ", FALSE))
+ {
+ case 'Y':
+ Fileloc = recallplayer();
+ break;
+
+ case 'Q':
+ cleanup(TRUE);
+ /*NOTREACHED*/
+
+ default:
+ Fileloc = rollnewplayer();
+ break;
+ }
+ clear();
+ }
+ while (Fileloc < 0L);
+
+ if (Player.p_level > 5.0)
+ /* low level players have long timeout */
+ Timeout = TRUE;
+
+ /* update some important player statistics */
+ strcpy(Player.p_login, Login);
+ time(&seconds);
+ Player.p_lastused = localtime(&seconds)->tm_yday;
+ Player.p_status = S_PLAYING;
+ writerecord(&Player, Fileloc);
+
+ Statptr = &Stattable[Player.p_type]; /* initialize pointer */
+
+ /* catch interrupts */
+#ifdef BSD41
+ sigset(SIGINT, interrupt);
+#endif
+#ifdef BSD42
+ signal(SIGINT, interrupt);
+#endif
+#ifdef SYS3
+ signal(SIGINT, interrupt);
+#endif
+#ifdef SYS5
+ signal(SIGINT, interrupt);
+#endif
+
+ altercoordinates(Player.p_x, Player.p_y, A_FORCED); /* set some flags */
+
+ clear();
+
+ for (;;)
+ /* loop forever, processing input */
+ {
+
+ adjuststats(); /* cleanup stats */
+
+ if (Throne && Player.p_crowns == 0 && Player.p_specialtype != SC_KING)
+ /* not allowed on throne -- move */
+ {
+ mvaddstr(5,0,"You're not allowed in the Lord's Chamber without a crown.\n");
+ altercoordinates(0.0, 0.0, A_NEAR);
+ }
+
+ checktampered(); /* check for energy voids, etc. */
+
+ if (Player.p_status != S_CLOAKED
+ /* not cloaked */
+ && (dtemp = fabs(Player.p_x)) == fabs(Player.p_y)
+ /* |x| = |y| */
+ && !Throne)
+ /* not on throne */
+ {
+ dtemp = sqrt(dtemp / 100.0);
+ if (floor(dtemp) == dtemp)
+ /* |x| / 100 == n*n; at a trading post */
+ {
+ tradingpost();
+ clear();
+ }
+ }
+
+ checkbattle(); /* check for player to player battle */
+ neatstuff(); /* gurus, medics, etc. */
+
+ if (Player.p_status == S_CLOAKED)
+ /* costs 3 mana per turn to be cloaked */
+ if (Player.p_mana > 3.0)
+ Player.p_mana -= 3.0;
+ else
+ /* ran out of mana, uncloak */
+ {
+ Player.p_status = S_PLAYING;
+ Changed = TRUE;
+ }
+
+ if (Player.p_status != S_PLAYING && Player.p_status != S_CLOAKED)
+ /* change status back to S_PLAYING */
+ {
+ Player.p_status = S_PLAYING;
+ Changed = TRUE;
+ }
+
+ if (Changed)
+ /* update file only if important stuff has changed */
+ {
+ writerecord(&Player, Fileloc);
+ Changed = FALSE;
+ continue;
+ }
+
+ readmessage(); /* read message, if any */
+
+ displaystats(); /* print statistics */
+
+ move(6, 0);
+
+ if (Throne)
+ /* maybe make king, print prompt, etc. */
+ throneroom();
+
+ /* print status line */
+ addstr("1:Move 2:Players 3:Talk 4:Stats 5:Quit ");
+ if (Player.p_level >= MEL_CLOAK && Player.p_magiclvl >= ML_CLOAK)
+ addstr("6:Cloak ");
+ if (Player.p_level >= MEL_TELEPORT && Player.p_magiclvl >= ML_TELEPORT)
+ addstr("7:Teleport ");
+ if (Player.p_specialtype >= SC_COUNCIL || Wizard)
+ addstr("8:Intervene ");
+
+ procmain(); /* process input */
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: initialstate()
+/
+/ FUNCTION: initialize some important global variable
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: time(), fopen(), srandom(), error(), getuid(), getlogin(),
+/ getpwuid()
+/
+/ GLOBAL INPUTS:
+/
+/ GLOBAL OUTPUTS: *Energyvoidfp, Echo, Marsh, *Login, Users, Beyond,
+/ Throne, Wizard, Changed, Okcount, Timeout, Windows, *Monstfp, *Messagefp,
+/ *Playersfp
+/
+/ DESCRIPTION:
+/ Set global flags, and open files which remain open.
+/
+/************************************************************************/
+
+initialstate()
+{
+ Beyond = FALSE;
+ Marsh = FALSE;
+ Throne = FALSE;
+ Changed = FALSE;
+ Wizard = FALSE;
+ Timeout = FALSE;
+ Users = 0;
+ Windows = FALSE;
+ Echo = TRUE;
+
+ /* setup login name */
+ if ((Login = getlogin()) == NULL)
+ Login = getpwuid(getuid())->pw_name;
+
+ /* open some files */
+ if ((Playersfp = fopen(_PATH_PEOPLE, "r+")) == NULL)
+ error(_PATH_PEOPLE);
+ /*NOTREACHED*/
+
+ if ((Monstfp = fopen(_PATH_MONST, "r+")) == NULL)
+ error(_PATH_MONST);
+ /*NOTREACHED*/
+
+ if ((Messagefp = fopen(_PATH_MESS, "r")) == NULL)
+ error(_PATH_MESS);
+ /*NOTREACHED*/
+
+ if ((Energyvoidfp = fopen(_PATH_VOID, "r+")) == NULL)
+ error(_PATH_VOID);
+ /*NOTREACHED*/
+
+ srandom((unsigned) time((long *) NULL)); /* prime random numbers */
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: rollnewplayer()
+/
+/ FUNCTION: roll up a new character
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: initplayer(), allocrecord(), truncstring(), fabs(), wmove(),
+/ wclear(), sscanf(), strcmp(), genchar(), waddstr(), findname(), mvprintw(),
+/ getanswer(), getstring()
+/
+/ GLOBAL INPUTS: Other, Wizard, Player, *stdscr, Databuf[]
+/
+/ GLOBAL OUTPUTS: Echo
+/
+/ DESCRIPTION:
+/ Prompt player, and roll up new character.
+/
+/************************************************************************/
+
+long
+rollnewplayer()
+{
+int chartype; /* character type */
+int ch; /* input */
+
+ initplayer(&Player); /* initialize player structure */
+
+ clear();
+ mvaddstr(4, 21, "Which type of character do you want:");
+ mvaddstr(8, 4, "1:Magic User 2:Fighter 3:Elf 4:Dwarf 5:Halfling 6:Experimento ");
+ if (Wizard) {
+ addstr("7:Super ? ");
+ chartype = getanswer("1234567", FALSE);
+ }
+ else {
+ addstr("? ");
+ chartype = getanswer("123456", FALSE);
+ }
+
+ do
+ {
+ genchar(chartype); /* roll up a character */
+
+ /* print out results */
+ mvprintw(12, 14,
+ "Strength : %2.0f Quickness: %2.0f Mana : %2.0f\n",
+ Player.p_strength, Player.p_quickness, Player.p_mana);
+ mvprintw(13, 14,
+ "Energy Level: %2.0f Brains : %2.0f Magic Level: %2.0f\n",
+ Player.p_energy, Player.p_brains, Player.p_magiclvl);
+
+ if (Player.p_type == C_EXPER || Player.p_type == C_SUPER)
+ break;
+
+ mvaddstr(14, 14, "Type '1' to keep >");
+ ch = getanswer(" ", TRUE);
+ }
+ while (ch != '1');
+
+ if (Player.p_type == C_EXPER || Player.p_type == C_SUPER)
+ /* get coordinates for experimento */
+ for (;;)
+ {
+ mvaddstr(16, 0, "Enter the X Y coordinates of your experimento ? ");
+ getstring(Databuf, SZ_DATABUF);
+ sscanf(Databuf, "%lf %lf", &Player.p_x, &Player.p_y);
+
+ if (fabs(Player.p_x) > D_EXPER || fabs(Player.p_y) > D_EXPER)
+ mvaddstr(17, 0, "Invalid coordinates. Try again.\n");
+ else
+ break;
+ }
+
+ for (;;)
+ /* name the new character */
+ {
+ mvprintw(18, 0,
+ "Give your character a name [up to %d characters] ? ", SZ_NAME - 1);
+ getstring(Player.p_name, SZ_NAME);
+ truncstring(Player.p_name); /* remove trailing blanks */
+
+ if (Player.p_name[0] == '\0')
+ /* no null names */
+ mvaddstr(19, 0, "Invalid name.");
+ else if (findname(Player.p_name, &Other) >= 0L)
+ /* cannot have duplicate names */
+ mvaddstr(19, 0, "Name already in use.");
+ else
+ /* name is acceptable */
+ break;
+
+ addstr(" Pick another.\n");
+ }
+
+ /* get a password for character */
+ Echo = FALSE;
+
+ do
+ {
+ mvaddstr(20, 0, "Give your character a password [up to 8 characters] ? ");
+ getstring(Player.p_password, SZ_PASSWORD);
+ mvaddstr(21, 0, "One more time to verify ? ");
+ getstring(Databuf, SZ_PASSWORD);
+ }
+ while (strcmp(Player.p_password, Databuf) != 0);
+
+ Echo = TRUE;
+
+ return(allocrecord());
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: procmain()
+/
+/ FUNCTION: process input from player
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: dotampered(), changestats(), inputoption(), allstatslist(),
+/ fopen(), wmove(), drandom(), sscanf(), fclose(), altercoordinates(),
+/ waddstr(), fprintf(), distance(), userlist(), leavegame(), encounter(),
+/ getstring(), wclrtobot()
+/
+/ GLOBAL INPUTS: Circle, Illcmd[], Throne, Wizard, Player, *stdscr,
+/ Databuf[], Illmove[]
+/
+/ GLOBAL OUTPUTS: Player, Changed
+/
+/ DESCRIPTION:
+/ Process main menu options.
+/
+/************************************************************************/
+
+procmain()
+{
+int ch; /* input */
+double x; /* desired new x coordinate */
+double y; /* desired new y coordinate */
+double temp; /* for temporary calculations */
+FILE *fp; /* for opening files */
+register int loop; /* a loop counter */
+bool hasmoved = FALSE; /* set if player has moved */
+
+ ch = inputoption();
+ mvaddstr(4, 0, "\n\n"); /* clear status area */
+
+ move(7, 0);
+ clrtobot(); /* clear data on bottom area of screen */
+
+ if (Player.p_specialtype == SC_VALAR && (ch == '1' || ch == '7'))
+ /* valar cannot move */
+ ch = ' ';
+
+ switch (ch)
+ {
+ case 'K': /* move up/north */
+ case 'N':
+ x = Player.p_x;
+ y = Player.p_y + MAXMOVE();
+ hasmoved = TRUE;
+ break;
+
+ case 'J': /* move down/south */
+ case 'S':
+ x = Player.p_x;
+ y = Player.p_y - MAXMOVE();
+ hasmoved = TRUE;
+ break;
+
+ case 'L': /* move right/east */
+ case 'E':
+ x = Player.p_x + MAXMOVE();
+ y = Player.p_y;
+ hasmoved = TRUE;
+ break;
+
+ case 'H': /* move left/west */
+ case 'W':
+ x = Player.p_x - MAXMOVE();
+ y = Player.p_y;
+ hasmoved = TRUE;
+ break;
+
+ default: /* rest */
+ Player.p_energy += (Player.p_maxenergy + Player.p_shield) / 15.0
+ + Player.p_level / 3.0 + 2.0;
+ Player.p_energy =
+ MIN(Player.p_energy, Player.p_maxenergy + Player.p_shield);
+
+ if (Player.p_status != S_CLOAKED)
+ /* cannot find mana if cloaked */
+ {
+ Player.p_mana += (Circle + Player.p_level) / 4.0;
+
+ if (drandom() < 0.2 && Player.p_status == S_PLAYING && !Throne)
+ /* wandering monster */
+ encounter(-1);
+ }
+ break;
+
+ case 'X': /* change/examine a character */
+ changestats(TRUE);
+ break;
+
+ case '1': /* move */
+ for (loop = 3; loop; --loop)
+ {
+ mvaddstr(4, 0, "X Y Coordinates ? ");
+ getstring(Databuf, SZ_DATABUF);
+
+ if (sscanf(Databuf, "%lf %lf", &x, &y) != 2)
+ mvaddstr(5, 0, "Try again\n");
+ else if (distance(Player.p_x, x, Player.p_y, y) > MAXMOVE())
+ ILLMOVE();
+ else
+ {
+ hasmoved = TRUE;
+ break;
+ }
+ }
+ break;
+
+ case '2': /* players */
+ userlist(TRUE);
+ break;
+
+ case '3': /* message */
+ mvaddstr(4, 0, "Message ? ");
+ getstring(Databuf, SZ_DATABUF);
+ /* we open the file for writing to erase any data which is already there */
+ fp = fopen(_PATH_MESS, "w");
+ if (Databuf[0] != '\0')
+ fprintf(fp, "%s: %s", Player.p_name, Databuf);
+ fclose(fp);
+ break;
+
+ case '4': /* stats */
+ allstatslist();
+ break;
+
+ case '5': /* good-bye */
+ leavegame();
+ /*NOTREACHED*/
+
+ case '6': /* cloak */
+ if (Player.p_level < MEL_CLOAK || Player.p_magiclvl < ML_CLOAK)
+ ILLCMD();
+ else if (Player.p_status == S_CLOAKED)
+ Player.p_status = S_PLAYING;
+ else if (Player.p_mana < MM_CLOAK)
+ mvaddstr(5, 0, "No mana left.\n");
+ else
+ {
+ Changed = TRUE;
+ Player.p_mana -= MM_CLOAK;
+ Player.p_status = S_CLOAKED;
+ }
+ break;
+
+ case '7': /* teleport */
+ /*
+ * conditions for teleport
+ * - 20 per (level plus magic level)
+ * - OR council of the wise or valar or ex-valar
+ * - OR transport from throne
+ * transports from throne cost no mana
+ */
+ if (Player.p_level < MEL_TELEPORT || Player.p_magiclvl < ML_TELEPORT)
+ ILLCMD();
+ else
+ for (loop = 3; loop; --loop)
+ {
+ mvaddstr(4, 0, "X Y Coordinates ? ");
+ getstring(Databuf, SZ_DATABUF);
+
+ if (sscanf(Databuf, "%lf %lf", &x, &y) == 2)
+ {
+ temp = distance(Player.p_x, x, Player.p_y, y);
+ if (!Throne
+ /* can transport anywhere from throne */
+ && Player.p_specialtype <= SC_COUNCIL
+ /* council, valar can transport anywhere */
+ && temp > (Player.p_level + Player.p_magiclvl) * 20.0)
+ /* can only move 20 per exp. level + mag. level */
+ ILLMOVE();
+ else
+ {
+ temp = (temp / 75.0 + 1.0) * 20.0; /* mana used */
+
+ if (!Throne && temp > Player.p_mana)
+ mvaddstr(5, 0, "Not enough power for that distance.\n");
+ else
+ {
+ if (!Throne)
+ Player.p_mana -= temp;
+ hasmoved = TRUE;
+ break;
+ }
+ }
+ }
+ }
+ break;
+
+ case 'C':
+ case '9': /* monster */
+ if (Throne)
+ /* no monsters while on throne */
+ mvaddstr(5, 0, "No monsters in the chamber!\n");
+ else if (Player.p_specialtype != SC_VALAR)
+ /* the valar cannot call monsters */
+ {
+ Player.p_sin += 1e-6;
+ encounter(-1);
+ }
+ break;
+
+ case '0': /* decree */
+ if (Wizard || Player.p_specialtype == SC_KING && Throne)
+ /* kings must be on throne to decree */
+ dotampered();
+ else
+ ILLCMD();
+ break;
+
+ case '8': /* intervention */
+ if (Wizard || Player.p_specialtype >= SC_COUNCIL)
+ dotampered();
+ else
+ ILLCMD();
+ break;
+ }
+
+ if (hasmoved)
+ /* player has moved -- alter coordinates, and do random monster */
+ {
+ altercoordinates(x, y, A_SPECIFIC);
+
+ if (drandom() < 0.2 && Player.p_status == S_PLAYING && !Throne)
+ encounter(-1);
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: titlelist()
+/
+/ FUNCTION: print title page
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: fread(), fseek(), fopen(), fgets(), wmove(), strcpy(),
+/ fclose(), strlen(), waddstr(), sprintf(), wrefresh()
+/
+/ GLOBAL INPUTS: Lines, Other, *stdscr, Databuf[], *Playersfp
+/
+/ GLOBAL OUTPUTS: Lines
+/
+/ DESCRIPTION:
+/ Print important information about game, players, etc.
+/
+/************************************************************************/
+
+titlelist()
+{
+register FILE *fp; /* used for opening various files */
+bool councilfound = FALSE; /* set if we find a member of the council */
+bool kingfound = FALSE; /* set if we find a king */
+double hiexp, nxtexp; /* used for finding the two highest players */
+double hilvl, nxtlvl; /* used for finding the two highest players */
+char hiname[21], nxtname[21];/* used for finding the two highest players */
+
+ mvaddstr(0, 14, "W e l c o m e t o P h a n t a s i a (vers. 3.3.2)!");
+
+ /* print message of the day */
+ if ((fp = fopen(_PATH_MOTD, "r")) != NULL
+ && fgets(Databuf, SZ_DATABUF, fp) != NULL)
+ {
+ mvaddstr(2, 40 - strlen(Databuf) / 2, Databuf);
+ fclose(fp);
+ }
+
+ /* search for king */
+ fseek(Playersfp, 0L, 0);
+ while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
+ if (Other.p_specialtype == SC_KING && Other.p_status != S_NOTUSED)
+ /* found the king */
+ {
+ sprintf(Databuf, "The present ruler is %s Level:%.0f",
+ Other.p_name, Other.p_level);
+ mvaddstr(4, 40 - strlen(Databuf) / 2, Databuf);
+ kingfound = TRUE;
+ break;
+ }
+
+ if (!kingfound)
+ mvaddstr(4, 24, "There is no ruler at this time.");
+
+ /* search for valar */
+ fseek(Playersfp, 0L, 0);
+ while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
+ if (Other.p_specialtype == SC_VALAR && Other.p_status != S_NOTUSED)
+ /* found the valar */
+ {
+ sprintf(Databuf, "The Valar is %s Login: %s", Other.p_name, Other.p_login);
+ mvaddstr(6, 40 - strlen(Databuf) / 2 , Databuf);
+ break;
+ }
+
+ /* search for council of the wise */
+ fseek(Playersfp, 0L, 0);
+ Lines = 10;
+ while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
+ if (Other.p_specialtype == SC_COUNCIL && Other.p_status != S_NOTUSED)
+ /* found a member of the council */
+ {
+ if (!councilfound)
+ {
+ mvaddstr(8, 30, "Council of the Wise:");
+ councilfound = TRUE;
+ }
+
+ /* This assumes a finite (<=5) number of C.O.W.: */
+ sprintf(Databuf, "%s Login: %s", Other.p_name, Other.p_login);
+ mvaddstr(Lines++, 40 - strlen(Databuf) / 2, Databuf);
+ }
+
+ /* search for the two highest players */
+ nxtname[0] = hiname[0] = '\0';
+ hiexp = 0.0;
+ nxtlvl = hilvl = 0;
+
+ fseek(Playersfp, 0L, 0);
+ while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
+ if (Other.p_experience > hiexp && Other.p_specialtype <= SC_KING && Other.p_status != S_NOTUSED)
+ /* highest found so far */
+ {
+ nxtexp = hiexp;
+ hiexp = Other.p_experience;
+ nxtlvl = hilvl;
+ hilvl = Other.p_level;
+ strcpy(nxtname, hiname);
+ strcpy(hiname, Other.p_name);
+ }
+ else if (Other.p_experience > nxtexp
+ && Other.p_specialtype <= SC_KING
+ && Other.p_status != S_NOTUSED)
+ /* next highest found so far */
+ {
+ nxtexp = Other.p_experience;
+ nxtlvl = Other.p_level;
+ strcpy(nxtname, Other.p_name);
+ }
+
+ mvaddstr(15, 28, "Highest characters are:");
+ sprintf(Databuf, "%s Level:%.0f and %s Level:%.0f",
+ hiname, hilvl, nxtname, nxtlvl);
+ mvaddstr(17, 40 - strlen(Databuf) / 2, Databuf);
+
+ /* print last to die */
+ if ((fp = fopen(_PATH_LASTDEAD,"r")) != NULL
+ && fgets(Databuf, SZ_DATABUF, fp) != NULL)
+ {
+ mvaddstr(19, 25, "The last character to die was:");
+ mvaddstr(20, 40 - strlen(Databuf) / 2,Databuf);
+ fclose(fp);
+ }
+
+ refresh();
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: recallplayer()
+/
+/ FUNCTION: find a character on file
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: writerecord(), truncstring(), more(), death(), wmove(),
+/ wclear(), strcmp(), printw(), cleanup(), waddstr(), findname(), mvprintw(),
+/ getanswer(), getstring()
+/
+/ GLOBAL INPUTS: Player, *stdscr, Databuf[]
+/
+/ GLOBAL OUTPUTS: Echo, Player
+/
+/ DESCRIPTION:
+/ Search for a character of a certain name, and check password.
+/
+/************************************************************************/
+
+long
+recallplayer()
+{
+long loc = 0L; /* location in player file */
+register int loop; /* loop counter */
+int ch; /* input */
+
+ clear();
+ mvprintw(10, 0, "What was your character's name ? ");
+ getstring(Databuf, SZ_NAME);
+ truncstring(Databuf);
+
+ if ((loc = findname(Databuf, &Player)) >= 0L)
+ /* found character */
+ {
+ Echo = FALSE;
+
+ for (loop = 0; loop < 2; ++loop)
+ {
+ /* prompt for password */
+ mvaddstr(11, 0, "Password ? ");
+ getstring(Databuf, SZ_PASSWORD);
+ if (strcmp(Databuf, Player.p_password) == 0)
+ /* password good */
+ {
+ Echo = TRUE;
+
+ if (Player.p_status != S_OFF)
+ /* player did not exit normally last time */
+ {
+ clear();
+ addstr("Your character did not exit normally last time.\n");
+ addstr("If you think you have good cause to have your character saved,\n");
+ printw("you may quit and mail your reason to 'root'.\n");
+ addstr("Otherwise, continuing spells certain death.\n");
+ addstr("Do you want to quit ? ");
+ ch = getanswer("YN", FALSE);
+ if (ch == 'Y')
+ {
+ Player.p_status = S_HUNGUP;
+ writerecord(&Player, loc);
+ cleanup(TRUE);
+ /*NOTREACHED*/
+ }
+ death("Stupidity");
+ /*NOTREACHED*/
+ }
+ return(loc);
+ }
+ else
+ mvaddstr(12, 0, "No good.\n");
+ }
+
+ Echo = TRUE;
+ }
+ else
+ mvaddstr(11, 0, "Not found.\n");
+
+ more(13);
+ return(-1L);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: neatstuff()
+/
+/ FUNCTION: do random stuff
+/
+/ AUTHOR: E. A. Estes, 3/3/86
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: collecttaxes(), floor(), wmove(), drandom(), infloat(),
+/ waddstr(), mvprintw(), getanswer()
+/
+/ GLOBAL INPUTS: Player, *stdscr, *Statptr
+/
+/ GLOBAL OUTPUTS: Player
+/
+/ DESCRIPTION:
+/ Handle gurus, medics, etc.
+/
+/************************************************************************/
+
+neatstuff()
+{
+double temp; /* for temporary calculations */
+int ch; /* input */
+
+ switch ((int) ROLL(0.0, 100.0))
+ {
+ case 1:
+ case 2:
+ if (Player.p_poison > 0.0)
+ {
+ mvaddstr(4, 0, "You've found a medic! How much will you offer to be cured ? ");
+ temp = floor(infloat());
+ if (temp < 0.0 || temp > Player.p_gold)
+ /* negative gold, or more than available */
+ {
+ mvaddstr(6, 0, "He was not amused, and made you worse.\n");
+ Player.p_poison += 1.0;
+ }
+ else if (drandom() / 2.0 > (temp + 1.0) / MAX(Player.p_gold, 1))
+ /* medic wants 1/2 of available gold */
+ mvaddstr(5, 0, "Sorry, he wasn't interested.\n");
+ else
+ {
+ mvaddstr(5, 0, "He accepted.");
+ Player.p_poison = MAX(0.0, Player.p_poison - 1.0);
+ Player.p_gold -= temp;
+ }
+ }
+ break;
+
+ case 3:
+ mvaddstr(4, 0, "You've been caught raping and pillaging!\n");
+ Player.p_experience += 4000.0;
+ Player.p_sin += 0.5;
+ break;
+
+ case 4:
+ temp = ROLL(10.0, 75.0);
+ mvprintw(4, 0, "You've found %.0f gold pieces, want them ? ", temp);
+ ch = getanswer("NY", FALSE);
+
+ if (ch == 'Y')
+ collecttaxes(temp, 0.0);
+ break;
+
+ case 5:
+ if (Player.p_sin > 1.0)
+ {
+ mvaddstr(4, 0, "You've found a Holy Orb!\n");
+ Player.p_sin -= 0.25;
+ }
+ break;
+
+ case 6:
+ if (Player.p_poison < 1.0)
+ {
+ mvaddstr(4, 0, "You've been hit with a plague!\n");
+ Player.p_poison += 1.0;
+ }
+ break;
+
+ case 7:
+ mvaddstr(4, 0, "You've found some holy water.\n");
+ ++Player.p_holywater;
+ break;
+
+ case 8:
+ mvaddstr(4, 0, "You've met a Guru. . .");
+ if (drandom() * Player.p_sin > 1.0)
+ addstr("You disgusted him with your sins!\n");
+ else if (Player.p_poison > 0.0)
+ {
+ addstr("He looked kindly upon you, and cured you.\n");
+ Player.p_poison = 0.0;
+ }
+ else
+ {
+ addstr("He rewarded you for your virtue.\n");
+ Player.p_mana += 50.0;
+ Player.p_shield += 2.0;
+ }
+ break;
+
+ case 9:
+ mvaddstr(4, 0, "You've found an amulet.\n");
+ ++Player.p_amulets;
+ break;
+
+ case 10:
+ if (Player.p_blindness)
+ {
+ mvaddstr(4, 0, "You've regained your sight!\n");
+ Player.p_blindness = FALSE;
+ }
+ break;
+
+ default: /* deal with poison */
+ if (Player.p_poison > 0.0)
+ {
+ temp = Player.p_poison * Statptr->c_weakness
+ * Player.p_maxenergy / 600.0;
+ if (Player.p_energy > Player.p_maxenergy / 10.0
+ && temp + 5.0 < Player.p_energy)
+ Player.p_energy -= temp;
+ }
+ break;
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: genchar()
+/
+/ FUNCTION: generate a random character
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ int type - ASCII value of character type to generate
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: floor(), drandom()
+/
+/ GLOBAL INPUTS: Wizard, Player, Stattable[]
+/
+/ GLOBAL OUTPUTS: Player
+/
+/ DESCRIPTION:
+/ Use the lookup table for rolling stats.
+/
+/************************************************************************/
+
+genchar(type)
+int type;
+{
+register int subscript; /* used for subscripting into Stattable */
+register struct charstats *statptr;/* for pointing into Stattable */
+
+ subscript = type - '1';
+
+ if (subscript < C_MAGIC || subscript > C_EXPER)
+ if (subscript != C_SUPER || !Wizard)
+ /* fighter is default */
+ subscript = C_FIGHTER;
+
+ statptr = &Stattable[subscript];
+
+ Player.p_quickness =
+ ROLL(statptr->c_quickness.base, statptr->c_quickness.interval);
+ Player.p_strength =
+ ROLL(statptr->c_strength.base, statptr->c_strength.interval);
+ Player.p_mana =
+ ROLL(statptr->c_mana.base, statptr->c_mana.interval);
+ Player.p_maxenergy =
+ Player.p_energy =
+ ROLL(statptr->c_energy.base, statptr->c_energy.interval);
+ Player.p_brains =
+ ROLL(statptr->c_brains.base, statptr->c_brains.interval);
+ Player.p_magiclvl =
+ ROLL(statptr->c_magiclvl.base, statptr->c_magiclvl.interval);
+
+ Player.p_type = subscript;
+
+ if (Player.p_type == C_HALFLING)
+ /* give halfling some experience */
+ Player.p_experience = ROLL(600.0, 200.0);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: playinit()
+/
+/ FUNCTION: initialize for playing game
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: signal(), wclear(), noecho(), crmode(), initscr(),
+/ wrefresh()
+/
+/ GLOBAL INPUTS: *stdscr, ill_sig()
+/
+/ GLOBAL OUTPUTS: Windows
+/
+/ DESCRIPTION:
+/ Catch a bunch of signals, and turn on curses stuff.
+/
+/************************************************************************/
+
+playinit()
+{
+ /* catch/ingnore signals */
+
+#ifdef BSD41
+ sigignore(SIGQUIT);
+ sigignore(SIGALRM);
+ sigignore(SIGTERM);
+ sigignore(SIGTSTP);
+ sigignore(SIGTTIN);
+ sigignore(SIGTTOU);
+ sighold(SIGINT);
+ sigset(SIGHUP, ill_sig);
+ sigset(SIGTRAP, ill_sig);
+ sigset(SIGIOT, ill_sig);
+ sigset(SIGEMT, ill_sig);
+ sigset(SIGFPE, ill_sig);
+ sigset(SIGBUS, ill_sig);
+ sigset(SIGSEGV, ill_sig);
+ sigset(SIGSYS, ill_sig);
+ sigset(SIGPIPE, ill_sig);
+#endif
+#ifdef BSD42
+ signal(SIGQUIT, ill_sig);
+ signal(SIGALRM, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+ signal(SIGTSTP, SIG_IGN);
+ signal(SIGTTIN, SIG_IGN);
+ signal(SIGTTOU, SIG_IGN);
+ signal(SIGINT, ill_sig);
+ signal(SIGHUP, SIG_DFL);
+ signal(SIGTRAP, ill_sig);
+ signal(SIGIOT, ill_sig);
+ signal(SIGEMT, ill_sig);
+ signal(SIGFPE, ill_sig);
+ signal(SIGBUS, ill_sig);
+ signal(SIGSEGV, ill_sig);
+ signal(SIGSYS, ill_sig);
+ signal(SIGPIPE, ill_sig);
+#endif
+#ifdef SYS3
+ signal(SIGINT, SIG_IGN);
+ signal(SIGQUIT, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+ signal(SIGALRM, SIG_IGN);
+ signal(SIGHUP, ill_sig);
+ signal(SIGTRAP, ill_sig);
+ signal(SIGIOT, ill_sig);
+ signal(SIGEMT, ill_sig);
+ signal(SIGFPE, ill_sig);
+ signal(SIGBUS, ill_sig);
+ signal(SIGSEGV, ill_sig);
+ signal(SIGSYS, ill_sig);
+ signal(SIGPIPE, ill_sig);
+#endif
+#ifdef SYS5
+ signal(SIGINT, SIG_IGN);
+ signal(SIGQUIT, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+ signal(SIGALRM, SIG_IGN);
+ signal(SIGHUP, ill_sig);
+ signal(SIGTRAP, ill_sig);
+ signal(SIGIOT, ill_sig);
+ signal(SIGEMT, ill_sig);
+ signal(SIGFPE, ill_sig);
+ signal(SIGBUS, ill_sig);
+ signal(SIGSEGV, ill_sig);
+ signal(SIGSYS, ill_sig);
+ signal(SIGPIPE, ill_sig);
+#endif
+
+ initscr(); /* turn on curses */
+ noecho(); /* do not echo input */
+ crmode(); /* do not process erase, kill */
+ clear();
+ refresh();
+ Windows = TRUE; /* mark the state */
+}
+
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: cleanup()
+/
+/ FUNCTION: close some files, and maybe exit
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ bool doexit - exit flag
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: exit(), wmove(), fclose(), endwin(), nocrmode(), wrefresh()
+/
+/ GLOBAL INPUTS: *Energyvoidfp, LINES, *stdscr, Windows, *Monstfp,
+/ *Messagefp, *Playersfp
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Close all open files. If we are "in curses" terminate curses.
+/ If 'doexit' is set, exit, otherwise return.
+/
+/************************************************************************/
+
+cleanup(doexit)
+bool doexit;
+{
+ if (Windows)
+ {
+ move(LINES - 2, 0);
+ refresh();
+ nocrmode();
+ endwin();
+ }
+
+ fclose(Playersfp);
+ fclose(Monstfp);
+ fclose(Messagefp);
+ fclose(Energyvoidfp);
+
+ if (doexit)
+ exit(0);
+ /*NOTREACHED*/
+}
diff --git a/games/phantasia/map.c b/games/phantasia/map.c
new file mode 100644
index 0000000..be035df
--- /dev/null
+++ b/games/phantasia/map.c
@@ -0,0 +1,160 @@
+#define minusminus plusplus
+#define minusplus plusminus
+
+main()
+{
+ /* Set up */
+
+ openpl();
+ space(-1400, -1000, 1200, 1200);
+
+ /* Big box */
+
+ move(-1400, -1000);
+ cont(-1400, 1000);
+ cont(600, 1000);
+ cont(600, -1000);
+ cont(-1400, -1000);
+
+ /* Grid -- horizontal lines every 200 */
+
+ linemod("dotted");
+ line(600, -800, -1400, -800);
+ line(-1400, -600, 600, -600);
+ line(600, -400, -1400, -400);
+ line(-1400, -200, 600, -200);
+ linemod("solid");
+ line(600, 0, -1400, 0);
+ linemod("dotted");
+ line(-1400, 200, 600, 200);
+ line(600, 400, -1400, 400);
+ line(-1400, 600, 600, 600);
+ line(600, 800, -1400, 800);
+
+ /* Grid -- vertical lines every 200 */
+
+ line(-1200, 1000, -1200, -1000);
+ line(-1000, 1000, -1000, -1000);
+ line(-800, 1000, -800, -1000);
+ line(-600, 1000, -600, -1000);
+ linemod("solid");
+ line(-400, 1000, -400, -1000);
+ linemod("dotted");
+ line(-200, 1000, -200, -1000);
+ line(0, 1000, 0, -1000);
+ line(200, 1000, 200, -1000);
+ line(400, 1000, 400, -1000);
+
+ /* Circles radius +250 on "center" */
+
+ linemod("solid");
+ circle(-400, 0, 250);
+ circle(-400, 0, 500);
+ circle(-400, 0, 750);
+ circle(-400, 0, 1000);
+
+ /* A few labels */
+
+ move(-670, 1075);
+ label("- THE PHANTASIA UNIVERSE -");
+ line(-630, 1045, -115, 1045);
+ move(-360, 80);
+ label("Lorien");
+ move(-385, -100);
+ label("Ithilien");
+ move(-560, 80);
+ label("Rohan");
+ move(-580, -100);
+ label("Anorien");
+ plusplus("Rovanion", -250, 320);
+ plusplus("The Iron Hills", -100, 560);
+ plusplus("Rhun", 250, 570);
+ minusplus("Dunland", -700, 160);
+ minusplus("Eriador", -920, 300);
+ minusplus("The Northern Waste", -1240, 320);
+ minusminus("Gondor", -720, -180);
+ minusminus("South Gondor", -940, -270);
+ minusminus("Far Harad", -1100, -500);
+ plusminus("Mordor", -180, -300);
+ plusminus("Khand", 0, -500);
+ plusminus("Near Harad", 40, -780);
+ move(340, 900);
+ label("The Moors");
+ move(300, 840);
+ label("Adventurous");
+ move(340, -840);
+ label("The Moors");
+ move(300, -900);
+ label("Adventurous");
+ move(-1340, 900);
+ label("The Moors");
+ move(-1340, 840);
+ label("Adventurous");
+ move(-1340, -840);
+ label("The Moors");
+ move(-1340, -900);
+ label("Adventurous");
+ move(700, 1000);
+ label("OUTER CIRCLES:");
+ line(690, 970, 1000, 970);
+ move(700, 900);
+ label("> 9: The Outer Waste");
+ move(700, 800);
+ label("> 20: The Dead Marshes");
+ move(700, 700);
+ label("> 35: Kennaquhair");
+ move(700, 600);
+ label("> 55: Morannon");
+ move(700, 300);
+ label("(0,0): The Lord's Chamber");
+
+ move(700, -400);
+ label("Grid squares are 100 x 100");
+ move(700, -800);
+ label("Created by Ted Estes");
+ move(700, -860);
+ label("Plotted by Chris Robertson");
+ move(700, -920);
+ label(" c 1985");
+ circle(723, -923, 20);
+
+ /* Close down */
+
+ move(-1380, 1180);
+ closepl();
+ exit(0);
+}
+
+plusplus(s, x, y) /* draw strings in plus plus quadrant */
+char *s;
+int x, y;
+{
+char s1[2];
+
+ while (*s)
+ {
+ move(x, y);
+ s1[0] = *s++;
+ s1[1] = '\0';
+ label(s1);
+ x += 25;
+ y -= 30;
+ }
+}
+
+plusminus(s, x, y) /* draw strings in plus minus quadrant */
+char *s;
+int x, y;
+{
+char s1[2];
+
+ while (*s)
+ {
+ move(x, y);
+ s1[0] = *s++;
+ s1[1] = '\0';
+ label(s1);
+ x += 25;
+ y += 30;
+ }
+}
diff --git a/games/phantasia/misc.c b/games/phantasia/misc.c
new file mode 100644
index 0000000..42c039d
--- /dev/null
+++ b/games/phantasia/misc.c
@@ -0,0 +1,1703 @@
+/*
+ * misc.c Phantasia miscellaneous support routines
+ */
+
+#include "include.h"
+
+
+/************************************************************************
+/
+/ FUNCTION NAME: movelevel()
+/
+/ FUNCTION: move player to new level
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: death(), floor(), wmove(), drandom(), waddstr(), explevel()
+/
+/ GLOBAL INPUTS: Player, *stdscr, *Statptr, Stattable[]
+/
+/ GLOBAL OUTPUTS: Player, Changed
+/
+/ DESCRIPTION:
+/ Use lookup table to increment important statistics when
+/ progressing to new experience level.
+/ Players are rested to maximum as a bonus for making a new
+/ level.
+/ Check for council of wise, and being too big to be king.
+/
+/************************************************************************/
+
+movelevel()
+{
+register struct charstats *statptr; /* for pointing into Stattable */
+double new; /* new level */
+double inc; /* increment between new and old levels */
+
+ Changed = TRUE;
+
+ if (Player.p_type == C_EXPER)
+ /* roll a type to use for increment */
+ statptr = &Stattable[(int) ROLL(C_MAGIC, C_HALFLING - C_MAGIC + 1)];
+ else
+ statptr = Statptr;
+
+ new = explevel(Player.p_experience);
+ inc = new - Player.p_level;
+ Player.p_level = new;
+
+ /* add increments to statistics */
+ Player.p_strength += statptr->c_strength.increase * inc;
+ Player.p_mana += statptr->c_mana.increase * inc;
+ Player.p_brains += statptr->c_brains.increase * inc;
+ Player.p_magiclvl += statptr->c_magiclvl.increase * inc;
+ Player.p_maxenergy += statptr->c_energy.increase * inc;
+
+ /* rest to maximum upon reaching new level */
+ Player.p_energy = Player.p_maxenergy + Player.p_shield;
+
+ if (Player.p_crowns > 0 && Player.p_level >= 1000.0)
+ /* no longer able to be king -- turn crowns into cash */
+ {
+ Player.p_gold += ((double) Player.p_crowns) * 5000.0;
+ Player.p_crowns = 0;
+ }
+
+ if (Player.p_level >= 3000.0 && Player.p_specialtype < SC_COUNCIL)
+ /* make a member of the council */
+ {
+ mvaddstr(6, 0, "You have made it to the Council of the Wise.\n");
+ addstr("Good Luck on your search for the Holy Grail.\n");
+
+ Player.p_specialtype = SC_COUNCIL;
+
+ /* no rings for council and above */
+ Player.p_ring.ring_type = R_NONE;
+ Player.p_ring.ring_duration = 0;
+
+ Player.p_lives = 3; /* three extra lives */
+ }
+
+ if (Player.p_level > 9999.0 && Player.p_specialtype != SC_VALAR)
+ death("Old age");
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: descrlocation()
+/
+/ FUNCTION: return a formatted description of location
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ struct player playerp - pointer to player structure
+/ bool shortflag - set if short form is desired
+/
+/ RETURN VALUE: pointer to string containing result
+/
+/ MODULES CALLED: fabs(), floor(), sprintf(), distance()
+/
+/ GLOBAL INPUTS: Databuf[]
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Look at coordinates and return an appropriately formatted
+/ string.
+/
+/************************************************************************/
+
+char *
+descrlocation(playerp, shortflag)
+struct player *playerp;
+bool shortflag;
+{
+double circle; /* corresponding circle for coordinates */
+register int quadrant; /* quandrant of grid */
+register char *label; /* pointer to place name */
+static char *nametable[4][4] = /* names of places */
+ {
+ "Anorien", "Ithilien", "Rohan", "Lorien",
+ "Gondor", "Mordor", "Dunland", "Rovanion",
+ "South Gondor", "Khand", "Eriador", "The Iron Hills",
+ "Far Harad", "Near Harad", "The Northern Waste", "Rhun"
+ };
+
+ if (playerp->p_specialtype == SC_VALAR)
+ return(" is in Valhala");
+ else if ((circle = CIRCLE(playerp->p_x, playerp->p_y)) >= 1000.0)
+ {
+ if (MAX(fabs(playerp->p_x), fabs(playerp->p_y)) > D_BEYOND)
+ label = "The Point of No Return";
+ else
+ label = "The Ashen Mountains";
+ }
+ else if (circle >= 55)
+ label = "Morannon";
+ else if (circle >= 35)
+ label = "Kennaquahair";
+ else if (circle >= 20)
+ label = "The Dead Marshes";
+ else if (circle >= 9)
+ label = "The Outer Waste";
+ else if (circle >= 5)
+ label = "The Moors Adventurous";
+ else
+ {
+ if (playerp->p_x == 0.0 && playerp->p_y == 0.0)
+ label = "The Lord's Chamber";
+ else
+ {
+ /* this expression is split to prevent compiler loop with some compilers */
+ quadrant = ((playerp->p_x > 0.0) ? 1 : 0);
+ quadrant += ((playerp->p_y >= 0.0) ? 2 : 0);
+ label = nametable[((int) circle) - 1][quadrant];
+ }
+ }
+
+ if (shortflag)
+ sprintf(Databuf, "%.29s", label);
+ else
+ sprintf(Databuf, " is in %s (%.0f,%.0f)", label, playerp->p_x, playerp->p_y);
+
+ return(Databuf);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: tradingpost()
+/
+/ FUNCTION: do trading post stuff
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: writerecord(), adjuststats(), fabs(), more(), sqrt(),
+/ sleep(), floor(), wmove(), drandom(), wclear(), printw(),
+/ altercoordinates(), infloat(), waddstr(), wrefresh(), mvprintw(), getanswer(),
+/ wclrtoeol(), wclrtobot()
+/
+/ GLOBAL INPUTS: Menu[], Circle, Player, *stdscr, Fileloc, Nobetter[]
+/
+/ GLOBAL OUTPUTS: Player
+/
+/ DESCRIPTION:
+/ Different trading posts have different items.
+/ Merchants cannot be cheated, but they can be dishonest
+/ themselves.
+/
+/ Shields, swords, and quicksilver are not cumulative. This is
+/ one major area of complaint, but there are two reasons for this:
+/ 1) It becomes MUCH too easy to make very large versions
+/ of these items.
+/ 2) In the real world, one cannot simply weld two swords
+/ together to make a bigger one.
+/
+/ At one time, it was possible to sell old weapons at half the purchase
+/ price. This resulted in huge amounts of gold floating around,
+/ and the game lost much of its challenge.
+/
+/ Also, purchasing gems defeats the whole purpose of gold. Gold
+/ is small change for lower level players. They really shouldn't
+/ be able to accumulate more than enough gold for a small sword or
+/ a few books. Higher level players shouldn't even bother to pick
+/ up gold, except maybe to buy mana once in a while.
+/
+/************************************************************************/
+
+tradingpost()
+{
+double numitems; /* number of items to purchase */
+double cost; /* cost of purchase */
+double blessingcost; /* cost of blessing */
+int ch; /* input */
+register int size; /* size of the trading post */
+register int loop; /* loop counter */
+int cheat = 0; /* number of times player has tried to cheat */
+bool dishonest = FALSE;/* set when merchant is dishonest */
+
+ Player.p_status = S_TRADING;
+ writerecord(&Player, Fileloc);
+
+ clear();
+ addstr("You are at a trading post. All purchases must be made with gold.");
+
+ size = sqrt(fabs(Player.p_x / 100)) + 1;
+ size = MIN(7, size);
+
+ /* set up cost of blessing */
+ blessingcost = 1000.0 * (Player.p_level + 5.0);
+
+ /* print Menu */
+ move(7, 0);
+ for (loop = 0; loop < size; ++loop)
+ /* print Menu */
+ {
+ if (loop == 6)
+ cost = blessingcost;
+ else
+ cost = Menu[loop].cost;
+ printw("(%d) %-12s: %6.0f\n", loop + 1, Menu[loop].item, cost);
+ }
+
+ mvprintw(5, 0, "L:Leave P:Purchase S:Sell Gems ? ");
+
+ for (;;)
+ {
+ adjuststats(); /* truncate any bad values */
+
+ /* print some important statistics */
+ mvprintw(1, 0, "Gold: %9.0f Gems: %9.0f Level: %6.0f Charms: %6d\n",
+ Player.p_gold, Player.p_gems, Player.p_level, Player.p_charms);
+ printw("Shield: %9.0f Sword: %9.0f Quicksilver:%3.0f Blessed: %s\n",
+ Player.p_shield, Player.p_sword, Player.p_quksilver,
+ (Player.p_blessing ? " True" : "False"));
+ printw("Brains: %9.0f Mana: %9.0f", Player.p_brains, Player.p_mana);
+
+ move(5, 36);
+ ch = getanswer("LPS", FALSE);
+ move(15, 0);
+ clrtobot();
+ switch(ch)
+ {
+ case 'L': /* leave */
+ case '\n':
+ altercoordinates(0.0, 0.0, A_NEAR);
+ return;
+
+ case 'P': /* make purchase */
+ mvaddstr(15, 0, "What what would you like to buy ? ");
+ ch = getanswer(" 1234567", FALSE);
+ move(15, 0);
+ clrtoeol();
+
+ if (ch - '0' > size)
+ addstr("Sorry, this merchant doesn't have that.");
+ else
+ switch (ch)
+ {
+ case '1':
+ printw("Mana is one per %.0f gold piece. How many do you want (%.0f max) ? ",
+ Menu[0].cost, floor(Player.p_gold / Menu[0].cost));
+ cost = (numitems = floor(infloat())) * Menu[0].cost;
+
+ if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else
+ {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_mana += numitems;
+ }
+ break;
+
+ case '2':
+ printw("Shields are %.0f per +1. How many do you want (%.0f max) ? ",
+ Menu[1].cost, floor(Player.p_gold / Menu[1].cost));
+ cost = (numitems = floor(infloat())) * Menu[1].cost;
+
+ if (numitems == 0.0)
+ break;
+ else if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else if (numitems < Player.p_shield)
+ NOBETTER();
+ else
+ {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_shield = numitems;
+ }
+ break;
+
+ case '3':
+ printw("A book costs %.0f gp. How many do you want (%.0f max) ? ",
+ Menu[2].cost, floor(Player.p_gold / Menu[2].cost));
+ cost = (numitems = floor(infloat())) * Menu[2].cost;
+
+ if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else
+ {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else if (drandom() * numitems > Player.p_level / 10.0
+ && numitems != 1)
+ {
+ printw("\nYou blew your mind!\n");
+ Player.p_brains /= 5;
+ }
+ else
+ {
+ Player.p_brains += floor(numitems) * ROLL(20, 8);
+ }
+ }
+ break;
+
+ case '4':
+ printw("Swords are %.0f gp per +1. How many + do you want (%.0f max) ? ",
+ Menu[3].cost, floor(Player.p_gold / Menu[3].cost));
+ cost = (numitems = floor(infloat())) * Menu[3].cost;
+
+ if (numitems == 0.0)
+ break;
+ else if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else if (numitems < Player.p_sword)
+ NOBETTER();
+ else
+ {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_sword = numitems;
+ }
+ break;
+
+ case '5':
+ printw("A charm costs %.0f gp. How many do you want (%.0f max) ? ",
+ Menu[4].cost, floor(Player.p_gold / Menu[4].cost));
+ cost = (numitems = floor(infloat())) * Menu[4].cost;
+
+ if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else
+ {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_charms += numitems;
+ }
+ break;
+
+ case '6':
+ printw("Quicksilver is %.0f gp per +1. How many + do you want (%.0f max) ? ",
+ Menu[5].cost, floor(Player.p_gold / Menu[5].cost));
+ cost = (numitems = floor(infloat())) * Menu[5].cost;
+
+ if (numitems == 0.0)
+ break;
+ else if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else if (numitems < Player.p_quksilver)
+ NOBETTER();
+ else
+ {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_quksilver = numitems;
+ }
+ break;
+
+ case '7':
+ if (Player.p_blessing)
+ {
+ addstr("You already have a blessing.");
+ break;
+ }
+
+ printw("A blessing requires a %.0f gp donation. Still want one ? ", blessingcost);
+ ch = getanswer("NY", FALSE);
+
+ if (ch == 'Y')
+ if (Player.p_gold < blessingcost)
+ ++cheat;
+ else
+ {
+ cheat = 0;
+ Player.p_gold -= blessingcost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_blessing = TRUE;
+ }
+ break;
+ }
+ break;
+
+ case 'S': /* sell gems */
+ mvprintw(15, 0, "A gem is worth %.0f gp. How many do you want to sell (%.0f max) ? ",
+ (double) N_GEMVALUE, Player.p_gems);
+ numitems = floor(infloat());
+
+ if (numitems > Player.p_gems || numitems < 0)
+ ++cheat;
+ else
+ {
+ cheat = 0;
+ Player.p_gems -= numitems;
+ Player.p_gold += numitems * N_GEMVALUE;
+ }
+ }
+
+ if (cheat == 1)
+ mvaddstr(17, 0, "Come on, merchants aren't stupid. Stop cheating.\n");
+ else if (cheat == 2)
+ {
+ mvaddstr(17, 0, "You had your chance. This merchant happens to be\n");
+ printw("a %.0f level magic user, and you made %s mad!\n",
+ ROLL(Circle * 20.0, 40.0), (drandom() < 0.5) ? "him" : "her");
+ altercoordinates(0.0, 0.0, A_FAR);
+ Player.p_energy /= 2.0;
+ ++Player.p_sin;
+ more(23);
+ return;
+ }
+ else if (dishonest)
+ {
+ mvaddstr(17, 0, "The merchant stole your money!");
+ refresh();
+ altercoordinates(Player.p_x - Player.p_x / 10.0,
+ Player.p_y - Player.p_y / 10.0, A_SPECIFIC);
+ sleep(2);
+ return;
+ }
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: displaystats()
+/
+/ FUNCTION: print out important player statistics
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: descrstatus(), descrlocation(), mvprintw()
+/
+/ GLOBAL INPUTS: Users, Player
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Important player statistics are printed on the screen.
+/
+/************************************************************************/
+
+displaystats()
+{
+ mvprintw(0, 0, "%s%s\n", Player.p_name, descrlocation(&Player, FALSE));
+ mvprintw(1, 0, "Level :%7.0f Energy :%9.0f(%9.0f) Mana :%9.0f Users:%3d\n",
+ Player.p_level, Player.p_energy, Player.p_maxenergy + Player.p_shield,
+ Player.p_mana, Users);
+ mvprintw(2, 0, "Quick :%3.0f(%3.0f) Strength:%9.0f(%9.0f) Gold :%9.0f %s\n",
+ Player.p_speed, Player.p_quickness + Player.p_quksilver, Player.p_might,
+ Player.p_strength + Player.p_sword, Player.p_gold, descrstatus(&Player));
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: allstatslist()
+/
+/ FUNCTION: show player items
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: mvprintw(), descrtype()
+/
+/ GLOBAL INPUTS: Player
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Print out some player statistics of lesser importance.
+/
+/************************************************************************/
+
+allstatslist()
+{
+static char *flags[] = /* to print value of some bools */
+ {
+ "False",
+ " True"
+ };
+
+ mvprintw( 8, 0, "Type: %s\n", descrtype(&Player, FALSE));
+
+ mvprintw(10, 0, "Experience: %9.0f", Player.p_experience);
+ mvprintw(11, 0, "Brains : %9.0f", Player.p_brains);
+ mvprintw(12, 0, "Magic Lvl : %9.0f", Player.p_magiclvl);
+ mvprintw(13, 0, "Sin : %9.5f", Player.p_sin);
+ mvprintw(14, 0, "Poison : %9.5f", Player.p_poison);
+ mvprintw(15, 0, "Gems : %9.0f", Player.p_gems);
+ mvprintw(16, 0, "Age : %9d", Player.p_age);
+ mvprintw(10, 40, "Holy Water: %9d", Player.p_holywater);
+ mvprintw(11, 40, "Amulets : %9d", Player.p_amulets);
+ mvprintw(12, 40, "Charms : %9d", Player.p_charms);
+ mvprintw(13, 40, "Crowns : %9d", Player.p_crowns);
+ mvprintw(14, 40, "Shield : %9.0f", Player.p_shield);
+ mvprintw(15, 40, "Sword : %9.0f", Player.p_sword);
+ mvprintw(16, 40, "Quickslver: %9.0f", Player.p_quksilver);
+
+ mvprintw(18, 0, "Blessing: %s Ring: %s Virgin: %s Palantir: %s",
+ flags[Player.p_blessing], flags[Player.p_ring.ring_type != R_NONE],
+ flags[Player.p_virgin], flags[Player.p_palantir]);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: descrtype()
+/
+/ FUNCTION: return a string specifying player type
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ struct player playerp - pointer to structure for player
+/ bool shortflag - set if short form is desired
+/
+/ RETURN VALUE: pointer to string describing player type
+/
+/ MODULES CALLED: strcpy()
+/
+/ GLOBAL INPUTS: Databuf[]
+/
+/ GLOBAL OUTPUTS: Databuf[]
+/
+/ DESCRIPTION:
+/ Return a string describing the player type.
+/ King, council, valar, supercedes other types.
+/ The first character of the string is '*' if the player
+/ has a crown.
+/ If 'shortflag' is TRUE, return a 3 character string.
+/
+/************************************************************************/
+
+char *
+descrtype(playerp, shortflag)
+struct player *playerp;
+bool shortflag;
+{
+register int type; /* for caluculating result subscript */
+static char *results[] = /* description table */
+ {
+ " Magic User", " MU",
+ " Fighter", " F ",
+ " Elf", " E ",
+ " Dwarf", " D ",
+ " Halfling", " H ",
+ " Experimento", " EX",
+ " Super", " S ",
+ " King", " K ",
+ " Council of Wise", " CW",
+ " Ex-Valar", " EV",
+ " Valar", " V ",
+ " ? ", " ? "
+ };
+
+ type = playerp->p_type;
+
+ switch (playerp->p_specialtype)
+ {
+ case SC_NONE:
+ type = playerp->p_type;
+ break;
+
+ case SC_KING:
+ type = 7;
+ break;
+
+ case SC_COUNCIL:
+ type = 8;
+ break;
+
+ case SC_EXVALAR:
+ type = 9;
+ break;
+
+ case SC_VALAR:
+ type = 10;
+ break;
+ }
+
+ type *= 2; /* calculate offset */
+
+ if (type > 20)
+ /* error */
+ type = 22;
+
+ if (shortflag)
+ /* use short descriptions */
+ ++type;
+
+ if (playerp->p_crowns > 0)
+ {
+ strcpy(Databuf, results[type]);
+ Databuf[0] = '*';
+ return(Databuf);
+ }
+ else
+ return(results[type]);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: findname()
+/
+/ FUNCTION: find location in player file of given name
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ char *name - name of character to look for
+/ struct player *playerp - pointer of structure to fill
+/
+/ RETURN VALUE: location of player if found, -1 otherwise
+/
+/ MODULES CALLED: fread(), fseek(), strcmp()
+/
+/ GLOBAL INPUTS: Wizard, *Playersfp
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Search the player file for the player of the given name.
+/ If player is found, fill structure with player data.
+/
+/************************************************************************/
+
+long
+findname(name, playerp)
+register char *name;
+register struct player *playerp;
+{
+long loc = 0; /* location in the file */
+
+ fseek(Playersfp, 0L, 0);
+ while (fread((char *) playerp, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
+ {
+ if (strcmp(playerp->p_name, name) == 0)
+ {
+ if (playerp->p_status != S_NOTUSED || Wizard)
+ /* found it */
+ return(loc);
+ }
+ loc += SZ_PLAYERSTRUCT;
+ }
+
+ return(-1);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: allocrecord()
+/
+/ FUNCTION: find space in the player file for a new character
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: location of free space in file
+/
+/ MODULES CALLED: initplayer(), writerecord(), fread(), fseek()
+/
+/ GLOBAL INPUTS: Other, *Playersfp
+/
+/ GLOBAL OUTPUTS: Player
+/
+/ DESCRIPTION:
+/ Search the player file for an unused entry. If none are found,
+/ make one at the end of the file.
+/
+/************************************************************************/
+
+long
+allocrecord()
+{
+long loc = 0L; /* location in file */
+
+ fseek(Playersfp, 0L, 0);
+ while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
+ {
+ if (Other.p_status == S_NOTUSED)
+ /* found an empty record */
+ return(loc);
+ else
+ loc += SZ_PLAYERSTRUCT;
+ }
+
+ /* make a new record */
+ initplayer(&Other);
+ Player.p_status = S_OFF;
+ writerecord(&Other, loc);
+
+ return(loc);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: freerecord()
+/
+/ FUNCTION: free up a record on the player file
+/
+/ AUTHOR: E. A. Estes, 2/7/86
+/
+/ ARGUMENTS:
+/ struct player playerp - pointer to structure to free
+/ long loc - location in file to free
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: writerecord()
+/
+/ GLOBAL INPUTS: none
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Mark structure as not used, and update player file.
+/
+/************************************************************************/
+
+freerecord(playerp, loc)
+struct player *playerp;
+long loc;
+{
+ playerp->p_name[0] = CH_MARKDELETE;
+ playerp->p_status = S_NOTUSED;
+ writerecord(playerp, loc);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: leavegame()
+/
+/ FUNCTION: leave game
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: freerecord(), writerecord(), cleanup()
+/
+/ GLOBAL INPUTS: Player, Fileloc
+/
+/ GLOBAL OUTPUTS: Player
+/
+/ DESCRIPTION:
+/ Mark player as inactive, and cleanup.
+/ Do not save players below level 1.
+/
+/************************************************************************/
+
+leavegame()
+{
+
+ if (Player.p_level < 1.0)
+ /* delete character */
+ freerecord(&Player, Fileloc);
+ else
+ {
+ Player.p_status = S_OFF;
+ writerecord(&Player, Fileloc);
+ }
+
+ cleanup(TRUE);
+ /*NOTREACHED*/
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: death()
+/
+/ FUNCTION: death routine
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ char *how - pointer to string describing cause of death
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: freerecord(), enterscore(), more(), exit(), fread(),
+/ fseek(), execl(), fopen(), floor(), wmove(), drandom(), wclear(), strcmp(),
+/ fwrite(), fflush(), printw(), strcpy(), fclose(), waddstr(), cleanup(),
+/ fprintf(), wrefresh(), getanswer(), descrtype()
+/
+/ GLOBAL INPUTS: Curmonster, Wizard, Player, *stdscr, Fileloc, *Monstfp
+/
+/ GLOBAL OUTPUTS: Player
+/
+/ DESCRIPTION:
+/ Kill off current player.
+/ Handle rings, and multiple lives.
+/ Print an appropriate message.
+/ Update scoreboard, lastdead, and let other players know about
+/ the demise of their comrade.
+/
+/************************************************************************/
+
+death(how)
+char *how;
+{
+FILE *fp; /* for updating various files */
+int ch; /* input */
+static char *deathmesg[] =
+ /* add more messages here, if desired */
+ {
+ "You have been wounded beyond repair. ",
+ "You have been disemboweled. ",
+ "You've been mashed, mauled, and spit upon. (You're dead.)\n",
+ "You died! ",
+ "You're a complete failure -- you've died!!\n",
+ "You have been dealt a fatal blow! "
+ };
+
+ clear();
+
+ if (strcmp(how, "Stupidity") != 0)
+ {
+ if (Player.p_level > 9999.0)
+ /* old age */
+ addstr("Characters must be retired upon reaching level 10000. Sorry.");
+ else if (Player.p_lives > 0)
+ /* extra lives */
+ {
+ addstr("You should be more cautious. You've been killed.\n");
+ printw("You only have %d more chance(s).\n", --Player.p_lives);
+ more(3);
+ Player.p_energy = Player.p_maxenergy;
+ return;
+ }
+ else if (Player.p_specialtype == SC_VALAR)
+ {
+ addstr("You had your chances, but Valar aren't totally\n");
+ addstr("immortal. You are now left to wither and die . . .\n");
+ more(3);
+ Player.p_brains = Player.p_level / 25.0;
+ Player.p_energy = Player.p_maxenergy /= 5.0;
+ Player.p_quksilver = Player.p_sword = 0.0;
+ Player.p_specialtype = SC_COUNCIL;
+ return;
+ }
+ else if (Player.p_ring.ring_inuse &&
+ (Player.p_ring.ring_type == R_DLREG || Player.p_ring.ring_type == R_NAZREG))
+ /* good ring in use - saved from death */
+ {
+ mvaddstr(4, 0, "Your ring saved you from death!\n");
+ refresh();
+ Player.p_ring.ring_type = R_NONE;
+ Player.p_energy = Player.p_maxenergy / 12.0 + 1.0;
+ if (Player.p_crowns > 0)
+ --Player.p_crowns;
+ return;
+ }
+ else if (Player.p_ring.ring_type == R_BAD
+ || Player.p_ring.ring_type == R_SPOILED)
+ /* bad ring in possession; name idiot after player */
+ {
+ mvaddstr(4, 0,
+ "Your ring has taken control of you and turned you into a monster!\n");
+ fseek(Monstfp, 13L * SZ_MONSTERSTRUCT, 0);
+ fread((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp);
+ strcpy(Curmonster.m_name, Player.p_name);
+ fseek(Monstfp, 13L * SZ_MONSTERSTRUCT, 0);
+ fwrite((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp);
+ fflush(Monstfp);
+ }
+ }
+
+ enterscore(); /* update score board */
+
+ /* put info in last dead file */
+ fp = fopen(_PATH_LASTDEAD, "w");
+ fprintf(fp,"%s (%s, run by %s, level %.0f, killed by %s)",
+ Player.p_name, descrtype(&Player, TRUE),
+ Player.p_login, Player.p_level, how);
+ fclose(fp);
+
+ /* let other players know */
+ fp = fopen(_PATH_MESS, "w");
+ fprintf(fp, "%s was killed by %s.", Player.p_name, how);
+ fclose(fp);
+
+ freerecord(&Player, Fileloc);
+
+ clear();
+ move(10, 0);
+ addstr(deathmesg[(int) ROLL(0.0, (double) sizeof(deathmesg) / sizeof(char *))]);
+ addstr("Care to give it another try ? ");
+ ch = getanswer("NY", FALSE);
+
+ if (ch == 'Y')
+ {
+ cleanup(FALSE);
+ execl(_PATH_GAMEPROG, "phantasia", "-s",
+ (Wizard ? "-S": (char *) NULL), 0);
+ exit(0);
+ /*NOTREACHED*/
+ }
+
+ cleanup(TRUE);
+ /*NOTREACHED*/
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: writerecord()
+/
+/ FUNCTION: update structure in player file
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ struct player *playerp - pointer to structure to write out
+/ long place - location in file to updata
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: fseek(), fwrite(), fflush()
+/
+/ GLOBAL INPUTS: *Playersfp
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Update location in player file with given structure.
+/
+/************************************************************************/
+
+writerecord(playerp, place)
+register struct player *playerp;
+long place;
+{
+ fseek(Playersfp, place, 0);
+ fwrite((char *) playerp, SZ_PLAYERSTRUCT, 1, Playersfp);
+ fflush(Playersfp);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: explevel()
+/
+/ FUNCTION: calculate level based upon experience
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ double experience - experience to calculate experience level from
+/
+/ RETURN VALUE: experience level
+/
+/ MODULES CALLED: pow(), floor()
+/
+/ GLOBAL INPUTS: none
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Experience level is a geometric progression. This has been finely
+/ tuned over the years, and probably should not be changed.
+/
+/************************************************************************/
+
+double
+explevel(experience)
+double experience;
+{
+ if (experience < 1.1e7)
+ return(floor(pow((experience / 1000.0), 0.4875)));
+ else
+ return(floor(pow((experience / 1250.0), 0.4865)));
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: truncstring()
+/
+/ FUNCTION: truncate trailing blanks off a string
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ char *string - pointer to null terminated string
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: strlen()
+/
+/ GLOBAL INPUTS: none
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Put nul characters in place of spaces at the end of the string.
+/
+/************************************************************************/
+
+truncstring(string)
+register char *string;
+{
+register int length; /* length of string */
+
+ length = strlen(string);
+ while (string[--length] == ' ')
+ string[length] = '\0';
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: altercoordinates()
+/
+/ FUNCTION: Alter x, y coordinates and set/check location flags
+/
+/ AUTHOR: E. A. Estes, 12/16/85
+/
+/ ARGUMENTS:
+/ double xnew, ynew - new x, y coordinates
+/ int operation - operation to perform with coordinates
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: fabs(), floor(), drandom(), distance()
+/
+/ GLOBAL INPUTS: Circle, Beyond, Player
+/
+/ GLOBAL OUTPUTS: Marsh, Circle, Beyond, Throne, Player, Changed
+/
+/ DESCRIPTION:
+/ This module is called whenever the player's coordinates are altered.
+/ If the player is beyond the point of no return, he/she is forced
+/ to stay there.
+/
+/************************************************************************/
+
+altercoordinates(xnew, ynew, operation)
+double xnew;
+double ynew;
+int operation;
+{
+ switch (operation)
+ {
+ case A_FORCED: /* move with no checks */
+ break;
+
+ case A_NEAR: /* pick random coordinates near */
+ xnew = Player.p_x + ROLL(1.0, 5.0);
+ ynew = Player.p_y - ROLL(1.0, 5.0);
+ /* fall through for check */
+
+ case A_SPECIFIC: /* just move player */
+ if (Beyond && fabs(xnew) < D_BEYOND && fabs(ynew) < D_BEYOND)
+ /*
+ * cannot move back from point of no return
+ * pick the largest coordinate to remain unchanged
+ */
+ {
+ if (fabs(xnew) > fabs(ynew))
+ xnew = SGN(Player.p_x) * MAX(fabs(Player.p_x), D_BEYOND);
+ else
+ ynew = SGN(Player.p_y) * MAX(fabs(Player.p_y), D_BEYOND);
+ }
+ break;
+
+ case A_FAR: /* pick random coordinates far */
+ xnew = Player.p_x + SGN(Player.p_x) * ROLL(50 * Circle, 250 * Circle);
+ ynew = Player.p_y + SGN(Player.p_y) * ROLL(50 * Circle, 250 * Circle);
+ break;
+ }
+
+ /* now set location flags and adjust coordinates */
+ Circle = CIRCLE(Player.p_x = floor(xnew), Player.p_y = floor(ynew));
+
+ /* set up flags based upon location */
+ Throne = Marsh = Beyond = FALSE;
+
+ if (Player.p_x == 0.0 && Player.p_y == 0.0)
+ Throne = TRUE;
+ else if (Circle < 35 && Circle >= 20)
+ Marsh = TRUE;
+ else if (MAX(fabs(Player.p_x), fabs(Player.p_y)) >= D_BEYOND)
+ Beyond = TRUE;
+
+ Changed = TRUE;
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: readrecord()
+/
+/ FUNCTION: read a player structure from file
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ struct player *playerp - pointer to structure to fill
+/ int loc - location of record to read
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: fread(), fseek()
+/
+/ GLOBAL INPUTS: *Playersfp
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Read structure information from player file.
+/
+/************************************************************************/
+
+readrecord(playerp, loc)
+register struct player *playerp;
+long loc;
+{
+ fseek(Playersfp, loc, 0);
+ fread((char *) playerp, SZ_PLAYERSTRUCT, 1, Playersfp);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: adjuststats()
+/
+/ FUNCTION: adjust player statistics
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: death(), floor(), drandom(), explevel(), movelevel()
+/
+/ GLOBAL INPUTS: Player, *Statptr
+/
+/ GLOBAL OUTPUTS: Circle, Player, Timeout
+/
+/ DESCRIPTION:
+/ Handle adjustment and maximums on various player characteristics.
+/
+/************************************************************************/
+
+adjuststats()
+{
+double dtemp; /* for temporary calculations */
+
+ if (explevel(Player.p_experience) > Player.p_level)
+ /* move one or more levels */
+ {
+ movelevel();
+ if (Player.p_level > 5.0)
+ Timeout = TRUE;
+ }
+
+ if (Player.p_specialtype == SC_VALAR)
+ /* valar */
+ Circle = Player.p_level / 5.0;
+
+ /* calculate effective quickness */
+ dtemp = ((Player.p_gold + Player.p_gems / 2.0) - 1000.0) / Statptr->c_goldtote
+ - Player.p_level;;
+ dtemp = MAX(0.0, dtemp); /* gold slows player down */
+ Player.p_speed = Player.p_quickness + Player.p_quksilver - dtemp;
+
+ /* calculate effective strength */
+ if (Player.p_poison > 0.0)
+ /* poison makes player weaker */
+ {
+ dtemp = 1.0 - Player.p_poison * Statptr->c_weakness / 800.0;
+ dtemp = MAX(0.1, dtemp);
+ }
+ else
+ dtemp = 1.0;
+ Player.p_might = dtemp * Player.p_strength + Player.p_sword;
+
+ /* insure that important things are within limits */
+ Player.p_quksilver = MIN(99.0, Player.p_quksilver);
+ Player.p_mana = MIN(Player.p_mana,
+ Player.p_level * Statptr->c_maxmana + 1000.0);
+ Player.p_brains = MIN(Player.p_brains,
+ Player.p_level * Statptr->c_maxbrains + 200.0);
+ Player.p_charms = MIN(Player.p_charms, Player.p_level + 10.0);
+
+ /*
+ * some implementations have problems with floating point compare
+ * we work around it with this stuff
+ */
+ Player.p_gold = floor(Player.p_gold) + 0.1;
+ Player.p_gems = floor(Player.p_gems) + 0.1;
+ Player.p_mana = floor(Player.p_mana) + 0.1;
+
+ if (Player.p_ring.ring_type != R_NONE)
+ /* do ring things */
+ {
+ /* rest to max */
+ Player.p_energy = Player.p_maxenergy + Player.p_shield;
+
+ if (Player.p_ring.ring_duration <= 0)
+ /* clean up expired rings */
+ switch (Player.p_ring.ring_type)
+ {
+ case R_BAD: /* ring drives player crazy */
+ Player.p_ring.ring_type = R_SPOILED;
+ Player.p_ring.ring_duration = (short) ROLL(10.0, 25.0);
+ break;
+
+ case R_NAZREG: /* ring disappears */
+ Player.p_ring.ring_type = R_NONE;
+ break;
+
+ case R_SPOILED: /* ring kills player */
+ death("A cursed ring");
+ break;
+
+ case R_DLREG: /* this ring doesn't expire */
+ Player.p_ring.ring_duration = 0;
+ break;
+ }
+ }
+
+ if (Player.p_age / N_AGE > Player.p_degenerated)
+ /* age player slightly */
+ {
+ ++Player.p_degenerated;
+ if (Player.p_quickness > 23.0)
+ Player.p_quickness *= 0.99;
+ Player.p_strength *= 0.97;
+ Player.p_brains *= 0.95;
+ Player.p_magiclvl *= 0.97;
+ Player.p_maxenergy *= 0.95;
+ Player.p_quksilver *= 0.95;
+ Player.p_sword *= 0.93;
+ Player.p_shield *= 0.93;
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: initplayer()
+/
+/ FUNCTION: initialize a character
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ struct player *playerp - pointer to structure to init
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: floor(), drandom()
+/
+/ GLOBAL INPUTS: none
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Put a bunch of default values in the given structure.
+/
+/************************************************************************/
+
+initplayer(playerp)
+register struct player *playerp;
+{
+ playerp->p_experience =
+ playerp->p_level =
+ playerp->p_strength =
+ playerp->p_sword =
+ playerp->p_might =
+ playerp->p_energy =
+ playerp->p_maxenergy =
+ playerp->p_shield =
+ playerp->p_quickness =
+ playerp->p_quksilver =
+ playerp->p_speed =
+ playerp->p_magiclvl =
+ playerp->p_mana =
+ playerp->p_brains =
+ playerp->p_poison =
+ playerp->p_gems =
+ playerp->p_sin =
+ playerp->p_1scratch =
+ playerp->p_2scratch = 0.0;
+
+ playerp->p_gold = ROLL(50.0, 75.0) + 0.1; /* give some gold */
+
+ playerp->p_x = ROLL(-125.0, 251.0);
+ playerp->p_y = ROLL(-125.0, 251.0); /* give random x, y */
+
+ /* clear ring */
+ playerp->p_ring.ring_type = R_NONE;
+ playerp->p_ring.ring_duration = 0;
+ playerp->p_ring.ring_inuse = FALSE;
+
+ playerp->p_age = 0L;
+
+ playerp->p_degenerated = 1; /* don't degenerate initially */
+
+ playerp->p_type = C_FIGHTER; /* default */
+ playerp->p_specialtype = SC_NONE;
+ playerp->p_lives =
+ playerp->p_crowns =
+ playerp->p_charms =
+ playerp->p_amulets =
+ playerp->p_holywater =
+ playerp->p_lastused = 0;
+ playerp->p_status = S_NOTUSED;
+ playerp->p_tampered = T_OFF;
+ playerp->p_istat = I_OFF;
+
+ playerp->p_palantir =
+ playerp->p_blessing =
+ playerp->p_virgin =
+ playerp->p_blindness = FALSE;
+
+ playerp->p_name[0] =
+ playerp->p_password[0] =
+ playerp->p_login[0] = '\0';
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: readmessage()
+/
+/ FUNCTION: read message from other players
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: fseek(), fgets(), wmove(), waddstr(), wclrtoeol()
+/
+/ GLOBAL INPUTS: *stdscr, Databuf[], *Messagefp
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ If there is a message from other players, print it.
+/
+/************************************************************************/
+
+readmessage()
+{
+ move(3, 0);
+ clrtoeol();
+ fseek(Messagefp, 0L, 0);
+ if (fgets(Databuf, SZ_DATABUF, Messagefp) != NULL)
+ addstr(Databuf);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: error()
+/
+/ FUNCTION: process evironment error
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ char *whichfile - pointer to name of file which caused error
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: wclear(), cleanup()
+/
+/ GLOBAL INPUTS: errno, *stdscr, printw(), printf(), Windows
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Print message about offending file, and exit.
+/
+/************************************************************************/
+
+error(whichfile)
+ char *whichfile;
+{
+ int (*funcp) __P((const char *, ...));
+
+ if (Windows)
+ {
+ funcp = printw;
+ clear();
+ }
+ else
+ funcp = printf;
+
+ (*funcp)("An unrecoverable error has occurred reading %s. (errno = %d)\n", whichfile, errno);
+ (*funcp)("Please run 'setup' to determine the problem.\n");
+ cleanup(TRUE);
+ /*NOTREACHED*/
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: distance()
+/
+/ FUNCTION: calculate distance between two points
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ double x1, y1 - x, y coordinates of first point
+/ double x2, y2 - x, y coordinates of second point
+/
+/ RETURN VALUE: distance between the two points
+/
+/ MODULES CALLED: sqrt()
+/
+/ GLOBAL INPUTS: none
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ This function is provided because someone's hypot() library function
+/ fails if x1 == x2 && y1 == y2.
+/
+/************************************************************************/
+
+double
+distance(x1, x2, y1, y2)
+double x1, x2, y1, y2;
+{
+double deltax, deltay;
+
+ deltax = x1 - x2;
+ deltay = y1 - y2;
+ return(sqrt(deltax * deltax + deltay * deltay));
+}
+
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: ill_sig()
+/
+/ FUNCTION: exit upon trapping an illegal signal
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ int whichsig - signal which occured to cause jump to here
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: wclear(), printw(), cleanup()
+/
+/ GLOBAL INPUTS: *stdscr
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ When an illegal signal is caught, print a message, and cleanup.
+/
+/************************************************************************/
+
+ill_sig(whichsig)
+int whichsig;
+{
+ clear();
+ if (!(whichsig == SIGINT || whichsig == SIGQUIT))
+ printw("Error: caught signal # %d.\n", whichsig);
+ cleanup(TRUE);
+ /*NOTREACHED*/
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: descrstatus()
+/
+/ FUNCTION: return a string describing the player status
+/
+/ AUTHOR: E. A. Estes, 3/3/86
+/
+/ ARGUMENTS:
+/ struct player playerp - pointer to player structure to describe
+/
+/ RETURN VALUE: string describing player's status
+/
+/ MODULES CALLED: none
+/
+/ GLOBAL INPUTS: none
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Return verbal description of player status.
+/ If player status is S_PLAYING, check for low energy and blindness.
+/
+/************************************************************************/
+
+char *
+descrstatus(playerp)
+register struct player *playerp;
+{
+ switch (playerp->p_status)
+ {
+ case S_PLAYING:
+ if (playerp->p_energy < 0.2 * (playerp->p_maxenergy + playerp->p_shield))
+ return("Low Energy");
+ else if (playerp->p_blindness)
+ return("Blind");
+ else
+ return("In game");
+
+ case S_CLOAKED:
+ return("Cloaked");
+
+ case S_INBATTLE:
+ return("In Battle");
+
+ case S_MONSTER:
+ return("Encounter");
+
+ case S_TRADING:
+ return("Trading");
+
+ case S_OFF:
+ return("Off");
+
+ case S_HUNGUP:
+ return("Hung up");
+
+ default:
+ return("");
+ }
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: drandom()
+/
+/ FUNCTION: return a random floating point number from 0.0 < 1.0
+/
+/ AUTHOR: E. A. Estes, 2/7/86
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: random()
+/
+/ GLOBAL INPUTS: none
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Convert random integer from library routine into a floating
+/ point number, and divide by the largest possible random number.
+/ We mask large integers with 32767 to handle sites that return
+/ 31 bit random integers.
+/
+/************************************************************************/
+
+double
+drandom()
+{
+ if (sizeof(int) != 2)
+ /* use only low bits */
+ return((double) (random() & 0x7fff) / 32768.0);
+ else
+ return((double) random() / 32768.0);
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: collecttaxes()
+/
+/ FUNCTION: collect taxes from current player
+/
+/ AUTHOR: E. A. Estes, 2/7/86
+/
+/ ARGUMENTS:
+/ double gold - amount of gold to tax
+/ double gems - amount of gems to tax
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: fread(), fseek(), fopen(), floor(), fwrite(), fclose()
+/
+/ GLOBAL INPUTS: Player
+/
+/ GLOBAL OUTPUTS: Player
+/
+/ DESCRIPTION:
+/ Pay taxes on gold and gems. If the player does not have enough
+/ gold to pay taxes on the added gems, convert some gems to gold.
+/ Add taxes to tax data base; add remaining gold and gems to
+/ player's cache.
+/
+/************************************************************************/
+
+collecttaxes(gold, gems)
+double gold;
+double gems;
+{
+FILE *fp; /* to update Goldfile */
+double dtemp; /* for temporary calculations */
+double taxes; /* tax liability */
+
+ /* add to cache */
+ Player.p_gold += gold;
+ Player.p_gems += gems;
+
+ /* calculate tax liability */
+ taxes = N_TAXAMOUNT / 100.0 * (N_GEMVALUE * gems + gold);
+
+ if (Player.p_gold < taxes)
+ /* not enough gold to pay taxes, must convert some gems to gold */
+ {
+ dtemp = floor(taxes / N_GEMVALUE + 1.0); /* number of gems to convert */
+
+ if (Player.p_gems >= dtemp)
+ /* player has enough to convert */
+ {
+ Player.p_gems -= dtemp;
+ Player.p_gold += dtemp * N_GEMVALUE;
+ }
+ else
+ /* take everything; this should never happen */
+ {
+ Player.p_gold += Player.p_gems * N_GEMVALUE;
+ Player.p_gems = 0.0;
+ taxes = Player.p_gold;
+ }
+ }
+
+ Player.p_gold -= taxes;
+
+ if ((fp = fopen(_PATH_GOLD, "r+")) != NULL)
+ /* update taxes */
+ {
+ dtemp = 0.0;
+ fread((char *) &dtemp, sizeof(double), 1, fp);
+ dtemp += floor(taxes);
+ fseek(fp, 0L, 0);
+ fwrite((char *) &dtemp, sizeof(double), 1, fp);
+ fclose(fp);
+ }
+}
diff --git a/games/phantasia/monsters.asc b/games/phantasia/monsters.asc
new file mode 100644
index 0000000..3d426a9
--- /dev/null
+++ b/games/phantasia/monsters.asc
@@ -0,0 +1,100 @@
+A Water Leaper 12 14 16 24 59 0 0 62
+A Leech 4 19 29 30 66 0 0 73
+An Urisk 13 30 15 46 127 1 0 3
+Shellycoat 28 21 18 63 226 2 0 0
+A Naiad 21 62 27 58 378 2 0 11
+A Nixie 22 58 28 108 604 3 0 6
+A Glaistig 21 106 25 127 1002 3 0 0
+A Mermaid 18 116 22 108 809 3 0 0
+A Merman 24 115 23 109 808 4 0 0
+A Siren 22 128 31 89 915 4 0 24
+A Lamprey 14 67 33 156 1562 4 15 37
+A Kopoacinth 26 36 26 206 2006 5 0 20
+A Kelpie 61 25 24 223 4025 5 0 0
+An Aspidchelone 114 104 19 898 10041 7 0 2
+An Idiot 13 14 16 28 49 0 0 0
+Some Green Slime 1 5 45 100 57 0 0 26
+A Pixie 11 29 23 26 64 0 0 32
+A Serpent 10 18 25 25 79 0 0 10
+A Cluricaun 12 27 20 30 81 0 14 5
+An Imp 22 30 14 40 92 0 0 1
+A Centipede 3 8 18 15 33 0 0 61
+A Beetle 2 11 21 26 44 0 0 48
+A Fir Darrig 18 22 17 35 107 0 14 1
+Modnar 15 23 20 40 101 7 2 12
+A Gnome 7 45 26 23 111 0 0 21
+A Sprite 9 37 25 31 132 1 0 43
+A Mimic 11 55 29 47 213 1 3 2
+A Kobold 13 10 14 21 121 1 12 68
+A Spider 6 11 28 28 124 1 0 57
+An Uldra 14 37 21 32 93 1 0 6
+A Gnoll 20 25 15 40 166 1 0 61
+A Bogie 23 28 19 57 189 1 0 57
+A Fachan 9 40 15 45 139 1 14 10
+A Moron 3 1 10 10 28 0 0 100
+An Orc 25 13 16 26 141 1 0 92
+A Ghillie Dhu 12 16 13 28 104 2 14 2
+A Bogle 19 15 16 35 157 2 14 15
+A Shrieker 2 62 27 9 213 2 16 0
+A Carrion Crawler 12 20 20 65 142 2 0 42
+A Trow 15 17 23 51 136 2 0 36
+A Warg 20 10 17 45 152 2 0 88
+A Stirge 2 6 35 25 153 2 0 95
+A Crebain 5 11 31 31 82 2 0 81
+A Killmoulis 30 19 8 75 175 3 14 22
+A Hob-goblin 35 20 15 72 246 3 0 18
+A Unicorn 27 57 27 57 627 3 1 0
+A Fenoderee 16 6 21 65 222 3 0 42
+An Ogre 42 14 16 115 409 3 0 19
+A Dodo 62 12 11 76 563 3 0 3
+A Hydra 14 27 33 99 599 3 0 27
+A Hamadryad 23 47 26 62 426 3 0 12
+A Bwca 21 17 19 55 387 3 14 1
+An Owlbear 35 16 18 100 623 4 0 22
+Black Annis 37 52 15 65 786 4 0 2
+A Jello Blob 100 25 7 264 1257 4 0 13
+A Jubjub Bird 45 23 12 114 1191 4 0 0
+A Wichtlein 13 40 25 61 800 4 0 8
+A Cocodrill 39 28 24 206 1438 4 0 38
+A Troll 75 12 20 185 1013 4 24 29
+A Bonnacon 89 26 9 255 1661 4 17 14
+A Gargoyle 22 21 29 200 1753 5 0 7
+A Chaladrius 8 49 37 172 1929 5 0 20
+A Gwyllion 27 73 20 65 1888 5 0 4
+A Cinomulgus 23 2 10 199 263 5 0 18
+A Peridexion 26 32 24 98 1300 5 0 2
+Smeagol 41 33 27 373 2487 5 18 0
+A Wraith 52 102 22 200 3112 5 25 13
+A Snotgurgle 143 19 26 525 4752 6 0 3
+A Phooka 42 63 21 300 4125 5 0 12
+A Vortex 101 30 31 500 6992 6 9 4
+Shelob 147 64 28 628 5003 7 13 0
+A Thaumaturgist 35 200 23 400 7628 6 7 0
+Smaug 251 76 26 1022 9877 7 0 0
+A Cold-drake 301 102 24 1222 10888 7 0 0
+A Red Dragon 342 141 23 1299 11649 8 0 0
+Scatha the Worm 406 208 20 1790 11999 8 0 0
+Tiamat 506 381 29 2000 13001 9 11 0
+A Bandersnatch 105 98 22 450 7981 6 0 3
+A Harpy 103 49 24 263 7582 6 0 2
+A Tigris 182 38 17 809 7777 6 0 3
+A Gryphon 201 45 19 813 8888 7 0 1
+A Coblynau 205 46 18 585 8333 6 0 2
+A Chimaera 173 109 28 947 12006 7 0 0
+A Jack-in-Irons 222 36 12 1000 9119 7 0 0
+Saruman 55 373 17 1500 17101 11 6 0
+A Balrog 500 100 25 705 8103 7 8 0
+Argus 201 87 14 1500 10010 8 0 0
+A Titan 302 1483 12 1625 11011 8 0 0
+Cacus 256 43 19 1750 12012 8 0 0
+Begion 403 154 10 1875 13013 8 0 0
+Grendel 197 262 23 2000 14014 8 0 0
+A Nazgul 250 251 26 1011 9988 12 10 9
+A Succubus 186 1049 27 2007 19984 9 19 0
+Red Cap 143 50 35 1965 23456 9 0 0
+A Nuckelavee 300 75 20 2185 11111 8 0 0
+Cerberus 236 96 29 2600 25862 9 20 0
+A Jabberwock 185 136 25 2265 23256 9 22 0
+Ungoliant 399 2398 37 2784 27849 10 21 0
+Leanan-Sidhe 486 5432 46 3000 30004 9 5 0
+The Dark Lord 9999 9999 31 19999 30005 13 4 0
diff --git a/games/phantasia/oldplayer.h b/games/phantasia/oldplayer.h
new file mode 100644
index 0000000..ce8661c
--- /dev/null
+++ b/games/phantasia/oldplayer.h
@@ -0,0 +1,54 @@
+/*
+ * oldplayer.h - old player structure
+ */
+
+struct oldplayer /* player statistics */
+ {
+ char o_name[21]; /* name */
+ char o_password[9]; /* password */
+ char o_login[10]; /* login */
+ double o_x; /* x coord */
+ double o_y; /* y coord */
+ double o_experience; /* experience */
+ int o_level; /* level */
+ short o_quickness; /* quickness */
+ double o_strength; /* strength */
+ double o_sin; /* sin */
+ double o_mana; /* mana */
+ double o_gold; /* gold */
+ double o_energy; /* energy */
+ double o_maxenergy; /* maximum energy */
+ double o_magiclvl; /* magic level */
+ double o_brains; /* brains */
+ short o_crowns; /* crowns */
+ struct
+ {
+ short ring_type; /* type of ring */
+ short ring_duration; /* duration of ring */
+ } o_ring; /* ring stuff */
+ bool o_palantir; /* palantir */
+ double o_poison; /* poison */
+ short o_holywater; /* holy water */
+ short o_amulets; /* amulets */
+ bool o_blessing; /* blessing */
+ short o_charms; /* charms */
+ double o_gems; /* gems */
+ short o_quksilver; /* quicksilver */
+ double o_sword; /* sword */
+ double o_shield; /* shield */
+ short o_type; /* character type */
+ bool o_virgin; /* virgin */
+ short o_lastused; /* day of year last used */
+ short o_status; /* playing, cloaked, etc. */
+ short o_tampered; /* decree'd, etc. flag */
+ double o_1scratch,
+ o_2scratch; /* variables used for decree, player battle */
+ bool o_blindness; /* blindness */
+ int o_notused; /* not used */
+ long o_age; /* age in seconds */
+ short o_degenerated; /* age/2500 last degenerated */
+ short o_istat; /* used for inter-terminal battle */
+#ifdef PHANTPLUS
+ short o_lives;
+#endif
+ };
diff --git a/games/phantasia/pathnames.h b/games/phantasia/pathnames.h
new file mode 100644
index 0000000..9e4d46b
--- /dev/null
+++ b/games/phantasia/pathnames.h
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)pathnames.h 8.2 (Berkeley) 4/2/94
+ */
+
+#define _PATH_GAMEPROG "/usr/games/phantasia"
+#define _PATH_GOLD "/var/games/phantasia/gold"
+#define _PATH_LASTDEAD "/var/games/phantasia/lastdead"
+#define _PATH_MESS "/var/games/phantasia/mess"
+#define _PATH_MONST "/var/games/phantasia/monsters"
+#define _PATH_MOTD "/var/games/phantasia/motd"
+#define _PATH_PEOPLE "/var/games/phantasia/characs"
+#define _PATH_SCORE "/var/games/phantasia/scoreboard"
+#define _PATH_VOID "/var/games/phantasia/void"
diff --git a/games/phantasia/phantasia.6 b/games/phantasia/phantasia.6
new file mode 100644
index 0000000..a7cb7f1
--- /dev/null
+++ b/games/phantasia/phantasia.6
@@ -0,0 +1,1220 @@
+.de sh
+.br
+.ne 5
+.PP
+\fB\\$1\fR
+.PP
+..
+.TH PHANTASIA 6 "April 19, 1994"
+.UC 4
+.SH NAME
+phantasia \- an interterminal fantasy game
+.SH SYNOPSIS
+phantasia [ \-HSabmpsx ]
+.SH DESCRIPTION
+.I Phantasia
+is a role playing game
+which allows players to roll up characters of various types to fight
+monsters and other players.
+Progression of characters is based upon gaining experience from fighting
+monsters (and other players).
+.PP
+Most of the game is menu driven and self-explanatory (more or less).
+The screen is cursor updated, so be sure to set up the
+.B TERM
+variable in your environment.
+.PP
+The options provide for a variety of functions to support the game.
+They are:
+.PP
+.TP .5i
+.B \-s
+Invokes
+.I phantasia
+without header information.
+.TP .5i
+.B \-m
+Get a monster listing.
+.TP .5i
+.B \-a
+Get a listing of all character names on file.
+.TP .5i
+.B \-x
+Examine/change a particular character on file.
+.TP .5i
+.B \-H
+Print header only.
+.TP .5i
+.B \-p
+Purge old characters.
+.TP .5i
+.B \-b
+Show scoreboard of top characters per login.
+.TP .5i
+.B \-S
+Turn on wizard options, if allowed, if running as ``root''.
+.PP
+The characters are saved on a common file, in order to make the game
+interactive between players. The characters are given a password
+in order to retrieve them later. Only characters above
+.B level
+zero are saved. Characters unused for awhile will be purged.
+Characters are only placed on the scoreboard when they die.
+.SH AUTHOR
+Edward Estes, AT&T Information Systems, Skokie, IL
+.SH PARTICULARS
+.sh "Normal Play"
+A number of the player's more important statistics are almost always
+displayed on the screen, with maximums (where applicable) in
+parentheses.
+.PP
+The character is placed randomly near the center of a cartesian
+system.
+Most commands are selected with a single letter or digit.
+For example, one may move by hitting 'W', 'S', 'N', or 'E',
+(lower case may also be used, at no time is the game case dependent).
+One may also use 'H', 'J', 'K', 'L',
+for movement, similar to
+.IR vi (1).
+To move to a specific (x, y) coordinate, use the
+.B move
+('1') command. The distance a character can move is calculated by
+1 plus 1.5 per
+.B level.
+Moving in a compass direction will move the player the maximum
+allowed distance in that direction.
+.PP
+A player may see who else is playing by using the
+.B players
+('2') option. One may see the coordinates of those who are the same
+distance or closer to the origin as he/she.
+.B Kings,
+and
+.B council of the wise
+can see and can be seen by everyone. A
+.B palantir
+removes these restrictions.
+.PP
+One can talk to other players with the
+.B talk
+('3') option. In general, this is a line or so of text. To remove a current
+message, just type <return> when prompted for a message.
+.PP
+The
+.B stats
+('4') option shows additional characteristics of a player.
+.PP
+One may leave the game either with the
+.B quit
+('5') option.
+.PP
+One may rest by default. Resting lets one regain maximum
+.B energy level,
+and also lets one find
+.B mana
+(more is found for larger levels and further distances from the origin).
+.PP
+One may call a monster by hitting '9' or 'C'.
+.PP
+Use 'X' to examine other players.
+.PP
+One may quit or execute a sub-shell by hitting interrupt.
+Quitting during battle results in death for obvious reasons.
+.PP
+Several other options become available as the player progresses in
+.B level
+and
+.B magic,
+or to other stations in the game (
+.B valar, council of the wise, king
+).
+These are described elsewhere.
+In general, a control-L will force the redrawing of the screen.
+.PP
+Other things which may happen are more or less self-explanatory.
+.sh "Fighting Monsters"
+A player has several options while fighting monsters. They are as follows:
+.TP 1.5i
+.B melee
+Inflicts damage on the monster, based upon
+.B strength.
+Also decreases the monster's
+.B strength
+some.
+.TP 1.5i
+.B skirmish
+Inflicts a little less damage than
+.B melee,
+but decreases the monster's
+.B quickness
+instead.
+.TP 1.5i
+.B evade
+Attempt to run away. Success is based upon both the player's and
+the monster's
+.B brains
+and
+.B quickness.
+.TP 1.5i
+.B spell
+Several options for throwing spells (described elsewhere).
+.TP 1.5i
+.B nick
+Hits the monster one plus the player's
+.B sword,
+and gives the player 10% of the monster's
+.B experience.
+Decreases the monster's
+.B experience
+an amount proportional to the amount granted.
+This also increases the monster's quickness.
+Paralyzed monsters wake up very fast when nicked.
+.TP 1.5i
+.B luckout
+This is essentially a battle of wits with the monster. Success is based
+upon the player's and the monster's
+.B brains.
+The player gets credit for slaying the monster if he/she succeeds.
+Otherwise, nothing happens, and the chance to
+.B luckout
+is lost.
+.sh "Character Statistics"
+.TP 1.5i
+.B strength
+determines how much damage a character can inflict.
+.TP 1.5i
+.B quickness
+determines how many chances a character gets to make decisions while
+fighting.
+.TP 1.5i
+.B energy level
+specifies how much damage a character may endure before dying.
+.TP 1.5i
+.B magic level
+determines which spells a character may throw, and how effective those
+spells will be.
+.TP 1.5i
+.B brains
+basically, the character's intelligence; used for various fighting options
+and spells.
+.TP 1.5i
+.B mana
+used as a power source for throwing spells.
+.TP 1.5i
+.B experience
+gained by fighting monsters and other characters.
+.TP 1.5i
+.B level
+indicative of how much experience a character has accumulated; progresses
+geometrically as
+.B experience
+increases.
+.TP 1.5i
+.B poison
+sickness which degrades a character's performance (affects
+.B energy level
+and
+.B strength
+).
+.TP 1.5i
+.B sin
+accumulated as a character does certain nasty things; used only rarely
+in normal play of the game.
+.TP 1.5i
+.B age
+of player; roughly equivalent to number of turns.
+As
+.B age
+increases, many personal statistics degenerate.
+.sh "Character Types"
+Character statistics are rolled randomly from the above list, according
+to character type. The types are as follows:
+.TP 1.5i
+.B magic user
+strong in
+.B magic level
+and
+.B brains
+, weak in other areas. Must rely on wits and magic to survive.
+.TP 1.5i
+.B fighter
+good in
+.B strength
+and
+.B energy level
+, fairly good in other areas. This adds up to a well-equipped fighter.
+.TP 1.5i
+.B elf
+very high
+.B quickness
+and above average
+.B magic level
+are
+.B elves
+selling points.
+.TP 1.5i
+.B dwarf
+very high
+.B strength
+and
+.B energy level
+, but with a tendency to be rather slow and not too bright.
+.TP 1.5i
+.B halfling
+rather quick and smart, with high
+.B energy level
+, but poor in
+.B magic
+and
+.B strength.
+Born with some
+.B experience.
+.TP 1.5i
+.B experimento
+very mediocre in all areas. However, the
+.B experimento
+may be placed almost anywhere within the playing grid.
+.PP
+The possible ranges for starting statistics are summarized in
+the following table.
+.PP
+.TS
+l c c c c c c
+l c c c c c c.
+Type Strength Quick Mana Energy Brains Magic
+_
+Mag. User 10-15 30-35 50-100 30-45 60-85 5-9
+Fighter 40-55 30-35 30-50 45-70 25-45 3-6
+Elf 35-45 32-38 45-90 30-50 40-65 4-7
+Dwarf 50-70 25-30 25-45 60-100 20-40 2-5
+Halfling 20-25 34 25-45 55-90 40-75 1-4
+Experimento 25 27 100 35 25 2
+.TE
+.PP
+Not only are the starting characteristics different for the different
+character types, the characteristics progress at different rates for the
+different types as the character goes up in
+.B level. Experimentoes'
+characteristics progress randomly as one of the other types.
+The progression as characters increase in
+.B level
+is summarized in the following table.
+.PP
+.TS
+l c c c c c
+l n n n n n.
+Type Strength Mana Energy Brains Magic
+_
+Mag. User 2.0 75 20 6 2.75
+Fighter 3.0 40 30 3.0 1.5
+Elf 2.5 65 25 4.0 2.0
+Dwarf 5 30 35 2.5 1
+Halfling 2.0 30 30 4.5 1
+.TE
+.PP
+The character type also determines how much gold a player may
+carry, how long until
+.B rings
+can overcome the player, and how much
+.B poison
+the player can withstand.
+.sh "Spells"
+During the course of the game, the player may exercise his/her
+magic powers. These cases are described below.
+.TP 1.5i
+.B cloak
+.I magic level necessary:
+20 (plus level 7)
+.br
+.I mana used:
+35 plus 3 per rest period
+.br
+Used during normal play. Prevents monsters from finding the character,
+as well as hiding the player from other players. His/her coordinates
+show up as '?' in the
+.B players
+option. Players cannot collect
+.B mana,
+find trading posts, or discover the
+.B grail
+while cloaked. Calling a monster uncloaks, as well as choosing
+this option while cloaked.
+.br
+.TP 1.5i
+.B teleport
+.I magic level necessary:
+40 (plus level 12)
+.br
+.I mana used:
+30 per 75 moved
+.br
+Used during normal play. Allows the player too move with much more freedom
+than with the
+.B move
+option, at the price of expending mana. The maximum distance possible
+to move is based upon
+.B level
+and
+.B magic level.
+.TP 1.5i
+.B power blast
+.I magic level necessary:
+none
+.br
+.I mana used:
+5 times
+.B level
+.br
+Used during inter-terminal battle. Damage is based upon
+.B magic level
+and
+.B strength.
+Hits much harder than a normal hit.
+.TP 1.5i
+.B all or nothing
+.I magic level necessary:
+none
+.br
+.I mana used:
+1
+.br
+Used while combating monsters.
+Has a 25% chance of working. If it works it hits the monster just enough
+to kill it. If it fails, it doesn't hit the monster, and doubles the
+monster's
+.B quickness
+and
+.B strength.
+Paralyzed monsters wake up much quicker as a result of this spell.
+.TP 1.5i
+.B magic bolt
+.I magic level necessary:
+5
+.br
+.I mana used:
+variable
+.br
+Used while combating monsters. Hits the monster based upon the amount
+of
+.B mana
+expended and
+.B magic level.
+Guaranteed to hit at least 10 per
+.B mana.
+.TP 1.5i
+.B force field
+.I magic level necessary:
+15
+.br
+.I mana used:
+30
+.br
+Used during monster combat. Throws up a shield to protect from damage.
+The shield is added to actual energy level, and is a fixed number, based
+upon maximum energy. Normally, damage occurs first to the shield, and
+then to the players actual
+.B energy level.
+.TP 1.5i
+.B transform
+.I magic level necessary:
+25
+.br
+.I mana used:
+50
+.br
+Used during monster combat. Transforms the monster randomly into one
+of the 100 monsters from the monster file.
+.TP 1.5i
+.B increase might
+.I magic level necessary:
+35
+.br
+.I mana used:
+75
+.br
+Used during combat with monsters. Increases strength up to a maximum.
+.TP 1.5i
+.B invisibility
+.I magic level necessary:
+45
+.br
+.I mana used:
+90
+.br
+Used while fighting monsters. Makes it harder for the monster to hit,
+by temporarily increasing the player's
+.B quickness.
+This spell may be thrown several times, but a maximum level will be reached.
+.TP 1.5i
+.B transport
+.I magic level necessary:
+60
+.br
+.I mana used:
+125
+.br
+Used during monster combat. Transports the monster away from the
+player. Success is base upon player's
+.B magic
+and
+.B brains,
+and the monster's
+.B experience.
+If it fails the player is transported instead. 60% of the time, the monster
+will drop any treasure it was carrying.
+.TP 1.5i
+.B paralyze
+.I magic level necessary:
+75
+.br
+.I mana used:
+150
+.br
+Used during monster combat. "Freezes" the monster by putting its
+.B quickness
+slightly negative. The monster will slowly wake up. Success is based
+upon player's
+.B magic
+and the monster's
+.B experience.
+If it fails, nothing happens.
+.TP 1.5i
+.B specify
+.I magic level necessary:
+none
+.br
+.I mana used:
+1000
+.br
+Used during monster combat only by
+.B valar
+or
+.B council of the wise.
+Allows the player to pick which monster to fight.
+.sh "Monsters"
+Monsters get bigger as one moves farther from the origin (0,0). Rings of
+distance 125 from the origin determine the size. A monster's
+.B experience, energy level,
+and
+.B brains
+are multiplied by the size.
+.B Strength
+is increase 50% per size over one, and
+.B quickness
+remains the same, regardless of size.
+.PP
+Also, nastier monsters are found as one progress farther out
+from the origin. Monsters also may flock. The percent chance of that
+happening is designated as
+.B flock%
+in the monster listing. Monsters outside the first ring
+may carry treasure, as determined by their treasure type.
+Flocking monsters, and bigger monsters increase the chances of treasure.
+.PP
+Certain monsters have special abilities; they are as follows:
+.TP 1.5i
+.B Unicorn
+can only be subdued if the player is in possession of a
+.B virgin.
+.TP 1.5i
+.B Modnar
+has random characteristics, including treasure type.
+.TP 1.5i
+.B Mimic
+will pick another name from the list of monsters in order to
+confuse.
+.TP 1.5i
+.B Dark Lord
+very nasty person. Does not like to be hit (especially nicked),
+and many spells do not work well (or at all) against him.
+One can always
+.B evade
+from the
+.B Dark Lord.
+.TP 1.5i
+.B Leanan-Sidhe
+also a very nasty person. She will permanently sap
+.B strength
+from someone.
+.TP 1.5i
+.B Saruman
+wanders around with
+.B Wormtongue
+, who can steal a
+.B palantir.
+Also,
+.B Saruman
+may turn a player's gems into gold pieces,
+or scramble her/his stats.
+.TP 1.5i
+.B Thaumaturgist
+can transport a player.
+.TP 1.5i
+.B Balrog
+inflicts damage by taking away
+.B experience
+, not
+.B energy.
+.TP 1.5i
+.B Vortex
+may take some
+.B mana.
+.TP 1.5i
+.B Nazgul
+may try to steal a
+.B ring
+or neutralize part of one's
+.B brains.
+.TP 1.5i
+.B Tiamat
+may take half a player's
+.B gold
+and
+.B gems
+and escape.
+.TP 1.5i
+.B Kobold
+may get nasty and steal one gold piece and run away.
+.TP 1.5i
+.B Shelob
+may bite, inflicting the equivalent of one
+.B poison.
+.TP 1.5i
+.B Assorted Faeries
+These are killed if attacking someone carrying
+.B holy water.
+These are
+.B Cluricaun, Fir Darrig, Fachan,
+.B Ghille Dhu, Bogle, Killmoulis,
+and
+.B Bwca.
+.TP 1.5i
+.B Lamprey
+may bite, inflicting 1/2 of a
+.B poison.
+.TP 1.5i
+.B Shrieker
+will call one of its (much bigger) buddies if picked upon.
+.TP 1.5i
+.B Bonnacon
+will become bored with battle, fart, and run off.
+.TP 1.5i
+.B Smeagol
+will try to steal a
+.B ring
+from a player, if given the chance.
+.TP 1.5i
+.B Succubus
+may inflict damage through a
+.B force field.
+This subtracts from
+.B energy level
+instead of any shield the player may have thrown up.
+This is a very easy way to die.
+.TP 1.5i
+.B Cerberus
+loves metal and will steal all the metal treasures from
+a player if able.
+.TP 1.5i
+.B Ungoliant
+can bite and poison. This inflicts five
+.B poisons
+, and also takes one from the player's
+.B quickness.
+.TP 1.5i
+.B Jabberwock
+may tire of battle, and leave after calling one of his friends
+(
+.B Jubjub Bird
+or
+.B Bandersnatch
+).
+.TP 1.5i
+.B Morgoth
+actually
+.B Modnar
+, but reserved for
+.B council of the wise, valar,
+and
+.B ex-valar.
+Fights with
+.B Morgoth
+end when either he or the player dies. His characteristics
+are calculated based upon the player's. The player is given
+the chance to ally with him. No magic, except
+.B force field
+works when battling
+.B Morgoth.
+.TP 1.5i
+.B Troll
+may regenerate its
+.B energy
+and
+.B strength
+while in battle.
+.TP 1.5i
+.B Wraith
+may make a player blind.
+.sh "Treasures"
+The various treasure types are as follows:
+.TP 1.5i
+.B Type zero
+.I none
+.TP 1.5i
+.B Type one
+.I power booster
+\- adds mana.
+.br
+.I druid
+\- adds experience.
+.br
+.I holy orb
+\- subtracts 0.25 sin.
+.TP 1.5i
+.B Type two
+.I amulet
+\- protects from cursed treasure.
+.br
+.I holy water
+\- kills
+.B assorted faeries.
+.br
+.I hermit
+\- reduces sin by 25% and adds some mana.
+.TP 1.5i
+.B Type three
+.I shield
+\- adds to maximum
+.B energy level
+.br
+.I virgin
+\- used to subdue a
+.B unicorn
+, or to give much
+.B experience
+(and some
+.B sin
+).
+.br
+.I athelas
+\- subtracts one
+.B poison.
+.TP 1.5i
+.B Type four (scrolls)
+.I shield
+\- throws a bigger than normal
+.B force field.
+.br
+.I invisible
+\- temporarily puts the finder's
+.B quickness
+to one million.
+.br
+.I ten fold strength
+\- multiplies finder's strength by ten.
+.br
+.I pick monster
+\- allows finder to pick next monster to battle.
+.br
+.I general knowledge
+\- adds to finder's
+.B brains
+and
+.B magic level.
+.PP
+All the scrolls except
+.B general knowledge
+automatically call a monster. These preserve any
+spells that were already in effect, but are only in
+effect while in battle.
+.TP 1.5i
+.B Type five
+.I dagger
+\- adds to
+.B strength.
+.br
+.I armour
+\- same as a
+.B shield,
+but bigger.
+.br
+.I tablet
+\- adds brains.
+.TP 1.5i
+.B Type six
+.I priest
+\- rests to maximum; adds
+.B mana, brains;
+and halves
+.B sin.
+.br
+.I Robin Hood
+\- increases
+.B shield
+and adds permanently to
+.B strength.
+.br
+.I axe
+\- like
+.B dagger,
+but bigger.
+.TP 1.5i
+.B Type seven
+.I charm
+\- protects from cursed treasure (used before
+.B amulet
+); used in conjunction with
+.B blessing
+to battle
+.B Dark Lord.
+.br
+.I Merlyn
+\- adds
+.B brains, magic,
+and
+.B mana.
+.br
+.I war hammer
+\- like an
+.B axe,
+but bigger.
+.TP 1.5i
+.B Type eight
+.I healing potion
+\- sets
+.B poison
+to -2, or subtracts two from
+.B poison,
+whichever is better.
+.br
+.I transporter
+\- allows finder to move anywhere.
+.br
+.I sword
+\- like a
+.B war hammer
+, but bigger.
+.TP 1.5i
+.B Type nine
+.I golden crown
+\- allows the player to become
+.B king,
+by going to (0,0).
+.br
+.I blessing
+\- cuts
+.B sin
+to 1/3, adds
+.B mana,
+rests to max., kills
+.B Dark Lord
+with a
+.B charm,
+and gives bearer first hit on all monsters.
+.br
+.I quicksilver
+\- adds to
+.B quickness.
+.TP 1.5i
+.B Type ten
+.I elven boots
+\- adds permanently to
+.B quickness.
+.TP 1.5i
+.B Type eleven
+.I palantir
+\- allows one to see all the other players; used by
+.B council of the wise
+to seek the
+.B grail.
+.TP 1.5i
+.B Type twelve/thirteen
+.I ring
+\- allows one to hit much harder in battle, etc.
+.PP
+Any treasure type 10-13 monsters may instead carry a type nine treasure.
+.PP
+A monster may also be carrying
+.B gold
+or
+.B gems.
+These are used at
+.B trading posts
+to buy things. A
+.B gem
+is worth 1000 gold pieces. Too much
+.B gold
+will slow a player down. One may carry 1000 plus 200 per
+.B level
+of
+.B gold.
+A
+.B gem
+weighs one half a gold piece.
+Monsters of treasure type 7 or higher may carry
+.B gems.
+.PP
+The chance of a cursed treasure is based upon treasure type.
+The more valuable treasures have a greater chance of being cursed.
+A cursed treasure knocks
+.B energy level
+very low, and adds 0.25
+.B poison.
+.sh "Rings"
+.B Rings
+are only carried by
+.B nazguls
+and
+.B Dark Lord.
+They come in four different flavors.
+All
+.B rings
+rest the player to maximum and cause him/her to hit much harder
+in battle with monsters (assuming one has chosen to use the
+.B ring
+for battle.)
+.PP
+Two types of
+.B rings
+are cursed and come either from
+.B nazguls
+or
+.B Dark Lord.
+After a few times of using these types, the player falls
+under the control of the
+.B ring,
+and strange, random things will occur.
+Eventually, the player dies, and gives his/her name to a monster
+on the file.
+Dying before the
+.B ring
+is used up also renames the monster.
+.PP
+The two remaining types of
+.B rings
+are much more benign.
+The one from a
+.B nazgul
+is good for a limited number of battle rounds, and will save
+the player from death if it was being used when he/she died.
+The one from
+.B Dark Lord
+is the same, except that it never is used up.
+.B rings
+disappear after saving someone from death.
+In general, cursed
+.B rings
+occur much more often than normal ones.
+It is usually not a good idea to pick one up.
+The only way to get rid of a
+.B ring
+is to have a monster steal it.
+.sh "King"
+A player may become
+.B king by finding a
+.I crown
+and going to (0,0). Players must have a
+.B level
+in the range of 10 to 1000 to be able to find a
+.I crown.
+When a player with one or more
+.I crowns
+reaches
+.B level
+1000, the
+.I crowns
+are converted to
+.I gold.
+.PP
+Once a player is king, he/she may do certain things while in
+the Lord's Chamber (0,0). These are exercised with the
+.B decree
+('0') option.
+.TP 1.5i
+.I transport
+This is done to another player. It randomly moves the affected
+player about. A
+.B charm
+protects from transports.
+.TP 1.5i
+.I curse
+This is done to another player. It is analogous to cursed treasure,
+but worse. It inflicts two
+.B poison,
+knocks
+.B energy level
+very low, and degrades the maximum energy. It also
+removes a
+.B cloak.
+A
+.B blessing
+protects from king's curses.
+.TP 1.5i
+.I energy void
+The king may put a number of these scattered about
+his/her kingdom as he/she pleases.
+If a player hits one, he/she loses
+.B mana, energy,
+and
+.B gold.
+The energy void disappears after being hit.
+.TP 1.5i
+.I bestow
+This is also done to another player. The king may
+wish to reward one or more loyal subjects by sharing his/her
+riches (
+.B gold
+). Or it is a convenient way to dispose of some unwanted
+deadweight.
+.TP 1.5i
+.I collect taxes
+Everyone pays 7% tax on all
+.B gold
+and
+.B gems
+acquired, regardless of the existence of a
+.B king.
+The king collects the accrued taxes with this option.
+.PP
+The
+.B king
+may also
+.B teleport
+anywhere for free by using the origin as a starting place.
+.sh "Council of the Wise, Valar"
+A player automatically becomes a member of the
+.B council of the wise
+upon reaching level 3000. Members of the council cannot have
+.B rings.
+Members of the council have a few extra options which they can exercise.
+These are exercised
+.B intervene
+('8') option.
+All
+.B intervene
+options cost 1000 mana.
+One
+.B intervene
+option is to
+.I heal
+another player. This is just a quick way for that player to be rested
+to maximum and lose a little
+.B poison.
+The main purpose in life for members of the council is to seek the
+.B Holy Grail.
+This is done with a
+.B palantir
+under the
+.I seek grail
+option. The distance cited by the seek is accurate within 10%, in order
+not to make it too easy to find the grail.
+A player must have infinitesimally small
+.B sin,
+or else it's all over upon finding the grail.
+In order to help members of the council on their quest, they
+may
+.I teleport
+with greater ease.
+.PP
+Upon finding the grail, the player advances to position of
+.B valar.
+He/she may then exercise more and niftier options under
+.I intervention.
+These include all of the council members' options plus the
+ability to move other players about, bless them, and throw monsters at
+them.
+A
+.BR valar 's
+blessing has the same effect as the treasure
+.I blessing,
+except that the affected player does not get his/her
+.I blessing
+flag set.
+All
+.I intervention
+options which affect other players age the player
+who uses them.
+.B Valars
+are essentially immortal, but are actually given five lives.
+If these are used up, the player is left to die, and becomes an
+.B ex-valar.
+A
+.B valar
+cannot
+.I move, teleport,
+or call monsters.
+(An exception to this is if the
+.I valar
+finds a
+.I transporter.
+This is to allow him/her to dispose of excess
+.I gold.
+Any monsters which a
+.B valar
+encounters are based upon his/her size.
+Only one valar may exist at a time.
+The current valar is replaced when another player finds the grail.
+The valar is then bumped back to the council of the wise.
+.sh "Wizard"
+The
+.I wizard
+is usually the owner of the game, and the one who maintains
+the associated files.
+The
+.I wizard
+is granted special powers within the game, if it is invoked
+with the '\-S' option.
+Otherwise, the
+.I wizard
+plays no different from other players.
+The
+.I wizard
+abilities are outlined below.
+.TP
+.I change players
+When examining a player, (game invoked with '-x', or use 'X' from within game),
+the
+.I wizard
+may also change the player.
+.TP
+.I intervention
+The
+.I wizard
+may do all the
+.I intervention
+options. One extra option,
+.I vaporize,
+is added to kill any offensive players.
+.TP
+.I super character type
+An extra character type is added. This character starts with the
+maximum possible in all statistics, selected from the other character types.
+A
+.B super
+character's statistics also progress at the maximum possible rate, selected
+from the other character types.
+.sh "Special Places"
+Certain regions of the playing grid have different names.
+In general, this is only to give the player some idea of
+his/her present location. Some special places do exist.
+.TP 1.5i
+.I Trading Posts
+These are located at |x| == |y| == n*n*100 for n = 1, 2...1000.
+Trading posts farther out have more things for sale.
+Be careful about cheating the merchants there, as they have short
+tempers.
+Merchants are dishonest about 5% of the time.
+.TP 1.5i
+.I Lord's Chamber
+This is located at (0,0). Only players with
+.B crowns
+may enter.
+.TP 1.5i
+.I Point of No Return
+This is located beyond 1.2e+6 in any direction.
+The only way to return from here is a
+.B transporter
+or to have a
+.B valar
+relocate the player.
+.TP 1.5i
+.I Dead Marshes
+This is a band located fairly distant from the origin. The first
+fourteen monsters (water monsters) can normally only be found here.
+.TP 1.5i
+.I Valhala
+This place is where the
+.B valar
+resides. It is associated with no particular coordinate on the
+playing grid.
+.TP 1.5i
+.sh "Miscellaneous"
+Once a player reaches
+.B level
+5, the game will start to time out waiting for input.
+This is to try to keep the game a bit faster paced.
+.PP
+A
+.I guru
+will never be disgusted with your
+.B sins
+if they are less than one.
+.PP
+A
+.I medic
+wants half of a player's
+.B gold
+to be happy. Offering more than one has, or a negative amount
+will anger the
+.I medic,
+who will make the player worse (add one
+.B poison
+).
+.PP
+The
+.B Holy Grail
+does little for those who are not ready to behold it.
+Whenever anyone finds it, it moves.
+It is always located within 1e+6 in any compass direction of the origin.
+.PP
+There is a maximum amount of
+.B mana
+and
+.B charms
+a player may posses, based upon
+.B level.
+.I Quicksilver
+is always limited to to a maximum of 99.
+.PP
+.I Books
+bought at a
+.B trading post
+increase
+.B brains,
+based upon the number bought.
+It is unwise, however to buy more than 1/10 of one's
+.B level
+in books at a time.
+.PP
+Players over level 10000 are automatically retired.
+.PP
+A
+.I blindness
+goes away in random time.
+.PP
+Players with
+.I crowns
+are identified with a '*' before their character type.
+.sh "Inter-terminal Battle"
+When two player's coordinates correspond, they may engage in battle.
+In general, the player with the highest
+.B quickness
+gets the first hit.
+If the two players are severely mis-matched, the stronger player
+is drastically handicapped for the battle.
+In order to protect from being stuck in an infinite loop,
+the player waiting for response may time out. Options for battle are:
+.TP 1.5i
+.I fight
+Inflicts damage upon other person.
+.TP 1.5i
+.I run away
+Escape from battle. Has a 75% chance of working.
+.TP 1.5i
+.I power blast
+Battle spell.
+.TP 1.5i
+.I luckout
+One-time chance to try to win against the foe. Has a 10% chance of working.
+.PP
+Sometimes waits for the other player may be excessive, because
+he/she may be battling a monster. Upon slaying a player in battle
+the winner gets the other's
+.B experience
+and treasures.
+.B Rings
+do not work for inter-terminal battle.
+.SH BUGS
+All screen formats assume at least 24 lines by at least 80 columns.
+No provisions are made for when any of the data items get too big
+for the allotted space on the screen.
diff --git a/games/phantasia/phantdefs.h b/games/phantasia/phantdefs.h
new file mode 100644
index 0000000..9e597e5
--- /dev/null
+++ b/games/phantasia/phantdefs.h
@@ -0,0 +1,139 @@
+/*
+ * phantdefs.h - important constants for Phantasia
+ */
+
+/* ring constants */
+#define R_NONE 0 /* no ring */
+#define R_NAZREG 1 /* regular Nazgul ring (expires) */
+#define R_DLREG 2 /* regular Dark Lord ring (does not expire) */
+#define R_BAD 3 /* bad ring */
+#define R_SPOILED 4 /* ring which has gone bad */
+
+/* status constants */
+#define S_NOTUSED 0 /* record not in use */
+#define S_OFF 1 /* not playing */
+#define S_PLAYING 2 /* playing - nothing else */
+#define S_CLOAKED 3 /* playing - cloaked */
+#define S_INBATTLE 4 /* playing - in battle */
+#define S_MONSTER 5 /* playing - fighting monster */
+#define S_TRADING 6 /* playing - at a trading post */
+#define S_HUNGUP 7 /* error occured with character */
+
+/* tampered constants */
+#define T_OFF 0 /* nothing */
+#define T_NRGVOID 1 /* hit an energy void */
+#define T_GRAIL 2 /* landed on the holy grail */
+#define T_TRANSPORT 3 /* transported by king */
+#define T_BESTOW 4 /* gold bestowed by king */
+#define T_CURSED 5 /* cursed by king */
+#define T_MONSTER 6 /* monster lobbed by valar */
+#define T_BLESSED 7 /* blessed by valar */
+#define T_RELOCATE 8 /* moved by valar */
+#define T_HEAL 9 /* healed by valar */
+#define T_VAPORIZED 10 /* vaporized by wizard */
+#define T_EXVALAR 11 /* no longer valar */
+
+/* inter-terminal battle status constants */
+#define I_OFF 0 /* nothing */
+#define I_RAN 1 /* ran away */
+#define I_STUCK 2 /* tried to run unsuccessfully */
+#define I_BLEWIT 3 /* tried to luckout unsuccessfully */
+#define I_KILLED 4 /* killed foe */
+
+/* constants for altering coordinates */
+#define A_SPECIFIC 0 /* coordinates specified */
+#define A_FORCED 1 /* coordinates specified, ignore Beyond */
+#define A_NEAR 2 /* coordinates not specified, move near */
+#define A_FAR 3 /* coordinates not specified, move far */
+
+/* constants for character types */
+#define C_MAGIC 0 /* magic user */
+#define C_FIGHTER 1 /* fighter */
+#define C_ELF 2 /* elf */
+#define C_DWARF 3 /* dwarf */
+#define C_HALFLING 4 /* halfling */
+#define C_EXPER 5 /* experimento */
+#define C_SUPER 6 /* super being */
+
+/* constants for special character types */
+#define SC_NONE 0 /* not a special character */
+#define SC_KING 1 /* king */
+#define SC_COUNCIL 2 /* council of the wise */
+#define SC_VALAR 3 /* valar */
+#define SC_EXVALAR 4 /* ex-valar */
+
+/* special monster constants */
+#define SM_NONE 0 /* nothing special */
+#define SM_UNICORN 1 /* unicorn */
+#define SM_MODNAR 2 /* Modnar */
+#define SM_MIMIC 3 /* mimic */
+#define SM_DARKLORD 4 /* Dark Lord */
+#define SM_LEANAN 5 /* Leanan-Sidhe */
+#define SM_SARUMAN 6 /* Saruman */
+#define SM_THAUMATURG 7 /* thaumaturgist */
+#define SM_BALROG 8 /* balrog */
+#define SM_VORTEX 9 /* vortex */
+#define SM_NAZGUL 10 /* nazgul */
+#define SM_TIAMAT 11 /* Tiamat */
+#define SM_KOBOLD 12 /* kobold */
+#define SM_SHELOB 13 /* Shelob */
+#define SM_FAERIES 14 /* assorted faeries */
+#define SM_LAMPREY 15 /* lamprey */
+#define SM_SHRIEKER 16 /* shrieker */
+#define SM_BONNACON 17 /* bonnacon */
+#define SM_SMEAGOL 18 /* Smeagol */
+#define SM_SUCCUBUS 19 /* succubus */
+#define SM_CERBERUS 20 /* Cerberus */
+#define SM_UNGOLIANT 21 /* Ungoliant */
+#define SM_JABBERWOCK 22 /* jabberwock */
+#define SM_MORGOTH 23 /* Morgoth */
+#define SM_TROLL 24 /* troll */
+#define SM_WRAITH 25 /* wraith */
+
+/* constants for spells */
+#define ML_ALLORNOTHING 0.0 /* magic level for 'all or nothing' */
+#define MM_ALLORNOTHING 1.0 /* mana used for 'all or nothing' */
+#define ML_MAGICBOLT 5.0 /* magic level for 'magic bolt' */
+#define ML_FORCEFIELD 15.0 /* magic level for 'force field' */
+#define MM_FORCEFIELD 30.0 /* mana used for 'force field' */
+#define ML_XFORM 25.0 /* magic level for 'transform' */
+#define MM_XFORM 50.0 /* mana used for 'transform' */
+#define ML_INCRMIGHT 35.0 /* magic level for 'increase might' */
+#define MM_INCRMIGHT 75.0 /* mana used for 'increase might' */
+#define ML_INVISIBLE 45.0 /* magic level for 'invisibility' */
+#define MM_INVISIBLE 90.0 /* mana used for 'invisibility' */
+#define ML_XPORT 60.0 /* magic level for 'transport' */
+#define MM_XPORT 125.0 /* mana used for 'transport' */
+#define ML_PARALYZE 75.0 /* magic level for 'paralyze' */
+#define MM_PARALYZE 150.0 /* mana used for 'paralyze' */
+#define MM_SPECIFY 1000.0 /* mana used for 'specify' */
+#define ML_CLOAK 20.0 /* magic level for 'cloak' */
+#define MEL_CLOAK 7.0 /* experience level for 'cloak' */
+#define MM_CLOAK 35.0 /* mana used for 'cloak' */
+#define ML_TELEPORT 40.0 /* magic level for 'teleport' */
+#define MEL_TELEPORT 12.0 /* experience level for 'teleport' */
+#define MM_INTERVENE 1000.0 /* mana used to 'intervene' */
+
+/* some miscellaneous constants */
+#define SZ_DATABUF 100 /* size of input buffer */
+#define SZ_PLAYERSTRUCT sizeof(struct player) /* size of player structure */
+#define SZ_VOIDSTRUCT sizeof(struct energyvoid) /* size of energy void struct */
+#define SZ_SCORESTRUCT sizeof(struct scoreboard) /* size of score board entry */
+#define SZ_MONSTERSTRUCT sizeof(struct monster) /* size of monster structure */
+#define SZ_NAME 21 /* size of player name (incl. trailing nul) */
+#define SZ_PASSWORD 9 /* size of password (incl. trailing nul) */
+#define SZ_LOGIN 9 /* size of login (incl. trailing nul) */
+
+#define N_DAYSOLD 21 /* number of days old for purge */
+#define N_AGE 500 /* age to degenerate ratio */
+#define N_GEMVALUE (1000.0) /* number of gold pieces to gem ratio */
+#define N_TAXAMOUNT (7.0) /* tax percent */
+
+#define D_BEYOND (1.1e6) /* distance to beyond point of no return */
+#define D_EXPER (2000.0) /* distance experimentos are allowed */
+
+#define CH_MARKDELETE '\001' /* used to alter name of deleted players */
+#define CH_KILL '\030' /* kill character (ctrl-X) */
+#define CH_ERASE '\010' /* erase character (ctrl-H) */
+#define CH_NEWLINE '\n' /* newline */
+#define CH_REDRAW '\014' /* redraw screen character (ctrl-L) */
diff --git a/games/phantasia/phantglobs.c b/games/phantasia/phantglobs.c
new file mode 100644
index 0000000..65ab630
--- /dev/null
+++ b/games/phantasia/phantglobs.c
@@ -0,0 +1,113 @@
+/*
+ * phantglobs.c - globals for Phantasia
+ */
+
+#include "include.h"
+
+double Circle; /* which circle player is in */
+double Shield; /* force field thrown up in monster battle */
+
+bool Beyond; /* set if player is beyond point of no return */
+bool Marsh; /* set if player is in dead marshes */
+bool Throne; /* set if player is on throne */
+bool Changed; /* set if important player stats have changed */
+bool Wizard; /* set if player is the 'wizard' of the game */
+bool Timeout; /* set if short timeout waiting for input */
+bool Windows; /* set if we are set up for curses stuff */
+bool Luckout; /* set if we have tried to luck out in fight */
+bool Foestrikes; /* set if foe gets a chance to hit in battleplayer() */
+bool Echo; /* set if echo input to terminal */
+
+int Users; /* number of users currently playing */
+int Whichmonster; /* which monster we are fighting */
+int Lines; /* line on screen counter for fight routines */
+
+jmp_buf Fightenv; /* used to jump into fight routine */
+jmp_buf Timeoenv; /* used for timing out waiting for input */
+
+long Fileloc; /* location in file of player statistics */
+
+char *Login; /* pointer to login of player */
+char *Enemyname; /* pointer name of monster/player we are battling*/
+
+struct player Player; /* stats for player */
+struct player Other; /* stats for another player */
+
+struct monster Curmonster;/* stats for current monster */
+
+struct energyvoid Enrgyvoid;/* energy void buffer */
+
+struct charstats *Statptr;/* pointer into Stattable[] */
+
+/* lookup table for character type dependent statistics */
+struct charstats Stattable[7] =
+ {
+ /* MAGIC USER */
+ /* max brains, max mana, weakness, gold tote, ring duration */
+ 15.0, 200.0, 18.0, 175.0, 10,
+ /* quickness strength mana energy brains magic lvl */
+ 30, 6, 0.0, 10, 6, 2.0, 50,51,75.0, 30,16,20.0, 60,26, 6.0, 5, 5,2.75,
+
+ /* FIGHTER */
+ /* max brains, max mana, weakness, gold tote, ring duration */
+ 10.0, 110.0, 15.0, 220.0, 20,
+ /* quickness strength mana energy brains magic lvl */
+ 30, 6, 0.0, 40,16, 3.0, 30,21,40.0, 45,26,30.0, 25,21, 3.0, 3, 4, 1.5,
+
+ /* ELF */
+ /* max brains, max mana, weakness, gold tote, ring duration */
+ 12.0, 150.0, 17.0, 190.0, 13,
+ /* quickness strength mana energy brains magic lvl */
+ 32, 7, 0.0, 35,11, 2.5, 45,46,65.0, 30,21,25.0, 40,26, 4.0, 4, 4, 2.0,
+
+ /* DWARF */
+ /* max brains, max mana, weakness, gold tote, ring duration */
+ 7.0, 80.0, 13.0, 255.0, 25,
+ /* quickness strength mana energy brains magic lvl */
+ 25, 6, 0.0, 50,21, 5.0, 25,21,30.0, 60,41,35.0, 20,21, 2.5, 2, 4, 1.0,
+
+ /* HALFLING */
+ /* max brains, max mana, weakness, gold tote, ring duration */
+ 11.0, 80.0, 10.0, 125.0, 40,
+ /* quickness strength mana energy brains magic lvl */
+ 34, 0, 0.0, 20, 6, 2.0, 25,21,30.0, 55,36,30.0, 40,36, 4.5, 1, 4, 1.0,
+
+ /* EXPERIMENTO */
+ /* max brains, max mana, weakness, gold tote, ring duration */
+ 9.0, 90.0, 16.0, 160.0, 20,
+ /* quickness strength mana energy brains magic lvl */
+ 27, 0, 0.0, 25, 0, 0.0, 100,0, 0.0, 35, 0, 0.0, 25, 0, 0.0, 2, 0, 0.0,
+
+ /* SUPER */
+ /* max brains, max mana, weakness, gold tote, ring duration */
+ 15.0, 200.0, 10.0, 225.0, 40,
+ /* quickness strength mana energy brains magic lvl */
+ 38, 0, 0.0, 65, 0, 5.0, 100,0,75.0, 80, 0,35.0, 85, 0, 6.0, 9, 0,2.75
+ };
+
+/* menu of items for purchase */
+struct menuitem Menu[] =
+ {
+ "Mana", 1,
+ "Shield", 5,
+ "Book", 200,
+ "Sword", 500,
+ "Charm", 1000,
+ "Quicksilver", 2500,
+ "Blessing", 1000,
+ };
+
+FILE *Playersfp; /* pointer to open player file */
+FILE *Monstfp; /* pointer to open monster file */
+FILE *Messagefp; /* pointer to open message file */
+FILE *Energyvoidfp; /* pointer to open energy void file */
+
+char Databuf[SZ_DATABUF]; /* a place to read data into */
+
+/* some canned strings for messages */
+char Illcmd[] = "Illegal command.\n";
+char Illmove[] = "Too far.\n";
+char Illspell[] = "Illegal spell.\n";
+char Nomana[] = "Not enought mana for that spell.\n";
+char Somebetter[] = "But you already have something better.\n";
+char Nobetter[] = "That's no better than what you already have.\n";
diff --git a/games/phantasia/phantglobs.h b/games/phantasia/phantglobs.h
new file mode 100644
index 0000000..4a10cc9
--- /dev/null
+++ b/games/phantasia/phantglobs.h
@@ -0,0 +1,86 @@
+/*
+ * phantglobs.h - global declarations for Phantasia
+ */
+
+extern double Circle; /* which circle player is in */
+extern double Shield; /* force field thrown up in monster battle */
+
+extern bool Beyond; /* set if player is beyond point of no return */
+extern bool Marsh; /* set if player is in dead marshes */
+extern bool Throne; /* set if player is on throne */
+extern bool Changed; /* set if important player stats have changed */
+extern bool Wizard; /* set if player is the 'wizard' of the game */
+extern bool Timeout; /* set if short timeout waiting for input */
+extern bool Windows; /* set if we are set up for curses stuff */
+extern bool Luckout; /* set if we have tried to luck out in fight */
+extern bool Foestrikes; /* set if foe gets a chance to hit in battleplayer()*/
+extern bool Echo; /* set if echo input to terminal */
+
+extern int Users; /* number of users currently playing */
+extern int Whichmonster; /* which monster we are fighting */
+extern int Lines; /* line on screen counter for fight routines */
+
+extern jmp_buf Fightenv; /* used to jump into fight routine */
+extern jmp_buf Timeoenv; /* used for timing out waiting for input */
+
+extern long Fileloc; /* location in file of player statistics */
+
+extern char *Login; /* pointer to login of current player */
+extern char *Enemyname; /* pointer name of monster/player we are battling*/
+
+extern struct player Player; /* stats for player */
+extern struct player Other; /* stats for another player */
+
+extern struct monster Curmonster;/* stats for current monster */
+
+extern struct energyvoid Enrgyvoid;/* energy void buffer */
+
+extern struct charstats Stattable[];/* used for rolling and changing player stats*/
+
+extern struct charstats *Statptr;/* pointer into Stattable[] */
+
+extern struct menuitem Menu[]; /* menu of items for purchase */
+
+extern FILE *Playersfp; /* pointer to open player file */
+extern FILE *Monstfp; /* pointer to open monster file */
+extern FILE *Messagefp; /* pointer to open message file */
+extern FILE *Energyvoidfp; /* pointer to open energy void file */
+
+extern char Databuf[]; /* a place to read data into */
+
+/* some canned strings for messages */
+extern char Illcmd[];
+extern char Illmove[];
+extern char Illspell[];
+extern char Nomana[];
+extern char Somebetter[];
+extern char Nobetter[];
+
+/* library functions and system calls */
+extern long time();
+extern char *getlogin();
+extern char *getpass();
+extern char *strchr();
+extern char *strcat();
+extern char *strcpy();
+extern char *strncpy();
+extern char *getenv();
+struct passwd *getpwuid();
+extern char *fgets();
+
+/* functions which we need to know about */
+extern int interrupt();
+extern int ill_sig();
+extern void catchalarm();
+extern long recallplayer();
+extern long findname();
+extern long allocrecord();
+extern long rollnewplayer();
+extern long allocvoid();
+extern double drandom();
+extern double distance();
+extern double infloat();
+extern double explevel();
+extern char *descrlocation();
+extern char *descrtype();
+extern char *descrstatus();
diff --git a/games/phantasia/phantstruct.h b/games/phantasia/phantstruct.h
new file mode 100644
index 0000000..05c6da5
--- /dev/null
+++ b/games/phantasia/phantstruct.h
@@ -0,0 +1,124 @@
+/*
+ * phantstruct.h - structure definitions for Phantasia
+ */
+
+struct player /* player statistics */
+ {
+ double p_experience; /* experience */
+ double p_level; /* level */
+ double p_strength; /* strength */
+ double p_sword; /* sword */
+ double p_might; /* effect strength */
+ double p_energy; /* energy */
+ double p_maxenergy; /* maximum energy */
+ double p_shield; /* shield */
+ double p_quickness; /* quickness */
+ double p_quksilver; /* quicksilver */
+ double p_speed; /* effective quickness */
+ double p_magiclvl; /* magic level */
+ double p_mana; /* mana */
+ double p_brains; /* brains */
+ double p_poison; /* poison */
+ double p_gold; /* gold */
+ double p_gems; /* gems */
+ double p_sin; /* sin */
+ double p_x; /* x coord */
+ double p_y; /* y coord */
+ double p_1scratch,
+ p_2scratch; /* variables used for decree, player battle */
+
+ struct
+ {
+ short ring_type; /* type of ring */
+ short ring_duration; /* duration of ring */
+ bool ring_inuse; /* ring in use flag */
+ } p_ring; /* ring stuff */
+
+ long p_age; /* age of player */
+
+ int p_degenerated; /* age/3000 last degenerated */
+
+ short p_type; /* character type */
+ short p_specialtype; /* special character type */
+ short p_lives; /* multiple lives for council, valar */
+ short p_crowns; /* crowns */
+ short p_charms; /* charms */
+ short p_amulets; /* amulets */
+ short p_holywater; /* holy water */
+ short p_lastused; /* day of year last used */
+ short p_status; /* playing, cloaked, etc. */
+ short p_tampered; /* decree'd, etc. flag */
+ short p_istat; /* used for inter-terminal battle */
+
+ bool p_palantir; /* palantir */
+ bool p_blessing; /* blessing */
+ bool p_virgin; /* virgin */
+ bool p_blindness; /* blindness */
+
+ char p_name[SZ_NAME]; /* name */
+ char p_password[SZ_PASSWORD];/* password */
+ char p_login[SZ_LOGIN]; /* login */
+ };
+
+struct monster /* monster stats */
+ {
+ double m_strength; /* strength */
+ double m_brains; /* brains */
+ double m_speed; /* speed */
+ double m_energy; /* energy */
+ double m_experience; /* experience */
+ double m_flock; /* % chance of flocking */
+
+ double m_o_strength; /* original strength */
+ double m_o_speed; /* original speed */
+ double m_maxspeed; /* maximum speed */
+ double m_o_energy; /* original energy */
+ double m_melee; /* melee damage */
+ double m_skirmish; /* skirmish damage */
+
+ int m_treasuretype; /* treasure type */
+ int m_type; /* special type */
+
+ char m_name[26]; /* name */
+ };
+
+struct energyvoid /* energy void */
+ {
+ double ev_x; /* x coordinate */
+ double ev_y; /* y coordinate */
+ bool ev_active; /* active or not */
+ };
+
+struct scoreboard /* scoreboard entry */
+ {
+ double sb_level; /* level of player */
+ char sb_type[4]; /* character type of player */
+ char sb_name[SZ_NAME]; /* name of player */
+ char sb_login[SZ_LOGIN]; /* login of player */
+ };
+
+struct charstats /* character type statistics */
+ {
+ double c_maxbrains; /* max brains per level */
+ double c_maxmana; /* max mana per level */
+ double c_weakness; /* how strongly poison affects player */
+ double c_goldtote; /* how much gold char can carry */
+ int c_ringduration; /* bad ring duration */
+ struct
+ {
+ double base; /* base for roll */
+ double interval; /* interval for roll */
+ double increase; /* increment per level */
+ } c_quickness, /* quickness */
+ c_strength, /* strength */
+ c_mana, /* mana */
+ c_energy, /* energy level */
+ c_brains, /* brains */
+ c_magiclvl; /* magic level */
+ };
+
+struct menuitem /* menu item for purchase */
+ {
+ char *item; /* menu item name */
+ double cost; /* cost of item */
+ };
diff --git a/games/phantasia/setup.c b/games/phantasia/setup.c
new file mode 100644
index 0000000..f916727
--- /dev/null
+++ b/games/phantasia/setup.c
@@ -0,0 +1,261 @@
+/*
+ * setup.c - set up all files for Phantasia
+ */
+#include "include.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: main()
+/
+/ FUNCTION: setup files for Phantasia 3.3.2
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: time(), exit(), stat(), Error(), creat(), close(), fopen(),
+/ fgets(), floor(), srandom(), umask(), drandom(), strcpy(), getuid(),
+/ unlink(), fwrite(), fclose(), sscanf(), printf(), strlen(), fprintf()
+/
+/ GLOBAL INPUTS: Curmonster, _iob[], Databuf[], *Monstfp, Enrgyvoid
+/
+/ GLOBAL OUTPUTS: Curmonster, Databuf[], *Monstfp, Enrgyvoid
+/
+/ DESCRIPTION:
+/
+/ This program tries to verify the parameters specified in
+/ the Makefile.
+/
+/ Create all necessary files. Note that nothing needs to be
+/ put in these files.
+/ Also, the monster binary data base is created here.
+/
+/************************************************************************/
+
+static char *files[] = { /* all files to create */
+ _PATH_MONST,
+ _PATH_PEOPLE,
+ _PATH_MESS,
+ _PATH_LASTDEAD,
+ _PATH_MOTD,
+ _PATH_GOLD,
+ _PATH_VOID,
+ _PATH_SCORE,
+ NULL,
+};
+
+char *monsterfile="monsters.asc";
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ register char **filename; /* for pointing to file names */
+ register int fd; /* file descriptor */
+ FILE *fp; /* for opening files */
+ struct stat fbuf; /* for getting files statistics */
+ int ch;
+
+ while ((ch = getopt(argc, argv, "m:")) != EOF)
+ switch(ch) {
+ case 'm':
+ monsterfile = optarg;
+ break;
+ case '?':
+ default:
+ break;
+ }
+ argc -= optind;
+ argv += optind;
+
+ srandom((unsigned) time((long *) NULL)); /* prime random numbers */
+
+ umask(0117); /* only owner can read/write created files */
+
+ /* try to create data files */
+ filename = &files[0];
+ while (*filename != NULL)
+ /* create each file */
+ {
+ if (stat(*filename, &fbuf) == 0)
+ /* file exists; remove it */
+ {
+ if (!strcmp(*filename, _PATH_PEOPLE))
+ /* do not reset character file if it already exists */
+ {
+ ++filename;
+ continue;
+ }
+
+ if (unlink(*filename) < 0)
+ Error("Cannot unlink %s.\n", *filename);
+ /*NOTREACHED*/
+ }
+
+ if ((fd = creat(*filename, 0660)) < 0)
+ Error("Cannot create %s.\n", *filename);
+ /*NOTREACHED*/
+
+ close(fd); /* close newly created file */
+
+ ++filename; /* process next file */
+ }
+
+ /* put holy grail info into energy void file */
+ Enrgyvoid.ev_active = TRUE;
+ Enrgyvoid.ev_x = ROLL(-1.0e6, 2.0e6);
+ Enrgyvoid.ev_y = ROLL(-1.0e6, 2.0e6);
+ if ((fp = fopen(_PATH_VOID, "w")) == NULL)
+ Error("Cannot update %s.\n", _PATH_VOID);
+ else
+ {
+ fwrite(&Enrgyvoid, SZ_VOIDSTRUCT, 1, fp);
+ fclose(fp);
+ }
+
+ /* create binary monster data base */
+ if ((Monstfp = fopen(_PATH_MONST, "w")) == NULL)
+ Error("Cannot update %s.\n", _PATH_MONST);
+ else
+ {
+ if ((fp = fopen(monsterfile, "r")) == NULL)
+ {
+ fclose(Monstfp);
+ Error("cannot open %s to create monster database.\n", "monsters.asc");
+ }
+ else
+ {
+ Curmonster.m_o_strength =
+ Curmonster.m_o_speed =
+ Curmonster.m_maxspeed =
+ Curmonster.m_o_energy =
+ Curmonster.m_melee =
+ Curmonster.m_skirmish = 0.0;
+
+ while (fgets(Databuf, SZ_DATABUF, fp) != NULL)
+ /* read in text file, convert to binary */
+ {
+ sscanf(&Databuf[24], "%lf%lf%lf%lf%lf%d%d%lf",
+ &Curmonster.m_strength, &Curmonster.m_brains,
+ &Curmonster.m_speed, &Curmonster.m_energy,
+ &Curmonster.m_experience, &Curmonster.m_treasuretype,
+ &Curmonster.m_type, &Curmonster.m_flock);
+ Databuf[24] = '\0';
+ strcpy(Curmonster.m_name, Databuf);
+ fwrite((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp);
+ }
+ fclose(fp);
+ fclose(Monstfp);
+ }
+ }
+
+#ifdef MAKE_INSTALLS_THIS_AND_DOESNT_WANT_TO_HEAR_ABOUT_IT
+ /* write to motd file */
+ printf("One line 'motd' ? ");
+ if (fgets(Databuf, SZ_DATABUF, stdin) == NULL)
+ Databuf[0] = '\0';
+ if ((fp = fopen(_PATH_MOTD, "w")) == NULL)
+ Error("Cannot update %s.\n", _PATH_MOTD);
+ else
+ {
+ fwrite(Databuf, sizeof(char), strlen(Databuf), fp);
+ fclose(fp);
+ }
+
+ /* report compile-time options */
+ printf("Compiled options:\n\n");
+ printf("Phantasia destination directory: %s\n", _PATH_PHANTDIR);
+ printf("Wizard: root UID: 0\n");
+
+#ifdef BSD41
+ printf("Compiled for BSD 4.1\n");
+#endif
+
+#ifdef BSD42
+ printf("Compiled for BSD 4.2\n");
+#endif
+
+#ifdef SYS3
+ printf("Compiled for System III\n");
+#endif
+
+#ifdef SYS5
+ printf("Compiled for System V\n");
+#endif
+#endif
+
+ exit(0);
+ /*NOTREACHED*/
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: Error()
+/
+/ FUNCTION: print an error message, and exit
+/
+/ AUTHOR: E. A. Estes, 12/4/85
+/
+/ ARGUMENTS:
+/ char *str - format string for printf()
+/ char *file - file which caused error
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: exit(), perror(), fprintf()
+/
+/ GLOBAL INPUTS: _iob[]
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/ Print an error message, then exit.
+/
+/************************************************************************/
+
+Error(str, file)
+char *str, *file;
+{
+ fprintf(stderr, "Error: ");
+ fprintf(stderr, str, file);
+ perror(file);
+ exit(1);
+ /*NOTREACHED*/
+}
+/* */
+/************************************************************************
+/
+/ FUNCTION NAME: drandom()
+/
+/ FUNCTION: return a random number
+/
+/ AUTHOR: E. A. Estes, 2/7/86
+/
+/ ARGUMENTS: none
+/
+/ RETURN VALUE: none
+/
+/ MODULES CALLED: random()
+/
+/ GLOBAL INPUTS: none
+/
+/ GLOBAL OUTPUTS: none
+/
+/ DESCRIPTION:
+/
+/************************************************************************/
+
+double
+drandom()
+{
+ if (sizeof(int) != 2)
+ return((double) (random() & 0x7fff) / 32768.0);
+ else
+ return((double) random() / 32768.0);
+}
diff --git a/games/pig/Makefile b/games/pig/Makefile
new file mode 100644
index 0000000..f1ab583
--- /dev/null
+++ b/games/pig/Makefile
@@ -0,0 +1,6 @@
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
+
+PROG= pig
+MAN6= pig.6
+
+.include <bsd.prog.mk>
diff --git a/games/pig/pig.6 b/games/pig/pig.6
new file mode 100644
index 0000000..bd1d5a7
--- /dev/null
+++ b/games/pig/pig.6
@@ -0,0 +1,48 @@
+.\" Copyright (c) 1992 The Regents of the University of California.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)pig.6 8.1 (Berkeley) 6/10/93
+.\"
+.Dd "June 10, 1993"
+.Dt PIG 6
+.Os
+.Sh NAME
+.Nm pig
+.Nd eformatray inputway asway Igpay Atinlay
+.Sh SYNOPSIS
+.Nm pig
+.Sh DESCRIPTION
+Ethay
+.Nm igpay
+utilityway eadsray ethay andardstay inputway andway iteswray itway
+outway otay andardstay outputway inway Igpay Atinlay.
+.Pp
+Usefulway orfay eneratinggay onthlymay eportsray.
diff --git a/games/pig/pig.c b/games/pig/pig.c
new file mode 100644
index 0000000..3fbd514
--- /dev/null
+++ b/games/pig/pig.c
@@ -0,0 +1,126 @@
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1992, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)pig.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+#include <sys/types.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void pigout __P((char *, int));
+void usage __P((void));
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ register int len;
+ int ch;
+ char buf[1024];
+
+ while ((ch = getopt(argc, argv, "")) != EOF)
+ switch(ch) {
+ case '?':
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ for (len = 0; (ch = getchar()) != EOF;) {
+ if (isalpha(ch)) {
+ if (len >= sizeof(buf)) {
+ (void)fprintf(stderr, "pig: ate too much!\n");
+ exit(1);
+ }
+ buf[len++] = ch;
+ continue;
+ }
+ if (len != 0) {
+ pigout(buf, len);
+ len = 0;
+ }
+ (void)putchar(ch);
+ }
+ exit(0);
+}
+
+void
+pigout(buf, len)
+ char *buf;
+ int len;
+{
+ register int ch, start;
+ int olen;
+
+ /*
+ * If the word starts with a vowel, append "way". Don't treat 'y'
+ * as a vowel if it appears first.
+ */
+ if (index("aeiouAEIOU", buf[0]) != NULL) {
+ (void)printf("%.*sway", len, buf);
+ return;
+ }
+
+ /*
+ * Copy leading consonants to the end of the word. The unit "qu"
+ * isn't treated as a vowel.
+ */
+ for (start = 0, olen = len;
+ !index("aeiouyAEIOUY", buf[start]) && start < olen;) {
+ ch = buf[len++] = buf[start++];
+ if ((ch == 'q' || ch == 'Q') && start < olen &&
+ (buf[start] == 'u' || buf[start] == 'U'))
+ buf[len++] = buf[start++];
+ }
+ (void)printf("%.*say", olen, buf + start);
+}
+
+void
+usage()
+{
+ (void)fprintf(stderr, "usage: pig\n");
+ exit(1);
+}
diff --git a/games/primes/Makefile b/games/primes/Makefile
new file mode 100644
index 0000000..edf216f
--- /dev/null
+++ b/games/primes/Makefile
@@ -0,0 +1,9 @@
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
+
+PROG= primes
+SRCS= pattern.c pr_tbl.c primes.c
+NOMAN= noman
+DPADD= ${LIBM}
+LDADD= -lm
+
+.include <bsd.prog.mk>
diff --git a/games/primes/pattern.c b/games/primes/pattern.c
new file mode 100644
index 0000000..5d65dab
--- /dev/null
+++ b/games/primes/pattern.c
@@ -0,0 +1,440 @@
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Landon Curt Noll.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)pattern.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+/*
+ * pattern - the Eratosthenes sieve on odd numbers for 3,5,7,11 and 13
+ *
+ * By: Landon Curt Noll chongo@toad.com
+ *
+ * chongo <for a good prime call: 391581 * 2^216193 - 1> /\oo/\
+ *
+ * To avoid excessive sieves for small factors, we use the table below to
+ * setup our sieve blocks. Each element represents a odd number starting
+ * with 1. All non-zero elements are factors of 3, 5, 7, 11 and 13.
+ */
+
+char pattern[] = {
+1,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,
+1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,
+1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,
+0,0,0,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,
+1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,
+0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,
+1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,
+0,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,
+1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,
+1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,
+1,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,
+1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,
+1,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,1,0,1,
+0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,
+1,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,
+0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,
+0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,
+0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,
+1,0,0,1,0,1,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,
+1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,0,0,0,
+0,0,1,1,0,1,0,0,0,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,0,0,0,1,0,0,1,0,1,
+0,0,0,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,
+1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,
+1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,
+0,0,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,0,0,1,
+0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,
+0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,
+1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,1,0,1,1,0,0,
+1,0,1,0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,
+1,0,0,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,0,1,
+0,0,1,1,0,0,0,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,
+1,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,0,0,1,
+1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,1,
+0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,
+1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,
+0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,0,0,0,1,0,1,
+1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,
+1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,0,1,0,0,0,
+1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,
+0,0,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,0,0,1,
+1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,
+1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,
+1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,1,1,0,0,
+1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,
+0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,
+0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,
+0,0,0,1,0,0,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,0,1,0,1,1,0,1,
+0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,
+1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,
+1,0,0,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,
+0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,
+0,0,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,
+1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,
+0,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,0,1,
+1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,
+0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,1,0,1,
+0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,
+1,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,0,0,0,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,0,0,
+1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,1,
+1,0,1,1,0,1,0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,
+0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,
+1,0,1,0,0,0,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,
+0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,
+1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,
+1,0,0,1,0,0,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,0,
+1,0,1,1,0,1,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,
+0,0,0,1,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,1,0,0,0,
+1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,
+1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,
+0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,
+0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,
+1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,
+0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,
+0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,0,0,0,0,0,1,
+1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,
+1,0,1,0,0,1,0,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,
+0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,
+0,0,1,0,0,0,0,0,1,1,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,0,0,0,0,1,0,0,
+1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,0,
+1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,
+1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,
+0,0,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,0,0,1,
+0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,0,1,
+1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,0,1,1,0,0,
+1,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,
+0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,1,0,0,1,
+1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,
+0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,
+1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,1,0,0,
+0,0,1,1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,
+1,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,
+1,0,0,1,0,0,0,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,
+1,0,0,0,0,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,
+1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,
+0,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,
+1,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,0,0,
+1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,
+0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,
+1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,
+0,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,0,0,0,0,0,1,1,0,0,
+1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,1,
+0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,0,0,0,1,0,0,1,0,1,
+1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,
+1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,
+0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,
+0,0,1,1,0,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,
+0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,
+1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,
+1,0,1,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0,0,0,
+1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,0,0,0,1,0,1,0,0,1,
+0,0,0,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,0,1,
+1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,
+0,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,
+1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,
+0,0,1,0,0,1,0,0,0,0,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,
+1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,0,
+0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,
+1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,1,
+1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,1,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,0,
+1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,
+1,0,1,0,0,0,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,0,0,1,0,1,0,0,0,
+1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,
+1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,0,0,0,1,1,0,0,
+1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,
+0,0,1,0,0,0,0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,
+1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,
+0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,
+0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,
+1,0,0,1,0,0,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,
+1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,
+0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,1,
+0,0,1,0,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,
+1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,
+1,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,0,0,
+1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,
+0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,
+0,0,0,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,
+1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,
+1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,
+1,0,0,0,0,1,0,0,1,1,0,0,0,0,0,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,
+0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,0,0,1,0,0,
+1,0,0,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,
+0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,0,0,1,0,0,1,0,1,
+1,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,
+1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,
+0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,0,
+1,0,1,1,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,
+0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,
+1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,
+1,0,0,0,0,1,0,0,0,0,0,1,1,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,0,0,0,1,0,0,0,
+1,0,1,1,0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,
+0,0,0,1,0,0,0,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,1,0,0,0,0,0,1,0,0,0,0,1,
+1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,
+0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,
+0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,0,0,1,1,0,1,
+0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,
+1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,
+1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,1,0,1,0,0,1,
+1,0,1,0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,
+0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,1,
+0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,
+1,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1,
+1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,
+1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,
+0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,0,0,0,
+1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,
+1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,
+0,0,1,0,0,0,0,0,1,1,0,1,0,0,0,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,0,0,0,0,0,0,1,
+1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,0,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,
+0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,0,1,0,0,
+1,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,
+0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,
+0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,0,0,1,0,0,1,
+1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,0,
+1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,
+1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,
+1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,0,0,0,0,0,0,1,0,0,
+1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,
+0,0,1,1,0,0,0,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,
+1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,
+0,0,0,1,0,1,0,0,1,1,0,0,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,1,0,1,
+1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,
+0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,
+1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,
+1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,
+0,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,
+0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,0,0,1,0,0,1,0,0,
+1,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,
+0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,0,
+0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,
+1,0,0,0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,0,0,0,
+1,0,0,1,0,1,0,0,0,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,
+0,0,0,1,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,1,
+1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,
+0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,
+0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,0,
+0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,
+1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,
+1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,
+1,0,1,0,0,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,0,
+1,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,
+0,0,1,1,0,0,0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,0,
+1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,1,
+1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,
+1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,
+0,0,1,1,0,0,0,0,0,1,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,1,
+1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,0,
+0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,
+0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,0,0,0,1,
+1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,0,0,0,1,0,0,1,
+1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,
+1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0,0,
+0,0,1,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,
+0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,
+0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,1,
+1,0,0,1,0,0,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,
+1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,0,0,1,
+0,0,1,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,
+1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,
+1,0,0,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,0,0,1,0,0,1,1,0,0,0,0,0,1,0,0,
+1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,
+1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,
+0,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,
+0,0,1,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,1,0,0,0,0,0,1,0,0,
+1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,
+0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,0,1,0,0,1,0,1,
+1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,
+1,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,1,0,0,0,
+1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,
+1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,
+0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,
+1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,
+0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,
+1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,
+0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,1,0,0,0,
+1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,
+0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,1,0,0,1,
+1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,
+1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,
+0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,0,0,0,1,0,1,
+0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,
+1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,1,0,1,
+1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,0,0,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,
+0,0,1,1,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,
+1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,
+1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,
+1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,
+1,0,1,1,0,0,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,1,0,0,1,0,1,0,0,0,
+1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,
+0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,0,0,0,1,0,0,
+1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,
+0,0,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,0,0,1,
+1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,
+1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,0,
+1,0,1,1,0,1,0,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,0,0,1,0,0,0,
+1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,
+1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,
+1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1,
+0,0,1,1,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,
+1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,
+0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,
+1,0,0,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,
+1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,
+0,0,0,1,0,0,0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,
+0,0,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,0,0,1,0,0,1,
+1,0,1,0,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,
+0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,
+0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,
+1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,
+1,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,
+1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,0,0,0,1,1,0,0,
+1,0,0,1,0,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,1,
+0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,1,0,1,
+0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,
+1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,
+0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,
+1,0,0,1,0,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,0,
+0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,
+1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,
+0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,0,0,0,
+1,0,1,0,0,1,0,0,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,0,0,0,1,0,1,1,0,0,
+0,0,0,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,
+1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0,1,0,1,0,0,1,
+1,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,0,
+0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,1,
+0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,
+1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,
+1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,
+1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,0,
+1,0,1,0,0,0,0,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,1,
+0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,1,
+1,0,0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,
+0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,
+1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0,1,
+0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,
+1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,0,
+1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,
+1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,
+0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,
+0,0,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,0,0,0,
+1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,
+1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,1,
+1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,0,1,1,0,0,
+1,0,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,
+0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,
+0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,1
+};
+int pattern_size = (sizeof(pattern)/sizeof(pattern[0]));
diff --git a/games/primes/pr_tbl.c b/games/primes/pr_tbl.c
new file mode 100644
index 0000000..b7b8d04
--- /dev/null
+++ b/games/primes/pr_tbl.c
@@ -0,0 +1,546 @@
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Landon Curt Noll.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)pr_tbl.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+/*
+ * prime - prime table
+ *
+ * By: Landon Curt Noll chongo@toad.com, ...!{sun,tolsoft}!hoptoad!chongo
+ *
+ * chongo <for a good prime call: 391581 * 2^216193 - 1> /\oo/\
+ *
+ * We are able to sieve 2^32-1 because this table has primes up to 65537
+ * and 65537^2 > 2^32-1.
+ */
+
+#include "primes.h"
+
+ubig prime[] = {
+2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,
+107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,
+211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,
+317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,
+439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,
+569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,
+677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,
+821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,
+947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,
+1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,
+1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,
+1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,
+1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,
+1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,
+1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,
+1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,
+1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,
+1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,
+2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,
+2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,
+2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,
+2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,
+2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,
+2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,
+2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,
+2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,
+3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,
+3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,
+3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,
+3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,
+3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,
+3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,
+3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,
+3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,
+4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,
+4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,
+4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,
+4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,
+4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,
+4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,
+4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,
+4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999,5003,5009,5011,
+5021,5023,5039,5051,5059,5077,5081,5087,5099,5101,5107,5113,5119,5147,5153,
+5167,5171,5179,5189,5197,5209,5227,5231,5233,5237,5261,5273,5279,5281,5297,
+5303,5309,5323,5333,5347,5351,5381,5387,5393,5399,5407,5413,5417,5419,5431,
+5437,5441,5443,5449,5471,5477,5479,5483,5501,5503,5507,5519,5521,5527,5531,
+5557,5563,5569,5573,5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,
+5683,5689,5693,5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,5801,5807,
+5813,5821,5827,5839,5843,5849,5851,5857,5861,5867,5869,5879,5881,5897,5903,
+5923,5927,5939,5953,5981,5987,6007,6011,6029,6037,6043,6047,6053,6067,6073,
+6079,6089,6091,6101,6113,6121,6131,6133,6143,6151,6163,6173,6197,6199,6203,
+6211,6217,6221,6229,6247,6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,
+6323,6329,6337,6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,6449,
+6451,6469,6473,6481,6491,6521,6529,6547,6551,6553,6563,6569,6571,6577,6581,
+6599,6607,6619,6637,6653,6659,6661,6673,6679,6689,6691,6701,6703,6709,6719,
+6733,6737,6761,6763,6779,6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,
+6863,6869,6871,6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,6977,
+6983,6991,6997,7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,
+7127,7129,7151,7159,7177,7187,7193,7207,7211,7213,7219,7229,7237,7243,7247,
+7253,7283,7297,7307,7309,7321,7331,7333,7349,7351,7369,7393,7411,7417,7433,
+7451,7457,7459,7477,7481,7487,7489,7499,7507,7517,7523,7529,7537,7541,7547,
+7549,7559,7561,7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,
+7673,7681,7687,7691,7699,7703,7717,7723,7727,7741,7753,7757,7759,7789,7793,
+7817,7823,7829,7841,7853,7867,7873,7877,7879,7883,7901,7907,7919,7927,7933,
+7937,7949,7951,7963,7993,8009,8011,8017,8039,8053,8059,8069,8081,8087,8089,
+8093,8101,8111,8117,8123,8147,8161,8167,8171,8179,8191,8209,8219,8221,8231,
+8233,8237,8243,8263,8269,8273,8287,8291,8293,8297,8311,8317,8329,8353,8363,
+8369,8377,8387,8389,8419,8423,8429,8431,8443,8447,8461,8467,8501,8513,8521,
+8527,8537,8539,8543,8563,8573,8581,8597,8599,8609,8623,8627,8629,8641,8647,
+8663,8669,8677,8681,8689,8693,8699,8707,8713,8719,8731,8737,8741,8747,8753,
+8761,8779,8783,8803,8807,8819,8821,8831,8837,8839,8849,8861,8863,8867,8887,
+8893,8923,8929,8933,8941,8951,8963,8969,8971,8999,9001,9007,9011,9013,9029,
+9041,9043,9049,9059,9067,9091,9103,9109,9127,9133,9137,9151,9157,9161,9173,
+9181,9187,9199,9203,9209,9221,9227,9239,9241,9257,9277,9281,9283,9293,9311,
+9319,9323,9337,9341,9343,9349,9371,9377,9391,9397,9403,9413,9419,9421,9431,
+9433,9437,9439,9461,9463,9467,9473,9479,9491,9497,9511,9521,9533,9539,9547,
+9551,9587,9601,9613,9619,9623,9629,9631,9643,9649,9661,9677,9679,9689,9697,
+9719,9721,9733,9739,9743,9749,9767,9769,9781,9787,9791,9803,9811,9817,9829,
+9833,9839,9851,9857,9859,9871,9883,9887,9901,9907,9923,9929,9931,9941,9949,
+9967,9973,10007,10009,10037,10039,10061,10067,10069,10079,10091,10093,10099,
+10103,10111,10133,10139,10141,10151,10159,10163,10169,10177,10181,10193,10211,
+10223,10243,10247,10253,10259,10267,10271,10273,10289,10301,10303,10313,10321,
+10331,10333,10337,10343,10357,10369,10391,10399,10427,10429,10433,10453,10457,
+10459,10463,10477,10487,10499,10501,10513,10529,10531,10559,10567,10589,10597,
+10601,10607,10613,10627,10631,10639,10651,10657,10663,10667,10687,10691,10709,
+10711,10723,10729,10733,10739,10753,10771,10781,10789,10799,10831,10837,10847,
+10853,10859,10861,10867,10883,10889,10891,10903,10909,10937,10939,10949,10957,
+10973,10979,10987,10993,11003,11027,11047,11057,11059,11069,11071,11083,11087,
+11093,11113,11117,11119,11131,11149,11159,11161,11171,11173,11177,11197,11213,
+11239,11243,11251,11257,11261,11273,11279,11287,11299,11311,11317,11321,11329,
+11351,11353,11369,11383,11393,11399,11411,11423,11437,11443,11447,11467,11471,
+11483,11489,11491,11497,11503,11519,11527,11549,11551,11579,11587,11593,11597,
+11617,11621,11633,11657,11677,11681,11689,11699,11701,11717,11719,11731,11743,
+11777,11779,11783,11789,11801,11807,11813,11821,11827,11831,11833,11839,11863,
+11867,11887,11897,11903,11909,11923,11927,11933,11939,11941,11953,11959,11969,
+11971,11981,11987,12007,12011,12037,12041,12043,12049,12071,12073,12097,12101,
+12107,12109,12113,12119,12143,12149,12157,12161,12163,12197,12203,12211,12227,
+12239,12241,12251,12253,12263,12269,12277,12281,12289,12301,12323,12329,12343,
+12347,12373,12377,12379,12391,12401,12409,12413,12421,12433,12437,12451,12457,
+12473,12479,12487,12491,12497,12503,12511,12517,12527,12539,12541,12547,12553,
+12569,12577,12583,12589,12601,12611,12613,12619,12637,12641,12647,12653,12659,
+12671,12689,12697,12703,12713,12721,12739,12743,12757,12763,12781,12791,12799,
+12809,12821,12823,12829,12841,12853,12889,12893,12899,12907,12911,12917,12919,
+12923,12941,12953,12959,12967,12973,12979,12983,13001,13003,13007,13009,13033,
+13037,13043,13049,13063,13093,13099,13103,13109,13121,13127,13147,13151,13159,
+13163,13171,13177,13183,13187,13217,13219,13229,13241,13249,13259,13267,13291,
+13297,13309,13313,13327,13331,13337,13339,13367,13381,13397,13399,13411,13417,
+13421,13441,13451,13457,13463,13469,13477,13487,13499,13513,13523,13537,13553,
+13567,13577,13591,13597,13613,13619,13627,13633,13649,13669,13679,13681,13687,
+13691,13693,13697,13709,13711,13721,13723,13729,13751,13757,13759,13763,13781,
+13789,13799,13807,13829,13831,13841,13859,13873,13877,13879,13883,13901,13903,
+13907,13913,13921,13931,13933,13963,13967,13997,13999,14009,14011,14029,14033,
+14051,14057,14071,14081,14083,14087,14107,14143,14149,14153,14159,14173,14177,
+14197,14207,14221,14243,14249,14251,14281,14293,14303,14321,14323,14327,14341,
+14347,14369,14387,14389,14401,14407,14411,14419,14423,14431,14437,14447,14449,
+14461,14479,14489,14503,14519,14533,14537,14543,14549,14551,14557,14561,14563,
+14591,14593,14621,14627,14629,14633,14639,14653,14657,14669,14683,14699,14713,
+14717,14723,14731,14737,14741,14747,14753,14759,14767,14771,14779,14783,14797,
+14813,14821,14827,14831,14843,14851,14867,14869,14879,14887,14891,14897,14923,
+14929,14939,14947,14951,14957,14969,14983,15013,15017,15031,15053,15061,15073,
+15077,15083,15091,15101,15107,15121,15131,15137,15139,15149,15161,15173,15187,
+15193,15199,15217,15227,15233,15241,15259,15263,15269,15271,15277,15287,15289,
+15299,15307,15313,15319,15329,15331,15349,15359,15361,15373,15377,15383,15391,
+15401,15413,15427,15439,15443,15451,15461,15467,15473,15493,15497,15511,15527,
+15541,15551,15559,15569,15581,15583,15601,15607,15619,15629,15641,15643,15647,
+15649,15661,15667,15671,15679,15683,15727,15731,15733,15737,15739,15749,15761,
+15767,15773,15787,15791,15797,15803,15809,15817,15823,15859,15877,15881,15887,
+15889,15901,15907,15913,15919,15923,15937,15959,15971,15973,15991,16001,16007,
+16033,16057,16061,16063,16067,16069,16073,16087,16091,16097,16103,16111,16127,
+16139,16141,16183,16187,16189,16193,16217,16223,16229,16231,16249,16253,16267,
+16273,16301,16319,16333,16339,16349,16361,16363,16369,16381,16411,16417,16421,
+16427,16433,16447,16451,16453,16477,16481,16487,16493,16519,16529,16547,16553,
+16561,16567,16573,16603,16607,16619,16631,16633,16649,16651,16657,16661,16673,
+16691,16693,16699,16703,16729,16741,16747,16759,16763,16787,16811,16823,16829,
+16831,16843,16871,16879,16883,16889,16901,16903,16921,16927,16931,16937,16943,
+16963,16979,16981,16987,16993,17011,17021,17027,17029,17033,17041,17047,17053,
+17077,17093,17099,17107,17117,17123,17137,17159,17167,17183,17189,17191,17203,
+17207,17209,17231,17239,17257,17291,17293,17299,17317,17321,17327,17333,17341,
+17351,17359,17377,17383,17387,17389,17393,17401,17417,17419,17431,17443,17449,
+17467,17471,17477,17483,17489,17491,17497,17509,17519,17539,17551,17569,17573,
+17579,17581,17597,17599,17609,17623,17627,17657,17659,17669,17681,17683,17707,
+17713,17729,17737,17747,17749,17761,17783,17789,17791,17807,17827,17837,17839,
+17851,17863,17881,17891,17903,17909,17911,17921,17923,17929,17939,17957,17959,
+17971,17977,17981,17987,17989,18013,18041,18043,18047,18049,18059,18061,18077,
+18089,18097,18119,18121,18127,18131,18133,18143,18149,18169,18181,18191,18199,
+18211,18217,18223,18229,18233,18251,18253,18257,18269,18287,18289,18301,18307,
+18311,18313,18329,18341,18353,18367,18371,18379,18397,18401,18413,18427,18433,
+18439,18443,18451,18457,18461,18481,18493,18503,18517,18521,18523,18539,18541,
+18553,18583,18587,18593,18617,18637,18661,18671,18679,18691,18701,18713,18719,
+18731,18743,18749,18757,18773,18787,18793,18797,18803,18839,18859,18869,18899,
+18911,18913,18917,18919,18947,18959,18973,18979,19001,19009,19013,19031,19037,
+19051,19069,19073,19079,19081,19087,19121,19139,19141,19157,19163,19181,19183,
+19207,19211,19213,19219,19231,19237,19249,19259,19267,19273,19289,19301,19309,
+19319,19333,19373,19379,19381,19387,19391,19403,19417,19421,19423,19427,19429,
+19433,19441,19447,19457,19463,19469,19471,19477,19483,19489,19501,19507,19531,
+19541,19543,19553,19559,19571,19577,19583,19597,19603,19609,19661,19681,19687,
+19697,19699,19709,19717,19727,19739,19751,19753,19759,19763,19777,19793,19801,
+19813,19819,19841,19843,19853,19861,19867,19889,19891,19913,19919,19927,19937,
+19949,19961,19963,19973,19979,19991,19993,19997,20011,20021,20023,20029,20047,
+20051,20063,20071,20089,20101,20107,20113,20117,20123,20129,20143,20147,20149,
+20161,20173,20177,20183,20201,20219,20231,20233,20249,20261,20269,20287,20297,
+20323,20327,20333,20341,20347,20353,20357,20359,20369,20389,20393,20399,20407,
+20411,20431,20441,20443,20477,20479,20483,20507,20509,20521,20533,20543,20549,
+20551,20563,20593,20599,20611,20627,20639,20641,20663,20681,20693,20707,20717,
+20719,20731,20743,20747,20749,20753,20759,20771,20773,20789,20807,20809,20849,
+20857,20873,20879,20887,20897,20899,20903,20921,20929,20939,20947,20959,20963,
+20981,20983,21001,21011,21013,21017,21019,21023,21031,21059,21061,21067,21089,
+21101,21107,21121,21139,21143,21149,21157,21163,21169,21179,21187,21191,21193,
+21211,21221,21227,21247,21269,21277,21283,21313,21317,21319,21323,21341,21347,
+21377,21379,21383,21391,21397,21401,21407,21419,21433,21467,21481,21487,21491,
+21493,21499,21503,21517,21521,21523,21529,21557,21559,21563,21569,21577,21587,
+21589,21599,21601,21611,21613,21617,21647,21649,21661,21673,21683,21701,21713,
+21727,21737,21739,21751,21757,21767,21773,21787,21799,21803,21817,21821,21839,
+21841,21851,21859,21863,21871,21881,21893,21911,21929,21937,21943,21961,21977,
+21991,21997,22003,22013,22027,22031,22037,22039,22051,22063,22067,22073,22079,
+22091,22093,22109,22111,22123,22129,22133,22147,22153,22157,22159,22171,22189,
+22193,22229,22247,22259,22271,22273,22277,22279,22283,22291,22303,22307,22343,
+22349,22367,22369,22381,22391,22397,22409,22433,22441,22447,22453,22469,22481,
+22483,22501,22511,22531,22541,22543,22549,22567,22571,22573,22613,22619,22621,
+22637,22639,22643,22651,22669,22679,22691,22697,22699,22709,22717,22721,22727,
+22739,22741,22751,22769,22777,22783,22787,22807,22811,22817,22853,22859,22861,
+22871,22877,22901,22907,22921,22937,22943,22961,22963,22973,22993,23003,23011,
+23017,23021,23027,23029,23039,23041,23053,23057,23059,23063,23071,23081,23087,
+23099,23117,23131,23143,23159,23167,23173,23189,23197,23201,23203,23209,23227,
+23251,23269,23279,23291,23293,23297,23311,23321,23327,23333,23339,23357,23369,
+23371,23399,23417,23431,23447,23459,23473,23497,23509,23531,23537,23539,23549,
+23557,23561,23563,23567,23581,23593,23599,23603,23609,23623,23627,23629,23633,
+23663,23669,23671,23677,23687,23689,23719,23741,23743,23747,23753,23761,23767,
+23773,23789,23801,23813,23819,23827,23831,23833,23857,23869,23873,23879,23887,
+23893,23899,23909,23911,23917,23929,23957,23971,23977,23981,23993,24001,24007,
+24019,24023,24029,24043,24049,24061,24071,24077,24083,24091,24097,24103,24107,
+24109,24113,24121,24133,24137,24151,24169,24179,24181,24197,24203,24223,24229,
+24239,24247,24251,24281,24317,24329,24337,24359,24371,24373,24379,24391,24407,
+24413,24419,24421,24439,24443,24469,24473,24481,24499,24509,24517,24527,24533,
+24547,24551,24571,24593,24611,24623,24631,24659,24671,24677,24683,24691,24697,
+24709,24733,24749,24763,24767,24781,24793,24799,24809,24821,24841,24847,24851,
+24859,24877,24889,24907,24917,24919,24923,24943,24953,24967,24971,24977,24979,
+24989,25013,25031,25033,25037,25057,25073,25087,25097,25111,25117,25121,25127,
+25147,25153,25163,25169,25171,25183,25189,25219,25229,25237,25243,25247,25253,
+25261,25301,25303,25307,25309,25321,25339,25343,25349,25357,25367,25373,25391,
+25409,25411,25423,25439,25447,25453,25457,25463,25469,25471,25523,25537,25541,
+25561,25577,25579,25583,25589,25601,25603,25609,25621,25633,25639,25643,25657,
+25667,25673,25679,25693,25703,25717,25733,25741,25747,25759,25763,25771,25793,
+25799,25801,25819,25841,25847,25849,25867,25873,25889,25903,25913,25919,25931,
+25933,25939,25943,25951,25969,25981,25997,25999,26003,26017,26021,26029,26041,
+26053,26083,26099,26107,26111,26113,26119,26141,26153,26161,26171,26177,26183,
+26189,26203,26209,26227,26237,26249,26251,26261,26263,26267,26293,26297,26309,
+26317,26321,26339,26347,26357,26371,26387,26393,26399,26407,26417,26423,26431,
+26437,26449,26459,26479,26489,26497,26501,26513,26539,26557,26561,26573,26591,
+26597,26627,26633,26641,26647,26669,26681,26683,26687,26693,26699,26701,26711,
+26713,26717,26723,26729,26731,26737,26759,26777,26783,26801,26813,26821,26833,
+26839,26849,26861,26863,26879,26881,26891,26893,26903,26921,26927,26947,26951,
+26953,26959,26981,26987,26993,27011,27017,27031,27043,27059,27061,27067,27073,
+27077,27091,27103,27107,27109,27127,27143,27179,27191,27197,27211,27239,27241,
+27253,27259,27271,27277,27281,27283,27299,27329,27337,27361,27367,27397,27407,
+27409,27427,27431,27437,27449,27457,27479,27481,27487,27509,27527,27529,27539,
+27541,27551,27581,27583,27611,27617,27631,27647,27653,27673,27689,27691,27697,
+27701,27733,27737,27739,27743,27749,27751,27763,27767,27773,27779,27791,27793,
+27799,27803,27809,27817,27823,27827,27847,27851,27883,27893,27901,27917,27919,
+27941,27943,27947,27953,27961,27967,27983,27997,28001,28019,28027,28031,28051,
+28057,28069,28081,28087,28097,28099,28109,28111,28123,28151,28163,28181,28183,
+28201,28211,28219,28229,28277,28279,28283,28289,28297,28307,28309,28319,28349,
+28351,28387,28393,28403,28409,28411,28429,28433,28439,28447,28463,28477,28493,
+28499,28513,28517,28537,28541,28547,28549,28559,28571,28573,28579,28591,28597,
+28603,28607,28619,28621,28627,28631,28643,28649,28657,28661,28663,28669,28687,
+28697,28703,28711,28723,28729,28751,28753,28759,28771,28789,28793,28807,28813,
+28817,28837,28843,28859,28867,28871,28879,28901,28909,28921,28927,28933,28949,
+28961,28979,29009,29017,29021,29023,29027,29033,29059,29063,29077,29101,29123,
+29129,29131,29137,29147,29153,29167,29173,29179,29191,29201,29207,29209,29221,
+29231,29243,29251,29269,29287,29297,29303,29311,29327,29333,29339,29347,29363,
+29383,29387,29389,29399,29401,29411,29423,29429,29437,29443,29453,29473,29483,
+29501,29527,29531,29537,29567,29569,29573,29581,29587,29599,29611,29629,29633,
+29641,29663,29669,29671,29683,29717,29723,29741,29753,29759,29761,29789,29803,
+29819,29833,29837,29851,29863,29867,29873,29879,29881,29917,29921,29927,29947,
+29959,29983,29989,30011,30013,30029,30047,30059,30071,30089,30091,30097,30103,
+30109,30113,30119,30133,30137,30139,30161,30169,30181,30187,30197,30203,30211,
+30223,30241,30253,30259,30269,30271,30293,30307,30313,30319,30323,30341,30347,
+30367,30389,30391,30403,30427,30431,30449,30467,30469,30491,30493,30497,30509,
+30517,30529,30539,30553,30557,30559,30577,30593,30631,30637,30643,30649,30661,
+30671,30677,30689,30697,30703,30707,30713,30727,30757,30763,30773,30781,30803,
+30809,30817,30829,30839,30841,30851,30853,30859,30869,30871,30881,30893,30911,
+30931,30937,30941,30949,30971,30977,30983,31013,31019,31033,31039,31051,31063,
+31069,31079,31081,31091,31121,31123,31139,31147,31151,31153,31159,31177,31181,
+31183,31189,31193,31219,31223,31231,31237,31247,31249,31253,31259,31267,31271,
+31277,31307,31319,31321,31327,31333,31337,31357,31379,31387,31391,31393,31397,
+31469,31477,31481,31489,31511,31513,31517,31531,31541,31543,31547,31567,31573,
+31583,31601,31607,31627,31643,31649,31657,31663,31667,31687,31699,31721,31723,
+31727,31729,31741,31751,31769,31771,31793,31799,31817,31847,31849,31859,31873,
+31883,31891,31907,31957,31963,31973,31981,31991,32003,32009,32027,32029,32051,
+32057,32059,32063,32069,32077,32083,32089,32099,32117,32119,32141,32143,32159,
+32173,32183,32189,32191,32203,32213,32233,32237,32251,32257,32261,32297,32299,
+32303,32309,32321,32323,32327,32341,32353,32359,32363,32369,32371,32377,32381,
+32401,32411,32413,32423,32429,32441,32443,32467,32479,32491,32497,32503,32507,
+32531,32533,32537,32561,32563,32569,32573,32579,32587,32603,32609,32611,32621,
+32633,32647,32653,32687,32693,32707,32713,32717,32719,32749,32771,32779,32783,
+32789,32797,32801,32803,32831,32833,32839,32843,32869,32887,32909,32911,32917,
+32933,32939,32941,32957,32969,32971,32983,32987,32993,32999,33013,33023,33029,
+33037,33049,33053,33071,33073,33083,33091,33107,33113,33119,33149,33151,33161,
+33179,33181,33191,33199,33203,33211,33223,33247,33287,33289,33301,33311,33317,
+33329,33331,33343,33347,33349,33353,33359,33377,33391,33403,33409,33413,33427,
+33457,33461,33469,33479,33487,33493,33503,33521,33529,33533,33547,33563,33569,
+33577,33581,33587,33589,33599,33601,33613,33617,33619,33623,33629,33637,33641,
+33647,33679,33703,33713,33721,33739,33749,33751,33757,33767,33769,33773,33791,
+33797,33809,33811,33827,33829,33851,33857,33863,33871,33889,33893,33911,33923,
+33931,33937,33941,33961,33967,33997,34019,34031,34033,34039,34057,34061,34123,
+34127,34129,34141,34147,34157,34159,34171,34183,34211,34213,34217,34231,34253,
+34259,34261,34267,34273,34283,34297,34301,34303,34313,34319,34327,34337,34351,
+34361,34367,34369,34381,34403,34421,34429,34439,34457,34469,34471,34483,34487,
+34499,34501,34511,34513,34519,34537,34543,34549,34583,34589,34591,34603,34607,
+34613,34631,34649,34651,34667,34673,34679,34687,34693,34703,34721,34729,34739,
+34747,34757,34759,34763,34781,34807,34819,34841,34843,34847,34849,34871,34877,
+34883,34897,34913,34919,34939,34949,34961,34963,34981,35023,35027,35051,35053,
+35059,35069,35081,35083,35089,35099,35107,35111,35117,35129,35141,35149,35153,
+35159,35171,35201,35221,35227,35251,35257,35267,35279,35281,35291,35311,35317,
+35323,35327,35339,35353,35363,35381,35393,35401,35407,35419,35423,35437,35447,
+35449,35461,35491,35507,35509,35521,35527,35531,35533,35537,35543,35569,35573,
+35591,35593,35597,35603,35617,35671,35677,35729,35731,35747,35753,35759,35771,
+35797,35801,35803,35809,35831,35837,35839,35851,35863,35869,35879,35897,35899,
+35911,35923,35933,35951,35963,35969,35977,35983,35993,35999,36007,36011,36013,
+36017,36037,36061,36067,36073,36083,36097,36107,36109,36131,36137,36151,36161,
+36187,36191,36209,36217,36229,36241,36251,36263,36269,36277,36293,36299,36307,
+36313,36319,36341,36343,36353,36373,36383,36389,36433,36451,36457,36467,36469,
+36473,36479,36493,36497,36523,36527,36529,36541,36551,36559,36563,36571,36583,
+36587,36599,36607,36629,36637,36643,36653,36671,36677,36683,36691,36697,36709,
+36713,36721,36739,36749,36761,36767,36779,36781,36787,36791,36793,36809,36821,
+36833,36847,36857,36871,36877,36887,36899,36901,36913,36919,36923,36929,36931,
+36943,36947,36973,36979,36997,37003,37013,37019,37021,37039,37049,37057,37061,
+37087,37097,37117,37123,37139,37159,37171,37181,37189,37199,37201,37217,37223,
+37243,37253,37273,37277,37307,37309,37313,37321,37337,37339,37357,37361,37363,
+37369,37379,37397,37409,37423,37441,37447,37463,37483,37489,37493,37501,37507,
+37511,37517,37529,37537,37547,37549,37561,37567,37571,37573,37579,37589,37591,
+37607,37619,37633,37643,37649,37657,37663,37691,37693,37699,37717,37747,37781,
+37783,37799,37811,37813,37831,37847,37853,37861,37871,37879,37889,37897,37907,
+37951,37957,37963,37967,37987,37991,37993,37997,38011,38039,38047,38053,38069,
+38083,38113,38119,38149,38153,38167,38177,38183,38189,38197,38201,38219,38231,
+38237,38239,38261,38273,38281,38287,38299,38303,38317,38321,38327,38329,38333,
+38351,38371,38377,38393,38431,38447,38449,38453,38459,38461,38501,38543,38557,
+38561,38567,38569,38593,38603,38609,38611,38629,38639,38651,38653,38669,38671,
+38677,38693,38699,38707,38711,38713,38723,38729,38737,38747,38749,38767,38783,
+38791,38803,38821,38833,38839,38851,38861,38867,38873,38891,38903,38917,38921,
+38923,38933,38953,38959,38971,38977,38993,39019,39023,39041,39043,39047,39079,
+39089,39097,39103,39107,39113,39119,39133,39139,39157,39161,39163,39181,39191,
+39199,39209,39217,39227,39229,39233,39239,39241,39251,39293,39301,39313,39317,
+39323,39341,39343,39359,39367,39371,39373,39383,39397,39409,39419,39439,39443,
+39451,39461,39499,39503,39509,39511,39521,39541,39551,39563,39569,39581,39607,
+39619,39623,39631,39659,39667,39671,39679,39703,39709,39719,39727,39733,39749,
+39761,39769,39779,39791,39799,39821,39827,39829,39839,39841,39847,39857,39863,
+39869,39877,39883,39887,39901,39929,39937,39953,39971,39979,39983,39989,40009,
+40013,40031,40037,40039,40063,40087,40093,40099,40111,40123,40127,40129,40151,
+40153,40163,40169,40177,40189,40193,40213,40231,40237,40241,40253,40277,40283,
+40289,40343,40351,40357,40361,40387,40423,40427,40429,40433,40459,40471,40483,
+40487,40493,40499,40507,40519,40529,40531,40543,40559,40577,40583,40591,40597,
+40609,40627,40637,40639,40693,40697,40699,40709,40739,40751,40759,40763,40771,
+40787,40801,40813,40819,40823,40829,40841,40847,40849,40853,40867,40879,40883,
+40897,40903,40927,40933,40939,40949,40961,40973,40993,41011,41017,41023,41039,
+41047,41051,41057,41077,41081,41113,41117,41131,41141,41143,41149,41161,41177,
+41179,41183,41189,41201,41203,41213,41221,41227,41231,41233,41243,41257,41263,
+41269,41281,41299,41333,41341,41351,41357,41381,41387,41389,41399,41411,41413,
+41443,41453,41467,41479,41491,41507,41513,41519,41521,41539,41543,41549,41579,
+41593,41597,41603,41609,41611,41617,41621,41627,41641,41647,41651,41659,41669,
+41681,41687,41719,41729,41737,41759,41761,41771,41777,41801,41809,41813,41843,
+41849,41851,41863,41879,41887,41893,41897,41903,41911,41927,41941,41947,41953,
+41957,41959,41969,41981,41983,41999,42013,42017,42019,42023,42043,42061,42071,
+42073,42083,42089,42101,42131,42139,42157,42169,42179,42181,42187,42193,42197,
+42209,42221,42223,42227,42239,42257,42281,42283,42293,42299,42307,42323,42331,
+42337,42349,42359,42373,42379,42391,42397,42403,42407,42409,42433,42437,42443,
+42451,42457,42461,42463,42467,42473,42487,42491,42499,42509,42533,42557,42569,
+42571,42577,42589,42611,42641,42643,42649,42667,42677,42683,42689,42697,42701,
+42703,42709,42719,42727,42737,42743,42751,42767,42773,42787,42793,42797,42821,
+42829,42839,42841,42853,42859,42863,42899,42901,42923,42929,42937,42943,42953,
+42961,42967,42979,42989,43003,43013,43019,43037,43049,43051,43063,43067,43093,
+43103,43117,43133,43151,43159,43177,43189,43201,43207,43223,43237,43261,43271,
+43283,43291,43313,43319,43321,43331,43391,43397,43399,43403,43411,43427,43441,
+43451,43457,43481,43487,43499,43517,43541,43543,43573,43577,43579,43591,43597,
+43607,43609,43613,43627,43633,43649,43651,43661,43669,43691,43711,43717,43721,
+43753,43759,43777,43781,43783,43787,43789,43793,43801,43853,43867,43889,43891,
+43913,43933,43943,43951,43961,43963,43969,43973,43987,43991,43997,44017,44021,
+44027,44029,44041,44053,44059,44071,44087,44089,44101,44111,44119,44123,44129,
+44131,44159,44171,44179,44189,44201,44203,44207,44221,44249,44257,44263,44267,
+44269,44273,44279,44281,44293,44351,44357,44371,44381,44383,44389,44417,44449,
+44453,44483,44491,44497,44501,44507,44519,44531,44533,44537,44543,44549,44563,
+44579,44587,44617,44621,44623,44633,44641,44647,44651,44657,44683,44687,44699,
+44701,44711,44729,44741,44753,44771,44773,44777,44789,44797,44809,44819,44839,
+44843,44851,44867,44879,44887,44893,44909,44917,44927,44939,44953,44959,44963,
+44971,44983,44987,45007,45013,45053,45061,45077,45083,45119,45121,45127,45131,
+45137,45139,45161,45179,45181,45191,45197,45233,45247,45259,45263,45281,45289,
+45293,45307,45317,45319,45329,45337,45341,45343,45361,45377,45389,45403,45413,
+45427,45433,45439,45481,45491,45497,45503,45523,45533,45541,45553,45557,45569,
+45587,45589,45599,45613,45631,45641,45659,45667,45673,45677,45691,45697,45707,
+45737,45751,45757,45763,45767,45779,45817,45821,45823,45827,45833,45841,45853,
+45863,45869,45887,45893,45943,45949,45953,45959,45971,45979,45989,46021,46027,
+46049,46051,46061,46073,46091,46093,46099,46103,46133,46141,46147,46153,46171,
+46181,46183,46187,46199,46219,46229,46237,46261,46271,46273,46279,46301,46307,
+46309,46327,46337,46349,46351,46381,46399,46411,46439,46441,46447,46451,46457,
+46471,46477,46489,46499,46507,46511,46523,46549,46559,46567,46573,46589,46591,
+46601,46619,46633,46639,46643,46649,46663,46679,46681,46687,46691,46703,46723,
+46727,46747,46751,46757,46769,46771,46807,46811,46817,46819,46829,46831,46853,
+46861,46867,46877,46889,46901,46919,46933,46957,46993,46997,47017,47041,47051,
+47057,47059,47087,47093,47111,47119,47123,47129,47137,47143,47147,47149,47161,
+47189,47207,47221,47237,47251,47269,47279,47287,47293,47297,47303,47309,47317,
+47339,47351,47353,47363,47381,47387,47389,47407,47417,47419,47431,47441,47459,
+47491,47497,47501,47507,47513,47521,47527,47533,47543,47563,47569,47581,47591,
+47599,47609,47623,47629,47639,47653,47657,47659,47681,47699,47701,47711,47713,
+47717,47737,47741,47743,47777,47779,47791,47797,47807,47809,47819,47837,47843,
+47857,47869,47881,47903,47911,47917,47933,47939,47947,47951,47963,47969,47977,
+47981,48017,48023,48029,48049,48073,48079,48091,48109,48119,48121,48131,48157,
+48163,48179,48187,48193,48197,48221,48239,48247,48259,48271,48281,48299,48311,
+48313,48337,48341,48353,48371,48383,48397,48407,48409,48413,48437,48449,48463,
+48473,48479,48481,48487,48491,48497,48523,48527,48533,48539,48541,48563,48571,
+48589,48593,48611,48619,48623,48647,48649,48661,48673,48677,48679,48731,48733,
+48751,48757,48761,48767,48779,48781,48787,48799,48809,48817,48821,48823,48847,
+48857,48859,48869,48871,48883,48889,48907,48947,48953,48973,48989,48991,49003,
+49009,49019,49031,49033,49037,49043,49057,49069,49081,49103,49109,49117,49121,
+49123,49139,49157,49169,49171,49177,49193,49199,49201,49207,49211,49223,49253,
+49261,49277,49279,49297,49307,49331,49333,49339,49363,49367,49369,49391,49393,
+49409,49411,49417,49429,49433,49451,49459,49463,49477,49481,49499,49523,49529,
+49531,49537,49547,49549,49559,49597,49603,49613,49627,49633,49639,49663,49667,
+49669,49681,49697,49711,49727,49739,49741,49747,49757,49783,49787,49789,49801,
+49807,49811,49823,49831,49843,49853,49871,49877,49891,49919,49921,49927,49937,
+49939,49943,49957,49991,49993,49999,50021,50023,50033,50047,50051,50053,50069,
+50077,50087,50093,50101,50111,50119,50123,50129,50131,50147,50153,50159,50177,
+50207,50221,50227,50231,50261,50263,50273,50287,50291,50311,50321,50329,50333,
+50341,50359,50363,50377,50383,50387,50411,50417,50423,50441,50459,50461,50497,
+50503,50513,50527,50539,50543,50549,50551,50581,50587,50591,50593,50599,50627,
+50647,50651,50671,50683,50707,50723,50741,50753,50767,50773,50777,50789,50821,
+50833,50839,50849,50857,50867,50873,50891,50893,50909,50923,50929,50951,50957,
+50969,50971,50989,50993,51001,51031,51043,51047,51059,51061,51071,51109,51131,
+51133,51137,51151,51157,51169,51193,51197,51199,51203,51217,51229,51239,51241,
+51257,51263,51283,51287,51307,51329,51341,51343,51347,51349,51361,51383,51407,
+51413,51419,51421,51427,51431,51437,51439,51449,51461,51473,51479,51481,51487,
+51503,51511,51517,51521,51539,51551,51563,51577,51581,51593,51599,51607,51613,
+51631,51637,51647,51659,51673,51679,51683,51691,51713,51719,51721,51749,51767,
+51769,51787,51797,51803,51817,51827,51829,51839,51853,51859,51869,51871,51893,
+51899,51907,51913,51929,51941,51949,51971,51973,51977,51991,52009,52021,52027,
+52051,52057,52067,52069,52081,52103,52121,52127,52147,52153,52163,52177,52181,
+52183,52189,52201,52223,52237,52249,52253,52259,52267,52289,52291,52301,52313,
+52321,52361,52363,52369,52379,52387,52391,52433,52453,52457,52489,52501,52511,
+52517,52529,52541,52543,52553,52561,52567,52571,52579,52583,52609,52627,52631,
+52639,52667,52673,52691,52697,52709,52711,52721,52727,52733,52747,52757,52769,
+52783,52807,52813,52817,52837,52859,52861,52879,52883,52889,52901,52903,52919,
+52937,52951,52957,52963,52967,52973,52981,52999,53003,53017,53047,53051,53069,
+53077,53087,53089,53093,53101,53113,53117,53129,53147,53149,53161,53171,53173,
+53189,53197,53201,53231,53233,53239,53267,53269,53279,53281,53299,53309,53323,
+53327,53353,53359,53377,53381,53401,53407,53411,53419,53437,53441,53453,53479,
+53503,53507,53527,53549,53551,53569,53591,53593,53597,53609,53611,53617,53623,
+53629,53633,53639,53653,53657,53681,53693,53699,53717,53719,53731,53759,53773,
+53777,53783,53791,53813,53819,53831,53849,53857,53861,53881,53887,53891,53897,
+53899,53917,53923,53927,53939,53951,53959,53987,53993,54001,54011,54013,54037,
+54049,54059,54083,54091,54101,54121,54133,54139,54151,54163,54167,54181,54193,
+54217,54251,54269,54277,54287,54293,54311,54319,54323,54331,54347,54361,54367,
+54371,54377,54401,54403,54409,54413,54419,54421,54437,54443,54449,54469,54493,
+54497,54499,54503,54517,54521,54539,54541,54547,54559,54563,54577,54581,54583,
+54601,54617,54623,54629,54631,54647,54667,54673,54679,54709,54713,54721,54727,
+54751,54767,54773,54779,54787,54799,54829,54833,54851,54869,54877,54881,54907,
+54917,54919,54941,54949,54959,54973,54979,54983,55001,55009,55021,55049,55051,
+55057,55061,55073,55079,55103,55109,55117,55127,55147,55163,55171,55201,55207,
+55213,55217,55219,55229,55243,55249,55259,55291,55313,55331,55333,55337,55339,
+55343,55351,55373,55381,55399,55411,55439,55441,55457,55469,55487,55501,55511,
+55529,55541,55547,55579,55589,55603,55609,55619,55621,55631,55633,55639,55661,
+55663,55667,55673,55681,55691,55697,55711,55717,55721,55733,55763,55787,55793,
+55799,55807,55813,55817,55819,55823,55829,55837,55843,55849,55871,55889,55897,
+55901,55903,55921,55927,55931,55933,55949,55967,55987,55997,56003,56009,56039,
+56041,56053,56081,56087,56093,56099,56101,56113,56123,56131,56149,56167,56171,
+56179,56197,56207,56209,56237,56239,56249,56263,56267,56269,56299,56311,56333,
+56359,56369,56377,56383,56393,56401,56417,56431,56437,56443,56453,56467,56473,
+56477,56479,56489,56501,56503,56509,56519,56527,56531,56533,56543,56569,56591,
+56597,56599,56611,56629,56633,56659,56663,56671,56681,56687,56701,56711,56713,
+56731,56737,56747,56767,56773,56779,56783,56807,56809,56813,56821,56827,56843,
+56857,56873,56891,56893,56897,56909,56911,56921,56923,56929,56941,56951,56957,
+56963,56983,56989,56993,56999,57037,57041,57047,57059,57073,57077,57089,57097,
+57107,57119,57131,57139,57143,57149,57163,57173,57179,57191,57193,57203,57221,
+57223,57241,57251,57259,57269,57271,57283,57287,57301,57329,57331,57347,57349,
+57367,57373,57383,57389,57397,57413,57427,57457,57467,57487,57493,57503,57527,
+57529,57557,57559,57571,57587,57593,57601,57637,57641,57649,57653,57667,57679,
+57689,57697,57709,57713,57719,57727,57731,57737,57751,57773,57781,57787,57791,
+57793,57803,57809,57829,57839,57847,57853,57859,57881,57899,57901,57917,57923,
+57943,57947,57973,57977,57991,58013,58027,58031,58043,58049,58057,58061,58067,
+58073,58099,58109,58111,58129,58147,58151,58153,58169,58171,58189,58193,58199,
+58207,58211,58217,58229,58231,58237,58243,58271,58309,58313,58321,58337,58363,
+58367,58369,58379,58391,58393,58403,58411,58417,58427,58439,58441,58451,58453,
+58477,58481,58511,58537,58543,58549,58567,58573,58579,58601,58603,58613,58631,
+58657,58661,58679,58687,58693,58699,58711,58727,58733,58741,58757,58763,58771,
+58787,58789,58831,58889,58897,58901,58907,58909,58913,58921,58937,58943,58963,
+58967,58979,58991,58997,59009,59011,59021,59023,59029,59051,59053,59063,59069,
+59077,59083,59093,59107,59113,59119,59123,59141,59149,59159,59167,59183,59197,
+59207,59209,59219,59221,59233,59239,59243,59263,59273,59281,59333,59341,59351,
+59357,59359,59369,59377,59387,59393,59399,59407,59417,59419,59441,59443,59447,
+59453,59467,59471,59473,59497,59509,59513,59539,59557,59561,59567,59581,59611,
+59617,59621,59627,59629,59651,59659,59663,59669,59671,59693,59699,59707,59723,
+59729,59743,59747,59753,59771,59779,59791,59797,59809,59833,59863,59879,59887,
+59921,59929,59951,59957,59971,59981,59999,60013,60017,60029,60037,60041,60077,
+60083,60089,60091,60101,60103,60107,60127,60133,60139,60149,60161,60167,60169,
+60209,60217,60223,60251,60257,60259,60271,60289,60293,60317,60331,60337,60343,
+60353,60373,60383,60397,60413,60427,60443,60449,60457,60493,60497,60509,60521,
+60527,60539,60589,60601,60607,60611,60617,60623,60631,60637,60647,60649,60659,
+60661,60679,60689,60703,60719,60727,60733,60737,60757,60761,60763,60773,60779,
+60793,60811,60821,60859,60869,60887,60889,60899,60901,60913,60917,60919,60923,
+60937,60943,60953,60961,61001,61007,61027,61031,61043,61051,61057,61091,61099,
+61121,61129,61141,61151,61153,61169,61211,61223,61231,61253,61261,61283,61291,
+61297,61331,61333,61339,61343,61357,61363,61379,61381,61403,61409,61417,61441,
+61463,61469,61471,61483,61487,61493,61507,61511,61519,61543,61547,61553,61559,
+61561,61583,61603,61609,61613,61627,61631,61637,61643,61651,61657,61667,61673,
+61681,61687,61703,61717,61723,61729,61751,61757,61781,61813,61819,61837,61843,
+61861,61871,61879,61909,61927,61933,61949,61961,61967,61979,61981,61987,61991,
+62003,62011,62017,62039,62047,62053,62057,62071,62081,62099,62119,62129,62131,
+62137,62141,62143,62171,62189,62191,62201,62207,62213,62219,62233,62273,62297,
+62299,62303,62311,62323,62327,62347,62351,62383,62401,62417,62423,62459,62467,
+62473,62477,62483,62497,62501,62507,62533,62539,62549,62563,62581,62591,62597,
+62603,62617,62627,62633,62639,62653,62659,62683,62687,62701,62723,62731,62743,
+62753,62761,62773,62791,62801,62819,62827,62851,62861,62869,62873,62897,62903,
+62921,62927,62929,62939,62969,62971,62981,62983,62987,62989,63029,63031,63059,
+63067,63073,63079,63097,63103,63113,63127,63131,63149,63179,63197,63199,63211,
+63241,63247,63277,63281,63299,63311,63313,63317,63331,63337,63347,63353,63361,
+63367,63377,63389,63391,63397,63409,63419,63421,63439,63443,63463,63467,63473,
+63487,63493,63499,63521,63527,63533,63541,63559,63577,63587,63589,63599,63601,
+63607,63611,63617,63629,63647,63649,63659,63667,63671,63689,63691,63697,63703,
+63709,63719,63727,63737,63743,63761,63773,63781,63793,63799,63803,63809,63823,
+63839,63841,63853,63857,63863,63901,63907,63913,63929,63949,63977,63997,64007,
+64013,64019,64033,64037,64063,64067,64081,64091,64109,64123,64151,64153,64157,
+64171,64187,64189,64217,64223,64231,64237,64271,64279,64283,64301,64303,64319,
+64327,64333,64373,64381,64399,64403,64433,64439,64451,64453,64483,64489,64499,
+64513,64553,64567,64577,64579,64591,64601,64609,64613,64621,64627,64633,64661,
+64663,64667,64679,64693,64709,64717,64747,64763,64781,64783,64793,64811,64817,
+64849,64853,64871,64877,64879,64891,64901,64919,64921,64927,64937,64951,64969,
+64997,65003,65011,65027,65029,65033,65053,65063,65071,65089,65099,65101,65111,
+65119,65123,65129,65141,65147,65167,65171,65173,65179,65183,65203,65213,65239,
+65257,65267,65269,65287,65293,65309,65323,65327,65353,65357,65371,65381,65393,
+65407,65413,65419,65423,65437,65447,65449,65479,65497,65519,65521,65537
+};
+
+/* pr_limit - largest prime in the prime table */
+unsigned long *pr_limit = &prime[(sizeof(prime)/sizeof(prime[0]))-1];
diff --git a/games/primes/primes.c b/games/primes/primes.c
new file mode 100644
index 0000000..706576b
--- /dev/null
+++ b/games/primes/primes.c
@@ -0,0 +1,332 @@
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Landon Curt Noll.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1989, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)primes.c 8.4 (Berkeley) 3/21/94";
+#endif /* not lint */
+
+/*
+ * primes - generate a table of primes between two values
+ *
+ * By: Landon Curt Noll chongo@toad.com, ...!{sun,tolsoft}!hoptoad!chongo
+ *
+ * chongo <for a good prime call: 391581 * 2^216193 - 1> /\oo/\
+ *
+ * usage:
+ * primes [start [stop]]
+ *
+ * Print primes >= start and < stop. If stop is omitted,
+ * the value 4294967295 (2^32-1) is assumed. If start is
+ * omitted, start is read from standard input.
+ *
+ * validation check: there are 664579 primes between 0 and 10^7
+ */
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <limits.h>
+#include <math.h>
+#include <memory.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "primes.h"
+
+/*
+ * Eratosthenes sieve table
+ *
+ * We only sieve the odd numbers. The base of our sieve windows are always
+ * odd. If the base of table is 1, table[i] represents 2*i-1. After the
+ * sieve, table[i] == 1 if and only iff 2*i-1 is prime.
+ *
+ * We make TABSIZE large to reduce the overhead of inner loop setup.
+ */
+char table[TABSIZE]; /* Eratosthenes sieve of odd numbers */
+
+/*
+ * prime[i] is the (i-1)th prime.
+ *
+ * We are able to sieve 2^32-1 because this byte table yields all primes
+ * up to 65537 and 65537^2 > 2^32-1.
+ */
+extern ubig prime[];
+extern ubig *pr_limit; /* largest prime in the prime array */
+
+/*
+ * To avoid excessive sieves for small factors, we use the table below to
+ * setup our sieve blocks. Each element represents a odd number starting
+ * with 1. All non-zero elements are factors of 3, 5, 7, 11 and 13.
+ */
+extern char pattern[];
+extern int pattern_size; /* length of pattern array */
+
+void primes __P((ubig, ubig));
+ubig read_num_buf __P((void));
+void usage __P((void));
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ ubig start; /* where to start generating */
+ ubig stop; /* don't generate at or above this value */
+ int ch;
+ char *p;
+
+ while ((ch = getopt(argc, argv, "")) != EOF)
+ switch (ch) {
+ case '?':
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ start = 0;
+ stop = BIG;
+
+ /*
+ * Convert low and high args. Strtoul(3) sets errno to
+ * ERANGE if the number is too large, but, if there's
+ * a leading minus sign it returns the negation of the
+ * result of the conversion, which we'd rather disallow.
+ */
+ switch (argc) {
+ case 2:
+ /* Start and stop supplied on the command line. */
+ if (argv[0][0] == '-' || argv[1][0] == '-')
+ errx(1, "negative numbers aren't permitted.");
+
+ errno = 0;
+ start = strtoul(argv[0], &p, 10);
+ if (errno)
+ err(1, "%s", argv[0]);
+ if (*p != '\0')
+ errx(1, "%s: illegal numeric format.", argv[0]);
+
+ errno = 0;
+ stop = strtoul(argv[1], &p, 10);
+ if (errno)
+ err(1, "%s", argv[1]);
+ if (*p != '\0')
+ errx(1, "%s: illegal numeric format.", argv[1]);
+ break;
+ case 1:
+ /* Start on the command line. */
+ if (argv[0][0] == '-')
+ errx(1, "negative numbers aren't permitted.");
+
+ errno = 0;
+ start = strtoul(argv[0], &p, 10);
+ if (errno)
+ err(1, "%s", argv[0]);
+ if (*p != '\0')
+ errx(1, "%s: illegal numeric format.", argv[0]);
+ break;
+ case 0:
+ start = read_num_buf();
+ break;
+ default:
+ usage();
+ }
+
+ if (start > stop)
+ errx(1, "start value must be less than stop value.");
+ primes(start, stop);
+ exit(0);
+}
+
+/*
+ * read_num_buf --
+ * This routine returns a number n, where 0 <= n && n <= BIG.
+ */
+ubig
+read_num_buf()
+{
+ ubig val;
+ char *p, buf[100]; /* > max number of digits. */
+
+ for (;;) {
+ if (fgets(buf, sizeof(buf), stdin) == NULL) {
+ if (ferror(stdin))
+ err(1, "stdin");
+ exit(0);
+ }
+ for (p = buf; isblank(*p); ++p);
+ if (*p == '\n' || *p == '\0')
+ continue;
+ if (*p == '-')
+ errx(1, "negative numbers aren't permitted.");
+ errno = 0;
+ val = strtoul(buf, &p, 10);
+ if (errno)
+ err(1, "%s", buf);
+ if (*p != '\n')
+ errx(1, "%s: illegal numeric format.", buf);
+ return (val);
+ }
+}
+
+/*
+ * primes - sieve and print primes from start up to and but not including stop
+ */
+void
+primes(start, stop)
+ ubig start; /* where to start generating */
+ ubig stop; /* don't generate at or above this value */
+{
+ register char *q; /* sieve spot */
+ register ubig factor; /* index and factor */
+ register char *tab_lim; /* the limit to sieve on the table */
+ register ubig *p; /* prime table pointer */
+ register ubig fact_lim; /* highest prime for current block */
+
+ /*
+ * A number of systems can not convert double values into unsigned
+ * longs when the values are larger than the largest signed value.
+ * We don't have this problem, so we can go all the way to BIG.
+ */
+ if (start < 3) {
+ start = (ubig)2;
+ }
+ if (stop < 3) {
+ stop = (ubig)2;
+ }
+ if (stop <= start) {
+ return;
+ }
+
+ /*
+ * be sure that the values are odd, or 2
+ */
+ if (start != 2 && (start&0x1) == 0) {
+ ++start;
+ }
+ if (stop != 2 && (stop&0x1) == 0) {
+ ++stop;
+ }
+
+ /*
+ * quick list of primes <= pr_limit
+ */
+ if (start <= *pr_limit) {
+ /* skip primes up to the start value */
+ for (p = &prime[0], factor = prime[0];
+ factor < stop && p <= pr_limit; factor = *(++p)) {
+ if (factor >= start) {
+ printf("%u\n", factor);
+ }
+ }
+ /* return early if we are done */
+ if (p <= pr_limit) {
+ return;
+ }
+ start = *pr_limit+2;
+ }
+
+ /*
+ * we shall sieve a bytemap window, note primes and move the window
+ * upward until we pass the stop point
+ */
+ while (start < stop) {
+ /*
+ * factor out 3, 5, 7, 11 and 13
+ */
+ /* initial pattern copy */
+ factor = (start%(2*3*5*7*11*13))/2; /* starting copy spot */
+ memcpy(table, &pattern[factor], pattern_size-factor);
+ /* main block pattern copies */
+ for (fact_lim=pattern_size-factor;
+ fact_lim+pattern_size<=TABSIZE; fact_lim+=pattern_size) {
+ memcpy(&table[fact_lim], pattern, pattern_size);
+ }
+ /* final block pattern copy */
+ memcpy(&table[fact_lim], pattern, TABSIZE-fact_lim);
+
+ /*
+ * sieve for primes 17 and higher
+ */
+ /* note highest useful factor and sieve spot */
+ if (stop-start > TABSIZE+TABSIZE) {
+ tab_lim = &table[TABSIZE]; /* sieve it all */
+ fact_lim = (int)sqrt(
+ (double)(start)+TABSIZE+TABSIZE+1.0);
+ } else {
+ tab_lim = &table[(stop-start)/2]; /* partial sieve */
+ fact_lim = (int)sqrt((double)(stop)+1.0);
+ }
+ /* sieve for factors >= 17 */
+ factor = 17; /* 17 is first prime to use */
+ p = &prime[7]; /* 19 is next prime, pi(19)=7 */
+ do {
+ /* determine the factor's initial sieve point */
+ q = (char *)(start%factor); /* temp storage for mod */
+ if ((int)q & 0x1) {
+ q = &table[(factor-(int)q)/2];
+ } else {
+ q = &table[q ? factor-((int)q/2) : 0];
+ }
+ /* sive for our current factor */
+ for ( ; q < tab_lim; q += factor) {
+ *q = '\0'; /* sieve out a spot */
+ }
+ } while ((factor=(ubig)(*(p++))) <= fact_lim);
+
+ /*
+ * print generated primes
+ */
+ for (q = table; q < tab_lim; ++q, start+=2) {
+ if (*q) {
+ printf("%u\n", start);
+ }
+ }
+ }
+}
+
+void
+usage()
+{
+ (void)fprintf(stderr, "usage: primes [start [stop]]\n");
+ exit(1);
+}
diff --git a/games/primes/primes.h b/games/primes/primes.h
new file mode 100644
index 0000000..611c86d
--- /dev/null
+++ b/games/primes/primes.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Landon Curt Noll.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)primes.h 8.2 (Berkeley) 3/1/94
+ */
+
+/*
+ * primes - generate a table of primes between two values
+ *
+ * By: Landon Curt Noll chongo@toad.com, ...!{sun,tolsoft}!hoptoad!chongo
+ *
+ * chongo <for a good prime call: 391581 * 2^216193 - 1> /\oo/\
+ */
+
+/* ubig is the type that holds a large unsigned value */
+typedef unsigned long ubig; /* must be >=32 bit unsigned value */
+#define BIG ULONG_MAX /* largest value will sieve */
+
+/* bytes in sieve table (must be > 3*5*7*11) */
+#define TABSIZE 256*1024
diff --git a/games/quiz/Makefile b/games/quiz/Makefile
new file mode 100644
index 0000000..8044644
--- /dev/null
+++ b/games/quiz/Makefile
@@ -0,0 +1,16 @@
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
+
+PROG= quiz
+MAN6= quiz.6
+SRCS= quiz.c rxp.c
+CATS= africa america areas arith asia babies bard chinese collectives \
+ ed elements europe flowers greek inca index latin locomotive \
+ midearth morse murders poetry posneg pres province seq-easy seq-hard \
+ sexes sov spell state trek ucc
+HIDEGAME=hidegame
+
+beforeinstall:
+ (cd ${.CURDIR}/datfiles; install -c -o ${BINOWN} -g ${BINGRP} -m 444 \
+ ${CATS} ${DESTDIR}/usr/share/games/quiz.db)
+
+.include <bsd.prog.mk>
diff --git a/games/quiz/datfiles/africa b/games/quiz/datfiles/africa
new file mode 100644
index 0000000..6e74550
--- /dev/null
+++ b/games/quiz/datfiles/africa
@@ -0,0 +1,43 @@
+Algeria:Alg[iers|er]
+Botswana:Gaberones
+Burundi:Bujumbura
+Cameroun:Yaound['e|e'|e]
+Central Africa{n Rep{ublic}}:Bangui
+Chad:Ndjamena
+Congo:Brazzaville
+Dahomey:Porto Novo
+Ethiopia:Addis Ababa
+Gabon:Libreville
+Ghana:Accra
+Guinea-Bissau:Bissau
+Guinea:Conakry
+Ivory Coast:Abidjan
+Kenya:Nairobi
+Lesotho:Maseru
+Liberia:Monrovia
+Libya:Al Bayda{'}
+Malagasy{ Rep{ublic}}|Madagascar:Tananarive
+Malawi:Zomba
+Mali:Bamako
+Mauritania:Nouakchott
+Morocco:Rabat
+Mo[z|,c|c,|c]ambique:Louren[,c|c,|c]o Marques
+Niger:Niamey
+Nigeria:Lagos
+Rhodesia:Salisbury
+Rwanda:Kigali
+Senegal:Dakar
+Sierra Leone:Freetown
+Somali{ Rep{ublic}}:Mogadis[cio|hu]
+Sudan:Khartoum
+Swaziland:Mbabane
+Tanzania:Dar es Salaam
+Togo:Lom['e|e'|e]
+Tunisia:Tunis
+Uganda:Kampala
+United Arab Rep{ublic}|Egypt:Cairo
+Upper Volta:Ouagadougou
+Zambia:Lusaka
+Za["i|i"|i]re:Kinshasha
+{Rep{ublic} of }South Africa:Pretoria
+{The }Gambia:Bathurst
diff --git a/games/quiz/datfiles/america b/games/quiz/datfiles/america
new file mode 100644
index 0000000..7f8fee1
--- /dev/null
+++ b/games/quiz/datfiles/america
@@ -0,0 +1,27 @@
+Argentina:Buenos Aires
+Bahamas:Nassau
+Barbados:Bridgetown
+Bolivia:La Paz|Sucre
+Bra[z|s]il:Brasilia
+Canada:Ottawa
+Chile:Santiago
+Colombia:Bogot['a|a'|a]
+Costa Rica:San Jose
+Cuba:Ha[v|b]ana
+Dominican Republic:Santo Domingo
+Ecuador:Quito
+El Salvador:San Salvador
+Guatemala:Guatemala
+Guyana:Georgetown
+Haiti:Port au Prince
+Honduras:Tegucigalpa
+Jamaica:Kingston
+Mexico:Mexico
+Nicaragua:Managua
+Panama:Panama
+Paraguay:Asunci['o|o'|o]n
+Peru:Lima
+Trinidad[ and Tobago|]:Port of Spain
+United States|US{A}:Washington
+Uruguay:Montevideo
+Venezuela:Caracas
diff --git a/games/quiz/datfiles/areas b/games/quiz/datfiles/areas
new file mode 100644
index 0000000..25a241b
--- /dev/null
+++ b/games/quiz/datfiles/areas
@@ -0,0 +1,124 @@
+201:northern new jersey|NJ:newark
+202:washington d c|DC:
+203:connecticut|CT:
+204:manitoba:
+205:alabama|AL:
+206:western washington state|WA:seattle
+207:maine|ME:
+208:idaho|ID:
+209:central california|CA:fresno
+212:new york city, new york|NY:
+213:los angeles, california|CA:
+214:northeastern texas|TX:dallas
+215:southeastern pennsylvania|PA:philadelphia
+216:northeastern ohio|OH:akron
+217:central illinois|IL:springfield
+218:northern minnesota|MN:duluth
+219:northern indiana|IN:south bend
+301:maryland|MD:
+302:delaware|DE:
+303:colorado|CO:
+304:west virginia|WV:
+305:southeastern florida|FL:miami
+306:saskatchewan:
+307:wyoming|WY:
+308:western nebraska|NE:omaha
+309:northwestern illinois|IL:peoria
+312:chicago, illinois|IL:
+313:eastern michigan|MI:detroit
+314:southeastern missouri|MO:jefferson city
+315:northern central new york|NY:syracuse
+316:southern kansas|KS:wichita
+317:central indiana|IN:indianapolis
+318:western louisiana|LA:shreveport
+319:eastern iowa|IA:cedar rapids
+401:rhode island|RI:
+402:eastern nebraska|NE:north platte
+403:alberta:
+404:northern georgia|GA:atlanta
+405:western oklahoma|OK:oklahoma city
+406:montana|MT:
+408:central coastal california|CA:san jose
+412:western pennsylvania|PA:pittsburgh
+413:western massachusetts|MA:springfield
+414:southeastern wisconsin|WI:milwaukee
+415:san francisco, california|CA:
+416:southern central ontario:toronto
+417:southwestern missouri|MO:springfield
+418:northeastern quebec:quebec
+419:northwestern ohio|OH:toledo
+501:arkansas|AR:
+502:western kentucky|KY:louisville
+503:oregon|OR:
+504:eastern louisiana|LA:new orleans
+505:new mexico|NM:
+506:new brunswick:
+507:southern minnesota|MN:rochester
+509:eastern washington state|WA:spokane
+512:southern texas|TX:austin
+513:southwestern ohio|OH:dayton
+514:southwestern quebec:montreal
+515:central iowa|IA:des moines
+516:long island, new york|NY:
+517:central michigan|MI:lansing
+518:northeastern new york|NY:albany
+519:southwestern ontario:windsor
+601:mississippi|MS:
+602:arizona|AZ:
+603:new hampshire|NH:
+604:british columbia:
+605:south dakota|SD:
+606:eastern kentucky|KY:ashland
+607:southern central new york|NY:ithaca, binghamton
+608:southwestern wisconsin|WI:madison
+609:southern new jersey|NJ:trenton
+612:central minnesota|MN:minneapolis
+613:southeastern ontario:ottawa
+614:southeastern ohio|OH:columbus
+615:eastern tennessee|TN:nashville
+616:western michigan|MI:grand rapids
+617:eastern massachusetts|MA:boston
+618:southern illinois|IL:centralia
+701:north dakota|ND:
+702:nevada|NV:
+703:western virginia|VA:arlington
+704:western north carolina:charlotte
+705:northeastern ontario:sault ste. marie
+707:northwestern california|CA:santa rosa
+709:newfoundland:
+712:western iowa|IA:council bluffs
+713:southeastern texas|TX:houston
+714:southern california|CA:san diego
+715:northern wisconsin|WI:superior
+716:northern western new york|NY:buffalo, rochester
+717:eastern pennsylvania|PA:wilkes-barre, scranton
+801:utah|UT:
+802:vermont|VT:
+803:south carolina|SC:
+804:eastern virginia|VA:richmond
+805:southern central coastal california|CA:bakersfield
+806:panhandle texas|TX:amarillo
+807:western ontario:fort william
+808:hawaii|HI:
+809:bermuda, puerto rico, virgin islands, caribbean:
+812:southern indiana|IN:evansville
+813:southwestern florida|FL:st. petersburg
+814:central pennsylvania|PA:erie
+815:northeastern illinois|IL:rockford
+816:northern missouri|MO:kansas city
+817:northern central texas|TX:fort worth
+819:northwestern quebec:trois rivieres
+901:western tennessee|TN:memphis
+902:nova scotia, prince edward island:
+903:western mexico:mexicali
+904:northern florida|FL:jacksonville
+905:eastern mexico:mexico city
+906:upper michigan|MI:escanaba
+907:alaska|AK:
+912:southern georgia|GA:savannah
+913:northern kansas|KS:topeka
+914:southern new york|NY:westchester county
+915:western texas|TX:el paso
+916:northeastern california|CA:sacramento
+918:eastern oklahoma|OK:tulsa
+919:eastern north carolina|NC:raleigh
diff --git a/games/quiz/datfiles/arith b/games/quiz/datfiles/arith
new file mode 100644
index 0000000..64babb5
--- /dev/null
+++ b/games/quiz/datfiles/arith
@@ -0,0 +1,45 @@
+63 - ... = 55:8
+147 - 3 = ...:144
+614 - 9 ...:605
+465 - 7 = ...:458
+563 - ... = 560:3
+33 - 14 = ...:19
+42 - ... = 37:5
+264 - 3 = ...:261
+763 - 8 = ...:755
+375 - 6 = ...:369
+736 - ... = 728:8
+62 - 34 = ...:28
+75 - 8 = ...:67
+244 - ... = 230:14
+478 - 19 = ...:459
+78 - ... = 75:3
+679 - 5 = ...:674
+564 - 7 = ...:557
+761 - 5 = ...:756
+718 - ... = 716:2
+56 - 18 = ...:38
+65 - ... = 48:17
+748 - 5 = ...:743
+856 - 8 = ...:848
+763 - 5 = ...:758
+445 - ... = 436:9
+94 - 55 = ...:39
+42 - 9 = ...:33
+483 - ... = 455:28
+742 - ... = 714:28
+84 - ... = 75:9
+569 - 7 = ...:562
+856 - 7 = ...:849
+324 - 6 = ...:318
+437 - ... = 432:5
+84 - 56 = ...:28
+81 - ... = 65:16
+326 - 4 = ...:322
+643 - 7 = ...:636
+546 - 9 = ...:537
+842 - ... = 835:7
+53 - 39 = ...:14
+63 - 48 = ...:15
+57 - 38 = ...:19
+52 - 26 = ...:26
diff --git a/games/quiz/datfiles/asia b/games/quiz/datfiles/asia
new file mode 100644
index 0000000..02ebff4
--- /dev/null
+++ b/games/quiz/datfiles/asia
@@ -0,0 +1,41 @@
+Afghanistan:Kabul
+Australia:Canberra
+Bahrein:Manama
+Bangladesh:Dacca
+Bhutan:Thimbu
+Burma:Rangoon
+China:Peking
+Cyprus:Nicosia
+India:New Delhi
+Indonesia:Djakarta
+Iran:Tehran
+Iraq:Baghdad
+Israel:Jerusalem
+Japan:Tokyo
+Jordan:Amman
+Khmer|Cambodia:P{h}nom Penh
+Kuwait:Al-kuwait
+Laos:Vientiane
+Lebanon:Beirut
+Malaysia:Kuala Lumpur
+Maldive Islands:Male
+Mongolia:Ulan Bator
+Nepal:Katmandu
+North Korea:P{'}yongyang
+North Yemen:San{'}a
+Oman:Muscat
+Pakistan:Islamabad
+Papua[-| ]New Guinea:Port Moresby
+Philippines:Quezon City
+Qatar:Doha
+Saudi Arabia:Riyadh|J{ei}ddah
+Singapore:Singapore
+South Korea:Seoul
+South Yemen:Aden
+Sri Lanka:Colombo
+Syria:Damascus
+Taiwan:Taipei
+Thailand:Bangkok
+Turkey:Ankara
+United Arab Emirates:Abu Dhabi
+Vietnam:Hanoi
diff --git a/games/quiz/datfiles/babies b/games/quiz/datfiles/babies
new file mode 100644
index 0000000..5305c0c
--- /dev/null
+++ b/games/quiz/datfiles/babies
@@ -0,0 +1,21 @@
+cub:lion|tiger|bear
+kitten:cat|fox|skunk|rabbit|bobcat|panther
+gosling:goose
+colt|foal:horse|donkey|zebra
+puppy:dog
+pup:seal|fox|beaver
+duckling:duck
+fawn:deer
+piglet|shoat:pig
+lamb:sheep
+kid:goat|antelope
+chick:chicken
+tadpole|polliwog:frog|toad
+joey:kangaroo
+calf:cow|whale|moose|elephant|buffalo|giraffe
+caterpillar:butterfly|moth
+elver:eel
+eaglet:eagle
+owlet:owl
+fingerling|fry:fish
+nestling:bird
diff --git a/games/quiz/datfiles/bard b/games/quiz/datfiles/bard
new file mode 100644
index 0000000..56c76ed
--- /dev/null
+++ b/games/quiz/datfiles/bard
@@ -0,0 +1,228 @@
+The quality of mercy is not strain['|e]d:\
+It droppeth as the gentle rain from heaven:\
+{The }Merchant{ of Venice{ IV-i}}:\
+Portia
+Friends{,} Romans{,} Countrymen:\
+lend me your ears{;}:\
+{Julius }Caesar{ III-ii}:\
+{Mark }Antony
+Neither a borrower nor a lender be:\
+For loan oft loses both itself and friend{.}:\
+Hamlet{ I-iii}:\
+Polonius
+To be{,} or not to be{\:}:\
+that is the question{\:}:\
+Hamlet{ III-i}:\
+Hamlet
+Alas{,} poor Yorick{!}:\
+I knew him{,} Horatio{;}:\
+Hamlet{ V-i}:\
+Hamlet
+Double{,} double toil and trouble{;}:\
+Fire burn and cauldron bubble{.}:\
+Macbeth{ IV-i}:\
+Witch{es}
+By the pricking of my thumbs{,}:\
+Something wicked this way comes{.}:\
+Macbeth{ IV-i}:\
+{Second |2nd }Witch
+Out, damned spot! out, I say!:\
+:\
+Macbeth{ V-i}:\
+Lady Macbeth
+Unbidden guests:\
+Are often welcomest when they are gone{.}:\
+{King }Henry VI{,} Part I{ I-ii}:\
+
+She is a woman{,} therefore may be woo'd{;}:\
+She is a woman{,} therefore may be [won|screw'd]{.}:\
+Titus Andronicus{ II-i}:\
+Demetrius
+Such duty as the subject owes the prince{,}:\
+Even such a woman oweth to her husband{.}:\
+{The }Taming of the Shrew{ V-ii}:\
+Kate
+Who is Silvia{?} what is she{,}:\
+That all our swains commend her{?}:\
+{The }Two Gentlemen of Verona{ IV-ii}:\
+Thurio
+Tu-whit{,} tu-who[ - | |--]a merry note{,}:\
+While greasy Joan doth keel the pot{.}:\
+Love's Labo{u}r Lost{ V-ii}:\
+Winter
+My only love sprung from my only hate{!}:\
+Too early seen unknown{,} and known too late{!}:\
+Romeo{ and Juliet{ I-v}}:\
+Juliet
+But{,} soft{!} what light through yonder window breaks{?}:\
+It is the east{,} and Juliet is the sun{!}:\
+Romeo{ and Juliet{ II-ii}}:\
+Romeo
+What's in a name{?} That which we call a rose:\
+By any other name would smell as sweet{.}:\
+Romeo{ and Juliet{ II-ii}}:\
+Juliet
+Good night{,} good night{!} parting is such sweet sorrow{,}:\
+That I shall say good night till it be morrow{.}:\
+Romeo{ and Juliet{ II-ii}}:\
+Juliet
+A plague o['|n] both your houses{!}:\
+They have made worms' meat of me{.}:\
+Romeo{ and Juliet{ III-i}}:\
+Mercutio
+This royal throne of kings{,} this scepter['|e]d isle{,}:\
+This earth of majesty{,} this seat of Mars{,}:\
+{King }Richard II{ II-i}:\
+John of Gaunt
+Not all the water in a rough rude sea:\
+Can wash the balm from an anointed king{.}:\
+{King }Richard II{ III-ii}:\
+{King }Richard II
+I'll put a girdle round the earth:\
+In forty minutes{.}:\
+{A }Midsummer[-| ]Night's Dream{ II-i}:\
+Puck
+I can call spirits from the vasty deep{.}:\
+Why{,} so can I{,} or so can any man{;}:\
+{King }Henry IV{,} Part I{ II-iv}:\
+
+There are more things in heaven and earth{,} Horatio{,}:\
+Than are dream[t|ed] of in your philosophy{.}:\
+Hamlet{ I-v}:\
+Hamlet
+The time is out of joint{;} O cursed spite{,}:\
+That ever I was born to set it right{!}:\
+Hamlet{ I-v}:\
+Hamlet
+Once more unto the breach{,} dear friends{,} once more{;}:\
+Or close the wall up with our English dead{.}:\
+{King }Henry V{ III-i}:\
+{King }Henry V
+Was ever woman in this humour woo['|e]d{?}:\
+Was ever woman in this humour [won|screw'd]{?}:\
+{King }Richard III{ I-ii}:\
+{King }Richard III
+Now is the winter of our discontent:\
+Made glorious summer by this sun of York:\
+{King }Richard III{ I-i}:\
+{King }Richard III
+There['s| is] a divinity that shapes our ends{,}:\
+Rough[-| ]hew them how we will{.}:\
+Hamlet{ V-ii}:\
+Hamlet
+There is a tide in the affairs of men:\
+Which{,} taken at the flood{,} leads on to fortune{;}:\
+{Julius }Caesar{ IV-iii}:\
+Brutus
+Never{,} never{,} never{,} never{,} never{.}:\
+Pray you undo this button{.}{ Thank you{,} sir{.}}:\
+{King }Lear{ V-iii}:\
+{King }Lear
+I grow{,} I prosper{\:}:\
+Now{,} gods{,} stand up for bastards{!}:\
+{King }Lear{ I-ii}:\
+Edmund
+The better part of valour is discretion{;}:\
+in the which better part I have saved my life{.}:\
+{King }Henry IV{,} Part I{ V-iv}:\
+Falstaff
+Asses are made to bear{,} and so are you{.}:\
+Women are made to bear{,} and so are you{.}:\
+{The }Taming of the Shrew{ II-i}:\
+
+Full fathom five thy father lies{;}:\
+Of his bones are coral made{;}:\
+{The }Tempest{ I-ii}:\
+Ariel
+She lov['|e]d me for the dangers I had pass['|e]d{;}:\
+And I lov['|e]d her that she did pity them{.}:\
+Othello{ I-iii}:\
+Othello
+Uneasy lies the head that wears a crown{.}:\
+Many good morrows to your Majesty{!}:\
+{King }Henry IV{,} Part II{ III-i}:\
+
+Mislike me not for my complexion{,}:\
+The shadow['|e]d livery of the burnish['|e]d sun{.}:\
+{The }Merchant{ of Venice{ II-i}}:\
+Morocco
+Cowards die many times before their deaths{;}:\
+The valiant never taste of death but once{.}:\
+{Julius }Caesar{ II-ii}:\
+Caesar
+O{h}{!|,} Pardon me{,} thou bleeding piece of earth{,}:\
+That I am meek and gentle with these butchers{.}:\
+{Julius }Caesar{ III-i}:\
+{Mark }Antony
+The play's the thing:\
+Wherein I'll catch the conscience of the king{.}:\
+Hamlet{ II-ii}:\
+Hamlet
+How sharper than a serpent's tooth it is:\
+to have a thankless child{.}:\
+{King }Lear{ I-iv}:\
+{King }Lear
+Had I but served my God with half the zeal I served my king:\
+He would not in [mine|my] old age have left me naked to [mine|my] enemies{.}:\
+{King }Henry VIII{ IV-ii}:\
+{Cardinal }Wolsey
+It seems she hangs upon the cheek of night:\
+Like a rich jewel in an Ethiop's ear{.}:\
+Romeo{ and Juliet{ I-v}}:\
+Romeo
+Where the bee sucks{,} there suck I{;}:\
+In a cowslip's bell I lie{.}:\
+{The }Tempest{ V-i}:\
+Ariel
+O brave new world{,}:\
+That has such people [in't|in it]{!}:\
+{The }Tempest{ V-i}:\
+Miranda
+Why{,} then the world's mine oyster{,}:\
+Which I with sword will open{.}:\
+{The }Merry Wives of Windsor{ II-ii}:\
+Falstaff
+A goodly apple rotten at the heart{\:}:\
+O{h}{,} what a goodly outside falsehood hath{!|.}:\
+{The }Merchant{ of Venice{ I-iii}}:\
+Antonio
+I never kill['|e]d a mouse{,} nor hurt a fly{;}:\
+I trod upon a worm against my will{,}:\
+Pericles{ IV-i}:\
+Marina
+Golden lads and girls all must{,}:\
+Like chimney sweepers{,} come to dust{.}:\
+Cymbeline{ IV-ii}:\
+Guiderius
+You blocks, you stones, you worse than senseless things!:\
+O you hard hearts{,} you cruel men of Rome{.}:\
+{Julius }Caesar{ I-i}:\
+Marullus
+A horse{!|,} a horse{!|,} my kingdom for a horse{!}:\
+:\
+{King }Richard III{ V-iv}:\
+{King }Richard III
+My salad days,:\
+When I was green in judg{e}ment, cold in blood{,}:\
+Antony [and|&] Cleopatra{ I-v}:\
+Cleopatra
+Age cannot wither her, nor custom stale:\
+Her infinite variety{.}:\
+Antony [and|&] Cleopatra{ II-iii}:\
+Enobarbus
+Give me some music\: music, moody food:\
+Of us that trade in love{.}:\
+Antony [and|&] Cleopatra{II-v}:\
+Cleopatra
+'Tis better playing with a lion's whelp,:\
+Than with an old one dying{.}:\
+Antony [and|&] Cleopatra:\
+Enobarbus
+The barge she sat in, like a burnished throne,:\
+Burned on the water{.} The poop was burnished gold{;|.}:\
+Antony [and|&] Cleopatra:\
+Enobarbus
+Done like a Frenchman - turn and turn again!:\
+:\
+{King }Henry VI{,} Part I{ III-iii}:\
+{Joan }Pucelle|{Saint |St{.} }Joan{ of Arc}
diff --git a/games/quiz/datfiles/chinese b/games/quiz/datfiles/chinese
new file mode 100644
index 0000000..66d9472
--- /dev/null
+++ b/games/quiz/datfiles/chinese
@@ -0,0 +1,12 @@
+rabbit:dragon
+dragon:snake
+snake:horse
+horse:sheep
+sheep:monkey
+monkey:rooster
+rooster:dog
+dog:boar
+boar:rat
+rat:ox
+ox:tiger
+tiger:rabbit
diff --git a/games/quiz/datfiles/collectives b/games/quiz/datfiles/collectives
new file mode 100644
index 0000000..3c4ba93
--- /dev/null
+++ b/games/quiz/datfiles/collectives
@@ -0,0 +1,105 @@
+actors|soldiers:company
+angels:host
+ants:colony|hill
+apes:shrewdness
+asses:pace|bunch
+badgers:cete
+bass:shoal
+bears:sloth
+bees:swarm
+bees|locusts:swarm
+birds:dissimulation
+brats:passel
+buffaloes:herd
+candidates:slate
+caterpillars:army
+cats:clowder
+cattle:drove|herd
+chickens:peep|flock
+crows:murder
+curs:cowardice
+dogs:pack
+doves:dule
+ducks:[pad|ba]dling
+earthquakes:swarm
+eggs:clutch
+elephants:herd
+elk:gang
+engineers:corps
+ferrets:business
+finches:charm
+firemen:brigade
+fish:school
+foxes:skulk
+gangsters:mob
+geese in flight:skein
+geese on water:gaggle
+goats:trip
+grapes|banannas:bunch
+hawks:cast
+hens:brood
+herons:siege
+horses:haras|team
+hounds:kennel
+jellyfish:smack
+kangaroos|monkeys:troop
+kittens:kindle
+lapwings:deceit
+larks:exaltation|bevy
+leopards:leap
+lions:pride
+locusts:plague
+magpies:tidings
+maidens|quail:bevy
+martens:richness
+men:band
+moles:labor
+monkeys|kangaroos:troop
+mountains:range
+mules:barren|baren
+nightingales:watch
+operating companies:at&t|bell system
+owls:parliament
+oxen:drove
+partridges:covey
+partridges|grouse:covey
+peacocks:ostentation
+people:crowd
+pheasants:bouquet
+plovers:congregation
+ponies:string
+porpoises:shoal
+prisoners:gang
+pups:litter
+quail|maidens:bevy
+rabbits:nest
+ravens:unkindness
+rhinoceroses:crash
+robbers:band
+roebucks:bevy
+rooks:building
+rubbish:heap
+seals:pod
+sheep:flock
+ships:fleet
+snipe:walk|wisp
+sparrows:host
+squirrels:dray
+starlings:murmuration
+stars:constellation
+storks:mustering
+swallows:flight
+teal:spring
+toads:knot
+turkeys:rafter
+turtledoves:pitying
+whales:gam|pod
+whales|fish:school
+witches:coven
+wolves:pack
+wolves:route
+woodcocks:fall
+woodpeckers:descent
+worshippers:congregation
+{H|h}uns:horde
+{wild }swine:sounder
diff --git a/games/quiz/datfiles/ed b/games/quiz/datfiles/ed
new file mode 100644
index 0000000..6ac8e89
--- /dev/null
+++ b/games/quiz/datfiles/ed
@@ -0,0 +1,84 @@
+prepare to add text at beginning of file:0a|1i
+find name of file being edited:f
+print last 3 lines of file:$-[2|-],$p
+print previous line:[-|^]{p}|{.}-{1}{p}
+print whole file:1,$p|g/[^|$]/p
+delete this line and next:.{,|;}[{.}+{1}|.1]d
+prepare to replace text from here to just before next "PP":\
+.{,|;}/[PP|{^}\\.PP]/-{1}c
+find next "1.2":/1\\.2/{p}
+find next 2-or-more digit number:\
+/\[[0|1]-9\]\[0-9\]/{p}
+move rest of this paragraph (separated by "PP") to end of previous one:\
+[.,|{.}+{1},|.1,]/[PP|{^}\\.PP]/-{1}m[??|?{^}{\\.}PP?]-{1}
+print every "Oxygen" or "oxygen":[g|1,$g]/\[[Oo|oO]\]xygen/[p|.p]
+change each "BTL" in file to "Bell Laboratories" and check:\
+[g|1,$g]/BTL/[s|.s]/[/|BTL/]Bell Laboratories/gp
+combine every even-numbered line with the next odd-numbered line:\
+2,${-{1}}g/[^|$]/[j|.,{.}+{1}j|.,.1j]
+print next "SH" and following line:\
+/SH/;[{.}+{1}|.1]p|/SH/,[//|/SH/][{.}+{1}|.1]p
+print from next "TS" to following "TE":/TS/;/TE/p
+reverse order of lines in whole file:[g|1,$g]/^/[m|.m]0
+replace each string of x's in current line by one x:\
+[s|.s]/[x|\[x\]][x|\[x\]]*/x/g{p}{ (not s/x*/x/g)}
+change first "hte" in current line to "the" and check:[s|.s]/hte/the/p
+combine previous line and this one:\
+[-,|^,|{.}-{1},].j
+go to line after third "PP" ahead:\
+/[PP|{^}\\.PP]/;[//|/[PP|{^}\\.PP]/];[//|/[PP|{^}\\.PP]/]\
+[{+}1|+]|;[{.}+{1}|.1]{ (not ...p)}
+exchange current line with previous line:\
+[[-|^]m|{.}-{1}m].|{.}m[[--|^^]|{.}-2]
+move everything from here through "stop." to end of file:\
+.,/stop\\./m$
+current line has 2 fields separated by 1 blank; exchange them:\
+[s|.s]/[\\|^\\]([.|\[^ \]]*\\) \\([.|\[^ \]]*\\)[/|$/]\\2 \\1/{p}
+insert a "0" after last "0" on current line:\
+[s|.s]/[.*0/&0|^.*0/&0|0\\(\[^0\]*\\)$/[0&|00\1]|0\[^0\]*$/0&\
+|\[^0\]*$/0&]/{p}
+replace "a*b" by "a**b":s/[a\\*b|a[*]b]/a**b/{p}|\
+s/\\*/**/p
+attach the word "extra" to the end of the current line:\
+[s|.s]/$/{ }extra/{p}
+replace "ATT" in current line by "AT&T":\
+[s|.s]/ATT/AT\\&T/{g}{p}
+double the length of the current line by repetition:\
+[s|.s]/[.*|.|^.*$]/&&/{p}
+look for another line containing what you just looked for://
+find the previous line that contains a capital letter:?\[A-Z\]?{p}
+delete the next line that contains only capital letters:\
+/^\[A-Z\]*$/d|/^\[A-Z\]\[A-Z\]*$/d
+place a copy of current line at the end of the file:\
+t$|.{,.}t$
+find how many lines there are:=|$=
+find the number of the current line:.=
+delete the first 3 lines of the file:1,3d
+delete every line that doesn't begin with "A":\
+[v|1,$v]/^A/d{ (not g/^\[^A\]/d)}
+delete every empty line from here through next "LP":\
+.,/[LP|{{^}\\.}LP]/g/^$/d
+print the line after each "AU":\
+[g|1,$g]/[AU|{^}\\.AU]/[{.}+{1}|.1]{p}
+delete everything after "proud" from current line:\
+[s|.s]/proud.*/proud/{p}
+delete part of current line from "alpha" through "omega":\
+[s|.s]/alpha.*omega//{p}
+save everything up through current line in file "prefix":1,.w prefix
+prepare to add text at end of file:$a
+append the contents of file "suffix" to this file:$r suffix
+go back 10 lines:{.}-10{p}|----------
+change every "01" in current line to "1":[s|.s]/01/1/g{p}
+go to next line that contains a double capital letter:\
+/\\(\[A-Z\]\\)\\1/{p}
+place parens () around current line:\
+[s|.s]/[.*|^.*$]/(&)/{p}
+the current line is too long for your terminal; print it to fit:\
+l|.l
+put the work you've done back in the original file:w
+append the whole file to the file "unfinished":\
+[W|1,$W] unfinished
+insert "\\&" at beginning of current line:\
+[s|.s]/^/\\\\\\&/{p}
+list your current directory:!ls
+stop work on current file and shift to file "other":e other
diff --git a/games/quiz/datfiles/elements b/games/quiz/datfiles/elements
new file mode 100644
index 0000000..aba620a
--- /dev/null
+++ b/games/quiz/datfiles/elements
@@ -0,0 +1,103 @@
+H:1:1.008:Hydrogen
+He:2:4.003:Helium
+Li:3:6.94:Lithium
+Be:4:9.013:Beryllium
+B:5:10.82:Boron
+C:6:12.011:Carbon
+N:7:14.008:Nitrogen
+O:8:16.0:Oxygen
+F:9:19.0:Fluorine
+Ne:10:20.183:Neon
+Na:11:22.991:Sodium
+Mg:12:24.32:Magnesium
+Al:13:26.98:Aluminum
+Si:14:28.09:Silicon
+P:15:30.975:Phosphorus
+S:16:32.066:Sulphur
+Cl:17:35.457:Chlorine
+Ar:18:39.944:Argon
+K:19:39.1:Potassium
+Ca:20:40.08:Calcium
+Sc:21:44.96:Scandium
+Ti:22:47.9:Titanium
+V:23:50.95:Vanadium
+Cr:24:52.01:Chromium
+Mn:25:54.94:Manganese
+Fe:26:55.85:Iron
+Co:27:58.94:Cobalt
+Ni:28:58.71:Nickel
+Cu:29:63.54:Copper
+Zn:30:65.38:Zinc
+Ga:31:69.72:Gallium
+Ge:32:72.6:Germanium
+As:33:74.91:Arsenic
+Se:34:78.96:Selenium
+Br:35:79.916:Bromine
+Kr:36:83.8:Krypton
+Rb:37:85.48:Rubidium
+Sr:38:87.63:Strontium
+Y:39:88.92:Yttrium
+Zr:40:91.22:Zirconium
+Nb:41:92.91:Niobium
+Mo:42:95.95:Molybdenum
+Tc:43:(99):Technetium
+Ru:44:101.1:Ruthenium
+Rh:45:102.91:Rhodium
+Pd:46:106.4:Palladium
+Ag:47:107.88:Silver
+Cd:48:112.41:Cadmium
+In:49:114.82:Indium
+Sn:50:118.7:Tin
+Sb:51:121.76:Antimony
+Te:52:127.61:Tellurium
+I:53:126.91:Iodine
+Xe:54:131.3:Xenon
+Cs:55:132.91:Cesium
+Ba:56:137.36:Barium
+La:57:138.92:Lanthanum
+Ce:58:140.13:Cerium
+Pr:59:140.92:Praseodymium
+Nd:60:144.27:Neodymium
+Pm:61:(145):Promethium
+Sm:62:150.35:Samarium
+Eu:63:152.0:Europium
+Gd:64:157.26:Gadolinium
+Tb:65:158.93:Terbium
+Dy:66:162.51:Dysprosium
+Ho:67:164.94:Holmium
+Er:68:167.27:Erbium
+Tm:69:168.94:Thulium
+Yb:70:173.04:Ytterbium
+Lu:71:174.99:Lutetium
+Hf:72:178.5:Hafnium
+Ta:73:180.95:Tantalum
+W:74:183.86:Tungsten
+Re:75:186.22:Rhenium
+Os:76:190.2:Osmium
+Ir:77:192.2:Iridium
+Pt:78:195.09:Platinum
+Au:79:197.0:Gold
+Hg:80:200.61:Mercury
+Tl:81:204.39:Thallium
+Pb:82:207.21:Lead
+Bi:83:209.0:Bismuth
+Po:84:(210):Polonium
+At:85:(210):Astatine
+Rn:86:(222):Radon
+Fr:87:(223):Francium
+Ra:88:(226):Radium
+Ac:89:(227):Actinium
+Th:90:232.05:Thorium
+Pa:91:(231):Protactinium
+U:92:238.07:Uranium
+Np:93:(237):Neptunium
+Pu:94:(242):Plutonium
+Am:95:(243):Americium
+Cm:96:(248):Curium
+Bk:97:(247):Berkelium
+Cf:98:(249):Californium
+Es:99:(254):Einsteinium
+Fm:100:(253):Fermium
+Md:101:(256):Mendelevium
+No:102:(253):Nobelium
+Lw:103:(259):Lawrencium
diff --git a/games/quiz/datfiles/europe b/games/quiz/datfiles/europe
new file mode 100644
index 0000000..f7ef781
--- /dev/null
+++ b/games/quiz/datfiles/europe
@@ -0,0 +1,33 @@
+Albania:Tirana|Tirane"
+Andorra:Andorra la V[ell|iej]a
+Austria:Vienna|Wien
+Belgium:Brussel[s|]|Bruxelles
+Bulgaria:Sofi[a|ya]
+Czechoslovakia:Prague|Praha
+Denmark:Copenhagen|K[o|o/]benhavn
+East Germany:Berlin
+United Kingdom|England|Great Britain|UK:London
+Finland:Helsinki
+France:Paris
+Greece:Athens
+Hungary:Budapest
+Iceland:Reykjavik
+Ireland|Eire:Dublin
+Italy:Rom[e|a]
+Liechtenstein:Vaduz
+Luxembourg:Luxembourg
+Malta:Valletta
+Monaco:Monte Carlo
+Netherlands|Holland:The Hague|'sGravenhage|den Haag|Amsterdam
+Norway:Oslo
+Poland:Wars[aw|zawa]
+Portugal:Lisbo[n|a]
+R[u|o]mania:Bucharest|Bucuresti
+San Marino:San Marino
+Spain:Madrid
+Sweden:Stockholm
+Switzerland:Bern{e}
+Turkey:Ankara
+USSR|Russia:Mos[cow|kva]
+[West |]Germany:Bonn
+Yugoslavia:Belgrade|Beograd
diff --git a/games/quiz/datfiles/flowers b/games/quiz/datfiles/flowers
new file mode 100644
index 0000000..1eb2360
--- /dev/null
+++ b/games/quiz/datfiles/flowers
@@ -0,0 +1,45 @@
+African violet:Such worth is rare
+Apple blossom:Preference
+Bachelor's button:Celibacy
+Bay leaf:I change but in death
+Camelia:Reflected loveliness
+Chrysanthemum, non-red/white:Slighted love
+Chrysanthemum, red:I love
+Chrysanthemum, white:Truth
+Clover:Be mine
+Crocus:Abuse not
+Daffodil:Innocence
+Dead leaves:Melancholy
+Forget-me-not:True love
+Fuchsia:Fast
+Gardenia:Secret, untold love
+Honeysuckle:Bonds of love
+Ivy:Friendship, fidelity, marriage
+Jasmine:Amiablity, transports of joy, sensuality
+Lilac:Youthful innocence
+Lilly of the valley:Return of happiness
+Lilly:Purity, sweetness
+Magnolia:Dignity, perseverance
+Marigold:Jealousy
+Mint:Virtue
+Orange blossom:Your purity equals your loveliness
+Orchid:Beauty, magnificence
+Pansy:Thoughts
+Peach blossom:I am your captive
+Petunia:Your presence soothes me
+Poppy:Sleep
+Rose, any color:Love
+Rose, deep red:Bashful shame
+Rose, single, pink:Simplicity
+Rose, thornless, any color:Early attachment
+Rose, white:I am worthy of you
+Rose, yellow:Decrease of love, rise of jealousy
+Rosebud, white:Girlhood, and a heart ignorant of love
+Rosemary:Rememberance
+Sunflower:Haughtiness
+Tulip, red:Declaration of love
+Tulip, yellow:Hopeless love
+Upside down:Reverses meaning
+Violet, blue:Faithfulness
+Violet, white:Modesty
+Zinnia:Thoughts of absent friends
diff --git a/games/quiz/datfiles/greek b/games/quiz/datfiles/greek
new file mode 100644
index 0000000..4833e83
--- /dev/null
+++ b/games/quiz/datfiles/greek
@@ -0,0 +1,7 @@
+$luw$:{I} [loose|destroy]
+$eluon$:{I} [loosed|destroyed|was loosing|was destroying]
+$elusa$:{I} [loosed|destroyed]
+$leluka$:{I} have [loosed|destroyed]
+$lusw$:{I} will [loose|destroy]
+$luswn$:[loosing|destroying]
+$lusas$:{having} [loosed|destroyed]
diff --git a/games/quiz/datfiles/inca b/games/quiz/datfiles/inca
new file mode 100644
index 0000000..02fd39f
--- /dev/null
+++ b/games/quiz/datfiles/inca
@@ -0,0 +1,12 @@
+manco capac:sinchi roca
+sinchi roca:lloque yupanqui
+lloque yupanqui:mayta capac
+mayta capac:capac yupanqui
+capac yupanqui:inca roca
+inca roca:yahuar huacac
+yahuar huacac:viracocha
+viracocha:pachacuti
+pachacuti:tupa inca yupanqui
+tupa inca yupanqui:huayna capac
+huayna capac:huascar
+huascar:atahuallpa
diff --git a/games/quiz/datfiles/index b/games/quiz/datfiles/index
new file mode 100644
index 0000000..67a5234
--- /dev/null
+++ b/games/quiz/datfiles/index
@@ -0,0 +1,32 @@
+/usr/share/games/quiz.db/africa:Africa{n}:cap{ital}
+/usr/share/games/quiz.db/america:America{n}:cap{ital}
+/usr/share/games/quiz.db/areas:area{-code}:state{-region}:city
+/usr/share/games/quiz.db/arith:arith{metic}:ans{wer}
+/usr/share/games/quiz.db/asia:Asia{n}:cap{ital}
+/usr/share/games/quiz.db/babies:baby:adult
+/usr/share/games/quiz.db/bard:Shakespeare{{-}line{s}}|line{s}:next:work:char{acter}
+/usr/share/games/quiz.db/chinese:{Chinese{-}}year:next
+/usr/share/games/quiz.db/collectives:ind{ividuals}:coll{ective}
+/usr/share/games/quiz.db/ed:function:ed-command
+/usr/share/games/quiz.db/elements:symbol:number:weight:element
+/usr/share/games/quiz.db/europe:Europe{an}:cap{ital}
+/usr/share/games/quiz.db/flowers:flower{s}:meaning
+/usr/share/games/quiz.db/greek:greek:english
+/usr/share/games/quiz.db/inca:inca:succ{essor}
+/usr/share/games/quiz.db/latin:latin:english
+/usr/share/games/quiz.db/locomotive:locomotive:name
+/usr/share/games/quiz.db/midearth:M[iddle{-}Earth|E]:cap{ital}
+/usr/share/games/quiz.db/morse:clear|alpha{bet{ic}}:morse
+/usr/share/games/quiz.db/mult:mult{iplication}:ans{wer}
+/usr/share/games/quiz.db/murders:victim:killer
+/usr/share/games/quiz.db/poetry:poem{-}line:next:poem:author
+/usr/share/games/quiz.db/posneg:pos{itive}:neg{ative}
+/usr/share/games/quiz.db/pres:pres{ident}:term:succ{essor}
+/usr/share/games/quiz.db/province:province:cap{ital}
+/usr/share/games/quiz.db/seq-easy:easy{-}{seq{uence}}:next:name
+/usr/share/games/quiz.db/seq-hard:hard{-}{seq{uence}}:next:name
+/usr/share/games/quiz.db/sexes:male:female
+/usr/share/games/quiz.db/sov:sov{ereign}:cen{t{ury}}:succ{essor}
+/usr/share/games/quiz.db/state:state:cap{ital}:abbr{ev{iation}}:flower
+/usr/share/games/quiz.db/trek:star:trek
+/usr/share/games/quiz.db/ucc:section:U{niform{-}}C{riminal{-}}C{ode}
diff --git a/games/quiz/datfiles/latin b/games/quiz/datfiles/latin
new file mode 100644
index 0000000..0b03bd3
--- /dev/null
+++ b/games/quiz/datfiles/latin
@@ -0,0 +1,157 @@
+condo:{I }found
+condidi:{I }founded
+laedo:{I }[injure|thwart]
+impello:{I }[drive|force]
+impulit:{he }[drove|forced]
+sino:{I }permit
+sinat:{he }permit{s}
+dolor:pain|grief
+invideo:{I }[envy|hate]
+invisus:[hated|envied]
+immitis:cruel|harsh
+arceo:{I }[keep away|hinder|prevent]
+ratis:ship
+antrum:cave
+freno:rein{ in}|curb|check
+celsus:lofty
+spelunca:cave{rn}
+foedus (n.):agreement|treaty|truce
+foedera:agreements|treaties
+laxus:loose|free
+habena:rein{s}
+mulceo:soothe|calm
+fluctus (n.):wave{s}
+exigo:finish|spend
+exegit:{he }[finished|spent]
+opto (v.):desire|wish
+optat:{he }[desire{s}|wish{es}]
+capesso:seize|carry out
+concilio (v.):secure|gain
+converto:reverse
+procella:blast|gust
+polus:sky|heaven
+mico:flash|gleam
+extemplo:immediately
+frigus (n.):cold|chill
+ingemo:groan
+os (n.):mouth
+effundo:pour{ out}
+corripio:snatch|catch
+harena:sand
+excutio:shake{ off}
+nare:{to }swim
+rima:crack|fissure
+fatisco:gape{ open}
+disjicio:scatter|disperse
+dolus (n.):deceit
+luo:wash{ away}|atone{ for}
+cito (adv.):quickly|soon
+tumidus:swollen
+fugo:put to flight|drive out
+adnitor:strive
+seditio:riot|uprising
+fax:fire{-}brand
+volo (v.):fly
+arrigo:prick up
+cunctus:whole|entire
+flecto:turn|guide
+sinus:bay|fold|curve|gulf
+scindo:split|divide
+rupes:crag|cliff
+geminus:twin
+minatur:{he }threaten{s}
+coruscus:flashing|waving
+horreo:bristle
+nemus:grove
+nemora:groves
+umbra:shade|shadow
+intus:within
+dulcis:sweet|fresh
+sedile:seat|bench
+fessus:weary|tired
+uncus:hooked|curved
+morsus:bite
+artus:joint|limb
+silex:flint
+scintilla:spark
+folium:leaf
+aridus:dry
+corrumpo:spoil|ruin
+corrupit:{he }[spoil{ed}|ruin{ed}]
+frux:grain
+torreo:parch
+celsus:high|lofty
+cervus:stag
+erro:wander
+armentum:herd
+pasco:feed|nourish
+pascor:graze
+arcus:bow
+turba:crowd
+sterno:strew
+humus:ground|earth
+vinum:wine
+maereo:mourn|sorrow
+ignarus:unknowing|ignorant|inexperienced
+rabies:rage|fury
+penitus:within
+sono (v.):sound|roar
+maestus:sad|gloomy
+forsan:perhaps
+olim:someday|sometime
+memini:{I }remember
+varius:different
+discrimen:crisis|danger
+quiesco:become quiet
+refert:{he }[say{s}|tell{s}]
+vultus:face|countenance
+cor:heart
+corda:hearts
+dolor:pain|grief
+daps:feast
+dapes:feasts
+viscus:flesh
+seco:cut
+tremo:quiver
+pinguis:fat|rich
+mensa:table
+sermo:talk|discourse
+dubius:doubtful|wavering
+pius:dutiful|devoted|loyal
+gemo:lament|moan|bemoan
+crudelis:cruel|bitter
+lumen:light|eye
+lumina:lights|eyes
+tristis:sad
+lacrima:tear
+niteo:shine|glisten
+fulmen:thunderbolt|lightning
+fulmina:thunderbolts
+funus:death|disaster
+funera:deaths|disasters
+orbis terrarum:world
+ductor:leader
+dicio (n.):power
+fons:spring|source
+fontes:springs|sources
+arvum:land
+infandus:unspeakable
+rideo:laugh
+osculum:lip
+libo:sip|touch|kiss
+nata:daughter
+haereo:{I }[stick to|adhere]
+promitto:primise
+sublimis:high|uplifted|up high
+quando:since|when|because
+arcanum:{a }secret
+ferox:fierce|savage
+contundo:crush
+albus:white
+donec:until
+sacerdos:priest{ess}
+lupus:wolf
+nutrix:nurse
+nutrices:nurses
+fulvus:tawny|yellow
+meta:limit|boundary
diff --git a/games/quiz/datfiles/locomotive b/games/quiz/datfiles/locomotive
new file mode 100644
index 0000000..a29cc01
--- /dev/null
+++ b/games/quiz/datfiles/locomotive
@@ -0,0 +1,11 @@
+4-4-0:American
+4-6-0:Mogul
+4-4-2:Atlantic
+4-6-2:Pacific
+2-8-0:Consolidation
+2-8-2:Mikado
+4-8-2:Mountain
+2-8-4:Berkshire
+4-6-4:Hudson
+4-8-4:Northern
+2-10-2:Decapod
diff --git a/games/quiz/datfiles/midearth b/games/quiz/datfiles/midearth
new file mode 100644
index 0000000..17e21c0
--- /dev/null
+++ b/games/quiz/datfiles/midearth
@@ -0,0 +1,10 @@
+Shire:Michel Delving|Hobbiton
+Mordor:Minas Morgul
+Gondor:Minas Tirith
+Umbar:{City of the }Corsairs
+Rhovanion:Esgaroth{ upon the Long Lake}
+Rohan:Edoras
+Lothl['o|o|o']rien:Caras Galadon
+Breeland:Bree
+Arnor:Ann['u|u'|u]minas
+Arthedain:Fornost{ Erain}|Norbury of the Kings
diff --git a/games/quiz/datfiles/morse b/games/quiz/datfiles/morse
new file mode 100644
index 0000000..4086374
--- /dev/null
+++ b/games/quiz/datfiles/morse
@@ -0,0 +1,26 @@
+A:.-
+B:-...
+C:-.-.
+D:-..
+E:.
+F:..-.
+G:--.
+H:....
+I:..
+J:.---
+K:-.-
+L:.-..
+M:--
+N:-.
+O:---
+P:.--.
+Q:--.-
+R:.-.
+S:...
+T:-
+U:..-
+V:...-
+W:.--
+X:-..-
+Y:-.--
+Z:--..
diff --git a/games/quiz/datfiles/mult b/games/quiz/datfiles/mult
new file mode 100644
index 0000000..2ce87a0
--- /dev/null
+++ b/games/quiz/datfiles/mult
@@ -0,0 +1,99 @@
+1 x 0:0
+1 x 1:1
+1 x 2:2
+1 x 3:3
+1 x 4:4
+1 x 5:5
+1 x 6:6
+1 x 7:7
+1 x 8:8
+1 x 9:9
+1 x 10:10
+2 x 0:0
+2 x 1:2
+2 x 2:4
+2 x 3:6
+2 x 4:8
+2 x 5:10
+2 x 6:12
+2 x 7:14
+2 x 8:16
+2 x 9:18
+2 x 10:20
+3 x 0:0
+3 x 1:3
+3 x 2:6
+3 x 3:9
+3 x 4:12
+3 x 5:15
+3 x 6:18
+3 x 7:21
+3 x 8:24
+3 x 9:27
+3 x 10:30
+4 x 0:0
+4 x 1:4
+4 x 2:8
+4 x 3:12
+4 x 4:16
+4 x 5:20
+4 x 6:24
+4 x 7:28
+4 x 8:32
+4 x 9:36
+4 x 10:40
+5 x 0:0
+5 x 1:5
+5 x 2:10
+5 x 3:15
+5 x 4:20
+5 x 5:25
+5 x 6:30
+5 x 7:35
+5 x 8:40
+5 x 9:45
+5 x 10:50
+6 x 0:0
+6 x 1:6
+6 x 2:12
+6 x 3:18
+6 x 4:24
+6 x 5:30
+6 x 6:36
+6 x 7:42
+6 x 8:48
+6 x 9:54
+6 x 10:60
+7 x 0:0
+7 x 1:7
+7 x 2:14
+7 x 3:21
+7 x 4:28
+7 x 5:35
+7 x 6:42
+7 x 7:49
+7 x 8:56
+7 x 9:63
+7 x 10:70
+8 x 0:0
+8 x 1:8
+8 x 2:16
+8 x 3:24
+8 x 4:32
+8 x 5:40
+8 x 6:48
+8 x 7:56
+8 x 8:64
+8 x 9:72
+8 x 10:80
+9 x 0:0
+9 x 1:9
+9 x 2:18
+9 x 3:27
+9 x 4:36
+9 x 5:45
+9 x 6:54
+9 x 7:63
+9 x 8:72
+9 x 9:81
+9 x 10:90
diff --git a/games/quiz/datfiles/murders b/games/quiz/datfiles/murders
new file mode 100644
index 0000000..30cf324
--- /dev/null
+++ b/games/quiz/datfiles/murders
@@ -0,0 +1,25 @@
+Cock Robin:{the }sparrow
+sleep|Duncan:Macbeth
+{the }cat:curiosity|care
+{John {F{.} }}Kennedy|JFK:{Lee Harvey }Oswald|{the }FBI|{the }CIA
+{Lee Harvey }Oswald:{Jack }Ruby|{the }FBI|{the }CIA
+{Martin Luther }King:{James {Earl }}Ray|{the }FBI|{the }CIA
+[Bobby |Robert {F{.} }]Kennedy|RFK:{Sirhan }Sirhan|{the }FBI|{the }CIA
+Christ:{the }Romans|{Pontius }Pilate|{the }CIA
+{Sharon }Tate:{Charles }Manson
+Charles Lindbergh Jr{.}:{Bruno }Hauptman{n}
+{Mr{.} }{{and }Mrs{.} }Borden|{her }parents:Lizzie{ Borden}
+{Prof{essor} }{James }Moriarty:{Sherlock }Holmes
+Achilles:Paris
+Abel:Cain
+{the }nurses:{Richard }Speck
+{J{.} |Julius }Caesar:Brutus{ et al.}
+Pompeii:Vesuvius
+{Abraham |Abe }Lincoln:{John {Wilkes }}Booth
+{Yukio }Mishima:{Yukio }Mishima
+{Alexander }Hamilton:{Aaron }Burr
+Cleopatra:{the |an }asp
+[Ann Boleyn|Catharine Howard]:Henry{ VIII}
+vaudeville:{the }movies|film
+{the }movies|film:TV|television
+{the }VA patients:{the }nurses
diff --git a/games/quiz/datfiles/poetry b/games/quiz/datfiles/poetry
new file mode 100644
index 0000000..f4c07d6
--- /dev/null
+++ b/games/quiz/datfiles/poetry
@@ -0,0 +1,184 @@
+Come live with me and be my love:\
+And we will all the pleasures prove:\
+{The }Passionate Shepherd{ to his Love}:\
+{Christopher }Marlowe
+Shall I compare thee to a summer's day{?}:\
+Thou art more lovely and more temperate:\
+Sonnet 18:\
+{William }Shakespeare
+Fine knacks for ladies, cheap, choice, brave, and new!:\
+Good pennyworths{! }but money cannot move:\
+Fine Knacks{ for Ladies}:\
+{John }Dowland
+My mind to me a kingdom is:\
+Such perfect joy therein I find:\
+My Mind to Me a Kingdom Is:\
+{Sir }{Edward }Dyer
+Underneath this stone doth lie:\
+As much beauty as could die:\
+Epitaph on Elizabeth{,} {L. H.}:\
+{Ben }Jonson
+Death be not proud, though some have called thee:\
+Mighty and dreadful{,} for thou art not so:\
+{Holy }Sonnet{s}{ 10}:\
+{John }Donne
+Gather ye rose-buds while ye may:\
+Old Time is still a-flying:\
+To the Virgins{,} {To Make Much of Time}:\
+{Robert }Herrick
+Why so pale and wan, fond lover?:\
+Prithee{,} why so pale{?}:\
+Song:\
+{Sir }{John }Suckling
+Stone walls do not a prison make:\
+Nor iron bars a cage:\
+To Althea{,} From Prison:\
+{Richard }Lovelace
+I could not love thee (Dear) so much,:\
+Lov['|e]d I not hono{u}r more:\
+To Lucasta{, Going to the Wars}:\
+{Richard }Lovelace
+I saw Eternity the other night:\
+Like a great ring of pure and endless light:\
+{The }World:\
+{Henry }Vaughan
+Come and trip it as you go,:\
+On the light fantastic toe:\
+L'Allegro:\
+{John }Milton
+When I consider how my light is spent:\
+Ere half my days in this dark world and wide:\
+On His Blindness|When I Consider:\
+{John }Milton
+The grave's a fine and private place{,}:\
+But none{,} I think{,} do there embrace{.}:\
+To His Coy Mistress:\
+{Andrew }Marvel
+Great wits are sure to madness near allied:\
+And thin partitions do their bounds divide:\
+Absalom and Achitophel|Absalom:\
+{John }Dryden
+A little learning is a dangerous thing{;}:\
+Drink deep{,} or taste not the Pierian spring{.}:\
+{An }Essay on Criticism|{On }Criticism:\
+{Alexander }Pope
+The curfew tolls the knell of parting day{,}:\
+The lowing herd wind slowly o'er the lea:\
+Elegy{ Written in a Country Church{-| }Yard:\
+{Thomas }Gray
+The best laid schemes o' mice an' men gang aft a-gley{,}:\
+An{'|d} lea{'|v}e us nought but grief an{'|d} pain for promised joy{.}:\
+To a Mouse:\
+{Robert }Burns
+Tiger! tiger! burning bright!:\
+In the forests of the night:\
+{The }Tiger:\
+{William }Blake
+My heart leaps up when I behold:\
+A rainbow in the sky:\
+My Heart Leaps Up:\
+{William }Wordsworth
+The world is too much with us; late and soon{,}:\
+Getting and spending{,} we lay waste our powers:\
+{The }World is Too Much With Us|Sonnet:\
+{William }Wordsworth
+A sadder and a wiser man{,}:\
+He rose the morrow morn:\
+{The }{Rime of }{The }Ancient Mariner:\
+{Samuel }{Taylor }Coleridge
+In Xanadu did Kubla Khan:\
+A stately pleasure{-| }dome decree:\
+Kubla Khan:\
+{Samuel }{Taylor }Coleridge
+She walks in beauty, like the night:\
+Of cloudless climes and starry skies:\
+She Walks in Beauty:\
+{George Gordon, }{Lord }Byron
+I want a hero- an uncommon want{,}:\
+When every year and month sends forth a new one:\
+Don Juan{ Canto I}:\
+{George Gordon, }{Lord }Byron
+A thing of beauty is a joy forever.:\
+Its loveliness increases{;|.} {it will never/Pass into nothingness}:\
+Endymion{ Book I}:\
+{John }Keats
+Matched with an aged wife, I mete and dole:\
+Unequal laws unto a savage race:\
+Ulysses:\
+{Alfred{,} }{Lord }Tennyson
+He will hold thee, when his passion shall have spent its novel force{,}:\
+Something better than his dog{,} a little dearer than his horse:\
+Locksley Hall:\
+{Alfred{,} }{Lord }Tennyson
+'Tis better to have loved and lost:\
+Than never to have loved at all:\
+{In }Memoriam{ A. H. H.}:\
+{Alfred{,} }{Lord }Tennyson
+Kind hearts are more than coronets,:\
+And simple faith than Norman blood{.}:\
+Lady Clara Vere de Vere:\
+{Alfred{,} }{Lord }Tennyson
+Oh, to be in England:\
+Now that April's there:\
+Home{-| }Thoughts{,} From Abroad:\
+{Robert }Browning
+Ah, but a man's reach should exceed his grasp{,}:\
+Or what's a heaven for{?}:\
+Andrea Del Sarto:\
+{Robert }Browning
+How do I love thee? Let me count the ways.:\
+I love thee to the depth and breadth and height:\
+Sonnet{s} {From the Portuguese}{ 43}:\
+{Elizabeth }{Barrett }Browning
+A Book of Verses underneath the Bough{,}:\
+A Jug of Wine, a Loaf of Bread{-|,| }and Thou:\
+{The }Rubaiyat{ of Omar Khayyam}{ 12}:\
+{Edward }Fitzgerald
+The Moving Finger writes; and, having writ,:\
+Moves on{\:|,|.} nor all your Piety nor Wit:\
+{The }Rubaiyat{ of Omar Khayyam}{ 71}:\
+{Edward }Fitzgerald
+Ah Love! could you and I with Him conspire:\
+To grasp this sorry Scheme of Things entire:\
+{The }Rubaiyat{ of Omar Khayyam}{ 99}:\
+{Edward }Fitzgerald
+Remember me when I am gone away,:\
+Gone far away into the silent land:\
+Remember:\
+{Christina }Rossetti
+Home is the sailor, home from the sea,:\
+And the hunter home from the hill:\
+Requiem:\
+{Robert }{Louis }Stevenson
+I fled Him, down the nights and down the days;:\
+I fled Him, down the arches of the years:\
+{The }Hound of Heaven:\
+{Francis }Thompson
+So 'ere's to you, Fuzzy-Wuzzy, at your 'ome in the Soudan;:\
+You're a {pore|poor} benighted {'|h}eathen but a first class fightin{'|g} man:\
+Fuzzy{-| }Wuzzy:\
+{Rudyard }Kipling
+Morns abed and daylight slumber:\
+Were not meant for man alive:\
+Reveille:\
+{A{.}{ }E{.}{ }}Houseman
+I will arise and go now, and go to Innisfree,:\
+And a small cabin build there{,} of clay and wattles made:\
+{The }{Lake Isle of }Innisfree:\
+{William }{Butler }Yeats
+I must go down to the seas again, to the lonely sea and the sky,:\
+And all I ask is a tall ship and a star to steer her by:\
+Sea{-| }Fever:\
+{John }Masefield
+April is the cruelest month, breeding:\
+Lilacs out of the dead land:\
+{The }Waste{ }Land:\
+{T{.}{ }S{.}{ }}Eliot
+Now as I was young and easy under the apple boughs:\
+About the little house and happy as the grass was green:\
+Fern Hill:\
+{Dylan }Thomas
+Of Man's first disobedience, and the fruit:\
+Of that forbidden tree{,} whose mortal taste:\
+Paradise Lost:\
+{John }Milton
diff --git a/games/quiz/datfiles/posneg b/games/quiz/datfiles/posneg
new file mode 100644
index 0000000..03fde40
--- /dev/null
+++ b/games/quiz/datfiles/posneg
@@ -0,0 +1,50 @@
+large|big:small
+on:off
+standing up:sitting down
+inside:outside
+high:low
+old:new|young
+hot:cold
+out:in
+heavy|dark:light
+daytime:night[time| time]
+stop|come:go
+top:bottom
+floor:ceiling
+near:far
+run:walk
+empty|hungry:full
+backwards:f[or|ront]wards
+big|large:little|small
+fat|thick:thin|skinny
+bright|light:dark|dull
+right:wrong|left
+give:take|receive|get
+buy:sell
+shiny|bright:dull
+dawn:dusk
+fall down|go to bed:[get|stand|rise] up
+asleep:awake
+up:down
+open[|ed|]:close[d|]
+smile:frown|cry
+happy|glad:sad
+hard:soft|easy
+boy|woman|lady:girl|man
+fast:slow
+wet:dry
+covered|hid[den|]:uncovered|open
+good:bad
+always|sometimes|now:never|sometimes
+beautiful|pretty:ugly
+rough:smooth
+hairy:bald||smooth
+above:below
+yin:yang
+sweet:sour
+if:unless
+from|fro:to
+with[|in|]:without|against
+after:before
+together:apart
+plus:minus
diff --git a/games/quiz/datfiles/pres b/games/quiz/datfiles/pres
new file mode 100644
index 0000000..49da275
--- /dev/null
+++ b/games/quiz/datfiles/pres
@@ -0,0 +1,38 @@
+{G{eorge} }Washington:1789-{17}97:{J{ohn} }Adams
+{J{ohn} }Adams:1797-1801:{T{homas} }Jefferson
+{T{homas} }Jefferson:1801-{{18}0}9:{J{ames} }Madison
+{J{ames} }Madison:1809-{18}17:{J{ames} }Monroe
+{J{ames} }Monroe:1817-1825:{J{ohn} }{Q{uincy} }Adams
+{J{ohn} }{Q{uincy} }Adams:1825-{{18}2}9:{A{ndrew} }Jackson
+{A{ndrew} }Jackson:1829-{18}37:{M{artin} }Van Buren
+{M{artin} }Van Buren:1837-{18}41:{W{illiam|m} }{H{enry} }Harrison
+{W{illiam|m} }{H{enry} }Harrison:1841:{J{ohn} }Tyler
+{J{ohn} }Tyler:1841-{{18}4}5:{J{ames} }{K{nox} }Polk
+{J{ames} }{K{nox} }Polk:1845-{{18}4}9:{Z{achary} }Taylor
+{Z{achary} }Taylor:1849-{18}50:{M{illard} }Fillmore
+{M{illard} }Fillmore:1850-{{18}5}3:{F{ranklin} }Pierce
+{F{ranklin} }Pierce:1853-{{18}5}7:{J{ames} }Buchanan
+{J{ames} }Buchanan:1857-{18}61:{A{braham|be} }Lincoln
+{A{braham|be} }Lincoln:1861-{{18}6}5:{A{ndrew} }Johnson
+{A{ndrew} }Johnson:1865-{{18}6}9:{U{lysses} }{S{impson} }Grant
+{U{lysses} }{S{impson} }Grant:1869-{18}77:{R{utherford} }{B{irchard} }Hayes
+{R{utherford} }{B{irchard} }Hayes:1877-{18}81:{J{ames} }{A{bram} }Garfield
+{J{ames} }{A{bram} }Garfield:1881:{C{hester} }{A{lan} }Arthur
+{C{hester} }{A{lan} }Arthur:1881-{{18}8}5:{G{rover} }Cleveland{ (1st term)}
+{G{rover} }Cleveland{ (1st term)}:1885-{{18}8}9:{B{enjamin} }Harrison
+{B{enjamin} }Harrison:1889-{18}93:{G{rover} }Cleveland{ (2nd term)}
+{G{rover} }Cleveland{ (2nd term)}:1893-{18}97:{W{illiam|m} }McKinley
+{W{illiam|m} }McKinley:1897-1901:{T{heodore|eddy} }Roosevelt|TR
+{T{heodore|eddy} }Roosevelt|TR:1901-{{19}0}9:{W{illiam|m} }{H{oward} }Taft
+{W{illiam|m} }{H{oward} }Taft:1909-{19}13:{W{oodrow} }Wilson
+{W{oodrow} }Wilson:1913-{19}21:{W{arren} }{G{amaliel} }Harding
+{W{arren} }{G{amaliel} }Harding:1921-{{19}2}3:{C{alvin} }Coolidge
+{C{alvin} }Coolidge:1923-{{19}2}9:{H{erbert} }Hoover
+{H{erbert} }Hoover:1929-{19}33:{F{ranklin} }{D{elano} }Roosevelt|FDR
+{F{ranklin} }{D{elano} }Roosevelt|FDR:1933-{19}45:{H{arry} }{S }Truman
+{H{arry} }{S }Truman:1945-{19}53:{D{wight} }{D{avid} }Eisenhower
+{D{wight} }{D{avid} }Eisenhower:1953-{19}61:{J{ohn} }{F{itzgerald} }Kennedy|JFK
+{J{ohn} }{F{itzgerald} }Kennedy|JFK:1961-{{19}6}3:{L{yndon} }{B{aines} }Johnson|LBJ
+{L{yndon} }{B{aines} }Johnson|LBJ:1963-{{19}6}9:{R{ichard} }{M{ilhouse} }Nixon
+{R{ichard} }{M{ilhouse} }Nixon:1969-{19}74:{G{erald} }{R{obert} }Ford
+{G{erald} }{R{obert} }Ford:1974-:
diff --git a/games/quiz/datfiles/province b/games/quiz/datfiles/province
new file mode 100644
index 0000000..63e044c
--- /dev/null
+++ b/games/quiz/datfiles/province
@@ -0,0 +1,13 @@
+Newfoundland{ and Labrador}:[St.|Saint] John's
+New Brunswick:Fredericton
+Prince Edward Island:Charlottetown
+Nova Scotia:Halifax
+Quebec:Quebec
+Ontario:Toronto
+Manitoba:Winnipeg
+Saskatchewan:Regina
+Alberta:Edmonton
+British Columbia:Victoria
+Yukon Territory:Whitehorse
+Northwest Territories:Yellowknife
+Canada:Ottawa
diff --git a/games/quiz/datfiles/seq-easy b/games/quiz/datfiles/seq-easy
new file mode 100644
index 0000000..e88cefa
--- /dev/null
+++ b/games/quiz/datfiles/seq-easy
@@ -0,0 +1,14 @@
+1,2,3,4,5,6:7{(integers)}:integers|[natural|counting] numbers
+1,2,3,5,8,13:21{(Fibonacci)}:Fibonacci{ seq{ence}| numbers}
+1,2,4,8,16,32:64{(powers of 2)}:powers of 2|2[**|^]n
+1,2,6,24,120,720:5040{(factorials)}:factorials|n!
+1,3,5,7,9,11:13{(odd nos.)}:odd [integ|numb]ers
+1,3,6,10,15,21:28{(triangular)}:triangular{ numbers}|C(n,2)
+1,3,9,27,81:243{(powers of 3)}:powers of 3|3[**|^]n
+1,4,9,16,25:36{(squares)}:squares|n[**|^]2
+1,4,16,64:256{(powers of 4)}:powers of 4|4[**|^]n
+1,5,25,125:625{(powers of 5)}:powers of 5|5[**|^]n
+1,8,27,64,125:216{(cubes)}:cubes|n[**|^]3
+2,3,5,7,11,13:17{(primes)}:prime[ number]s
+2,4,6,8,10,12:14{(even nos.)}:even [integ|numb]ers|multiples of 2|2n
+3,6,9,12,15:18{(3n)}:multiples of 3|3n
diff --git a/games/quiz/datfiles/seq-hard b/games/quiz/datfiles/seq-hard
new file mode 100644
index 0000000..9d9373f
--- /dev/null
+++ b/games/quiz/datfiles/seq-hard
@@ -0,0 +1,15 @@
+1,1,2,1,2,2,3,1,2,2,3,2,3,3,4:1{(1's in binary nos)}:number of 1's in binary numbers
+1,1,2,2,4,2,6,4,6,4,10:4{(phi(n))}:Euler's [totient|phi]{ function}|phi(n)
+1,2,2,4,2,4,2,4,6,2:6{(diff of primes)}:diff{erences} [between|of] primes
+1,2,4,11,34:156{(unlabeled graphs)}:{unlabeled }graphs
+1,2,5,14,42,132:429{(Catalan)}:Catalan{ numbers}
+1,2,5,16,61:272{(Euler)}:Euler{ numbers}
+1,3,12,60,360:2520{(n!/2)}:Even permutations|n!/2
+1,3,16,125,1296,16807:262144{(n**(n-2))}:{labeled }trees|n[**|^](n-2)
+1,4,10,20,35,56:84{(C(n,3))}:Tetrahedral{ numbers}|C(n,3)
+1,4,11,20,31,44,61:100{(n**2 base 8)}:[Squares|n[**|^]2} base 8|octal squares
+1,4,16,256:65536{(2**2**n)}:{labeled }boolean functions|2[**|^]2[**|^]n
+1,6,28:496{(perfect nos)}:perfect{ numbers}
+2,7,1,8,2,8:1{(e)}:{digits of }e
+3,1,4,1,5,9:2{(pi)}:{digits of }pi
+3,7,31,127:8191{(Mersenne primes)}:Mersenne{ primes}
diff --git a/games/quiz/datfiles/sexes b/games/quiz/datfiles/sexes
new file mode 100644
index 0000000..78c583a
--- /dev/null
+++ b/games/quiz/datfiles/sexes
@@ -0,0 +1,26 @@
+Y|y:X|x
+abbot:abbess
+alumnus:alumna
+ambassador:ambassadress
+boar:sow
+buck:doe
+bull:cow
+cob:pen
+colt:filly
+curator:curatrix
+dog:bitch|vixen
+duke:duchess
+drake:duck
+effeminate|womanish:mannish
+gander:goose
+gentleman:lady|gentlewoman
+jack:jenny
+lad:lass
+manly:womanly
+marquis:marchioness[|e]|marquise
+monk:nun
+[O|o]edipus complex:[E|e]lectra[| complex]
+prince:princess
+ram:ewe
+rooster|cock:hen
+stallion:mare
diff --git a/games/quiz/datfiles/sov b/games/quiz/datfiles/sov
new file mode 100644
index 0000000..c02d417
--- /dev/null
+++ b/games/quiz/datfiles/sov
@@ -0,0 +1,42 @@
+W[illia|]m [I|1|the Conqueror]:11:W[illia|]m [II|2|Rufus|the Red]
+W[illia|]m [II|2|Rufus|the Red]:11:Hen[ry|] [I|1]
+Hen[ry|] [I|1]:12:Stephen
+Stephen:12:Hen[ry|] [II|2]
+Hen[ry|] [II|2]:12:Rich[ard|] [I|1]
+Rich[ard|] [I|1]:12:John
+John:13|12-13:Hen[ry|] [III|3]
+Hen[ry|] [III|3]:13:Ed[w[ard|]|] [I|1]
+Ed[w[ard|]|] [I|1]:13-14|13|14:Ed[w[ard|]|] [II|2]
+Ed[w[ard|]|] [II|2]:14:Ed[w[ard|]|] [III|3]
+Ed[w[ard|]|] [III|3]:14:Rich[ard|] [II|2]
+Rich[ard|] [II|2]:14:Hen[ry|] [IV|4] Part 1
+Hen[ry|] [IV|4] Part 1:15|14-15:Hen[ry|] [IV|4] Part 2
+Hen[ry|] [IV|4] Part 2:15|14-15:Hen[ry|] [V|5]
+Hen[ry|] [V|5]:15:Hen[ry|] [VI|6]
+Hen[ry|] [VI|6]:15:Ed[w[ard|]|] [IV|4]
+Ed[w[ard|]|] [IV|4]:15:Ed[w[ard|]|] [V|5]
+Ed[w[ard|]|] [V|5]:15:Rich[ard|] [III|3]
+Rich[ard|] [III|3]:15:Hen[ry|] [VII|7]
+Hen[ry|] [VII|7]:15-16|15|16:Hen[ry|] [VIII|8]
+Hen[ry|] [VIII|8]:16:Ed[w[ard|]|] [VI|6]
+Ed[w[ard|]|] [VI|6]:16:Mary
+Mary:16:Eliz[abeth|][ [I|1]|]
+Elizabeth[ [I|1]|]:16-17|16:Ja[me|]s [I|1]
+Ja[me|]s [I|1]:17:Cha[rle|]s [I|1]
+Cha[rle|]s [I|1]:17:[Oliver |]Cromwell
+[Oliver |]Cromwell:17:Rich[ard|] Cromwell
+Rich[ard|] Cromwell:17:Ch[arle|]s [II|2]
+Cha[rle|]s [II|2]:17:Ja[me|]s [II|2]
+Ja[me|]s [II|2]:17:W[illia|]m and Mary
+W[illia|]m and Mary:17-18|17:Anne
+Anne:18:Geo[rge|] [I|1]
+Geo[rge|] [I|1]:18:Geo[rge|] [II|2]
+Geo[rge|] [II|2]:18:Geo[rge|] [III|3]
+Geo[rge|] [III|3]:18-19|18|19:Geo[rge|] [IV|4]
+Geo[rge|] [IV|4]:19:W[illia|]m [IV|4]
+W[illia|]m [IV|4]:19:Victoria
+Victoria:19:Ed[w[ard|]|] [VII|7]
+Ed[w[ard|]|] [VII|7]:19-20|19|20:Geo[rge|] [V|5]
+Geo[rge|] [V|5]:20:Ed[w[ard|]|] [VIII|8]
+Ed[w[ard|]|] [VIII|8]:20:Geo[rge|] [VI|6]
+Geo[rge|] [VI|6]:20:Eliz[abeth|] [II|2]
diff --git a/games/quiz/datfiles/spell b/games/quiz/datfiles/spell
new file mode 100644
index 0000000..75ce1e8
--- /dev/null
+++ b/games/quiz/datfiles/spell
@@ -0,0 +1,2 @@
+The son went behind a cloud.:sun
+Did you see the monky at the zoo?:monkey
diff --git a/games/quiz/datfiles/state b/games/quiz/datfiles/state
new file mode 100644
index 0000000..0c11487
--- /dev/null
+++ b/games/quiz/datfiles/state
@@ -0,0 +1,50 @@
+Alabama|Ala|AL:Montgomery:AL:goldenrod
+Alaska|AK:Juneau:AK:forget{-| }me{-| }not
+Arizona|Ariz|AZ:Phoenix:AZ:{saguaro }cactus
+Arkansas|Ark|AR:Little Rock:AR:gok
+Cal{if{ornia}}|CA:Sacramento:CA:{golden }poppy
+Col{o{rado}}|CO:Denver:CO:columbine
+Conn{ecticut}|CT:Hartford:CT:{mountain }laurel
+Del{aware}|DE:Dover:DE:peach{ blossom}
+Fl{orid}a|FL:Tallahassee:FL:orange{ blossom}
+Georgia|Ga:Atlanta:GA:{Cherokee }rose
+Hawaii|HI:Honolulu:HI:hibiscus
+Idaho|Ida|ID:Boise:ID:syringa
+Ill{inois}|IL:Springfield:IL:violet
+Ind{iana}|IN:Indianapolis:IN:zinnia
+Iowa|Ia:Des Moines:IA:{wild }rose
+Kans{as}|Kan|KS:Topeka:KS:sun{ }flower
+Kentucky|Ky:Frankfort:KY:goldenrod
+Louisiana|La:Baton Rouge:LA:magnolia
+Maine|Me:Augusta:ME:pinecone{ and}{ tassel}
+Maryland|Md:Annapolis:MD:blackeyed susan
+Mass{achusetts}|MA:Boston:MA:{trailing }arbutus
+Mich{igan}|MI:Lansing:MI:apple{ blossom}
+Minn{esota}|MN:Saint Paul|St Paul:MN:gok
+Miss{issippi}|MS:Jackson:MS:magnolia
+Missouri|Mo:Jefferson City:MO:hawthorn
+Mont{ana}|MT:Helena:MT:bitterroot
+Nebraska|Neb|NE|NB:Lincoln:NE|NB:goldenrod
+Nevada|Nev|NV:Carson City:NV:sagebrush
+New Hampshire|NH:Concord:NH:{purple }lilac
+New Jersey|NJ:Trenton:NJ:violet
+New Mexico|NM:Santa Fe:NM:yucca
+New York|NY:Albany:NY:{wild }rose
+N{orth} Carolina|NC:Raleigh:NC:dogwood
+N{orth} Dakota|ND:Bismarck:ND:{wild }{prarie }rose
+Ohio|O|OH:Columbus:OH:{scarlet }carnation
+Oklahoma|Okla|OK:Oklahoma City:OK:mistletoe
+Oregon|Ore|OR:Salem:OR:{Oregon }grape
+Pennsylvania|Pa:Harrisburg:PA:{mountain }laurel
+Rhode Island|RI:Providence:RI:violet
+S{outh} Carolina|SC:Columbia:SC:{yellow }jasmine
+S{outh} Dakota|SD:Pierre:SD:pasque{ flower}
+Tenn{essee}|TN:Nashville:TN:iris
+Texas|Tex|TX:Austin:TX:blue{-| }bonnet
+Utah|UT:Salt Lake City:UT:{sego }lilly
+Vermont|Vt:Montpelier:VT:{red }clover
+Virginia|Va:Richmond:VA:dogwood
+Wash{ington}|WA:Olympia:WA:rhododendron
+W{est} Virginia|W{ }Va|WV:Charleston:WV:rhododendron
+Wisconsin|Wis|WI:Madison:WI:violet
+Wyo{ming}|WY:Cheyenne:WY:indian paint brush
diff --git a/games/quiz/datfiles/trek b/games/quiz/datfiles/trek
new file mode 100644
index 0000000..11740b8
--- /dev/null
+++ b/games/quiz/datfiles/trek
@@ -0,0 +1,19 @@
+captain's name:{James |Jim }{T. }Kirk|{james |jim }{t. }kirk
+first officers name:Spock|spock|Mr. Spock|mr. spock
+name of ship:{the }{u.s.s. }enterprise|Enterprise
+name of the "good guys":{the }Federation|federation|{the }federation
+name of the "bad guys":{the }klingons|{the }romulans
+nickname of chief engineer:scotty|Scotty
+nickname of chief medical officer:bones|Bones
+machine used for transportation to surface of nearby planet:transporter|shuttlecraft
+main engines of ship:warp engines|warp
+number of crew:400|four hundred
+hand-held weapon:phaser
+type of torpedoes used on the ship:photon torpedoes|photon
+name of electronic protective device on ship:shields|shield
+name of device that makes a ship invisible:cloaking device|cloak|cloaking
+type of voice that the on-board computer has:female|feminine|woman's
+where first officer comes from:vulcan|Vulcan
+rare, but very powerful enemies:romulans|Romulans
+reaction that main engines operate on:matter-antimatter{ reaction}|matter/antimatter{ reaction}
+slow engines used in emergencies:impulse engines|impulse
diff --git a/games/quiz/datfiles/ucc b/games/quiz/datfiles/ucc
new file mode 100644
index 0000000..d852b95
--- /dev/null
+++ b/games/quiz/datfiles/ucc
@@ -0,0 +1,127 @@
+1-103:supplementary general principles of law applicable
+1-106:remedies to be liberally administered
+1-201:general definitions
+1-203:obligation of good faith
+1-205:course of dealing and usage of trade
+1-206:statue of frauds for kinds of personal property not otherwise covered
+2-103:definitions-sales
+2-201:statute of frauds
+2-208:course of performance or practical consideration
+2-302:unconscionable contract or clause
+2-310:open time for payment or running of credit
+2-319:FOB and FAS terms
+2-320:CIF and C&F terms
+2-323:form of bill of lading required in overseas shipment
+2-401:passing of title; reservation for security
+2-402:rights of seller's creditors against sold goods
+2-403:powr to transfer; good faith purchase of goods; entrusting
+2-501:insurable interest in goods; manner of identification of goods
+2-502:buyer's right to goods on seller's insolvency
+2-503:manner of seller's tender of delivery
+2-506:rights of financing agency
+2-507:effect of seller's tender; delivery on condition
+2-508:cure by seller of improper tender or delivery; replacement
+2-509:risk of loss in the absence ogf breach
+2-510:effect of breach on risk of loss
+2-513:buyer's right to inspection of goods
+2-601:buyer's rights on improper delivery
+2-602:manner and effect of rightful rejection
+2-603:merchant buyer's duties as to rightfully rejected goods
+2-605:waiver of buyer's objections by failure to particularize
+2-606:what constitutes acceptance of goods
+2-607:effect of acceptance; notice of breach
+2-608:revocation of acceptance in whole or in part
+2-609:right to adequate assurance of performance
+2-610:anticipatory repudiation
+2-611:retraction of anticipatory repudiation
+2-612:installment contract; breach
+2-702:seller's remedies on discovery o buyer's insolvency
+2-703:seller's remedies in general
+2-705:seller's stoppage of delivery in transit or otherwise
+2-706:seller's resale including contract for resale
+2-708:seller's damages for non-acceptance or repudiation
+2-709:action for the price
+2-711:buyer's remedies in general; buyer's security interest in rejected goods
+2-712:cover; buyer's procurement of substitute goods
+2-713:buyer's damages for on-delivery or repudiation
+2-714:buyer's damages for breach in regard to accepted goods
+2-715:buyer's incidental and consequential damages
+2-716:buyer's right to specific performance or replevin
+3-102:definitions-commercial paper
+3-104:form of negotiable instruments; draft; check; certificate of deposit; note
+3-110:payable to order
+3-111:payable to bearer
+3-201:transfer: right to indorsement
+3-202:negotiation
+3-204:special indorsement; blank indorsement
+3-301:rights of a holder
+3-302:holder in due course
+3-305:rights of a holder in due course
+3-306:rights of one not holder in due course
+3-401:signature
+3-404:unauthorized signature
+3-405:impostors; signature in name of payee
+3-406:negligence contributing to alteration or unauthorized signature
+3-407:alteration
+3-410:definition and operation of acceptance
+3-411:certification of a check
+3-413:contract of maker, drawer and acceptor
+3-414:contract of indorser; order of liability
+3-417:warranties on presentment and transfer
+3-418:finality of payment or acceptance
+3-419:conversion of instrument; innocent representative
+3-501:when presentment, notice of dishonor, and protest necessary or permissible
+3-502:unexcused delay; discharge
+3-503:time or presentment
+3-507:dishonor; holder's right of recourse; term allowing representment
+3-508:notice of dishonor
+3-511:waived or excused presentment, protest or notice of dishonor or delay therein
+3-601:discharge of parties
+3-802:effect of instrument on obligation for which it is given
+3-804:lost,destroyed or stolen instruments
+4-104:definitions-bank deposits and collections
+4-105:banks-depositary, intermediary, collecting, payor, presenting, remitting
+4-207:warranties of customer and collecting bank on transfer or presentment of items
+4-208:security interest of collecting bank in items, accompanying documents and proceeds
+4-209:when bank gives value for purposes of holder in due course
+4-211:media of remittance; provision and final settlement in remittance cases
+4-213:final payment of item by payor bank
+4-401:when bank may charge customer's account
+4-406:customer's duty to discover and report unauthorized signature or alteration
+4-402:bank liability to customer for wrongful dishonor
+4-407:payor bank's right to subrogation on improper payment
+5-111:warranties on transfer and presentment (letters of credit)
+5-114:issuer's duty and privilege to honor; right to reimbursement
+5-115:remedy for improper dishonor or anticipatory repudiaion (letters of credit)
+7-104:negotiable and non-negotiable warehouse receipt, bill of lading, other title
+7-204:duty of care; contractual limitation of warehouseperson's liability
+7-301:liability for non-receipt or misdescription
+7-403:obligation of warehouseperson or carrier to deliver; excuse
+7-404:no liability for good faith delivery pursuant to receipt or bill
+7-501:form of negotiation and requirements of due negotiation
+7-502:rights acquired by due negotiation
+7-503:document of title to goods defeated in certain cases
+7-504:rights acquired in absence of due negotiation; effect of diversion
+7-507:warranties on negotiation or transfer of receipt or bill
+7-508:warranties of collecting bank as to documents
+9-105:definitions-secured transactions
+9-107:definitions "purchase money security interest"
+9-109:classification of goods; consumer goods; equipment; farm products; inventory
+9-113:security interests arising under article on sales
+9-203:attachment and enforceability of security interest; proceeds; formal requisites
+9-206:agreement not to asserr defenses against assignee; modification of sales warranties
+9-301:persons who take priority over unperfected security interests
+9-302:when filing is required to perfect security interest
+9-303:when security interest is perfected
+9-304:perfection of security interest in instruments, documents
+9-305:when possession by secured party perfects security interest without filing
+9-306:proceeds; secured party's rights on disposition of collateral
+9-307:protection of buyers of goods
+9-310:periority of certain liens arising by opration of law (mechanic's liens)
+9-311:alienability of debtor's rights; judicial process
+9-312:priorities among conflicting security interests in the same collateral
+9-405:assignment of security interest
+9-501:default; procedure when security agreement covers real and personal property
+9-503:secured party's right to take possession after default
+9-504:secured party's right to dispose of collateral after default
+9-505:compulsory disposition of collateral; acceptance of collateral as discharge of obligation
diff --git a/games/quiz/pathnames.h b/games/quiz/pathnames.h
new file mode 100644
index 0000000..08f4a6b
--- /dev/null
+++ b/games/quiz/pathnames.h
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)pathnames.h 8.1 (Berkeley) 5/31/93
+ */
+
+#define _PATH_PAGER "/usr/bin/more"
+#define _PATH_QUIZIDX "/usr/share/games/quiz.db/index"
diff --git a/games/quiz/quiz.6 b/games/quiz/quiz.6
new file mode 100644
index 0000000..d658703
--- /dev/null
+++ b/games/quiz/quiz.6
@@ -0,0 +1,119 @@
+.\" Copyright (c) 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Jim R. Oldroyd at The Instruction Set.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)quiz.6 8.1 (Berkeley) 5/31/93
+.\"
+.Dd May 31, 1993
+.Dt QUIZ 6
+.Os
+.Sh NAME
+.Nm quiz
+.Nd random knowledge tests
+.Sh SYNOPSIS
+.Nm quiz
+.Op Fl t
+.Op Fl i Ar file
+.Op Ar question answer
+.Sh DESCRIPTION
+The
+.Nm quiz
+utility tests your knowledge of random facts.
+It has a database of subjects from which you can choose.
+With no arguments,
+.Nm quiz
+displays the list of available subjects.
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl t
+Use tutorial mode, in which questions are repeated later if you didn't get
+them right the first time, and new questions are presented less frequently
+to help you learn the older ones.
+.It Fl i
+Specify an alternate index file.
+.El
+.Pp
+Subjects are divided into categories.
+You can pick any two categories from the same subject.
+.Nm Quiz
+will ask questions from the first category and it expects answers from
+the second category.
+For example, the command ``quiz victim killer'' asks questions which are
+the names of victims, and expects you to answer with the cause of their
+untimely demise, whereas the command ``quiz killer victim'' works the
+other way around.
+.Pp
+If you get the answer wrong,
+.Nm quiz
+lets you try again.
+To see the right answer, enter a blank line.
+.Sh "Index and Data File Syntax"
+The index and data files have a similar syntax.
+Lines in them consist of several categories separated by colons.
+The categories are regular expressions formed using the following
+meta-characters:
+.sp
+.Bl -tag -width "pat|pat" -compact -offset indent
+.It pat|pat
+alternate patterns
+.It {pat}
+optional pattern
+.It [pat]
+delimiters, as in pat[pat|pat]pat
+.El
+.Pp
+In an index file, each line represents a subject.
+The first category in each subject is the pathname of the data file for
+the subject.
+The remaining categories are regular expressions for the titles of each
+category in the subject.
+.Pp
+In data files, each line represents a question/answer set.
+Each category is the information for the question/answer for that category.
+.Pp
+The backslash character (``\e'') is used to quote syntactically significant
+characters, or at the end of a line to signify that a continuation line
+follows.
+.Pp
+If either a question or its answer is empty,
+.Nm quiz
+will refrain from asking it.
+.Sh FILES
+.Bl -tag -width /usr/share/games/quiz.db -compact
+.It Pa /usr/share/games/quiz.db
+The default index and data files.
+.El
+.Sh BUGS
+.Nm Quiz
+is pretty cynical about certain subjects.
diff --git a/games/quiz/quiz.c b/games/quiz/quiz.c
new file mode 100644
index 0000000..aa5f527
--- /dev/null
+++ b/games/quiz/quiz.c
@@ -0,0 +1,383 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jim R. Oldroyd at The Instruction Set and Keith Gabryelski at
+ * Commodore Business Machines.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1991, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)quiz.c 8.2 (Berkeley) 1/3/94";
+#endif /* not lint */
+
+#include <sys/types.h>
+#include <errno.h>
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include "quiz.h"
+#include "pathnames.h"
+
+static QE qlist;
+static int catone, cattwo, tflag;
+static u_int qsize;
+
+char *appdstr __P((char *, char *, size_t));
+void downcase __P((char *));
+void err __P((const char *, ...));
+void get_cats __P((char *, char *));
+void get_file __P((char *));
+char *next_cat __P((char *));
+void quiz __P((void));
+void score __P((u_int, u_int, u_int));
+void show_index __P((void));
+void usage __P((void));
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ register int ch;
+ char *indexfile;
+
+ indexfile = _PATH_QUIZIDX;
+ while ((ch = getopt(argc, argv, "i:t")) != EOF)
+ switch(ch) {
+ case 'i':
+ indexfile = optarg;
+ break;
+ case 't':
+ tflag = 1;
+ break;
+ case '?':
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ switch(argc) {
+ case 0:
+ get_file(indexfile);
+ show_index();
+ break;
+ case 2:
+ get_file(indexfile);
+ get_cats(argv[0], argv[1]);
+ quiz();
+ break;
+ default:
+ usage();
+ }
+ exit(0);
+}
+
+void
+get_file(file)
+ char *file;
+{
+ register FILE *fp;
+ register QE *qp;
+ size_t len;
+ char *lp;
+
+ if ((fp = fopen(file, "r")) == NULL)
+ err("%s: %s", file, strerror(errno));
+
+ /*
+ * XXX
+ * Should really free up space from any earlier read list
+ * but there are no reverse pointers to do so with.
+ */
+ qp = &qlist;
+ qsize = 0;
+ while ((lp = fgetln(fp, &len)) != NULL) {
+ if (qp->q_text && qp->q_text[strlen(qp->q_text) - 1] == '\\')
+ qp->q_text = appdstr(qp->q_text, lp, len);
+ else {
+ if ((qp->q_next = malloc(sizeof(QE))) == NULL)
+ err("%s", strerror(errno));
+ qp = qp->q_next;
+ lp[len - 1] = '\0';
+ if ((qp->q_text = strdup(lp)) == NULL)
+ err("%s", strerror(errno));
+ qp->q_asked = qp->q_answered = FALSE;
+ qp->q_next = NULL;
+ ++qsize;
+ }
+ }
+ (void)fclose(fp);
+}
+
+void
+show_index()
+{
+ register QE *qp;
+ register char *p, *s;
+ FILE *pf;
+
+ if ((pf = popen(_PATH_PAGER, "w")) == NULL)
+ err("%s: %s", _PATH_PAGER, strerror(errno));
+ (void)fprintf(pf, "Subjects:\n\n");
+ for (qp = qlist.q_next; qp; qp = qp->q_next) {
+ for (s = next_cat(qp->q_text); s; s = next_cat(s)) {
+ if (!rxp_compile(s))
+ err("%s", rxperr);
+ if (p = rxp_expand())
+ (void)fprintf(pf, "%s ", p);
+ }
+ (void)fprintf(pf, "\n");
+ }
+ (void)fprintf(pf, "\n%s\n%s\n%s\n",
+"For example, \"quiz victim killer\" prints a victim's name and you reply",
+"with the killer, and \"quiz killer victim\" works the other way around.",
+"Type an empty line to get the correct answer.");
+ (void)pclose(pf);
+}
+
+void
+get_cats(cat1, cat2)
+ char *cat1, *cat2;
+{
+ register QE *qp;
+ int i;
+ char *s;
+
+ downcase(cat1);
+ downcase(cat2);
+ for (qp = qlist.q_next; qp; qp = qp->q_next) {
+ s = next_cat(qp->q_text);
+ catone = cattwo = i = 0;
+ while (s) {
+ if (!rxp_compile(s))
+ err("%s", rxperr);
+ i++;
+ if (rxp_match(cat1))
+ catone = i;
+ if (rxp_match(cat2))
+ cattwo = i;
+ s = next_cat(s);
+ }
+ if (catone && cattwo && catone != cattwo) {
+ if (!rxp_compile(qp->q_text))
+ err("%s", rxperr);
+ get_file(rxp_expand());
+ return;
+ }
+ }
+ err("invalid categories");
+}
+
+void
+quiz()
+{
+ register QE *qp;
+ register int i;
+ size_t len;
+ u_int guesses, rights, wrongs;
+ int next;
+ char *answer, *s, *t, question[LINE_SZ];
+
+ srandom(time(NULL));
+ guesses = rights = wrongs = 0;
+ for (;;) {
+ if (qsize == 0)
+ break;
+ next = random() % qsize;
+ qp = qlist.q_next;
+ for (i = 0; i < next; i++)
+ qp = qp->q_next;
+ while (qp && qp->q_answered)
+ qp = qp->q_next;
+ if (!qp) {
+ qsize = next;
+ continue;
+ }
+ if (tflag && random() % 100 > 20) {
+ /* repeat questions in tutorial mode */
+ while (qp && (!qp->q_asked || qp->q_answered))
+ qp = qp->q_next;
+ if (!qp)
+ continue;
+ }
+ s = qp->q_text;
+ for (i = 0; i < catone - 1; i++)
+ s = next_cat(s);
+ if (!rxp_compile(s))
+ err("%s", rxperr);
+ t = rxp_expand();
+ if (!t || *t == '\0') {
+ qp->q_answered = TRUE;
+ continue;
+ }
+ (void)strcpy(question, t);
+ s = qp->q_text;
+ for (i = 0; i < cattwo - 1; i++)
+ s = next_cat(s);
+ if (!rxp_compile(s))
+ err("%s", rxperr);
+ t = rxp_expand();
+ if (!t || *t == '\0') {
+ qp->q_answered = TRUE;
+ continue;
+ }
+ qp->q_asked = TRUE;
+ (void)printf("%s?\n", question);
+ for (;; ++guesses) {
+ if ((answer = fgetln(stdin, &len)) == NULL) {
+ score(rights, wrongs, guesses);
+ exit(0);
+ }
+ answer[len - 1] = '\0';
+ downcase(answer);
+ if (rxp_match(answer)) {
+ (void)printf("Right!\n");
+ ++rights;
+ qp->q_answered = TRUE;
+ break;
+ }
+ if (*answer == '\0') {
+ (void)printf("%s\n", t);
+ ++wrongs;
+ if (!tflag)
+ qp->q_answered = TRUE;
+ break;
+ }
+ (void)printf("What?\n");
+ }
+ }
+ score(rights, wrongs, guesses);
+}
+
+char *
+next_cat(s)
+ register char * s;
+{
+ for (;;)
+ switch (*s++) {
+ case '\0':
+ return (NULL);
+ case '\\':
+ break;
+ case ':':
+ return (s);
+ }
+ /* NOTREACHED */
+}
+
+char *
+appdstr(s, tp, len)
+ char *s;
+ register char *tp;
+ size_t len;
+{
+ register char *mp, *sp;
+ register int ch;
+ char *m;
+
+ if ((m = malloc(strlen(s) + len + 1)) == NULL)
+ err("%s", strerror(errno));
+ for (mp = m, sp = s; *mp++ = *sp++;);
+
+ if (*(mp - 1) == '\\')
+ --mp;
+ while ((ch = *mp++ = *tp++) && ch != '\n');
+ *mp = '\0';
+
+ free(s);
+ return (m);
+}
+
+void
+score(r, w, g)
+ u_int r, w, g;
+{
+ (void)printf("Rights %d, wrongs %d,", r, w);
+ if (g)
+ (void)printf(" extra guesses %d,", g);
+ (void)printf(" score %d%%\n", (r + w + g) ? r * 100 / (r + w + g) : 0);
+}
+
+void
+downcase(p)
+ register char *p;
+{
+ register int ch;
+
+ for (; ch = *p; ++p)
+ if (isascii(ch) && isupper(ch))
+ *p = tolower(ch);
+}
+
+void
+usage()
+{
+ (void)fprintf(stderr, "quiz [-t] [-i file] category1 category2\n");
+ exit(1);
+}
+
+#if __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+void
+#if __STDC__
+err(const char *fmt, ...)
+#else
+err(fmt, va_alist)
+ char *fmt;
+ va_dcl
+#endif
+{
+ va_list ap;
+#if __STDC__
+ va_start(ap, fmt);
+#else
+ va_start(ap);
+#endif
+ (void)fprintf(stderr, "quiz: ");
+ (void)vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ (void)fprintf(stderr, "\n");
+ exit(1);
+}
diff --git a/games/quiz/quiz.h b/games/quiz/quiz.h
new file mode 100644
index 0000000..8923c8f
--- /dev/null
+++ b/games/quiz/quiz.h
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jim R. Oldroyd at The Instruction Set and Keith Gabryelski at
+ * Commodore Business Machines.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)quiz.h 8.1 (Berkeley) 5/31/93
+ */
+
+#define TRUE 1
+#define FALSE 0
+
+/* Length of compiled regexp machine; increase if not big enough. */
+#define RXP_LINE_SZ 8192
+
+/* Maximum line length for data files. */
+#define LINE_SZ 1024
+
+/* Linked list for holding index and data file information. */
+typedef struct qentry {
+ struct qentry *q_next; /* next one */
+ char *q_text; /* category text string from file */
+ int q_asked; /* TRUE if question's been asked */
+ int q_answered; /* TRUE if question's been answered */
+} QE;
+
+extern char rxperr[];
+
+int rxp_compile __P((char *));
+char *rxp_expand __P((void));
+int rxp_match __P((char *));
diff --git a/games/quiz/rxp.c b/games/quiz/rxp.c
new file mode 100644
index 0000000..4b6a74f
--- /dev/null
+++ b/games/quiz/rxp.c
@@ -0,0 +1,313 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jim R. Oldroyd at The Instruction Set and Keith Gabryelski at
+ * Commodore Business Machines.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)rxp.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+/*
+ * regular expression parser
+ *
+ * external functions and return values are:
+ * rxp_compile(s)
+ * TRUE success
+ * FALSE parse failure; error message will be in char rxperr[]
+ * metas are:
+ * {...} optional pattern, equialent to [...|]
+ * | alternate pattern
+ * [...] pattern delimiters
+ *
+ * rxp_match(s)
+ * TRUE string s matches compiled pattern
+ * FALSE match failure or regexp error
+ *
+ * rxp_expand()
+ * char * reverse-engineered regular expression string
+ * NULL regexp error
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+#include "quiz.h"
+ /* regexp tokens, arg */
+#define LIT (-1) /* literal character, char */
+#define SOT (-2) /* start text anchor, - */
+#define EOT (-3) /* end text anchor, - */
+#define GRP_S (-4) /* start alternate grp, ptr_to_end */
+#define GRP_E (-5) /* end group, - */
+#define ALT_S (-6) /* alternate starts, ptr_to_next */
+#define ALT_E (-7) /* alternate ends, - */
+#define END (-8) /* end of regexp, - */
+
+typedef short Rxp_t; /* type for regexp tokens */
+
+static Rxp_t rxpbuf[RXP_LINE_SZ]; /* compiled regular expression buffer */
+char rxperr[128]; /* parser error message */
+
+static int rxp__compile __P((char *, int));
+static char *rxp__expand __P((int));
+static int rxp__match __P((char *, int, Rxp_t *, Rxp_t *, char *));
+
+int
+rxp_compile(s)
+ register char * s;
+{
+ return (rxp__compile(s, TRUE));
+}
+
+static int
+rxp__compile(s, first)
+ register char *s;
+ int first;
+{
+ static Rxp_t *rp;
+ static char *sp;
+ Rxp_t *grp_ptr;
+ Rxp_t *alt_ptr;
+ int esc, err;
+
+ esc = 0;
+ if (first) {
+ rp = rxpbuf;
+ sp = s;
+ *rp++ = SOT; /* auto-anchor: pat is really ^pat$ */
+ *rp++ = GRP_S; /* auto-group: ^pat$ is really ^[pat]$ */
+ *rp++ = 0;
+ }
+ *rp++ = ALT_S;
+ alt_ptr = rp;
+ *rp++ = 0;
+ for (; *sp; ++sp) {
+ if (rp - rxpbuf >= RXP_LINE_SZ - 4) {
+ (void)snprintf(rxperr, sizeof(rxperr),
+ "regular expression too long %s", s);
+ return (FALSE);
+ }
+ if (*sp == ':' && !esc)
+ break;
+ if (esc) {
+ *rp++ = LIT;
+ *rp++ = *sp;
+ esc = 0;
+ }
+ else switch (*sp) {
+ case '\\':
+ esc = 1;
+ break;
+ case '{':
+ case '[':
+ *rp++ = GRP_S;
+ grp_ptr = rp;
+ *rp++ = 0;
+ sp++;
+ if ((err = rxp__compile(s, FALSE)) != TRUE)
+ return (err);
+ *rp++ = GRP_E;
+ *grp_ptr = rp - rxpbuf;
+ break;
+ case '}':
+ case ']':
+ case '|':
+ *rp++ = ALT_E;
+ *alt_ptr = rp - rxpbuf;
+ if (*sp != ']') {
+ *rp++ = ALT_S;
+ alt_ptr = rp;
+ *rp++ = 0;
+ }
+ if (*sp != '|') {
+ if (*sp != ']') {
+ *rp++ = ALT_E;
+ *alt_ptr = rp - rxpbuf;
+ }
+ if (first) {
+ (void)snprintf(rxperr, sizeof(rxperr),
+ "unmatched alternator in regexp %s",
+ s);
+ return (FALSE);
+ }
+ return (TRUE);
+ }
+ break;
+ default:
+ *rp++ = LIT;
+ *rp++ = *sp;
+ esc = 0;
+ break;
+ }
+ }
+ if (!first) {
+ (void)snprintf(rxperr, sizeof(rxperr),
+ "unmatched alternator in regexp %s", s);
+ return (FALSE);
+ }
+ *rp++ = ALT_E;
+ *alt_ptr = rp - rxpbuf;
+ *rp++ = GRP_E;
+ *(rxpbuf + 2) = rp - rxpbuf;
+ *rp++ = EOT;
+ *rp = END;
+ return (TRUE);
+}
+
+/*
+ * match string against compiled regular expression
+ */
+int
+rxp_match(s)
+ register char * s;
+{
+ return (rxp__match(s, TRUE, NULL, NULL, NULL));
+}
+
+static int
+rxp__match(s, first, j_succ, j_fail, sp_fail)
+ char *s;
+ int first;
+ Rxp_t *j_succ; /* jump here on successful alt match */
+ Rxp_t *j_fail; /* jump here on failed match */
+ char *sp_fail; /* reset sp to here on failed match */
+{
+ static Rxp_t *rp;
+ static char *sp;
+ register int ch;
+ Rxp_t *grp_end;
+ int err;
+
+ if (first) {
+ rp = rxpbuf;
+ sp = s;
+ }
+ while (rp < rxpbuf + RXP_LINE_SZ && *rp != END)
+ switch(*rp) {
+ case LIT:
+ rp++;
+ ch = isascii(*rp) && isupper(*rp) ? tolower(*rp) : *rp;
+ if (ch != *sp++) {
+ rp = j_fail;
+ sp = sp_fail;
+ return (TRUE);
+ }
+ rp++;
+ break;
+ case SOT:
+ if (sp != s)
+ return (FALSE);
+ rp++;
+ break;
+ case EOT:
+ if (*sp != 0)
+ return (FALSE);
+ rp++;
+ break;
+ case GRP_S:
+ rp++;
+ grp_end = rxpbuf + *rp++;
+ break;
+ case ALT_S:
+ rp++;
+ if ((err = rxp__match(sp,
+ FALSE, grp_end, rxpbuf + *rp++, sp)) != TRUE)
+ return (err);
+ break;
+ case ALT_E:
+ rp = j_succ;
+ return (TRUE);
+ case GRP_E:
+ default:
+ return (FALSE);
+ }
+ return (*rp != END ? FALSE : TRUE);
+}
+
+/*
+ * Reverse engineer the regular expression, by picking first of all alternates.
+ */
+char *
+rxp_expand()
+{
+ return (rxp__expand(TRUE));
+}
+
+static char *
+rxp__expand(first)
+ int first;
+{
+ static char buf[RXP_LINE_SZ/2];
+ static Rxp_t *rp;
+ static char *bp;
+ Rxp_t *grp_ptr;
+ char *err;
+
+ if (first) {
+ rp = rxpbuf;
+ bp = buf;
+ }
+ while (rp < rxpbuf + RXP_LINE_SZ && *rp != END)
+ switch(*rp) {
+ case LIT:
+ rp++;
+ *bp++ = *rp++;
+ break;
+ case GRP_S:
+ rp++;
+ grp_ptr = rxpbuf + *rp;
+ rp++;
+ if ((err = rxp__expand(FALSE)) == NULL)
+ return (err);
+ rp = grp_ptr;
+ break;
+ case ALT_E:
+ return (buf);
+ case ALT_S:
+ rp++;
+ /* FALLTHROUGH */
+ case SOT:
+ case EOT:
+ case GRP_E:
+ rp++;
+ break;
+ default:
+ return (NULL);
+ }
+ if (first) {
+ if (*rp != END)
+ return (NULL);
+ *bp = '\0';
+ }
+ return (buf);
+}
diff --git a/games/x11/xneko/Makefile b/games/x11/xneko/Makefile
new file mode 100644
index 0000000..a8a9a18
--- /dev/null
+++ b/games/x11/xneko/Makefile
@@ -0,0 +1,9 @@
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
+
+PROG= xneko
+MAN6= xneko.6
+DPADD+= ${X11BASE}/lib/libX11.a ${LIBM}
+LDDESTDIR+= -L${X11BASE}/lib
+LDADD+= -lX11 -lm
+
+.include <bsd.prog.mk>
diff --git a/games/x11/xneko/bitmaps/awake.xbm b/games/x11/xneko/bitmaps/awake.xbm
new file mode 100644
index 0000000..7ad4135
--- /dev/null
+++ b/games/x11/xneko/bitmaps/awake.xbm
@@ -0,0 +1,14 @@
+#define awake_width 32
+#define awake_height 32
+static char awake_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04,
+ 0x40, 0x10, 0x10, 0x02, 0x80, 0x28, 0x28, 0x01, 0x00, 0x49, 0x24, 0x00,
+ 0x06, 0x44, 0x44, 0x60, 0x18, 0x84, 0x42, 0x18, 0x60, 0x82, 0x83, 0x06,
+ 0x00, 0x02, 0x80, 0x00, 0x00, 0x22, 0x88, 0x00, 0x0f, 0x22, 0x88, 0x78,
+ 0x00, 0x22, 0x88, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x3a, 0xb9, 0x00,
+ 0x00, 0x04, 0x40, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x70, 0x1c, 0x02,
+ 0x00, 0x40, 0x04, 0x05, 0x00, 0x20, 0x88, 0x04, 0x00, 0x10, 0x50, 0x02,
+ 0x00, 0x08, 0x20, 0x01, 0x00, 0x0b, 0xa0, 0x01, 0x80, 0x0c, 0x61, 0x02,
+ 0x40, 0x18, 0x31, 0x04, 0x40, 0x10, 0x11, 0x04, 0xc0, 0x11, 0x11, 0x07,
+ 0x60, 0x90, 0x13, 0x0c, 0xe0, 0xff, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/cursor.xbm b/games/x11/xneko/bitmaps/cursor.xbm
new file mode 100644
index 0000000..2646ea7
--- /dev/null
+++ b/games/x11/xneko/bitmaps/cursor.xbm
@@ -0,0 +1,8 @@
+#define cursor_width 17
+#define cursor_height 12
+#define cursor_x_hot 8
+#define cursor_y_hot 7
+static char cursor_bits[] = {
+ 0x20, 0x00, 0x00, 0x90, 0x20, 0x00, 0x40, 0x40, 0x00, 0x0c, 0x40, 0x00,
+ 0x14, 0x8f, 0x00, 0x94, 0xb0, 0x00, 0x7c, 0x20, 0x01, 0x0c, 0x4c, 0x01,
+ 0x0a, 0x42, 0x01, 0x42, 0x82, 0x00, 0x3b, 0x87, 0x00, 0xff, 0x7f, 0x00};
diff --git a/games/x11/xneko/bitmaps/cursor_mask.xbm b/games/x11/xneko/bitmaps/cursor_mask.xbm
new file mode 100644
index 0000000..2548715
--- /dev/null
+++ b/games/x11/xneko/bitmaps/cursor_mask.xbm
@@ -0,0 +1,6 @@
+#define cursor_mask_width 17
+#define cursor_mask_height 12
+static char cursor_mask_bits[] = {
+ 0x20, 0x00, 0x00, 0x90, 0x20, 0x00, 0x40, 0x40, 0x00, 0x0c, 0x40, 0x00,
+ 0x1c, 0x8f, 0x00, 0x9c, 0xbf, 0x00, 0xfc, 0x3f, 0x01, 0xfc, 0x7f, 0x01,
+ 0xfe, 0x7f, 0x01, 0xfe, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x7f, 0x00};
diff --git a/games/x11/xneko/bitmaps/down1.xbm b/games/x11/xneko/bitmaps/down1.xbm
new file mode 100644
index 0000000..3a8218f
--- /dev/null
+++ b/games/x11/xneko/bitmaps/down1.xbm
@@ -0,0 +1,14 @@
+#define down1_width 32
+#define down1_height 32
+static char down1_bits[] = {
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x78, 0x1e, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x02, 0x40, 0x00,
+ 0x00, 0x01, 0x80, 0x00, 0x80, 0x00, 0x00, 0x01, 0x80, 0x10, 0x10, 0x02,
+ 0x80, 0x28, 0x28, 0x02, 0x40, 0x48, 0x24, 0x04, 0x40, 0x44, 0x44, 0x04,
+ 0x40, 0x84, 0x42, 0x04, 0x40, 0x82, 0x83, 0x04, 0x40, 0x02, 0x80, 0x04,
+ 0x60, 0x02, 0x80, 0x0c, 0xc0, 0x02, 0x80, 0x06, 0x20, 0x23, 0x88, 0x09,
+ 0xa0, 0x23, 0x88, 0x0b, 0xe0, 0x22, 0x88, 0x0e, 0x80, 0x04, 0x41, 0x02,
+ 0x00, 0x0f, 0xe0, 0x01, 0x00, 0x7c, 0x7c, 0x00, 0x00, 0xc0, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/down2.xbm b/games/x11/xneko/bitmaps/down2.xbm
new file mode 100644
index 0000000..dcb92e4
--- /dev/null
+++ b/games/x11/xneko/bitmaps/down2.xbm
@@ -0,0 +1,14 @@
+#define down2_width 32
+#define down2_height 32
+static char down2_bits[] = {
+ 0x00, 0x8c, 0x61, 0x00, 0x00, 0x5a, 0xb2, 0x00, 0x00, 0x52, 0x92, 0x00,
+ 0x00, 0x52, 0x92, 0x00, 0x00, 0x61, 0x0a, 0x01, 0x00, 0x61, 0x06, 0x01,
+ 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
+ 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x80, 0x00, 0x00, 0x12, 0x90, 0x00,
+ 0x00, 0x29, 0x28, 0x01, 0x00, 0x49, 0x24, 0x01, 0x00, 0x45, 0x44, 0x01,
+ 0x00, 0x85, 0x42, 0x01, 0x00, 0x83, 0x83, 0x01, 0x00, 0x03, 0x80, 0x01,
+ 0x60, 0x03, 0x80, 0x0d, 0x80, 0x03, 0x80, 0x03, 0x00, 0x23, 0x88, 0x01,
+ 0x00, 0x23, 0x88, 0x01, 0x00, 0x22, 0x88, 0x00, 0x00, 0x06, 0xc1, 0x00,
+ 0x00, 0x0a, 0xa0, 0x00, 0x00, 0x72, 0x9c, 0x00, 0x00, 0xc2, 0x87, 0x00,
+ 0x00, 0x24, 0x48, 0x00, 0x00, 0x24, 0x48, 0x00, 0x00, 0x34, 0x58, 0x00,
+ 0x00, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/dtogi1.xbm b/games/x11/xneko/bitmaps/dtogi1.xbm
new file mode 100644
index 0000000..06cb335
--- /dev/null
+++ b/games/x11/xneko/bitmaps/dtogi1.xbm
@@ -0,0 +1,14 @@
+#define dtogi1_width 32
+#define dtogi1_height 32
+static char dtogi1_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x20, 0x01, 0x00,
+ 0x00, 0x18, 0x02, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x40, 0x04, 0x00,
+ 0x00, 0x78, 0x3c, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x02, 0x80, 0x00,
+ 0x00, 0x01, 0x00, 0x01, 0x80, 0x00, 0x00, 0x02, 0x80, 0x10, 0x10, 0x02,
+ 0x80, 0x28, 0x28, 0x02, 0xc0, 0x48, 0x24, 0x06, 0x30, 0x45, 0x44, 0x19,
+ 0x08, 0x84, 0x42, 0x20, 0xf8, 0x83, 0x83, 0x3f, 0x00, 0x02, 0x80, 0x00,
+ 0x00, 0x02, 0x80, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x22, 0x88, 0x00,
+ 0x00, 0x22, 0x88, 0x00, 0x00, 0x26, 0x88, 0x00, 0x00, 0x06, 0x41, 0x00,
+ 0x00, 0x0a, 0x60, 0x00, 0x00, 0x72, 0x5c, 0x00, 0x00, 0xd2, 0x57, 0x00,
+ 0x00, 0x52, 0x54, 0x00, 0x00, 0x5a, 0x54, 0x00, 0x00, 0x54, 0x54, 0x00,
+ 0x00, 0x54, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/dtogi2.xbm b/games/x11/xneko/bitmaps/dtogi2.xbm
new file mode 100644
index 0000000..4b9105e
--- /dev/null
+++ b/games/x11/xneko/bitmaps/dtogi2.xbm
@@ -0,0 +1,14 @@
+#define dtogi2_width 32
+#define dtogi2_height 32
+static char dtogi2_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x12, 0x00,
+ 0x00, 0x00, 0x11, 0x00, 0x00, 0x80, 0x08, 0x00, 0x00, 0x80, 0x04, 0x00,
+ 0x00, 0xf0, 0x3c, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x04, 0x80, 0x00,
+ 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x80, 0x10, 0x10, 0x02,
+ 0x80, 0x28, 0x28, 0x02, 0xc0, 0x48, 0x24, 0x06, 0x30, 0x45, 0x44, 0x19,
+ 0x08, 0x84, 0x42, 0x20, 0xf8, 0x83, 0x83, 0x3f, 0x00, 0x02, 0x80, 0x00,
+ 0x00, 0x02, 0x80, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x22, 0x88, 0x00,
+ 0x00, 0x22, 0x88, 0x00, 0x00, 0x22, 0xc8, 0x00, 0x00, 0x04, 0xc1, 0x00,
+ 0x00, 0x0c, 0xa0, 0x00, 0x00, 0x74, 0x9c, 0x00, 0x00, 0xd4, 0x97, 0x00,
+ 0x00, 0x54, 0x94, 0x00, 0x00, 0x54, 0xb4, 0x00, 0x00, 0x54, 0x54, 0x00,
+ 0x00, 0x50, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/dwleft1.xbm b/games/x11/xneko/bitmaps/dwleft1.xbm
new file mode 100644
index 0000000..d529546
--- /dev/null
+++ b/games/x11/xneko/bitmaps/dwleft1.xbm
@@ -0,0 +1,14 @@
+#define dwleft1_width 32
+#define dwleft1_height 32
+static char dwleft1_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
+ 0x00, 0x00, 0x1c, 0x07, 0x00, 0xc0, 0x07, 0x08, 0x00, 0x20, 0xf0, 0x07,
+ 0x00, 0x10, 0xc0, 0x01, 0x00, 0x08, 0x00, 0x03, 0x18, 0x0f, 0x00, 0x06,
+ 0x28, 0x0d, 0x00, 0x04, 0x48, 0x09, 0x10, 0x04, 0x88, 0x11, 0x08, 0x04,
+ 0x08, 0x20, 0x04, 0x04, 0x08, 0x40, 0x04, 0x04, 0x08, 0x40, 0x04, 0x02,
+ 0x24, 0x42, 0x04, 0x02, 0x24, 0x42, 0x04, 0x02, 0x27, 0xf2, 0x08, 0x02,
+ 0x04, 0x00, 0x08, 0x02, 0x24, 0x00, 0x08, 0x02, 0x04, 0x00, 0x11, 0x01,
+ 0x68, 0x20, 0x91, 0x00, 0xf0, 0x1f, 0x8a, 0x00, 0xc0, 0x1f, 0x4a, 0x00,
+ 0x00, 0x3f, 0x4c, 0x00, 0x00, 0xfe, 0x24, 0x00, 0x00, 0x8c, 0x37, 0x00,
+ 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/dwleft2.xbm b/games/x11/xneko/bitmaps/dwleft2.xbm
new file mode 100644
index 0000000..6248e70
--- /dev/null
+++ b/games/x11/xneko/bitmaps/dwleft2.xbm
@@ -0,0 +1,14 @@
+#define dwleft2_width 32
+#define dwleft2_height 32
+static char dwleft2_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x3f, 0x00, 0x00, 0xe0, 0x40, 0x3e, 0x00, 0x90, 0x38, 0x41,
+ 0x00, 0x20, 0x89, 0x38, 0x00, 0x60, 0x72, 0x04, 0x00, 0x90, 0x1c, 0x04,
+ 0x00, 0x08, 0x00, 0x04, 0x80, 0x0d, 0x00, 0x04, 0x86, 0x07, 0x00, 0x04,
+ 0xde, 0x0c, 0x00, 0x04, 0xf2, 0x18, 0x00, 0x02, 0xe2, 0x31, 0x00, 0x01,
+ 0x86, 0x60, 0x80, 0x00, 0x04, 0x40, 0x60, 0x00, 0x04, 0x80, 0x10, 0x00,
+ 0x04, 0x00, 0x08, 0x00, 0x15, 0x71, 0x08, 0x00, 0x16, 0x09, 0x04, 0x00,
+ 0x14, 0x81, 0x04, 0x00, 0x04, 0x40, 0x02, 0x00, 0x2c, 0x30, 0x01, 0x00,
+ 0x18, 0x8f, 0x00, 0x00, 0xf8, 0x43, 0x00, 0x00, 0x7c, 0x22, 0x00, 0x00,
+ 0x3c, 0x22, 0x00, 0x00, 0x3c, 0x12, 0x00, 0x00, 0x18, 0x0e, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/dwright1.xbm b/games/x11/xneko/bitmaps/dwright1.xbm
new file mode 100644
index 0000000..e071a2f
--- /dev/null
+++ b/games/x11/xneko/bitmaps/dwright1.xbm
@@ -0,0 +1,14 @@
+#define dwright1_width 32
+#define dwright1_height 32
+static char dwright1_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
+ 0xe0, 0x38, 0x00, 0x00, 0x10, 0xe0, 0x03, 0x00, 0xe0, 0x0f, 0x04, 0x00,
+ 0x80, 0x03, 0x08, 0x00, 0xc0, 0x00, 0x10, 0x00, 0x60, 0x00, 0xf0, 0x18,
+ 0x20, 0x00, 0xb0, 0x14, 0x20, 0x08, 0x90, 0x12, 0x20, 0x10, 0x88, 0x11,
+ 0x20, 0x20, 0x04, 0x10, 0x20, 0x20, 0x02, 0x10, 0x40, 0x20, 0x02, 0x10,
+ 0x40, 0x20, 0x42, 0x24, 0x40, 0x20, 0x42, 0x24, 0x40, 0x10, 0x4f, 0xe4,
+ 0x40, 0x10, 0x00, 0x20, 0x40, 0x10, 0x00, 0x24, 0x80, 0x88, 0x00, 0x20,
+ 0x00, 0x89, 0x04, 0x16, 0x00, 0x51, 0xf8, 0x0f, 0x00, 0x52, 0xf8, 0x03,
+ 0x00, 0x32, 0xfc, 0x00, 0x00, 0x24, 0x7f, 0x00, 0x00, 0xec, 0x31, 0x00,
+ 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/dwright2.xbm b/games/x11/xneko/bitmaps/dwright2.xbm
new file mode 100644
index 0000000..6565caa
--- /dev/null
+++ b/games/x11/xneko/bitmaps/dwright2.xbm
@@ -0,0 +1,14 @@
+#define dwright2_width 32
+#define dwright2_height 32
+static char dwright2_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0x01, 0x00, 0x7c, 0x02, 0x07, 0x00, 0x82, 0x1c, 0x09, 0x00,
+ 0x1c, 0x91, 0x04, 0x00, 0x20, 0x4e, 0x06, 0x00, 0x20, 0x38, 0x09, 0x00,
+ 0x20, 0x00, 0x10, 0x00, 0x20, 0x00, 0xb0, 0x01, 0x20, 0x00, 0xe0, 0x61,
+ 0x20, 0x00, 0x30, 0x7b, 0x40, 0x00, 0x18, 0x4f, 0x80, 0x00, 0x8c, 0x47,
+ 0x00, 0x01, 0x06, 0x61, 0x00, 0x06, 0x02, 0x20, 0x00, 0x08, 0x01, 0x20,
+ 0x00, 0x10, 0x00, 0x20, 0x00, 0x10, 0x8e, 0xa8, 0x00, 0x20, 0x90, 0x68,
+ 0x00, 0x20, 0x81, 0x28, 0x00, 0x40, 0x02, 0x20, 0x00, 0x80, 0x0c, 0x34,
+ 0x00, 0x00, 0xf1, 0x18, 0x00, 0x00, 0xc2, 0x1f, 0x00, 0x00, 0x44, 0x3e,
+ 0x00, 0x00, 0x44, 0x3c, 0x00, 0x00, 0x48, 0x3c, 0x00, 0x00, 0x70, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/icon.xbm b/games/x11/xneko/bitmaps/icon.xbm
new file mode 100644
index 0000000..f1f6f05
--- /dev/null
+++ b/games/x11/xneko/bitmaps/icon.xbm
@@ -0,0 +1,14 @@
+#define icon_width 32
+#define icon_height 32
+static char icon_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x06, 0xc0, 0x01, 0x00, 0x07,
+ 0x40, 0x03, 0x80, 0x0f, 0x60, 0x06, 0x80, 0x1f, 0xa0, 0x05, 0xc0, 0x1d,
+ 0xb0, 0xea, 0xcf, 0x1f, 0x50, 0x3c, 0xf8, 0x3f, 0x58, 0x03, 0xc0, 0x3f,
+ 0xc8, 0x01, 0x00, 0x3f, 0x68, 0x00, 0x00, 0x3e, 0x38, 0x00, 0x00, 0x3c,
+ 0x08, 0x00, 0x00, 0x38, 0x08, 0x00, 0x00, 0x20, 0x8c, 0x0f, 0xf8, 0x20,
+ 0x44, 0x10, 0x04, 0x21, 0x24, 0x28, 0x0a, 0x22, 0x26, 0x20, 0x02, 0x22,
+ 0x42, 0x10, 0x04, 0x41, 0x82, 0x0f, 0xf8, 0x40, 0x02, 0x00, 0x00, 0x40,
+ 0x02, 0x80, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x63, 0x00, 0x00, 0x80,
+ 0x91, 0x00, 0x00, 0xc7, 0x49, 0x00, 0x80, 0xc9, 0xa9, 0x20, 0x82, 0xe2,
+ 0xa1, 0xc0, 0x01, 0xa5, 0xa3, 0x00, 0x00, 0xa5, 0x05, 0x00, 0x00, 0x91,
+ 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80};
diff --git a/games/x11/xneko/bitmaps/jare2.xbm b/games/x11/xneko/bitmaps/jare2.xbm
new file mode 100644
index 0000000..86723f7
--- /dev/null
+++ b/games/x11/xneko/bitmaps/jare2.xbm
@@ -0,0 +1,14 @@
+#define jare2_width 32
+#define jare2_height 32
+static char jare2_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
+ 0x00, 0xd0, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x10, 0x02, 0x00,
+ 0xe0, 0x10, 0x0c, 0x00, 0x20, 0x37, 0x10, 0x00, 0x20, 0x18, 0x20, 0x00,
+ 0x40, 0x00, 0x41, 0x00, 0x40, 0x00, 0x42, 0x00, 0x40, 0x00, 0x50, 0x00,
+ 0x40, 0x08, 0x48, 0x00, 0x80, 0x10, 0x41, 0x00, 0x80, 0x00, 0x3c, 0x00,
+ 0x00, 0x39, 0x22, 0x00, 0x00, 0x02, 0x44, 0x00, 0x00, 0x7c, 0x7c, 0x00,
+ 0x00, 0x40, 0x44, 0x00, 0x00, 0x20, 0x46, 0x00, 0x00, 0x10, 0x40, 0x00,
+ 0x00, 0x08, 0x30, 0x00, 0x00, 0x0b, 0xa4, 0x01, 0x80, 0x0c, 0x63, 0x02,
+ 0x40, 0x18, 0x01, 0x04, 0x40, 0x10, 0x01, 0x3c, 0xc0, 0x11, 0x05, 0x47,
+ 0x60, 0x90, 0x03, 0x3c, 0xe0, 0xff, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/kaki1.xbm b/games/x11/xneko/bitmaps/kaki1.xbm
new file mode 100644
index 0000000..3f2cbdf
--- /dev/null
+++ b/games/x11/xneko/bitmaps/kaki1.xbm
@@ -0,0 +1,14 @@
+#define kaki1_width 32
+#define kaki1_height 32
+static char kaki1_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00,
+ 0x00, 0x62, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00,
+ 0x3c, 0x02, 0x34, 0x00, 0xc4, 0x03, 0x58, 0x00, 0x08, 0x00, 0x58, 0x00,
+ 0x08, 0x20, 0x58, 0x00, 0x10, 0x10, 0xd8, 0x00, 0x20, 0x08, 0x18, 0x01,
+ 0x20, 0xc8, 0x18, 0x02, 0xe0, 0x21, 0x18, 0x04, 0x20, 0x00, 0x34, 0x08,
+ 0xe0, 0x05, 0x24, 0x08, 0xc0, 0x60, 0x38, 0x08, 0x00, 0x1f, 0x10, 0x08,
+ 0x00, 0x08, 0x20, 0x08, 0x00, 0x0b, 0x20, 0x08, 0x80, 0x0c, 0x21, 0x0c,
+ 0x40, 0x18, 0x31, 0x04, 0x40, 0x10, 0x11, 0x02, 0xc0, 0x11, 0x91, 0x7f,
+ 0x60, 0x90, 0xf3, 0x80, 0xe0, 0xff, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/kaki2.xbm b/games/x11/xneko/bitmaps/kaki2.xbm
new file mode 100644
index 0000000..88d9540
--- /dev/null
+++ b/games/x11/xneko/bitmaps/kaki2.xbm
@@ -0,0 +1,14 @@
+#define kaki2_width 32
+#define kaki2_height 32
+static char kaki2_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00,
+ 0x20, 0x90, 0x00, 0x00, 0x50, 0x10, 0x01, 0x00, 0x90, 0x08, 0x02, 0x00,
+ 0x10, 0x09, 0x04, 0x00, 0x10, 0x06, 0x08, 0x00, 0x10, 0x00, 0x08, 0x00,
+ 0x20, 0x00, 0x10, 0x00, 0x20, 0x80, 0x10, 0x00, 0x20, 0x60, 0x10, 0x00,
+ 0x20, 0x10, 0x08, 0x00, 0xe0, 0x81, 0xf9, 0x03, 0x20, 0x60, 0x18, 0x04,
+ 0xe0, 0xc5, 0x0f, 0x08, 0xc0, 0xe0, 0x00, 0x08, 0x00, 0x9f, 0x11, 0x08,
+ 0x00, 0x08, 0x2e, 0x08, 0x00, 0x0b, 0x20, 0x08, 0x80, 0x0c, 0x21, 0x08,
+ 0x40, 0x18, 0x31, 0x04, 0x40, 0x10, 0x11, 0x04, 0xc0, 0x11, 0x91, 0x7f,
+ 0x60, 0x90, 0xf3, 0x80, 0xe0, 0xff, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/left1.xbm b/games/x11/xneko/bitmaps/left1.xbm
new file mode 100644
index 0000000..706bbff
--- /dev/null
+++ b/games/x11/xneko/bitmaps/left1.xbm
@@ -0,0 +1,14 @@
+#define left1_width 32
+#define left1_height 32
+static char left1_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0e, 0x00, 0x00, 0x80, 0x31, 0x00, 0x00, 0x60, 0xc0, 0x00,
+ 0x00, 0x10, 0x00, 0x01, 0x00, 0x08, 0x00, 0x01, 0x0c, 0x04, 0x00, 0x02,
+ 0x14, 0x04, 0x00, 0x04, 0x64, 0x02, 0x00, 0x08, 0x88, 0x03, 0x01, 0x12,
+ 0x08, 0x84, 0x00, 0x23, 0x08, 0x80, 0x00, 0x45, 0x04, 0x40, 0x00, 0x49,
+ 0x12, 0x40, 0x00, 0x92, 0x12, 0x40, 0x00, 0xa4, 0x12, 0x87, 0x00, 0xc2,
+ 0xc3, 0x81, 0x00, 0x01, 0x01, 0x40, 0x03, 0x01, 0x02, 0x80, 0x9e, 0x01,
+ 0x04, 0x03, 0x91, 0x01, 0xf8, 0x0e, 0xce, 0x03, 0x00, 0x3c, 0xc8, 0x03,
+ 0x00, 0xf8, 0x2f, 0x03, 0x00, 0xf0, 0x38, 0x00, 0x00, 0xe0, 0x18, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/left2.xbm b/games/x11/xneko/bitmaps/left2.xbm
new file mode 100644
index 0000000..f0d1aed
--- /dev/null
+++ b/games/x11/xneko/bitmaps/left2.xbm
@@ -0,0 +1,14 @@
+#define left2_width 32
+#define left2_height 32
+static char left2_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x20, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0x90, 0xa0, 0x00, 0x00, 0x88,
+ 0x20, 0x01, 0x00, 0x44, 0x20, 0x02, 0x00, 0x22, 0x30, 0x0c, 0x00, 0x11,
+ 0x08, 0x10, 0xc0, 0x08, 0x24, 0x30, 0x38, 0x08, 0x24, 0x20, 0x06, 0x08,
+ 0x24, 0x40, 0x01, 0x10, 0x02, 0xc0, 0x00, 0x10, 0xc2, 0x03, 0x00, 0x10,
+ 0x02, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x10, 0x78, 0x00, 0x00, 0x20,
+ 0x80, 0x07, 0x08, 0x20, 0x80, 0x01, 0x30, 0xc0, 0xc0, 0x00, 0xc0, 0x81,
+ 0x60, 0x18, 0xf8, 0x9f, 0x30, 0xfc, 0x87, 0xbf, 0x18, 0x3f, 0x00, 0xf8,
+ 0xcc, 0x07, 0x00, 0x30, 0x38, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/ltogi1.xbm b/games/x11/xneko/bitmaps/ltogi1.xbm
new file mode 100644
index 0000000..a52961c
--- /dev/null
+++ b/games/x11/xneko/bitmaps/ltogi1.xbm
@@ -0,0 +1,14 @@
+#define ltogi1_width 32
+#define ltogi1_height 32
+static char ltogi1_bits[] = {
+ 0xc0, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00,
+ 0x43, 0x04, 0x00, 0x00, 0x37, 0x18, 0x00, 0x00, 0x0f, 0x20, 0x00, 0x00,
+ 0x07, 0x40, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00,
+ 0x2d, 0x40, 0x00, 0x00, 0x31, 0x40, 0x00, 0x00, 0xc1, 0xa0, 0x0f, 0x00,
+ 0x03, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x40, 0x00, 0x38, 0xc0, 0x80, 0x00,
+ 0x70, 0x20, 0x00, 0x01, 0x40, 0x10, 0x00, 0x02, 0x40, 0x08, 0x00, 0x02,
+ 0x80, 0x09, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x10,
+ 0x00, 0x1c, 0x00, 0x20, 0x00, 0x38, 0x03, 0x46, 0x00, 0xfe, 0x01, 0x8d,
+ 0x00, 0x8f, 0xe0, 0x70, 0x00, 0x0f, 0x10, 0x00, 0x00, 0xfe, 0x1f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/ltogi2.xbm b/games/x11/xneko/bitmaps/ltogi2.xbm
new file mode 100644
index 0000000..11d6368
--- /dev/null
+++ b/games/x11/xneko/bitmaps/ltogi2.xbm
@@ -0,0 +1,14 @@
+#define ltogi2_width 32
+#define ltogi2_height 32
+static char ltogi2_bits[] = {
+ 0xc0, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00,
+ 0x40, 0x04, 0x00, 0x00, 0x41, 0x18, 0x00, 0x00, 0x31, 0x20, 0x00, 0x00,
+ 0x09, 0x40, 0x00, 0x00, 0x25, 0x40, 0x00, 0x00, 0x25, 0x40, 0x00, 0x00,
+ 0x23, 0x40, 0x00, 0x00, 0x83, 0x41, 0x00, 0x00, 0x65, 0xa0, 0x0f, 0x00,
+ 0x05, 0x00, 0x30, 0x00, 0xe9, 0x01, 0x40, 0x00, 0x31, 0xc0, 0x80, 0x00,
+ 0x0f, 0x20, 0x00, 0x01, 0x01, 0x10, 0x00, 0xc2, 0x7e, 0x08, 0x00, 0xa2,
+ 0xfe, 0x09, 0x00, 0x94, 0x0c, 0x0f, 0x00, 0x8c, 0x00, 0x0c, 0x00, 0x40,
+ 0x00, 0x1c, 0x00, 0x20, 0x00, 0x38, 0x03, 0x1e, 0x00, 0xfe, 0x01, 0x01,
+ 0x00, 0x8f, 0xe0, 0x00, 0x00, 0x0f, 0x10, 0x00, 0x00, 0xfe, 0x1f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/mati2.xbm b/games/x11/xneko/bitmaps/mati2.xbm
new file mode 100644
index 0000000..41864ec
--- /dev/null
+++ b/games/x11/xneko/bitmaps/mati2.xbm
@@ -0,0 +1,14 @@
+#define mati2_width 32
+#define mati2_height 32
+static char mati2_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x10, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, 0x48, 0x24, 0x00,
+ 0x00, 0x44, 0x44, 0x00, 0x00, 0x84, 0x42, 0x00, 0x00, 0x82, 0x83, 0x00,
+ 0x00, 0x02, 0x80, 0x00, 0x00, 0x22, 0x88, 0x00, 0x00, 0x22, 0x88, 0x00,
+ 0x00, 0x22, 0x88, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x3a, 0xb9, 0x00,
+ 0x00, 0x04, 0x40, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x70, 0x1c, 0x00,
+ 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x10, 0x10, 0x00,
+ 0x00, 0x08, 0x20, 0x00, 0x00, 0x0b, 0xa0, 0x01, 0x80, 0x0c, 0x61, 0x02,
+ 0x40, 0x18, 0x31, 0x04, 0x40, 0x10, 0x11, 0x04, 0xc0, 0x11, 0x11, 0x7f,
+ 0x60, 0x90, 0x13, 0x8c, 0xe0, 0xff, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/mati3.xbm b/games/x11/xneko/bitmaps/mati3.xbm
new file mode 100644
index 0000000..6087cf8
--- /dev/null
+++ b/games/x11/xneko/bitmaps/mati3.xbm
@@ -0,0 +1,14 @@
+#define mati3_width 32
+#define mati3_height 32
+static char mati3_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x10, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, 0x48, 0x24, 0x00,
+ 0x00, 0x44, 0x44, 0x00, 0x00, 0x84, 0x42, 0x00, 0x00, 0x82, 0x83, 0x00,
+ 0x00, 0x3a, 0xb8, 0x00, 0x00, 0x42, 0x85, 0x00, 0x00, 0x92, 0x91, 0x00,
+ 0x00, 0x4e, 0xe2, 0x00, 0x00, 0x42, 0x82, 0x00, 0x00, 0x42, 0x82, 0x00,
+ 0x00, 0x44, 0x42, 0x00, 0x00, 0x88, 0x21, 0x00, 0x00, 0x70, 0x1c, 0x00,
+ 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x10, 0x10, 0x00,
+ 0x00, 0x08, 0x20, 0x00, 0x00, 0x0b, 0xa0, 0x01, 0x80, 0x0c, 0x61, 0x02,
+ 0x40, 0x18, 0x31, 0x04, 0x40, 0x10, 0x11, 0x04, 0xc0, 0x11, 0x11, 0x7f,
+ 0x60, 0x90, 0x13, 0x8c, 0xe0, 0xff, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/right1.xbm b/games/x11/xneko/bitmaps/right1.xbm
new file mode 100644
index 0000000..b2538e0
--- /dev/null
+++ b/games/x11/xneko/bitmaps/right1.xbm
@@ -0,0 +1,14 @@
+#define right1_width 32
+#define right1_height 32
+static char right1_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x70, 0x00, 0x00, 0x00, 0x8c, 0x01, 0x00, 0x00, 0x03, 0x06, 0x00,
+ 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x10, 0x00, 0x40, 0x00, 0x20, 0x30,
+ 0x20, 0x00, 0x20, 0x28, 0x10, 0x00, 0x40, 0x26, 0x48, 0x80, 0xc0, 0x11,
+ 0xc4, 0x00, 0x21, 0x10, 0xa2, 0x00, 0x01, 0x10, 0x92, 0x00, 0x02, 0x20,
+ 0x49, 0x00, 0x02, 0x48, 0x25, 0x00, 0x02, 0x48, 0x43, 0x00, 0xe1, 0x48,
+ 0x80, 0x00, 0x91, 0xc3, 0x80, 0xc0, 0x02, 0x80, 0x80, 0x79, 0x01, 0x40,
+ 0x80, 0x89, 0xc0, 0x20, 0xc0, 0x73, 0x70, 0x1f, 0xc0, 0x13, 0x3c, 0x00,
+ 0xc0, 0xf4, 0x1f, 0x00, 0x00, 0x1c, 0x0f, 0x00, 0x00, 0x18, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/right2.xbm b/games/x11/xneko/bitmaps/right2.xbm
new file mode 100644
index 0000000..d8b4dbe
--- /dev/null
+++ b/games/x11/xneko/bitmaps/right2.xbm
@@ -0,0 +1,14 @@
+#define right2_width 32
+#define right2_height 32
+static char right2_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x07, 0x00, 0x00, 0x04, 0x09, 0x00, 0x00, 0x06, 0x19, 0x00, 0x00, 0x05,
+ 0x22, 0x00, 0x80, 0x04, 0x44, 0x00, 0x40, 0x04, 0x88, 0x00, 0x30, 0x0c,
+ 0x10, 0x03, 0x08, 0x10, 0x10, 0x1c, 0x0c, 0x24, 0x10, 0x60, 0x04, 0x24,
+ 0x08, 0x80, 0x02, 0x24, 0x08, 0x00, 0x03, 0x40, 0x08, 0x00, 0xc0, 0x43,
+ 0x08, 0x00, 0x00, 0x40, 0x08, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x1e,
+ 0x04, 0x10, 0x80, 0x01, 0x03, 0x0c, 0x80, 0x01, 0x81, 0x03, 0x00, 0x03,
+ 0xf9, 0x0f, 0x18, 0x06, 0xfd, 0xf9, 0x3f, 0x0c, 0x1f, 0x00, 0xfc, 0x18,
+ 0x0c, 0x00, 0xe0, 0x33, 0x00, 0x00, 0xc0, 0x1c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/rtogi1.xbm b/games/x11/xneko/bitmaps/rtogi1.xbm
new file mode 100644
index 0000000..496c0cb
--- /dev/null
+++ b/games/x11/xneko/bitmaps/rtogi1.xbm
@@ -0,0 +1,14 @@
+#define rtogi1_width 32
+#define rtogi1_height 32
+static char rtogi1_bits[] = {
+ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x02,
+ 0x00, 0x00, 0x20, 0xc2, 0x00, 0x00, 0x18, 0xec, 0x00, 0x00, 0x04, 0xf0,
+ 0x00, 0x00, 0x02, 0xe0, 0x00, 0x00, 0x02, 0xe4, 0x00, 0x00, 0x02, 0xe4,
+ 0x00, 0x00, 0x02, 0xb4, 0x00, 0x00, 0x02, 0x8c, 0x00, 0xf0, 0x05, 0x83,
+ 0x00, 0x0c, 0x00, 0xc0, 0x00, 0x02, 0x00, 0xb0, 0x00, 0x01, 0x03, 0x1c,
+ 0x80, 0x00, 0x04, 0x0e, 0x40, 0x00, 0x08, 0x02, 0x40, 0x00, 0x10, 0x02,
+ 0x20, 0x00, 0x90, 0x01, 0x30, 0x00, 0xf0, 0x00, 0x08, 0x00, 0x30, 0x00,
+ 0x04, 0x00, 0x38, 0x00, 0x62, 0xc0, 0x1c, 0x00, 0xb1, 0x80, 0x7f, 0x00,
+ 0x0e, 0x07, 0xf1, 0x00, 0x00, 0x08, 0xf0, 0x00, 0x00, 0xf8, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/rtogi2.xbm b/games/x11/xneko/bitmaps/rtogi2.xbm
new file mode 100644
index 0000000..7255c4d
--- /dev/null
+++ b/games/x11/xneko/bitmaps/rtogi2.xbm
@@ -0,0 +1,14 @@
+#define rtogi2_width 32
+#define rtogi2_height 32
+static char rtogi2_bits[] = {
+ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x02,
+ 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x18, 0x82, 0x00, 0x00, 0x04, 0x8c,
+ 0x00, 0x00, 0x02, 0x90, 0x00, 0x00, 0x02, 0xa4, 0x00, 0x00, 0x02, 0xa4,
+ 0x00, 0x00, 0x02, 0xc4, 0x00, 0x00, 0x82, 0xc1, 0x00, 0xf0, 0x05, 0xa6,
+ 0x00, 0x0c, 0x00, 0xa0, 0x00, 0x02, 0x80, 0x97, 0x00, 0x01, 0x03, 0x8c,
+ 0x80, 0x00, 0x04, 0xf0, 0x43, 0x00, 0x08, 0x80, 0x45, 0x00, 0x10, 0x7e,
+ 0x29, 0x00, 0x90, 0x7f, 0x31, 0x00, 0xf0, 0x30, 0x02, 0x00, 0x30, 0x00,
+ 0x04, 0x00, 0x38, 0x00, 0x78, 0xc0, 0x1c, 0x00, 0x80, 0x80, 0x7f, 0x00,
+ 0x00, 0x07, 0xf1, 0x00, 0x00, 0x08, 0xf0, 0x00, 0x00, 0xf8, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/sleep1.xbm b/games/x11/xneko/bitmaps/sleep1.xbm
new file mode 100644
index 0000000..9cda30c
--- /dev/null
+++ b/games/x11/xneko/bitmaps/sleep1.xbm
@@ -0,0 +1,14 @@
+#define sleep1_width 32
+#define sleep1_height 32
+static char sleep1_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x1f, 0x00, 0x80, 0x00, 0x08, 0x00,
+ 0xc0, 0x1f, 0x04, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x41, 0x02,
+ 0x00, 0x80, 0x22, 0x02, 0x00, 0x40, 0x3e, 0x06, 0x00, 0x38, 0x14, 0x0a,
+ 0x00, 0x26, 0x18, 0x14, 0x00, 0x11, 0x00, 0x18, 0x00, 0x11, 0x00, 0x18,
+ 0x80, 0x10, 0x00, 0x38, 0x40, 0x10, 0x00, 0x2c, 0x40, 0xa0, 0x01, 0x2b,
+ 0x40, 0x20, 0x8e, 0x68, 0x40, 0x20, 0x10, 0x54, 0x40, 0x40, 0x40, 0x5b,
+ 0x80, 0x80, 0xff, 0x4c, 0x00, 0x3f, 0xf0, 0x64, 0x00, 0xe0, 0x9f, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/sleep2.xbm b/games/x11/xneko/bitmaps/sleep2.xbm
new file mode 100644
index 0000000..f1a217c
--- /dev/null
+++ b/games/x11/xneko/bitmaps/sleep2.xbm
@@ -0,0 +1,14 @@
+#define sleep2_width 32
+#define sleep2_height 32
+static char sleep2_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x3f, 0x00, 0x00, 0x00, 0x10, 0x3c, 0x00, 0x00, 0x0c, 0x10, 0x00,
+ 0x00, 0x04, 0x88, 0x01, 0x00, 0x3f, 0x7c, 0x01, 0x00, 0x80, 0x60, 0x01,
+ 0x00, 0xc0, 0x21, 0x02, 0x00, 0x78, 0x3f, 0x06, 0x00, 0x26, 0x12, 0x0a,
+ 0x00, 0x21, 0x0c, 0x14, 0x80, 0x10, 0x00, 0x18, 0x80, 0x10, 0x00, 0x18,
+ 0x80, 0x10, 0x00, 0x38, 0x40, 0x10, 0x00, 0x2a, 0x40, 0xa0, 0x03, 0x29,
+ 0x40, 0x20, 0x8c, 0x68, 0x40, 0x20, 0x10, 0x54, 0x40, 0x40, 0x40, 0x5b,
+ 0x80, 0x80, 0xff, 0x4c, 0x00, 0x3f, 0xf0, 0x64, 0x00, 0xe0, 0x9f, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/space.xbm b/games/x11/xneko/bitmaps/space.xbm
new file mode 100644
index 0000000..2ebb658
--- /dev/null
+++ b/games/x11/xneko/bitmaps/space.xbm
@@ -0,0 +1,14 @@
+#define space_width 32
+#define space_height 32
+static char space_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/up1.xbm b/games/x11/xneko/bitmaps/up1.xbm
new file mode 100644
index 0000000..2011ac7
--- /dev/null
+++ b/games/x11/xneko/bitmaps/up1.xbm
@@ -0,0 +1,14 @@
+#define up1_width 32
+#define up1_height 32
+static char up1_bits[] = {
+ 0x00, 0xc0, 0x03, 0x00, 0x00, 0x3e, 0x7c, 0x00, 0x00, 0x08, 0x10, 0x00,
+ 0x00, 0x26, 0x64, 0x00, 0x00, 0x22, 0x44, 0x00, 0x00, 0x22, 0x44, 0x00,
+ 0x00, 0x01, 0x80, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x01, 0x80, 0x00,
+ 0x00, 0x22, 0x42, 0x00, 0x00, 0x1e, 0x7c, 0x00, 0x00, 0x06, 0x60, 0x00,
+ 0x80, 0x3f, 0xfc, 0x01, 0xc0, 0x07, 0xe0, 0x02, 0x40, 0x02, 0x40, 0x02,
+ 0x40, 0x02, 0x40, 0x02, 0x40, 0x01, 0x80, 0x02, 0x40, 0x00, 0x00, 0x02,
+ 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01,
+ 0x80, 0x00, 0x00, 0x01, 0x00, 0x01, 0x80, 0x00, 0x00, 0x06, 0x60, 0x00,
+ 0x00, 0x78, 0x1e, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/up2.xbm b/games/x11/xneko/bitmaps/up2.xbm
new file mode 100644
index 0000000..a8619d5
--- /dev/null
+++ b/games/x11/xneko/bitmaps/up2.xbm
@@ -0,0 +1,14 @@
+#define up2_width 32
+#define up2_height 32
+static char up2_bits[] = {
+ 0x00, 0xc0, 0x03, 0x00, 0x80, 0x3f, 0xfc, 0x01, 0x40, 0x0b, 0xd0, 0x02,
+ 0x40, 0x26, 0x64, 0x02, 0x40, 0x22, 0x44, 0x02, 0x40, 0x22, 0x44, 0x02,
+ 0x40, 0x01, 0x80, 0x02, 0x40, 0x1f, 0xf8, 0x02, 0x40, 0x01, 0x80, 0x02,
+ 0x40, 0x22, 0x42, 0x02, 0x80, 0x1e, 0x7c, 0x01, 0x80, 0x04, 0x20, 0x01,
+ 0x80, 0x38, 0x1c, 0x01, 0x80, 0x00, 0x00, 0x01, 0x00, 0x01, 0x80, 0x00,
+ 0x00, 0x0d, 0xb0, 0x00, 0x00, 0x83, 0xc1, 0x00, 0x00, 0x41, 0x82, 0x00,
+ 0x80, 0x40, 0x02, 0x01, 0x80, 0x40, 0x02, 0x01, 0x80, 0x40, 0x02, 0x01,
+ 0x80, 0x40, 0x02, 0x01, 0x80, 0x40, 0x02, 0x01, 0x80, 0x00, 0x00, 0x01,
+ 0x80, 0xc0, 0x03, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x21, 0x84, 0x00,
+ 0x00, 0x11, 0x88, 0x00, 0x00, 0x09, 0x90, 0x00, 0x00, 0x06, 0x60, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/upleft1.xbm b/games/x11/xneko/bitmaps/upleft1.xbm
new file mode 100644
index 0000000..62ae6c7
--- /dev/null
+++ b/games/x11/xneko/bitmaps/upleft1.xbm
@@ -0,0 +1,14 @@
+#define upleft1_width 32
+#define upleft1_height 32
+static char upleft1_bits[] = {
+ 0x00, 0x00, 0x07, 0x00, 0x80, 0xff, 0x04, 0x00, 0x40, 0x78, 0x04, 0x00,
+ 0xe0, 0x25, 0x04, 0x00, 0x36, 0x22, 0x04, 0x00, 0x18, 0x21, 0x04, 0x00,
+ 0x10, 0x20, 0x04, 0x00, 0x10, 0x00, 0x04, 0x00, 0x10, 0x00, 0x3e, 0x00,
+ 0x20, 0x00, 0xc1, 0x01, 0x20, 0x00, 0x00, 0x02, 0xc0, 0x00, 0x00, 0x04,
+ 0x00, 0x01, 0x00, 0x08, 0x00, 0x01, 0x00, 0x08, 0x00, 0x01, 0x00, 0x10,
+ 0x00, 0x01, 0x00, 0x20, 0x00, 0xc3, 0x00, 0x20, 0x00, 0x22, 0x00, 0x20,
+ 0x00, 0x32, 0x00, 0x20, 0x00, 0x22, 0x00, 0x30, 0x00, 0x24, 0x00, 0x30,
+ 0x00, 0x64, 0x00, 0x20, 0x00, 0xd8, 0xc0, 0x64, 0x00, 0xd0, 0xc1, 0x4f,
+ 0x00, 0xf0, 0xc3, 0x9b, 0x00, 0x70, 0xf0, 0x93, 0x00, 0x10, 0x1e, 0x60,
+ 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/upleft2.xbm b/games/x11/xneko/bitmaps/upleft2.xbm
new file mode 100644
index 0000000..0f3ddd3
--- /dev/null
+++ b/games/x11/xneko/bitmaps/upleft2.xbm
@@ -0,0 +1,14 @@
+#define upleft2_width 32
+#define upleft2_height 32
+static char upleft2_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x80, 0xb0, 0x01, 0x00, 0x40, 0x07, 0x3e, 0x00, 0x60, 0xc0, 0x20, 0x00,
+ 0x58, 0xb8, 0x10, 0x00, 0x40, 0x88, 0x10, 0x00, 0x5e, 0x80, 0x08, 0x00,
+ 0xf2, 0x80, 0x08, 0x00, 0xc6, 0x00, 0x14, 0x00, 0x8c, 0x03, 0x24, 0x00,
+ 0x18, 0x00, 0x42, 0x0e, 0x30, 0x50, 0x81, 0x09, 0x40, 0x00, 0x00, 0x09,
+ 0x80, 0x01, 0x80, 0x04, 0x00, 0x02, 0x80, 0x0c, 0x00, 0x04, 0x40, 0x0a,
+ 0x00, 0x08, 0x00, 0x32, 0x00, 0x10, 0x00, 0x40, 0x00, 0x10, 0x20, 0x40,
+ 0x00, 0x10, 0x40, 0x40, 0x00, 0x10, 0x80, 0x40, 0x00, 0x20, 0x80, 0x87,
+ 0x00, 0x20, 0x80, 0x88, 0x00, 0x40, 0x80, 0x90, 0x00, 0x80, 0x8f, 0x90,
+ 0x00, 0x00, 0x90, 0xa0, 0x00, 0x00, 0x90, 0xc0, 0x00, 0x00, 0x90, 0x00,
+ 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x60, 0x00};
diff --git a/games/x11/xneko/bitmaps/upright1.xbm b/games/x11/xneko/bitmaps/upright1.xbm
new file mode 100644
index 0000000..c01d840
--- /dev/null
+++ b/games/x11/xneko/bitmaps/upright1.xbm
@@ -0,0 +1,14 @@
+#define upright1_width 32
+#define upright1_height 32
+static char upright1_bits[] = {
+ 0x00, 0xe0, 0x00, 0x00, 0x00, 0x20, 0xff, 0x01, 0x00, 0x20, 0x1e, 0x02,
+ 0x00, 0x20, 0xa4, 0x07, 0x00, 0x20, 0x44, 0x6c, 0x00, 0x20, 0x84, 0x18,
+ 0x00, 0x20, 0x04, 0x08, 0x00, 0x20, 0x00, 0x08, 0x00, 0x7c, 0x00, 0x08,
+ 0x80, 0x83, 0x00, 0x04, 0x40, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x03,
+ 0x10, 0x00, 0x80, 0x00, 0x10, 0x00, 0x80, 0x00, 0x08, 0x00, 0x80, 0x00,
+ 0x04, 0x00, 0x80, 0x00, 0x04, 0x00, 0xc3, 0x00, 0x04, 0x00, 0x44, 0x00,
+ 0x04, 0x00, 0x4c, 0x00, 0x0c, 0x00, 0x44, 0x00, 0x0c, 0x00, 0x24, 0x00,
+ 0x04, 0x00, 0x26, 0x00, 0x26, 0x03, 0x1b, 0x00, 0xf2, 0x83, 0x0b, 0x00,
+ 0xd9, 0xc3, 0x0f, 0x00, 0xc9, 0x0f, 0x0e, 0x00, 0x06, 0x78, 0x08, 0x00,
+ 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/upright2.xbm b/games/x11/xneko/bitmaps/upright2.xbm
new file mode 100644
index 0000000..4c43d25
--- /dev/null
+++ b/games/x11/xneko/bitmaps/upright2.xbm
@@ -0,0 +1,14 @@
+#define upright2_width 32
+#define upright2_height 32
+static char upright2_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
+ 0x00, 0x80, 0x0d, 0x01, 0x00, 0x7c, 0xe0, 0x02, 0x00, 0x04, 0x03, 0x06,
+ 0x00, 0x08, 0x1d, 0x1a, 0x00, 0x08, 0x11, 0x02, 0x00, 0x10, 0x01, 0x7a,
+ 0x00, 0x10, 0x01, 0x4f, 0x00, 0x28, 0x00, 0x63, 0x00, 0x24, 0xc0, 0x31,
+ 0x70, 0x42, 0x00, 0x18, 0x90, 0x81, 0x0a, 0x0c, 0x90, 0x00, 0x00, 0x02,
+ 0x20, 0x01, 0x80, 0x01, 0x30, 0x01, 0x40, 0x00, 0x50, 0x02, 0x20, 0x00,
+ 0x4c, 0x00, 0x10, 0x00, 0x02, 0x00, 0x08, 0x00, 0x02, 0x04, 0x08, 0x00,
+ 0x02, 0x02, 0x08, 0x00, 0x02, 0x01, 0x08, 0x00, 0xe1, 0x01, 0x04, 0x00,
+ 0x11, 0x01, 0x04, 0x00, 0x09, 0x01, 0x02, 0x00, 0x09, 0xf1, 0x01, 0x00,
+ 0x05, 0x09, 0x00, 0x00, 0x03, 0x09, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
+ 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/utogi1.xbm b/games/x11/xneko/bitmaps/utogi1.xbm
new file mode 100644
index 0000000..ace1af9
--- /dev/null
+++ b/games/x11/xneko/bitmaps/utogi1.xbm
@@ -0,0 +1,14 @@
+#define utogi1_width 32
+#define utogi1_height 32
+static char utogi1_bits[] = {
+ 0x00, 0x2a, 0x32, 0x00, 0x00, 0x2a, 0x4a, 0x00, 0x80, 0xeb, 0x4b, 0x00,
+ 0x00, 0x3e, 0xfc, 0x00, 0x00, 0x0a, 0x90, 0x00, 0x00, 0x26, 0xa4, 0x00,
+ 0x00, 0x23, 0xc4, 0x00, 0x00, 0x23, 0xc4, 0x00, 0x00, 0x01, 0x80, 0x00,
+ 0x80, 0x1f, 0xf8, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x27, 0x62, 0x00,
+ 0x00, 0x1d, 0x5c, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x1e, 0x78, 0x00,
+ 0x00, 0x02, 0x40, 0x00, 0x00, 0x01, 0x80, 0x00, 0x80, 0x00, 0x00, 0x01,
+ 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0x0d,
+ 0xe8, 0x01, 0x80, 0x13, 0x08, 0x03, 0xc0, 0x10, 0x10, 0x00, 0x00, 0x08,
+ 0xe0, 0x78, 0x1e, 0x07, 0x00, 0x47, 0xe2, 0x00, 0x00, 0x20, 0x02, 0x00,
+ 0x00, 0x10, 0x01, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/bitmaps/utogi2.xbm b/games/x11/xneko/bitmaps/utogi2.xbm
new file mode 100644
index 0000000..08adba4
--- /dev/null
+++ b/games/x11/xneko/bitmaps/utogi2.xbm
@@ -0,0 +1,14 @@
+#define utogi2_width 32
+#define utogi2_height 32
+static char utogi2_bits[] = {
+ 0x00, 0x26, 0x2a, 0x00, 0x00, 0x29, 0x2a, 0x00, 0x00, 0xe9, 0xeb, 0x00,
+ 0x00, 0x3d, 0x3c, 0x00, 0x00, 0x09, 0x30, 0x00, 0x00, 0x25, 0x44, 0x00,
+ 0x00, 0x23, 0x44, 0x00, 0x00, 0x23, 0x44, 0x00, 0x00, 0x01, 0x80, 0x00,
+ 0x80, 0x1f, 0xf8, 0x01, 0x80, 0x00, 0x80, 0x00, 0x00, 0x27, 0x62, 0x00,
+ 0x00, 0x1d, 0x5c, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x1e, 0x78, 0x00,
+ 0x00, 0x02, 0x40, 0x00, 0x00, 0x01, 0x80, 0x00, 0x80, 0x00, 0x00, 0x01,
+ 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0x0d,
+ 0xe8, 0x01, 0x80, 0x13, 0x08, 0x03, 0xc0, 0x10, 0x10, 0x00, 0x00, 0x08,
+ 0xe0, 0x78, 0x1e, 0x07, 0x00, 0x47, 0xe2, 0x00, 0x00, 0x40, 0x04, 0x00,
+ 0x00, 0x80, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/games/x11/xneko/xneko.6 b/games/x11/xneko/xneko.6
new file mode 100644
index 0000000..d9567b8
--- /dev/null
+++ b/games/x11/xneko/xneko.6
@@ -0,0 +1,84 @@
+.\" Copyright (c) 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)xneko.6 8.1 (Berkeley) 5/31/93
+.\"
+.TH XNEKO 6 "May 31, 1993"
+.SH NAME
+xneko \- cat-and-mouse chase in an X window
+.SH SYNOPSIS
+xneko [
+.B -display
+.I display
+] [
+.B -geometry
+.I geometry
+] [
+.B -title
+.I title
+] [
+.B -name
+.I name
+] [
+.B -iconic
+] [
+.B -speed
+.I speed
+] [
+.B -time
+.I time
+] [
+.B -help
+]
+.SH DESCRIPTION
+.I Xneko
+displays a window in which a cat chases your ``mouse'' cursor.
+.PP
+All options except the last three above behave in the standard manner
+for X applications (see
+.IR X (1)).
+The
+.B -speed
+option controls the speed of the cat (the default is 16).
+The
+.B -time
+option controls the interval (in microseconds) between updates of the
+.I xneko
+window (the default is 125000).
+The
+.B -help
+option provides a usage message and exits.
+.PP
+The word ``neko'' means ``cat'' in Japanese.
+.SH SEE ALSO
+X(1)
+.SH AUTHOR
+Masayuki Koba, 1990
diff --git a/games/x11/xneko/xneko.c b/games/x11/xneko/xneko.c
new file mode 100644
index 0000000..731e6c8
--- /dev/null
+++ b/games/x11/xneko/xneko.c
@@ -0,0 +1,1762 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1991, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)xneko.c 8.1 (Berkeley) 5/31/93";
+#endif /* not lint */
+
+/*--------------------------------------------------------------
+ *
+ * xneko - X11 G-
+ *
+ * Original Writer: Masayuki Koba
+ * Programmed by Masayuki Koba, 1990
+ *
+ *--------------------------------------------------------------
+ *
+ *!!Introduction:
+ *
+ *!!!!K\@(#)xneko.c 8.1m%0%i%`$O Macintosh $N5/31/939%/%"%/%;%5%j!< "neko" $N
+ *!!F0:n$r X11 $G%^%M$?$b$N$G$9!#
+ *
+ *!!!!Macintosh "neko" $N=(0o$J5/31/936%$%s$K7I0U$rI=$7$D$D!"$3$N
+ *!!@(#)xneko.c 8.1m%0%i%`$r3'$5$s$KJ{$2$^$9!#
+ *
+ *--------------------------------------------------------------
+ *
+ *!!Special Thanks to
+ *
+ * toshi-w !D!!Macintosh neko $N>R2p<T
+ * shio-m !D!!!VX11 $N neko $,M_$7$$!*!W$H%?%@$r$3$M$??M
+ * disco !D!!X11 SCCS/s.xneko.c/%K%+%k!&%"8.1P%$%6!<
+ *
+ * HOMY !D!!/usr/src/games/xneko/SCCS/s.xneko.c0;XE&<T
+ * BNS !D!!J#?t@(#)xneko.c 8.1l!<%sBP1~May 31, 1993C%ADs6!<T
+ *
+ * "xneko" Presented by Masayuki Koba (masa-k).
+ *
+ *--------------------------------------------------------------
+ *
+ *!!Manifest:
+ *
+ *!!!!K\@(#)xneko.c 8.1m%0%i%`$O Public Domain Software $G$9!#E>:\!&2~NI$O
+ *!!<+M3$K9T$C$F2<$5$$!#
+ *
+ *!!!!$J$*!"86:n<T$O!"K\@(#)xneko.c 8.1m%0%i%`$r;HMQ$9$k$3$H$K$h$C$F@8$8$?
+ *!!>c32$dITMx1W$K$D$$$F$$$C$5$$@UG$$r;}$A$^$;$s!#
+ *
+ *--------------------------------------------------------------
+ *
+ *!!Bugs:
+ *
+ *!!!!!J#1!KX11 $N .Xdefaults $N@_Dj$r$^$k$C$-$jL5;k$7$F$$$^$9!#
+ *
+ *!!!!!J#2!KG-$NF0:n$,;~4V$HF14|$7$F$$$k$?$a!"%^%&%9$N0\F0>pJs
+ *!!!!!!!!$r%]!<%j%s%0$7$F$$$^$9!#=>$C$F!"%^%&%9$,A4$/F0:n$7$F
+ *!!!!!!!!$$$J$$;~$OL5BL$J%^%&%9:BI8FI$_<h$j$r9T$C$F$7$^$$$^$9!#
+ *
+ *!!!!!J#3!K%&%#%s8.1&$,%"%$%3%s2=$5$l$F$b!"$7$i$s$W$j$GIA2h$7
+ *!!!!!!!!$D$E$1$^$9!#$3$NItJ,$O!"8=:_$N%&%#%s8.1&$N>uBV$r@(#) xneko.c 8.1@(#)'
+ *!!!!!!!!70/$7$F!"%"%$%3%s2=$5$l$F$$$k;~$O40A4$K%$s%HBT$A
+ *!!!!!!!!$K$J$k$h$&$K=q$-JQ$($J$1$l$P$J$j$^$;$s!# ($=$s$J$3$H!"
+ *!!!!!!!!$G$-$k$N$+$J$!!#X10 $G$O$G$-$^$7$?$,!#)
+ *
+ *!!!!!J#4!K%j%5%$%:8e$N%&%#%s8.1&$,6KC<$K>.$5$/$J$C$?;~$NF0:n
+ *!!!!!!!!$OJ]>Z$G$-$^$;$s!#
+ *
+ *!!!!!J#5!KK\Mh$J$i$P3NJ]$7$?%&%#%s8.1&$d Pixmap $O@(#)xneko.c 8.1m%0%i%`
+ *!!!!!!!!=*N;;~$K2rJ|$9$kI,MW$,$"$j$^$9$,!"K\@(#)xneko.c 8.1m%0%i%`$O$=$N
+ *!!!!!!!!$X$s$r%5%\$C$F$*$j!"Hs>o$K$*9T57$,0-$/$J$C$F$$$^$9!#
+ *!!!!!!!!IaDL$O exit() ;~$K%7%9SCCS/s.xneko.c`$,M>J,$J%j%=!<%9$r2rJ|$7$F
+ *!!!!!!!!$/$l$^$9$,!"#O#S$K/usr/src/games/xneko/SCCS/s.xneko.c0$,$"$k>l9g$O xneko $r2?EY$b5/
+ *!!!!!!!!F0$9$k$H!"$=$N$&$A%9%o82WNN0h$,ITB-$7$F$7$^$&$3$H$K
+ *!!!!!!!!$J$k$+$b$7$l$^$;$s!#
+ *
+ *!!!!!J#6!K;~4V$KF14|$7$FI,$:IA2h=hM}$r<B9T$9$k$?$a!"0BDj>uBV
+ *!!!!!!!!$G$b Idle 90 !A 95% $H$J$j!"%7%9SCCS/s.xneko.c`#C#P#U$r 5 !A 10%
+ *!!!!!!!!Dx>CHq$7$^$9!#!Jxtachos $GD4$Y$^$7$?!#!K
+ *
+ *--------------------------------------------------------------
+ *
+ *!!System (Machine):
+ *
+ *!!!!K\@(#)xneko.c 8.1m%0%i%`$NF0:n$r3NG'$7$?%7%9SCCS/s.xneko.c`9=@.$O0J2<$NDL$j!#
+ *
+ * !&NWS-1750!"NWS-1720 (NEWS)!"NWP-512D
+ * !!NEWS-OS 3.2a (UNIX 4.3BSD)!"X11 Release 2
+ *
+ * !&NWS-1750!"NWS-1720 (NEWS)!"NWP-512D
+ * !!NEWS-OS 3.3 (UNIX 4.3BSD)!"X11 Release 3
+ *
+ * !&Sun 3!"X11 Release 4
+ *
+ * !&LUNA!"X11 Release 3
+ *
+ * !&DECstation 3100!"ULTRIX!"X11
+ *
+ *--------------------------------------------------------------*/
+
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/keysym.h>
+
+#include <stdio.h>
+
+#include <signal.h>
+#include <math.h>
+#include <sys/time.h>
+
+
+#ifndef lint
+static char
+ rcsid[] = "$Header: /afs/athena.mit.edu/user/j/jik/sipbsrc/src/xneko/RCS/xneko.c,v 1.2 90/09/01 23:40:01 jik Exp $";
+static char WriterMessage[] = "xneko: Programmed by Masayuki Koba, 1990";
+#endif
+
+
+/*
+ * X11 G- 0C5/31/93^129W18:45:36!%$%k0lMw!'
+ *
+ * "icon.xbm" !D!!%"%$%3%s
+ * "cursor.xbm" !D!!%+!<%=%k
+ * "cursor_mask.xbm" !D!!%+!<%=%k!J%^%9%/!K
+ *
+ * "space.xbm" !D!!%9%Z!<%9
+ *
+ * "mati2.xbm" !D!!BT$A#2
+ * "jare2.xbm" !D!!$8$c$l#2
+ * "kaki1.xbm" !D!!A_$-#1
+ * "kaki2.xbm" !D!!A_$-#2
+ * "mati3.xbm" !D!!BT$A#3!J$"$/$S!K
+ * "sleep1.xbm" !D!!?2$k#1
+ * "sleep2.xbm" !D!!?2$k#2
+ *
+ * "awake.xbm" !D!!L\3P$a
+ *
+ * "up1.xbm" !D!!>e#1
+ * "up2.xbm" !D!!>e#2
+ * "down1.xbm" !D!!2<#1
+ * "down2.xbm" !D!!2<#2
+ * "left1.xbm" !D!!:8#1
+ * "left2.xbm" !D!!:8#2
+ * "right1.xbm" !D!!1&#1
+ * "right2.xbm" !D!!1&#2
+ * "upleft1.xbm" !D!!:8>e#1
+ * "upleft2.xbm" !D!!:8>e#2
+ * "upright1.xbm" !D!!1&>e#1
+ * "upright2.xbm" !D!!1&>e#2
+ * "dwleft1.xbm" !D!!:82<#1
+ * "dwleft2.xbm" !D!!:82<#2
+ * "dwright1.xbm" !D!!1&2<#1
+ * "dwright2.xbm" !D!!1&2<#2
+ *
+ * "utogi1.xbm" !D!!>eKa$.#1
+ * "utogi2.xbm" !D!!>eKa$.#2
+ * "dtogi1.xbm" !D!!2<Ka$.#1
+ * "dtogi2.xbm" !D!!2<Ka$.#2
+ * "ltogi1.xbm" !D!!:8Ka$.#1
+ * "ltogi2.xbm" !D!!:8Ka$.#2
+ * "rtogi1.xbm" !D!!1&Ka$.#1
+ * "rtogi2.xbm" !D!!1&Ka$.#2
+ *
+ * !!$3$l$i$N18:45:36!%$%k$O bitmap %3%^%s%I$GJT=82DG=$G$9!#
+ *
+ * (bitmap size "* 32x32 ... Macintosh ICON resource size.)
+ *
+ */
+
+
+#include "bitmaps/icon.xbm"
+#include "bitmaps/cursor.xbm"
+#include "bitmaps/cursor_mask.xbm"
+
+#include "bitmaps/space.xbm"
+
+#include "bitmaps/mati2.xbm"
+#include "bitmaps/jare2.xbm"
+#include "bitmaps/kaki1.xbm"
+#include "bitmaps/kaki2.xbm"
+#include "bitmaps/mati3.xbm"
+#include "bitmaps/sleep1.xbm"
+#include "bitmaps/sleep2.xbm"
+
+#include "bitmaps/awake.xbm"
+
+#include "bitmaps/up1.xbm"
+#include "bitmaps/up2.xbm"
+#include "bitmaps/down1.xbm"
+#include "bitmaps/down2.xbm"
+#include "bitmaps/left1.xbm"
+#include "bitmaps/left2.xbm"
+#include "bitmaps/right1.xbm"
+#include "bitmaps/right2.xbm"
+#include "bitmaps/upright1.xbm"
+#include "bitmaps/upright2.xbm"
+#include "bitmaps/upleft1.xbm"
+#include "bitmaps/upleft2.xbm"
+#include "bitmaps/dwleft1.xbm"
+#include "bitmaps/dwleft2.xbm"
+#include "bitmaps/dwright1.xbm"
+#include "bitmaps/dwright2.xbm"
+
+#include "bitmaps/utogi1.xbm"
+#include "bitmaps/utogi2.xbm"
+#include "bitmaps/dtogi1.xbm"
+#include "bitmaps/dtogi2.xbm"
+#include "bitmaps/ltogi1.xbm"
+#include "bitmaps/ltogi2.xbm"
+#include "bitmaps/rtogi1.xbm"
+#include "bitmaps/rtogi2.xbm"
+
+
+/*
+ * Dj?tDj5A
+ */
+
+#define BITMAP_WIDTH 32 /* #1%-%c%i%/%?$NI} (18:45:53/%;%k) */
+#define BITMAP_HEIGHT 32 /* #1%-%c%i%/%?$N9b$5 (18:45:53/%;%k) */
+
+#define WINDOW_WIDTH 320 /* %&%#%s8.1&$NI} (18:45:53/%;%k) */
+#define WINDOW_HEIGHT 256 /* %&%#%s8.1&$N9b$5 (18:45:53/%;%k) */
+
+#define DEFAULT_BORDER 2 /* %\!<%@!<%5%$%: */
+
+#define DEFAULT_WIN_X 1 /* %&%#%s8.1&@8@.#X:BI8 */
+#define DEFAULT_WIN_Y 1 /* %&%#%s8.1&@8@.#Y:BI8 */
+
+#define AVAIL_KEYBUF 255
+
+#define EVENT_MASK1 ( KeyPressMask | StructureNotifyMask )
+
+#define EVENT_MASK2 ( KeyPressMask | \
+ ExposureMask | \
+ StructureNotifyMask )
+
+#define MAX_TICK 9999 /* Odd Only! */
+
+#define INTERVAL 125000L /* %$%s%?!</usr/src/games/xneko/SCCS/s.xneko.ck%?%$%` */
+
+#define NEKO_SPEED 16
+
+#define IDLE_SPACE 6
+
+#define NORMAL_STATE 1
+#define DEBUG_LIST 2
+#define DEBUG_MOVE 3
+
+/* G-$N>uBVDj?t */
+
+#define NEKO_STOP 0 /* N)$A;_$^$C$? */
+#define NEKO_JARE 1 /* 4i$r@v$C$F$$$k */
+#define NEKO_KAKI 2 /* F,$rA_$$$F$$$k */
+#define NEKO_AKUBI 3 /* $"$/$S$r$7$F$$$k */
+#define NEKO_SLEEP 4 /* ?2$F$7$^$C$? */
+#define NEKO_AWAKE 5 /* L\$,3P$a$? */
+#define NEKO_U_MOVE 6 /* >e$K0\F0Cf */
+#define NEKO_D_MOVE 7 /* 2<$K0\F0Cf */
+#define NEKO_L_MOVE 8 /* :8$K0\F0Cf */
+#define NEKO_R_MOVE 9 /* 1&$K0\F0Cf */
+#define NEKO_UL_MOVE 10 /* :8>e$K0\F0Cf */
+#define NEKO_UR_MOVE 11 /* 1&>e$K0\F0Cf */
+#define NEKO_DL_MOVE 12 /* :82<$K0\F0Cf */
+#define NEKO_DR_MOVE 13 /* 1&2<$K0\F0Cf */
+#define NEKO_U_TOGI 14 /* >e$NJI$r0z$CA_$$$F$$$k */
+#define NEKO_D_TOGI 15 /* 2<$NJI$r0z$CA_$$$F$$$k */
+#define NEKO_L_TOGI 16 /* :8$NJI$r0z$CA_$$$F$$$k */
+#define NEKO_R_TOGI 17 /* 1&$NJI$r0z$CA_$$$F$$$k */
+
+/* G-$N%"%K%a!<%7%g%s7+$jJV$72s?t */
+
+#define NEKO_STOP_TIME 4
+#define NEKO_JARE_TIME 10
+#define NEKO_KAKI_TIME 4
+#define NEKO_AKUBI_TIME 3
+#define NEKO_AWAKE_TIME 3
+#define NEKO_TOGI_TIME 10
+
+#define PI_PER8 ((double)3.1415926535/(double)8)
+
+#define DIRNAMELEN 255
+
+
+/*
+ * %0%m!</usr/src/games/xneko/SCCS/s.xneko.ckJQ?t
+ */
+
+static char *ProgramName; /* %3%^%s%IL>>N */
+
+Display *theDisplay;
+int theScreen;
+unsigned int theDepth;
+unsigned long theBlackPixel;
+unsigned long theWhitePixel;
+Window theWindow;
+Cursor theCursor;
+
+static unsigned int WindowWidth;
+static unsigned int WindowHeight;
+
+static int WindowPointX;
+static int WindowPointY;
+
+static unsigned int BorderWidth = DEFAULT_BORDER;
+
+long IntervalTime = INTERVAL;
+
+int EventState; /* %$s%H=hM}MQ >uBVJQ?t */
+
+int NekoTickCount; /* G-F0:n%+%&%s%? */
+int NekoStateCount; /* G-F10l>uBV%+%&%s%? */
+int NekoState; /* G-$N>uBV */
+
+int MouseX; /* %^%&%9#X:BI8 */
+int MouseY; /* %^%&%9#Y:BI8 */
+
+int PrevMouseX = 0; /* D>A0$N%^%&%9#X:BI8 */
+int PrevMouseY = 0; /* D>A0$N%^%&%9#Y:BI8 */
+
+int NekoX; /* G-#X:BI8 */
+int NekoY; /* G-#Y:BI8 */
+
+int NekoMoveDx; /* G-0\F05wN%#X */
+int NekoMoveDy; /* G-0\F05wN%#Y */
+
+int NekoLastX; /* G-:G=*IA2h#X:BI8 */
+int NekoLastY; /* G-:G=*IA2h#Y:BI8 */
+GC NekoLastGC; /* G-:G=*IA2h GC */
+
+double NekoSpeed = (double)NEKO_SPEED;
+
+double SinPiPer8Times3; /* sin( #3&P!?#8 ) */
+double SinPiPer8; /* sin( &P!?#8 ) */
+
+Pixmap SpaceXbm;
+
+Pixmap Mati2Xbm;
+Pixmap Jare2Xbm;
+Pixmap Kaki1Xbm;
+Pixmap Kaki2Xbm;
+Pixmap Mati3Xbm;
+Pixmap Sleep1Xbm;
+Pixmap Sleep2Xbm;
+
+Pixmap AwakeXbm;
+
+Pixmap Up1Xbm;
+Pixmap Up2Xbm;
+Pixmap Down1Xbm;
+Pixmap Down2Xbm;
+Pixmap Left1Xbm;
+Pixmap Left2Xbm;
+Pixmap Right1Xbm;
+Pixmap Right2Xbm;
+Pixmap UpLeft1Xbm;
+Pixmap UpLeft2Xbm;
+Pixmap UpRight1Xbm;
+Pixmap UpRight2Xbm;
+Pixmap DownLeft1Xbm;
+Pixmap DownLeft2Xbm;
+Pixmap DownRight1Xbm;
+Pixmap DownRight2Xbm;
+
+Pixmap UpTogi1Xbm;
+Pixmap UpTogi2Xbm;
+Pixmap DownTogi1Xbm;
+Pixmap DownTogi2Xbm;
+Pixmap LeftTogi1Xbm;
+Pixmap LeftTogi2Xbm;
+Pixmap RightTogi1Xbm;
+Pixmap RightTogi2Xbm;
+
+GC SpaceGC;
+
+GC Mati2GC;
+GC Jare2GC;
+GC Kaki1GC;
+GC Kaki2GC;
+GC Mati3GC;
+GC Sleep1GC;
+GC Sleep2GC;
+
+GC AwakeGC;
+
+GC Up1GC;
+GC Up2GC;
+GC Down1GC;
+GC Down2GC;
+GC Left1GC;
+GC Left2GC;
+GC Right1GC;
+GC Right2GC;
+GC UpLeft1GC;
+GC UpLeft2GC;
+GC UpRight1GC;
+GC UpRight2GC;
+GC DownLeft1GC;
+GC DownLeft2GC;
+GC DownRight1GC;
+GC DownRight2GC;
+
+GC UpTogi1GC;
+GC UpTogi2GC;
+GC DownTogi1GC;
+GC DownTogi2GC;
+GC LeftTogi1GC;
+GC LeftTogi2GC;
+GC RightTogi1GC;
+GC RightTogi2GC;
+
+typedef struct {
+ GC *GCCreatePtr;
+ Pixmap *BitmapCreatePtr;
+ char *PixelPattern;
+ unsigned int PixelWidth;
+ unsigned int PixelHeight;
+} BitmapGCData;
+
+BitmapGCData BitmapGCDataTable[] =
+{
+ { &SpaceGC, &SpaceXbm, space_bits, space_width, space_height },
+ { &Mati2GC, &Mati2Xbm, mati2_bits, mati2_width, mati2_height },
+ { &Jare2GC, &Jare2Xbm, jare2_bits, jare2_width, jare2_height },
+ { &Kaki1GC, &Kaki1Xbm, kaki1_bits, kaki1_width, kaki1_height },
+ { &Kaki2GC, &Kaki2Xbm, kaki2_bits, kaki2_width, kaki2_height },
+ { &Mati3GC, &Mati3Xbm, mati3_bits, mati3_width, mati3_height },
+ { &Sleep1GC, &Sleep1Xbm, sleep1_bits, sleep1_width, sleep1_height },
+ { &Sleep2GC, &Sleep2Xbm, sleep2_bits, sleep2_width, sleep2_height },
+ { &AwakeGC, &AwakeXbm, awake_bits, awake_width, awake_height },
+ { &Up1GC, &Up1Xbm, up1_bits, up1_width, up1_height },
+ { &Up2GC, &Up2Xbm, up2_bits, up2_width, up2_height },
+ { &Down1GC, &Down1Xbm, down1_bits, down1_width, down1_height },
+ { &Down2GC, &Down2Xbm, down2_bits, down2_width, down2_height },
+ { &Left1GC, &Left1Xbm, left1_bits, left1_width, left1_height },
+ { &Left2GC, &Left2Xbm, left2_bits, left2_width, left2_height },
+ { &Right1GC, &Right1Xbm, right1_bits, right1_width, right1_height },
+ { &Right2GC, &Right2Xbm, right2_bits, right2_width, right2_height },
+ { &UpLeft1GC, &UpLeft1Xbm, upleft1_bits, upleft1_width, upleft1_height },
+ { &UpLeft2GC, &UpLeft2Xbm, upleft2_bits, upleft2_width, upleft2_height },
+ { &UpRight1GC,
+ &UpRight1Xbm, upright1_bits, upright1_width, upright1_height },
+ { &UpRight2GC,
+ &UpRight2Xbm, upright2_bits, upright2_width, upright2_height },
+ { &DownLeft1GC,
+ &DownLeft1Xbm, dwleft1_bits, dwleft1_width, dwleft1_height },
+ { &DownLeft2GC,
+ &DownLeft2Xbm, dwleft2_bits, dwleft2_width, dwleft2_height },
+ { &DownRight1GC,
+ &DownRight1Xbm, dwright1_bits, dwright1_width, dwright1_height },
+ { &DownRight2GC,
+ &DownRight2Xbm, dwright2_bits, dwright2_width, dwright2_height },
+ { &UpTogi1GC, &UpTogi1Xbm, utogi1_bits, utogi1_width, utogi1_height },
+ { &UpTogi2GC, &UpTogi2Xbm, utogi2_bits, utogi2_width, utogi2_height },
+ { &DownTogi1GC, &DownTogi1Xbm, dtogi1_bits, dtogi1_width, dtogi1_height },
+ { &DownTogi2GC, &DownTogi2Xbm, dtogi2_bits, dtogi2_width, dtogi2_height },
+ { &LeftTogi1GC, &LeftTogi1Xbm, ltogi1_bits, ltogi1_width, ltogi1_height },
+ { &LeftTogi2GC, &LeftTogi2Xbm, ltogi2_bits, ltogi2_width, ltogi2_height },
+ { &RightTogi1GC,
+ &RightTogi1Xbm, rtogi1_bits, rtogi1_width, rtogi1_height },
+ { &RightTogi2GC,
+ &RightTogi2Xbm, rtogi2_bits, rtogi2_width, rtogi2_height },
+ { NULL, NULL, NULL, NULL, NULL }
+};
+
+typedef struct {
+ GC *TickEvenGCPtr;
+ GC *TickOddGCPtr;
+} Animation;
+
+Animation AnimationPattern[] =
+{
+ { &Mati2GC, &Mati2GC }, /* NekoState == NEKO_STOP */
+ { &Jare2GC, &Mati2GC }, /* NekoState == NEKO_JARE */
+ { &Kaki1GC, &Kaki2GC }, /* NekoState == NEKO_KAKI */
+ { &Mati3GC, &Mati3GC }, /* NekoState == NEKO_AKUBI */
+ { &Sleep1GC, &Sleep2GC }, /* NekoState == NEKO_SLEEP */
+ { &AwakeGC, &AwakeGC }, /* NekoState == NEKO_AWAKE */
+ { &Up1GC, &Up2GC } , /* NekoState == NEKO_U_MOVE */
+ { &Down1GC, &Down2GC }, /* NekoState == NEKO_D_MOVE */
+ { &Left1GC, &Left2GC }, /* NekoState == NEKO_L_MOVE */
+ { &Right1GC, &Right2GC }, /* NekoState == NEKO_R_MOVE */
+ { &UpLeft1GC, &UpLeft2GC }, /* NekoState == NEKO_UL_MOVE */
+ { &UpRight1GC, &UpRight2GC }, /* NekoState == NEKO_UR_MOVE */
+ { &DownLeft1GC, &DownLeft2GC }, /* NekoState == NEKO_DL_MOVE */
+ { &DownRight1GC, &DownRight2GC }, /* NekoState == NEKO_DR_MOVE */
+ { &UpTogi1GC, &UpTogi2GC }, /* NekoState == NEKO_U_TOGI */
+ { &DownTogi1GC, &DownTogi2GC }, /* NekoState == NEKO_D_TOGI */
+ { &LeftTogi1GC, &LeftTogi2GC }, /* NekoState == NEKO_L_TOGI */
+ { &RightTogi1GC, &RightTogi2GC }, /* NekoState == NEKO_R_TOGI */
+};
+
+
+/*--------------------------------------------------------------
+ *
+ * 0C5/31/93^504W%G!<%?!&GC =i4|2=
+ *
+ *--------------------------------------------------------------*/
+
+void
+InitBitmapAndGCs()
+{
+ BitmapGCData *BitmapGCDataTablePtr;
+ XGCValues theGCValues;
+
+ theGCValues.function = GXcopy;
+ theGCValues.foreground = BlackPixel( theDisplay, theScreen );
+ theGCValues.background = WhitePixel( theDisplay, theScreen );
+ theGCValues.fill_style = FillTiled;
+
+ for ( BitmapGCDataTablePtr = BitmapGCDataTable;
+ BitmapGCDataTablePtr->GCCreatePtr != NULL;
+ BitmapGCDataTablePtr++ ) {
+
+ *(BitmapGCDataTablePtr->BitmapCreatePtr)
+ = XCreatePixmapFromBitmapData(
+ theDisplay,
+ RootWindow( theDisplay, theScreen ),
+ BitmapGCDataTablePtr->PixelPattern,
+ BitmapGCDataTablePtr->PixelWidth,
+ BitmapGCDataTablePtr->PixelHeight,
+ BlackPixel( theDisplay, theScreen ),
+ WhitePixel( theDisplay, theScreen ),
+ DefaultDepth( theDisplay, theScreen ) );
+
+ theGCValues.tile = *(BitmapGCDataTablePtr->BitmapCreatePtr);
+
+ *(BitmapGCDataTablePtr->GCCreatePtr)
+ = XCreateGC( theDisplay, theWindow,
+ GCFunction | GCForeground | GCBackground |
+ GCTile | GCFillStyle,
+ &theGCValues );
+ }
+
+ XFlush( theDisplay );
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * %9%/%j!<%s4D6-=i4|2=
+ *
+ *--------------------------------------------------------------*/
+
+void
+InitScreen( DisplayName, theGeometry, TitleName, iconicState )
+ char *DisplayName;
+ char *theGeometry;
+ char *TitleName;
+ Bool iconicState;
+{
+ int GeometryStatus;
+ XSetWindowAttributes theWindowAttributes;
+ XSizeHints theSizeHints;
+ unsigned long theWindowMask;
+ Pixmap theIconPixmap;
+ Pixmap theCursorSource;
+ Pixmap theCursorMask;
+ XWMHints theWMHints;
+ Window theRoot;
+ Colormap theColormap;
+ XColor theWhiteColor, theBlackColor, theExactColor;
+
+ if ( ( theDisplay = XOpenDisplay( DisplayName ) ) == NULL ) {
+ fprintf( stderr, "%s: Can't open display", ProgramName );
+ if ( DisplayName != NULL ) {
+ fprintf( stderr, " %s.\n", DisplayName );
+ } else {
+ fprintf( stderr, ".\n" );
+ }
+ exit( 1 );
+ }
+
+ theScreen = DefaultScreen( theDisplay );
+ theDepth = DefaultDepth( theDisplay, theScreen );
+
+ theBlackPixel = BlackPixel( theDisplay, theScreen );
+ theWhitePixel = WhitePixel( theDisplay, theScreen );
+
+ GeometryStatus = XParseGeometry( theGeometry,
+ &WindowPointX, &WindowPointY,
+ &WindowWidth, &WindowHeight );
+
+ if ( !( GeometryStatus & XValue ) ) {
+ WindowPointX = DEFAULT_WIN_X;
+ }
+ if ( !( GeometryStatus & YValue ) ) {
+ WindowPointY = DEFAULT_WIN_Y;
+ }
+ if ( !( GeometryStatus & WidthValue ) ) {
+ WindowWidth = WINDOW_WIDTH;
+ }
+ if ( !( GeometryStatus & HeightValue ) ) {
+ WindowHeight = WINDOW_HEIGHT;
+ }
+
+ theCursorSource
+ = XCreateBitmapFromData( theDisplay,
+ RootWindow( theDisplay, theScreen ),
+ cursor_bits,
+ cursor_width,
+ cursor_height );
+
+ theCursorMask
+ = XCreateBitmapFromData( theDisplay,
+ RootWindow( theDisplay, theScreen ),
+ cursor_mask_bits,
+ cursor_mask_width,
+ cursor_mask_height );
+
+ theColormap = DefaultColormap( theDisplay, theScreen );
+
+ if ( !XAllocNamedColor( theDisplay, theColormap,
+ "white", &theWhiteColor, &theExactColor ) ) {
+ fprintf( stderr,
+ "%s: Can't XAllocNamedColor( \"white\" ).\n", ProgramName );
+ exit( 1 );
+ }
+
+ if ( !XAllocNamedColor( theDisplay, theColormap,
+ "black", &theBlackColor, &theExactColor ) ) {
+ fprintf( stderr,
+ "%s: Can't XAllocNamedColor( \"black\" ).\n", ProgramName );
+ exit( 1 );
+ }
+
+ theCursor = XCreatePixmapCursor( theDisplay,
+ theCursorSource, theCursorMask,
+ &theBlackColor, &theWhiteColor,
+ cursor_x_hot, cursor_y_hot );
+
+ theWindowAttributes.border_pixel = theBlackPixel;
+ theWindowAttributes.background_pixel = theWhitePixel;
+ theWindowAttributes.cursor = theCursor;
+ theWindowAttributes.override_redirect = False;
+
+ theWindowMask = CWBackPixel |
+ CWBorderPixel |
+ CWCursor |
+ CWOverrideRedirect;
+
+ theWindow = XCreateWindow( theDisplay,
+ RootWindow( theDisplay, theScreen ),
+ WindowPointX, WindowPointY,
+ WindowWidth, WindowHeight,
+ BorderWidth,
+ theDepth,
+ InputOutput,
+ CopyFromParent,
+ theWindowMask,
+ &theWindowAttributes );
+
+ theIconPixmap = XCreateBitmapFromData( theDisplay, theWindow,
+ icon_bits,
+ icon_width,
+ icon_height );
+
+ theWMHints.icon_pixmap = theIconPixmap;
+ if ( iconicState ) {
+ theWMHints.initial_state = IconicState;
+ } else {
+ theWMHints.initial_state = NormalState;
+ }
+ theWMHints.flags = IconPixmapHint | StateHint;
+
+ XSetWMHints( theDisplay, theWindow, &theWMHints );
+
+ theSizeHints.flags = PPosition | PSize;
+ theSizeHints.x = WindowPointX;
+ theSizeHints.y = WindowPointY;
+ theSizeHints.width = WindowWidth;
+ theSizeHints.height = WindowHeight;
+
+ XSetNormalHints( theDisplay, theWindow, &theSizeHints );
+
+ if ( strlen( TitleName ) >= 1 ) {
+ XStoreName( theDisplay, theWindow, TitleName );
+ XSetIconName( theDisplay, theWindow, TitleName );
+ } else {
+ XStoreName( theDisplay, theWindow, ProgramName );
+ XSetIconName( theDisplay, theWindow, ProgramName );
+ }
+
+ XMapWindow( theDisplay, theWindow );
+
+ XFlush( theDisplay );
+
+ XGetGeometry( theDisplay, theWindow,
+ &theRoot,
+ &WindowPointX, &WindowPointY,
+ &WindowWidth, &WindowHeight,
+ &BorderWidth, &theDepth );
+
+ InitBitmapAndGCs();
+
+ XSelectInput( theDisplay, theWindow, EVENT_MASK1 );
+
+ XFlush( theDisplay );
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * %$%s%?!</usr/src/games/xneko/SCCS/s.xneko.ck
+ *
+ * !!$3$N4X?t$r8F$V$H!"$"$k0lDj$N;~4VJV$C$F$3$J$/$J$k!#G-
+ * $NF0:n%?%$%_%s%0D4@0$KMxMQ$9$k$3$H!#
+ *
+ *--------------------------------------------------------------*/
+
+void
+Interval()
+{
+ pause();
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * SCCS/s.xneko.c#728/%+%&%s%H=hM}
+ *
+ *--------------------------------------------------------------*/
+
+void
+TickCount()
+{
+ if ( ++NekoTickCount >= MAX_TICK ) {
+ NekoTickCount = 0;
+ }
+
+ if ( NekoTickCount % 2 == 0 ) {
+ if ( NekoStateCount < MAX_TICK ) {
+ NekoStateCount++;
+ }
+ }
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * G->uBV@_Dj
+ *
+ *--------------------------------------------------------------*/
+
+void
+SetNekoState( SetValue )
+ int SetValue;
+{
+ NekoTickCount = 0;
+ NekoStateCount = 0;
+
+ NekoState = SetValue;
+
+#ifdef DEBUG
+ switch ( NekoState ) {
+ case NEKO_STOP:
+ case NEKO_JARE:
+ case NEKO_KAKI:
+ case NEKO_AKUBI:
+ case NEKO_SLEEP:
+ case NEKO_U_TOGI:
+ case NEKO_D_TOGI:
+ case NEKO_L_TOGI:
+ case NEKO_R_TOGI:
+ NekoMoveDx = NekoMoveDy = 0;
+ break;
+ default:
+ break;
+ }
+#endif
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * G-IA2h=hM}
+ *
+ *--------------------------------------------------------------*/
+
+void
+DrawNeko( x, y, DrawGC )
+ int x;
+ int y;
+ GC DrawGC;
+{
+ if ( ( x != NekoLastX || y != NekoLastY )
+ && ( EventState != DEBUG_LIST ) ) {
+ XFillRectangle( theDisplay, theWindow, SpaceGC,
+ NekoLastX, NekoLastY,
+ BITMAP_WIDTH, BITMAP_HEIGHT );
+ }
+
+ XSetTSOrigin( theDisplay, DrawGC, x, y );
+
+ XFillRectangle( theDisplay, theWindow, DrawGC,
+ x, y, BITMAP_WIDTH, BITMAP_HEIGHT );
+
+ XFlush( theDisplay );
+
+ NekoLastX = x;
+ NekoLastY = y;
+
+ NekoLastGC = DrawGC;
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * G-:FIA2h=hM}
+ *
+ *--------------------------------------------------------------*/
+
+void
+RedrawNeko()
+{
+ XFillRectangle( theDisplay, theWindow, NekoLastGC,
+ NekoLastX, NekoLastY,
+ BITMAP_WIDTH, BITMAP_HEIGHT );
+
+ XFlush( theDisplay );
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * G-0\F0J}K!7hDj
+ *
+ *--------------------------------------------------------------*/
+
+void
+NekoDirection()
+{
+ int NewState;
+ double LargeX, LargeY;
+ double Length;
+ double SinTheta;
+
+ if ( NekoMoveDx == 0 && NekoMoveDy == 0 ) {
+ NewState = NEKO_STOP;
+ } else {
+ LargeX = (double)NekoMoveDx;
+ LargeY = (double)(-NekoMoveDy);
+ Length = sqrt( LargeX * LargeX + LargeY * LargeY );
+ SinTheta = LargeY / Length;
+
+ if ( NekoMoveDx > 0 ) {
+ if ( SinTheta > SinPiPer8Times3 ) {
+ NewState = NEKO_U_MOVE;
+ } else if ( ( SinTheta <= SinPiPer8Times3 )
+ && ( SinTheta > SinPiPer8 ) ) {
+ NewState = NEKO_UR_MOVE;
+ } else if ( ( SinTheta <= SinPiPer8 )
+ && ( SinTheta > -( SinPiPer8 ) ) ) {
+ NewState = NEKO_R_MOVE;
+ } else if ( ( SinTheta <= -( SinPiPer8 ) )
+ && ( SinTheta > -( SinPiPer8Times3 ) ) ) {
+ NewState = NEKO_DR_MOVE;
+ } else {
+ NewState = NEKO_D_MOVE;
+ }
+ } else {
+ if ( SinTheta > SinPiPer8Times3 ) {
+ NewState = NEKO_U_MOVE;
+ } else if ( ( SinTheta <= SinPiPer8Times3 )
+ && ( SinTheta > SinPiPer8 ) ) {
+ NewState = NEKO_UL_MOVE;
+ } else if ( ( SinTheta <= SinPiPer8 )
+ && ( SinTheta > -( SinPiPer8 ) ) ) {
+ NewState = NEKO_L_MOVE;
+ } else if ( ( SinTheta <= -( SinPiPer8 ) )
+ && ( SinTheta > -( SinPiPer8Times3 ) ) ) {
+ NewState = NEKO_DL_MOVE;
+ } else {
+ NewState = NEKO_D_MOVE;
+ }
+ }
+ }
+
+ if ( NekoState != NewState ) {
+ SetNekoState( NewState );
+ }
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * G-JI$V$D$+$jH=Dj
+ *
+ *--------------------------------------------------------------*/
+
+Bool
+IsWindowOver()
+{
+ Bool ReturnValue = False;
+
+ if ( NekoY <= 0 ) {
+ NekoY = 0;
+ ReturnValue = True;
+ } else if ( NekoY >= WindowHeight - BITMAP_HEIGHT ) {
+ NekoY = WindowHeight - BITMAP_HEIGHT;
+ ReturnValue = True;
+ }
+ if ( NekoX <= 0 ) {
+ NekoX = 0;
+ ReturnValue = True;
+ } else if ( NekoX >= WindowWidth - BITMAP_WIDTH ) {
+ NekoX = WindowWidth - BITMAP_WIDTH;
+ ReturnValue = True;
+ }
+
+ return( ReturnValue );
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * G-0\F0>u67H=Dj
+ *
+ *--------------------------------------------------------------*/
+
+Bool
+IsNekoDontMove()
+{
+ if ( NekoX == NekoLastX && NekoY == NekoLastY ) {
+ return( True );
+ } else {
+ return( False );
+ }
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * G-0\F03+;OH=Dj
+ *
+ *--------------------------------------------------------------*/
+
+Bool
+IsNekoMoveStart()
+{
+#ifndef DEBUG
+ if ( ( PrevMouseX >= MouseX - IDLE_SPACE
+ && PrevMouseX <= MouseX + IDLE_SPACE ) &&
+ ( PrevMouseY >= MouseY - IDLE_SPACE
+ && PrevMouseY <= MouseY + IDLE_SPACE ) ) {
+ return( False );
+ } else {
+ return( True );
+ }
+#else
+ if ( NekoMoveDx == 0 && NekoMoveDy == 0 ) {
+ return( False );
+ } else {
+ return( True );
+ }
+#endif
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * G-0\F0 dx, dy 7W;;
+ *
+ *--------------------------------------------------------------*/
+
+void
+CalcDxDy()
+{
+ Window QueryRoot, QueryChild;
+ int AbsoluteX, AbsoluteY;
+ int RelativeX, RelativeY;
+ unsigned int ModKeyMask;
+ double LargeX, LargeY;
+ double DoubleLength, Length;
+
+ XQueryPointer( theDisplay, theWindow,
+ &QueryRoot, &QueryChild,
+ &AbsoluteX, &AbsoluteY,
+ &RelativeX, &RelativeY,
+ &ModKeyMask );
+
+ PrevMouseX = MouseX;
+ PrevMouseY = MouseY;
+
+ MouseX = RelativeX;
+ MouseY = RelativeY;
+
+ LargeX = (double)( MouseX - NekoX - BITMAP_WIDTH / 2 );
+ LargeY = (double)( MouseY - NekoY - BITMAP_HEIGHT );
+
+ DoubleLength = LargeX * LargeX + LargeY * LargeY;
+
+ if ( DoubleLength != (double)0 ) {
+ Length = sqrt( DoubleLength );
+ if ( Length <= NekoSpeed ) {
+ NekoMoveDx = (int)LargeX;
+ NekoMoveDy = (int)LargeY;
+ } else {
+ NekoMoveDx = (int)( ( NekoSpeed * LargeX ) / Length );
+ NekoMoveDy = (int)( ( NekoSpeed * LargeY ) / Length );
+ }
+ } else {
+ NekoMoveDx = NekoMoveDy = 0;
+ }
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * F0:n2r@OG-IA2h=hM}
+ *
+ *--------------------------------------------------------------*/
+
+void
+NekoThinkDraw()
+{
+#ifndef DEBUG
+ CalcDxDy();
+#endif
+
+ if ( NekoState != NEKO_SLEEP ) {
+ DrawNeko( NekoX, NekoY,
+ NekoTickCount % 2 == 0 ?
+ *(AnimationPattern[ NekoState ].TickEvenGCPtr) :
+ *(AnimationPattern[ NekoState ].TickOddGCPtr) );
+ } else {
+ DrawNeko( NekoX, NekoY,
+ NekoTickCount % 8 <= 3 ?
+ *(AnimationPattern[ NekoState ].TickEvenGCPtr) :
+ *(AnimationPattern[ NekoState ].TickOddGCPtr) );
+ }
+
+ TickCount();
+
+ switch ( NekoState ) {
+ case NEKO_STOP:
+ if ( IsNekoMoveStart() ) {
+ SetNekoState( NEKO_AWAKE );
+ break;
+ }
+ if ( NekoStateCount < NEKO_STOP_TIME ) {
+ break;
+ }
+ if ( NekoMoveDx < 0 && NekoX <= 0 ) {
+ SetNekoState( NEKO_L_TOGI );
+ } else if ( NekoMoveDx > 0 && NekoX >= WindowWidth - BITMAP_WIDTH ) {
+ SetNekoState( NEKO_R_TOGI );
+ } else if ( NekoMoveDy < 0 && NekoY <= 0 ) {
+ SetNekoState( NEKO_U_TOGI );
+ } else if ( NekoMoveDy > 0 && NekoY >= WindowHeight - BITMAP_HEIGHT ) {
+ SetNekoState( NEKO_D_TOGI );
+ } else {
+ SetNekoState( NEKO_JARE );
+ }
+ break;
+ case NEKO_JARE:
+ if ( IsNekoMoveStart() ) {
+ SetNekoState( NEKO_AWAKE );
+ break;
+ }
+ if ( NekoStateCount < NEKO_JARE_TIME ) {
+ break;
+ }
+ SetNekoState( NEKO_KAKI );
+ break;
+ case NEKO_KAKI:
+ if ( IsNekoMoveStart() ) {
+ SetNekoState( NEKO_AWAKE );
+ break;
+ }
+ if ( NekoStateCount < NEKO_KAKI_TIME ) {
+ break;
+ }
+ SetNekoState( NEKO_AKUBI );
+ break;
+ case NEKO_AKUBI:
+ if ( IsNekoMoveStart() ) {
+ SetNekoState( NEKO_AWAKE );
+ break;
+ }
+ if ( NekoStateCount < NEKO_AKUBI_TIME ) {
+ break;
+ }
+ SetNekoState( NEKO_SLEEP );
+ break;
+ case NEKO_SLEEP:
+ if ( IsNekoMoveStart() ) {
+ SetNekoState( NEKO_AWAKE );
+ break;
+ }
+ break;
+ case NEKO_AWAKE:
+ if ( NekoStateCount < NEKO_AWAKE_TIME ) {
+ break;
+ }
+ NekoDirection(); /* G-$,F0$/8~$-$r5a$a$k */
+ break;
+ case NEKO_U_MOVE:
+ case NEKO_D_MOVE:
+ case NEKO_L_MOVE:
+ case NEKO_R_MOVE:
+ case NEKO_UL_MOVE:
+ case NEKO_UR_MOVE:
+ case NEKO_DL_MOVE:
+ case NEKO_DR_MOVE:
+ NekoX += NekoMoveDx;
+ NekoY += NekoMoveDy;
+ NekoDirection();
+ if ( IsWindowOver() ) {
+ if ( IsNekoDontMove() ) {
+ SetNekoState( NEKO_STOP );
+ }
+ }
+ break;
+ case NEKO_U_TOGI:
+ case NEKO_D_TOGI:
+ case NEKO_L_TOGI:
+ case NEKO_R_TOGI:
+ if ( IsNekoMoveStart() ) {
+ SetNekoState( NEKO_AWAKE );
+ break;
+ }
+ if ( NekoStateCount < NEKO_TOGI_TIME ) {
+ break;
+ }
+ SetNekoState( NEKO_KAKI );
+ break;
+ default:
+ /* Internal Error */
+ SetNekoState( NEKO_STOP );
+ break;
+ }
+
+ Interval();
+}
+
+
+#ifdef DEBUG
+
+/*--------------------------------------------------------------
+ *
+ * %-%c%i%/%?!<0lMwI=<(!J5/31/93P11500MQ!K
+ *
+ *--------------------------------------------------------------*/
+
+void
+DisplayCharacters()
+{
+ int Index;
+ int x, y;
+
+ for ( Index = 0, x = 0, y = 0;
+ BitmapGCDataTable[ Index ].GCCreatePtr != NULL; Index++ ) {
+
+ DrawNeko( x, y, *(BitmapGCDataTable[ Index ].GCCreatePtr) );
+ XFlush( theDisplay );
+
+ x += BITMAP_WIDTH;
+
+ if ( x > WindowWidth - BITMAP_WIDTH ) {
+ x = 0;
+ y += BITMAP_HEIGHT;
+ if ( y > WindowHeight - BITMAP_HEIGHT) {
+ break;
+ }
+ }
+ }
+}
+
+#endif /* DEBUG */
+
+
+/*--------------------------------------------------------------
+ *
+ * %-!<%$s%H=hM}
+ *
+ *--------------------------------------------------------------*/
+
+Bool
+ProcessKeyPress( theKeyEvent )
+ XKeyEvent *theKeyEvent;
+{
+ int Length;
+ int theKeyBufferMaxLen = AVAIL_KEYBUF;
+ char theKeyBuffer[ AVAIL_KEYBUF + 1 ];
+ KeySym theKeySym;
+ XComposeStatus theComposeStatus;
+ Bool ReturnState;
+
+ ReturnState = True;
+
+ Length = XLookupString( theKeyEvent,
+ theKeyBuffer, theKeyBufferMaxLen,
+ &theKeySym, &theComposeStatus );
+
+ if ( Length > 0 ) {
+ switch ( theKeyBuffer[ 0 ] ) {
+ case 'q':
+ case 'Q':
+ if ( theKeyEvent->state & Mod1Mask ) { /* META (Alt) %-!< */
+ ReturnState = False;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ if ( EventState == DEBUG_MOVE ) {
+ switch ( theKeySym ) {
+ case XK_KP_1:
+ NekoMoveDx = -(int)( NekoSpeed / sqrt( (double)2 ) );
+ NekoMoveDy = -NekoMoveDx;
+ break;
+ case XK_KP_2:
+ NekoMoveDx = 0;
+ NekoMoveDy = (int)NekoSpeed;
+ break;
+ case XK_KP_3:
+ NekoMoveDx = (int)( NekoSpeed / sqrt( (double)2 ) );
+ NekoMoveDy = NekoMoveDx;
+ break;
+ case XK_KP_4:
+ NekoMoveDx = -(int)NekoSpeed;
+ NekoMoveDy = 0;
+ break;
+ case XK_KP_5:
+ NekoMoveDx = 0;
+ NekoMoveDy = 0;
+ break;
+ case XK_KP_6:
+ NekoMoveDx = (int)NekoSpeed;
+ NekoMoveDy = 0;
+ break;
+ case XK_KP_7:
+ NekoMoveDx = -(int)( NekoSpeed / sqrt( (double)2 ) );
+ NekoMoveDy = NekoMoveDx;
+ break;
+ case XK_KP_8:
+ NekoMoveDx = 0;
+ NekoMoveDy = -(int)NekoSpeed;
+ break;
+ case XK_KP_9:
+ NekoMoveDx = (int)( NekoSpeed / sqrt( (double)2 ) );
+ NekoMoveDy = -NekoMoveDx;
+ break;
+ }
+ }
+#endif
+
+ return( ReturnState );
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * G-0LCVD4@0
+ *
+ *--------------------------------------------------------------*/
+
+void
+NekoAdjust()
+{
+ if ( NekoX < 0 ) {
+ NekoX = 0;
+ } else if ( NekoX > WindowWidth - BITMAP_WIDTH ) {
+ NekoX = WindowWidth - BITMAP_WIDTH;
+ }
+
+ if ( NekoY < 0 ) {
+ NekoY = 0;
+ } else if ( NekoY > WindowHeight - BITMAP_HEIGHT ) {
+ NekoY = WindowHeight - BITMAP_HEIGHT;
+ }
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * %$s%H=hM}
+ *
+ *--------------------------------------------------------------*/
+
+Bool
+ProcessEvent()
+{
+ XEvent theEvent;
+ Bool ContinueState = True;
+
+ switch ( EventState ) {
+ case NORMAL_STATE:
+ while ( XCheckMaskEvent( theDisplay, EVENT_MASK1, &theEvent ) ) {
+ switch ( theEvent.type ) {
+ case ConfigureNotify:
+ WindowWidth = theEvent.xconfigure.width;
+ WindowHeight = theEvent.xconfigure.height;
+ WindowPointX = theEvent.xconfigure.x;
+ WindowPointY = theEvent.xconfigure.y;
+ BorderWidth = theEvent.xconfigure.border_width;
+ NekoAdjust();
+ break;
+ case Expose:
+ if ( theEvent.xexpose.count == 0 ) {
+ RedrawNeko();
+ }
+ break;
+ case MapNotify:
+ RedrawNeko();
+ break;
+ case KeyPress:
+ ContinueState = ProcessKeyPress( &theEvent.xkey );
+ if ( !ContinueState ) {
+ return( ContinueState );
+ }
+ break;
+ default:
+ /* Unknown Event */
+ break;
+ }
+ }
+ break;
+#ifdef DEBUG
+ case DEBUG_LIST:
+ XNextEvent( theDisplay, &theEvent );
+ switch ( theEvent.type ) {
+ case ConfigureNotify:
+ WindowWidth = theEvent.xconfigure.width;
+ WindowHeight = theEvent.xconfigure.height;
+ WindowPointX = theEvent.xconfigure.x;
+ WindowPointY = theEvent.xconfigure.y;
+ BorderWidth = theEvent.xconfigure.border_width;
+ break;
+ case Expose:
+ if ( theEvent.xexpose.count == 0 ) {
+ DisplayCharacters();
+ }
+ break;
+ case MapNotify:
+ DisplayCharacters();
+ break;
+ case KeyPress:
+ ContinueState = ProcessKeyPress( &theEvent );
+ break;
+ default:
+ /* Unknown Event */
+ break;
+ }
+ break;
+ case DEBUG_MOVE:
+ while ( XCheckMaskEvent( theDisplay, EVENT_MASK1, &theEvent ) ) {
+ switch ( theEvent.type ) {
+ case ConfigureNotify:
+ WindowWidth = theEvent.xconfigure.width;
+ WindowHeight = theEvent.xconfigure.height;
+ WindowPointX = theEvent.xconfigure.x;
+ WindowPointY = theEvent.xconfigure.y;
+ BorderWidth = theEvent.xconfigure.border_width;
+ NekoAdjust();
+ break;
+ case Expose:
+ if ( theEvent.xexpose.count == 0 ) {
+ RedrawNeko();
+ }
+ break;
+ case MapNotify:
+ RedrawNeko();
+ break;
+ case KeyPress:
+ ContinueState = ProcessKeyPress( &theEvent );
+ if ( !ContinueState ) {
+ return( ContinueState );
+ }
+ break;
+ default:
+ /* Unknown Event */
+ break;
+ }
+ }
+ break;
+#endif
+ default:
+ /* Internal Error */
+ break;
+ }
+
+ return( ContinueState );
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * G-=hM}
+ *
+ *--------------------------------------------------------------*/
+
+void
+ProcessNeko()
+{
+ struct itimerval Value;
+
+ /* 4D6-$N=i4|2= */
+
+ EventState = NORMAL_STATE;
+
+ /* G-$N=i4|2= */
+
+ NekoX = ( WindowWidth - BITMAP_WIDTH / 2 ) / 2;
+ NekoY = ( WindowHeight - BITMAP_HEIGHT / 2 ) / 2;
+
+ NekoLastX = NekoX;
+ NekoLastY = NekoY;
+
+ SetNekoState( NEKO_STOP );
+
+ /* %?%$%^!<@_Dj */
+
+ timerclear( &Value.it_interval );
+ timerclear( &Value.it_value );
+
+ Value.it_interval.tv_usec = IntervalTime;
+ Value.it_value.tv_usec = IntervalTime;
+
+ setitimer( ITIMER_REAL, &Value, 0 );
+
+ /* %a%$%s=hM} */
+
+ do {
+ NekoThinkDraw();
+ } while ( ProcessEvent() );
+}
+
+
+#ifdef DEBUG
+
+/*--------------------------------------------------------------
+ *
+ * G-0lMw!J5/31/93P14460MQ!K
+ *
+ *--------------------------------------------------------------*/
+
+void
+NekoList()
+{
+ EventState = DEBUG_LIST;
+
+ fprintf( stderr, "\n" );
+ fprintf( stderr, "G-0lMw$rI=<($7$^$9!#(Quit !D Alt-Q)\n" );
+ fprintf( stderr, "\n" );
+
+ XSelectInput( theDisplay, theWindow, EVENT_MASK2 );
+
+ while ( ProcessEvent() );
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * G-0\F0SCCS/s.xneko.c9%H!J5/31/93P14670MQ!K
+ *
+ *--------------------------------------------------------------*/
+
+void
+NekoMoveTest()
+{
+ struct itimerval Value;
+
+ /* 4D6-$N=i4|2= */
+
+ EventState = DEBUG_MOVE;
+
+ /* G-$N=i4|2= */
+
+ NekoX = ( WindowWidth - BITMAP_WIDTH / 2 ) / 2;
+ NekoY = ( WindowHeight - BITMAP_HEIGHT / 2 ) / 2;
+
+ NekoLastX = NekoX;
+ NekoLastY = NekoY;
+
+ SetNekoState( NEKO_STOP );
+
+ /* %?%$%^!<@_Dj */
+
+ timerclear( &Value.it_interval );
+ timerclear( &Value.it_value );
+
+ Value.it_interval.tv_usec = IntervalTime;
+ Value.it_value.tv_usec = IntervalTime;
+
+ setitimer( ITIMER_REAL, &Value, 0 );
+
+ /* %a%$%s=hM} */
+
+ fprintf( stderr, "\n" );
+ fprintf( stderr, "G-$N0\F0SCCS/s.xneko.c9%H$r9T$$$^$9!#(Quit !D Alt-Q)\n" );
+ fprintf( stderr, "\n" );
+ fprintf( stderr, "\t%-!<May 31, 1993C%I>e$NSCCS/s.xneko.cs%-!<$GG-$r0\F0$5$;$F2<$5$$!#\n" );
+ fprintf( stderr, "\t(M-8z$J%-!<$O#1!A#9$G$9!#)\n" );
+ fprintf( stderr, "\n" );
+
+ do {
+ NekoThinkDraw();
+ } while ( ProcessEvent() );
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * %a%K%e!<=hM}!J5/31/93P15170MQ!K
+ *
+ *--------------------------------------------------------------*/
+
+void
+ProcessDebugMenu()
+{
+ int UserSelectNo = 0;
+ char UserAnswer[ BUFSIZ ];
+
+ fprintf( stderr, "\n" );
+ fprintf( stderr, "!Zxneko 5/31/93P15280%a%K%e!<![\n" );
+
+ while ( !( UserSelectNo >= 1 && UserSelectNo <= 2 ) ) {
+ fprintf( stderr, "\n" );
+ fprintf( stderr, "\t1)!!G-%-%c%i%/%?!<0lMwI=<(\n" );
+ fprintf( stderr, "\t2)!!G-0\F0SCCS/s.xneko.c9%H\n" );
+ fprintf( stderr, "\n" );
+ fprintf( stderr, "Select: " );
+
+ fgets( UserAnswer, sizeof( UserAnswer ), stdin );
+
+ UserSelectNo = atoi( UserAnswer );
+
+ if ( !( UserSelectNo >= 1 && UserSelectNo <= 2 ) ) {
+ fprintf( stderr, "\n" );
+ fprintf( stderr, "@5$7$$HV9f$rA*Br$7$F2<$5$$!#\n" );
+ }
+ }
+
+ switch ( UserSelectNo ) {
+ case 1:
+ /* G-%-%c%i%/%?!<0lMwI=<( */
+ NekoList();
+ break;
+ case 2:
+ /* G-0\F0SCCS/s.xneko.c9%H */
+ NekoMoveTest();
+ break;
+ default:
+ /* Internal Error */
+ break;
+ }
+
+ fprintf( stderr, "SCCS/s.xneko.c9%H=*N;!#\n" );
+ fprintf( stderr, "\n" );
+}
+
+#endif /* DEBUG */
+
+
+/*--------------------------------------------------------------
+ *
+ * SIGALRM %7%0%J%k=hM}
+ *
+ *--------------------------------------------------------------*/
+
+void
+NullFunction()
+{
+ /* No Operation */
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * Usage
+ *
+ *--------------------------------------------------------------*/
+
+void
+Usage()
+{
+ fprintf( stderr,
+ "Usage: %s [-display <display>] [-geometry <geometry>] \\\n",
+ ProgramName );
+ fprintf( stderr, " [-title <title>] [-name <title>] [-iconic] \\\n" );
+ fprintf( stderr, " [-speed <speed>] [-time <time>] [-help]\n" );
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * #XMay 31, 1993i%a!<%?I>2A
+ *
+ *--------------------------------------------------------------*/
+
+Bool
+GetArguments( argc, argv, theDisplayName, theGeometry, theTitle,
+ NekoSpeed, IntervalTime )
+ int argc;
+ char *argv[];
+ char *theDisplayName;
+ char *theGeometry;
+ char *theTitle;
+ double *NekoSpeed;
+ long *IntervalTime;
+{
+ int ArgCounter;
+ Bool iconicState;
+
+ theDisplayName[ 0 ] = '\0';
+ theGeometry[ 0 ] = '\0';
+ theTitle[ 0 ] = '\0';
+
+ iconicState = False;
+
+ for ( ArgCounter = 0; ArgCounter < argc; ArgCounter++ ) {
+
+ if ( strncmp( argv[ ArgCounter ], "-h", 2 ) == 0 ) {
+ Usage();
+ exit( 0 );
+ } else if ( strcmp( argv[ ArgCounter ], "-display" ) == 0 ) {
+ ArgCounter++;
+ if ( ArgCounter < argc ) {
+ strcpy( theDisplayName, argv[ ArgCounter ] );
+ } else {
+ fprintf( stderr, "%s: -display option error.\n", ProgramName );
+ exit( 1 );
+ }
+ } else if ( strncmp( argv[ ArgCounter ], "-geom", 5 ) == 0 ) {
+ ArgCounter++;
+ if ( ArgCounter < argc ) {
+ strcpy( theGeometry, argv[ ArgCounter ] );
+ } else {
+ fprintf( stderr,
+ "%s: -geometry option error.\n", ProgramName );
+ exit( 1 );
+ }
+ } else if ( ( strcmp( argv[ ArgCounter ], "-title" ) == 0 )
+ || ( strcmp( argv[ ArgCounter ], "-name" ) == 0 ) ) {
+ ArgCounter++;
+ if ( ArgCounter < argc ) {
+ strcpy( theTitle, argv[ ArgCounter ] );
+ } else {
+ fprintf( stderr, "%s: -title option error.\n", ProgramName );
+ exit( 1 );
+ }
+ } else if ( strcmp( argv[ ArgCounter ], "-iconic" ) == 0 ) {
+ iconicState = True;
+ } else if ( strcmp( argv[ ArgCounter ], "-speed" ) == 0 ) {
+ ArgCounter++;
+ if ( ArgCounter < argc ) {
+ *NekoSpeed = atof( argv[ ArgCounter ] );
+ } else {
+ fprintf( stderr, "%s: -speed option error.\n", ProgramName );
+ exit( 1 );
+ }
+ } else if ( strcmp( argv[ ArgCounter ], "-time" ) == 0 ) {
+ ArgCounter++;
+ if ( ArgCounter < argc ) {
+ *IntervalTime = atol( argv[ ArgCounter ] );
+ } else {
+ fprintf( stderr, "%s: -time option error.\n", ProgramName );
+ exit( 1 );
+ }
+ } else {
+ fprintf( stderr,
+ "%s: Unknown option \"%s\".\n", ProgramName,
+ argv[ ArgCounter ] );
+ Usage();
+ exit( 1 );
+ }
+ }
+
+ if ( strlen( theDisplayName ) < 1 ) {
+ theDisplayName = NULL;
+ }
+
+ if ( strlen( theGeometry ) < 1 ) {
+ theGeometry = NULL;
+ }
+
+ return( iconicState );
+}
+
+
+/*--------------------------------------------------------------
+ *
+ * %a%$%s4X?t
+ *
+ *--------------------------------------------------------------*/
+
+int
+main( argc, argv )
+ int argc;
+ char *argv[];
+{
+ Bool iconicState;
+ char theDisplayName[ DIRNAMELEN ];
+ char theGeometry[ DIRNAMELEN ];
+ char theTitle[ DIRNAMELEN ];
+
+ ProgramName = argv[ 0 ];
+
+ argc--;
+ argv++;
+
+ iconicState = GetArguments( argc, argv,
+ theDisplayName,
+ theGeometry,
+ theTitle,
+ &NekoSpeed,
+ &IntervalTime );
+
+ InitScreen( theDisplayName, theGeometry, theTitle, iconicState );
+
+ signal( SIGALRM, NullFunction );
+
+ SinPiPer8Times3 = sin( PI_PER8 * (double)3 );
+ SinPiPer8 = sin( PI_PER8 );
+
+#ifndef DEBUG
+ ProcessNeko();
+#else
+ ProcessDebugMenu();
+#endif
+
+ exit( 0 );
+}
diff --git a/games/x11/xroach/Makefile b/games/x11/xroach/Makefile
new file mode 100644
index 0000000..dc762c8
--- /dev/null
+++ b/games/x11/xroach/Makefile
@@ -0,0 +1,10 @@
+# @(#)Makefile 8.1 (Berkeley) 6/8/93
+
+PROG= xroach
+MAN6= xroach.6
+CFLAGS+= -I${.CURDIR}/bitmaps
+DPADD+= ${X11BASE}/lib/libX11.a ${LIBM}
+LDDESTDIR+= -L${X11BASE}/lib
+LDADD+= -lX11 -lm
+
+.include <bsd.prog.mk>
diff --git a/games/x11/xroach/bitmaps/roach000.xbm b/games/x11/xroach/bitmaps/roach000.xbm
new file mode 100644
index 0000000..4b04b05
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach000.xbm
@@ -0,0 +1,30 @@
+#define roach000_width 48
+#define roach000_height 48
+
+static char roach000_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x06, 0x80,
+ 0x00, 0x00, 0x03, 0x00, 0x03, 0x60, 0x00, 0x00, 0x7e, 0x80, 0xc1, 0x3f,
+ 0x00, 0x00, 0xc0, 0x83, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0xc6, 0x30, 0x00,
+ 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xef, 0x01,
+ 0x00, 0x00, 0xfe, 0xff, 0xe7, 0x11, 0x10, 0xc0, 0xff, 0xff, 0xf7, 0x03,
+ 0x02, 0xf0, 0xff, 0xff, 0xf3, 0x3f, 0x00, 0xf0, 0xff, 0xff, 0xf3, 0x3b,
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, 0x00, 0xe0, 0xff, 0xff, 0xf3, 0x3f,
+ 0x00, 0xe0, 0xff, 0xff, 0xf3, 0x3f, 0x00, 0xe0, 0xff, 0xff, 0xf3, 0x07,
+ 0x01, 0xe0, 0xff, 0xff, 0xf7, 0x13, 0x08, 0xc0, 0xff, 0xff, 0xf7, 0x03,
+ 0x00, 0x00, 0xfe, 0xff, 0xe7, 0x01, 0x00, 0x00, 0x00, 0xff, 0x0f, 0x00,
+ 0x00, 0x00, 0x00, 0x88, 0x18, 0x00, 0x00, 0x00, 0xf8, 0xc7, 0xf0, 0x03,
+ 0x00, 0x00, 0xfe, 0x81, 0xc1, 0x3f, 0x00, 0x00, 0x06, 0x00, 0x01, 0x30,
+ 0x00, 0x00, 0x03, 0x00, 0x02, 0x40, 0x00, 0x80, 0x01, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach015.xbm b/games/x11/xroach/bitmaps/roach015.xbm
new file mode 100644
index 0000000..f5ad87e
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach015.xbm
@@ -0,0 +1,30 @@
+#define roach015_width 48
+#define roach015_height 48
+
+static char roach015_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80, 0x00, 0x0c,
+ 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x07,
+ 0x00, 0x00, 0x00, 0x40, 0xf8, 0x01, 0x00, 0x00, 0x00, 0x60, 0x3c, 0x00,
+ 0x00, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x10, 0x00, 0x10, 0x06, 0x00,
+ 0x00, 0x60, 0xfc, 0x30, 0x72, 0x04, 0x00, 0xc0, 0x9f, 0xe3, 0xf3, 0x1e,
+ 0x00, 0x00, 0x00, 0xfe, 0xfb, 0x1d, 0x00, 0x00, 0xc0, 0xff, 0xfb, 0x3d,
+ 0x00, 0x00, 0xf8, 0xff, 0xf9, 0x3f, 0x00, 0x00, 0xfe, 0xff, 0xfb, 0x3f,
+ 0x3c, 0x00, 0xff, 0xff, 0xfb, 0x07, 0x00, 0xc0, 0xff, 0x1f, 0xf8, 0x17,
+ 0x00, 0xe0, 0xff, 0xe1, 0xf7, 0x07, 0x00, 0xf0, 0x1f, 0xfe, 0xf7, 0x03,
+ 0x00, 0xf0, 0xe1, 0xff, 0xe7, 0x03, 0x00, 0x00, 0xfe, 0xff, 0xcf, 0x01,
+ 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x7f, 0xfc,
+ 0x00, 0xc0, 0xff, 0x3f, 0xc3, 0x1f, 0x01, 0xc0, 0xff, 0x23, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x1c, 0x00,
+ 0x00, 0x00, 0x80, 0x07, 0x20, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x40, 0x00,
+ 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach030.xbm b/games/x11/xroach/bitmaps/roach030.xbm
new file mode 100644
index 0000000..ec28236
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach030.xbm
@@ -0,0 +1,30 @@
+#define roach030_width 48
+#define roach030_height 48
+
+static char roach030_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x40, 0x00, 0x00, 0x00, 0x10, 0x1e, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x98, 0x01, 0x09,
+ 0x00, 0x00, 0x00, 0x8c, 0x01, 0x04, 0x00, 0x00, 0x00, 0x8c, 0xb8, 0x07,
+ 0x00, 0x00, 0x00, 0x84, 0x7c, 0x0f, 0x00, 0x00, 0x00, 0xfc, 0xfc, 0x8e,
+ 0x00, 0x00, 0x00, 0xf8, 0xfc, 0x1f, 0x00, 0x00, 0xe0, 0xff, 0xfc, 0x05,
+ 0x00, 0x04, 0x1e, 0xff, 0xfd, 0x17, 0x00, 0xf8, 0x87, 0xff, 0xf9, 0x03,
+ 0x00, 0xe0, 0xc0, 0xff, 0xf9, 0x07, 0x00, 0x00, 0xf0, 0x7f, 0xf0, 0x07,
+ 0x00, 0x00, 0xf8, 0x1f, 0xe7, 0x03, 0x00, 0x00, 0xfe, 0xcf, 0xcf, 0xc1,
+ 0x03, 0x00, 0xff, 0xf3, 0x1f, 0xe0, 0x00, 0x80, 0xff, 0xfc, 0xff, 0x3f,
+ 0x00, 0x80, 0x3f, 0xfe, 0xbf, 0x07, 0x00, 0xc0, 0x9f, 0xff, 0x07, 0x00,
+ 0x00, 0xc0, 0xe7, 0xff, 0x0f, 0x00, 0x00, 0xc0, 0xf9, 0xff, 0x3c, 0x00,
+ 0x00, 0x00, 0xfe, 0xff, 0xf8, 0x01, 0x00, 0x00, 0xff, 0x8f, 0x00, 0x02,
+ 0x00, 0x00, 0xff, 0x61, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x30, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach045.xbm b/games/x11/xroach/bitmaps/roach045.xbm
new file mode 100644
index 0000000..0ea6e2b
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach045.xbm
@@ -0,0 +1,30 @@
+#define roach045_width 48
+#define roach045_height 48
+
+static char roach045_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x01,
+ 0x00, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x62, 0xc0, 0x43,
+ 0x00, 0x00, 0x00, 0x62, 0xfe, 0x13, 0x00, 0x00, 0x00, 0x23, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x23, 0xff, 0x07, 0x00, 0x00, 0x00, 0x63, 0xff, 0x0b,
+ 0x00, 0x00, 0x00, 0x73, 0xff, 0x01, 0x00, 0x00, 0x00, 0x7e, 0xfe, 0x01,
+ 0x00, 0x00, 0x00, 0xfc, 0xfc, 0x03, 0x00, 0x00, 0x40, 0xfe, 0xf9, 0x03,
+ 0x07, 0x00, 0xf0, 0xff, 0xf1, 0xc3, 0x00, 0x00, 0x18, 0xff, 0xc0, 0xe3,
+ 0x00, 0x00, 0x8e, 0x7f, 0x1e, 0x70, 0x00, 0x00, 0xc7, 0x3f, 0xff, 0x1f,
+ 0x00, 0xfc, 0xe3, 0x9f, 0x7f, 0x07, 0x00, 0xe0, 0xe1, 0xcf, 0x3f, 0x00,
+ 0x00, 0x00, 0xf0, 0xe7, 0x3f, 0x00, 0x00, 0x00, 0xf8, 0xf1, 0x1f, 0x00,
+ 0x00, 0x00, 0xfc, 0xfc, 0xe7, 0x0f, 0x00, 0x00, 0x7e, 0xfe, 0x03, 0x00,
+ 0x00, 0x00, 0x3e, 0xff, 0x03, 0x00, 0x00, 0x00, 0x9f, 0xff, 0x02, 0x00,
+ 0x00, 0x00, 0xcf, 0x7f, 0x03, 0x00, 0x00, 0x00, 0xe7, 0x1f, 0x03, 0x00,
+ 0x00, 0x00, 0xf2, 0x8f, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x83, 0x01, 0x00,
+ 0x00, 0x00, 0xf8, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach060.xbm b/games/x11/xroach/bitmaps/roach060.xbm
new file mode 100644
index 0000000..145987a
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach060.xbm
@@ -0,0 +1,30 @@
+#define roach060_width 48
+#define roach060_height 48
+
+static char roach060_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x10,
+ 0x00, 0x00, 0x00, 0x60, 0x00, 0x08, 0x00, 0x00, 0x00, 0x30, 0x74, 0x04,
+ 0x00, 0x00, 0x00, 0x30, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x18, 0xfc, 0x01,
+ 0x00, 0x00, 0x00, 0x88, 0xff, 0x00, 0x00, 0x00, 0x40, 0xc8, 0xff, 0x02,
+ 0x00, 0x00, 0xc0, 0xd8, 0x7f, 0x00, 0x00, 0x00, 0xc0, 0xd8, 0xff, 0x80,
+ 0x01, 0x00, 0x80, 0x90, 0xff, 0xe1, 0x00, 0x00, 0x80, 0x18, 0xff, 0x61,
+ 0x00, 0x00, 0x80, 0x3f, 0xfe, 0x33, 0x00, 0x00, 0x00, 0x7f, 0xfc, 0x19,
+ 0x00, 0x00, 0x00, 0xfe, 0xf1, 0x18, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x0f,
+ 0x00, 0x00, 0xc0, 0xff, 0xff, 0x01, 0x00, 0x00, 0xe0, 0x7f, 0x7f, 0x00,
+ 0x00, 0x00, 0x90, 0xbf, 0x7f, 0x00, 0x00, 0x00, 0x98, 0xbf, 0x3f, 0x38,
+ 0x00, 0x00, 0xd8, 0xdf, 0x7f, 0x0f, 0x00, 0x00, 0xcc, 0xef, 0xdf, 0x01,
+ 0x00, 0x00, 0xe6, 0xef, 0x0f, 0x00, 0x00, 0xc0, 0xe3, 0xf7, 0x0f, 0x00,
+ 0x00, 0x00, 0xe0, 0xf7, 0x1f, 0x00, 0x00, 0x00, 0xf0, 0xfb, 0x1f, 0x00,
+ 0x00, 0x00, 0xf0, 0xf9, 0x1b, 0x00, 0x00, 0x00, 0xf0, 0xfd, 0x19, 0x00,
+ 0x00, 0x00, 0xf8, 0xfe, 0x08, 0x00, 0x00, 0x00, 0x78, 0x7e, 0x0c, 0x00,
+ 0x00, 0x00, 0x70, 0x3f, 0x04, 0x00, 0x00, 0x00, 0x30, 0x3f, 0x06, 0x00,
+ 0x00, 0x00, 0x80, 0x1f, 0x06, 0x00, 0x00, 0x00, 0x00, 0x07, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach075.xbm b/games/x11/xroach/bitmaps/roach075.xbm
new file mode 100644
index 0000000..5a85ba4
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach075.xbm
@@ -0,0 +1,30 @@
+#define roach075_width 48
+#define roach075_height 48
+
+static char roach075_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x06, 0x80, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x84, 0x06, 0x00, 0x00, 0x00, 0x00, 0x86, 0x3e, 0x00,
+ 0x00, 0x00, 0x00, 0x06, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x06, 0x1e, 0x60,
+ 0x00, 0x00, 0x00, 0xc6, 0x3f, 0x20, 0x00, 0x00, 0x00, 0xe6, 0x3f, 0x18,
+ 0x00, 0x00, 0x00, 0xf2, 0x7f, 0x18, 0x00, 0x00, 0x08, 0xf2, 0x7f, 0x18,
+ 0x00, 0x00, 0x30, 0xf6, 0xff, 0x0c, 0x00, 0x00, 0x20, 0xe4, 0xff, 0x0c,
+ 0x00, 0x00, 0x60, 0x98, 0xff, 0x0c, 0x00, 0x00, 0x40, 0x38, 0x38, 0x06,
+ 0x00, 0x00, 0xc0, 0xff, 0xe0, 0x01, 0x00, 0x00, 0x80, 0xff, 0xfe, 0x00,
+ 0x00, 0x00, 0x00, 0x7e, 0xfe, 0x78, 0x00, 0x00, 0x00, 0x7e, 0x7f, 0x1c,
+ 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x0e, 0x00, 0x00, 0xc0, 0x7f, 0xff, 0x03,
+ 0x00, 0x00, 0xc0, 0x3e, 0x7f, 0x00, 0x00, 0x00, 0x20, 0xbf, 0x3f, 0x00,
+ 0x00, 0x00, 0x20, 0xbf, 0x3f, 0x00, 0x00, 0x00, 0x20, 0xbf, 0x7f, 0x00,
+ 0x00, 0x00, 0x10, 0x9f, 0x5f, 0x00, 0x00, 0x00, 0x10, 0xdf, 0x5f, 0x00,
+ 0x00, 0x00, 0x18, 0xdf, 0x4f, 0x00, 0x00, 0x00, 0x0c, 0xdf, 0x4f, 0x00,
+ 0x00, 0x00, 0x86, 0xcf, 0x47, 0x00, 0x00, 0x00, 0x80, 0xef, 0x47, 0x00,
+ 0x00, 0x00, 0x80, 0xef, 0x63, 0x00, 0x00, 0x00, 0x00, 0xef, 0x63, 0x00,
+ 0x00, 0x00, 0x00, 0xe7, 0x41, 0x00, 0x00, 0x00, 0x00, 0xf7, 0x81, 0x00,
+ 0x00, 0x00, 0x00, 0xf0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach090.xbm b/games/x11/xroach/bitmaps/roach090.xbm
new file mode 100644
index 0000000..78904ee
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach090.xbm
@@ -0,0 +1,30 @@
+#define roach090_width 48
+#define roach090_height 48
+
+static char roach090_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0xc0, 0xc0, 0x03, 0x0c, 0x00, 0x00, 0xc0, 0xd0, 0x07, 0x0c,
+ 0x00, 0x00, 0xc0, 0xc0, 0x07, 0x04, 0x00, 0x00, 0xc0, 0x60, 0x07, 0x06,
+ 0x00, 0x00, 0xc0, 0x80, 0x03, 0x06, 0x00, 0x00, 0xc0, 0xf0, 0x3f, 0x06,
+ 0x00, 0x00, 0x80, 0xf8, 0x7f, 0x06, 0x00, 0x00, 0x80, 0xf9, 0x7f, 0x06,
+ 0x00, 0x00, 0x80, 0xf9, 0x7f, 0x02, 0x00, 0x00, 0x00, 0xfb, 0x7f, 0x03,
+ 0x00, 0x00, 0x00, 0xf3, 0x9f, 0x61, 0x00, 0x00, 0x18, 0x1c, 0x70, 0x30,
+ 0x00, 0x00, 0x30, 0xfc, 0x7e, 0x18, 0x00, 0x00, 0x60, 0xfc, 0x7e, 0x0c,
+ 0x00, 0x00, 0xc0, 0xfc, 0x7e, 0x06, 0x00, 0x00, 0xc0, 0xff, 0xfe, 0x03,
+ 0x00, 0x00, 0x00, 0xfc, 0x7e, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7e, 0x00,
+ 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfe, 0x01,
+ 0x00, 0x00, 0x00, 0xff, 0x7e, 0x01, 0x00, 0x00, 0x80, 0xfc, 0x7e, 0x03,
+ 0x00, 0x00, 0x80, 0xfc, 0x7e, 0x02, 0x00, 0x00, 0x80, 0xfc, 0x7e, 0x02,
+ 0x00, 0x00, 0x80, 0xf8, 0x3e, 0x06, 0x00, 0x00, 0xc0, 0xf8, 0x3e, 0x06,
+ 0x00, 0x00, 0xc0, 0xf8, 0x3e, 0x06, 0x00, 0x00, 0xc0, 0xf8, 0x3e, 0x04,
+ 0x00, 0x00, 0xc0, 0xf8, 0x3e, 0x0c, 0x00, 0x00, 0x60, 0xf8, 0x3e, 0x08,
+ 0x00, 0x00, 0x20, 0xf8, 0x3e, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1e, 0x00,
+ 0x00, 0x00, 0x00, 0xf0, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach105.xbm b/games/x11/xroach/bitmaps/roach105.xbm
new file mode 100644
index 0000000..a0bcc80
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach105.xbm
@@ -0,0 +1,30 @@
+#define roach105_width 48
+#define roach105_height 48
+
+static char roach105_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xc1, 0x00,
+ 0x00, 0x00, 0x06, 0xf8, 0xc0, 0x00, 0x00, 0x00, 0x1c, 0xfa, 0xc1, 0x00,
+ 0x00, 0x00, 0x18, 0x88, 0x83, 0x00, 0x00, 0x00, 0x10, 0xe0, 0x9f, 0x00,
+ 0x00, 0x00, 0x30, 0xf8, 0x9f, 0x00, 0x00, 0x00, 0x20, 0xfc, 0x9f, 0x10,
+ 0x00, 0x00, 0x60, 0xfe, 0x5f, 0x18, 0x00, 0x00, 0x60, 0xfe, 0x4f, 0x0c,
+ 0x00, 0x00, 0x60, 0xfc, 0x27, 0x0c, 0x00, 0x00, 0xc0, 0x78, 0x3c, 0x0e,
+ 0x00, 0x00, 0x80, 0x07, 0x7c, 0x06, 0x00, 0x00, 0x00, 0xfc, 0xfe, 0x03,
+ 0x00, 0x00, 0x08, 0xfc, 0xfe, 0x00, 0x00, 0x00, 0x78, 0xfc, 0xfd, 0x00,
+ 0x00, 0x00, 0xe0, 0xfc, 0xfd, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0x07,
+ 0x00, 0x00, 0x00, 0xf8, 0xfd, 0x05, 0x00, 0x00, 0x00, 0xf8, 0xfb, 0x05,
+ 0x00, 0x00, 0x00, 0xf8, 0xfb, 0x09, 0x00, 0x00, 0x00, 0xfc, 0xfb, 0x19,
+ 0x00, 0x00, 0x00, 0xfc, 0xf3, 0x19, 0x00, 0x00, 0x00, 0xe4, 0xf7, 0x31,
+ 0x00, 0x00, 0x00, 0xe4, 0xf7, 0x31, 0x00, 0x00, 0x00, 0xe4, 0xf7, 0xc1,
+ 0x00, 0x00, 0x00, 0xc4, 0xe7, 0x03, 0x01, 0x00, 0x00, 0xcc, 0xef, 0x03,
+ 0x00, 0x00, 0x00, 0x8c, 0xef, 0x03, 0x00, 0x00, 0x00, 0x8c, 0xef, 0x01,
+ 0x00, 0x00, 0x00, 0x0c, 0xcf, 0x01, 0x00, 0x00, 0x00, 0x0c, 0xde, 0x01,
+ 0x00, 0x00, 0x00, 0x06, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach120.xbm b/games/x11/xroach/bitmaps/roach120.xbm
new file mode 100644
index 0000000..9087d9d
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach120.xbm
@@ -0,0 +1,30 @@
+#define roach120_width 48
+#define roach120_height 48
+
+static char roach120_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00,
+ 0x00, 0x00, 0x10, 0x08, 0x18, 0x00, 0x00, 0x00, 0x00, 0x28, 0x18, 0x00,
+ 0x00, 0x00, 0x00, 0x1e, 0x38, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x30, 0x00,
+ 0x00, 0x00, 0x00, 0x9f, 0x63, 0x00, 0x00, 0x00, 0x80, 0xe6, 0x67, 0x04,
+ 0x00, 0x80, 0x00, 0xfa, 0x27, 0x04, 0x00, 0x00, 0x07, 0xfc, 0x2f, 0x06,
+ 0x00, 0x00, 0x0c, 0xfc, 0x07, 0x06, 0x00, 0x00, 0x18, 0xfe, 0x37, 0x02,
+ 0x00, 0x00, 0x18, 0xff, 0x3b, 0x02, 0x00, 0x00, 0x30, 0xfe, 0xfc, 0x03,
+ 0x00, 0x00, 0x60, 0x3e, 0xfc, 0x00, 0x00, 0x00, 0x60, 0xc0, 0xfe, 0x00,
+ 0x00, 0x00, 0xc0, 0xff, 0xfd, 0x07, 0x00, 0x00, 0x00, 0xfc, 0xfd, 0x0f,
+ 0x00, 0x00, 0x00, 0xfc, 0xfb, 0x1b, 0x00, 0x00, 0x20, 0xf8, 0xf3, 0x37,
+ 0x00, 0x00, 0xf0, 0xf9, 0xf7, 0x67, 0x00, 0x00, 0xc0, 0xff, 0xef, 0xc7,
+ 0x00, 0x00, 0x00, 0xe0, 0xef, 0x8f, 0x01, 0x00, 0x00, 0xe0, 0xdf, 0x0f,
+ 0x0f, 0x00, 0x00, 0xe0, 0x9f, 0x0f, 0x00, 0x00, 0x00, 0xb0, 0xbf, 0x1f,
+ 0x00, 0x00, 0x00, 0x20, 0x3f, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x7e, 0x1e,
+ 0x00, 0x00, 0x00, 0x20, 0xfe, 0x3e, 0x00, 0x00, 0x00, 0x60, 0xfc, 0x3c,
+ 0x00, 0x00, 0x00, 0x40, 0xf8, 0x3d, 0x00, 0x00, 0x00, 0xc0, 0xf8, 0x19,
+ 0x00, 0x00, 0x00, 0x80, 0xf1, 0x03, 0x00, 0x00, 0x00, 0x80, 0xc1, 0x03,
+ 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach135.xbm b/games/x11/xroach/bitmaps/roach135.xbm
new file mode 100644
index 0000000..2f330d4
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach135.xbm
@@ -0,0 +1,30 @@
+#define roach135_width 48
+#define roach135_height 48
+
+static char roach135_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x40, 0xc0, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x01, 0x02, 0x0e, 0x00,
+ 0x00, 0x00, 0x04, 0x03, 0x88, 0x01, 0x00, 0x00, 0xd8, 0xef, 0x88, 0x01,
+ 0x00, 0x00, 0xc0, 0xff, 0x89, 0x01, 0x00, 0x00, 0x80, 0xfd, 0x8b, 0x01,
+ 0x00, 0x00, 0xa0, 0xfc, 0x9f, 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x01,
+ 0x00, 0x00, 0x00, 0xfe, 0x7d, 0x00, 0x00, 0xc0, 0x01, 0xff, 0xfe, 0x00,
+ 0x00, 0x00, 0x06, 0x7f, 0xfe, 0x07, 0x00, 0x00, 0x0e, 0x3f, 0xfe, 0x1f,
+ 0x00, 0x00, 0x3c, 0xcf, 0xfd, 0x27, 0x00, 0x00, 0x70, 0xe0, 0xfb, 0xc7,
+ 0x00, 0x00, 0xe0, 0xff, 0xf7, 0x8f, 0x7f, 0x00, 0x00, 0xf8, 0xef, 0x1f,
+ 0x07, 0x00, 0x00, 0xf0, 0xdf, 0x3f, 0x00, 0x00, 0x00, 0xf0, 0xbf, 0x7f,
+ 0x00, 0x00, 0x80, 0xf7, 0x7f, 0x7e, 0x00, 0x00, 0xe0, 0xdf, 0xff, 0xfc,
+ 0x00, 0x00, 0x00, 0x80, 0xff, 0xf9, 0x01, 0x00, 0x00, 0x80, 0xfe, 0xf3,
+ 0x01, 0x00, 0x00, 0x80, 0xfd, 0xe7, 0x01, 0x00, 0x00, 0x00, 0xf1, 0xcf,
+ 0x01, 0x00, 0x00, 0x00, 0xe3, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x86, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach150.xbm b/games/x11/xroach/bitmaps/roach150.xbm
new file mode 100644
index 0000000..47d9d6f
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach150.xbm
@@ -0,0 +1,30 @@
+#define roach150_width 48
+#define roach150_height 48
+
+static char roach150_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x04, 0x70, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0x00, 0x00, 0x80, 0x21, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00,
+ 0x00, 0x00, 0xc0, 0x7b, 0x42, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x42, 0x00,
+ 0x00, 0x00, 0xe1, 0xfd, 0x7f, 0x00, 0x00, 0x00, 0xf0, 0xfe, 0x3f, 0x04,
+ 0x00, 0x00, 0x60, 0xfe, 0xfe, 0x3f, 0x00, 0x00, 0x50, 0xff, 0xfe, 0x61,
+ 0x70, 0x00, 0x00, 0x7f, 0xfe, 0x87, 0x0f, 0x00, 0x00, 0x7f, 0xff, 0x0f,
+ 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x3f, 0x00, 0x00, 0x07, 0xdf, 0xf3, 0x7f,
+ 0x00, 0x80, 0x1f, 0xee, 0xcf, 0xff, 0x00, 0x00, 0x38, 0xf0, 0x3f, 0xff,
+ 0x01, 0x00, 0xe0, 0xff, 0xff, 0xfc, 0x03, 0x00, 0x00, 0xe0, 0xff, 0xf3,
+ 0x07, 0x00, 0x00, 0xc0, 0xff, 0xcf, 0x07, 0x00, 0x00, 0xc0, 0xff, 0x3f,
+ 0x07, 0x00, 0x00, 0x7c, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x3e, 0xfc, 0xff,
+ 0x01, 0x00, 0x00, 0x00, 0xec, 0xff, 0x03, 0x00, 0x00, 0x00, 0x18, 0xff,
+ 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach165.xbm b/games/x11/xroach/bitmaps/roach165.xbm
new file mode 100644
index 0000000..2f12876
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach165.xbm
@@ -0,0 +1,30 @@
+#define roach165_width 48
+#define roach165_height 48
+
+static char roach165_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x06, 0x00,
+ 0x00, 0x00, 0x80, 0x1f, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x1c, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x18, 0x00, 0x00, 0x80, 0x00, 0xc0, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00, 0x44, 0xf8, 0x1f, 0x3e,
+ 0x0e, 0x00, 0x30, 0x7c, 0xff, 0xe0, 0x07, 0x00, 0xe0, 0x7e, 0xff, 0x03,
+ 0x00, 0x00, 0xf0, 0x7e, 0xff, 0x07, 0x00, 0x00, 0x70, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0x70, 0xff, 0xff, 0xff, 0x00, 0x00, 0x60, 0x7f, 0xff, 0xff,
+ 0x01, 0x00, 0x50, 0x7f, 0x80, 0xff, 0x0f, 0x00, 0x00, 0x3f, 0x1f, 0xf8,
+ 0x1f, 0x00, 0x00, 0xbf, 0xff, 0x01, 0x1f, 0x00, 0x00, 0xde, 0xff, 0x1f,
+ 0x00, 0x00, 0x00, 0xec, 0xff, 0xff, 0x01, 0x00, 0x3e, 0xf0, 0xff, 0xff,
+ 0x07, 0x00, 0xff, 0x8f, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x07, 0xf9, 0xff,
+ 0x07, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x30, 0x00,
+ 0x00, 0x00, 0x00, 0x70, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach180.xbm b/games/x11/xroach/bitmaps/roach180.xbm
new file mode 100644
index 0000000..e3811dc
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach180.xbm
@@ -0,0 +1,30 @@
+#define roach180_width 48
+#define roach180_height 48
+
+static char roach180_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
+ 0x02, 0x00, 0x08, 0x80, 0x01, 0x00, 0x01, 0x00, 0xf8, 0x81, 0x03, 0x80,
+ 0x01, 0x00, 0xe0, 0x0f, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x84, 0x07,
+ 0x00, 0x00, 0x00, 0x20, 0x84, 0x01, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x03,
+ 0x00, 0x00, 0x00, 0x8c, 0xff, 0xff, 0x01, 0x00, 0x00, 0x9c, 0xff, 0xff,
+ 0x07, 0x00, 0x20, 0xbe, 0xff, 0xff, 0x0f, 0x00, 0xe0, 0x7f, 0xff, 0xff,
+ 0x1f, 0x00, 0xf0, 0x7f, 0xff, 0xff, 0x0f, 0x00, 0x70, 0x7f, 0x00, 0x00,
+ 0x00, 0x00, 0x70, 0x7f, 0xff, 0xff, 0x0f, 0x00, 0x70, 0x7f, 0xff, 0xff,
+ 0x1f, 0x00, 0x48, 0x7f, 0xff, 0xff, 0x1f, 0x80, 0x20, 0x7f, 0xff, 0xff,
+ 0x0f, 0x00, 0x00, 0xbe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x9c, 0xff, 0x1f,
+ 0x00, 0x00, 0x00, 0x48, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x20, 0xc4, 0x00,
+ 0x00, 0x00, 0xf0, 0x1f, 0x8c, 0xff, 0x00, 0x00, 0xf8, 0x03, 0x07, 0x80,
+ 0x01, 0x00, 0x18, 0x80, 0x03, 0x00, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x04, 0x00, 0x00, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach195.xbm b/games/x11/xroach/bitmaps/roach195.xbm
new file mode 100644
index 0000000..303008b
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach195.xbm
@@ -0,0 +1,30 @@
+#define roach195_width 48
+#define roach195_height 48
+
+static char roach195_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x1c,
+ 0x00, 0x00, 0x00, 0x38, 0x00, 0x07, 0x00, 0x00, 0x00, 0x70, 0xe0, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, 0xff,
+ 0x01, 0x00, 0xe7, 0x07, 0xff, 0xff, 0x07, 0x00, 0xfc, 0x1c, 0xff, 0xff,
+ 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0x3f,
+ 0x08, 0x00, 0x00, 0xde, 0xff, 0xc3, 0x1f, 0x00, 0x00, 0xbe, 0x3f, 0xfc,
+ 0x1f, 0x00, 0x00, 0x7f, 0xc3, 0xff, 0x1f, 0x00, 0x20, 0x7f, 0xfc, 0xff,
+ 0x0f, 0x00, 0x60, 0x7f, 0xff, 0xff, 0x01, 0x00, 0x70, 0x7f, 0xff, 0x7f,
+ 0x00, 0x00, 0x70, 0xfe, 0xff, 0x3f, 0x00, 0x00, 0xf0, 0xfe, 0xff, 0x07,
+ 0x00, 0x00, 0xe0, 0xfe, 0xff, 0xc1, 0x03, 0x00, 0x10, 0xfd, 0x7f, 0xff,
+ 0x0f, 0x00, 0xc0, 0x78, 0x11, 0x00, 0x18, 0x00, 0x02, 0xb0, 0x20, 0x00,
+ 0x00, 0x00, 0x01, 0x80, 0x30, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x38, 0x00,
+ 0x00, 0x00, 0x00, 0x7c, 0x1c, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x0c, 0x00,
+ 0x00, 0x00, 0xc0, 0x01, 0x04, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach210.xbm b/games/x11/xroach/bitmaps/roach210.xbm
new file mode 100644
index 0000000..11f9b02
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach210.xbm
@@ -0,0 +1,30 @@
+#define roach210_width 48
+#define roach210_height 48
+
+static char roach210_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xf0,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0xff, 0x01, 0x00, 0x00, 0x03, 0x8c, 0xff,
+ 0x01, 0x00, 0x00, 0x3e, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x60, 0xfc, 0x1f,
+ 0x04, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0x0f, 0x00, 0x00, 0xc0, 0xff, 0xc3,
+ 0x0f, 0x00, 0x80, 0xe7, 0xff, 0xf0, 0x07, 0x00, 0xf0, 0xf8, 0x3f, 0xfc,
+ 0x03, 0x00, 0x7f, 0xf0, 0x1f, 0xff, 0x01, 0x00, 0x0e, 0xcc, 0xc7, 0xff,
+ 0x00, 0x00, 0x00, 0x9e, 0xf1, 0x7f, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x3f,
+ 0x00, 0x00, 0x00, 0x7f, 0xfe, 0x0f, 0x0f, 0x00, 0x00, 0xff, 0xfe, 0x87,
+ 0x33, 0x00, 0xa0, 0xff, 0xfe, 0xff, 0x00, 0x00, 0xe0, 0xff, 0xfd, 0x1c,
+ 0x00, 0x00, 0xf0, 0xff, 0x7d, 0x00, 0x00, 0x00, 0xe3, 0xfd, 0xfd, 0x00,
+ 0x00, 0x00, 0xe0, 0xf9, 0x85, 0x00, 0x00, 0x00, 0xc0, 0xf1, 0xc7, 0x00,
+ 0x00, 0x00, 0x40, 0xc2, 0xc2, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x00,
+ 0x00, 0x00, 0x20, 0x80, 0x63, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00,
+ 0x00, 0x00, 0x08, 0x70, 0x20, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach225.xbm b/games/x11/xroach/bitmaps/roach225.xbm
new file mode 100644
index 0000000..cd17ce1
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach225.xbm
@@ -0,0 +1,30 @@
+#define roach225_width 48
+#define roach225_height 48
+
+static char roach225_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0xc6, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe3, 0x9f,
+ 0x01, 0x00, 0x00, 0x00, 0xf1, 0xcf, 0x01, 0x00, 0x00, 0x00, 0xf9, 0xe7,
+ 0x01, 0x00, 0x00, 0x00, 0xff, 0xf3, 0x01, 0x00, 0x00, 0x0f, 0xff, 0xf9,
+ 0x01, 0x00, 0xc0, 0x1f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0xf0, 0x3f, 0x7e,
+ 0x00, 0x00, 0x00, 0xe0, 0x9f, 0x7f, 0x00, 0x00, 0x00, 0xf0, 0xcf, 0x3f,
+ 0x3e, 0x00, 0x80, 0xff, 0xe7, 0x1f, 0x07, 0x00, 0xc0, 0xf0, 0xf3, 0xdf,
+ 0x03, 0x00, 0x70, 0xe0, 0xf9, 0xcf, 0x00, 0x00, 0x38, 0x3c, 0xfc, 0x67,
+ 0x00, 0x00, 0x1e, 0x7e, 0xfe, 0x1f, 0x00, 0x80, 0x0f, 0xfe, 0xfc, 0x01,
+ 0x00, 0x00, 0x00, 0xfe, 0xfd, 0x01, 0x00, 0x00, 0x00, 0xfe, 0xfb, 0x01,
+ 0x00, 0x00, 0x00, 0xff, 0x7b, 0x03, 0x00, 0x00, 0x00, 0xfd, 0x0f, 0x03,
+ 0x00, 0x00, 0x80, 0xf9, 0x1f, 0x03, 0x00, 0x00, 0xc0, 0xe3, 0x1f, 0x03,
+ 0x00, 0x00, 0x80, 0x9f, 0x1b, 0x01, 0x00, 0x00, 0x00, 0x07, 0x18, 0x01,
+ 0x00, 0x00, 0x02, 0x08, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach240.xbm b/games/x11/xroach/bitmaps/roach240.xbm
new file mode 100644
index 0000000..467ac9d
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach240.xbm
@@ -0,0 +1,30 @@
+#define roach240_width 48
+#define roach240_height 48
+
+static char roach240_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x80, 0xc1, 0x03, 0x00, 0x00, 0x00, 0x80, 0xf1, 0x11,
+ 0x00, 0x00, 0x00, 0x80, 0xf8, 0x18, 0x00, 0x00, 0x00, 0x80, 0xf8, 0x3c,
+ 0x00, 0x00, 0x00, 0x40, 0x7c, 0x3c, 0x00, 0x00, 0x00, 0x40, 0x7e, 0x3e,
+ 0x00, 0x00, 0x00, 0x20, 0x3f, 0x1e, 0x00, 0x00, 0x00, 0xa0, 0x3f, 0x1f,
+ 0x00, 0x00, 0x00, 0xe0, 0x9f, 0x1f, 0x3e, 0x00, 0x00, 0xc0, 0x9f, 0x0f,
+ 0x07, 0x00, 0x00, 0xc0, 0xcf, 0x8f, 0x00, 0x00, 0x00, 0xe6, 0xe7, 0xcf,
+ 0x00, 0x00, 0xc0, 0xf9, 0xe7, 0x47, 0x00, 0x00, 0x00, 0xf0, 0xf3, 0x67,
+ 0x00, 0x00, 0x00, 0xf8, 0xf3, 0x37, 0x00, 0x00, 0x00, 0xf8, 0xf9, 0x1f,
+ 0x00, 0x00, 0x00, 0xff, 0xfd, 0x07, 0x00, 0x00, 0xc0, 0x03, 0xfc, 0x01,
+ 0x00, 0x00, 0x60, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x30, 0xfc, 0xfc, 0x03,
+ 0x00, 0x00, 0x30, 0xfe, 0xfb, 0x06, 0x00, 0x00, 0x30, 0xfe, 0x77, 0x06,
+ 0x00, 0x00, 0x1c, 0xfc, 0x37, 0x06, 0x00, 0x00, 0x02, 0xfc, 0x2f, 0x06,
+ 0x00, 0x00, 0x00, 0xf8, 0x7f, 0x04, 0x00, 0x00, 0x00, 0xe5, 0x6f, 0x0c,
+ 0x00, 0x00, 0x00, 0x8e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x60, 0x00,
+ 0x00, 0x00, 0x00, 0x3e, 0x20, 0x00, 0x00, 0x00, 0x80, 0xf0, 0x30, 0x00,
+ 0x00, 0x00, 0x40, 0x10, 0x30, 0x00, 0x00, 0x00, 0x00, 0x10, 0x18, 0x00,
+ 0x00, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach255.xbm b/games/x11/xroach/bitmaps/roach255.xbm
new file mode 100644
index 0000000..de5cea6
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach255.xbm
@@ -0,0 +1,30 @@
+#define roach255_width 48
+#define roach255_height 48
+
+static char roach255_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0x18, 0x00, 0x00, 0x00, 0x00, 0x06, 0x9c, 0x01,
+ 0x00, 0x00, 0x00, 0x0c, 0x9e, 0x03, 0x00, 0x00, 0x00, 0x18, 0x8f, 0x03,
+ 0x00, 0x00, 0x00, 0x18, 0xcf, 0x03, 0x00, 0x00, 0x00, 0x98, 0xcf, 0x03,
+ 0x00, 0x00, 0x00, 0x88, 0xcf, 0x83, 0x01, 0x00, 0x00, 0xc8, 0xc7, 0xe3,
+ 0x00, 0x00, 0x00, 0xc8, 0xe7, 0x63, 0x00, 0x00, 0x00, 0xec, 0xe7, 0x33,
+ 0x00, 0x00, 0x00, 0xec, 0xe7, 0x33, 0x00, 0x00, 0x00, 0xf8, 0xe3, 0x13,
+ 0x00, 0x00, 0x00, 0xf8, 0xf3, 0x1b, 0x00, 0x00, 0x00, 0xf0, 0xf3, 0x1b,
+ 0x00, 0x00, 0x00, 0xf0, 0xf3, 0x09, 0x00, 0x00, 0x80, 0xff, 0xf9, 0x07,
+ 0x00, 0x00, 0xc0, 0xf8, 0xf9, 0x01, 0x00, 0x00, 0xe0, 0xf8, 0xf9, 0x01,
+ 0x00, 0x00, 0x10, 0xfc, 0xf9, 0x01, 0x00, 0x00, 0x00, 0xfc, 0xfc, 0x07,
+ 0x00, 0x00, 0x00, 0x02, 0xfc, 0x0c, 0x00, 0x00, 0x00, 0x01, 0xf8, 0x0c,
+ 0x00, 0x00, 0x80, 0xf8, 0x63, 0x18, 0x00, 0x00, 0xc0, 0xfc, 0x6f, 0x18,
+ 0x00, 0x00, 0x60, 0xfc, 0x9f, 0x30, 0x00, 0x00, 0x60, 0xfc, 0x3f, 0x01,
+ 0x00, 0x00, 0x60, 0xf8, 0x3f, 0x01, 0x00, 0x00, 0x20, 0xe0, 0x3f, 0x01,
+ 0x00, 0x00, 0x38, 0xb0, 0x8f, 0x01, 0x00, 0x00, 0x08, 0xf4, 0x83, 0x01,
+ 0x00, 0x00, 0x00, 0xf0, 0x81, 0x01, 0x00, 0x00, 0x00, 0xf0, 0x85, 0x00,
+ 0x00, 0x00, 0x00, 0x08, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x81, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach270.xbm b/games/x11/xroach/bitmaps/roach270.xbm
new file mode 100644
index 0000000..d3a0787
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach270.xbm
@@ -0,0 +1,30 @@
+#define roach270_width 48
+#define roach270_height 48
+
+static char roach270_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xc0, 0x0c, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1c, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0x1c, 0x00, 0x00, 0x00, 0x20, 0xf0, 0x3c, 0x18,
+ 0x00, 0x00, 0xc0, 0xf0, 0x3c, 0x0c, 0x00, 0x00, 0x80, 0xf1, 0x3c, 0x06,
+ 0x00, 0x00, 0x00, 0xf9, 0x7c, 0x06, 0x00, 0x00, 0x00, 0xf9, 0x7c, 0x06,
+ 0x00, 0x00, 0x00, 0xf9, 0x7c, 0x06, 0x00, 0x00, 0x00, 0xf9, 0x7c, 0x06,
+ 0x00, 0x00, 0x00, 0xf9, 0x7c, 0x06, 0x00, 0x00, 0x00, 0xfb, 0x7c, 0x02,
+ 0x00, 0x00, 0x00, 0xff, 0xfc, 0x02, 0x00, 0x00, 0x00, 0xfe, 0xfc, 0x01,
+ 0x00, 0x00, 0x00, 0xfc, 0xfc, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfc, 0x00,
+ 0x00, 0x00, 0x00, 0xf8, 0xfc, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfc, 0x07,
+ 0x00, 0x00, 0x80, 0xfc, 0xfc, 0x0c, 0x00, 0x00, 0xc0, 0xfc, 0xfc, 0x18,
+ 0x00, 0x00, 0x60, 0x78, 0xfc, 0x10, 0x00, 0x00, 0x30, 0x18, 0xc0, 0x20,
+ 0x00, 0x00, 0x00, 0xc6, 0x1f, 0x01, 0x00, 0x00, 0x00, 0xe3, 0x7f, 0x02,
+ 0x00, 0x00, 0x00, 0xf1, 0xff, 0x06, 0x00, 0x00, 0x80, 0xf1, 0xff, 0x06,
+ 0x00, 0x00, 0x80, 0xf1, 0xff, 0x06, 0x00, 0x00, 0x80, 0xe1, 0x7f, 0x06,
+ 0x00, 0x00, 0x80, 0x81, 0x1f, 0x06, 0x00, 0x00, 0x80, 0x81, 0x0f, 0x04,
+ 0x00, 0x00, 0x80, 0x81, 0x2f, 0x04, 0x00, 0x00, 0xc0, 0x80, 0x0f, 0x0c,
+ 0x00, 0x00, 0x40, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach285.xbm b/games/x11/xroach/bitmaps/roach285.xbm
new file mode 100644
index 0000000..5e2af7a
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach285.xbm
@@ -0,0 +1,30 @@
+#define roach285_width 48
+#define roach285_height 48
+
+static char roach285_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x60, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0xe6, 0xc1, 0x00, 0x00, 0x00, 0x00, 0xcf, 0x63, 0x00,
+ 0x00, 0x00, 0x00, 0xcf, 0x47, 0x00, 0x00, 0x00, 0x00, 0xcf, 0x47, 0x00,
+ 0x00, 0x00, 0x03, 0xdf, 0x4f, 0x00, 0x00, 0x00, 0x1c, 0x9f, 0xcf, 0x00,
+ 0x00, 0x00, 0x30, 0x9f, 0x9f, 0x00, 0x00, 0x00, 0x30, 0xbf, 0x9f, 0x00,
+ 0x00, 0x00, 0x20, 0xbf, 0xbf, 0x00, 0x00, 0x00, 0x40, 0x3e, 0xff, 0x00,
+ 0x00, 0x00, 0x40, 0x3e, 0x7f, 0x00, 0x00, 0x00, 0xc0, 0x7e, 0x7f, 0x00,
+ 0x00, 0x00, 0xc0, 0x7f, 0x7f, 0x03, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0x07,
+ 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x1c, 0x00, 0x00, 0x00, 0xfc, 0xfe, 0x18,
+ 0x00, 0x00, 0x00, 0xfc, 0xfe, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfd, 0x00,
+ 0x00, 0x00, 0x00, 0xfd, 0x01, 0x07, 0x00, 0x00, 0x80, 0x7c, 0xf8, 0x0e,
+ 0x00, 0x00, 0xc0, 0xb8, 0xff, 0x0d, 0x00, 0x00, 0x40, 0xd8, 0xff, 0x09,
+ 0x00, 0x00, 0x00, 0xcc, 0xff, 0x19, 0x00, 0x00, 0x00, 0xee, 0xff, 0x19,
+ 0x00, 0x00, 0x00, 0xe6, 0xff, 0x18, 0x00, 0x00, 0x00, 0xc6, 0x7f, 0x30,
+ 0x00, 0x00, 0x00, 0x86, 0x7f, 0x60, 0x00, 0x00, 0x00, 0x06, 0x7e, 0xc1,
+ 0x00, 0x00, 0x00, 0x04, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x0c, 0xbc, 0x00,
+ 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach300.xbm b/games/x11/xroach/bitmaps/roach300.xbm
new file mode 100644
index 0000000..ca4e89b
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach300.xbm
@@ -0,0 +1,30 @@
+#define roach300_width 48
+#define roach300_height 48
+
+static char roach300_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x1f, 0x06, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x04, 0x00,
+ 0x00, 0x00, 0x60, 0x7c, 0x0c, 0x00, 0x00, 0x00, 0xe0, 0x7c, 0x0c, 0x00,
+ 0x00, 0x00, 0xf0, 0xf8, 0x08, 0x00, 0x00, 0x00, 0xe0, 0xf9, 0x11, 0x00,
+ 0x00, 0x00, 0xe0, 0xf3, 0x13, 0x00, 0x00, 0x00, 0xe0, 0xf3, 0x17, 0x00,
+ 0x00, 0x00, 0xc0, 0xe7, 0x1f, 0x00, 0x00, 0xc0, 0xc7, 0xc7, 0x1f, 0x00,
+ 0x00, 0x00, 0xcc, 0xcf, 0x9f, 0x00, 0x00, 0x00, 0x88, 0x9f, 0xff, 0x07,
+ 0x00, 0x00, 0x98, 0x9f, 0xff, 0x3c, 0x00, 0x00, 0xb0, 0x3f, 0x7f, 0x00,
+ 0x00, 0x00, 0x60, 0x7f, 0xff, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0xfe, 0x00,
+ 0x00, 0x00, 0x00, 0xfe, 0x7e, 0x0f, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x1c,
+ 0x00, 0x00, 0x00, 0xfc, 0xf1, 0x19, 0x00, 0x00, 0x00, 0x7e, 0xf8, 0x33,
+ 0x00, 0x00, 0x00, 0x79, 0xfc, 0x63, 0x00, 0x00, 0x80, 0x31, 0xfe, 0x63,
+ 0x00, 0x00, 0x80, 0x31, 0xff, 0xc3, 0x01, 0x00, 0x80, 0x91, 0xff, 0x01,
+ 0x03, 0x00, 0x80, 0x91, 0xff, 0x04, 0x00, 0x00, 0x80, 0x98, 0x7f, 0x01,
+ 0x00, 0x00, 0x00, 0x18, 0xff, 0x03, 0x00, 0x00, 0x00, 0x10, 0xf0, 0x05,
+ 0x00, 0x00, 0x00, 0x30, 0x60, 0x08, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach315.xbm b/games/x11/xroach/bitmaps/roach315.xbm
new file mode 100644
index 0000000..922698a
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach315.xbm
@@ -0,0 +1,30 @@
+#define roach315_width 48
+#define roach315_height 48
+
+static char roach315_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0xe1, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc7, 0x01, 0x00,
+ 0x00, 0x00, 0xe0, 0x9f, 0x01, 0x00, 0x00, 0x00, 0xc6, 0x3f, 0x02, 0x00,
+ 0x00, 0x00, 0x8e, 0x7f, 0x06, 0x00, 0x00, 0x00, 0x1e, 0xff, 0x06, 0x00,
+ 0x00, 0x00, 0x3e, 0xfe, 0xc3, 0x00, 0x00, 0x00, 0x7c, 0xfc, 0xe7, 0x1f,
+ 0x00, 0x00, 0xfc, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0xf8, 0xf1, 0x1f, 0x00,
+ 0x00, 0x00, 0xf8, 0xe7, 0x3f, 0x00, 0x00, 0x80, 0xf1, 0xcf, 0x3f, 0x02,
+ 0x00, 0x00, 0xe6, 0x9f, 0xff, 0x07, 0x00, 0x00, 0xcc, 0x3f, 0x1f, 0x08,
+ 0x00, 0x00, 0x9c, 0x7f, 0xce, 0x31, 0x00, 0x00, 0xf0, 0xff, 0xe0, 0x63,
+ 0x00, 0x00, 0xc0, 0xfe, 0xf1, 0xe7, 0x03, 0x00, 0x00, 0xfc, 0xf9, 0xc7,
+ 0x00, 0x00, 0x00, 0xf8, 0xf8, 0x07, 0x00, 0x00, 0x00, 0xfe, 0xfc, 0x03,
+ 0x00, 0x00, 0x00, 0x62, 0xfe, 0x05, 0x00, 0x00, 0x00, 0x42, 0xfe, 0x0e,
+ 0x00, 0x00, 0x00, 0x42, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x46, 0xfe, 0x47,
+ 0x00, 0x00, 0x00, 0x66, 0x84, 0x03, 0x00, 0x00, 0x00, 0xc2, 0x40, 0x00,
+ 0x04, 0x00, 0x00, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x04, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach330.xbm b/games/x11/xroach/bitmaps/roach330.xbm
new file mode 100644
index 0000000..67735f8
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach330.xbm
@@ -0,0 +1,30 @@
+#define roach330_width 48
+#define roach330_height 48
+
+static char roach330_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x60, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0xc1, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x8f, 0xf0, 0x01,
+ 0x00, 0x00, 0xf8, 0xff, 0x38, 0x00, 0x00, 0x80, 0xe0, 0xff, 0x0f, 0x00,
+ 0x00, 0x80, 0xc3, 0xff, 0x07, 0x00, 0x00, 0x80, 0x0f, 0xff, 0x1f, 0x03,
+ 0x00, 0x80, 0x3f, 0xfc, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xf0, 0x7f, 0x38,
+ 0x00, 0x00, 0xfe, 0xe3, 0x8f, 0xe1, 0x07, 0x00, 0xf8, 0x8f, 0xc7, 0xc3,
+ 0x00, 0x00, 0xf0, 0x3f, 0xe6, 0x07, 0x00, 0x00, 0xe1, 0xff, 0xf0, 0x07,
+ 0x00, 0xc0, 0xc7, 0xff, 0xf9, 0x07, 0x00, 0x30, 0xbc, 0xff, 0xf9, 0x07,
+ 0x00, 0x00, 0xf0, 0xfd, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0xf8, 0xfd, 0x7f,
+ 0x00, 0x00, 0x00, 0xf0, 0xfc, 0x1d, 0x08, 0x00, 0x00, 0xc8, 0xfd, 0x1e,
+ 0x00, 0x00, 0x00, 0x0c, 0x7d, 0x06, 0x00, 0x00, 0x00, 0x08, 0x19, 0x02,
+ 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x10, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/bitmaps/roach345.xbm b/games/x11/xroach/bitmaps/roach345.xbm
new file mode 100644
index 0000000..af01fa5
--- /dev/null
+++ b/games/x11/xroach/bitmaps/roach345.xbm
@@ -0,0 +1,30 @@
+#define roach345_width 48
+#define roach345_height 48
+
+static char roach345_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x40, 0x00,
+ 0x00, 0x00, 0x00, 0x0e, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
+ 0x00, 0x00, 0xff, 0x23, 0x03, 0x00, 0x00, 0x80, 0xff, 0xff, 0x83, 0x03,
+ 0x00, 0xc0, 0xff, 0xff, 0xe3, 0xff, 0x03, 0x80, 0xff, 0xff, 0x3f, 0x70,
+ 0x00, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0x00, 0x40, 0x00, 0xff, 0xcf, 0x03,
+ 0x00, 0xe0, 0x0f, 0xf0, 0xef, 0x03, 0x00, 0xc0, 0x7f, 0x00, 0xf7, 0x07,
+ 0x00, 0xc0, 0xff, 0x07, 0xf0, 0x07, 0x00, 0x00, 0xff, 0x7f, 0xf0, 0xff,
+ 0x13, 0x00, 0xfe, 0xff, 0xf1, 0x3f, 0x00, 0x00, 0xf0, 0xff, 0xf9, 0x3b,
+ 0x00, 0x00, 0xc0, 0xff, 0xf9, 0x1f, 0x00, 0x00, 0x82, 0xff, 0xfb, 0x1f,
+ 0x00, 0x00, 0xff, 0xfb, 0xfb, 0x03, 0x00, 0x80, 0xe1, 0xe1, 0xf3, 0x81,
+ 0x00, 0x40, 0x00, 0x30, 0x62, 0x00, 0x02, 0x00, 0x00, 0x30, 0x04, 0x00,
+ 0x04, 0x00, 0x00, 0x60, 0x0c, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x78, 0x00,
+ 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00};
+
diff --git a/games/x11/xroach/roachmap.h b/games/x11/xroach/roachmap.h
new file mode 100644
index 0000000..209bf54
--- /dev/null
+++ b/games/x11/xroach/roachmap.h
@@ -0,0 +1,65 @@
+#include "roach000.xbm"
+#include "roach015.xbm"
+#include "roach030.xbm"
+#include "roach045.xbm"
+#include "roach060.xbm"
+#include "roach075.xbm"
+#include "roach090.xbm"
+#include "roach105.xbm"
+#include "roach120.xbm"
+#include "roach135.xbm"
+#include "roach150.xbm"
+#include "roach165.xbm"
+#include "roach180.xbm"
+#include "roach195.xbm"
+#include "roach210.xbm"
+#include "roach225.xbm"
+#include "roach240.xbm"
+#include "roach255.xbm"
+#include "roach270.xbm"
+#include "roach285.xbm"
+#include "roach300.xbm"
+#include "roach315.xbm"
+#include "roach330.xbm"
+#include "roach345.xbm"
+
+#define ROACH_HEADINGS 24 /* number of orientations */
+#define ROACH_ANGLE 15 /* angle between orientations */
+
+typedef struct RoachMap {
+ char *roachBits;
+ Pixmap pixmap;
+ int width;
+ int height;
+ float sine;
+ float cosine;
+} RoachMap;
+
+RoachMap roachPix[] = {
+ {roach000_bits, None, roach000_height, roach000_width, 0.0, 0.0},
+ {roach015_bits, None, roach015_height, roach015_width, 0.0, 0.0},
+ {roach030_bits, None, roach030_height, roach030_width, 0.0, 0.0},
+ {roach045_bits, None, roach045_height, roach045_width, 0.0, 0.0},
+ {roach060_bits, None, roach060_height, roach060_width, 0.0, 0.0},
+ {roach075_bits, None, roach075_height, roach075_width, 0.0, 0.0},
+ {roach090_bits, None, roach090_height, roach090_width, 0.0, 0.0},
+ {roach105_bits, None, roach105_height, roach105_width, 0.0, 0.0},
+ {roach120_bits, None, roach120_height, roach120_width, 0.0, 0.0},
+ {roach135_bits, None, roach135_height, roach135_width, 0.0, 0.0},
+ {roach150_bits, None, roach150_height, roach150_width, 0.0, 0.0},
+ {roach165_bits, None, roach165_height, roach165_width, 0.0, 0.0},
+ {roach180_bits, None, roach180_height, roach180_width, 0.0, 0.0},
+ {roach195_bits, None, roach195_height, roach195_width, 0.0, 0.0},
+ {roach210_bits, None, roach210_height, roach210_width, 0.0, 0.0},
+ {roach225_bits, None, roach225_height, roach225_width, 0.0, 0.0},
+ {roach240_bits, None, roach240_height, roach240_width, 0.0, 0.0},
+ {roach255_bits, None, roach255_height, roach255_width, 0.0, 0.0},
+ {roach270_bits, None, roach270_height, roach270_width, 0.0, 0.0},
+ {roach285_bits, None, roach285_height, roach285_width, 0.0, 0.0},
+ {roach300_bits, None, roach300_height, roach300_width, 0.0, 0.0},
+ {roach315_bits, None, roach315_height, roach315_width, 0.0, 0.0},
+ {roach330_bits, None, roach330_height, roach330_width, 0.0, 0.0},
+ {roach345_bits, None, roach345_height, roach345_width, 0.0, 0.0},
+};
+
+
diff --git a/games/x11/xroach/xroach.6 b/games/x11/xroach/xroach.6
new file mode 100644
index 0000000..509fc40
--- /dev/null
+++ b/games/x11/xroach/xroach.6
@@ -0,0 +1,75 @@
+.\" Copyright (c) 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" from: X Version 11 Release 4, May 30, 1991
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)xroach.6 8.2 (Berkeley) 4/19/94
+.\"
+.TH XROACH 6 "April 19, 1994" "X Version 11 Release 4"
+.SH NAME
+xroach \- cockroaches hide under your windows
+.SH SYNOPSIS
+.B xroach
+[-option .,..]
+.SH DESCRIPTION
+.I Xroach
+displays disgusting cockroaches on your root window. These creepy crawlies
+scamper
+around until they find a window to hide under. Whenever you move or iconify
+a window, the exposed beetles again scamper for cover.
+.SH OPTIONS
+.TP 8
+.B \-display \fIdisplay_name\fB
+Drop the roaches on the given display. Make sure the display is nearby, so you
+can hear the screams.
+.TP 8
+.B \-rc \fIroach_color\fB
+Use the given string as the color for the bugs instead of the default "black".
+.TP 8
+.B \-speed \fIroach_speed\fB
+Use the given speed for the insects instead of the default 20.0. For example,
+in winter the speed should be set to 5.0. In summer, 30.0 might be about
+right.
+.TP 8
+.B \-roaches \fInum_roaches\fB
+This is the number of the little critters. Default is 10.
+.SH BUGS
+As given by the -roaches option. Default is 10.
+.SH COPYRIGHT
+Copyright 1991 by J.T. Anderson
+.SH AUTHORS
+J.T. Anderson
+(jta@locus.com)
+.SH DEDICATION
+Greg McFarlane
+(gregm@otc.otca.oz.au)
+.SH "SEE ALSO"
+xroachmotel(1), xddt(1)
diff --git a/games/x11/xroach/xroach.c b/games/x11/xroach/xroach.c
new file mode 100644
index 0000000..854167f
--- /dev/null
+++ b/games/x11/xroach/xroach.c
@@ -0,0 +1,602 @@
+/*
+ Xroach - A game of skill. Try to find the roaches under your windows.
+
+ Copyright 1991 by J.T. Anderson
+
+ jta@locus.com
+
+ This program may be freely distributed provided that all
+ copyright notices are retained.
+
+ To build:
+ cc -o xroach roach.c -lX11 [-lsocketorwhatever] [-lm] [-l...]
+
+ Dedicated to Greg McFarlane. (gregm@otc.otca.oz.au)
+*/
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+
+#include <stdio.h>
+#include <math.h>
+#include <signal.h>
+#include <stdlib.h>
+
+char Copyright[] = "Xroach\nCopyright 1991 J.T. Anderson";
+
+#include "roachmap.h"
+
+typedef unsigned long Pixel;
+typedef int ErrorHandler();
+
+#define SCAMPER_EVENT (LASTEvent + 1)
+
+#if !defined(GRAB_SERVER)
+#define GRAB_SERVER 0
+#endif
+
+Display *display;
+int screen;
+Window rootWin;
+unsigned int display_width, display_height;
+int center_x, center_y;
+GC gc;
+char *display_name = NULL;
+Pixel black, white;
+
+int done = 0;
+int eventBlock = 0;
+int errorVal = 0;
+
+typedef struct Roach {
+ RoachMap *rp;
+ int index;
+ float x;
+ float y;
+ int intX;
+ int intY;
+ int hidden;
+ int turnLeft;
+ int steps;
+} Roach;
+
+Roach *roaches;
+int maxRoaches = 10;
+int curRoaches = 0;
+float roachSpeed = 20.0;
+
+Region rootVisible = NULL;
+
+void Usage();
+void SigHandler();
+void AddRoach();
+void MoveRoach();
+void DrawRoaches();
+void CoverRoot();
+int CalcRootVisible();
+int MarkHiddenRoaches();
+Pixel AllocNamedColor();
+
+void
+main(ac, av)
+int ac;
+char *av[];
+{
+ XGCValues xgcv;
+ int ax;
+ char *arg;
+ RoachMap *rp;
+ int rx;
+ float angle;
+ XEvent ev;
+ char *roachColor = "black";
+ int nVis;
+ int needCalc;
+
+ /*
+ Process command line options.
+ */
+ for (ax=1; ax<ac; ax++) {
+ arg = av[ax];
+ if (strcmp(arg, "-display") == 0) {
+ display_name = av[++ax];
+ }
+ else if (strcmp(arg, "-rc") == 0) {
+ roachColor = av[++ax];
+ }
+ else if (strcmp(arg, "-speed") == 0) {
+ roachSpeed = atof(av[++ax]);
+ }
+ else if (strcmp(arg, "-roaches") == 0) {
+ maxRoaches = strtol(av[++ax], (char **)NULL, 0);
+ }
+ else {
+ Usage();
+ }
+ }
+
+ srand((int)time((long *)NULL));
+
+ /*
+ Catch some signals so we can erase any visible roaches.
+ */
+ signal(SIGKILL, SigHandler);
+ signal(SIGINT, SigHandler);
+ signal(SIGTERM, SigHandler);
+ signal(SIGHUP, SigHandler);
+
+ display = XOpenDisplay(display_name);
+ if (display == NULL) {
+ if (display_name == NULL) display_name = getenv("DISPLAY");
+ (void) fprintf(stderr, "%s: cannot connect to X server %s\n", av[0],
+ display_name ? display_name : "(default)");
+ exit(1);
+ }
+
+ screen = DefaultScreen(display);
+ rootWin = RootWindow(display, screen);
+ black = BlackPixel(display, screen);
+ white = WhitePixel(display, screen);
+
+ display_width = DisplayWidth(display, screen);
+ display_height = DisplayHeight(display, screen);
+ center_x = display_width / 2;
+ center_y = display_height / 2;
+
+ /*
+ Create roach pixmaps at several orientations.
+ */
+ for (ax=0; ax<360; ax+=ROACH_ANGLE) {
+ rx = ax / ROACH_ANGLE;
+ angle = rx * 0.261799387799;
+ rp = &roachPix[rx];
+ rp->pixmap = XCreateBitmapFromData(display, rootWin,
+ rp->roachBits, rp->width, rp->height);
+ rp->sine = sin(angle);
+ rp->cosine = cos(angle);
+ }
+
+ roaches = (Roach *)malloc(sizeof(Roach) * maxRoaches);
+
+ gc = XCreateGC(display, rootWin, 0L, &xgcv);
+ XSetForeground(display, gc, AllocNamedColor(roachColor, black));
+ XSetFillStyle(display, gc, FillStippled);
+
+ while (curRoaches < maxRoaches)
+ AddRoach();
+
+ XSelectInput(display, rootWin, ExposureMask | SubstructureNotifyMask);
+
+ needCalc = 1;
+ while (!done) {
+ if (XPending(display)) {
+ XNextEvent(display, &ev);
+ }
+ else {
+ if (needCalc) {
+ needCalc = CalcRootVisible();
+ }
+ nVis = MarkHiddenRoaches();
+ if (nVis) {
+ ev.type = SCAMPER_EVENT;
+ }
+ else {
+ DrawRoaches();
+ eventBlock = 1;
+ XNextEvent(display, &ev);
+ eventBlock = 0;
+ }
+ }
+
+ switch (ev.type) {
+
+ case SCAMPER_EVENT:
+ for (rx=0; rx<curRoaches; rx++) {
+ if (!roaches[rx].hidden)
+ MoveRoach(rx);
+ }
+ DrawRoaches();
+ XSync(display, False);
+ break;
+
+ case Expose:
+ case MapNotify:
+ case UnmapNotify:
+ case ConfigureNotify:
+ needCalc = 1;
+ break;
+
+ }
+ }
+
+ CoverRoot();
+
+ XCloseDisplay(display);
+}
+
+#define USEPRT(msg) fprintf(stderr, msg)
+
+void
+Usage()
+{
+ USEPRT("Usage: xroach [options]\n\n");
+ USEPRT("Options:\n");
+ USEPRT(" -display displayname\n");
+ USEPRT(" -rc roachcolor\n");
+ USEPRT(" -roaches numroaches\n");
+ USEPRT(" -speed roachspeed\n");
+
+ exit(1);
+}
+
+void
+SigHandler()
+{
+
+ /*
+ If we are blocked, no roaches are visible and we can just bail
+ out. If we are not blocked, then let the main procedure clean
+ up the root window.
+ */
+ if (eventBlock) {
+ XCloseDisplay(display);
+ exit(0);
+ }
+ else {
+ done = 1;
+ }
+}
+
+/*
+ Generate random integer between 0 and maxVal-1.
+*/
+int
+RandInt(maxVal)
+int maxVal;
+{
+ return rand() % maxVal;
+}
+
+/*
+ Check for roach completely in specified rectangle.
+*/
+int
+RoachInRect(roach, rx, ry, x, y, width, height)
+Roach *roach;
+int rx;
+int ry;
+int x;
+int y;
+unsigned int width;
+unsigned int height;
+{
+ if (rx < x) return 0;
+ if ((rx + roach->rp->width) > (x + width)) return 0;
+ if (ry < y) return 0;
+ if ((ry + roach->rp->height) > (y + height)) return 0;
+
+ return 1;
+}
+
+/*
+ Check for roach overlapping specified rectangle.
+*/
+int
+RoachOverRect(roach, rx, ry, x, y, width, height)
+Roach *roach;
+int rx;
+int ry;
+int x;
+int y;
+unsigned int width;
+unsigned int height;
+{
+ if (rx >= (x + width)) return 0;
+ if ((rx + roach->rp->width) <= x) return 0;
+ if (ry >= (y + height)) return 0;
+ if ((ry + roach->rp->height) <= y) return 0;
+
+ return 1;
+}
+
+/*
+ Give birth to a roach.
+*/
+void
+AddRoach()
+{
+ Roach *r;
+
+ if (curRoaches < maxRoaches) {
+ r = &roaches[curRoaches++];
+ r->index = RandInt(ROACH_HEADINGS);
+ r->rp = &roachPix[r->index];
+ r->x = RandInt(display_width - r->rp->width);
+ r->y = RandInt(display_height - r->rp->height);
+ r->intX = -1;
+ r->intY = -1;
+ r->hidden = 0;
+ r->steps = RandInt(200);
+ r->turnLeft = RandInt(100) >= 50;
+ }
+}
+
+/*
+ Turn a roach.
+*/
+void
+TurnRoach(roach)
+Roach *roach;
+{
+ if (roach->index != (roach->rp - roachPix)) return;
+
+ if (roach->turnLeft) {
+ roach->index += (RandInt(30) / 10) + 1;
+ if (roach->index >= ROACH_HEADINGS)
+ roach->index -= ROACH_HEADINGS;
+ }
+ else {
+ roach->index -= (RandInt(30) / 10) + 1;
+ if (roach->index < 0)
+ roach->index += ROACH_HEADINGS;
+ }
+}
+
+/*
+ Move a roach.
+*/
+void
+MoveRoach(rx)
+int rx;
+{
+ Roach *roach;
+ Roach *r2;
+ float newX;
+ float newY;
+ int ii;
+
+ roach = &roaches[rx];
+ newX = roach->x + (roachSpeed * roach->rp->cosine);
+ newY = roach->y - (roachSpeed * roach->rp->sine);
+
+ if (RoachInRect(roach, (int)newX, (int)newY,
+ 0, 0, display_width, display_height)) {
+
+ roach->x = newX;
+ roach->y = newY;
+
+ if (roach->steps-- <= 0) {
+ TurnRoach(roach);
+ roach->steps = RandInt(200);
+ }
+
+ for (ii=rx+1; ii<curRoaches; ii++) {
+ r2 = &roaches[ii];
+ if (RoachOverRect(roach, (int)newX, (int)newY,
+ r2->intX, r2->intY, r2->rp->width, r2->rp->height)) {
+
+ TurnRoach(roach);
+ }
+ }
+ }
+ else {
+ TurnRoach(roach);
+ }
+}
+
+/*
+ Draw all roaches.
+*/
+void
+DrawRoaches()
+{
+ Roach *roach;
+ int rx;
+
+ for (rx=0; rx<curRoaches; rx++) {
+ roach = &roaches[rx];
+
+ if (roach->intX >= 0) {
+ XClearArea(display, rootWin, roach->intX, roach->intY,
+ roach->rp->width, roach->rp->height, False);
+ }
+ }
+
+ for (rx=0; rx<curRoaches; rx++) {
+ roach = &roaches[rx];
+
+ if (!roach->hidden) {
+ roach->intX = roach->x;
+ roach->intY = roach->y;
+ roach->rp = &roachPix[roach->index];
+
+ XSetStipple(display, gc, roach->rp->pixmap);
+ XSetTSOrigin(display, gc, roach->intX, roach->intY);
+ XFillRectangle(display, rootWin, gc,
+ roach->intX, roach->intY, roach->rp->width, roach->rp->height);
+ }
+ else {
+ roach->intX = -1;
+ }
+ }
+}
+
+/*
+ Cover root window to erase roaches.
+*/
+void
+CoverRoot()
+{
+ XSetWindowAttributes xswa;
+ long wamask;
+ Window roachWin;
+
+ xswa.background_pixmap = ParentRelative;
+ xswa.override_redirect = True;
+ wamask = CWBackPixmap | CWOverrideRedirect;
+ roachWin = XCreateWindow(display, rootWin, 0, 0,
+ display_width, display_height, 0, CopyFromParent,
+ InputOutput, CopyFromParent, wamask, &xswa);
+ XLowerWindow(display, roachWin);
+ XMapWindow(display, roachWin);
+ XFlush(display);
+}
+
+#if !GRAB_SERVER
+
+int
+RoachErrors(dpy, err)
+Display *dpy;
+XErrorEvent *err;
+{
+ errorVal = err->error_code;
+
+ return 0;
+}
+
+#endif /* GRAB_SERVER */
+
+/*
+ Calculate Visible region of root window.
+*/
+int
+CalcRootVisible()
+{
+ Region covered;
+ Region visible;
+ Window *children;
+ int nChildren;
+ Window dummy;
+ XWindowAttributes wa;
+ int wx;
+ XRectangle rect;
+ int winX, winY;
+ unsigned int winHeight, winWidth;
+ unsigned int borderWidth;
+ unsigned int depth;
+
+ /*
+ If we don't grab the server, the XGetWindowAttribute or XGetGeometry
+ calls can abort us. On the other hand, the server grabs can make for
+ some annoying delays.
+ */
+#if GRAB_SERVER
+ XGrabServer(display);
+#else
+ XSetErrorHandler(RoachErrors);
+#endif
+
+ /*
+ Get children of root.
+ */
+ XQueryTree(display, rootWin, &dummy, &dummy, &children, &nChildren);
+
+ /*
+ For each mapped child, add the window rectangle to the covered
+ region.
+ */
+ covered = XCreateRegion();
+ for (wx=0; wx<nChildren; wx++) {
+ if (XEventsQueued(display, QueuedAlready)) return 1;
+ errorVal = 0;
+ XGetWindowAttributes(display, children[wx], &wa);
+ if (errorVal) continue;
+ if (wa.map_state == IsViewable) {
+ XGetGeometry(display, children[wx], &dummy, &winX, &winY,
+ &winWidth, &winHeight, &borderWidth, &depth);
+ if (errorVal) continue;
+ rect.x = winX;
+ rect.y = winY;
+ rect.width = winWidth + (borderWidth * 2);
+ rect.height = winHeight + (borderWidth * 2);
+ XUnionRectWithRegion(&rect, covered, covered);
+ }
+ }
+ XFree((char *)children);
+
+#if GRAB_SERVER
+ XUngrabServer(display);
+#else
+ XSetErrorHandler((ErrorHandler *)NULL);
+#endif
+
+ /*
+ Subtract the covered region from the root window region.
+ */
+ visible = XCreateRegion();
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = display_width;
+ rect.height = display_height;
+ XUnionRectWithRegion(&rect, visible, visible);
+ XSubtractRegion(visible, covered, visible);
+ XDestroyRegion(covered);
+
+ /*
+ Save visible region globally.
+ */
+ if (rootVisible)
+ XDestroyRegion(rootVisible);
+ rootVisible = visible;
+
+
+ /*
+ Mark all roaches visible.
+ */
+ for (wx=0; wx<curRoaches; wx++)
+ roaches[wx].hidden = 0;
+
+ return 0;
+}
+
+/*
+ Mark hidden roaches.
+*/
+int
+MarkHiddenRoaches()
+{
+ int rx;
+ Roach *r;
+ int nVisible;
+
+ nVisible = 0;
+ for (rx=0; rx<curRoaches; rx++) {
+ r = &roaches[rx];
+
+ if (!r->hidden) {
+ if (r->intX > 0 && XRectInRegion(rootVisible, r->intX, r->intY,
+ r->rp->width, r->rp->height) == RectangleOut) {
+ r->hidden = 1;
+ }
+ else {
+ nVisible++;
+ }
+ }
+ }
+
+ return nVisible;
+}
+
+/*
+ Allocate a color by name.
+*/
+Pixel
+AllocNamedColor(colorName, dfltPix)
+char *colorName;
+Pixel dfltPix;
+{
+ Pixel pix;
+ XColor scrncolor;
+ XColor exactcolor;
+
+ if (XAllocNamedColor(display, DefaultColormap(display, screen),
+ colorName, &scrncolor, &exactcolor)) {
+ pix = scrncolor.pixel;
+ }
+ else {
+ pix = dfltPix;
+ }
+
+ return pix;
+}
+
OpenPOWER on IntegriCloud