summaryrefslogtreecommitdiffstats
path: root/hunt
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2009-07-04 07:10:22 +0000
committerdholland <dholland@NetBSD.org>2009-07-04 07:10:22 +0000
commit2e8daf459306ea1d8374438d469f60aa0149aa32 (patch)
treef8ac868239c10468429ad0ae7a90a340de2c89d3 /hunt
parent90a7b8b0ddece21340e896e8cec8e3f8ef4383d3 (diff)
downloadbsdgames-darwin-2e8daf459306ea1d8374438d469f60aa0149aa32.tar.gz
bsdgames-darwin-2e8daf459306ea1d8374438d469f60aa0149aa32.tar.zst
bsdgames-darwin-2e8daf459306ea1d8374438d469f60aa0149aa32.zip
Remove the non-curses screen handling, since it relies on knowing
about various internals of SVR4 curses, old BSD curses, and/or other unclean things. (Yes, the non-curses handling still used bits of curses. Fie.)
Diffstat (limited to 'hunt')
-rw-r--r--hunt/Makefile.inc10
-rw-r--r--hunt/hunt/hunt.c138
-rw-r--r--hunt/hunt/otto.c9
-rw-r--r--hunt/hunt/playit.c194
-rw-r--r--hunt/huntd/hunt.h9
5 files changed, 14 insertions, 346 deletions
diff --git a/hunt/Makefile.inc b/hunt/Makefile.inc
index 7d64e776..409a49c0 100644
--- a/hunt/Makefile.inc
+++ b/hunt/Makefile.inc
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.9 2009/07/04 06:38:34 dholland Exp $
+# $NetBSD: Makefile.inc,v 1.10 2009/07/04 07:10:22 dholland Exp $
#
#
# Hunt
@@ -55,21 +55,19 @@ GAME_PARAM= -DRANDOM -DREFLECT -DMONITOR -DOOZE -DFLY -DVOLCANO -DBOOTS \
# LOG Use syslog error-logging in driver
# OLDIPC Use 4.1a internet system calls (must also define
# INTERNET)
-# TERMINFO Use terminfo instead of termcap
# LOG Use syslog(3) for logging errors
# BSD_RELEASE Which version of BSD distribution
# 42 is 4.2BSD
# 43 is 4.3BSD (implies BROADCAST)
-# USE_CURSES Use curses for everything (automatic w/TERMINFO)
# HPUX do special HPUX only hacks
#
DEFS_BSD43= -DINTERNET -DLOG -DBSD_RELEASE=43
-DEFS_BSD44= -DINTERNET -DLOG -DBSD_RELEASE=44 -DUSE_CURSES
+DEFS_BSD44= -DINTERNET -DLOG -DBSD_RELEASE=44
DEFS_SUN= -DINTERNET -DLOG -DBSD_RELEASE=42 -DBROADCAST
DEFS_SUN4_0= -DINTERNET -DLOG -DBROADCAST
DEFS_ULTRIX= -DINTERNET -DLOG -DBSD_RELEASE=42
-DEFS_HPUX= -DHPUX -DINTERNET -DLOG -DBROADCAST -DTERMINFO
-DEFS_SGI= -DINTERNET -DLOG -DBSD_RELEASE=43 -DTERMINFO
+DEFS_HPUX= -DHPUX -DINTERNET -DLOG -DBROADCAST
+DEFS_SGI= -DINTERNET -DLOG -DBSD_RELEASE=43
DEFS_NEXT= $(DEFS_BSD43) -bsd -Dconst=
DEFS_OSF1= -DINTERNET -DLOG -DBSD_RELEASE=43 -D_BSD
diff --git a/hunt/hunt/hunt.c b/hunt/hunt/hunt.c
index 291f50d5..8a6788a5 100644
--- a/hunt/hunt/hunt.c
+++ b/hunt/hunt/hunt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hunt.c,v 1.33 2009/07/04 06:38:34 dholland Exp $ */
+/* $NetBSD: hunt.c,v 1.34 2009/07/04 07:10:23 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hunt.c,v 1.33 2009/07/04 06:38:34 dholland Exp $");
+__RCSID("$NetBSD: hunt.c,v 1.34 2009/07/04 07:10:23 dholland Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -46,10 +46,6 @@ __RCSID("$NetBSD: hunt.c,v 1.33 2009/07/04 06:38:34 dholland Exp $");
#include <signal.h>
#include <stdlib.h>
#include <string.h>
-#if !defined(USE_CURSES) && defined(BSD_RELEASE) && BSD_RELEASE >= 44
-#include <termios.h>
-static struct termios saved_tty;
-#endif
#include <unistd.h>
#include <ifaddrs.h>
@@ -62,18 +58,9 @@ static struct termios saved_tty;
#define cbreak() crmode()
#endif
-#if !defined(USE_CURSES) || !defined(TERMINFO)
-#define beep() (void) putchar(CTRL('G'))
-#endif
-#if !defined(USE_CURSES)
-#undef refresh
-#define refresh() (void) fflush(stdout);
-#endif
-#ifdef USE_CURSES
#define clear_eol() clrtoeol()
#define put_ch addch
#define put_str addstr
-#endif
FLAG Last_player = FALSE;
#ifdef MONITOR
@@ -256,25 +243,10 @@ main(int ac, char **av)
(void) fflush(stdout);
if (!isatty(0) || (term = getenv("TERM")) == NULL)
errx(1, "no terminal type");
-#ifdef USE_CURSES
if (!initscr())
errx(0, "couldn't initialize screen");
(void) noecho();
(void) cbreak();
-#else /* !USE_CURSES */
-#if !defined(BSD_RELEASE) || BSD_RELEASE < 44
- _tty_ch = 0;
-#endif
- gettmode();
- (void) setterm(term);
- (void) noecho();
- (void) cbreak();
-#if defined(BSD_RELEASE) && BSD_RELEASE >= 44
- tcgetattr(0, &saved_tty);
-#endif
- _puts(TI);
- _puts(VS);
-#endif /* !USE_CURSES */
in_visual = TRUE;
if (LINES < SCREEN_HEIGHT || COLS < SCREEN_WIDTH)
leavex(1, "Need a larger window");
@@ -283,9 +255,6 @@ main(int ac, char **av)
(void) signal(SIGTERM, sigterm);
(void) signal(SIGUSR1, sigusr1);
(void) signal(SIGPIPE, SIG_IGN);
-#if !defined(USE_CURSES) && defined(SIGTSTP)
- (void) signal(SIGTSTP, tstp);
-#endif
for (;;) {
#ifdef INTERNET
@@ -582,26 +551,14 @@ find_driver(FLAG do_startup)
}
/* go thru list and return host that matches daemon */
clear_the_screen();
-#ifdef USE_CURSES
move(1, 0);
-#else
- mvcur(cur_row, cur_col, 1, 0);
- cur_row = 1;
- cur_col = 0;
-#endif
put_str("Pick one:");
for (i = 0; i < HEIGHT - 4 && hosts[i].sin_port != htons(0);
i += 1) {
struct hostent *hp;
char buf[80];
-#ifdef USE_CURSES
move(3 + i, 0);
-#else
- mvcur(cur_row, cur_col, 3 + i, 0);
- cur_row = 3 + i;
- cur_col = 0;
-#endif
hp = gethostbyaddr((char *) &hosts[i].sin_addr,
sizeof hosts[i].sin_addr, AF_INET);
(void) snprintf(buf, sizeof(buf),
@@ -610,13 +567,7 @@ find_driver(FLAG do_startup)
: inet_ntoa(hosts->sin_addr));
put_str(buf);
}
-#ifdef USE_CURSES
move(4 + i, 0);
-#else
- mvcur(cur_row, cur_col, 4 + i, 0);
- cur_row = 4 + i;
- cur_col = 0;
-#endif
put_str("Enter letter: ");
refresh();
while (!islower(c = getchar()) || (c -= 'a') >= i) {
@@ -679,13 +630,7 @@ start_driver(void)
}
#endif
-#ifdef USE_CURSES
move(HEIGHT, 0);
-#else
- mvcur(cur_row, cur_col, HEIGHT, 0);
- cur_row = HEIGHT;
- cur_col = 0;
-#endif
put_str("Starting...");
refresh();
procid = fork();
@@ -708,13 +653,7 @@ start_driver(void)
(void) kill(getppid(), SIGUSR1); /* tell mom */
_exit(1);
}
-#ifdef USE_CURSES
move(HEIGHT, 0);
-#else
- mvcur(cur_row, cur_col, HEIGHT, 0);
- cur_row = HEIGHT;
- cur_col = 0;
-#endif
put_str("Connecting...");
refresh();
}
@@ -803,16 +742,8 @@ intr(int dummy __unused)
int y, x;
(void) signal(SIGINT, SIG_IGN);
-#ifdef USE_CURSES
getyx(stdscr, y, x);
move(HEIGHT, 0);
-#else
- y = cur_row;
- x = cur_col;
- mvcur(cur_row, cur_col, HEIGHT, 0);
- cur_row = HEIGHT;
- cur_col = 0;
-#endif
put_str("Really quit? ");
clear_eol();
refresh();
@@ -830,13 +761,7 @@ intr(int dummy __unused)
}
else if (ch == 'n') {
(void) signal(SIGINT, intr);
-#ifdef USE_CURSES
move(y, x);
-#else
- mvcur(cur_row, cur_col, y, x);
- cur_row = y;
- cur_col = x;
-#endif
refresh();
return;
}
@@ -854,21 +779,9 @@ void
fincurs(void)
{
if (in_visual) {
-#ifdef USE_CURSES
move(HEIGHT, 0);
refresh();
endwin();
-#else /* !USE_CURSES */
- mvcur(cur_row, cur_col, HEIGHT, 0);
- (void) fflush(stdout); /* flush in case VE changes pages */
-#if defined(BSD_RELEASE) && BSD_RELEASE >= 44
- tcsetattr(0, TCSADRAIN, &__orig_termios);
-#else
- resetty();
-#endif
- _puts(VE);
- _puts(TE);
-#endif /* !USE_CURSES */
}
}
@@ -898,53 +811,6 @@ leavex(int eval, const char *mesg)
errx(eval, mesg ? mesg : "");
}
-#if !defined(USE_CURSES) && defined(SIGTSTP)
-/*
- * tstp:
- * Handle stop and start signals
- */
-void
-tstp(int dummy __unused)
-{
-#if BSD_RELEASE < 44
- static struct sgttyb tty;
-#endif
- int y, x;
-
- y = cur_row;
- x = cur_col;
- mvcur(cur_row, cur_col, HEIGHT, 0);
- cur_row = HEIGHT;
- cur_col = 0;
-#if !defined(BSD_RELEASE) || BSD_RELEASE < 44
- tty = _tty;
-#endif
- _puts(VE);
- _puts(TE);
- (void) fflush(stdout);
-#if defined(BSD_RELEASE) && BSD_RELEASE >= 44
- tcsetattr(0, TCSADRAIN, &__orig_termios);
-#else
- resetty();
-#endif
- (void) kill(getpid(), SIGSTOP);
- (void) signal(SIGTSTP, tstp);
-#if defined(BSD_RELEASE) && BSD_RELEASE >= 44
- tcsetattr(0, TCSADRAIN, &saved_tty);
-#else
- _tty = tty;
- ioctl(_tty_ch, TIOCSETP, &_tty);
-#endif
- _puts(TI);
- _puts(VS);
- cur_row = y;
- cur_col = x;
- _puts(tgoto(CM, cur_row, cur_col));
- redraw_screen();
- (void) fflush(stdout);
-}
-#endif /* !defined(USE_CURSES) && defined(SIGTSTP) */
-
#if defined(BSD_RELEASE) && BSD_RELEASE < 43
char *
strpbrk(char *s, char *brk)
diff --git a/hunt/hunt/otto.c b/hunt/hunt/otto.c
index 47dd0383..8c163b47 100644
--- a/hunt/hunt/otto.c
+++ b/hunt/hunt/otto.c
@@ -1,4 +1,4 @@
-/* $NetBSD: otto.c,v 1.14 2009/07/04 06:38:34 dholland Exp $ */
+/* $NetBSD: otto.c,v 1.15 2009/07/04 07:10:23 dholland Exp $ */
#ifdef OTTO
/*
* Copyright (c) 1983-2003, Regents of the University of California.
@@ -45,7 +45,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: otto.c,v 1.14 2009/07/04 06:38:34 dholland Exp $");
+__RCSID("$NetBSD: otto.c,v 1.15 2009/07/04 07:10:23 dholland Exp $");
#endif /* not lint */
#include <sys/time.h>
@@ -70,12 +70,7 @@ __RCSID("$NetBSD: otto.c,v 1.14 2009/07/04 06:38:34 dholland Exp $");
#define random rand
#endif
-#ifndef USE_CURSES
-extern char screen[SCREEN_HEIGHT][SCREEN_WIDTH2];
-#define SCREEN(y, x) screen[y][x]
-#else
#define SCREEN(y, x) mvinch(y, x)
-#endif
#ifndef DEBUG
#define STATIC static
diff --git a/hunt/hunt/playit.c b/hunt/hunt/playit.c
index 34393fa9..da35d564 100644
--- a/hunt/hunt/playit.c
+++ b/hunt/hunt/playit.c
@@ -1,4 +1,4 @@
-/* $NetBSD: playit.c,v 1.12 2009/07/04 05:01:16 dholland Exp $ */
+/* $NetBSD: playit.c,v 1.13 2009/07/04 07:10:23 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: playit.c,v 1.12 2009/07/04 05:01:16 dholland Exp $");
+__RCSID("$NetBSD: playit.c,v 1.13 2009/07/04 07:10:23 dholland Exp $");
#endif /* not lint */
#include <sys/file.h>
@@ -52,24 +52,11 @@ __RCSID("$NetBSD: playit.c,v 1.12 2009/07/04 05:01:16 dholland Exp $");
#define FREAD 1
#endif
-#if !defined(USE_CURSES) || !defined(TERMINFO)
-#define beep() (void) putchar(CTRL('G'))
-#endif
-#if !defined(USE_CURSES)
-#undef refresh
-#define refresh() (void) fflush(stdout);
-#endif
-#ifdef USE_CURSES
#define clear_eol() clrtoeol()
#define put_ch addch
#define put_str addstr
-#endif
static int nchar_send;
-#ifndef USE_CURSES
-char screen[SCREEN_HEIGHT][SCREEN_WIDTH2], blanks[SCREEN_WIDTH];
-int cur_row, cur_col;
-#endif
#ifdef OTTO
int Otto_count;
int Otto_mode;
@@ -130,13 +117,7 @@ playit(void)
case MOVE:
y = GETCHR();
x = GETCHR();
-#ifdef USE_CURSES
move(y, x);
-#else
- mvcur(cur_row, cur_col, y, x);
- cur_row = y;
- cur_col = x;
-#endif
break;
case ADDCH:
ch = GETCHR();
@@ -148,12 +129,7 @@ playit(void)
case '^':
case 'v':
otto_face = ch;
-#ifdef USE_CURSES
getyx(stdscr, otto_y, otto_x);
-#else
- otto_y = cur_row;
- otto_x = cur_col;
-#endif
break;
}
#endif
@@ -216,12 +192,7 @@ playit(void)
case '^':
case 'v':
otto_face = ch;
-#ifdef USE_CURSES
getyx(stdscr, otto_y, otto_x);
-#else
- otto_y = cur_row;
- otto_x = cur_col;
-#endif
break;
}
#endif
@@ -331,13 +302,7 @@ quit(int old_status)
if (Otto_mode)
return Q_CLOAK;
#endif
-#ifdef USE_CURSES
move(HEIGHT, 0);
-#else
- mvcur(cur_row, cur_col, HEIGHT, 0);
- cur_row = HEIGHT;
- cur_col = 0;
-#endif
put_str("Re-enter game [ynwo]? ");
clear_eol();
explain = FALSE;
@@ -353,13 +318,7 @@ quit(int old_status)
#ifndef INTERNET
return Q_QUIT;
#else
-#ifdef USE_CURSES
move(HEIGHT, 0);
-#else
- mvcur(cur_row, cur_col, HEIGHT, 0);
- cur_row = HEIGHT;
- cur_col = 0;
-#endif
put_str("Write a parting message [yn]? ");
clear_eol();
refresh();
@@ -380,13 +339,7 @@ quit(int old_status)
get_message:
c = ch; /* save how we got here */
-#ifdef USE_CURSES
move(HEIGHT, 0);
-#else
- mvcur(cur_row, cur_col, HEIGHT, 0);
- cur_row = HEIGHT;
- cur_col = 0;
-#endif
put_str("Message: ");
clear_eol();
refresh();
@@ -395,42 +348,30 @@ get_message:
refresh();
if ((ch = getchar()) == '\n' || ch == '\r')
break;
-#if defined(TERMINFO) || BSD_RELEASE >= 44
+#if BSD_RELEASE >= 44
if (ch == erasechar())
#else
if (ch == _tty.sg_erase)
#endif
{
if (cp > buf) {
-#ifdef USE_CURSES
int y, x;
getyx(stdscr, y, x);
move(y, x - 1);
-#else
- mvcur(cur_row, cur_col, cur_row,
- cur_col - 1);
- cur_col -= 1;
-#endif
cp -= 1;
clear_eol();
}
continue;
}
-#if defined(TERMINFO) || BSD_RELEASE >= 44
+#if BSD_RELEASE >= 44
else if (ch == killchar())
#else
else if (ch == _tty.sg_kill)
#endif
{
-#ifdef USE_CURSES
int y, x;
getyx(stdscr, y, x);
move(y, x - (cp - buf));
-#else
- mvcur(cur_row, cur_col, cur_row,
- cur_col - (cp - buf));
- cur_col -= cp - buf;
-#endif
cp = buf;
clear_eol();
continue;
@@ -455,13 +396,7 @@ get_message:
}
}
-#ifdef USE_CURSES
move(HEIGHT, 0);
-#else
- mvcur(cur_row, cur_col, HEIGHT, 0);
- cur_row = HEIGHT;
- cur_col = 0;
-#endif
#ifdef FLY
put_str("Scan, Cloak, Flying, or Quit? ");
#else
@@ -496,140 +431,19 @@ get_message:
}
}
-#ifndef USE_CURSES
-void
-put_ch(char ch)
-{
- if (!isprint(ch)) {
- fprintf(stderr, "r,c,ch: %d,%d,%d", cur_row, cur_col, ch);
- return;
- }
- screen[cur_row][cur_col] = ch;
- putchar(ch);
- if (++cur_col >= COLS) {
- if (!AM || XN)
- putchar('\n');
- cur_col = 0;
- if (++cur_row >= LINES)
- cur_row = LINES;
- }
-}
-
-void
-put_str(char *s)
-{
- while (*s)
- put_ch(*s++);
-}
-#endif
-
void
clear_the_screen(void)
{
-#ifdef USE_CURSES
clear();
move(0, 0);
refresh();
-#else
- int i;
-
- if (blanks[0] == '\0')
- for (i = 0; i < SCREEN_WIDTH; i++)
- blanks[i] = ' ';
-
- if (CL != NULL) {
-#if !defined(BSD_RELEASE) || BSD_RELEASE < 44
- tputs(CL, LINES, _putchar);
-#else
- tputs(CL, LINES, __cputchar);
-#endif
- for (i = 0; i < SCREEN_HEIGHT; i++)
- memcpy(screen[i], blanks, SCREEN_WIDTH);
- } else {
- for (i = 0; i < SCREEN_HEIGHT; i++) {
- mvcur(cur_row, cur_col, i, 0);
- cur_row = i;
- cur_col = 0;
- clear_eol();
- }
- mvcur(cur_row, cur_col, 0, 0);
- }
- cur_row = cur_col = 0;
-#endif
}
-#ifndef USE_CURSES
-void
-clear_eol(void)
-{
- if (CE != NULL)
-#if !defined(BSD_RELEASE) || BSD_RELEASE < 44
- tputs(CE, 1, _putchar);
-#else
- tputs(CE, 1, __cputchar);
-#endif
- else {
- fwrite(blanks, sizeof (char), SCREEN_WIDTH - cur_col, stdout);
- if (COLS != SCREEN_WIDTH)
- mvcur(cur_row, SCREEN_WIDTH, cur_row, cur_col);
- else if (AM)
- mvcur(cur_row + 1, 0, cur_row, cur_col);
- else
- mvcur(cur_row, SCREEN_WIDTH - 1, cur_row, cur_col);
- }
- memcpy(&screen[cur_row][cur_col], blanks, SCREEN_WIDTH - cur_col);
-}
-#endif
-
void
redraw_screen(void)
{
-#ifdef USE_CURSES
clearok(stdscr, TRUE);
touchwin(stdscr);
-#else
- int i;
-#ifndef NOCURSES
- static int first = 1;
-
- if (first) {
- curscr = newwin(SCREEN_HEIGHT, SCREEN_WIDTH, 0, 0);
- if (curscr == NULL)
- errx(1, "Can't create curscr");
-#if !defined(BSD_RELEASE) || BSD_RELEASE < 44
- for (i = 0; i < SCREEN_HEIGHT; i++)
- curscr->_y[i] = screen[i];
-#endif
- first = 0;
- }
-#if defined(BSD_RELEASE) && BSD_RELEASE >= 44
- for (i = 0; i < SCREEN_HEIGHT; i++) {
- int j;
-
- for (j = 0; j < SCREEN_WIDTH; j++)
- curscr->lines[i]->line[j].ch = screen[i][j];
- }
- curscr->cury = cur_row;
- curscr->curx = cur_col;
-#else
- curscr->_cury = cur_row;
- curscr->_curx = cur_col;
-#endif
- clearok(curscr, TRUE);
- touchwin(curscr);
- wrefresh(curscr);
-#else
- mvcur(cur_row, cur_col, 0, 0);
- for (i = 0; i < SCREEN_HEIGHT - 1; i++) {
- fwrite(screen[i], sizeof (char), SCREEN_WIDTH, stdout);
- if (COLS > SCREEN_WIDTH || (COLS == SCREEN_WIDTH && !AM))
- putchar('\n');
- }
- fwrite(screen[SCREEN_HEIGHT - 1], sizeof (char), SCREEN_WIDTH - 1,
- stdout);
- mvcur(SCREEN_HEIGHT - 1, SCREEN_WIDTH - 1, cur_row, cur_col);
-#endif
-#endif
}
/*
diff --git a/hunt/huntd/hunt.h b/hunt/huntd/hunt.h
index 1b98b276..49b8c0e5 100644
--- a/hunt/huntd/hunt.h
+++ b/hunt/huntd/hunt.h
@@ -1,4 +1,4 @@
-/* $NetBSD: hunt.h,v 1.16 2009/07/04 06:38:35 dholland Exp $ */
+/* $NetBSD: hunt.h,v 1.17 2009/07/04 07:10:23 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
@@ -40,7 +40,7 @@
#include <syslog.h>
#endif
-#if !defined(TERMINFO) && BSD_RELEASE < 44
+#if BSD_RELEASE < 44
#include <sgtty.h>
#else
#include <sys/ioctl.h>
@@ -80,11 +80,6 @@
#if !defined(REFLECT) && !defined(RANDOM)
#define RANDOM
#endif
-#ifdef TERMINFO
-/* mvcur() in terminfo needs the curses library to be initialized to not
- * coredump, so give up and use it. */
-#define USE_CURSES
-#endif
/* decrement version number for each change in startup protocol */
#define HUNT_VERSION -1