1*6765Srrh static char sccsid[] = "	save.c	1.1	82/05/11	";
2*6765Srrh 
3*6765Srrh #include "back.h"
4*6765Srrh 
5*6765Srrh extern int	errno;
6*6765Srrh 
7*6765Srrh int	code[] = {
8*6765Srrh 	0000413, 0000000, 0004000, 0000000, 0002000, 0000000, 0002620, 0000000,
9*6765Srrh 	0001100, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000,
10*6765Srrh 	0000000, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000,
11*6765Srrh /* *, */
12*6765Srrh 	0000000, 0004302, 0150136, 0004256, 0117156, 0006256, 0150120, 0127120,
13*6765Srrh 	0152404, 0011200, 0150774, 0137120, 0014404, 0152402, 0150160, 0127120,
14*6765Srrh 	0150010, 0167520, 0003730, 0000000, 0001773, 0006757, 0000000, 0156400,
15*6765Srrh 	0175520, 0167401, 0000134, 0000000, 0000674, 0000000, 0000000, 0000335,
16*6765Srrh 	0136335, 0157410, 0156357, 0000007, 0157400, 0145757, 0000007, 0157400,
17*6765Srrh 	0127757, 0000007, 0175400, 0167405, 0000004, 0000000, 0000004, 0000000,
18*6765Srrh 	0000000, 0126237, 0156410, 0002254, 0001373, 0000757, 0000000, 0002000,
19*6765Srrh 	0000000, 0167735, 0003610, 0000000, 0126335, 0156410, 0002254, 0001773,
20*6765Srrh 	0001757, 0000000, 0002000, 0000000, 0000000, 0035674, 0167427, 0000016,
21*6765Srrh 	0000000, 0000000, 0000000, 0000373, 0106757, 0000001, 0136000, 0000001,
22*6765Srrh 	0050320, 0160757, 0000010, 0147000, 0050001, 0000004, 0007400, 0002302,
23*6765Srrh 	0150136, 0004254, 0160133, 0125401, 0050014, 0000716, 0002120, 0054724,
24*6765Srrh 	0054720, 0030530, 0000207, 0126366, 0126404, 0150377, 0054001, 0054335,
25*6765Srrh 	0126737, 0114377, 0006653, 0175576, 0167403, 0002312, 0000000, 0050320,
26*6765Srrh 	0010531, 0114152, 0056357, 0000007, 0077000, 0000773, 0141757, 0000001,
27*6765Srrh 	0152400, 0011520, 0104005, 0100217, 0006253, 0167736, 0004220, 0000000,
28*6765Srrh 	0004253, 0167736, 0004210, 0000000, 0002253, 0003741, 0006253, 0150102,
29*6765Srrh 	0004253, 0173132, 0002254, 0002273, 0125726, 0140404, 0000217, 0000004,
30*6765Srrh 	0055000, 0150520, 0002253, 0014120, 0150406, 0002254, 0011012, 0141617,
31*6765Srrh 	0125532, 0050004, 0050320, 0156530, 0156520, 0114132, 0006653, 0175576,
32*6765Srrh 	0167403, 0002142, 0000000, 0050320, 0150131, 0125532, 0152004, 0010553,
33*6765Srrh 	0160556, 0125402, 0001414, 0066461, 0150377, 0004253, 0011132, 0150463,
34*6765Srrh 	0107533, 0004070, 0000000, 0001422, 0074061, 0156777, 0000217, 0000004,
35*6765Srrh 	0175400, 0167401, 0000630, 0000000, 0050320, 0150132, 0125532, 0011010,
36*6765Srrh 	0104006, 0125404, 0010414, 0104203, 0125410, 0152014, 0150131, 0054131,
37*6765Srrh 	0020021, 0055303, 0002253, 0150131, 0054131, 0013025, 0055320, 0002253,
38*6765Srrh 	0054735, 0055335, 0125630, 0077015, 0001773, 0174757, 0000003, 0150000,
39*6765Srrh 	0054520, 0107462, 0001777, 0173153, 0002254, 0150212, 0125532, 0150404,
40*6765Srrh 	0054530, 0003423, 0020210, 0006253, 0167461, 0150376, 0002254, 0002120,
41*6765Srrh 	0007000, 0126320, 0055404, 0125630, 0050014, 0107712, 0177771, 0177777,
42*6765Srrh 	0150520, 0001120, 0040022, 0125720, 0055010, 0035023, 0055303, 0002253,
43*6765Srrh 	0012531, 0150063, 0125532, 0111404, 0102217, 0006253, 0002023, 0050324,
44*6765Srrh 	0002421, 0107462, 0002000, 0150120, 0065520, 0054735, 0055335, 0125630,
45*6765Srrh 	0077015, 0001773, 0107757, 0000003, 0150400, 0054520, 0004023, 0020210,
46*6765Srrh 	0006253, 0000716, 0002120, 0050324, 0000004, 0004000, 0167736, 0002766,
47*6765Srrh 	0000000, 0010533, 0156414, 0175533, 0167401, 0000016, 0000000, 0010300,
48*6765Srrh 	0150533, 0167533, 0003440, 0000000, 0165431, 0000004, 0006000, 0126320,
49*6765Srrh 	0055404, 0000716, 0111532, 0125403, 0011414, 0160074, 0125406, 0033414,
50*6765Srrh 	0055735, 0000773, 0063757, 0177777, 0150377, 0055120, 0125630, 0077015,
51*6765Srrh 	0000773, 0026757, 0000000, 0152400, 0014120, 0147003, 0055001, 0001741,
52*6765Srrh 	0006253, 0156412, 0004253, 0000773, 0167757, 0000001, 0111400, 0106217,
53*6765Srrh 	0006253, 0001423, 0125724, 0105010, 0177617, 0006253, 0065724, 0055320,
54*6765Srrh 	0002120, 0000000, 0000000, 0003274, 0003036, 0167427, 0176760, 0177777,
55*6765Srrh 	0050324, 0000004, 0000000, 0004302, 0157536, 0175255, 0126335, 0175404,
56*6765Srrh 	0167402, 0000044, 0000000, 0050325, 0001430, 0050324, 0150004, 0050001,
57*6765Srrh 	0000004, 0000000, 0000000, 0126335, 0156410, 0004617, 0000164, 0156400,
58*6765Srrh 	0002254, 0001773, 0013757, 0000000, 0002000, 0000000, 0126335, 0156410,
59*6765Srrh 	0004217, 0000164, 0156400, 0002254, 0001773, 0000757, 0000000, 0002000,
60*6765Srrh 	0000000, 0033274, 0003036, 0167427, 0176624, 0177777, 0000004, 0000000,
61*6765Srrh 	0007000, 0167725, 0003124, 0000000, 0027022, 0000711, 0070217, 0000011,
62*6765Srrh 	0167400, 0003106, 0000000, 0000711, 0066217, 0000011, 0167400, 0003076,
63*6765Srrh 	0000000, 0167736, 0003070, 0000000, 0035757, 0000006, 0157000, 0024757,
64*6765Srrh 	0000006, 0167400, 0003054, 0000000, 0002335, 0003701, 0002254, 0175576,
65*6765Srrh 	0167402, 0001052, 0000000, 0050320, 0150131, 0012757, 0000006, 0055400,
66*6765Srrh 	0167724, 0003032, 0000000, 0065751, 0010405, 0150044, 0065552, 0065720,
67*6765Srrh 	0164532, 0173552, 0001170, 0050131, 0055700, 0150520, 0050132, 0007431,
68*6765Srrh 	0001170, 0050131, 0055700, 0150520, 0055520, 0001431, 0134461, 0150000,
69*6765Srrh 	0055133, 0000713, 0055553, 0055721, 0012132, 0150713, 0167532, 0002726,
70*6765Srrh 	0000000, 0004422, 0055721, 0066217, 0000011, 0011400, 0152003, 0002120,
71*6765Srrh 	0000761, 0167401, 0002710, 0000000, 0177654, 0107701, 0000400, 0000000,
72*6765Srrh 	0050131, 0107706, 0000400, 0000000, 0074120, 0050010, 0127757, 0000005,
73*6765Srrh 	0156400, 0175400, 0167401, 0000542, 0000000, 0050320, 0074132, 0167402,
74*6765Srrh 	0002634, 0000000, 0140120, 0050132, 0050321, 0014532, 0074300, 0167402,
75*6765Srrh 	0002614, 0000000, 0175576, 0167401, 0000500, 0000000, 0050320, 0150532,
76*6765Srrh 	0107532, 0177777, 0177777, 0122423, 0055320, 0064777, 0000005, 0140400,
77*6765Srrh 	0167404, 0002542, 0000000, 0150520, 0050132, 0003423, 0000710, 0052777,
78*6765Srrh 	0000005, 0074000, 0167402, 0002526, 0000000, 0140120, 0050132, 0002303,
79*6765Srrh 	0065120, 0065320, 0037757, 0000005, 0144400, 0107401, 0004554, 0000000,
80*6765Srrh 	0031777, 0000005, 0030400, 0177430, 0001170, 0050131, 0055701, 0167520,
81*6765Srrh 	0002440, 0000000, 0055321, 0014757, 0000005, 0012400, 0150022, 0010777,
82*6765Srrh 	0000005, 0167400, 0002424, 0000000, 0065720, 0002777, 0000005, 0144400,
83*6765Srrh 	0167401, 0002376, 0000000, 0140553, 0055404, 0002120, 0006000, 0126320,
84*6765Srrh 	0055404, 0055720, 0141132, 0055004, 0055320, 0162757, 0000004, 0145400,
85*6765Srrh 	0065001, 0150120, 0065120, 0000004, 0007000, 0006302, 0150136, 0002254,
86*6765Srrh 	0164533, 0176253, 0156411, 0175533, 0167401, 0177716, 0177777, 0055703,
87*6765Srrh 	0176253, 0143520, 0050004, 0172255, 0126335, 0175410, 0167401, 0177116,
88*6765Srrh 	0177777, 0050320, 0011532, 0150405, 0055532, 0002022, 0055320, 0002120,
89*6765Srrh 	0055720, 0176255, 0055320, 0174255, 0002335, 0001701, 0004254, 0175576,
90*6765Srrh 	0167402, 0000232, 0000000, 0050320, 0150531, 0126531, 0017364, 0150031,
91*6765Srrh 	0126531, 0010764, 0150023, 0176255, 0150120, 0174255, 0150121, 0060540,
92*6765Srrh 	0002300, 0176255, 0002300, 0174255, 0126720, 0050364, 0126727, 0152764,
93*6765Srrh 	0011120, 0150742, 0055532, 0132030, 0001170, 0050131, 0055300, 0150520,
94*6765Srrh 	0055520, 0124031, 0001170, 0050131, 0055300, 0141120, 0050133, 0002306,
95*6765Srrh 	0150120, 0042757, 0000004, 0040000, 0010552, 0000221, 0000000, 0167701,
96*6765Srrh 	0002100, 0000000, 0002254, 0156576, 0150001, 0051534, 0057320, 0136134,
97*6765Srrh 	0017021, 0013406, 0043757, 0177773, 0150377, 0022757, 0000004, 0050000,
98*6765Srrh 	0121700, 0167404, 0002034, 0000000, 0000004, 0136000, 0017021, 0013406,
99*6765Srrh 	0025757, 0177773, 0150377, 0002254, 0003757, 0000004, 0152000, 0002120,
100*6765Srrh 	0000000, 0126320, 0050004, 0126320, 0051010, 0002423, 0051321, 0012401,
101*6765Srrh 	0152010, 0075521, 0050122, 0051120, 0011404, 0150413, 0051120, 0001436,
102*6765Srrh 	0050324, 0150004, 0050001, 0000004, 0000000, 0002274, 0003036, 0167427,
103*6765Srrh 	0175354, 0177777, 0000004, 0000000, 0000000, 0000000, 0000000, 0000000,
104*6765Srrh 	0000000, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000,
105*6765Srrh /* *, */
106*6765Srrh 	0000000, 0000000, 0072457, 0071163, 0063457, 0066541, 0071545, 0061057,
107*6765Srrh 	0061541, 0063553, 0066541, 0067555, 0000156, 0060542, 0065543, 0060547,
108*6765Srrh 	0066555, 0067157, 0071400, 0000000, 0000000, 0000000, 0006620, 0000000,
109*6765Srrh 	0006620, 0000000, 0000001, 0000000, 0000000, 0000000, 0000000, 0000000,
110*6765Srrh 	0000000, 0000000, 0000402, 0000000, 0000000, 0000000, 0000000, 0000000,
111*6765Srrh 	0000000, 0000000, 0001006, 0000000, 0000000, 0000000, 0000000, 0000000,
112*6765Srrh 	0000000, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000,
113*6765Srrh /* *, */
114*6765Srrh 	0000000, 0000000, 0000000, 0000000, 0004550, 0000000, 0000000, 0000000,
115*6765Srrh 	0000000, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000,
116*6765Srrh 	0000000, 0000000, 0010620, 0000000, 0000000, 0000000, 0000000, 0000000,
117*6765Srrh 	0000000, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000, 0000000,
118*6765Srrh /* *, */
119*6765Srrh 	0000004, 0000000, 0000004, 0000013, 0000000, 0000000, 0000013, 0000000,
120*6765Srrh 	0000002, 0000000, 0000001, 0000000, 0000020, 0000000, 0000004, 0000000,
121*6765Srrh 	0000074, 0000000, 0000030, 0000000, 0000004, 0000000, 0000140, 0000000,
122*6765Srrh 	0000040, 0000000, 0000004, 0000005, 0000160, 0000000, 0000050, 0000000,
123*6765Srrh 	0000004, 0000007, 0000210, 0000000, 0000061, 0000000, 0000004, 0000001,
124*6765Srrh 	0000224, 0000000, 0000070, 0000000, 0000004, 0000013, 0000240, 0000000,
125*6765Srrh 	0000101, 0000000, 0000004, 0000013, 0000254, 0000000, 0000112, 0000000,
126*6765Srrh 	0000004, 0000001, 0001244, 0000000, 0000121, 0000000, 0000004, 0000007,
127*6765Srrh 	0001244, 0000000, 0000131, 0000000, 0000004, 0000001, 0001264, 0000000,
128*6765Srrh 	0000142, 0000000, 0000004, 0000002, 0001324, 0000000, 0000151, 0000000,
129*6765Srrh 	0000004, 0000002, 0001400, 0000000, 0000161, 0000000, 0000004, 0000001,
130*6765Srrh 	0001420, 0000000, 0000172, 0000000, 0000004, 0000004, 0002474, 0000000,
131*6765Srrh 	0000201, 0000000, 0000004, 0000005, 0002600, 0000000, 0000210, 0000000,
132*6765Srrh 	0000004, 0000000, 0002650, 0000000, 0000220, 0000000, 0000005, 0001640,
133*6765Srrh 	0000224, 0000000, 0000226, 0000000, 0000005, 0002416, 0000000, 0000000,
134*6765Srrh 	0000234, 0000000, 0000005, 0001576, 0000074, 0000000, 0000242, 0000000,
135*6765Srrh 	0000007, 0002562, 0004000, 0000000, 0000253, 0000000, 0000005, 0003572,
136*6765Srrh 	0000140, 0000000, 0000262, 0000000, 0000005, 0003604, 0000160, 0000000,
137*6765Srrh 	0000271, 0000000, 0000005, 0003317, 0000210, 0000000, 0000301, 0000000,
138*6765Srrh 	0000005, 0004034, 0000240, 0000000, 0000310, 0000000, 0000005, 0001626,
139*6765Srrh 	0001052, 0000000, 0000322, 0000000, 0000011, 0003627, 0004610, 0000000,
140*6765Srrh 	0000331, 0000000, 0000005, 0001146, 0000254, 0000000, 0000342, 0000000,
141*6765Srrh 	0000005, 0004225, 0002650, 0000000, 0000351, 0000000, 0000007, 0001456,
142*6765Srrh 	0004050, 0000000, 0000357, 0000000, 0000005, 0003463, 0001264, 0000000,
143*6765Srrh 	0000367, 0000000, 0000011, 0003012, 0004620, 0000000, 0000377, 0000000,
144*6765Srrh 	0000005, 0003253, 0001420, 0000000, 0000407, 0000000, 0000005, 0003114,
145*6765Srrh 	0000720, 0000000, 0000417, 0000000, 0000005, 0003001, 0001114, 0000000,
146*6765Srrh 	0000427, 0000000, 0000007, 0002664, 0004550, 0000000, 0000441, 0000000,
147*6765Srrh 	0000005, 0003473, 0001244, 0000000, 0000450, 0000000, 0000005, 0001571,
148*6765Srrh 	0002174, 0000000, 0000456, 0000000, 0000011, 0002732, 0006620, 0000000,
149*6765Srrh 	0000466, 0000000, 0000005, 0001673, 0001352, 0000000, 0000474, 0000000,
150*6765Srrh 	0000005, 0002033, 0001324, 0000000, 0000502, 0000000, 0000005, 0003614,
151*6765Srrh 	0001400, 0000000, 0000511, 0000000, 0000005, 0003200, 0002600, 0000000,
152*6765Srrh 	0000516, 0000000, 0000005, 0001701, 0002474, 0000000, 0000524, 0000000,
153*6765Srrh 	0000005, 0003067, 0002230, 0000000, 0000535, 0000000, 0000011, 0002714,
154*6765Srrh 	0010620, 0000000, 0000542, 0000000, 0000005, 0002717, 0002551, 0000000,
155*6765Srrh 	0000547, 0000000, 0071143, 0030164, 0067456, 0062400, 0064570, 0000164,
156*6765Srrh 	0074145, 0061545, 0027154, 0000157, 0074145, 0061545, 0027154, 0000157,
157*6765Srrh 	0074145, 0061545, 0027166, 0000157, 0074145, 0061545, 0062566, 0067456,
158*6765Srrh 	0062400, 0064570, 0027164, 0000157, 0062543, 0071162, 0071157, 0067456,
159*6765Srrh 	0063000, 0071554, 0072542, 0027146, 0000157, 0060544, 0060564, 0067456,
160*6765Srrh 	0061400, 0067554, 0062563, 0067456, 0064400, 0060563, 0072164, 0027171,
161*6765Srrh 	0000157, 0072163, 0074564, 0067456, 0064400, 0061557, 0066164, 0067456,
162*6765Srrh 	0066400, 0066141, 0067554, 0027143, 0000157, 0061163, 0065562, 0067456,
163*6765Srrh 	0072400, 0064544, 0027166, 0000157, 0071167, 0072151, 0027145, 0000157,
164*6765Srrh 	0062537, 0064570, 0000164, 0072163, 0071141, 0000164, 0066537, 0064541,
165*6765Srrh 	0000156, 0062537, 0073156, 0071151, 0067157, 0057400, 0074145, 0061545,
166*6765Srrh 	0000154, 0062537, 0062570, 0073143, 0057400, 0074145, 0061545, 0062566,
167*6765Srrh 	0061400, 0071145, 0067562, 0000162, 0057537, 0066143, 0060545, 0072556,
168*6765Srrh 	0000160, 0062537, 0071162, 0067556, 0057400, 0063137, 0071554, 0072542,
169*6765Srrh 	0000146, 0073537, 0064562, 0062564, 0057400, 0064537, 0061157, 0057400,
170*6765Srrh 	0071551, 0072141, 0074564, 0057400, 0071537, 0061157, 0063165, 0057400,
171*6765Srrh 	0060555, 0066154, 0061557, 0057400, 0063146, 0072554, 0064163, 0057400,
172*6765Srrh 	0061546, 0067554, 0062563, 0057400, 0066137, 0071541, 0061164, 0063165,
173*6765Srrh 	0057400, 0066143, 0071557, 0000145, 0063137, 0062562, 0000145, 0057537,
174*6765Srrh 	0064563, 0072542, 0000146, 0063537, 0072164, 0000171, 0071537, 0072164,
175*6765Srrh 	0000171, 0064537, 0061557, 0066164, 0072400, 0064544, 0000166, 0071537,
176*6765Srrh 	0071142, 0000153, 0071137, 0060545, 0066154, 0061557, 0057400, 0067145,
177*6765Srrh 	0000144, 0061137, 0065562, 0000000,
178*6765Srrh };
179*6765Srrh 
180*6765Srrh static char	confirm[] = "Are you sure you want to leave now?";
181*6765Srrh static char	prompt[] = "Enter a file name:  ";
182*6765Srrh static char	exist1[] = "The file '";
183*6765Srrh static char	exist2[] =
184*6765Srrh 	"' already exists.\nAre you sure you want to use this file?";
185*6765Srrh static char	cantuse[] = "\nCan't use ";
186*6765Srrh static char	saved[] = "This file has been saved on the file '";
187*6765Srrh static char	type[] = "'.\nType '";
188*6765Srrh static char	rec[] = "' to recover your game.\n\n";
189*6765Srrh static char	cantrec[] = "Can't recover file:  ";
190*6765Srrh 
191*6765Srrh save (n)
192*6765Srrh register int	n;
193*6765Srrh 
194*6765Srrh {
195*6765Srrh 	register int	fdesc;
196*6765Srrh 	register char	*fs;
197*6765Srrh 	char		fname[50];
198*6765Srrh 
199*6765Srrh 	if (n)  {
200*6765Srrh 		if (tflag)  {
201*6765Srrh 			curmove (20,0);
202*6765Srrh 			clend();
203*6765Srrh 		} else
204*6765Srrh 			writec ('\n');
205*6765Srrh 		writel (confirm);
206*6765Srrh 		if (! yorn(0))
207*6765Srrh 			return;
208*6765Srrh 	}
209*6765Srrh 	cflag = 1;
210*6765Srrh 	for (;;)  {
211*6765Srrh 		writel (prompt);
212*6765Srrh 		fs = fname;
213*6765Srrh 		while ((*fs = readc()) != '\n')  {
214*6765Srrh 			if (*fs == tty.sg_erase)  {
215*6765Srrh 				if (fs > fname)  {
216*6765Srrh 					fs--;
217*6765Srrh 					if (tflag)
218*6765Srrh 						curmove (curr,curc-1);
219*6765Srrh 					else
220*6765Srrh 						writec (*fs);
221*6765Srrh 				} else
222*6765Srrh 					writec ('\007');
223*6765Srrh 				continue;
224*6765Srrh 			}
225*6765Srrh 			writec (*fs++);
226*6765Srrh 		}
227*6765Srrh 		*fs = '\0';
228*6765Srrh 		if ((fdesc = open(fname,2)) == -1 && errno == 2)  {
229*6765Srrh 			if ((fdesc = creat (fname,0700)) != -1)
230*6765Srrh 			break;
231*6765Srrh 		}
232*6765Srrh 		if (fdesc != -1)  {
233*6765Srrh 			if (tflag)  {
234*6765Srrh 				curmove (18,0);
235*6765Srrh 				clend();
236*6765Srrh 			} else
237*6765Srrh 				writec ('\n');
238*6765Srrh 			writel (exist1);
239*6765Srrh 			writel (fname);
240*6765Srrh 			writel (exist2);
241*6765Srrh 			cflag = 0;
242*6765Srrh 			close (fdesc);
243*6765Srrh 			if (yorn (0))  {
244*6765Srrh 				unlink (fname);
245*6765Srrh 				fdesc = creat (fname,0700);
246*6765Srrh 				break;
247*6765Srrh 			} else  {
248*6765Srrh 				cflag = 1;
249*6765Srrh 				continue;
250*6765Srrh 			}
251*6765Srrh 		}
252*6765Srrh 		writel (cantuse);
253*6765Srrh 		writel (fname);
254*6765Srrh 		writel (".\n");
255*6765Srrh 		close (fdesc);
256*6765Srrh 		cflag = 1;
257*6765Srrh 	}
258*6765Srrh 	write (fdesc,code,sizeof code);
259*6765Srrh 	write (fdesc,board,52);
260*6765Srrh 	write (fdesc,off,4);
261*6765Srrh 	write (fdesc,in,4);
262*6765Srrh 	write (fdesc,dice,4);
263*6765Srrh 	write (fdesc,&cturn,2);
264*6765Srrh 	write (fdesc,&dlast,2);
265*6765Srrh 	write (fdesc,&pnum,2);
266*6765Srrh 	write (fdesc,&rscore,2);
267*6765Srrh 	write (fdesc,&wscore,2);
268*6765Srrh 	write (fdesc,&gvalue,2);
269*6765Srrh 	write (fdesc,&raflag,2);
270*6765Srrh 	close (fdesc);
271*6765Srrh 	if (tflag)
272*6765Srrh 		curmove (18,0);
273*6765Srrh 	writel (saved);
274*6765Srrh 	writel (fname);
275*6765Srrh 	writel (type);
276*6765Srrh 	writel (fname);
277*6765Srrh 	writel (rec);
278*6765Srrh 	if (tflag)
279*6765Srrh 		clend();
280*6765Srrh 	getout ();
281*6765Srrh }
282*6765Srrh 
283*6765Srrh recover (s)
284*6765Srrh char	*s;
285*6765Srrh 
286*6765Srrh {
287*6765Srrh 	register int	i;
288*6765Srrh 	int		fdesc;
289*6765Srrh 
290*6765Srrh 	if ((fdesc = open (s,0)) == -1)
291*6765Srrh 		norec (s);
292*6765Srrh 	read (fdesc,board,52);
293*6765Srrh 	for (i = 0; i < 26; i++)
294*6765Srrh 		if (board[i] != code[i])
295*6765Srrh 			norec (s);
296*6765Srrh 	if (lseek (fdesc,(long) sizeof code,0) == -1)
297*6765Srrh 		norec (s);
298*6765Srrh 	read (fdesc,board,52);
299*6765Srrh 	read (fdesc,off,4);
300*6765Srrh 	read (fdesc,in,4);
301*6765Srrh 	read (fdesc,dice,4);
302*6765Srrh 	read (fdesc,&cturn,2);
303*6765Srrh 	read (fdesc,&dlast,2);
304*6765Srrh 	read (fdesc,&pnum,2);
305*6765Srrh 	read (fdesc,&rscore,2);
306*6765Srrh 	read (fdesc,&wscore,2);
307*6765Srrh 	read (fdesc,&gvalue,2);
308*6765Srrh 	read (fdesc,&raflag,2);
309*6765Srrh 	close (fdesc);
310*6765Srrh 	rflag = 1;
311*6765Srrh }
312*6765Srrh 
313*6765Srrh norec (s)
314*6765Srrh register char	*s;
315*6765Srrh 
316*6765Srrh {
317*6765Srrh 	register char	*c;
318*6765Srrh 
319*6765Srrh 	tflag = 0;
320*6765Srrh 	writel (cantrec);
321*6765Srrh 	c = s;
322*6765Srrh 	while (*c != '\0')
323*6765Srrh 		writec (*c++);
324*6765Srrh 	getout ();
325*6765Srrh }
326