summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--backgammon/Makefile.inc6
-rw-r--r--dab/Makefile6
-rw-r--r--hack/Makefile8
-rw-r--r--hack/extern.h12
-rw-r--r--hack/hack.c6
-rw-r--r--hack/hack.cmd.c6
-rw-r--r--hack/hack.end.c6
-rw-r--r--hack/hack.main.c6
-rw-r--r--hack/hack.pager.c6
-rw-r--r--hack/hack.pri.c6
-rw-r--r--hack/hack.save.c6
-rw-r--r--hack/hack.terminfo.c (renamed from hack/hack.termcap.c)228
-rw-r--r--hack/hack.tty.c16
-rw-r--r--hack/hack.u_init.c8
-rw-r--r--hunt/hunt/Makefile4
-rw-r--r--larn/Makefile6
-rw-r--r--larn/io.c136
-rw-r--r--tetris/Makefile6
-rw-r--r--tetris/scores.c10
-rw-r--r--tetris/screen.c178
20 files changed, 241 insertions, 425 deletions
diff --git a/backgammon/Makefile.inc b/backgammon/Makefile.inc
index 427d624d..05a32544 100644
--- a/backgammon/Makefile.inc
+++ b/backgammon/Makefile.inc
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile.inc,v 1.6 2000/12/30 17:51:26 sommerfeld Exp $
+# $NetBSD: Makefile.inc,v 1.7 2010/02/03 15:34:38 roy Exp $
.include <bsd.own.mk>
LIBCOMMON != cd ${.CURDIR}/../common_source; ${PRINTOBJDIR}
CPPFLAGS+=-DV7 -I${.CURDIR}/../common_source
-DPADD+= ${LIBCOMMON}/libcommon.a ${LIBTERMCAP}
-LDADD+= -L${LIBCOMMON} -lcommon -ltermcap
+DPADD+= ${LIBCOMMON}/libcommon.a ${LIBTERMINFO}
+LDADD+= -L${LIBCOMMON} -lcommon -lterminfo
HIDEGAME=hidegame
diff --git a/dab/Makefile b/dab/Makefile
index b5e9a818..db09457d 100644
--- a/dab/Makefile
+++ b/dab/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.6 2008/01/28 07:03:59 dholland Exp $
+# $NetBSD: Makefile,v 1.7 2010/02/03 15:34:38 roy Exp $
-DPADD+=${LIBCURSES} ${LIBTERMCAP} ${LIBM}
-LDADD+=-lcurses -ltermcap -lm
+DPADD+=${LIBCURSES} ${LIBTERMINFO} ${LIBM}
+LDADD+=-lcurses -lterminfo -lm
PROG_CXX=dab
MAN=dab.6
diff --git a/hack/Makefile b/hack/Makefile
index fe787747..be6c78a1 100644
--- a/hack/Makefile
+++ b/hack/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.41 2008/08/29 00:02:22 gmcgarry Exp $
+# $NetBSD: Makefile,v 1.42 2010/02/03 15:34:38 roy Exp $
# @(#)Makefile 8.2 (Berkeley) 4/27/95
.include <bsd.own.mk>
@@ -13,13 +13,13 @@ SRCS+= alloc.c hack.Decl.c hack.apply.c hack.bones.c hack.c hack.cmd.c \
hack.mkmaze.c hack.mkobj.c hack.mkshop.c hack.mon.c hack.monst.c \
hack.o_init.c hack.objnam.c hack.options.c hack.pager.c hack.potion.c \
hack.pri.c hack.read.c hack.rip.c hack.rumors.c hack.save.c \
- hack.search.c hack.shk.c hack.shknam.c hack.steal.c hack.termcap.c \
+ hack.search.c hack.shk.c hack.shknam.c hack.steal.c hack.terminfo.c \
hack.timeout.c hack.topl.c hack.track.c hack.trap.c hack.tty.c \
hack.u_init.c hack.unix.c hack.vault.c hack.version.c hack.wield.c \
hack.wizard.c hack.worm.c hack.worn.c hack.zap.c rnd.c
MAN= hack.6
-DPADD+= ${LIBTERMCAP}
-LDADD+= -ltermcap
+DPADD+= ${LIBTERMINFO}
+LDADD+= -lterminfo
HIDEGAME=hidegame
SETGIDGAME=yes
CLEANFILES+=makedefs makedefs.lo
diff --git a/hack/extern.h b/hack/extern.h
index e2b67441..fe8bdfc5 100644
--- a/hack/extern.h
+++ b/hack/extern.h
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.12 2009/08/12 07:28:40 dholland Exp $ */
+/* $NetBSD: extern.h,v 1.13 2010/02/03 15:34:38 roy Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -137,7 +137,7 @@ void done1(int);
void done_in_by(struct monst *);
void done(const char *);
void clearlocks(void);
-void hangup(int) __attribute__((__noreturn__));
+void hang_up(int) __attribute__((__noreturn__));
char *eos(char *);
void charcat(char *, int);
void prscore(int, char **);
@@ -400,16 +400,16 @@ void relobj(struct monst *, int);
/* hack.termcap.c */
void startup(void);
-void start_screen(void);
-void end_screen(void);
+void startscreen(void);
+void endscreen(void);
void curs(int, int);
void cl_end(void);
-void clear_screen(void);
+void clearscreen(void);
void home(void);
void standoutbeg(void);
void standoutend(void);
void backsp(void);
-void bell(void);
+void sound_bell(void);
void delay_output(void);
void cl_eos(void);
diff --git a/hack/hack.c b/hack/hack.c
index 8da2c771..8b1731a2 100644
--- a/hack/hack.c
+++ b/hack/hack.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.c,v 1.9 2009/08/12 07:28:40 dholland Exp $ */
+/* $NetBSD: hack.c,v 1.10 2010/02/03 15:34:38 roy Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.c,v 1.9 2009/08/12 07:28:40 dholland Exp $");
+__RCSID("$NetBSD: hack.c,v 1.10 2010/02/03 15:34:38 roy Exp $");
#endif /* not lint */
#include "hack.h"
@@ -459,7 +459,7 @@ pickup(int all)
pline("Pick up %s ? [ynaq]", doname(obj));
while (!strchr("ynaq ", (c = readchar())))
- bell();
+ sound_bell();
if (c == 'q')
return;
if (c == 'n')
diff --git a/hack/hack.cmd.c b/hack/hack.cmd.c
index a9e7fc08..e2e931f9 100644
--- a/hack/hack.cmd.c
+++ b/hack/hack.cmd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.cmd.c,v 1.10 2009/08/12 07:28:40 dholland Exp $ */
+/* $NetBSD: hack.cmd.c,v 1.11 2010/02/03 15:34:38 roy Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.cmd.c,v 1.10 2009/08/12 07:28:40 dholland Exp $");
+__RCSID("$NetBSD: hack.cmd.c,v 1.11 2010/02/03 15:34:38 roy Exp $");
#endif /* not lint */
#include "hack.h"
@@ -159,7 +159,7 @@ rhack(const char *cmd)
}
if (!*cmd || (*cmd & 0377) == 0377 ||
(flags.no_rest_on_space && *cmd == ' ')) {
- bell();
+ sound_bell();
flags.move = 0;
return; /* probably we just had an interrupt */
}
diff --git a/hack/hack.end.c b/hack/hack.end.c
index eef8effb..6d972497 100644
--- a/hack/hack.end.c
+++ b/hack/hack.end.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.end.c,v 1.13 2009/08/12 07:28:40 dholland Exp $ */
+/* $NetBSD: hack.end.c,v 1.14 2010/02/03 15:34:38 roy Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.end.c,v 1.13 2009/08/12 07:28:40 dholland Exp $");
+__RCSID("$NetBSD: hack.end.c,v 1.14 2010/02/03 15:34:38 roy Exp $");
#endif /* not lint */
#include <signal.h>
@@ -648,7 +648,7 @@ clearlocks(void)
#ifdef NOSAVEONHANGUP
/*ARGSUSED*/
void
-hangup(int n __unused)
+hang_up(int n __unused)
{
(void) signal(SIGINT, SIG_IGN);
clearlocks();
diff --git a/hack/hack.main.c b/hack/hack.main.c
index 623752c7..cfa379b9 100644
--- a/hack/hack.main.c
+++ b/hack/hack.main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.main.c,v 1.14 2009/08/12 07:28:40 dholland Exp $ */
+/* $NetBSD: hack.main.c,v 1.15 2010/02/03 15:34:38 roy Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.main.c,v 1.14 2009/08/12 07:28:40 dholland Exp $");
+__RCSID("$NetBSD: hack.main.c,v 1.15 2010/02/03 15:34:38 roy Exp $");
#endif /* not lint */
#include <signal.h>
@@ -184,7 +184,7 @@ main(int argc, char *argv[])
cls();
u.uhp = 1; /* prevent RIP on early quits */
u.ux = FAR; /* prevent nscr() */
- (void) signal(SIGHUP, hangup);
+ (void) signal(SIGHUP, hang_up);
/*
* Find the creation date of this game,
diff --git a/hack/hack.pager.c b/hack/hack.pager.c
index b72cb99e..eb6484be 100644
--- a/hack/hack.pager.c
+++ b/hack/hack.pager.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.pager.c,v 1.13 2009/08/12 07:28:41 dholland Exp $ */
+/* $NetBSD: hack.pager.c,v 1.14 2010/02/03 15:34:38 roy Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.pager.c,v 1.13 2009/08/12 07:28:41 dholland Exp $");
+__RCSID("$NetBSD: hack.pager.c,v 1.14 2010/02/03 15:34:38 roy Exp $");
#endif /* not lint */
/* This file contains the command routine dowhatis() and a pager. */
@@ -359,7 +359,7 @@ dohelp(void)
pline("Long or short help? ");
while (((c = readchar()) != 'l') && (c != 's') && !strchr(quitchars, c))
- bell();
+ sound_bell();
if (!strchr(quitchars, c))
(void) page_file((c == 'l') ? HELP : SHELP, FALSE);
return (0);
diff --git a/hack/hack.pri.c b/hack/hack.pri.c
index 0db65d56..ad09bab6 100644
--- a/hack/hack.pri.c
+++ b/hack/hack.pri.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.pri.c,v 1.12 2009/08/12 07:28:41 dholland Exp $ */
+/* $NetBSD: hack.pri.c,v 1.13 2010/02/03 15:34:38 roy Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.pri.c,v 1.12 2009/08/12 07:28:41 dholland Exp $");
+__RCSID("$NetBSD: hack.pri.c,v 1.13 2010/02/03 15:34:38 roy Exp $");
#endif /* not lint */
#include "hack.h"
@@ -796,7 +796,7 @@ cls(void)
more();
flags.toplin = 0;
- clear_screen();
+ clearscreen();
flags.botlx = 1;
}
diff --git a/hack/hack.save.c b/hack/hack.save.c
index 72722a02..65ce5012 100644
--- a/hack/hack.save.c
+++ b/hack/hack.save.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.save.c,v 1.13 2009/08/12 07:28:41 dholland Exp $ */
+/* $NetBSD: hack.save.c,v 1.14 2010/02/03 15:34:38 roy Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.save.c,v 1.13 2009/08/12 07:28:41 dholland Exp $");
+__RCSID("$NetBSD: hack.save.c,v 1.14 2010/02/03 15:34:38 roy Exp $");
#endif /* not lint */
#include <signal.h>
@@ -87,7 +87,7 @@ dosave(void)
#ifndef NOSAVEONHANGUP
void
-hangup(int n __unused)
+hang_up(int n __unused)
{
(void) dosave0(1);
exit(1);
diff --git a/hack/hack.termcap.c b/hack/hack.terminfo.c
index 6e7e9662..8ded6387 100644
--- a/hack/hack.termcap.c
+++ b/hack/hack.terminfo.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.termcap.c,v 1.18 2009/08/12 07:28:41 dholland Exp $ */
+/* $NetBSD: hack.terminfo.c,v 1.1 2010/02/03 15:34:38 roy Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,147 +63,102 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.termcap.c,v 1.18 2009/08/12 07:28:41 dholland Exp $");
+__RCSID("$NetBSD: hack.terminfo.c,v 1.1 2010/02/03 15:34:38 roy Exp $");
#endif /* not lint */
#include <string.h>
#include <termios.h>
-#include <termcap.h>
+#include <term.h>
#include <stdlib.h>
#include <unistd.h>
#include "hack.h"
#include "extern.h"
#include "def.flag.h" /* for flags.nonull */
-static struct tinfo *info;
-static const char *HO, *CL, *CE, *CM, *ND, *XD, *BC_BS, *SO, *SE, *TI, *TE;
-static const char *VS, *VE;
-static int SG;
char *CD; /* tested in pri.c: docorner() */
int CO, LI; /* used in pri.c and whatis.c */
-static void nocmov(int, int);
-static void cmov(int, int);
-static int xputc(int);
-static void xputs(const char *);
-
void
startup(void)
{
- char *term;
-
- /* UP, BC, PC already set */
- if (!(term = getenv("TERM")))
- error("Can't get TERM.");
- if (!strncmp(term, "5620", 4))
- flags.nonull = 1; /* this should be a termcap flag */
- if (t_getent(&info, term) < 1)
- error("Unknown terminal type: %s.", term);
- BC_BS = t_agetstr(info, "bc");
- if (!BC_BS) {
- if (!t_getflag(info, "bs"))
- error("Terminal must backspace.");
- BC_BS = "\b";
- }
- HO = t_agetstr(info, "ho");
- CO = t_getnum(info, "co");
- LI = t_getnum(info, "li");
+
+ /* Will exit if no suitable term found */
+ setupterm(NULL, 0, NULL);
+ CO = columns;
+ LI = lines;
if (CO < COLNO || LI < ROWNO + 2)
setclipped();
- if (!(CL = t_agetstr(info, "cl")))
- error("Hack needs CL.");
- ND = t_agetstr(info, "nd");
- if (t_getflag(info, "os"))
- error("Hack can't have OS.");
- CE = t_agetstr(info, "ce");
- /*
- * It seems that xd is no longer supported, and we should use a
- * linefeed instead; unfortunately this requires resetting CRMOD, and
- * many output routines will have to be modified slightly. Let's
- * leave that till the next release.
- */
- XD = t_agetstr(info, "xd");
- /* not: XD = t_agetstr(info, "do"); */
- if (!(CM = t_agetstr(info, "cm"))) {
- if (!UP && !HO)
- error("Hack needs CM or UP or HO.");
- printf("Playing hack on terminals without cm is suspect...\n");
+ if (clear_screen == NULL)
+ error("Hack needs clear_screen.");
+ if (over_strike)
+ error("Hack can't have over_strike.");
+ if (cursor_address == NULL) {
+ printf("Playing hack without cursor_address is suspect...");
getret();
}
- SO = t_agetstr(info, "so");
- SE = t_agetstr(info, "se");
- SG = t_getnum(info, "sg"); /* -1: not fnd; else # of spaces left by so */
- if (!SO || !SE || (SG > 0))
- SO = SE = 0;
- CD = t_agetstr(info, "cd");
- set_whole_screen(); /* uses LI and CD */
+ set_whole_screen();
}
void
-start_screen(void)
+startscreen(void)
{
- xputs(TI);
- xputs(VS);
}
void
-end_screen(void)
+endscreen(void)
{
- xputs(VE);
- xputs(TE);
}
-/*
- * Cursor movements
- *
- * x,y not xchar: perhaps xchar is unsigned and
- * curx-x would be unsigned as well
- */
-void
-curs(int x, int y)
+static int
+xputc(int c)
{
+ return (fputc(c, stdout));
+}
- if (y == cury && x == curx)
- return;
- if (!ND && (curx != x || x <= 3)) { /* Extremely primitive */
- cmov(x, y); /* bunker!wtm */
- return;
+static void
+xputs(const char *s)
+{
+ tputs(s, 1, xputc);
+}
+
+static void
+cmov(int x, int y)
+{
+ char *p;
+
+ p = vtparm(cursor_address, y - 1, x - 1);
+ if (p) {
+ xputs(p);
+ cury = y;
+ curx = x;
}
- if (abs(cury - y) <= 3 && abs(curx - x) <= 3)
- nocmov(x, y);
- else if ((x <= 3 && abs(cury - y) <= 3) || (!CM && x < abs(curx - x))) {
- (void) putchar('\r');
- curx = 1;
- nocmov(x, y);
- } else if (!CM) {
- nocmov(x, y);
- } else
- cmov(x, y);
}
static void
nocmov(int x, int y)
{
if (cury > y) {
- if (UP) {
+ if (cursor_up) {
while (cury > y) { /* Go up. */
- xputs(UP);
+ xputs(cursor_up);
cury--;
}
- } else if (CM) {
+ } else if (cursor_address) {
cmov(x, y);
- } else if (HO) {
+ } else if (cursor_home) {
home();
curs(x, y);
} /* else impossible("..."); */
} else if (cury < y) {
- if (XD) {
+ if (cursor_address) {
+ cmov(x, y);
+#if 0
+ } else if (XD) {
while (cury < y) {
xputs(XD);
cury++;
}
- } else if (CM) {
- cmov(x, y);
+#endif
} else {
while (cury < y) {
xputc('\n');
@@ -213,51 +168,55 @@ nocmov(int x, int y)
}
}
if (curx < x) { /* Go to the right. */
- if (!ND)
+ if (!cursor_right)
cmov(x, y);
else /* bah */
/* should instead print what is there already */
while (curx < x) {
- xputs(ND);
+ xputs(cursor_right);
curx++;
}
} else if (curx > x) {
- while (curx > x) { /* Go to the left. */
- xputs(BC_BS);
- curx--;
- }
+ while (curx > x)
+ backsp();
}
}
-static void
-cmov(int x, int y)
+/*
+ * Cursor movements
+ *
+ * x,y not xchar: perhaps xchar is unsigned and
+ * curx-x would be unsigned as well
+ */
+void
+curs(int x, int y)
{
- char buf[256];
- if (t_goto(info, CM, x - 1, y - 1, buf, 255) >= 0) {
- xputs(buf);
- cury = y;
- curx = x;
+ if (y == cury && x == curx)
+ return;
+ if (!cursor_right && (curx != x || x <= 3)) { /* Extremely primitive */
+ cmov(x, y); /* bunker!wtm */
+ return;
}
-}
-
-static int
-xputc(int c)
-{
- return (fputc(c, stdout));
-}
-
-static void
-xputs(const char *s)
-{
- tputs(s, 1, xputc);
+ if (abs(cury - y) <= 3 && abs(curx - x) <= 3)
+ nocmov(x, y);
+ else if ((x <= 3 && abs(cury - y) <= 3) ||
+ (!cursor_address && x < abs(curx - x)))
+ {
+ (void) putchar('\r');
+ curx = 1;
+ nocmov(x, y);
+ } else if (!cursor_address) {
+ nocmov(x, y);
+ } else
+ cmov(x, y);
}
void
cl_end(void)
{
- if (CE)
- xputs(CE);
+ if (clr_eol)
+ xputs(clr_eol);
else { /* no-CE fix - free after Harold Rynes */
/*
* this looks terrible, especially on a slow terminal but is
@@ -274,21 +233,21 @@ cl_end(void)
}
void
-clear_screen(void)
+clearscreen(void)
{
- xputs(CL);
+ xputs(clear_screen);
curx = cury = 1;
}
void
home(void)
{
- char buf[256];
+ char *out;
- if (HO)
- xputs(HO);
- else if ((CM) && (t_goto(info, CM, 0, 0, buf, 255) >= 0))
- xputs(buf);
+ if (cursor_home)
+ xputs(cursor_home);
+ else if ((cursor_address) && (out = vtparm(cursor_address, 0, 0)))
+ xputs(out);
else
curs(1, 1); /* using UP ... */
curx = cury = 1;
@@ -297,26 +256,29 @@ home(void)
void
standoutbeg(void)
{
- if (SO)
- xputs(SO);
+ if (enter_standout_mode && exit_standout_mode && !magic_cookie_glitch)
+ xputs(enter_standout_mode);
}
void
standoutend(void)
{
- if (SE)
- xputs(SE);
+ if (exit_standout_mode && enter_standout_mode && !magic_cookie_glitch)
+ xputs(exit_standout_mode);
}
void
backsp(void)
{
- xputs(BC_BS);
+ if (cursor_left)
+ xputs(cursor_left);
+ else
+ (void) putchar('\b');
curx--;
}
void
-bell(void)
+sound_bell(void)
{
(void) putchar('\007'); /* curx does not change */
(void) fflush(stdout);
@@ -336,8 +298,8 @@ cl_eos(void)
{ /* free after Robert Viduya *//* must only be
* called with curx = 1 */
- if (CD)
- xputs(CD);
+ if (clr_eos)
+ xputs(clr_eos);
else {
int cx = curx, cy = cury;
while (cury <= LI - 2) {
diff --git a/hack/hack.tty.c b/hack/hack.tty.c
index 8d0802b7..474afab5 100644
--- a/hack/hack.tty.c
+++ b/hack/hack.tty.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.tty.c,v 1.14 2009/08/12 07:28:41 dholland Exp $ */
+/* $NetBSD: hack.tty.c,v 1.15 2010/02/03 15:34:39 roy Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)hack.tty.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: hack.tty.c,v 1.14 2009/08/12 07:28:41 dholland Exp $");
+__RCSID("$NetBSD: hack.tty.c,v 1.15 2010/02/03 15:34:39 roy Exp $");
#endif
#endif /* not lint */
@@ -152,8 +152,8 @@ gettty(void)
void
settty(const char *s)
{
- clear_screen();
- end_screen();
+ clearscreen();
+ endscreen();
if (s)
printf("%s", s);
(void) fflush(stdout);
@@ -193,7 +193,7 @@ setftty(void)
if (change) {
setctty();
}
- start_screen();
+ startscreen();
}
@@ -242,7 +242,7 @@ getlin(char *bufp)
bufp--;
putstr("\b \b"); /* putsym converts \b */
} else
- bell();
+ sound_bell();
} else if (c == '\n') {
*bufp = 0;
return;
@@ -263,7 +263,7 @@ getlin(char *bufp)
putstr("\b \b");
}
} else
- bell();
+ sound_bell();
}
}
@@ -305,7 +305,7 @@ xwaitforspace(const char *s)
morc = c;
break;
}
- bell();
+ sound_bell();
}
}
}
diff --git a/hack/hack.u_init.c b/hack/hack.u_init.c
index 5bed1e5e..b20bf1de 100644
--- a/hack/hack.u_init.c
+++ b/hack/hack.u_init.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.u_init.c,v 1.11 2009/08/12 07:28:41 dholland Exp $ */
+/* $NetBSD: hack.u_init.c,v 1.12 2010/02/03 15:34:39 roy Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.u_init.c,v 1.11 2009/08/12 07:28:41 dholland Exp $");
+__RCSID("$NetBSD: hack.u_init.c,v 1.12 2010/02/03 15:34:39 roy Exp $");
#endif /* not lint */
#include <ctype.h>
@@ -184,7 +184,7 @@ u_init(void)
printf("\nAre you an experienced player? [ny] ");
while (!strchr("ynYN \n\004", (exper = readchar())))
- bell();
+ sound_bell();
if (exper == '\004') /* Give him an opportunity to get out */
end_of_input();
printf("%c\n", exper); /* echo */
@@ -218,7 +218,7 @@ u_init(void)
if (pc == '\004') /* Give him the opportunity to get
* out */
end_of_input();
- bell();
+ sound_bell();
}
if (pc == '\n')
pc = 0;
diff --git a/hunt/hunt/Makefile b/hunt/hunt/Makefile
index 49ea5339..39bfe891 100644
--- a/hunt/hunt/Makefile
+++ b/hunt/hunt/Makefile
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.5 1998/02/18 22:37:31 jtc Exp $
+# $NetBSD: Makefile,v 1.6 2010/02/03 15:34:39 roy Exp $
PROG= hunt
SRCS= connect.c hunt.c otto.c playit.c pathname.c
MAN= hunt.6
LDADD= -lcurses
-DPADD= ${LIBTERMCAP}
+DPADD= ${LIBCURSES}
HIDEGAME=hidegame
CPPFLAGS+=-I${.CURDIR}/../huntd
diff --git a/larn/Makefile b/larn/Makefile
index 05b4ba16..5facdacf 100644
--- a/larn/Makefile
+++ b/larn/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.19 2008/02/19 06:05:26 dholland Exp $
+# $NetBSD: Makefile,v 1.20 2010/02/03 15:34:39 roy Exp $
# @(#)Makefile 5.12 (Berkeley) 5/30/93
# EXTRA
@@ -63,8 +63,8 @@ CPPFLAGS+=-DBSD -DVER=12 -DSUBVER=0 -DNONAP -DUIDSCORE -DTERMIOS
SRCS= main.c object.c create.c tok.c display.c global.c data.c io.c \
monster.c store.c diag.c help.c config.c nap.c bill.c scores.c \
signal.c action.c moreobj.c movem.c regen.c fortune.c savelev.c
-DPADD= ${LIBTERM}
-LDADD= -ltermcap
+DPADD= ${LIBTERMINFO}
+LDADD= -lterminfo
HIDEGAME=hidegame
SETGIDGAME=yes
diff --git a/larn/io.c b/larn/io.c
index f9495afc..56027858 100644
--- a/larn/io.c
+++ b/larn/io.c
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.24 2009/08/12 08:04:05 dholland Exp $ */
+/* $NetBSD: io.c,v 1.25 2010/02/03 15:34:39 roy Exp $ */
/*
* io.c Larn is copyrighted 1986 by Noah Morgan.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: io.c,v 1.24 2009/08/12 08:04:05 dholland Exp $");
+__RCSID("$NetBSD: io.c,v 1.25 2010/02/03 15:34:39 roy Exp $");
#endif /* not lint */
#include "header.h"
@@ -71,7 +71,7 @@ __RCSID("$NetBSD: io.c,v 1.24 2009/08/12 08:04:05 dholland Exp $");
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
-#include <termcap.h>
+#include <term.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
@@ -650,63 +650,32 @@ cursors()
* obvious meanings.
*/
-static struct tinfo *info;
-static char *CM, *CE, *CD, *CL, *SO, *SE, *AL, *DL; /* Termcap capabilities */
-static char *outbuf = 0; /* translated output buffer */
-
+static char *outbuf = 0; /* translated output buffer */
/*
* init_term() Terminal initialization -- setup termcap info
*/
void
init_term()
{
- char *term;
-
- switch (t_getent(&info, term = getenv("TERM"))) {
- case -1:
- write(2, "Cannot open termcap file.\n", 26);
- exit(1);
- case 0:
- write(2, "Cannot find entry of ", 21);
- write(2, term, strlen(term));
- write(2, " in termcap\n", 12);
- exit(1);
- };
-
- CM = t_agetstr(info, "cm"); /* Cursor motion */
- CE = t_agetstr(info, "ce"); /* Clear to eoln */
- CL = t_agetstr(info, "cl"); /* Clear screen */
-
- /* OPTIONAL */
- AL = t_agetstr(info, "al"); /* Insert line */
- DL = t_agetstr(info, "dl"); /* Delete line */
- SO = t_agetstr(info, "so"); /* Begin standout mode */
- SE = t_agetstr(info, "se"); /* End standout mode */
- CD = t_agetstr(info, "cd"); /* Clear to end of display */
-
- if (!CM) { /* can't find cursor motion entry */
- write(2, "Sorry, for a ", 13);
- write(2, term, strlen(term));
- write(2, ", I can't find the cursor motion entry in termcap\n", 50);
+ setupterm(NULL, 0, NULL); /* will exit if invalid term */
+ if (!cursor_address) {
+ fprintf(stderr, "term does not have cursor_address.\n");
exit(1);
}
- if (!CE) { /* can't find clear to end of line entry */
- write(2, "Sorry, for a ", 13);
- write(2, term, strlen(term));
- write(2, ", I can't find the clear to end of line entry in termcap\n", 57);
+ if (!clr_eol) {
+ fprintf(stderr, "term does not have clr_eol.\n");
exit(1);
}
- if (!CL) { /* can't find clear entire screen entry */
- write(2, "Sorry, for a ", 13);
- write(2, term, strlen(term));
- write(2, ", I can't find the clear entire screen entry in termcap\n", 56);
+ if (!clear_screen) {
+ fprintf(stderr, "term does not have clear_screen.\n");
exit(1);
}
- if ((outbuf = malloc(BUFBIG + 16)) == 0) { /* get memory for
+ if ((outbuf = malloc(BUFBIG + 16)) == 0) { /* get memory for
* decoded output buffer */
- write(2, "Error malloc'ing memory for decoded output buffer\n", 50);
- died(-285); /* malloc() failure */
+ fprintf(stderr, "Error malloc'ing memory for decoded output buffer\n");
+ died(-285); /* malloc() failure */
}
+
}
#endif /* VT100 */
@@ -761,7 +730,7 @@ cl_dn(x, y)
#else /* VT100 */
int i;
cursor(1, y);
- if (!CD) {
+ if (!clr_eos) {
*lpnt++ = CL_LINE;
for (i = y; i <= 24; i++) {
*lpnt++ = CL_LINE;
@@ -820,7 +789,6 @@ lflush()
u_char *str;
static int curx = 0;
static int cury = 0;
- char tgoto_buf[256];
if ((lpoint = lpnt - lpbuf) > 0) {
#ifdef EXTRA
@@ -840,77 +808,69 @@ lflush()
} else
switch (*str) {
case CLEAR:
- tputs(CL, 0, ttputch);
+ tputs(clear_screen, 0, ttputch);
curx = cury = 0;
break;
case CL_LINE:
- tputs(CE, 0, ttputch);
+ tputs(clr_eol, 0, ttputch);
break;
case CL_DOWN:
- tputs(CD, 0, ttputch);
+ tputs(clr_eos, 0, ttputch);
break;
case ST_START:
- tputs(SO, 0, ttputch);
+ tputs(enter_standout_mode, 0, ttputch);
break;
case ST_END:
- tputs(SE, 0, ttputch);
+ tputs(exit_standout_mode, 0, ttputch);
break;
case CURSOR:
curx = *++str - 1;
cury = *++str - 1;
- if (t_goto(info, CM, curx, cury,
- tgoto_buf, 255) == 0)
- tputs(tgoto_buf, 0, ttputch);
+ tputs(vtparm(cursor_address,
+ cury, curx), 0, ttputch);
break;
case '\n':
if ((cury == 23) && enable_scroll) {
- if (!DL || !AL) { /* wraparound or scroll? */
+ if (!delete_line ||
+ !insert_line)
+ { /* wraparound or scroll? */
if (++scrline > 23)
scrline = 19;
if (++scrline > 23)
scrline = 19;
- if (t_goto(info, CM, 0,
- scrline,
- tgoto_buf,
- 255) == 0)
- tputs(tgoto_buf,
- 0,
- ttputch);
- tputs(CE, 0, ttputch);
+ tputs(vtparm(
+ cursor_address,
+ scrline, 0),
+ 0, ttputch);
+ tputs(clr_eol, 0,
+ ttputch);
if (--scrline < 19)
scrline = 23;
- if (t_goto(info, CM, 0,
- scrline,
- tgoto_buf,
- 255) == 0)
- tputs(tgoto_buf,
- 0,
- ttputch);
- tputs(CE, 0, ttputch);
+ tputs(vtparm(
+ cursor_address,
+ scrline, 0),
+ 0, ttputch);
+ tputs(clr_eol, 0,
+ ttputch);
} else {
- if (t_goto(info, CM, 0,
- 19,
- tgoto_buf,
- 255) == 0)
- tputs(tgoto_buf,
- 0,
- ttputch);
- tputs(DL, 0, ttputch);
- if (t_goto(info, CM, 0,
- 23,
- tgoto_buf,
- 255) == 0)
- tputs(tgoto_buf,
- 0,
- ttputch);
+ tputs(vtparm(
+ cursor_address,
+ 19, 0),
+ 0, ttputch);
+ tputs(delete_line, 0,
+ ttputch);
+ tputs(vtparm(
+ cursor_address,
+ 23, 0),
+ 0, ttputch);
/*
* tputs (AL, 0,
* ttputch);
diff --git a/tetris/Makefile b/tetris/Makefile
index 19122c16..25a3639a 100644
--- a/tetris/Makefile
+++ b/tetris/Makefile
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.6 2008/01/28 07:03:59 dholland Exp $
+# $NetBSD: Makefile,v 1.7 2010/02/03 15:34:39 roy Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= tetris
SRCS= input.c screen.c shapes.c scores.c tetris.c
MAN= tetris.6
-DPADD= ${LIBTERM}
-LDADD= -ltermcap
+DPADD= ${LIBTERMINFO}
+LDADD= -lterminfo
HIDEGAME=hidegame
SETGIDGAME=yes
diff --git a/tetris/scores.c b/tetris/scores.c
index eaf2618c..42c427e0 100644
--- a/tetris/scores.c
+++ b/tetris/scores.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scores.c,v 1.18 2009/09/08 13:38:01 dholland Exp $ */
+/* $NetBSD: scores.c,v 1.19 2010/02/03 15:34:39 roy Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -50,7 +50,7 @@
#include <string.h>
#include <sys/stat.h>
#include <time.h>
-#include <termcap.h>
+#include <term.h>
#include <unistd.h>
#include "pathnames.h"
@@ -861,7 +861,7 @@ showscores(int level)
* the high scores; we do not need to check for printing in highlight
* mode. If SOstr is null, we can't do highlighting anyway.
*/
- me = level && SOstr ? thisuser() : NULL;
+ me = level && enter_standout_mode ? thisuser() : NULL;
/*
* Set times to 0 except for high score on each level.
@@ -939,12 +939,12 @@ printem(int level, int offset, struct highscore *hs, int n, const char *me)
sp->hs_level == level &&
sp->hs_score == score &&
strcmp(sp->hs_name, me) == 0) {
- putpad(SOstr);
+ putpad(enter_standout_mode);
highlight = 1;
}
(void)printf("%s", buf);
if (highlight) {
- putpad(SEstr);
+ putpad(exit_standout_mode);
highlight = 0;
}
diff --git a/tetris/screen.c b/tetris/screen.c
index cb9d2023..ed9e849b 100644
--- a/tetris/screen.c
+++ b/tetris/screen.c
@@ -1,4 +1,4 @@
-/* $NetBSD: screen.c,v 1.25 2009/12/19 19:27:53 ahoka Exp $ */
+/* $NetBSD: screen.c,v 1.26 2010/02/03 15:34:39 roy Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -46,7 +46,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <termcap.h>
+#include <term.h>
#include <termios.h>
#include <unistd.h>
@@ -68,62 +68,6 @@ static void stopset(int) __dead;
/*
- * Capabilities from TERMCAP.
- */
-extern short ospeed;
-
-static char
- *bcstr, /* backspace char */
- *CEstr, /* clear to end of line */
- *CLstr, /* clear screen */
- *CMstr, /* cursor motion string */
-#ifdef unneeded
- *CRstr, /* "\r" equivalent */
-#endif
- *HOstr, /* cursor home */
- *LLstr, /* last line, first column */
- *pcstr, /* pad character */
- *TEstr, /* end cursor motion mode */
- *TIstr, /* begin cursor motion mode */
- *VIstr, /* make cursor invisible */
- *VEstr; /* make cursor appear normal */
-char
- *SEstr, /* end standout mode */
- *SOstr; /* begin standout mode */
-static int
- COnum, /* co# value */
- LInum, /* li# value */
- MSflag; /* can move in standout mode */
-
-
-static struct tcsinfo { /* termcap string info; some abbrevs above */
- char tcname[3];
- char **tcaddr;
-} tcstrings[] = {
- {"bc", &bcstr},
- {"ce", &CEstr},
- {"cl", &CLstr},
- {"cm", &CMstr},
-#ifdef unneeded
- {"cr", &CRstr},
-#endif
- {"le", &BC}, /* move cursor left one space */
- {"pc", &pcstr},
- {"se", &SEstr},
- {"so", &SOstr},
- {"te", &TEstr},
- {"ti", &TIstr},
- {"vi", &VIstr},
- {"ve", &VEstr},
- {"up", &UP}, /* cursor up */
- { {0}, NULL}
-};
-
-/* This is where we will actually stuff the information */
-
-static struct tinfo *info;
-
-/*
* Routine used by tputs().
*/
int
@@ -143,9 +87,10 @@ put(int c)
static void
moveto(int r, int c)
{
- char buf[256];
+ char *buf;
- if (t_goto(info, CMstr, c, r, buf, 255) == 0)
+ buf = vtparm(cursor_address, r, c);
+ if (buf != NULL)
putpad(buf);
}
@@ -155,65 +100,12 @@ moveto(int r, int c)
void
scr_init(void)
{
- static int bsflag, xsflag, sgnum;
-#ifdef unneeded
- static int ncflag;
-#endif
- char *term;
- static struct tcninfo { /* termcap numeric and flag info */
- char tcname[3];
- int *tcaddr;
- } tcflags[] = {
- {"bs", &bsflag},
- {"ms", &MSflag},
-#ifdef unneeded
- {"nc", &ncflag},
-#endif
- {"xs", &xsflag},
- { {0}, NULL}
- }, tcnums[] = {
- {"co", &COnum},
- {"li", &LInum},
- {"sg", &sgnum},
- { {0}, NULL}
- };
- static char backspace[] = "\b";
-
- if ((term = getenv("TERM")) == NULL)
- stop("you must set the TERM environment variable");
- if (t_getent(&info, term) <= 0)
- stop("cannot find your termcap");
- {
- struct tcsinfo *p;
-
- for (p = tcstrings; p->tcaddr; p++)
- *p->tcaddr = t_agetstr(info, p->tcname);
- }
- {
- struct tcninfo *p;
- for (p = tcflags; p->tcaddr; p++)
- *p->tcaddr = t_getflag(info, p->tcname);
- for (p = tcnums; p->tcaddr; p++)
- *p->tcaddr = t_getnum(info, p->tcname);
- }
- if (bsflag)
- BC = backspace;
- else if (BC == NULL && bcstr != NULL)
- BC = bcstr;
- if (CLstr == NULL)
+ setupterm(NULL, 0, NULL);
+ if (clear_screen == NULL)
stop("cannot clear screen");
- if (CMstr == NULL || UP == NULL || BC == NULL)
- stop("cannot do random cursor positioning via tgoto()");
- PC = pcstr ? *pcstr : 0;
- if (sgnum >= 0 || xsflag)
- SOstr = SEstr = NULL;
-#ifdef unneeded
- if (ncflag)
- CRstr = NULL;
- else if (CRstr == NULL)
- CRstr = "\r";
-#endif
+ if (cursor_address == NULL || cursor_up == NULL)
+ stop("cannot do random cursor positioning");
}
/* this foolery is needed to modify tty state `atomically' */
@@ -278,9 +170,9 @@ scr_set(void)
Cols = ws.ws_col;
}
if (Rows == 0)
- Rows = LInum;
+ Rows = lines;
if (Cols == 0)
- Cols = COnum;
+ Cols = columns;
if (Rows < MINROWS || Cols < MINCOLS) {
(void) fprintf(stderr,
"the screen is too small: must be at least %dx%d, ",
@@ -301,10 +193,10 @@ scr_set(void)
* We made it. We are now in screen mode, modulo TIstr
* (which we will fix immediately).
*/
- if (TIstr)
- putstr(TIstr); /* termcap(5) says this is not padded */
- if (VIstr)
- putstr(VIstr); /* termcap(5) says this is not padded */
+ if (enter_ca_mode)
+ putstr(enter_ca_mode);
+ if (cursor_invisible)
+ putstr(cursor_invisible);
if (tstp != SIG_IGN)
(void) signal(SIGTSTP, scr_stop);
if (ttou != SIG_IGN)
@@ -328,15 +220,15 @@ scr_end(void)
sigaddset(&nsigset, SIGTTOU);
(void) sigprocmask(SIG_BLOCK, &nsigset, &osigset);
/* move cursor to last line */
- if (LLstr)
- putstr(LLstr); /* termcap(5) says this is not padded */
+ if (cursor_to_ll)
+ putstr(cursor_to_ll);
else
moveto(Rows - 1, 0);
/* exit screen mode */
- if (TEstr)
- putstr(TEstr); /* termcap(5) says this is not padded */
- if (VEstr)
- putstr(VEstr); /* termcap(5) says this is not padded */
+ if (exit_ca_mode)
+ putstr(exit_ca_mode);
+ if (cursor_normal)
+ putstr(cursor_normal);
(void) fflush(stdout);
(void) tcsetattr(0, TCSADRAIN, &oldtt);
isset = 0;
@@ -362,7 +254,7 @@ void
scr_clear(void)
{
- putpad(CLstr);
+ putpad(clear_screen);
curscore = -1;
memset((char *)curscreen, 0, sizeof(curscreen));
}
@@ -393,8 +285,8 @@ scr_update(void)
curscreen[D_LAST * B_COLS - 1] = -1;
if (score != curscore) {
- if (HOstr)
- putpad(HOstr);
+ if (cursor_home)
+ putpad(cursor_home);
else
moveto(0, 0);
(void) printf("Score: %d", score);
@@ -409,7 +301,7 @@ scr_update(void)
lastshape = nextshape;
/* clean */
- putpad(SEstr);
+ putpad(exit_standout_mode);
moveto(r-1, c-1); putstr(" ");
moveto(r, c-1); putstr(" ");
moveto(r+1, c-1); putstr(" ");
@@ -419,7 +311,7 @@ scr_update(void)
putstr("Next shape:");
/* draw */
- putpad(SOstr);
+ putpad(enter_standout_mode);
moveto(r, 2*c);
putstr(" ");
for(i=0; i<3; i++) {
@@ -432,7 +324,7 @@ scr_update(void)
moveto(tr, 2*tc);
putstr(" ");
}
- putpad(SEstr);
+ putpad(exit_standout_mode);
}
bp = &board[D_FIRST * B_COLS];
@@ -444,15 +336,17 @@ scr_update(void)
continue;
*sp = so;
if (i != ccol) {
- if (cur_so && MSflag) {
- putpad(SEstr);
+ if (cur_so && move_standout_mode) {
+ putpad(exit_standout_mode);
cur_so = 0;
}
moveto(RTOD(j), CTOD(i));
}
- if (SOstr) {
+ if (enter_standout_mode) {
if (so != cur_so) {
- putpad(so ? SOstr : SEstr);
+ putpad(so ?
+ enter_standout_mode :
+ exit_standout_mode);
cur_so = so;
}
putstr(" ");
@@ -479,7 +373,7 @@ scr_update(void)
}
}
if (cur_so)
- putpad(SEstr);
+ putpad(exit_standout_mode);
(void) fflush(stdout);
(void) sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0);
}
@@ -492,7 +386,7 @@ void
scr_msg(char *s, int set)
{
- if (set || CEstr == NULL) {
+ if (set || clr_eol == NULL) {
int l = strlen(s);
moveto(Rows - 2, ((Cols - l) >> 1) - 1);
@@ -503,6 +397,6 @@ scr_msg(char *s, int set)
(void) putchar(' ');
} else {
moveto(Rows - 2, 0);
- putpad(CEstr);
+ putpad(clr_eol);
}
}