copy in from cvs; cvs2svn fucked up big time

git-svn-id: file:///srv/svn/joey/trunk/src/packages/bsdgames@9775 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
joey
2003-12-19 19:12:08 +00:00
parent 351c8ca204
commit 51eabc017b
310 changed files with 7852 additions and 5005 deletions

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for tetris
#
# Copyright (c) 1997, 1998 Joseph Samuel Myers.
# 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. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
tetris_CLEANFILES := tetris-bsd.6
tetris_DIRS := $(GAMESDIR) $(MAN6DIR)

View File

@@ -1,4 +1,4 @@
/* $NetBSD: input.c,v 1.3 1996/02/06 22:47:33 jtc Exp $ */
/* $NetBSD: input.c,v 1.8 2002/12/29 15:12:17 kristerw Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -44,6 +44,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/poll.h>
#include <errno.h>
#include <unistd.h>
@@ -65,44 +66,41 @@
}
/*
* Do a `read wait': select for reading from stdin, with timeout *tvp.
* Do a `read wait': poll for reading from stdin, with timeout *tvp.
* On return, modify *tvp to reflect the amount of time spent waiting.
* It will be positive only if input appeared before the time ran out;
* otherwise it will be zero or perhaps negative.
*
* If tvp is nil, wait forever, but return if select is interrupted.
* If tvp is nil, wait forever, but return if poll is interrupted.
*
* Return 0 => no input, 1 => can read() from stdin
*/
int
rwait(tvp)
register struct timeval *tvp;
struct timeval *tvp;
{
int i;
struct timeval starttv, endtv, *s;
struct pollfd set[1];
struct timeval starttv, endtv;
int timeout;
#define NILTZ ((struct timezone *)0)
/*
* Someday, select() will do this for us.
* Just in case that day is now, and no one has
* changed this, we use a temporary.
*/
if (tvp) {
(void) gettimeofday(&starttv, NILTZ);
endtv = *tvp;
s = &endtv;
timeout = tvp->tv_sec * 1000 + tvp->tv_usec / 1000;
} else
s = 0;
timeout = INFTIM;
again:
i = 1;
switch (select(1, (fd_set *)&i, (fd_set *)0, (fd_set *)0, s)) {
set[0].fd = STDIN_FILENO;
set[0].events = POLLIN;
switch (poll(set, 1, timeout)) {
case -1:
if (tvp == 0)
return (-1);
if (errno == EINTR)
goto again;
stop("select failed, help");
stop("poll failed, help");
/* NOTREACHED */
case 0: /* timed out */
@@ -120,7 +118,7 @@ again:
}
/*
* `sleep' for the current turn time (using select).
* `sleep' for the current turn time.
* Eat any input that might be available.
*/
void
@@ -136,20 +134,6 @@ tsleep()
break;
}
/*
* Eat up any input (used at end of game).
*/
void
eat_input()
{
struct timeval tv;
char c;
do {
tv.tv_sec = tv.tv_usec = 0;
} while (rwait(&tv) && read(0, &c, 1) == 1);
}
/*
* getchar with timeout.
*/

View File

@@ -1,4 +1,4 @@
/* $NetBSD: input.h,v 1.2 1995/04/22 07:42:36 cgd Exp $ */
/* $NetBSD: input.h,v 1.3 1999/01/03 02:00:17 hubertf Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -38,7 +38,6 @@
* @(#)input.h 8.1 (Berkeley) 5/31/93
*/
void eat_input __P((void));
int rwait __P((struct timeval *));
int tgetchar __P((void));
void tsleep __P((void));

View File

@@ -1,4 +1,4 @@
/* $NetBSD: screen.h,v 1.3 1997/10/14 01:14:34 lukem Exp $ */
/* $NetBSD: screen.h,v 1.6 2000/05/22 12:42:48 blymn Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,8 +41,8 @@
/*
* Capabilities from TERMCAP (used in the score code).
*/
char *SEstr; /* end standout mode */
char *SOstr; /* begin standout mode */
extern char *SEstr; /* end standout mode */
extern char *SOstr; /* begin standout mode */
/*
* putpad() is for padded strings with count=1.

View File

@@ -1,4 +1,4 @@
/* $NetBSD: shapes.c,v 1.3 1997/10/12 02:03:47 lukem Exp $ */
/* $NetBSD: shapes.c,v 1.5 2002/06/02 22:17:38 wiz Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -56,7 +56,7 @@
#define BC B_COLS /* bottom center */
#define BR B_COLS+1 /* bottom right */
struct shape shapes[] = {
const struct shape shapes[] = {
/* 0*/ { 7, { TL, TC, MR, } },
/* 1*/ { 8, { TC, TR, ML, } },
/* 2*/ { 9, { ML, MR, BC, } },
@@ -84,10 +84,10 @@ struct shape shapes[] = {
*/
int
fits_in(shape, pos)
struct shape *shape;
register int pos;
const struct shape *shape;
int pos;
{
register int *o = shape->off;
int *o = shape->off;
if (board[pos] || board[pos + *o++] || board[pos + *o++] ||
board[pos + *o])
@@ -101,10 +101,10 @@ fits_in(shape, pos)
*/
void
place(shape, pos, onoff)
struct shape *shape;
register int pos, onoff;
const struct shape *shape;
int pos, onoff;
{
register int *o = shape->off;
int *o = shape->off;
board[pos] = onoff;
board[pos + *o++] = onoff;

View File

@@ -1,4 +1,4 @@
.\" $NetBSD: tetris.6,v 1.4 1997/09/01 23:26:11 mikel Exp $
.\" $NetBSD: tetris.6,v 1.9 2002/09/26 18:32:05 wiz Exp $
.\"
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -44,7 +44,7 @@
.Nd the game of tetris
.Sh SYNOPSIS
.Nm
.Op Fl s
.Op Fl ps
.Op Fl k Ar keys
.Op Fl l Ar level
.Sh DESCRIPTION
@@ -60,14 +60,14 @@ The default level of play is 2.
.Pp
The default control keys are as follows:
.Pp
.Bl -tag -width "<space>" -compact -offset indent
.Bl -tag -width "xxspacexx" -compact -offset indent
.It j
move left
.It k
rotate 1/4 turn counterclockwise
.It l
move right
.It <space>
.It Aq space
drop
.It p
pause
@@ -97,6 +97,8 @@ during play.
Select a level of play.
.It Fl s
Display the top scores.
.It Fl p
Switch on previewing of the shape that will appear next.
.El
.Pp
.Sh PLAY
@@ -108,7 +110,7 @@ at level 9, they fall 9 times per second.
(As the game goes on, things speed up,
no matter what your initial selection.)
When this shape
.Dq "touches down"
.Dq touches down
on the bottom of the field, another will appear at the top.
.Pp
You can move shapes to the left or right, rotate them counterclockwise,
@@ -155,3 +157,5 @@ Chris Torek and Darren F. Provine.
.Pp
Manual adapted from the original entry written by Nancy L. Tinkham and
Darren F. Provine.
.Pp
Code for previewing next shape added by Hubert Feyrer in 1999.

View File

@@ -1,4 +1,4 @@
/* $NetBSD: tetris.h,v 1.3 1998/09/13 15:27:30 hubertf Exp $ */
/* $NetBSD: tetris.h,v 1.8 2000/01/01 10:15:17 jsm Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -60,7 +60,7 @@
#define B_SIZE (B_ROWS * B_COLS)
typedef unsigned char cell;
cell board[B_SIZE]; /* 1 => occupied, 0 => empty */
extern cell board[B_SIZE]; /* 1 => occupied, 0 => empty */
/* the displayed area (rows) */
#define D_FIRST 1
@@ -76,7 +76,7 @@ cell board[B_SIZE]; /* 1 => occupied, 0 => empty */
#define MINROWS 23
#define MINCOLS 40
int Rows, Cols; /* current screen size */
extern int Rows, Cols; /* current screen size */
/*
* Translations from board coordinates to display coordinates.
@@ -131,9 +131,12 @@ struct shape {
int off[3]; /* offsets to other blots if center is at (0,0) */
};
extern struct shape shapes[];
extern const struct shape shapes[];
#define randshape() (&shapes[random() % 7])
extern const struct shape *curshape;
extern const struct shape *nextshape;
/*
* Shapes fall at a rate faster than once per second.
*
@@ -144,7 +147,7 @@ extern struct shape shapes[];
* The value eventually reaches a limit, and things stop going faster,
* but by then the game is utterly impossible.
*/
long fallrate; /* less than 1 million; smaller => faster */
extern long fallrate; /* less than 1 million; smaller => faster */
#define faster() (fallrate -= fallrate / 3000)
/*
@@ -164,11 +167,12 @@ long fallrate; /* less than 1 million; smaller => faster */
* we find that it is at rest and integrate it---until then, it can
* still be moved or rotated).
*/
int score; /* the obvious thing */
gid_t gid, egid;
extern int score; /* the obvious thing */
extern gid_t gid, egid;
char key_msg[100];
extern char key_msg[100];
extern int showpreview;
int fits_in __P((struct shape *, int));
void place __P((struct shape *, int, int));
void stop __P((char *)) __attribute__((__noreturn__));
int fits_in __P((const struct shape *, int));
void place __P((const struct shape *, int, int));
void stop __P((const char *)) __attribute__((__noreturn__));