-
Notifications
You must be signed in to change notification settings - Fork 0
/
ringoban 1.6
404 lines (404 loc) · 17.8 KB
/
ringoban 1.6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
10 GOSUB 900: REM Initialise, intro
15 GOSUB 4000: REM Read catalog, select directory DI$
17 IF LV$ = "/RINGOBAN/SAVED.GAMES" THEN 3500
20 GOSUB 2000: REM Select level F$
25 GOSUB 1200: REM Load & display level
97 :
98 REM display stats
99 :
100 VTAB VT: HTAB HT: IF (T / 2 = INT (T / 2)) THEN PRINT P2$;: GOTO 120
110 PRINT P1$;
120 VTAB 6: HTAB 33: PRINT MID$ (LE$,11,8)
130 VTAB 12: HTAB 35: PRINT MO;: VTAB 15: HTAB 35: PRINT PU;
140 VTAB 18: HTAB 35: PRINT BO;: VTAB 21: HTAB 35: PRINT BC:
147 :
148 REM win?
149 :
150 IF BC = BO THEN GOTO 800
197 :
198 REM get K$
199 :
200 VTAB 24: HTAB 1: IF PEEK ( - 16384) < 128 THEN 200
210 GET K$:K = ASC (K$) - 32 * ( ASC (K$) > 96)
220 IF K = 11 OR K = 73 THEN V = - 1:H = 0: GOTO 350: REM up
230 IF K = 10 OR K = 75 THEN V = 1:H = 0: GOTO 350: REM down
240 IF K = 8 OR K = 74 THEN V = 0:H = - 1: GOTO 350: REM left
250 IF K = 21 OR K = 76 THEN V = 0:H = 1: GOTO 350: REM right
260 IF K = 81 THEN CALL - 958: GOTO 810: REM q
265 IF K = 83 THEN GOSUB 3300: GOTO 100: REM s
270 IF K = 85 THEN GOSUB 1450: GOTO 100: REM u
275 IF K = 82 THEN GOTO 3500: REM r
280 IF K = 90 THEN GOSUB 600: GOTO 100: REM z
290 IF K = 78 THEN 850: REM n
300 IF K = 19 THEN GOSUB 1700: REM ^s
310 IF K = 18 THEN GOSUB 1800: GOTO 100: REM ^r
320 GOTO 200
347 :
348 REM process move
349 :
350 IF (LV(VT + V,HT + H) = 0) OR (LV(VT + V,HT + H) = 2 AND (LV(VT + V + V,HT + H + H) = 0 OR LV(VT + V + V,HT + H + H) = 2 OR LV(VT + V + V,HT + H + H) = 4)) OR (LV(VT + V,HT + H) = 4 AND (LV(VT + V + V,HT + H + H) = 0 OR LV(VT + V + V,HT + H + H) = 2 OR LV(VT + V + V,HT + H + H) = 4)) THEN 200
355 Z = 1: IF LV(VT + V,HT + H) = 1 THEN MO = MO + 1: GOTO 540
360 IF LV(VT + V,HT + H) = 3 THEN MO = MO + 1: GOTO 540
369 :
370 REM process push
371 :
380 Z = 2
390 IF LV(VT + V,HT + H) = 2 AND LV(VT + V + V,HT + H + H) = 1 THEN 440
400 IF LV(VT + V,HT + H) = 2 AND LV(VT + V + V,HT + H + H) = 3 THEN 460
410 IF LV(VT + V,HT + H) = 4 AND LV(VT + V + V,HT + H + H) = 1 THEN 480
420 IF LV(VT + V,HT + H) = 4 AND LV(VT + V + V,HT + H + H) = 3 THEN 500
430 GOTO 200
440 LV(VT + V + V,HT + H + H) = 2
450 VTAB VT + V + V: HTAB HT + H + H: PRINT BO$;: GOTO 520
460 LV(VT + V + V,HT + H + H) = 4
470 VTAB VT + V + V: HTAB HT + H + H:BC = BC + 1: PRINT BC$;: GOTO 520
480 LV(VT + V + V,HT + H + H) = 2
490 VTAB VT + V + V: HTAB HT + H + H:BC = BC - 1: PRINT BO$;: GOTO 520
500 LV(VT + V + V,HT + H + H) = 4
510 VTAB VT + V + V: HTAB HT + H + H: PRINT BC$;
520 LV(VT + V,HT + H) = 1:PU = PU + 1
530 IF MID$ (A$(VT + V),HT + H,1) = "." OR MID$ (A$(VT + V),HT + H,1) = "*" OR MID$ (A$(VT + V),HT + H,1) = "+" THEN LV(VT + V,HT + H) = 3
540 IF MID$ (A$(VT),HT,1) = "." OR MID$ (A$(VT),HT,1) = "*" OR MID$ (A$(VT),HT,1) = "+" THEN VTAB VT: HTAB HT: PRINT ".";: GOTO 560
550 VTAB VT: HTAB HT: PRINT " ";
560 VT = VT + V:HT = HT + H:T = T + 1:VM = V:HM = H: GOTO 100
597 :
598 REM undo
599 :
600 V = VM:H = HM: IF Z = 0 THEN 200
610 IF Z = 2 THEN 670
619 :
620 REM undo move
621 :
630 LV(VT,HT) = 1: VTAB VT: HTAB HT: PRINT " "
640 IF MID$ (A$(VT),HT,1) = "." OR MID$ (A$(VT),HT,1) = "+" OR MID$ (A$(VT),HT,1) = "*" THEN LV(VT,HT) = 3: VTAB VT: HTAB HT: PRINT "."
650 MO = MO - 1: GOTO 760
659 :
660 REM undo push
661 :
670 IF LV(VT + V,HT + H) = 4 THEN LV(VT + V,HT + H) = 3
680 IF LV(VT + V,HT + H) = 2 THEN LV(VT + V,HT + H) = 1: GOTO 720
690 VTAB VT + V: HTAB HT + H: PRINT ".": VTAB VT: HTAB HT: PRINT BO$
700 BC = BC - 1:LV(VT,HT) = 2
710 GOTO 740
720 VTAB VT + V: HTAB HT + H: PRINT " ": VTAB VT: HTAB HT: PRINT BO$
730 LV(VT,HT) = 2
740 IF MID$ (A$(VT),HT,1) = "." OR MID$ (A$(VT),HT,1) = "*" OR MID$ (A$(VT),HT,1) = "+" THEN VTAB VT: HTAB HT: PRINT BC$:LV(VT,HT) = 4:BC = BC + 1
750 PU = PU - 1
760 VT = VT - V:HT = HT - H:T = T - 1:Z = 0: RETURN
797 :
798 REM level solved
799 :
800 VTAB 22: PRINT "Level ";C;" solved! "
805 PRINT D$"lock"LE$:F$(C) = "*" + F$
810 VTAB 23: HTAB 1: CALL - 958: PRINT " Another level? (y/n) ";: GET K$
820 IF K$ = "N" OR K$ = "n" THEN HOME : VTAB 10: PRINT "Bye!": END
830 IF K$ = "Y" OR K$ = "y" THEN GOTO 850
840 GOTO 810
847 :
848 REM get new level
849 :
850 HOME : VTAB 10: HTAB 12: PRINT HG$;" cleaning up ";HG$
860 B$ = "": FOR I = 0 TO 22:A$(I) = "": VTAB 14: PRINT "> ";: FOR J = 0 TO 32:LV(I,J) = 0: NEXT : NEXT
870 HH = 0:VV = 0:LL = 0:ST = 0:C = 8: IF CC > 8 THEN C = CC
880 VTAB 22: HTAB 5: GOSUB 2100: GOTO 25
897 :
898 REM initialise
899 :
900 DIM A$(22),F$(350),DI$(51,1),LV(22,32),LE(350)
905 D$ = CHR$ (4):M1$ = CHR$ (15) + CHR$ (27):M0$ = CHR$ (14) + CHR$ (24):P1$ = M1$ + "]" + M0$:P2$ = "+"
910 W1$ = M1$ + "W" + M0$:W2$ = M1$ + "V" + M0$:BC$ = M1$ + "@" + M0$:BO$ = M1$ + "A" + M0$:HG$ = M1$ + "C" + M0$:PA$ = " "
915 HT = 0:VT = 0:V = 0:H = 0:VM = 0:HM = 0:MO = 0:PU = 0:Z = 0:T = 0:ST = 0:C = 8:N = 0
920 for I = 0 TO 9: SG$(I+1)="GAME."+STR$(I): NEXT
947 :
948 REM introduction
949 :
950 PRINT D$"pr#3"
960 HOME : HTAB 16: PRINT BC$;" RINGOBAN - a Sokoban clone in Applesoft BASIC ";BC$
970 PRINT : HTAB 3: PRINT BC$;" Original game: Hiroyuki Imabayashi ";BC$;" Published by Thinking Rabbit, 1982 ";BC$
980 PRINT : HTAB 21: PRINT BC$;" This version by Mike Beaumont, 2021 ";BC$
990 FOR I = 1 TO 80: PRINT "_";: NEXT
1000 PRINT : HTAB 9: PRINT BO$;" The game where you, a warehouse worker, must move all the"
1010 HTAB 13: PRINT "boxes (";BO$;") to their correct places as marked by '.'"
1020 PRINT : HTAB 9: PRINT BO$;" You may only push boxes, and only one at a time."
1030 PRINT : HTAB 9: PRINT BO$;" You must be careful to avoid an impossible-to-move"
1040 HTAB 13: PRINT "situation, for example a box in a corner."
1050 PRINT : HTAB 9: PRINT BO$;" Move using the arrow keys, or the 'ijkl' inverted 'T'."
1060 PRINT : HTAB 9: PRINT BO$;" Other commands:"
1070 HTAB 13: PRINT "z: undo the last move, n: select new level, s: save a game"
1075 HTAB 13: PRINT "u: reset the level, q: quit the game, r: resume a saved game"
1080 HTAB 15: PRINT "ctrl-s: store position & ctrl-r: restore position."
1085 GOSUB 1160
1090 VTAB 8: CALL - 958: HTAB 6: PRINT BO$;" Sokoban is a copyrighted work created by Hiroyuki Imabayashi.": PRINT : PRINT
1095 HTAB 6: PRINT BO$;" 'Sokoban' and 'sokoban' are registered trademarks of Falcon Co., Ltd.": PRINT : PRINT
1100 HTAB 6: PRINT BO$;" This version is a tribute to Imabayashi-sensei. Arigato gozaimashita!": PRINT : PRINT
1105 GOSUB 1160
1125 VTAB 7: CALL - 958: PRINT : HTAB 6: PRINT BO$;" Ver 2.0, Jul 2024: Save game implemented.": HTAB 28: PRINT "Additional levels directories."
1127 HTAB 28: PRINT "Moved to 800K disk fomat.": HTAB 28: PRINT "More cosmetic tweaks!": PRINT
1130 HTAB 6: PRINT BO$;" Ver 1.5, Oct 2022: Improved levels selection.": HTAB 28: PRINT "Already solved levels are marked by being locked.": HTAB 28: PRINT "Cosmetic tweaks.": PRINT
1135 HTAB 6: PRINT BO$;" Ver 1.1, Aug 2022: Undo could behave badly - fixed.": HTAB 28: PRINT "Minor cosmetic changes.": HTAB 28: PRINT "Boot disk from ProDOS 8 v2.4.2": PRINT
1140 HTAB 6: PRINT BO$;" Ver 1.0, Nov 2021: First release": PRINT : PRINT
1145 GOSUB 1160
1150 PRINT CHR$ (17): HOME : RETURN
1160 VTAB 22: FOR I = 0 TO 79: PRINT "_";: NEXT : VTAB 24: HTAB 26: PRINT BC$;" press [space] to continue ";BC$;
1165 VTAB 22: IF PEEK ( - 16384) < 128 THEN 1165
1170 GET K$:K = ASC (K$) - 32 * ( ASC (K$) > 96)
1175 IF K < > 32 THEN 1165
1180 RETURN
1197 :
1198 REM read level
1199 :
1200 HOME
1210 A$(0) = LE$:LE = LE(C):I = 1
1220 VTAB 10: PRINT "Reading level..."
1230 PRINT D$"open"LE$
1240 PRINT D$"read"LE$
1250 FOR J = 1 TO LE
1260 GET X$:B$ = B$ + X$
1270 IF ASC (X$) = 13 THEN A$(I) = B$:B$ = "":I = I + 1: VTAB 14: PRINT "> ";
1280 NEXT
1290 PRINT D$"close"
1355 VTAB 10: HTAB 1: PRINT "Processing..."
1359 :
1360 REM centre level
1361 :
1370 HH = 0: FOR J = 1 TO 22:LL = LEN (A$(J)) - 1: IF HH < LL THEN HH = LL
1380 NEXT : IF HH > 31 THEN 1400
1385 HH = INT ((32 - HH) / 2): IF HH < 1 THEN 1400
1390 IF I > 22 THEN I = 22
1395 FOR J = 1 TO I:A$(J) = LEFT$ (PA$,HH) + A$(J): NEXT
1400 IF I < 21 THEN VV = INT ((22 - I) / 2): FOR J = I TO 1 STEP - 1:A$(J + VV) = A$(J): NEXT
1410 IF VV > 0 THEN FOR J = 1 TO VV:A$(J) = "": NEXT
1415 IF RE THEN 3000
1447 :
1448 REM display level
1449 :
1450 HOME : VTAB 23: PRINT "Displaying level..."
1455 VTAB 1: HTAB 1:BO = 0:BC = 0:MO = 0:PU = 0
1460 FOR Y = 1 TO 22: FOR X = 1 TO LEN (A$(Y)):B$ = MID$ (A$(Y),X,1)
1470 IF B$ = "#" THEN LV(Y,X) = 0: IF (X / 2 = INT (X / 2)) THEN PRINT W1$;: GOTO 1490
1480 IF B$ = "#" THEN PRINT W2$;
1490 IF B$ = " " THEN LV(Y,X) = 1: PRINT B$;
1500 IF B$ = "$" THEN LV(Y,X) = 2: PRINT BO$;
1510 IF B$ = "." THEN LV(Y,X) = 3: PRINT ".";:BO = BO + 1
1520 IF B$ = "*" THEN LV(Y,X) = 4: PRINT BC$;:BO = BO + 1:BC = BC + 1
1530 IF B$ = "@" THEN LV(Y,X) = 1: PRINT P2$;:VT = Y:HT = X
1540 IF B$ = "+" THEN LV(Y,X) = 3: PRINT ".";:BO = BO + 1:VT = Y:HT = X
1550 NEXT : PRINT : NEXT
1560 VTAB 2: HTAB 33: PRINT "Ring";BO$;"b";BC$;"n"
1565 VTAB 3: HTAB 33: PRINT M1$"LLLLLLLL"M0$
1567 VTAB 5: HTAB 34: PRINT "Folder"
1570 VTAB 8: HTAB 34: PRINT "Level": VTAB 9: HTAB 35: PRINT C
1580 VTAB 11: HTAB 34: PRINT "Moves"
1590 VTAB 14: HTAB 34: PRINT "Pushes"
1600 VTAB 17: HTAB 34: PRINT "Boxes"
1610 VTAB 20: HTAB 34: PRINT "Placed"
1620 VTAB 23: CALL - 958: PRINT " z:undo n:new s:save ^s:snapshot": PRINT " u:reset q:quit r:resume ^r:restore";
1630 RETURN
1697 :
1698 REM store
1699 :
1700 VTAB 23: CALL - 958
1705 PRINT "Saving position...":ST = 1
1710 PRINT D$"store ringo"
1715 GOSUB 1620
1720 RETURN
1797 :
1798 REM restore
1799 :
1800 VTAB 23: CALL - 958
1805 IF ST = 1 THEN 1815
1810 PRINT " No snapshot in memory.";: FOR I = 1 TO 1000: NEXT : INPUT " Press return.";K$: GOTO 1860
1815 PRINT "Restoring..."
1820 PRINT D$"restore ringo"
1830 FOR I = 1 TO 22: FOR J = 1 TO 32
1835 IF LV(I,J) = 1 THEN VTAB I: HTAB J: PRINT " "
1840 IF LV(I,J) = 2 THEN VTAB I: HTAB J: PRINT BO$
1845 IF LV(I,J) = 3 THEN VTAB I: HTAB J: PRINT "."
1850 IF LV(I,J) = 4 THEN VTAB I: HTAB J: PRINT BC$
1855 NEXT : NEXT : VTAB VT: HTAB HT: PRINT P1$
1860 GOSUB 1620
1865 RETURN
1997 :
1998 REM read directory
1999 :
2000 HOME : VTAB 10: HTAB 10: PRINT HG$" reading directory "HG$: PRINT
2005 N = 0:C = 8
2010 PRINT D$"OPEN"LV$",TDIR": PRINT D$"READ"LV$
2020 INPUT N1$,N2$,N$:N1$ = N1$ + "/"
2030 INPUT N$: IF N$ = "" THEN PRINT : GOTO 2050
2040 N = N + 1:F$(N) = LEFT$ (N$,16):LE(N) = VAL ( MID$ (N$,69,3)): VTAB 14: PRINT "> ";: GOTO 2030
2050 PRINT D$"CLOSE"
2060 FOR I = N + 1 TO 350:F$(I) = "": NEXT
2097 :
2098 REM display directory
2099 :
2100 HOME : PRINT " "M1$"XY"M0$" = "LV$: VTAB 3: PRINT " Completed levels are marked by '*'.": FOR I = 1 TO 40: PRINT "_";: NEXT
2110 VTAB 21: FOR I = 1 TO 40: PRINT "_";: NEXT : VTAB 23: HTAB 3: PRINT "Use arrow keys & <return> to select";
2120 POKE 32,13: PRINT
2130 IF N < 8 THEN C = 1:TP = 1: VTAB 6: INVERSE : PRINT F$(C): NORMAL : FOR L = 2 TO N: PRINT F$(L): NEXT : GOTO 2200
2140 GOTO 2170
2150 IF C < 1 OR C > N THEN C = C + (A = 11) - (A = 10): GOTO 2200
2160 IF C < 8 OR C > (N - 7) THEN VTAB 5 + (C - TP): PRINT F$(C - 1): INVERSE : PRINT F$(C): NORMAL : PRINT F$(C + 1): GOTO 2200
2170 TP = C - 7: VTAB 6
2180 FOR L = TP TO C - 1: PRINT F$(L): NEXT : INVERSE : PRINT F$(L): NORMAL : FOR L = L + 1 TO TP + 14: PRINT F$(L): NEXT
2197 :
2198 REM choose level
2199 :
2200 VTAB 22: HTAB 1: IF PEEK ( - 16384) < 128 THEN 2200
2210 GET A$:A = ASC (A$) - 32 * ( ASC (A$) > 96): PRINT
2215 IF A = 8 OR A = 21 THEN A = (11 * (A = 8)) + (10 * (A = 21))
2220 IF A = 10 OR A = 11 THEN C = C + (A = 10) - (A = 11): GOTO 2150
2230 F$ = MID$ (F$(C),2,15)
2240 IF A > 48 AND A < 58 THEN O = A - 49:C = (A = 49) + INT (O * (N / 8)): GOSUB 2300: GOTO 2200
2250 IF A = 13 THEN PRINT : POKE 32,0:LE$ = LV$ + "/" + F$:CC = C: RETURN
2260 IF A = 27 THEN POP :C = 8:N = 0: GOTO 15
2270 GOTO 2200
2297 :
2298 REM refresh display
2299 :
2300 IF C < 9 THEN TP = 1
2310 IF C > 8 THEN TP = C - 7
2320 IF C > N - 8 THEN TP = N - 14
2330 IF TP < 1 THEN TP = 1
2340 VTAB 6
2350 IF C < > 1 THEN FOR L = TP TO C - 1: PRINT F$(L): NEXT
2360 IF C = 1 THEN L = 1
2370 INVERSE : PRINT F$(L): NORMAL
2380 FOR L = L + 1 TO TP + 14: PRINT F$(L): NEXT
2390 RETURN
2397 :
2398 REM end routine
2399 :
2400 VTAB 23: HTAB 1: CALL - 958: PRINT " Are you sure you want to quit? (y/n) ";: GET K$
2405 IF K$ = "N" OR K$ = "n" THEN GOTO 15
2410 IF K$ = "Y" OR K$ = "y" THEN 2420
2415 GOTO 2400
2420 HOME : VTAB 10: PRINT "Bye!": END
2997 :
2998 REM new display
2999 :
3000 HOME : VTAB 23: PRINT "Displaying level..."
3005 VTAB 1: HTAB 1:BO = 0:BC = 0:MO = 0:PU = 0
3010 FOR Y = 1 TO 22: FOR X = 1 TO LEN (A$(Y)):B$ = MID$ (A$(Y),X,1)
3015 IF B$ = "#" THEN LV(Y,X) = 0: IF (X / 2 = INT (X / 2)) THEN PRINT W1$;: GOTO 3025
3020 IF B$ = "#" THEN PRINT W2$;
3025 IF B$ = " " THEN PRINT B$;
3030 IF B$ = "$" THEN PRINT " ";
3035 IF B$ = "." THEN PRINT ".";
3040 IF B$ = "*" THEN PRINT ".";
3045 IF B$ = "@" THEN PRINT " ";
3050 IF B$ = "+" THEN PRINT ".";
3055 NEXT : PRINT : NEXT
3060 PRINT D$"restore"VA$
3065 VTAB 23: PRINT " Restoring level..."
3070 FOR I = 1 TO 22: FOR J = 1 TO 32
3075 IF LV(I,J) = 1 THEN VTAB I: HTAB J: PRINT " "
3080 IF LV(I,J) = 2 THEN VTAB I: HTAB J: PRINT BO$
3085 IF LV(I,J) = 3 THEN VTAB I: HTAB J: PRINT "."
3090 IF LV(I,J) = 4 THEN VTAB I: HTAB J: PRINT BC$
3095 NEXT : NEXT : VTAB VT: HTAB HT: PRINT P1$
3100 ST = 0: GOSUB 1560
3105 RETURN
3297 :
3298 REM save game
3299 :
3300 VTAB 22: CALL - 958: PRINT
3305 PRINT "Enter a # for the saved game (0-9): ";
3310 VTAB 23: HTAB 1: IF PEEK ( - 16384) < 128 THEN 3310
3315 GET K$:K = ASC (K$) - 32 * ( ASC (K$) > 96)
3320 IF K < 48 OR K > 57 THEN 3310
3325 GAME$ = "/ringoban/saved.games/game." + K$
3327 VTAB 22: CALL - 958: PRINT : PRINT "Saving game GAME."K$
3330 VTAB 23: PRINT D$"open"GAME$
3332 PRINT D$"write"GAME$
3335 PRINT LE$
3336 PRINT LE: PRINT C
3337 PRINT LV$
3340 PRINT D$"CLOSE"
3342 GAME$ = "/ringoban/saved.games/var." + K$
3345 VTAB 23: PRINT D$"STORE"GAME$
3350 GOSUB 1620
3355 RETURN
3497 :
3498 REM Restore
3499 :
3500 HOME : PRINT " "M1$"XY"M0$" = /RINGOBAN/SAVED.GAMES/": PRINT : FOR I = 1 TO 40: PRINT "_";: NEXT
3505 VTAB 21: FOR I = 1 TO 40: PRINT "_";: NEXT : VTAB 23: HTAB 3: PRINT "Use arrow keys & <return> to select";
3510 FOR I = 0 TO 22:A$(I) = "": NEXT
3515 FOR I = 1 TO 10: GOSUB 3575: NEXT :I = 1: GOTO 3570
3520 IF PEEK ( - 16384) < 128 THEN 3520
3525 GET K$:K = ASC (K$) - 32 * ( ASC (K$) > 96)
3530 GOSUB 3575: IF K = 27 THEN: C = 8:N = 0: GOTO 15
3535 IF K = 13 THEN I = I - 1: GOTO 3600
3540 IF K = 8 OR K = 11 THEN I = I - 1: GOTO 3560
3545 IF K = 10 OR K = 21 OR K = 32 THEN I = I + 1: GOTO 3560
3560 IF I < 1 THEN I = 10
3565 IF I > 10 THEN I = 1
3570 VTAB I + 5: HTAB 15: INVERSE : PRINT SG$(I): NORMAL : GOTO 3520
3574 :
3575 VTAB I + 5: HTAB 15: PRINT SG$(I): RETURN
3600 PRINT
3605 LE$ = "/ringoban/saved.games/game." + STR$ (I)
3607 VA$ = "/ringoban/saved.games/var." + STR$ (I)
3610 PRINT D$"open"LE$
3615 PRINT D$"read"LE$
3620 INPUT LE$
3625 INPUT LE: INPUT C
3626 INPUT LV$
3630 PRINT D$"close"
3635 LE(C) = LE:RE = 1
3640 GOTO 25
3997 :
3998 REM read catalog
3999 :
4000 TEXT : HOME : VTAB 10: HTAB 12: PRINT HG$" reading catalog "HG$: PRINT
4010 PRINT D$"open /ringoban/,tdir"
4015 PRINT D$"read/ringoban/"
4020 INPUT N1$,N2$,N$:N1$ = N1$ + "/"
4030 INPUT N$: IF N$ = "" THEN PRINT : GOTO 4050
4035 IF MID$ (N$,18,3) < > "DIR" THEN 4030
4040 N = N + 1: GOSUB 4070: VTAB 14: PRINT "> ";: GOTO 4030
4050 PRINT D$"CLOSE"
4055 GOTO 4100
4060 FOR I = N TO 51:DI$(I) = "": NEXT
4065 :
4070 N$ = MID$ (N$,2,15):DI$(N,1) = N$: FOR I = 2 TO 17: IF MID$ (N$,I,1) = " " THEN DI$(N,0) = LEFT$ (N$,I - 1):I = 17
4080 NEXT : RETURN
4097 :
4098 REM display directories
4099 :
4100 HOME : PRINT " /RINGOBAN/": VTAB 3: PRINT " Displaying directories.": FOR I = 1 TO 40: PRINT "_";: NEXT
4110 VTAB 21: FOR I = 1 TO 40: PRINT "_";: NEXT : VTAB 23: HTAB 3: PRINT "Use arrow keys & <return> to select";
4120 POKE 32,13: PRINT
4130 C = 1:TP = 1: VTAB 6: INVERSE : PRINT DI$(C,1): NORMAL : FOR L = 2 TO 15: PRINT DI$(L,1): NEXT : GOTO 4200
4140 GOTO 4170
4150 IF C < 1 OR C > N THEN C = C + (A = 11) - (A = 10): GOTO 4200
4160 IF C < 8 OR C > (N - 7) THEN VTAB 5 + (C - TP): PRINT DI$(C - 1,1): INVERSE : PRINT DI$(C,1): NORMAL : PRINT DI$(C + 1,1): GOTO 4200
4170 TP = C - 7: VTAB 6
4180 FOR L = TP TO C - 1: PRINT DI$(L,1): NEXT : INVERSE : PRINT DI$(L,1): NORMAL : FOR L = L + 1 TO TP + 14: PRINT DI$(L,1): NEXT
4197 :
4198 REM choose directory
4199 :
4200 VTAB 22: HTAB 1: IF PEEK ( - 16384) < 128 THEN 4200
4210 GET A$:A = ASC (A$) - 32 * ( ASC (A$) > 96): PRINT
4215 IF A = 8 OR A = 21 THEN A = (11 * (A = 8)) + (10 * (A = 21))
4220 IF A = 10 OR A = 11 THEN C = C + (A = 10) - (A = 11): GOTO 4150
4230 DI$ = DI$(C,0)
4240 IF A > 48 AND A < 58 THEN O = A - 49:C = (A = 49) + INT (O * (N / 8)): GOSUB 4300: GOTO 4200
4250 IF A = 13 THEN PRINT : POKE 32,0:LV$ = "/RINGOBAN/" + DI$:CC = C: RETURN
4255 REM IFLV$ = "/RINGOBAN/SAVED.GAMES/" THEN 3500
4265 IF A = 27 THEN POP : POKE 32,0:C = 8:N = 0: GOTO 2400
4270 GOTO 4200
4297 :
4298 REM refresh display
4299 :
4300 IF C < 9 THEN TP = 1
4310 IF C > 8 THEN TP = C - 7
4320 IF C > N - 8 THEN TP = N - 14
4330 IF TP < 1 THEN TP = 1
4340 VTAB 6
4350 IF C < > 1 THEN FOR L = TP TO C - 1: PRINT DI$(L,1): NEXT
4360 IF C = 1 THEN L = 1
4370 INVERSE : PRINT DI$(L,1): NORMAL
4380 FOR L = L + 1 TO TP + 14: PRINT DI$(L,1): NEXT
4390 RETURN