diff options
author | mycroft <mycroft@NetBSD.org> | 1995-04-29 00:06:37 +0000 |
---|---|---|
committer | mycroft <mycroft@NetBSD.org> | 1995-04-29 00:06:37 +0000 |
commit | 567e3567cfbbfd9940e7ac02313f241710d726c7 (patch) | |
tree | 228d88f95f9cb70b08cc3ed2f05568c249107c86 /snake | |
parent | 8f72a779d994431bcdc39e53f57c7984396f3e22 (diff) | |
download | bsdgames-darwin-567e3567cfbbfd9940e7ac02313f241710d726c7.tar.gz bsdgames-darwin-567e3567cfbbfd9940e7ac02313f241710d726c7.tar.zst bsdgames-darwin-567e3567cfbbfd9940e7ac02313f241710d726c7.zip |
Use POSIX tty semantics.
Diffstat (limited to 'snake')
-rw-r--r-- | snake/snake/move.c | 53 | ||||
-rw-r--r-- | snake/snake/snake.c | 9 | ||||
-rw-r--r-- | snake/snake/snake.h | 10 |
3 files changed, 21 insertions, 51 deletions
diff --git a/snake/snake/move.c b/snake/snake/move.c index 5e72dac2..993c1636 100644 --- a/snake/snake/move.c +++ b/snake/snake/move.c @@ -1,4 +1,4 @@ -/* $NetBSD: move.c,v 1.9 1995/04/22 10:16:04 cgd Exp $ */ +/* $NetBSD: move.c,v 1.10 1995/04/29 00:06:37 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 7/19/93"; #else -static char rcsid[] = "$NetBSD: move.c,v 1.9 1995/04/22 10:16:04 cgd Exp $"; +static char rcsid[] = "$NetBSD: move.c,v 1.10 1995/04/29 00:06:37 mycroft Exp $"; #endif #endif /* not lint */ @@ -90,7 +90,6 @@ static char rcsid[] = "$NetBSD: move.c,v 1.9 1995/04/22 10:16:04 cgd Exp $"; * * point(&p,x,y) return point set to x,y. * - * baudrate(x) returns the baudrate of the terminal. * delay(t) causes an approximately constant delay * independent of baudrate. * Duration is ~ t/20 seconds. @@ -511,28 +510,12 @@ char *str; if (str) tputs(str, 1, outch); } -baudrate() -{ - - switch (orig.sg_ospeed){ - case B300: - return(300); - case B1200: - return(1200); - case B4800: - return(4800); - case B9600: - return(9600); - default: - return(0); - } -} delay(t) int t; { int k,j; - k = baudrate() * t / 300; + k = ospeed * t / 300; for(j=0;j<k;j++){ putchar(PC); } @@ -550,18 +533,12 @@ cook() putpad(TE); putpad(KE); fflush(stdout); - stty(0, &orig); -#ifdef TIOCSLTC - ioctl(0, TIOCSLTC, &olttyc); -#endif + tcsetattr(0, TCSADRAIN, &orig); } raw() { - stty(0, &new); -#ifdef TIOCSLTC - ioctl(0, TIOCSLTC, &nlttyc); -#endif + tcsetattr(0, TCSADRAIN, &new); } struct point *point(ps,x,y) @@ -682,21 +659,17 @@ getcap() exit(5); } - gtty(0, &orig); - new=orig; - new.sg_flags &= ~(ECHO|CRMOD|ALLDELAY|XTABS); - new.sg_flags |= CBREAK; + tcgetattr(0, &orig); + new = orig; + new.c_lflag &= ~(ECHO|ICANON); + new.c_oflag &= ~(ONLCR|OXTABS); signal(SIGINT,stop); - ospeed = orig.sg_ospeed; -#ifdef TIOCGLTC - ioctl(0, TIOCGLTC, &olttyc); - nlttyc = olttyc; - nlttyc.t_suspc = '\377'; - nlttyc.t_dsuspc = '\377'; -#endif + ospeed = cfgetospeed(&orig); + new.c_cc[VSUSP] = _POSIX_VDISABLE; + new.c_cc[VDSUSP] = _POSIX_VDISABLE; raw(); - if ((orig.sg_flags & XTABS) == XTABS) TA=0; + if (orig.c_oflag & OXTABS) TA=0; putpad(KS); putpad(TI); point(&cursor,0,LINES-1); diff --git a/snake/snake/snake.c b/snake/snake/snake.c index 089121cc..db69aefa 100644 --- a/snake/snake/snake.c +++ b/snake/snake/snake.c @@ -1,4 +1,4 @@ -/* $NetBSD: snake.c,v 1.7 1995/04/24 12:25:34 cgd Exp $ */ +/* $NetBSD: snake.c,v 1.8 1995/04/29 00:06:41 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)snake.c 8.2 (Berkeley) 1/7/94"; #else -static char rcsid[] = "$NetBSD: snake.c,v 1.7 1995/04/24 12:25:34 cgd Exp $"; +static char rcsid[] = "$NetBSD: snake.c,v 1.8 1995/04/29 00:06:41 mycroft Exp $"; #endif #endif /* not lint */ @@ -173,8 +173,7 @@ char **argv; snrand(&money); snrand(&snake[0]); - if ((orig.sg_ospeed < B9600) || - ((! CM) && (! TA))) fast=0; + if (ospeed < 9600 || ((! CM) && (! TA))) fast=0; for(i=1;i<6;i++) chase (&snake[i], &snake[i-1]); setup(); @@ -528,7 +527,7 @@ int iscore, flag; */ flushi() { - stty(0, &new); + tcflush(0, TCIFLUSH); } int mx [8] = { 0, 1, 1, 1, 0,-1,-1,-1}; diff --git a/snake/snake/snake.h b/snake/snake/snake.h index fda11923..3543fd16 100644 --- a/snake/snake/snake.h +++ b/snake/snake/snake.h @@ -1,4 +1,4 @@ -/* $NetBSD: snake.h,v 1.4 1995/04/24 12:25:38 cgd Exp $ */ +/* $NetBSD: snake.h,v 1.5 1995/04/29 00:06:43 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,8 +39,8 @@ # include <string.h> # include <assert.h> # include <sys/types.h> -# include <sgtty.h> # include <signal.h> +# include <termios.h> # include <math.h> #define ESC '\033' @@ -62,6 +62,7 @@ char tbuf[1024], tcapbuf[128]; char *tgetstr(), *tgoto(); int Klength; /* length of KX strings */ int chunk; /* amount of money given at a time */ +short ospeed; #ifdef debug #define cashvalue (loot-penalty)/25 #else @@ -72,10 +73,7 @@ struct point { int col, line; }; struct point cursor; -struct sgttyb orig, new; -#ifdef TIOCLGET -struct ltchars olttyc, nlttyc; -#endif +struct termios orig, new; struct point *point(); #if __STDC__ void apr(struct point *, const char *, ...); |