|
|
1.1 root 1: /*
2: * Copyright (c) 1980 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: char copyright[] =
20: "@(#) Copyright (c) 1980 Regents of the University of California.\n\
21: All rights reserved.\n";
22: #endif /* not lint */
23:
24: #ifndef lint
25: static char sccsid[] = "@(#)teach.c 5.5 (Berkeley) 6/18/88";
26: #endif /* not lint */
27:
28: #include "back.h"
29:
30: char *hello[];
31: char *list[];
32: char *intro1[];
33: char *intro2[];
34: char *moves[];
35: char *remove[];
36: char *hits[];
37: char *endgame[];
38: char *doubl[];
39: char *stragy[];
40: char *prog[];
41: char *lastch[];
42:
43: extern char ospeed; /* tty output speed for termlib */
44:
45: char *helpm[] = {
46: "\nEnter a space or newline to roll, or",
47: " b to display the board",
48: " d to double",
49: " q to quit\n",
50: 0
51: };
52:
53: char *contin[] = {
54: "",
55: 0
56: };
57:
58: main (argc,argv)
59: int argc;
60: char **argv;
61:
62: {
63: register int i;
64:
65: signal (2,getout);
66: if (gtty (0,&tty) == -1) /* get old tty mode */
67: errexit ("teachgammon(gtty)");
68: old = tty.sg_flags;
69: #ifdef V7
70: raw = ((noech = old & ~ECHO) | CBREAK); /* set up modes */
71: #else
72: raw = ((noech = old & ~ECHO) | RAW); /* set up modes */
73: #endif
74: ospeed = tty.sg_ospeed; /* for termlib */
75: tflag = getcaps (getenv ("TERM"));
76: #ifdef V7
77: while (*++argv != 0)
78: #else
79: while (*++argv != -1)
80: #endif
81: getarg (&argv);
82: if (tflag) {
83: noech &= ~(CRMOD|XTABS);
84: raw &= ~(CRMOD|XTABS);
85: clear();
86: }
87: text (hello);
88: text (list);
89: i = text (contin);
90: if (i == 0)
91: i = 2;
92: init();
93: while (i)
94: switch (i) {
95:
96: case 1:
97: leave();
98:
99: case 2:
100: if (i = text(intro1))
101: break;
102: wrboard();
103: if (i = text(intro2))
104: break;
105:
106: case 3:
107: if (i = text(moves))
108: break;
109:
110: case 4:
111: if (i = text(remove))
112: break;
113:
114: case 5:
115: if (i = text(hits))
116: break;
117:
118: case 6:
119: if (i = text(endgame))
120: break;
121:
122: case 7:
123: if (i = text(doubl))
124: break;
125:
126: case 8:
127: if (i = text(stragy))
128: break;
129:
130: case 9:
131: if (i = text(prog))
132: break;
133:
134: case 10:
135: if (i = text(lastch))
136: break;
137: }
138: tutor();
139: }
140:
141: leave() {
142: if (tflag)
143: clear();
144: else
145: writec ('\n');
146: fixtty(old);
147: execl (EXEC,"backgammon",args,"n",0);
148: writel ("Help! Backgammon program is missing\007!!\n");
149: exit (-1);
150: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.