-/* $NetBSD: tetris.c,v 1.17 2004/01/27 20:30:30 jsm Exp $ */
+/* $NetBSD: tetris.c,v 1.25 2014/06/11 16:47:39 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
#include <sys/cdefs.h>
#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
- The Regents of the University of California. All rights reserved.\n");
+__COPYRIGHT("@(#) Copyright (c) 1992, 1993\
+ The Regents of the University of California. All rights reserved.");
#endif /* not lint */
/*
int Rows, Cols; /* current screen size */
-const struct shape *curshape;
+static const struct shape *curshape;
const struct shape *nextshape;
long fallrate; /* less than 1 million; smaller => faster */
char key_msg[100];
int showpreview;
-static void elide(void);
-static void setup_board(void);
- int main(int, char **);
- void onintr(int) __attribute__((__noreturn__));
- void usage(void) __attribute__((__noreturn__));
+static void elide(void);
+static void setup_board(void);
+static void onintr(int) __dead;
+static void usage(void) __dead;
/*
* Set up the initial board. The bottom display row is completely set,
* right edges are set.
*/
static void
-setup_board()
+setup_board(void)
{
int i;
cell *p;
p = board;
for (i = B_SIZE; i; i--)
- *p++ = i <= (2 * B_COLS) || (i % B_COLS) < 2;
+ *p++ = (i <= (2 * B_COLS) || (i % B_COLS) < 2) ? 7 : 0;
}
/*
* Elide any full active rows.
*/
static void
-elide()
+elide(void)
{
int i, j, base;
cell *p;
}
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int pos, c;
const char *keys;
}
}
- sprintf(key_msg,
+ snprintf(key_msg, sizeof(key_msg),
"%s - left %s - rotate %s - right %s - drop %s - pause %s - quit",
key_write[0], key_write[1], key_write[2], key_write[3],
key_write[4], key_write[5]);
scr_msg(key_msg, 0);
scr_msg(msg, 1);
(void) fflush(stdout);
- } while (rwait((struct timeval *)NULL) == -1);
+ } while (rwait(NULL) == -1);
scr_msg(msg, 0);
scr_msg(key_msg, 1);
place(curshape, pos, 0);
exit(0);
}
-void
-onintr(signo)
- int signo __attribute__((__unused__));
+static void
+onintr(int signo __unused)
{
scr_clear();
scr_end();
exit(0);
}
-void
-usage()
+static void
+usage(void)
{
- (void)fprintf(stderr, "usage: tetris [-ps] [-k keys] [-l level]\n");
+ (void)fprintf(stderr, "usage: %s [-ps] [-k keys] [-l level]\n",
+ getprogname());
exit(1);
}