|
|
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: (1) source distributions retain this entire copyright
7: * notice and comment, and (2) distributions including binaries display
8: * the following acknowledgement: ``This product includes software
9: * developed by the University of California, Berkeley and its contributors''
10: * in the documentation or other materials provided with the distribution
11: * and in all advertising materials mentioning features or use of this
12: * software. Neither the name of the University nor the names of its
13: * contributors may be used to endorse or promote products derived
14: * from this software without specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: */
19:
20: #ifndef lint
21: static char sccsid[] = "@(#)tutor.c 5.4 (Berkeley) 6/1/90";
22: #endif /* not lint */
23:
24: #include "back.h"
25: #include "tutor.h"
26:
27: extern int maxmoves;
28: extern char *finis[];
29:
30: extern struct situatn test[];
31:
32: static char better[] = "That is a legal move, but there is a better one.\n";
33:
34: tutor () {
35: register int i, j;
36:
37: i = 0;
38: begscr = 18;
39: cturn = -1;
40: home = 0;
41: bar = 25;
42: inptr = &in[0];
43: inopp = &in[1];
44: offptr = &off[0];
45: offopp = &off[1];
46: Colorptr = &color[0];
47: colorptr = &color[2];
48: colen = 5;
49: wrboard();
50:
51: while (1) {
52: if (! brdeq(test[i].brd,board)) {
53: if (tflag && curr == 23)
54: curmove (18,0);
55: writel (better);
56: nexturn();
57: movback (mvlim);
58: if (tflag) {
59: refresh();
60: clrest ();
61: }
62: if ((! tflag) || curr == 19) {
63: proll();
64: writec ('\t');
65: }
66: else
67: curmove (curr > 19? curr-2: curr+4,25);
68: getmove();
69: if (cturn == 0)
70: leave();
71: continue;
72: }
73: if (tflag)
74: curmove (18,0);
75: text (*test[i].com);
76: if (! tflag)
77: writec ('\n');
78: if (i == maxmoves)
79: break;
80: D0 = test[i].roll1;
81: D1 = test[i].roll2;
82: d0 = 0;
83: mvlim = 0;
84: for (j = 0; j < 4; j++) {
85: if (test[i].mp[j] == test[i].mg[j])
86: break;
87: p[j] = test[i].mp[j];
88: g[j] = test[i].mg[j];
89: mvlim++;
90: }
91: if (mvlim)
92: for (j = 0; j < mvlim; j++)
93: if (makmove(j))
94: writel ("AARGH!!!\n");
95: if (tflag)
96: refresh();
97: nexturn();
98: D0 = test[i].new1;
99: D1 = test[i].new2;
100: d0 = 0;
101: i++;
102: mvlim = movallow();
103: if (mvlim) {
104: if (tflag)
105: clrest();
106: proll();
107: writec('\t');
108: getmove();
109: if (tflag)
110: refresh();
111: if (cturn == 0)
112: leave();
113: }
114: }
115: leave();
116: }
117:
118: clrest () {
119: register int r, c, j;
120:
121: r = curr;
122: c = curc;
123: for (j = r+1; j < 24; j++) {
124: curmove (j,0);
125: cline();
126: }
127: curmove (r,c);
128: }
129:
130: brdeq (b1,b2)
131: register int *b1, *b2;
132:
133: {
134: register int *e;
135:
136: e = b1+26;
137: while (b1 < e)
138: if (*b1++ != *b2++)
139: return(0);
140: return(1);
141: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.