diff --git a/games/backgammon/backgammon/Makefile b/games/backgammon/backgammon/Makefile index 033527b..9500749 100644 --- a/games/backgammon/backgammon/Makefile +++ b/games/backgammon/backgammon/Makefile @@ -3,7 +3,7 @@ # $DragonFly: src/games/backgammon/backgammon/Makefile,v 1.4 2006/10/08 16:22:35 pavalos Exp $ PROG= backgammon -CFLAGS+=-DV7 -I${.CURDIR}/../common_source +CFLAGS+=-I${.CURDIR}/../common_source SRCS= allow.c board.c check.c extra.c fancy.c init.c main.c move.c \ odds.c one.c save.c subs.c table.c text.c version.c MAN= backgammon.6 diff --git a/games/backgammon/backgammon/main.c b/games/backgammon/backgammon/main.c index 4791faf..3ae7c54 100644 --- a/games/backgammon/backgammon/main.c +++ b/games/backgammon/backgammon/main.c @@ -37,7 +37,10 @@ */ #include +#include +#include #include +#include #include #include "back.h" @@ -61,7 +64,7 @@ const char *contin[] = { /* pause message */ }; static const char rules[] = "\nDo you want the rules of the game?"; -static const char noteach[] = "Teachgammon not available!\n\007"; +static const char noteach[] = "Teachgammon not available!\n\a"; static const char need[] = "Do you need instructions for this program?"; static const char askcol[] = "Enter 'r' to play red, 'w' to play white, 'b' to play both:"; @@ -95,14 +98,11 @@ main(int argc, char **argv) bflag = 2; /* default no board */ acnt = 1; /* Nuber of args */ signal (SIGINT,(sig_t)getout); /* trap interrupts */ - if (ioctl(0, TIOCGETP, &tty) == -1) /* get old tty mode */ - errexit ("backgammon(gtty)"); - old = tty.sg_flags; -#ifdef V7 - raw = ((noech = old & ~ECHO) | CBREAK); /* set up modes */ -#else - raw = ((noech = old & ~ECHO) | RAW); /* set up modes */ -#endif + if (tcgetattr (0,&tty) == -1) /* get old tty mode */ + errexit ("backgammon(tcgetattr)"); + old = tty.c_lflag; + raw = ((noech = old & ~ECHO) & ~ICANON); /* set up modes */ + ospeed = cfgetospeed(&tty); /* for termlib */ /* get terminal * capabilities, and @@ -118,8 +118,8 @@ main(int argc, char **argv) getarg (argc, argv); args[acnt] = NULL; if (tflag) { /* clear screen */ - noech &= ~(CRMOD|XTABS); - raw &= ~(CRMOD|XTABS); + noech &= ~(ICRNL|OXTABS); + raw &= ~(ICRNL|OXTABS); clear(); } fixtty (raw); /* go into raw mode */ diff --git a/games/backgammon/common_source/back.h b/games/backgammon/common_source/back.h index 7b946be..4469531 100644 --- a/games/backgammon/common_source/back.h +++ b/games/backgammon/common_source/back.h @@ -34,7 +34,7 @@ * $DragonFly: src/games/backgammon/common_source/back.h,v 1.2 2006/08/08 16:36:11 pavalos Exp $ */ -#include +#include #include #include @@ -117,7 +117,7 @@ extern const char *const *colorptr; /* color of current player */ extern const char *const *Colorptr; /* color of current player, capitalized */ extern int colen; /* length of color of current player */ -extern struct sgttyb tty; /* tty information buffer */ +extern struct termios tty; /* tty information buffer */ extern int old; /* original tty status */ extern int noech; /* original tty status without echo */ extern int raw; /* raw tty status, no echo */ diff --git a/games/backgammon/common_source/save.c b/games/backgammon/common_source/save.c index 3674548..3250c7d 100644 --- a/games/backgammon/common_source/save.c +++ b/games/backgammon/common_source/save.c @@ -74,7 +74,7 @@ save(int n) writel (prompt); fs = fname; while ((*fs = readc()) != '\n') { - if (*fs == tty.sg_erase) { + if (*fs == tty.c_cc[2]) { if (fs > fname) { fs--; if (tflag) diff --git a/games/backgammon/common_source/subs.c b/games/backgammon/common_source/subs.c index 5906aa9..77676bf 100644 --- a/games/backgammon/common_source/subs.c +++ b/games/backgammon/common_source/subs.c @@ -36,6 +36,7 @@ */ #include +#include #include #include "back.h" @@ -422,8 +423,8 @@ fixtty(int mode) if (tflag) newpos(); buflush(); - tty.sg_flags = mode; - if (ioctl(0, TIOCSETP, &tty) < 0) + tty.c_lflag = mode; + if (tcsetattr (0,TCSANOW,&tty) < 0) errexit("fixtty"); } diff --git a/games/backgammon/common_source/table.c b/games/backgammon/common_source/table.c index dce7806..6c3944e 100644 --- a/games/backgammon/common_source/table.c +++ b/games/backgammon/common_source/table.c @@ -112,11 +112,11 @@ dochar: } } - if (c == tty.sg_erase && ncin > 0) { + if (c == tty.c_cc[2] && ncin > 0) { if (tflag) curmove (curr,curc-1); else { - if (tty.sg_erase == '\010') + if (tty.c_cc[2] == '\010') writel ("\010 \010"); else writec (cin[ncin-1]); @@ -133,13 +133,13 @@ dochar: goto domove; } - if (c == tty.sg_kill && ncin > 0) { + if (c == tty.c_cc[3] && ncin > 0) { if (tflag) { refresh(); curmove (curr,39); ist = -1; goto domove; - } else if (tty.sg_erase == '\010') { + } else if (tty.c_cc[2] == '\010') { for (j = 0; j < ncin; j++) writel ("\010 \010"); ist = -1; diff --git a/games/backgammon/teachgammon/Makefile b/games/backgammon/teachgammon/Makefile index 19315b6..41a358f 100644 --- a/games/backgammon/teachgammon/Makefile +++ b/games/backgammon/teachgammon/Makefile @@ -2,7 +2,7 @@ # $DragonFly: src/games/backgammon/teachgammon/Makefile,v 1.3 2006/10/08 16:22:35 pavalos Exp $ PROG= teachgammon -CFLAGS+=-DTEACHGAMMON_TEXT -DV7 -I${.CURDIR}/../common_source +CFLAGS+=-DTEACHGAMMON_TEXT -I${.CURDIR}/../common_source SRCS= allow.c board.c check.c data.c fancy.c init.c odds.c one.c save.c \ subs.c table.c teach.c ttext1.c ttext2.c tutor.c DPADD= ${LIBTERMCAP} diff --git a/games/backgammon/teachgammon/teach.c b/games/backgammon/teachgammon/teach.c index 1b2acba..0bb3fc6 100644 --- a/games/backgammon/teachgammon/teach.c +++ b/games/backgammon/teachgammon/teach.c @@ -38,6 +38,8 @@ #include #include +#include +#include #include #include "back.h" #include "tutor.h" @@ -65,19 +67,16 @@ main(int argc, char **argv) acnt = 1; signal (SIGINT,(sig_t)getout); - if (ioctl(0,TIOCGETP,&tty) == -1) /* get old tty mode */ - errexit ("teachgammon(gtty)"); - old = tty.sg_flags; -#ifdef V7 - raw = ((noech = old & ~ECHO) | CBREAK); /* set up modes */ -#else - raw = ((noech = old & ~ECHO) | RAW); /* set up modes */ -#endif + if (tcgetattr (0,&tty) == -1) /* get old tty mode */ + errexit ("teachgammon(tcgetattr)"); + old = tty.c_lflag; + raw = ((noech = old & ~ECHO) & ~ICANON); /* set up modes */ + ospeed = cfgetospeed(&tty); /* for termlib */ tflag = getcaps (getenv ("TERM")); getarg (argc, argv); if (tflag) { - noech &= ~(CRMOD|XTABS); - raw &= ~(CRMOD|XTABS); + noech &= ~(ICRNL|OXTABS); + raw &= ~(ICRNL|OXTABS); clear(); } text (hello);