Converted games to use the new termcap interface.
This commit is contained in:
parent
5de72de121
commit
494e4c93a6
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: io.c,v 1.8 1999/10/04 23:27:02 lukem Exp $ */
|
||||
/* $NetBSD: io.c,v 1.9 2000/05/22 12:42:46 blymn 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.8 1999/10/04 23:27:02 lukem Exp $");
|
||||
__RCSID("$NetBSD: io.c,v 1.9 2000/05/22 12:42:46 blymn Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include "header.h"
|
||||
|
@ -763,7 +763,8 @@ cursors()
|
|||
* obvious meanings.
|
||||
*/
|
||||
|
||||
static char cap[256];
|
||||
static char *cap;
|
||||
struct tinfo *info;
|
||||
char *CM, *CE, *CD, *CL, *SO, *SE, *AL, *DL; /* Termcap capabilities */
|
||||
static char *outbuf = 0; /* translated output buffer */
|
||||
|
||||
|
@ -773,11 +774,11 @@ static char *outbuf = 0; /* translated output buffer */
|
|||
void
|
||||
init_term()
|
||||
{
|
||||
char termbuf[1024];
|
||||
char *capptr = cap + 10;
|
||||
char *capptr;
|
||||
char *term;
|
||||
|
||||
switch (tgetent(termbuf, term = getenv("TERM"))) {
|
||||
*cap = NULL;
|
||||
switch (t_getent(&info, term = getenv("TERM"))) {
|
||||
case -1:
|
||||
write(2, "Cannot open termcap file.\n", 26);
|
||||
exit(1);
|
||||
|
@ -788,16 +789,16 @@ init_term()
|
|||
exit(1);
|
||||
};
|
||||
|
||||
CM = tgetstr("cm", &capptr); /* Cursor motion */
|
||||
CE = tgetstr("ce", &capptr); /* Clear to eoln */
|
||||
CL = tgetstr("cl", &capptr); /* Clear screen */
|
||||
CM = t_agetstr(info, "cm", &cap, &capptr); /* Cursor motion */
|
||||
CE = t_agetstr(info, "ce", &cap, &capptr); /* Clear to eoln */
|
||||
CL = t_agetstr(info, "cl", &cap, &capptr); /* Clear screen */
|
||||
|
||||
/* OPTIONAL */
|
||||
AL = tgetstr("al", &capptr); /* Insert line */
|
||||
DL = tgetstr("dl", &capptr); /* Delete line */
|
||||
SO = tgetstr("so", &capptr); /* Begin standout mode */
|
||||
SE = tgetstr("se", &capptr); /* End standout mode */
|
||||
CD = tgetstr("cd", &capptr); /* Clear to end of display */
|
||||
AL = t_agetstr(info, "al", &cap, &capptr); /* Insert line */
|
||||
DL = t_agetstr(info, "dl", &cap, &capptr); /* Delete line */
|
||||
SO = t_agetstr(info, "so", &cap, &capptr); /* Begin standout mode */
|
||||
SE = t_agetstr(info, "se", &cap, &capptr); /* End standout mode */
|
||||
CD = t_agetstr(info, "cd", &cap, &capptr); /* Clear to end of display */
|
||||
|
||||
if (!CM) { /* can't find cursor motion entry */
|
||||
write(2, "Sorry, for a ", 13);
|
||||
|
@ -936,6 +937,7 @@ lflush()
|
|||
u_char *str;
|
||||
static int curx = 0;
|
||||
static int cury = 0;
|
||||
char tgoto_buf[256];
|
||||
|
||||
if ((lpoint = lpnt - lpbuf) > 0) {
|
||||
#ifdef EXTRA
|
||||
|
@ -978,7 +980,9 @@ lflush()
|
|||
case CURSOR:
|
||||
curx = *++str - 1;
|
||||
cury = *++str - 1;
|
||||
tputs(tgoto(CM, curx, cury), 0, xputchar);
|
||||
if (t_goto(info, CM, curx, cury,
|
||||
tgoto_buf, 255) == 0)
|
||||
tputs(tgoto_buf, 0, xputchar);
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
|
@ -989,17 +993,41 @@ lflush()
|
|||
|
||||
if (++scrline > 23)
|
||||
scrline = 19;
|
||||
tputs(tgoto(CM, 0, scrline), 0, xputchar);
|
||||
if (t_goto(info, CM, 0,
|
||||
scrline,
|
||||
tgoto_buf,
|
||||
255) == 0)
|
||||
tputs(tgoto_buf,
|
||||
0,
|
||||
xputchar);
|
||||
tputs(CE, 0, xputchar);
|
||||
|
||||
if (--scrline < 19)
|
||||
scrline = 23;
|
||||
tputs(tgoto(CM, 0, scrline), 0, xputchar);
|
||||
if (t_goto(info, CM, 0,
|
||||
scrline,
|
||||
tgoto_buf,
|
||||
255) == 0)
|
||||
tputs(tgoto_buf,
|
||||
0,
|
||||
xputchar);
|
||||
tputs(CE, 0, xputchar);
|
||||
} else {
|
||||
tputs(tgoto(CM, 0, 19), 0, xputchar);
|
||||
if (t_goto(info, CM, 0,
|
||||
19,
|
||||
tgoto_buf,
|
||||
255) == 0)
|
||||
tputs(tgoto_buf,
|
||||
0,
|
||||
xputchar);
|
||||
tputs(DL, 0, xputchar);
|
||||
tputs(tgoto(CM, 0, 23), 0, xputchar);
|
||||
if (t_goto(info, CM, 0,
|
||||
23,
|
||||
tgoto_buf,
|
||||
255) == 0)
|
||||
tputs(tgoto_buf,
|
||||
0,
|
||||
xputchar);
|
||||
/*
|
||||
* tputs (AL, 0,
|
||||
* xputchar);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* $NetBSD: main.c,v 1.14 1998/08/30 09:19:38 veego Exp $ */
|
||||
/* $NetBSD: main.c,v 1.15 2000/05/22 12:42:46 blymn Exp $ */
|
||||
|
||||
/* main.c */
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: main.c,v 1.14 1998/08/30 09:19:38 veego Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.15 2000/05/22 12:42:46 blymn Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -62,6 +62,7 @@ main(argc, argv)
|
|||
const char *ptr = 0;
|
||||
struct passwd *pwe;
|
||||
|
||||
i = 0;
|
||||
euid = geteuid();
|
||||
uid = getuid();
|
||||
seteuid(uid); /* give up "games" if we have it */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: screen.c,v 1.13 1999/10/04 23:27:03 lukem Exp $ */
|
||||
/* $NetBSD: screen.c,v 1.14 2000/05/22 12:42:47 blymn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -73,7 +73,6 @@ static void stopset __P((int)) __attribute__((__noreturn__));
|
|||
/*
|
||||
* Capabilities from TERMCAP.
|
||||
*/
|
||||
char PC, *BC, *UP; /* tgoto requires globals: ugh! */
|
||||
short ospeed;
|
||||
|
||||
static char
|
||||
|
@ -121,8 +120,8 @@ struct tcsinfo { /* termcap string info; some abbrevs above */
|
|||
|
||||
/* This is where we will actually stuff the information */
|
||||
|
||||
static char combuf[1024], tbuf[1024];
|
||||
|
||||
static char *combuf;
|
||||
static struct tinfo *info;
|
||||
|
||||
/*
|
||||
* Routine used by tputs().
|
||||
|
@ -141,7 +140,15 @@ put(c)
|
|||
* count=1. (See screen.h for putpad().)
|
||||
*/
|
||||
#define putstr(s) (void)fputs(s, stdout)
|
||||
#define moveto(r, c) putpad(tgoto(CMstr, c, r))
|
||||
|
||||
void
|
||||
moveto(int r, int c)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
if (t_goto(info, CMstr, c, r, buf, 255) == 0)
|
||||
putpad(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up from termcap.
|
||||
|
@ -174,22 +181,23 @@ scr_init()
|
|||
|
||||
if ((term = getenv("TERM")) == NULL)
|
||||
stop("you must set the TERM environment variable");
|
||||
if (tgetent(tbuf, term) <= 0)
|
||||
if (t_getent(&info, term) <= 0)
|
||||
stop("cannot find your termcap");
|
||||
fill = combuf;
|
||||
*combuf = NULL;
|
||||
{
|
||||
register struct tcsinfo *p;
|
||||
|
||||
for (p = tcstrings; p->tcaddr; p++)
|
||||
*p->tcaddr = tgetstr(p->tcname, &fill);
|
||||
*p->tcaddr = t_agetstr(info, p->tcname, &combuf,
|
||||
&fill);
|
||||
}
|
||||
{
|
||||
register struct tcninfo *p;
|
||||
|
||||
for (p = tcflags; p->tcaddr; p++)
|
||||
*p->tcaddr = tgetflag(p->tcname);
|
||||
*p->tcaddr = t_getflag(info, p->tcname);
|
||||
for (p = tcnums; p->tcaddr; p++)
|
||||
*p->tcaddr = tgetnum(p->tcname);
|
||||
*p->tcaddr = t_getnum(info, p->tcname);
|
||||
}
|
||||
if (bsflag)
|
||||
BC = "\b";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: screen.h,v 1.5 2000/01/01 10:15:17 jsm Exp $ */
|
||||
/* $NetBSD: screen.h,v 1.6 2000/05/22 12:42:48 blymn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -49,6 +49,7 @@ extern char *SOstr; /* begin standout mode */
|
|||
*/
|
||||
#define putpad(s) tputs(s, 1, put)
|
||||
|
||||
void moveto(int, int);
|
||||
int put __P((int)); /* just calls putchar; for tputs */
|
||||
void scr_clear __P((void));
|
||||
void scr_end __P((void));
|
||||
|
|
Loading…
Reference in New Issue