1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 char copyright[] =
10 "@(#) Copyright (c) 1980 Regents of the University of California.\n\
11  All rights reserved.\n";
12 #endif /* not lint */
13 
14 #ifndef lint
15 static char sccsid[] = "@(#)teach.c	5.6 (Berkeley) 06/01/90";
16 #endif /* not lint */
17 
18 #include "back.h"
19 
20 char	*hello[];
21 char	*list[];
22 char	*intro1[];
23 char	*intro2[];
24 char	*moves[];
25 char	*remove[];
26 char	*hits[];
27 char	*endgame[];
28 char	*doubl[];
29 char	*stragy[];
30 char	*prog[];
31 char	*lastch[];
32 
33 extern char	ospeed;			/* tty output speed for termlib */
34 
35 char *helpm[] = {
36 	"\nEnter a space or newline to roll, or",
37 	"     b   to display the board",
38 	"     d   to double",
39 	"     q   to quit\n",
40 	0
41 };
42 
43 char *contin[] = {
44 	"",
45 	0
46 };
47 
48 main (argc,argv)
49 int	argc;
50 char	**argv;
51 
52 {
53 	register int	i;
54 
55 	signal (2,getout);
56 	if (gtty (0,&tty) == -1)			/* get old tty mode */
57 		errexit ("teachgammon(gtty)");
58 	old = tty.sg_flags;
59 #ifdef V7
60 	raw = ((noech = old & ~ECHO) | CBREAK);		/* set up modes */
61 #else
62 	raw = ((noech = old & ~ECHO) | RAW);		/* set up modes */
63 #endif
64 	ospeed = tty.sg_ospeed;				/* for termlib */
65 	tflag = getcaps (getenv ("TERM"));
66 #ifdef V7
67 	while (*++argv != 0)
68 #else
69 	while (*++argv != -1)
70 #endif
71 		getarg (&argv);
72 	if (tflag)  {
73 		noech &= ~(CRMOD|XTABS);
74 		raw &= ~(CRMOD|XTABS);
75 		clear();
76 	}
77 	text (hello);
78 	text (list);
79 	i = text (contin);
80 	if (i == 0)
81 		i = 2;
82 	init();
83 	while (i)
84 		switch (i)  {
85 
86 		case 1:
87 			leave();
88 
89 		case 2:
90 			if (i = text(intro1))
91 				break;
92 			wrboard();
93 			if (i = text(intro2))
94 				break;
95 
96 		case 3:
97 			if (i = text(moves))
98 				break;
99 
100 		case 4:
101 			if (i = text(remove))
102 				break;
103 
104 		case 5:
105 			if (i = text(hits))
106 				break;
107 
108 		case 6:
109 			if (i = text(endgame))
110 				break;
111 
112 		case 7:
113 			if (i = text(doubl))
114 				break;
115 
116 		case 8:
117 			if (i = text(stragy))
118 				break;
119 
120 		case 9:
121 			if (i = text(prog))
122 				break;
123 
124 		case 10:
125 			if (i = text(lastch))
126 				break;
127 		}
128 	tutor();
129 }
130 
131 leave()  {
132 	if (tflag)
133 		clear();
134 	else
135 		writec ('\n');
136 	fixtty(old);
137 	execl (EXEC,"backgammon",args,"n",0);
138 	writel ("Help! Backgammon program is missing\007!!\n");
139 	exit (-1);
140 }
141