summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlukem <lukem@NetBSD.org>1997-10-12 02:12:45 +0000
committerlukem <lukem@NetBSD.org>1997-10-12 02:12:45 +0000
commit005769031bfe3c881881d8f65b9703ff7a349c4b (patch)
tree331f9770273c34be1fc828dc6bb2fddae4523fba
parente0fada49e2f6fe9e3304c580dbc4fa389ae0f70d (diff)
downloadbsdgames-darwin-005769031bfe3c881881d8f65b9703ff7a349c4b.tar.gz
bsdgames-darwin-005769031bfe3c881881d8f65b9703ff7a349c4b.tar.zst
bsdgames-darwin-005769031bfe3c881881d8f65b9703ff7a349c4b.zip
WARNSify
-rw-r--r--worm/worm.66
-rw-r--r--worm/worm.c64
-rw-r--r--worms/worms.64
-rw-r--r--worms/worms.c39
4 files changed, 71 insertions, 42 deletions
diff --git a/worm/worm.6 b/worm/worm.6
index a4ba9bdc..4a117aaa 100644
--- a/worm/worm.6
+++ b/worm/worm.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: worm.6,v 1.4 1995/04/22 07:56:21 cgd Exp $
+.\" $NetBSD: worm.6,v 1.5 1997/10/12 02:12:45 lukem Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -40,11 +40,11 @@
.Nm worm
.Nd Play the growing worm game
.Sh SYNOPSIS
-.Nm worm
+.Nm
.Op Ar size
.Sh DESCRIPTION
In
-.Nm worm,
+.Nm "" ,
you are a little worm, your body is the "o"'s on the screen
and your head is the "@". You move with the hjkl keys (as in the game
snake). If you don't press any keys, you continue in the direction you
diff --git a/worm/worm.c b/worm/worm.c
index e4488bc0..0a7b96ef 100644
--- a/worm/worm.c
+++ b/worm/worm.c
@@ -1,4 +1,4 @@
-/* $NetBSD: worm.c,v 1.7 1995/04/29 01:12:41 mycroft Exp $ */
+/* $NetBSD: worm.c,v 1.8 1997/10/12 02:12:48 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[] = "@(#)worm.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: worm.c,v 1.7 1995/04/29 01:12:41 mycroft Exp $";
+__RCSID("$NetBSD: worm.c,v 1.8 1997/10/12 02:12:48 lukem Exp $");
#endif
#endif /* not lint */
@@ -57,6 +57,7 @@ static char rcsid[] = "$NetBSD: worm.c,v 1.7 1995/04/29 01:12:41 mycroft Exp $";
#include <signal.h>
#include <stdlib.h>
#include <termios.h>
+#include <unistd.h>
#define newlink() (struct body *) malloc(sizeof (struct body));
#define HEAD '@'
@@ -81,8 +82,20 @@ int start_len = LENGTH;
char lastch;
char outbuf[BUFSIZ];
-void leave(), wake(), suspend();
+void crash __P((void));
+void display __P((struct body *, char));
+int main __P((int, char **));
+void leave __P((int));
+void life __P((void));
+void newpos __P((struct body *));
+void process __P((char));
+void prize __P((void));
+int rnd __P((int));
+void setup __P((void));
+void suspend __P((int));
+void wake __P((int));
+int
main(argc, argv)
int argc;
char **argv;
@@ -132,11 +145,13 @@ main(argc, argv)
}
}
+void
life()
{
- register struct body *bp, *np;
- register int i;
+ struct body *bp, *np;
+ int i;
+ np = NULL;
head = newlink();
head->x = start_len+2;
head->y = 12;
@@ -154,36 +169,42 @@ life()
tail->prev = NULL;
}
+void
display(pos, chr)
-struct body *pos;
-char chr;
+ struct body *pos;
+ char chr;
{
wmove(tv, pos->y, pos->x);
waddch(tv, chr);
}
void
-leave()
+leave(dummy)
+ int dummy;
{
endwin();
exit(0);
}
void
-wake()
+wake(dummy)
+ int dummy;
{
signal(SIGALRM, wake);
fflush(stdout);
process(lastch);
}
+int
rnd(range)
+ int range;
{
return abs((rand()>>5)+(rand()>>5)) % range;
}
+void
newpos(bp)
-struct body * bp;
+ struct body * bp;
{
do {
bp->y = rnd(LINES-3)+ 2;
@@ -192,6 +213,7 @@ struct body * bp;
} while(winch(tv) != ' ');
}
+void
prize()
{
int value;
@@ -202,10 +224,11 @@ prize()
wrefresh(tv);
}
+void
process(ch)
-char ch;
+ char ch;
{
- register int x,y;
+ int x,y;
struct body *nh;
alarm(0);
@@ -222,7 +245,7 @@ char ch;
case 'K': y--; running = RUNLEN/2; ch = tolower(ch); break;
case 'L': x++; running = RUNLEN; ch = tolower(ch); break;
case '\f': setup(); return;
- case CNTRL('Z'): suspend(); return;
+ case CNTRL('Z'): suspend(0); return;
case CNTRL('C'): crash(); return;
case CNTRL('D'): crash(); return;
default: if (! running) alarm(1);
@@ -265,6 +288,7 @@ char ch;
alarm(1);
}
+void
crash()
{
sleep(2);
@@ -273,14 +297,13 @@ crash()
refresh();
printf("Well, you ran into something and the game is over.\n");
printf("Your final score was %d\n", score);
- leave();
+ leave(0);
}
void
-suspend()
+suspend(dummy)
+ int dummy;
{
- char *sh;
-
move(LINES-1, 0);
refresh();
endwin();
@@ -292,6 +315,7 @@ suspend()
setup();
}
+void
setup()
{
clear();
diff --git a/worms/worms.6 b/worms/worms.6
index 4a757bed..ff74123c 100644
--- a/worms/worms.6
+++ b/worms/worms.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: worms.6,v 1.6 1995/04/22 08:07:59 cgd Exp $
+.\" $NetBSD: worms.6,v 1.7 1997/10/12 02:18:22 lukem Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -39,7 +39,7 @@
.Nm worms
.Nd animate worms on a display terminal
.Sh SYNOPSIS
-.Nm worms
+.Nm
.Op Fl ft
.Op Fl l Ar length
.Op Fl n Ar number
diff --git a/worms/worms.c b/worms/worms.c
index dbf9511a..b0731afd 100644
--- a/worms/worms.c
+++ b/worms/worms.c
@@ -1,4 +1,4 @@
-/* $NetBSD: worms.c,v 1.8 1995/04/22 08:09:22 cgd Exp $ */
+/* $NetBSD: worms.c,v 1.9 1997/10/12 02:18:25 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[] = "@(#)worms.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: worms.c,v 1.8 1995/04/22 08:09:22 cgd Exp $";
+__RCSID("$NetBSD: worms.c,v 1.9 1997/10/12 02:18:25 lukem Exp $");
#endif
#endif /* not lint */
@@ -184,7 +184,12 @@ static struct worm {
} *worm;
void fputchar __P((int));
+int main __P((int, char **));
+void nomem __P((void));
void onsig __P((int));
+int tgetent __P((char *, char *));
+int tgetflag __P((char *));
+int tgetnum __P((char *));
char *tgetstr __P((char *, char **));
char *tgoto __P((char *, int, int));
int tputs __P((char *, int, void (*)(int)));
@@ -194,28 +199,27 @@ main(argc, argv)
int argc;
char *argv[];
{
- extern int optind;
- extern char *optarg, *UP;
- register int x, y, h, n;
- register struct worm *w;
- register struct options *op;
- register short *ip;
- register char *term;
+ extern char *UP;
+ int x, y, h, n;
+ struct worm *w;
+ struct options *op;
+ short *ip;
+ char *term;
int CO, IN, LI, last, bottom, ch, length, number, trail, Wrap;
short **ref;
char *AL, *BC, *CM, *EI, *HO, *IC, *IM, *IP, *SR;
char *field, tcb[100], *mp;
- long random();
struct termios ti;
#ifdef TIOCGWINSZ
struct winsize ws;
#endif
+ mp = NULL;
length = 16;
number = 3;
trail = ' ';
field = NULL;
- while ((ch = getopt(argc, argv, "fl:n:t")) != EOF)
+ while ((ch = getopt(argc, argv, "fl:n:t")) != -1)
switch(ch) {
case 'f':
field = "WORM";
@@ -326,7 +330,7 @@ main(argc, argv)
tputs(tgetstr("ti", &tcp), 1, fputchar);
tputs(tgetstr("cl", &tcp), 1, fputchar);
if (field) {
- register char *p = field;
+ char *p = field;
for (y = bottom; --y >= 0;) {
for (x = CO; --x >= 0;) {
@@ -402,7 +406,7 @@ main(argc, argv)
if (++h == length)
h = 0;
if (w->xpos[w->head = h] >= 0) {
- register int x1, y1;
+ int x1, y1;
x1 = w->xpos[h];
y1 = w->ypos[h];
@@ -417,7 +421,7 @@ main(argc, argv)
case 0:
(void)fflush(stdout);
abort();
- return;
+ return(1);
case 1:
w->orientation = op->opts[0];
break;
@@ -450,6 +454,7 @@ fputchar(c)
(void)putchar(c);
}
+void
nomem()
{
(void)fprintf(stderr, "worms: not enough memory.\n");