Project

General

Profile

backgammon.diff

uqs, 09/08/2009 05:35 PM

View differences:

games/backgammon/backgammon/Makefile
3 3
# $DragonFly: src/games/backgammon/backgammon/Makefile,v 1.4 2006/10/08 16:22:35 pavalos Exp $
4 4

  
5 5
PROG=	backgammon
6
CFLAGS+=-DV7 -I${.CURDIR}/../common_source
6
CFLAGS+=-I${.CURDIR}/../common_source
7 7
SRCS=	allow.c board.c check.c extra.c fancy.c init.c main.c move.c \
8 8
	odds.c one.c save.c subs.c table.c text.c version.c
9 9
MAN=	backgammon.6
games/backgammon/backgammon/main.c
37 37
 */
38 38

  
39 39
#include <stdio.h>
40
#include <termcap.h>
41
#include <unistd.h>
40 42
#include <string.h>
43
#include <stdlib.h>
41 44
#include <signal.h>
42 45
#include "back.h"
43 46

  
......
61 64
};
62 65

  
63 66
static const char	rules[] = "\nDo you want the rules of the game?";
64
static const char	noteach[] = "Teachgammon not available!\n\007";
67
static const char	noteach[] = "Teachgammon not available!\n\a";
65 68
static const char	need[] = "Do you need instructions for this program?";
66 69
static const char	askcol[] =
67 70
	"Enter 'r' to play red, 'w' to play white, 'b' to play both:";
......
95 98
	bflag = 2;					/* default no board */
96 99
	acnt = 1;                                       /* Nuber of args */
97 100
	signal (SIGINT,(sig_t)getout);			/* trap interrupts */
98
	if (ioctl(0, TIOCGETP, &tty) == -1)		/* get old tty mode */
99
		errexit ("backgammon(gtty)");
100
	old = tty.sg_flags;
101
#ifdef V7
102
	raw = ((noech = old & ~ECHO) | CBREAK);		/* set up modes */
103
#else
104
	raw = ((noech = old & ~ECHO) | RAW);		/* set up modes */
105
#endif
101
	if (tcgetattr (0,&tty) == -1)			/* get old tty mode */
102
		errexit ("backgammon(tcgetattr)");
103
	old = tty.c_lflag;
104
	raw = ((noech = old & ~ECHO) & ~ICANON);		/* set up modes */
105
	ospeed = cfgetospeed(&tty);				/* for termlib */
106 106

  
107 107
							/* get terminal
108 108
							 * capabilities, and
......
118 118
	getarg (argc, argv);
119 119
	args[acnt] = NULL;
120 120
	if (tflag)  {					/* clear screen */
121
		noech &= ~(CRMOD|XTABS);
122
		raw &= ~(CRMOD|XTABS);
121
		noech &= ~(ICRNL|OXTABS);
122
		raw &= ~(ICRNL|OXTABS);
123 123
		clear();
124 124
	}
125 125
	fixtty (raw);					/* go into raw mode */
games/backgammon/common_source/back.h
34 34
 * $DragonFly: src/games/backgammon/common_source/back.h,v 1.2 2006/08/08 16:36:11 pavalos Exp $
35 35
 */
36 36

  
37
#include <sgtty.h>
37
#include <termios.h>
38 38
#include <stdlib.h>
39 39
#include <unistd.h>
40 40

  
......
117 117
extern const char *const *Colorptr;	/* color of current player, capitalized */
118 118
extern int	colen;		/* length of color of current player */
119 119

  
120
extern struct sgttyb	tty;	/* tty information buffer */
120
extern struct termios	tty;	/* tty information buffer */
121 121
extern int		old;	/* original tty status */
122 122
extern int		noech;	/* original tty status without echo */
123 123
extern int		raw;	/* raw tty status, no echo */
games/backgammon/common_source/save.c
74 74
		writel (prompt);
75 75
		fs = fname;
