summaryrefslogtreecommitdiffstats
path: root/cribbage
diff options
context:
space:
mode:
Diffstat (limited to 'cribbage')
-rw-r--r--cribbage/cards.c19
-rw-r--r--cribbage/crib.c36
-rw-r--r--cribbage/cribbage.610
-rw-r--r--cribbage/extern.c5
-rw-r--r--cribbage/instr.c5
-rw-r--r--cribbage/io.c35
-rw-r--r--cribbage/score.c25
-rw-r--r--cribbage/support.c31
8 files changed, 90 insertions, 76 deletions
diff --git a/cribbage/cards.c b/cribbage/cards.c
index a81bdf65..e6c52628 100644
--- a/cribbage/cards.c
+++ b/cribbage/cards.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cards.c,v 1.3 1995/03/21 15:08:41 cgd Exp $ */
+/* $NetBSD: cards.c,v 1.4 1997/10/10 12:32:22 lukem Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -33,8 +33,13 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
+#if 0
static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: cards.c,v 1.4 1997/10/10 12:32:22 lukem Exp $");
+#endif
#endif /* not lint */
#include <curses.h>
@@ -53,7 +58,7 @@ void
makedeck(d)
CARD d[];
{
- register int i, j, k;
+ int i, j, k;
i = time(NULL);
i = ((i & 0xff) << 8) | ((i >> 8) & 0xff) | 1;
@@ -74,7 +79,7 @@ void
shuffle(d)
CARD d[];
{
- register int j, k;
+ int j, k;
CARD c;
for (j = CARDS; j > 0; --j) {
@@ -103,7 +108,7 @@ isone(a, b, n)
CARD a, b[];
int n;
{
- register int i;
+ int i;
for (i = 0; i < n; i++)
if (eq(a, b[i]))
@@ -119,7 +124,7 @@ cremove(a, d, n)
CARD a, d[];
int n;
{
- register int i, j;
+ int i, j;
for (i = j = 0; i < n; i++)
if (!eq(a, d[i]))
@@ -134,10 +139,10 @@ cremove(a, d, n)
*/
void
sorthand(h, n)
- register CARD h[];
+ CARD h[];
int n;
{
- register CARD *cp, *endp;
+ CARD *cp, *endp;
CARD c;
for (endp = &h[n]; h < endp - 1; h++)
diff --git a/cribbage/crib.c b/cribbage/crib.c
index cf59d5aa..696c86b2 100644
--- a/cribbage/crib.c
+++ b/cribbage/crib.c
@@ -1,4 +1,4 @@
-/* $NetBSD: crib.c,v 1.7 1997/07/10 06:47:29 mikel Exp $ */
+/* $NetBSD: crib.c,v 1.8 1997/10/10 12:32:24 lukem Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -33,17 +33,17 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1980, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
+__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
+ The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: crib.c,v 1.7 1997/07/10 06:47:29 mikel Exp $";
+__RCSID("$NetBSD: crib.c,v 1.8 1997/10/10 12:32:24 lukem Exp $");
#endif
#endif /* not lint */
@@ -58,6 +58,8 @@ static char rcsid[] = "$NetBSD: crib.c,v 1.7 1997/07/10 06:47:29 mikel Exp $";
#include "cribcur.h"
#include "pathnames.h"
+int main __P((int, char *[]));
+
int
main(argc, argv)
int argc;
@@ -67,7 +69,7 @@ main(argc, argv)
FILE *f;
int ch;
- while ((ch = getopt(argc, argv, "eqr")) != EOF)
+ while ((ch = getopt(argc, argv, "eqr")) != -1)
switch (ch) {
case 'e':
explain = TRUE;
@@ -193,10 +195,11 @@ gamescore()
void
game()
{
- register int i, j;
+ int i, j;
BOOLEAN flag;
BOOLEAN compcrib;
+ compcrib = FALSE;
makedeck(deck);
shuffle(deck);
if (gamecount == 0) {
@@ -287,7 +290,7 @@ int
playhand(mycrib)
BOOLEAN mycrib;
{
- register int deckpos;
+ int deckpos;
werase(Compwin);
wrefresh(Compwin);
@@ -319,7 +322,7 @@ int
deal(mycrib)
BOOLEAN mycrib;
{
- register int i, j;
+ int i, j;
for (i = j = 0; i < FULLHAND; i++) {
if (mycrib) {
@@ -342,7 +345,7 @@ void
discard(mycrib)
BOOLEAN mycrib;
{
- register char *prompt;
+ char *prompt;
CARD crd;
prcrib(mycrib, TRUE);
@@ -373,7 +376,7 @@ cut(mycrib, pos)
BOOLEAN mycrib;
int pos;
{
- register int i;
+ int i;
BOOLEAN win;
win = FALSE;
@@ -416,7 +419,7 @@ void
prcrib(mycrib, blank)
BOOLEAN mycrib, blank;
{
- register int y, cardx;
+ int y, cardx;
if (mycrib)
cardx = CRIB_X;
@@ -448,12 +451,13 @@ peg(mycrib)
BOOLEAN mycrib;
{
static CARD ch[CINHAND], ph[CINHAND];
- register int i, j, k;
- register int l;
- register int cnum, pnum, sum;
- register BOOLEAN myturn, mego, ugo, last, played;
+ int i, j, k;
+ int l;
+ int cnum, pnum, sum;
+ BOOLEAN myturn, mego, ugo, last, played;
CARD crd;
+ played = FALSE;
cnum = pnum = CINHAND;
for (i = 0; i < CINHAND; i++) { /* make copies of hands */
ch[i] = chand[i];
diff --git a/cribbage/cribbage.6 b/cribbage/cribbage.6
index f7be11c1..e40e6c04 100644
--- a/cribbage/cribbage.6
+++ b/cribbage/cribbage.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: cribbage.6,v 1.4 1995/03/21 15:08:45 cgd Exp $
+.\" $NetBSD: cribbage.6,v 1.5 1997/10/10 12:32:26 lukem Exp $
.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -40,10 +40,10 @@
.Nm cribbage
.Nd the card game cribbage
.Sh SYNOPSIS
-.Nm /usr/games/cribbage
+.Nm
.Op Fl eqr
.Sh DESCRIPTION
-.Nm Cribbage
+.Nm
plays the card game cribbage, with the program playing one hand
and the user the other. The program will initially ask the user if
the rules of the game are needed \- if so, it will print out
@@ -52,7 +52,7 @@ the appropriate section from
with
.Xr more 1 .
.Pp
-.Nm Cribbage
+.Nm
options include:
.Bl -tag -width indent
.It Fl e
@@ -67,7 +67,7 @@ Instead of asking the player to cut the deck, the program will randomly
cut the deck.
.El
.Pp
-.Nm Cribbage
+.Nm
first asks the player whether he wishes to play a short game (
.Dq once around ,
to 61) or a long game (
diff --git a/cribbage/extern.c b/cribbage/extern.c
index 1b7c4125..4594e906 100644
--- a/cribbage/extern.c
+++ b/cribbage/extern.c
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.c,v 1.3 1995/03/21 15:08:50 cgd Exp $ */
+/* $NetBSD: extern.c,v 1.4 1997/10/10 12:32:29 lukem Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: extern.c,v 1.3 1995/03/21 15:08:50 cgd Exp $";
+__RCSID("$NetBSD: extern.c,v 1.4 1997/10/10 12:32:29 lukem Exp $");
#endif
#endif /* not lint */
diff --git a/cribbage/instr.c b/cribbage/instr.c
index 936302e0..e4409bc2 100644
--- a/cribbage/instr.c
+++ b/cribbage/instr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: instr.c,v 1.5 1997/07/10 06:47:30 mikel Exp $ */
+/* $NetBSD: instr.c,v 1.6 1997/10/10 12:32:30 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)instr.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: instr.c,v 1.5 1997/07/10 06:47:30 mikel Exp $";
+__RCSID("$NetBSD: instr.c,v 1.6 1997/10/10 12:32:30 lukem Exp $");
#endif
#endif /* not lint */
diff --git a/cribbage/io.c b/cribbage/io.c
index 452a3ecf..f73fc097 100644
--- a/cribbage/io.c
+++ b/cribbage/io.c
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.9 1997/07/09 06:25:47 phil Exp $ */
+/* $NetBSD: io.c,v 1.10 1997/10/10 12:32:32 lukem Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: io.c,v 1.9 1997/07/09 06:25:47 phil Exp $";
+__RCSID("$NetBSD: io.c,v 1.10 1997/10/10 12:32:32 lukem Exp $");
#endif
#endif /* not lint */
@@ -173,7 +174,7 @@ prhand(h, n, win, blank)
WINDOW *win;
BOOLEAN blank;
{
- register int i;
+ int i;
werase(win);
for (i = 0; i < n; i++)
@@ -192,7 +193,7 @@ infrom(hand, n, prompt)
int n;
char *prompt;
{
- register int i, j;
+ int i, j;
CARD crd;
if (n < 1) {
@@ -246,7 +247,7 @@ int
incard(crd)
CARD *crd;
{
- register int i;
+ int i;
int rnk, sut;
char *line, *p, *p1;
BOOLEAN retval;
@@ -330,7 +331,7 @@ gotit:
int
getuchar()
{
- register int c;
+ int c;
c = readchar();
if (islower(c))
@@ -349,8 +350,8 @@ number(lo, hi, prompt)
int lo, hi;
char *prompt;
{
- register char *p;
- register int sum;
+ char *p;
+ int sum;
for (sum = 0;;) {
msg(prompt);
@@ -447,8 +448,8 @@ void
endmsg()
{
static int lastline = 0;
- register int len;
- register char *mp, *omp;
+ int len;
+ char *mp, *omp;
/* All messages should start with uppercase */
mvaddch(lastline + Y_MSG_START, SCORE_X, ' ');
@@ -516,9 +517,9 @@ do_wait()
*/
void
wait_for(ch)
- register int ch;
+ int ch;
{
- register char c;
+ char c;
if (ch == '\n')
while ((c = readchar()) != '\n')
@@ -535,7 +536,7 @@ wait_for(ch)
int
readchar()
{
- register int cnt;
+ int cnt;
char c;
over:
@@ -563,9 +564,9 @@ over:
char *
getline()
{
- register char *sp;
- register int c, oy, ox;
- register WINDOW *oscr;
+ char *sp;
+ int c, oy, ox;
+ WINDOW *oscr;
oscr = stdscr;
stdscr = Msgwin;
@@ -578,7 +579,7 @@ getline()
else
if (c == erasechar()) { /* process erase character */
if (sp > linebuf) {
- register int i;
+ int i;
sp--;
for (i = strlen(unctrl(*sp)); i; i--)
diff --git a/cribbage/score.c b/cribbage/score.c
index ac8c210d..d0ae050d 100644
--- a/cribbage/score.c
+++ b/cribbage/score.c
@@ -1,4 +1,4 @@
-/* $NetBSD: score.c,v 1.4 1997/05/17 19:26:19 pk Exp $ */
+/* $NetBSD: score.c,v 1.5 1997/10/10 12:32:34 lukem Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: score.c,v 1.4 1997/05/17 19:26:19 pk Exp $";
+__RCSID("$NetBSD: score.c,v 1.5 1997/10/10 12:32:34 lukem Exp $");
#endif
#endif /* not lint */
@@ -109,15 +110,15 @@ static int pairpoints, runpoints; /* Globals from pairuns. */
*/
int
scorehand(hand, starter, n, crb, do_explain)
- register CARD hand[];
+ CARD hand[];
CARD starter;
int n;
BOOLEAN crb; /* true if scoring crib */
BOOLEAN do_explain; /* true if must explain this hand */
{
- register int i, k;
- register int score;
- register BOOLEAN flag;
+ int i, k;
+ int score;
+ BOOLEAN flag;
CARD h[(CINHAND + 1)];
char buf[32];
@@ -182,12 +183,12 @@ scorehand(hand, starter, n, crb, do_explain)
*/
int
fifteens(hand, n)
- register CARD hand[];
+ CARD hand[];
int n;
{
- register int *sp, *np;
- register int i;
- register CARD *endp;
+ int *sp, *np;
+ int i;
+ CARD *endp;
static int sums[15], nsums[15];
np = nsums;
@@ -228,7 +229,7 @@ pairuns(h, n)
CARD h[];
int n;
{
- register int i;
+ int i;
int runlength, runmult, lastmult, curmult;
int mult1, mult2, pair1, pair2;
BOOLEAN run;
@@ -298,7 +299,7 @@ pegscore(crd, tbl, n, sum)
int n, sum;
{
BOOLEAN got[RANKS];
- register int i, j, scr;
+ int i, j, scr;
int k, lo, hi;
sum += VAL(crd.rank);
diff --git a/cribbage/support.c b/cribbage/support.c
index a2064a21..96ea67ad 100644
--- a/cribbage/support.c
+++ b/cribbage/support.c
@@ -1,4 +1,4 @@
-/* $NetBSD: support.c,v 1.3 1995/03/21 15:08:59 cgd Exp $ */
+/* $NetBSD: support.c,v 1.4 1997/10/10 12:32:36 lukem Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: support.c,v 1.3 1995/03/21 15:08:59 cgd Exp $";
+__RCSID("$NetBSD: support.c,v 1.4 1997/10/10 12:32:36 lukem Exp $");
#endif
#endif /* not lint */
@@ -62,7 +63,7 @@ cchose(h, n, s)
CARD h[];
int n, s;
{
- register int i, j, l;
+ int i, j, l;
if (n <= 1)
return (0);
@@ -132,8 +133,8 @@ plyrhand(hand, s)
char *s;
{
static char prompt[BUFSIZ];
- register int i, j;
- register BOOLEAN win;
+ int i, j;
+ BOOLEAN win;
prhand(hand, CINHAND, Playwin, FALSE);
(void) sprintf(prompt, "Your %s scores ", s);
@@ -167,7 +168,7 @@ comphand(h, s)
CARD h[];
char *s;
{
- register int j;
+ int j;
j = scorehand(h, turnover, CINHAND, strcmp(s, "crib") == 0, FALSE);
prhand(h, CINHAND, Compwin, FALSE);
@@ -190,8 +191,8 @@ chkscr(scr, inc)
myturn = (scr == &cscore);
if (inc != 0) {
- prpeg(Lastscore[myturn], '.', myturn);
- Lastscore[myturn] = *scr;
+ prpeg(Lastscore[(int)myturn], '.', myturn);
+ Lastscore[(int)myturn] = *scr;
*scr += inc;
prpeg(*scr, PEG, myturn);
refresh();
@@ -206,11 +207,11 @@ chkscr(scr, inc)
*/
void
prpeg(score, peg, myturn)
- register int score;
+ int score;
int peg;
BOOLEAN myturn;
{
- register int y, x;
+ int y, x;
if (!myturn)
y = SCORE_Y + 2;
@@ -248,7 +249,7 @@ cdiscard(mycrib)
BOOLEAN mycrib;
{
CARD d[CARDS], h[FULLHAND], cb[2];
- register int i, j, k;
+ int i, j, k;
int nc, ns;
long sums[15];
static int undo1[15] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4};
@@ -301,7 +302,7 @@ anymove(hand, n, sum)
CARD hand[];
int n, sum;
{
- register int i, j;
+ int i, j;
if (n < 1)
return (FALSE);
@@ -322,7 +323,7 @@ anysumto(hand, n, s, t)
CARD hand[];
int n, s, t;
{
- register int i;
+ int i;
for (i = 0; i < n; i++) {
if (s + VAL(hand[i].rank) == t)
@@ -339,7 +340,7 @@ numofval(h, n, v)
CARD h[];
int n, v;
{
- register int i, j;
+ int i, j;
j = 0;
for (i = 0; i < n; i++) {
@@ -357,7 +358,7 @@ makeknown(h, n)
CARD h[];
int n;
{
- register int i;
+ int i;
for (i = 0; i < n; i++)
known[knownum++] = h[i];