mirror of
https://github.com/vattam/BSDGames.git
synced 2025-12-20 19:04:49 +00:00
Initial revision
git-svn-id: file:///srv/svn/joey/bsdgames-trunk@5086 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
9
worms/Makefile.bsd
Normal file
9
worms/Makefile.bsd
Normal file
@@ -0,0 +1,9 @@
|
||||
# $NetBSD: Makefile,v 1.6 1998/02/18 22:37:32 jtc Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
|
||||
PROG= worms
|
||||
MAN= worms.6
|
||||
DPADD= ${LIBCURSES}
|
||||
LDADD= -lcurses
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
10
worms/Makefrag
Normal file
10
worms/Makefrag
Normal file
@@ -0,0 +1,10 @@
|
||||
# Makefrag - makefile fragment for worms
|
||||
|
||||
worms_DIRS := $(GAMESDIR) $(MAN6DIR)
|
||||
|
||||
worms_all: worms/worms worms/worms.6
|
||||
|
||||
worms_install: worms_all
|
||||
$(INSTALL_BINARY) worms/worms $(INSTALL_PREFIX)$(GAMESDIR)/worms
|
||||
$(HIDE_GAME) worms
|
||||
$(INSTALL_MANUAL) worms/worms.6
|
||||
63
worms/worms.6
Normal file
63
worms/worms.6
Normal file
@@ -0,0 +1,63 @@
|
||||
.\" $NetBSD: worms.6,v 1.8 1998/04/28 06:00:52 fair Exp $
|
||||
.\"
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)worms.6 8.1 (Berkeley) 5/31/93
|
||||
.\"
|
||||
.Dd May 31, 1993
|
||||
.Dt WORMS 6
|
||||
.Sh NAME
|
||||
.Nm worms
|
||||
.Nd animate worms on a display terminal
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl ft
|
||||
.Op Fl l Ar length
|
||||
.Op Fl n Ar number
|
||||
.Sh DESCRIPTION
|
||||
A
|
||||
.Ux
|
||||
version of the DEC-2136 program ``worms''.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Fl f
|
||||
Makes a ``field'' for the worm(s) to eat.
|
||||
.It Fl t
|
||||
Makes each worm leave a trail behind it.
|
||||
.It Fl l
|
||||
Specifies a length for each worm; the default is 16.
|
||||
.It Fl n
|
||||
Specifies the number of worms; the default is 3.
|
||||
.Sh BUGS
|
||||
The lower-right-hand character position will not be updated properly
|
||||
on a terminal that wraps at the right margin.
|
||||
465
worms/worms.c
Normal file
465
worms/worms.c
Normal file
@@ -0,0 +1,465 @@
|
||||
/* $NetBSD: worms.c,v 1.10 1998/09/13 15:27:31 hubertf Exp $ */
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__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
|
||||
__RCSID("$NetBSD: worms.c,v 1.10 1998/09/13 15:27:31 hubertf Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*
|
||||
* @@@ @@@ @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
|
||||
* @@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@
|
||||
* @@@ @@@ @@@@ @@@@ @@@@ @@@@ @@@ @@@@
|
||||
* @@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
|
||||
* @@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
|
||||
* @@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@
|
||||
* @@@@@@@@@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@
|
||||
* @@@@ @@@@ @@@@@@@@@@@@ @@@ @@@ @@@ @@@
|
||||
* @@ @@ @@@@@@@@@@ @@@ @@@ @@@ @@@
|
||||
*
|
||||
* Eric P. Scott
|
||||
* Caltech High Energy Physics
|
||||
* October, 1980
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static struct options {
|
||||
int nopts;
|
||||
int opts[3];
|
||||
}
|
||||
normal[8] = {
|
||||
{ 3, { 7, 0, 1 } },
|
||||
{ 3, { 0, 1, 2 } },
|
||||
{ 3, { 1, 2, 3 } },
|
||||
{ 3, { 2, 3, 4 } },
|
||||
{ 3, { 3, 4, 5 } },
|
||||
{ 3, { 4, 5, 6 } },
|
||||
{ 3, { 5, 6, 7 } },
|
||||
{ 3, { 6, 7, 0 } }
|
||||
}, upper[8] = {
|
||||
{ 1, { 1, 0, 0 } },
|
||||
{ 2, { 1, 2, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 2, { 4, 5, 0 } },
|
||||
{ 1, { 5, 0, 0 } },
|
||||
{ 2, { 1, 5, 0 } }
|
||||
},
|
||||
left[8] = {
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 2, { 2, 3, 0 } },
|
||||
{ 1, { 3, 0, 0 } },
|
||||
{ 2, { 3, 7, 0 } },
|
||||
{ 1, { 7, 0, 0 } },
|
||||
{ 2, { 7, 0, 0 } }
|
||||
},
|
||||
right[8] = {
|
||||
{ 1, { 7, 0, 0 } },
|
||||
{ 2, { 3, 7, 0 } },
|
||||
{ 1, { 3, 0, 0 } },
|
||||
{ 2, { 3, 4, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 2, { 6, 7, 0 } }
|
||||
},
|
||||
lower[8] = {
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 2, { 0, 1, 0 } },
|
||||
{ 1, { 1, 0, 0 } },
|
||||
{ 2, { 1, 5, 0 } },
|
||||
{ 1, { 5, 0, 0 } },
|
||||
{ 2, { 5, 6, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } }
|
||||
},
|
||||
upleft[8] = {
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 1, { 3, 0, 0 } },
|
||||
{ 2, { 1, 3, 0 } },
|
||||
{ 1, { 1, 0, 0 } }
|
||||
},
|
||||
upright[8] = {
|
||||
{ 2, { 3, 5, 0 } },
|
||||
{ 1, { 3, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 1, { 5, 0, 0 } }
|
||||
},
|
||||
lowleft[8] = {
|
||||
{ 3, { 7, 0, 1 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 1, { 1, 0, 0 } },
|
||||
{ 2, { 1, 7, 0 } },
|
||||
{ 1, { 7, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } }
|
||||
},
|
||||
lowright[8] = {
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 1, { 7, 0, 0 } },
|
||||
{ 2, { 5, 7, 0 } },
|
||||
{ 1, { 5, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } },
|
||||
{ 0, { 0, 0, 0 } }
|
||||
};
|
||||
|
||||
#define cursor(c, r) tputs(tgoto(CM, c, r), 1, fputchar)
|
||||
|
||||
char *tcp;
|
||||
static char flavor[] = {
|
||||
'O', '*', '#', '$', '%', '0', '@', '~'
|
||||
};
|
||||
static short xinc[] = {
|
||||
1, 1, 1, 0, -1, -1, -1, 0
|
||||
}, yinc[] = {
|
||||
-1, 0, 1, 1, 1, 0, -1, -1
|
||||
};
|
||||
static struct worm {
|
||||
int orientation, head;
|
||||
short *xpos, *ypos;
|
||||
} *worm;
|
||||
|
||||
void fputchar __P((int));
|
||||
int main __P((int, char **));
|
||||
void nomem __P((void)) __attribute__((__noreturn__));
|
||||
void onsig __P((int)) __attribute__((__noreturn__));
|
||||
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)));
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
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;
|
||||
struct termios ti;
|
||||
#ifdef TIOCGWINSZ
|
||||
struct winsize ws;
|
||||
#endif
|
||||
|
||||
/* Revoke setgid privileges */
|
||||
setregid(getgid(), getgid());
|
||||
|
||||
mp = NULL;
|
||||
length = 16;
|
||||
number = 3;
|
||||
trail = ' ';
|
||||
field = NULL;
|
||||
while ((ch = getopt(argc, argv, "fl:n:t")) != -1)
|
||||
switch(ch) {
|
||||
case 'f':
|
||||
field = "WORM";
|
||||
break;
|
||||
case 'l':
|
||||
if ((length = atoi(optarg)) < 2 || length > 1024) {
|
||||
(void)fprintf(stderr,
|
||||
"worms: invalid length (%d - %d).\n",
|
||||
2, 1024);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'n':
|
||||
if ((number = atoi(optarg)) < 1) {
|
||||
(void)fprintf(stderr,
|
||||
"worms: invalid number of worms.\n");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
trail = '.';
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
(void)fprintf(stderr,
|
||||
"usage: worms [-ft] [-l length] [-n number]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(term = getenv("TERM"))) {
|
||||
(void)fprintf(stderr, "worms: no TERM environment variable.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!(worm = malloc((size_t)number *
|
||||
sizeof(struct worm))) || !(mp = malloc((size_t)1024)))
|
||||
nomem();
|
||||
if (tgetent(mp, term) <= 0) {
|
||||
(void)fprintf(stderr, "worms: %s: unknown terminal type.\n",
|
||||
term);
|
||||
exit(1);
|
||||
}
|
||||
tcp = tcb;
|
||||
if (!(CM = tgetstr("cm", &tcp))) {
|
||||
(void)fprintf(stderr,
|
||||
"worms: terminal incapable of cursor motion.\n");
|
||||
exit(1);
|
||||
}
|
||||
AL = tgetstr("al", &tcp);
|
||||
BC = tgetflag("bs") ? "\b" : tgetstr("bc", &tcp);
|
||||
EI = tgetstr("ei", &tcp);
|
||||
HO = tgetstr("ho", &tcp);
|
||||
IC = tgetstr("ic", &tcp);
|
||||
IM = tgetstr("im", &tcp);
|
||||
IN = tgetflag("in");
|
||||
IP = tgetstr("ip", &tcp);
|
||||
SR = tgetstr("sr", &tcp);
|
||||
UP = tgetstr("up", &tcp);
|
||||
#ifdef TIOCGWINSZ
|
||||
if (ioctl(fileno(stdout), TIOCGWINSZ, &ws) != -1 &&
|
||||
ws.ws_col && ws.ws_row) {
|
||||
CO = ws.ws_col;
|
||||
LI = ws.ws_row;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if ((CO = tgetnum("co")) <= 0)
|
||||
CO = 80;
|
||||
if ((LI = tgetnum("li")) <= 0)
|
||||
LI = 24;
|
||||
}
|
||||
last = CO - 1;
|
||||
bottom = LI - 1;
|
||||
tcgetattr(fileno(stdout), &ti);
|
||||
Wrap = tgetflag("am");
|
||||
if (!(ip = malloc((size_t)(LI * CO * sizeof(short)))))
|
||||
nomem();
|
||||
if (!(ref = malloc((size_t)(LI * sizeof(short *)))))
|
||||
nomem();
|
||||
for (n = 0; n < LI; ++n) {
|
||||
ref[n] = ip;
|
||||
ip += CO;
|
||||
}
|
||||
for (ip = ref[0], n = LI * CO; --n >= 0;)
|
||||
*ip++ = 0;
|
||||
if (Wrap)
|
||||
ref[bottom][last] = 1;
|
||||
for (n = number, w = &worm[0]; --n >= 0; w++) {
|
||||
w->orientation = w->head = 0;
|
||||
if (!(ip = malloc((size_t)(length * sizeof(short)))))
|
||||
nomem();
|
||||
w->xpos = ip;
|
||||
for (x = length; --x >= 0;)
|
||||
*ip++ = -1;
|
||||
if (!(ip = malloc((size_t)(length * sizeof(short)))))
|
||||
nomem();
|
||||
w->ypos = ip;
|
||||
for (y = length; --y >= 0;)
|
||||
*ip++ = -1;
|
||||
}
|
||||
|
||||
(void)signal(SIGHUP, onsig);
|
||||
(void)signal(SIGINT, onsig);
|
||||
(void)signal(SIGQUIT, onsig);
|
||||
(void)signal(SIGSTOP, onsig);
|
||||
(void)signal(SIGTSTP, onsig);
|
||||
(void)signal(SIGTERM, onsig);
|
||||
|
||||
tputs(tgetstr("ti", &tcp), 1, fputchar);
|
||||
tputs(tgetstr("cl", &tcp), 1, fputchar);
|
||||
if (field) {
|
||||
char *p = field;
|
||||
|
||||
for (y = bottom; --y >= 0;) {
|
||||
for (x = CO; --x >= 0;) {
|
||||
fputchar(*p++);
|
||||
if (!*p)
|
||||
p = field;
|
||||
}
|
||||
if (!Wrap)
|
||||
fputchar('\n');
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
if (Wrap) {
|
||||
if (IM && !IN) {
|
||||
for (x = last; --x > 0;) {
|
||||
fputchar(*p++);
|
||||
if (!*p)
|
||||
p = field;
|
||||
}
|
||||
y = *p++;
|
||||
if (!*p)
|
||||
p = field;
|
||||
fputchar(*p);
|
||||
if (BC)
|
||||
tputs(BC, 1, fputchar);
|
||||
else
|
||||
cursor(last - 1, bottom);
|
||||
tputs(IM, 1, fputchar);
|
||||
if (IC)
|
||||
tputs(IC, 1, fputchar);
|
||||
fputchar(y);
|
||||
if (IP)
|
||||
tputs(IP, 1, fputchar);
|
||||
tputs(EI, 1, fputchar);
|
||||
}
|
||||
else if (SR || AL) {
|
||||
if (HO)
|
||||
tputs(HO, 1, fputchar);
|
||||
else
|
||||
cursor(0, 0);
|
||||
if (SR)
|
||||
tputs(SR, 1, fputchar);
|
||||
else
|
||||
tputs(AL, LI, fputchar);
|
||||
for (x = CO; --x >= 0;) {
|
||||
fputchar(*p++);
|
||||
if (!*p)
|
||||
p = field;
|
||||
}
|
||||
}
|
||||
else for (x = last; --x >= 0;) {
|
||||
fputchar(*p++);
|
||||
if (!*p)
|
||||
p = field;
|
||||
}
|
||||
}
|
||||
else for (x = CO; --x >= 0;) {
|
||||
fputchar(*p++);
|
||||
if (!*p)
|
||||
p = field;
|
||||
}
|
||||
}
|
||||
for (;;) {
|
||||
(void)fflush(stdout);
|
||||
for (n = 0, w = &worm[0]; n < number; n++, w++) {
|
||||
if ((x = w->xpos[h = w->head]) < 0) {
|
||||
cursor(x = w->xpos[h] = 0,
|
||||
y = w->ypos[h] = bottom);
|
||||
fputchar(flavor[n % sizeof(flavor)]);
|
||||
ref[y][x]++;
|
||||
}
|
||||
else
|
||||
y = w->ypos[h];
|
||||
if (++h == length)
|
||||
h = 0;
|
||||
if (w->xpos[w->head = h] >= 0) {
|
||||
int x1, y1;
|
||||
|
||||
x1 = w->xpos[h];
|
||||
y1 = w->ypos[h];
|
||||
if (--ref[y1][x1] == 0) {
|
||||
cursor(x1, y1);
|
||||
if (trail)
|
||||
fputchar(trail);
|
||||
}
|
||||
}
|
||||
op = &(!x ? (!y ? upleft : (y == bottom ? lowleft : left)) : (x == last ? (!y ? upright : (y == bottom ? lowright : right)) : (!y ? upper : (y == bottom ? lower : normal))))[w->orientation];
|
||||
switch (op->nopts) {
|
||||
case 0:
|
||||
(void)fflush(stdout);
|
||||
abort();
|
||||
return(1);
|
||||
case 1:
|
||||
w->orientation = op->opts[0];
|
||||
break;
|
||||
default:
|
||||
w->orientation =
|
||||
op->opts[(int)random() % op->nopts];
|
||||
}
|
||||
cursor(x += xinc[w->orientation],
|
||||
y += yinc[w->orientation]);
|
||||
if (!Wrap || x != last || y != bottom)
|
||||
fputchar(flavor[n % sizeof(flavor)]);
|
||||
ref[w->ypos[h] = y][w->xpos[h] = x]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
onsig(signo)
|
||||
int signo __attribute__((unused));
|
||||
{
|
||||
tputs(tgetstr("cl", &tcp), 1, fputchar);
|
||||
tputs(tgetstr("te", &tcp), 1, fputchar);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
fputchar(c)
|
||||
int c;
|
||||
{
|
||||
(void)putchar(c);
|
||||
}
|
||||
|
||||
void
|
||||
nomem()
|
||||
{
|
||||
(void)fprintf(stderr, "worms: not enough memory.\n");
|
||||
exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user