76 76
		while ((*fs = readc()) != '\n')  {
77
			if (*fs == tty.sg_erase)  {
77
			if (*fs == tty.c_cc[2])  {
78 78
				if (fs > fname)  {
79 79
					fs--;
80 80
					if (tflag)
games/backgammon/common_source/subs.c
36 36
 */
37 37

  
38 38
#include <stdio.h>
39
#include <stdlib.h>
39 40
#include <string.h>
40 41
#include "back.h"
41 42

  
......
422 423
	if (tflag)
423 424
		newpos();
424 425
	buflush();
425
	tty.sg_flags = mode;
426
	if (ioctl(0, TIOCSETP, &tty) < 0)
426
	tty.c_lflag = mode;
427
	if (tcsetattr (0,TCSANOW,&tty) < 0)
427 428
		errexit("fixtty");
428 429
}
429 430

  
games/backgammon/common_source/table.c
112 112
		}
113 113
	}
114 114

  
115
	if (c == tty.sg_erase && ncin > 0)  {
115
	if (c == tty.c_cc[2] && ncin > 0)  {
116 116
		if (tflag)
117 117
			curmove (curr,curc-1);
118 118
		else  {
119
			if (tty.sg_erase == '\010')
119
			if (tty.c_cc[2] == '\010')
120 120
				writel ("\010 \010");
121 121
			else
122 122
				writec (cin[ncin-1]);
......
133 133
		goto domove;
134 134
	}
135 135

  
136
	if (c == tty.sg_kill && ncin > 0)  {
136
	if (c == tty.c_cc[3] && ncin > 0)  {
137 137
		if (tflag)  {
138 138
			refresh();
139 139
			curmove (curr,39);
140 140
			ist = -1;
141 141
			goto domove;
142
		} else  if (tty.sg_erase == '\010')  {
142
		} else  if (tty.c_cc[2] == '\010')  {
143 143
			for (j = 0; j < ncin; j++)
144 144
				writel ("\010 \010");
145 145
			ist = -1;
games/backgammon/teachgammon/Makefile
2 2
# $DragonFly: src/games/backgammon/teachgammon/Makefile,v 1.3 2006/10/08 16:22:35 pavalos Exp $
3 3

  
4 4
PROG=	teachgammon
5
CFLAGS+=-DTEACHGAMMON_TEXT -DV7 -I${.CURDIR}/../common_source
5
CFLAGS+=-DTEACHGAMMON_TEXT -I${.CURDIR}/../common_source
6 6
SRCS=	allow.c board.c check.c data.c fancy.c init.c odds.c one.c save.c \
7 7
	subs.c table.c teach.c ttext1.c ttext2.c tutor.c
8 8
DPADD=	${LIBTERMCAP}
games/backgammon/teachgammon/teach.c
38 38

  
39 39
#include <string.h>
40 40
#include <sys/types.h>
41
#include <termcap.h>
42
#include <unistd.h>
41 43
#include <signal.h>
42 44
#include "back.h"
43 45
#include "tutor.h"
......
65 67

  
66 68
	acnt = 1;
67 69
	signal (SIGINT,(sig_t)getout);
68
	if (ioctl(0,TIOCGETP,&tty) == -1)			/* get old tty mode */
69
		errexit ("teachgammon(gtty)");
70
	old = tty.sg_flags;
71
#ifdef V7
72
	raw = ((noech = old & ~ECHO) | CBREAK);		/* set up modes */
73
#else
74
	raw = ((noech = old & ~ECHO) | RAW);		/* set up modes */
75
#endif
70
	if (tcgetattr (0,&tty) == -1)			/* get old tty mode */
71
		errexit ("teachgammon(tcgetattr)");
72
	old = tty.c_lflag;
73
	raw = ((noech = old & ~ECHO) & ~ICANON);		/* set up modes */
74
	ospeed = cfgetospeed(&tty);				/* for termlib */
76 75
	tflag = getcaps (getenv ("TERM"));
77 76
	getarg (argc, argv);
78 77
	if (tflag)  {
79
		noech &= ~(CRMOD|XTABS);
80
		raw &= ~(CRMOD|XTABS);
78
		noech &= ~(ICRNL|OXTABS);
79
		raw &= ~(ICRNL|OXTABS);
81 80
		clear();
82 81
	}
83 82
	text (hello);