home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2002 September / PCPlus_193_Laplink2000.iso / Prog / wilf / RUBOT.BAS next >
Encoding:
BASIC Source File  |  2004-04-29  |  79.6 KB  |  2,686 lines

  1. '+-------------------------------------------------------------------+
  2. '▌                                                                   ▌
  3. '▌ R U B O T                                                         ▌
  4. '▌                                                                   ▌
  5. '+-------------------------------------------------------------------+
  6. '<->
  7. DEFINT A-Z
  8. DECLARE SUB ziPublish (Printstring$, size, italic)
  9. ' Print a string at graphics cursor (advanced)
  10. '   Size   = magnitude (per 8 pixels)
  11. '   Italic = +1 to make italic
  12. '          = +2 to make overprint (no background)
  13.  
  14. DECLARE SUB ziPublishHere (Row, Col, Printstring$, size, italic)
  15. ' Print a string at the specified text position
  16.  
  17. DECLARE SUB zsAlignGCursor ()
  18. ' Align graphic cursor to same as text cursor
  19. '  - sets Row, Col, GXloc, GYloc
  20.  
  21. DECLARE SUB zsAlignTCursor ()
  22. ' Align text cursor to same as graphic cursor
  23. '  - sets Row, Col, GXloc, GYloc
  24.  
  25. DECLARE SUB zsLocateGCursor (XCoord, YCoord)
  26. ' Locate graphic cursor to a named point
  27.  
  28. DECLARE SUB zsPastel (XCoord, YCoord, Wide, Deep, colour1, colour2)
  29. ' Colour the defined oblong with a pastel mix of two colours
  30. '  Deep = 0 or 1 - square
  31. '       = n      - Y-pixel depth
  32.  
  33. DECLARE SUB zsSetScrnMode (Mode, HiRows, HiCols)
  34. ' Mode = 9, 12 or 13
  35. ' HiRows = 1 to make high number of rows
  36. ' HiCols = 1 to make high number of cols (80)
  37. ' Set SCREEN parameters and blank the screen
  38. '  - sets ScrnMode, Xmax, Ymax, Rows, Cols, XYRatio!
  39. '  - uses FG and optionally BG (colours)
  40.  
  41. DECLARE SUB zsSubstitute (XCoord, YCoord, Wide, Deep, colour1, colour2)
  42. ' Substitute one colour with another within the defined oblong
  43. '  Deep = 0 or 1 - square
  44. '       = n      - Y-pixel depth
  45.  
  46. '/==============================================/
  47. '/  UK copyright (c) 2002 by Future Publishing  /
  48. '/==============================================/
  49.  
  50. CONST Pi! = 3.14159
  51. CONST Ex! = 2.71828
  52. CONST DegToRad! = .0174533
  53. CONST RadToDeg! = 57.2958
  54.  
  55. DIM SHARED Bad
  56. DIM SHARED ScrnMode, Bg, Fg
  57. DIM SHARED Xmax, Ymax, GXloc, GYloc, XYratio!
  58. DIM SHARED Rows, Cols, Row, Col
  59. DIM SHARED Font(255, 7)
  60. DIM SHARED Shades(7, 4) AS STRING * 8
  61.  
  62. '++++++++++++++++++++++++
  63. RANDOMIZE TIMER
  64. ON ERROR GOTO RESUMENEXT
  65. RESUMENEXT:
  66.   IF ERR THEN
  67.     Bad = ERR
  68.     RESUME NEXT
  69.   END IF
  70. '/==================================/'
  71. '/  End of Standard Piecrust code   /'
  72. '/==================================/'
  73. '<+>
  74. Bg = 8: Fg = 0: zsSetScrnMode 12, 1, 1
  75.  
  76. DIM Temp(15)
  77.  
  78. CubeShape:
  79.  
  80. XUpright = 49: YUpright = 36
  81. XInverse = -591: YInverse = -320
  82.  
  83. ' outline (foreshortened view from above)
  84.  DATA 999,  111,  0,    0, 54,    0,195
  85.  DATA       111,288,  222,195,  222, 54,  111,   0
  86.  DATA         0, 53,  111,125,  222, 53,  222,  55
  87.  DATA       112,127,  112,288,  110,288,  110, 127
  88.  DATA         0, 55,    0, 54,  111,126,  222,  54
  89.  DATA 999,  111,126,  111,288
  90.  
  91. ' lattice lines
  92.  DATA 999,   74, 18,  185, 78,  185,226
  93.  DATA 999,   37, 36,  148,102,  148,257
  94.  
  95.  DATA 999,  148, 18,   37, 78,   37,226
  96.  DATA 999,  185, 36,   74,102,   74,257
  97.  
  98.  DATA 999,    0,101,  111,180,  222,101
  99.  DATA 999,    0,148,  111,234,  222,148
  100.  
  101.  DATA 999,999
  102.  
  103. ' Draw the cube TWICE: the second time, inverted
  104.  
  105. XCorner = XUpright: YCorner = YUpright
  106. DO
  107.  DO
  108.   READ XCoord, YCoord
  109.   IF XCoord = 999 THEN
  110.    IF YCoord = 999 THEN EXIT DO
  111.    XCoord = YCoord
  112.    READ YCoord
  113.    PSET (ABS(XCoord + XCorner), ABS(YCoord + YCorner))
  114.   ELSE
  115.    LINE -(ABS(XCoord + XCorner), ABS(YCoord + YCorner)), 0
  116.   END IF
  117.  LOOP
  118.  IF XCorner < 0 THEN EXIT DO
  119.  RESTORE CubeShape
  120. ' negative coordinates for inverted image
  121.  XCorner = XInverse: YCorner = YInverse
  122. LOOP
  123.  
  124. PAINT (0, 0), 11, 0
  125. Bg = 15
  126. LINE (213, 5)-STEP(190, 54), 0, B
  127. PAINT (214, 6), Bg, 0
  128. Fg = 4: zsLocateGCursor 216, 8
  129. ziPublish "ESC", 1, 2: Fg = 0: ziPublish "-End", 1, 3
  130. Fg = 4: zsLocateGCursor 312, 8
  131. ziPublish "HOME", 1, 2: Fg = 0: ziPublish "-Reset", 1, 3
  132. Fg = 4: zsLocateGCursor 216, 18
  133. ziPublish "DEL", 1, 2: Fg = 0: ziPublish "-Scramble", 1, 3
  134. Fg = 4: zsLocateGCursor 216, 28
  135. ziPublish " X ", 1, 2: Fg = 0: ziPublish "-Preset", 1, 3
  136. Fg = 4: zsLocateGCursor 320, 18
  137. ziPublish "TAB", 1, 2: Fg = 0: ziPublish "-Solve", 1, 3
  138. Fg = 4: zsLocateGCursor 320, 28
  139. ziPublish " Z ", 1, 2: Fg = 0: ziPublish "-CTR=0", 1, 3
  140. Fg = 4: zsLocateGCursor 216, 38
  141. ziPublish "  [T]  ", 1, 2: Fg = 0: ziPublish "-", 1, 3
  142. ziPublish "UP", 1, 2: ziPublish " or ", 1, 3: ziPublish "RIGHT", 1, 2
  143. Fg = 4: zsLocateGCursor 216, 48
  144. ziPublish "ctl+[T]", 1, 2: Fg = 0: ziPublish "-", 1, 3
  145. ziPublish "DOWN", 1, 2: ziPublish " or ", 1, 3: ziPublish "LEFT", 1, 2
  146.  
  147. LINE (0, 0)-(100, 32), 0, BF
  148. zsLocateGCursor 5, 8: Fg = 15: ziPublish "RUbot!", 2, 2
  149.  
  150.  
  151.  
  152. DIM VCube(6, 9)
  153. '               F, q --> face (1-6)
  154. '               p, C --> colour on face
  155.  
  156. FOR i = 1 TO 6
  157.  FOR j = 1 TO 9
  158.   VCube(i, j) = i
  159.  NEXT
  160. NEXT
  161.  
  162. DIM Face(6, 9, 2)
  163. '        N, q, r --> N = face
  164. '  At the start, the pure cube has face 1 Red, face 2 White,
  165. '  face 3 Blue, face 4 Green, face 5 Yellow, face 6 Orange
  166. '        p, N, r --> colour within middle cell for each face
  167. '        p, q, 1 --> x co-ordinate
  168. '        p, q, 2 --> y co-ordinate
  169.  
  170. '       LAYOUT OF CUBE: (at start)
  171.  
  172. '               W3 W6 W9
  173. '               W2 W5 W8
  174. '               W1 W4 W7
  175.  
  176. '    B7 B4 B1   R1 R2 R3   O9 O8 O7   G3 G6 G9
  177. '    B8 B5 B2   R4 R5 R6   O6 O5 O4   G2 G5 G8
  178. '    B9 B6 B3   R7 R8 R9   O3 O2 O1   G1 G4 G7
  179.  
  180. '               Y9 Y8 Y7
  181. '               Y6 Y5 Y4
  182. '               Y3 Y2 Y1
  183.  
  184. ' Note that the corner cubes are:
  185. '         R1-W1-B1    R3-W7-O9    R7-B3-Y9    R9-Y7-O3
  186. '         W3-B7-G9    W9-G3-O7    B9-G7-Y3    G1-Y1-O1
  187.  
  188. ' ..and the edge cubes are:
  189. '       R2-W4   R4-B2   R8-Y8   R6-O6   W2-B4   W6-G6
  190. '       W8-O8   B8-G8   B6-Y6   G4-Y2   G2-O4   Y4-O2
  191.  
  192. ' 'A' face co-ordinates
  193.  DATA 129,151,  166,115,  203, 90
  194.  DATA 129,193,  166,165,  203,138
  195.  DATA 129,246,  166,216,  203,187
  196.  
  197. ' 'B' face co-ordinates
  198.  DATA 111,102,   74, 78,   37, 54
  199.  DATA 148, 78,  111, 54,   74, 36
  200.  DATA 185, 54,  148, 36,  111, 18
  201.  
  202. ' 'C' co-ordinates
  203.  DATA  93,151,   93,193,   93,246
  204.  DATA  56,115,   56,165,   56,216
  205.  DATA  18, 90,   18,138,   18,187
  206.  
  207. FOR i = 1 TO 3
  208.  FOR j = 1 TO 9
  209.   READ M, n
  210.   Face(i, j, 1) = M + XUpright
  211.   Face(i, j, 2) = n + YUpright
  212.   Face(7 - i, j, 1) = ABS(M + XInverse)
  213.   Face(7 - i, j, 2) = ABS(n + YInverse)
  214.  NEXT
  215. NEXT
  216.  
  217. DIM Neighbours(4, 9)
  218. '              D, q       --> direction (1=North, 2=East, 3=South, 4=West)
  219. '              p, V (1-6) --> virtual face in that direction
  220. '              p, C (7-9) --> border cells on virtual face
  221.  
  222. '   Each face has three neighbours, and they border each
  223. '   other in this manner:
  224.  
  225. '                       North
  226. '                      N1 N4 N7
  227.    
  228. '                 W1   F1 F2 F3   E9
  229.  
  230. '           West  W2   F4 F5 F6   E6  East
  231.  
  232. '                 W3   F7 F8 F9   E3
  233.  
  234. '                      S9 S8 S7
  235. '                       South
  236.  
  237.  
  238. '         White                   Blue                     Red
  239. '   Blue   RED   Orange     Red   WHITE   Green     White  BLUE  Yellow
  240. '         Yellow                  Orange                   Green
  241.  
  242. '         Orange                  Green                   Yellow
  243. '  Yellow  GREEN  White    Orange YELLOW  Blue     Green  ORANGE  Red
  244. '          Blue                    Red                    White
  245.  
  246.  DATA 2,3,1,6,4,5,   1,4,7
  247.  DATA 6,4,5,2,3,1,   9,6,3
  248.  DATA 5,6,4,3,1,2,   7,8,9
  249.  DATA 3,1,2,5,6,4,   3,2,1
  250.  
  251. FOR i = 1 TO 4
  252.  FOR j = 1 TO 9
  253.   READ Neighbours(i, j)
  254.  NEXT
  255. NEXT
  256.  
  257. ' Colour control:      RED   =  1
  258. '                      WHITE =  2
  259. '                      BLUE  =  3
  260. '                      GREEN =  4
  261. '                      YELLOW = 5
  262. '                      ORANGE = 6
  263.  
  264. ' Note that RED and GREEN are opposite;
  265. '           WHITE and YELLOW are opposite;
  266. '           BLUE and ORANGE are opposite
  267.  
  268. DIM ColourTable(6)
  269.  DATA 4, 15, 1, 2, 14, 12
  270.  
  271. FOR i = 1 TO 6
  272.  READ ColourTable(i)
  273. NEXT
  274.  
  275. DIM Orient(40)
  276.  
  277. DIM Horizontal(19)
  278.  DATA 2,7,  0,1
  279.  DATA 5,3,  0,1
  280.  DATA 4,9,  6,7,  1,9,  3,3,  0,1
  281.  DATA 999
  282. FOR i = 1 TO 19
  283.  READ Horizontal(i)
  284. NEXT
  285.  
  286. DIM Vertical(19)
  287.  DATA 1,3,  0,1
  288.  DATA 4,7,  0,1
  289.  DATA 2,9,  3,7,  5,9,  6,3,  0,1
  290.  DATA 999
  291. FOR i = 1 TO 19
  292.  READ Vertical(i)
  293. NEXT
  294.  
  295.  
  296. ' put up labels for the slices
  297. Bg = 11: Fg = 0
  298. zsLocateGCursor 50, 260: ziPublish "L", 2, 0
  299. zsLocateGCursor 87, 291: ziPublish "M", 2, 0
  300. zsLocateGCursor 124, 322: ziPublish "R", 2, 0
  301.  
  302. zsLocateGCursor 180, 322: ziPublish "F", 2, 0
  303. zsLocateGCursor 217, 291: ziPublish "V", 2, 0
  304. zsLocateGCursor 254, 260: ziPublish "A", 2, 0
  305.  
  306. zsLocateGCursor 20, 103: ziPublish "T", 2, 0
  307. zsLocateGCursor 20, 150: ziPublish "H", 2, 0
  308. zsLocateGCursor 20, 197: ziPublish "B", 2, 0
  309.  
  310. Fg = 12
  311. zsLocateGCursor 570, 80: ziPublish "F", 2, 0
  312. zsLocateGCursor 533, 49: ziPublish "V", 2, 0
  313. zsLocateGCursor 496, 18: ziPublish "A", 2, 0
  314.  
  315. zsLocateGCursor 448, 18: ziPublish "L", 2, 0
  316. zsLocateGCursor 411, 49: ziPublish "M", 2, 0
  317. zsLocateGCursor 374, 80: ziPublish "R", 2, 0
  318.  
  319. zsLocateGCursor 605, 143: ziPublish "T", 2, 0
  320. zsLocateGCursor 605, 190: ziPublish "H", 2, 0
  321. zsLocateGCursor 605, 237: ziPublish "B", 2, 0
  322.  
  323. ' number the faces
  324. Fg = 15
  325. CIRCLE (285, 239), 15, 1: PAINT (285, 239), 1
  326. zsLocateGCursor 278, 231: ziPublish "1", 2, 2
  327. CIRCLE (160, 20), 15, 1: PAINT (160, 20), 1
  328. zsLocateGCursor 154, 12: ziPublish "2", 2, 2
  329. CIRCLE (35, 239), 15, 1: PAINT (35, 239), 1
  330. zsLocateGCursor 28, 231: ziPublish "3", 2, 2
  331.  
  332. CIRCLE (355, 117), 15, 1: PAINT (355, 117), 1
  333. zsLocateGCursor 347, 109: ziPublish "6", 2, 2
  334. CIRCLE (480, 336), 15, 1: PAINT (480, 336), 1
  335. zsLocateGCursor 472, 328: ziPublish "5", 2, 2
  336. CIRCLE (605, 117), 15, 1: PAINT (605, 117), 1
  337. zsLocateGCursor 597, 109: ziPublish "4", 2, 2
  338.  
  339. LINE (0, 350)-(Xmax, Ymax), 10, BF
  340. LINE (0, 349)-(Xmax, 350), 0, BF
  341. LINE (128, 350)-(129, Ymax), 0, BF
  342. LINE (422, 350)-(423, Ymax), 0, BF
  343.  
  344. ' set out area for status of central squares
  345. DIM Centres(6)
  346.  
  347. Bg = 11
  348. FOR i = 1 TO 6
  349.  Centres(i) = i
  350.  j = 353 + 16 * i
  351.  LINE (44, j)-STEP(13, 13), 0, B
  352.  PAINT (45, j + 1), ColourTable(i), 0
  353.  zsLocateGCursor 32, j + 4
  354.  Fg = 0: ziPublish MID$("RWBGYO", i, 1), 1, 2
  355. NEXT
  356.  
  357. ' set out area for status of Edge Pieces
  358. DIM Edges(12, 5)
  359. '          P, y --> sequential number of piece (domino-style)
  360. '          x, 1 --> lower colour number (1=Red, etc)
  361. '          x, 2 --> higher colour number
  362. '          x, 3 --> face for lower colour
  363. '          x, 4 --> face for higher colour
  364. '          x, 5 --> status: 0 = wrong place
  365. '                           1 = correct place
  366. '                           2 = correct alignment
  367. ix = 0
  368. FOR i = 1 TO 5
  369.  FOR j = i + 1 TO 6
  370.   IF j - i <> 3 THEN
  371.    ix = ix + 1
  372.    Edges(ix, 1) = i
  373.    Edges(ix, 2) = j
  374.    Edges(ix, 3) = i
  375.    Edges(ix, 4) = j
  376.    jx = 353 + 16 * ((ix - 1) MOD 6 + 1)
  377.    kx = 184 + 139 * ((ix - 1) \ 6)
  378.    LINE (kx, jx)-STEP(13, 13), 0, B
  379.    PAINT (kx + 1, jx + 1), ColourTable(i), 0
  380.    LINE (kx + 13, jx)-STEP(13, 13), 0, B
  381.    PAINT (kx + 14, jx + 1), ColourTable(j), 0
  382.    Fg = 0: zsLocateGCursor kx - 20, jx + 4
  383.    ziPublish MID$("RWBGYO", i, 1), 1, 2
  384.    ziPublish MID$("RWBGYO", j, 1), 1, 2
  385.   END IF
  386.  NEXT
  387. NEXT
  388.  
  389. ' set out area for status of Corner Pieces
  390. DIM Corners(8, 7)
  391. '           P, y --> sequential number of piece (domino-style)
  392. '           x, 1 --> lowest colour number (1=Red, etc)
  393. '           x, 2 --> higher colour number
  394. '           x, 3 --> highest colour
  395. '           x, 4 --> face for lowest colour
  396. '           x, 5 --> face for higher colour
  397. '           x, 6 --> face for highest colour
  398. '           x, 7 --> status: 0 = wrong place
  399. '                            1 = correct place
  400. '                            2 = correct alignment
  401. ix = 0
  402. FOR i = 1 TO 4
  403.  FOR j = i + 1 TO 5
  404.   FOR k = j + 1 TO 6
  405.    IF j - i <> 3 THEN 'insure against opposite sides
  406.     IF k - i <> 3 THEN
  407.      IF k - j <> 3 THEN
  408.       ix = ix + 1
  409.       Corners(ix, 1) = i
  410.       Corners(ix, 2) = j
  411.       Corners(ix, 3) = k
  412.       Corners(ix, 4) = i
  413.       Corners(ix, 5) = j
  414.       Corners(ix, 6) = k
  415.       jx = 337 + 16 * ix
  416.       LINE (488, jx)-STEP(13, 13), 0, B
  417.       PAINT (489, jx + 1), ColourTable(i), 0
  418.       LINE (501, jx)-STEP(13, 13), 0, B
  419.       PAINT (502, jx + 1), ColourTable(j), 0
  420.       LINE (514, jx)-STEP(13, 13), 0, B
  421.       PAINT (515, jx + 1), ColourTable(k), 0
  422.       Fg = 0: zsLocateGCursor 464, jx + 4
  423.       ziPublish MID$("RWBGYO", i, 1), 1, 2
  424.       ziPublish MID$("RWBGYO", j, 1), 1, 2
  425.       ziPublish MID$("RWBGYO", k, 1), 1, 2
  426.      END IF
  427.     END IF
  428.    END IF
  429.   NEXT
  430.  NEXT
  431. NEXT
  432. FOR i = 1 TO 6
  433.  FOR j = 1 TO 9
  434.   VCube(i, j) = i
  435.  NEXT
  436. NEXT
  437.  
  438. ' pre-recorded games
  439.  
  440. DIM Setup(9, 25)
  441.  
  442.  DATA 2,4,6,3,1,  4,6,5,3,3,  5,2,5,6,1,  6,2,4,3,3,  6,6,6,3,4
  443.  DATA 4,2,5,6,6,  4,5,5,5,3,  2,1,4,4,3,  5,1,6,6,1,  1,5,1,4,2
  444.  DATA 1,5,1,6,1,  2,1,1,5,6,  3,2,2,1,4,  5,6,1,2,5,  5,6,2,5,5
  445.  DATA 2,5,6,3,3,  2,4,5,2,5,  1,4,1,5,2,  6,5,1,2,2,  3,1,6,2,5
  446.  DATA 4,5,2,2,1,  1,2,1,6,5,  4,6,4,6,6,  1,1,6,5,6,  3,6,2,2,4
  447.  DATA 2,3,3,2,6,  5,1,1,5,6,  4,1,6,5,1,  4,4,3,3,2,  5,5,5,6,5
  448.  DATA 3,2,4,1,6,  5,3,3,5,2,  6,6,6,2,6,  1,1,2,1,2,  6,3,4,6,2
  449.  DATA 6,1,4,5,5,  2,2,1,5,2,  6,4,2,5,2,  4,6,2,5,4,  3,6,4,3,6
  450.  DATA 6,4,4,6,4,  2,3,2,2,6,  4,3,6,4,3,  1,1,1,5,5,  3,2,1,1,5
  451.  DATA 2,3,3,4,2,  2,5,1,2,1,  2,3,4,5,4,  4,3,1,2,3,  6,5,6,3,3
  452.  
  453. FOR i = 0 TO 9
  454.  FOR j = 1 TO 5
  455.   jx = 5 * j - 5
  456.   FOR k = 1 TO 5
  457.    READ Setup(i, jx + k)
  458.   NEXT
  459.  NEXT
  460. NEXT
  461.  
  462. DIM Macros(10, 10)
  463.  
  464.  
  465. '+-------------------------------------------------------------------+
  466. '▌                       ACTUAL PROGRAM                              ▌
  467. '▌                       ==============                              ▌
  468. '+-------------------------------------------------------------------+
  469. Responses$ = "YN"
  470. PerSecond! = 4
  471. DO
  472.  FOR i = 1 TO 6
  473.   FOR j = 1 TO 9
  474.    Hue = ColourTable(VCube(i, j))
  475.    PAINT (Face(i, j, 1), Face(i, j, 2)), Hue, 0
  476.   NEXT
  477.  NEXT
  478.  
  479.  GOSUB Establish
  480.  
  481.  
  482. ' get a keystroke
  483.  
  484.  RevFlag = 0
  485.  GOSUB GetKey
  486.  SELECT CASE lenx
  487.  CASE 1
  488.   NoGait = 1
  489.   CommStr$ = UCASE$(x$)
  490.   IF INSTR("THBLMRFVA", CommStr$) THEN GOSUB Interpret
  491.   CommStr$ = CHR$(ASC(x$) + ASC("A") - 1) + "'"
  492.   IF INSTR("THBLMRFVA", LEFT$(CommStr$, 1)) THEN GOSUB Interpret
  493.   NoGait = 0
  494.   SELECT CASE UCASE$(x$)
  495.  
  496.   CASE "X" 'preset puzzles
  497.    Msg$ = "Select Game"
  498.    Responses$ = "1234567890" + CHR$(27)
  499.    GOSUB SetYorNMsg
  500.    IF ASC(x$) <> 27 THEN
  501.     FOR i = 1 TO 6
  502.      FOR j = 1 TO 9
  503.       VCube(i, j) = i
  504.      NEXT
  505.     NEXT
  506.     i = VAL(x$)
  507.     FOR j = 1 TO 25
  508.      VFaceNum = Setup(i, j)
  509.      GOSUB Rotate
  510.     NEXT
  511.    END IF
  512.  
  513.   CASE "Z" 'clear count
  514.    OpCount = -1: OpCode$ = "": GOSUB ShowOpCode
  515.  
  516.   CASE CHR$(9) 'Tab -- SOLVE
  517.    AutoSw = 1
  518.  
  519. '+-------------------------------------------------------------------+
  520. '▌  PHASE 0: ORIENT CUBE SO THAT WHITE IS ON TOP                     ▌
  521. '+-------------------------------------------------------------------+
  522.    OpCount = -1: OpCode$ = "": GOSUB ShowOpCode
  523.    Tally1 = 0
  524.  
  525.    DO
  526.     IF VCube(2, 5) = 2 THEN EXIT DO
  527.     Tally1 = Tally1 + 1
  528.     HorizontalSwitch = 2
  529.     IF Tally1 = 4 THEN
  530.      HorizontalSwitch = 1
  531.     END IF
  532.     GOSUB OrientTurn: GOSUB Establish: GOSUB Gait
  533.    LOOP
  534.    RevFlag = 0
  535.    AutoSw = 0: CommStr$ = "": GOSUB Establish: AutoSw = 1
  536.  
  537. '+-------------------------------------------------------------------+
  538. '▌  PHASE 1: TOP EDGES                                               ▌
  539. '+-------------------------------------------------------------------+
  540.    DO
  541.     IF VCube(2, 2) = 2 THEN
  542.      IF VCube(2, 4) = 2 THEN
  543.       IF VCube(2, 6) = 2 THEN
  544.        IF VCube(2, 8) = 2 THEN
  545.     IF VCube(3, 4) = VCube(3, 5) THEN
  546.      IF VCube(1, 2) = VCube(1, 5) THEN
  547.       IF VCube(6, 8) = VCube(6, 5) THEN
  548.        IF VCube(4, 6) = VCube(4, 5) THEN
  549.         EXIT DO
  550.        END IF
  551.       END IF
  552.      END IF
  553.     END IF
  554.        END IF
  555.       END IF
  556.      END IF
  557.     END IF
  558.  
  559. ' 1.A: move white edges to bottom surface
  560.  
  561.     DO
  562.     
  563. ' (i) move white edge from top surface to bottom surface
  564.      DO
  565.       IF VCube(2, 2) <> 2 THEN EXIT DO
  566.       GOSUB ClearBottom
  567.       CommStr$ = "FF": GOSUB Interpret
  568.      LOOP
  569.  
  570. ' (ii) move white edge from left surface to bottom surface
  571.      DO
  572.       IF VCube(4, 8) <> 2 THEN EXIT DO
  573.       GOSUB ClearBottom
  574.       CommStr$ = "F'": GOSUB Interpret
  575.      LOOP
  576.  
  577. ' (iii) move white edge from right surface to bottom surface
  578.      DO
  579.       IF VCube(1, 4) <> 2 THEN EXIT DO
  580.       GOSUB ClearBottom
  581.       CommStr$ = "F'": GOSUB Interpret
  582.      LOOP
  583.  
  584. '(iv) move white edge from left to bottom surface
  585.      DO
  586.       IF VCube(3, 8) <> 2 THEN EXIT DO
  587.       GOSUB ClearBottom
  588.       CommStr$ = "B'L'": GOSUB Interpret
  589.      LOOP
  590.  
  591. '(v) move white edge from top to right
  592.      DO
  593.       IF VCube(3, 4) <> 2 THEN EXIT DO
  594.       GOSUB ClearBottom
  595.       CommStr$ = "F": GOSUB Interpret
  596.      LOOP
  597.  
  598. '(vi) move white edge from bottom to right
  599.      DO
  600.       IF VCube(3, 6) <> 2 THEN EXIT DO
  601.       CommStr$ = "F'": GOSUB Interpret
  602.      LOOP
  603.  
  604. '(vii) move white edge from right to bottom surface
  605.      DO
  606.       IF VCube(3, 2) <> 2 THEN EXIT DO
  607.       GOSUB ClearBottom
  608.       CommStr$ = "BR'": GOSUB Interpret
  609.      LOOP
  610.  
  611.      IF VCube(2, 2) <> 2 THEN
  612.       IF VCube(4, 8) <> 2 THEN
  613.        IF VCube(1, 4) <> 2 THEN
  614.     IF VCube(3, 8) <> 2 THEN
  615.      IF VCube(3, 4) <> 2 THEN
  616.       IF VCube(3, 6) <> 2 THEN
  617.        IF VCube(3, 2) <> 2 THEN
  618.         EXIT DO
  619.        END IF
  620.       END IF
  621.      END IF
  622.     END IF
  623.        END IF
  624.       END IF
  625.      END IF
  626.  
  627.     LOOP
  628.  
  629. ' when we get here, the face has been 'exhausted'
  630.   
  631.     IF VCube(5, 2) = 2 THEN
  632.      IF VCube(5, 4) = 2 THEN
  633.       IF VCube(5, 6) = 2 THEN
  634.        IF VCube(5, 8) = 2 THEN
  635.     EXIT DO
  636.        END IF
  637.       END IF
  638.      END IF
  639.     END IF
  640.     CommStr$ = ">": GOSUB Interpret
  641.   
  642.    LOOP
  643.    AutoSw = 0: CommStr$ = "": GOSUB Establish: AutoSw = 1
  644.  
  645. ' when we get here, all the white edge faces are on the bottom
  646.  
  647. ' 1.B: move white edges to correct place in top surface
  648.  
  649.    DO
  650.     DO
  651.      IF VCube(3, 6) <> VCube(3, 5) THEN EXIT DO
  652.      IF VCube(5, 6) <> 2 THEN EXIT DO
  653.      CommStr$ = "FF>": GOSUB Interpret
  654.     LOOP
  655.  
  656.     IF VCube(2, 2) = 2 THEN
  657.      IF VCube(2, 4) = 2 THEN
  658.       IF VCube(2, 6) = 2 THEN
  659.        IF VCube(2, 8) = 2 THEN
  660.     EXIT DO
  661.        END IF
  662.       END IF
  663.      END IF
  664.     END IF
  665.     CommStr$ = "B": GOSUB Interpret
  666.  
  667.    LOOP
  668.    AutoSw = 0: CommStr$ = "": GOSUB Establish: AutoSw = 1
  669.  
  670. '+-------------------------------------------------------------------+
  671. '▌  PHASE 2: TOP CORNERS                                             ▌
  672. '+-------------------------------------------------------------------+
  673.    
  674.    DO
  675. ' retire when everything is correct
  676.  
  677.     IF VCube(2, 1) = 2 THEN
  678.      IF VCube(2, 3) = 2 THEN
  679.       IF VCube(2, 7) = 2 THEN
  680.        IF VCube(2, 9) = 2 THEN
  681.     IF VCube(3, 1) = VCube(3, 5) THEN
  682.      IF VCube(3, 7) = VCube(3, 5) THEN
  683.       IF VCube(6, 9) = VCube(6, 5) THEN
  684.        IF VCube(6, 7) = VCube(6, 5) THEN
  685.         EXIT DO
  686.        END IF
  687.       END IF
  688.      END IF
  689.     END IF
  690.        END IF
  691.       END IF
  692.      END IF
  693.     END IF
  694.  
  695.     DO
  696. ' continue when top front right (123) is already in place
  697.      IF VCube(2, 1) = 2 THEN
  698.       IF VCube(3, 1) = VCube(3, 5) THEN
  699.        EXIT DO
  700.       END IF
  701.      END IF
  702. ' find the corner that goes in top front right
  703.      i = VCube(1, 5): j = VCube(2, 5): k = VCube(3, 5)
  704.      IF i > j THEN SWAP i, j
  705.      IF i > k THEN SWAP i, k
  706.      IF j > k THEN SWAP j, k
  707.      L = 0
  708.      DO
  709.       L = L + 1
  710.       IF Corners(L, 1) = i THEN
  711.        IF Corners(L, 2) = j THEN
  712.     IF Corners(L, 3) = k THEN
  713.      i = Corners(L, 4)
  714.      j = Corners(L, 5)
  715.      k = Corners(L, 6)
  716.      EXIT DO
  717.     END IF
  718.        END IF
  719.       END IF
  720.      LOOP
  721.      IF j = 2 THEN SWAP i, j
  722.      IF k = 2 THEN SWAP i, k
  723.      IF j = 5 THEN SWAP i, j
  724.      IF k = 5 THEN SWAP i, k
  725.      IF j > k THEN SWAP j, k
  726. ' now we know the location of the cornerpiece that fits in top front right
  727.      DO
  728.       IF i = 2 THEN
  729.        IF j = 1 THEN
  730.     IF k = 3 THEN
  731.      IF VCube(2, 1) = 2 THEN EXIT DO
  732.      CommStr$ = "FBF'"
  733.     ELSE
  734.      CommStr$ = "AB'A'"
  735.     END IF
  736.        ELSE
  737.     IF j = 3 THEN
  738.      CommStr$ = "F'BFB"
  739.     ELSE
  740.      CommStr$ = "A'BBA"
  741.     END IF
  742.        END IF
  743.       ELSE
  744.        IF j = 1 THEN
  745.     IF k = 3 THEN
  746.     ELSE
  747.      CommStr$ = "B'"
  748.     END IF
  749.        ELSE
  750.     IF j = 3 THEN
  751.      CommStr$ = "B"
  752.     ELSE
  753.      CommStr$ = "BB"
  754.     END IF
  755.        END IF
  756.       END IF
  757.       GOSUB Interpret
  758. ' now piece at front right bottom (135) is to go to front right top (123)
  759.       IF VCube(1, 7) = 2 THEN
  760.        CommStr$ = "R'B'R"
  761.       ELSE
  762.        IF VCube(3, 3) = 2 THEN
  763.     CommStr$ = "FBF'"
  764.        ELSE
  765.     CommStr$ = "FBBF'B'FBF'"
  766.        END IF
  767.       END IF
  768.       GOSUB Interpret
  769.       EXIT DO
  770.      LOOP
  771.  
  772. ' now the piece 123 is correct
  773.  
  774.     EXIT DO
  775.     LOOP
  776.  
  777.   
  778.     IF VCube(2, 1) = 2 THEN
  779.      IF VCube(2, 3) = 2 THEN
  780.       IF VCube(2, 7) = 2 THEN
  781.        IF VCube(2, 9) = 2 THEN
  782.     IF VCube(3, 1) = VCube(3, 5) THEN
  783.      IF VCube(3, 7) = VCube(3, 5) THEN
  784.       IF VCube(6, 9) = VCube(6, 5) THEN
  785.        IF VCube(6, 7) = VCube(6, 5) THEN
  786.         EXIT DO
  787.        END IF
  788.       END IF
  789.      END IF
  790.     END IF
  791.        END IF
  792.       END IF
  793.      END IF
  794.     END IF
  795.     CommStr$ = ">": GOSUB Interpret
  796.    
  797.    LOOP
  798.    AutoSw = 0: CommStr$ = "": GOSUB Establish: AutoSw = 1
  799.   
  800.  
  801. '+-------------------------------------------------------------------+
  802. '▌  PHASE 3: MIDDLE EDGES                                            ▌
  803. '+-------------------------------------------------------------------+
  804.   
  805.    DO
  806. ' retire when all is well
  807.     IF VCube(1, 4) = VCube(1, 5) THEN
  808.      IF VCube(1, 6) = VCube(1, 5) THEN
  809.       IF VCube(3, 2) = VCube(3, 5) THEN
  810.        IF VCube(3, 8) = VCube(3, 5) THEN
  811.     IF VCube(4, 2) = VCube(4, 5) THEN
  812.      IF VCube(4, 8) = VCube(4, 5) THEN
  813.       IF VCube(6, 4) = VCube(6, 5) THEN
  814.        IF VCube(6, 6) = VCube(6, 5) THEN
  815.         EXIT DO
  816.        END IF
  817.       END IF
  818.      END IF
  819.     END IF
  820.        END IF
  821.       END IF
  822.      END IF
  823.     END IF
  824.  
  825. ' get a candidate edge into the front face
  826.  
  827.     TallyTurn = 0
  828.     DO
  829.      IF VCube(3, 6) <> 5 THEN
  830.       IF VCube(5, 6) <> 5 THEN
  831.        TallyTurn = 0
  832.        EXIT DO
  833.       END IF
  834.      END IF
  835.      TallyTurn = TallyTurn + 1
  836.      IF TallyTurn > 4 THEN
  837. ' if we get here, at least one piece is 'embedded'
  838.       TallyTurn = 0
  839.       DO
  840.        IF VCube(3, 2) <> VCube(3, 5) THEN EXIT DO
  841.        IF VCube(1, 4) <> VCube(1, 5) THEN EXIT DO
  842.        CommStr$ = ">": GOSUB Interpret
  843.       LOOP
  844.       CommStr$ = "M'B'R'BMB'RB": GOSUB Interpret
  845.      ELSE
  846.       CommStr$ = ">": GOSUB Interpret
  847.      END IF
  848.     LOOP
  849.  
  850. ' here is a candidate
  851.    
  852.     DO
  853.      IF VCube(5, 6) = VCube(3, 5) THEN EXIT DO
  854.      CommStr$ = "B<": GOSUB Interpret
  855.     LOOP
  856.     IF VCube(3, 6) = VCube(4, 5) THEN
  857.      CommStr$ = "BBM'BL'B'MBL"
  858.     ELSE
  859.      CommStr$ = "BBM'B'R'BMB'R"
  860.     END IF
  861.     GOSUB Interpret
  862.   
  863.    LOOP
  864.    AutoSw = 0: CommStr$ = "": GOSUB Establish: AutoSw = 1
  865.  
  866. '+-------------------------------------------------------------------+
  867. '▌  PHASE 4: BOTTOM CORNERS                                          ▌
  868. '+-------------------------------------------------------------------+
  869.  
  870. ' (i) position the corners relative to each other
  871.  
  872.    DO
  873.     DO
  874.  
  875. ' Cnrx(1) details the content of FLB (345)
  876. ' Cnrx(2) details the content of FRB (315)
  877. ' Cnrx(3) details the content of ARB (615)
  878. ' Cnrx(4) details the content of ALB (645)
  879.  
  880. ' value 1 is Red: 2 is Blue: 4 is Green: 8 is Orange
  881. ' the expected (cyclic) order is:
  882. '       6 (G + B); 3 (B + R); 9 (R + O); 12 (O + G)
  883.  
  884.      x$ = "RWBGYO": y$ = "RBxGxxxO"
  885.      Cnrx(1) = INSTR(y$, MID$(x$, VCube(3, 9), 1))
  886.      Cnrx(1) = Cnrx(1) + INSTR(y$, MID$(x$, VCube(4, 7), 1))
  887.      Cnrx(1) = Cnrx(1) + INSTR(y$, MID$(x$, VCube(5, 3), 1))
  888.  
  889.      Cnrx(2) = INSTR(y$, MID$(x$, VCube(1, 7), 1))
  890.      Cnrx(2) = Cnrx(2) + INSTR(y$, MID$(x$, VCube(3, 3), 1))
  891.      Cnrx(2) = Cnrx(2) + INSTR(y$, MID$(x$, VCube(5, 9), 1))
  892.  
  893.      Cnrx(3) = INSTR(y$, MID$(x$, VCube(1, 9), 1))
  894.      Cnrx(3) = Cnrx(3) + INSTR(y$, MID$(x$, VCube(5, 7), 1))
  895.      Cnrx(3) = Cnrx(3) + INSTR(y$, MID$(x$, VCube(6, 3), 1))
  896.  
  897.      Cnrx(4) = INSTR(y$, MID$(x$, VCube(4, 1), 1))
  898.      Cnrx(4) = Cnrx(4) + INSTR(y$, MID$(x$, VCube(5, 1), 1))
  899.      Cnrx(4) = Cnrx(4) + INSTR(y$, MID$(x$, VCube(6, 1), 1))
  900.    
  901.      i = 0: j = 5
  902.      DO
  903.       i = i + 1
  904.       IF Cnrx(i) = 6 THEN EXIT DO
  905.      LOOP
  906.      i = i MOD 4 + 1
  907.      DO
  908.       Cnrx(j) = Cnrx(i)
  909.       i = i MOD 4 + 1
  910.       j = j + 1
  911.       IF j = 8 THEN EXIT DO
  912.      LOOP
  913. ' now Cnrx(5 to 7) has the second, third and fourth in order
  914.  
  915. ' find a pair of correctly placed corners (with respect to each other)
  916.      SELECT CASE Cnrx(5)
  917.      CASE 3
  918.       IF Cnrx(6) = 9 THEN EXIT DO 'no change necessary
  919.       Cnrx(0) = 9
  920.      CASE 9
  921.       IF Cnrx(6) = 3 THEN
  922.        Cnrx(0) = 6
  923.       ELSE
  924.        Cnrx(0) = 3
  925.       END IF
  926.      CASE ELSE
  927.       IF Cnrx(6) = 3 THEN
  928.        Cnrx(0) = 12
  929.       ELSE
  930.        Cnrx(0) = Cnrx(1)
  931.       END IF
  932.      END SELECT
  933.      i = 0
  934.      DO
  935.       i = i + 1
  936.       IF Cnrx(i) = Cnrx(0) THEN EXIT DO
  937.      LOOP
  938.  
  939. ' re-orient cube so that two contiguous corners can be swapped
  940.      SELECT CASE i
  941.      CASE 1
  942.       CommStr$ = ""
  943.      CASE 2
  944.       CommStr$ = "<"
  945.      CASE 3
  946.       CommStr$ = ">>"
  947.      CASE 4
  948.       CommStr$ = ">"
  949.      END SELECT
  950.  
  951. ' swap contiguous corners and try again
  952.      CommStr$ = CommStr$ + "R'BL'B'RBL"
  953.      GOSUB Interpret
  954.   
  955.     LOOP
  956.  
  957. ' turn the base until corners are in right place
  958.  
  959.     SELECT CASE Cnrx(1)
  960.     CASE 3
  961.      IF VCube(3, 5) = 1 THEN EXIT DO
  962.     CASE 6
  963.      IF VCube(1, 5) = 1 THEN EXIT DO
  964.     CASE 9
  965.      IF VCube(4, 5) = 1 THEN EXIT DO
  966.     CASE 12
  967.      IF VCube(6, 5) = 1 THEN EXIT DO
  968.     END SELECT
  969.  
  970.     CommStr$ = "B": GOSUB Interpret
  971.  
  972.    LOOP
  973.    AutoSw = 0: CommStr$ = "": GOSUB Establish: AutoSw = 1
  974.  
  975.  
  976. ' (ii) re-orient the corners as required
  977.  
  978.    DO
  979.  
  980. ' determine which are set correctly
  981.     IF VCube(5, 3) = 5 THEN
  982.      BottomCorners = 0
  983.     ELSE
  984.      BottomCorners = 1
  985.     END IF
  986.     IF VCube(5, 9) <> 5 THEN
  987.      BottomCorners = BottomCorners + 2
  988.     END IF
  989.     IF VCube(5, 7) <> 5 THEN
  990.      BottomCorners = BottomCorners + 4
  991.     END IF
  992.     IF VCube(5, 1) <> 5 THEN
  993.      BottomCorners = BottomCorners + 8
  994.     END IF
  995.  
  996. ' swap corners that are in wrong sequence
  997.  
  998.     SELECT CASE BottomCorners
  999.     CASE 0
  1000.      EXIT DO
  1001.     CASE 2, 10, 14, 15
  1002.      CommStr$ = "R'B'RB'R'BBRBB"
  1003.     CASE 3
  1004.      CommStr$ = "R'B'RB'R'BBRBBL'BLBL'BBLBB"
  1005.     CASE ELSE
  1006.      CommStr$ = ">"
  1007.     END SELECT
  1008.    
  1009.     GOSUB Interpret
  1010.   
  1011.    LOOP
  1012.  
  1013.    AutoSw = 0: CommStr$ = "": GOSUB Establish: AutoSw = 1
  1014.  
  1015.  
  1016. '+-------------------------------------------------------------------+
  1017. '▌  PHASE 5: BOTTOM EDGES                                            ▌
  1018. '+-------------------------------------------------------------------+
  1019.     
  1020. ' (i) ensure that edges are in the right place
  1021.  
  1022.    DO
  1023.     IF VCube(3, 6) + VCube(5, 6) - 5 = VCube(3, 5) THEN
  1024.      EdgeSum = VCube(3, 5)
  1025.     ELSE
  1026.      EdgeSum = 0
  1027.     END IF
  1028.     IF VCube(1, 8) + VCube(5, 8) - 5 = VCube(1, 5) THEN
  1029.      EdgeSum = EdgeSum + VCube(1, 5)
  1030.     END IF
  1031.     IF VCube(6, 2) + VCube(5, 4) - 5 = VCube(6, 5) THEN
  1032.      EdgeSum = EdgeSum + VCube(6, 5)
  1033.     END IF
  1034.     IF VCube(4, 4) + VCube(5, 2) - 5 = VCube(4, 5) THEN
  1035.      EdgeSum = EdgeSum + VCube(4, 5)
  1036.     END IF
  1037.    
  1038.     IF EdgeSum = 14 THEN EXIT DO 'all correct
  1039.  
  1040.     CommStr$ = ""
  1041.     DO
  1042.      SELECT CASE EdgeSum
  1043.      CASE 0, VCube(3, 5)'front face correct
  1044.       EXIT DO
  1045.      CASE ELSE
  1046.       CommStr$ = ">"'rotate until found
  1047.       GOSUB Interpret
  1048.      END SELECT
  1049.     LOOP
  1050.     CommStr$ = "M'B'MBBM'B'M"
  1051.     GOSUB Interpret
  1052.   
  1053.    LOOP
  1054.    AutoSw = 0: CommStr$ = "": GOSUB Establish: AutoSw = 1
  1055.  
  1056. ' (ii) re-align the edges
  1057.   
  1058.    DO
  1059.     IF VCube(5, 6) = 5 THEN
  1060.      EdgeSum = 0
  1061.     ELSE
  1062.      EdgeSum = 3
  1063.     END IF
  1064.     IF VCube(5, 8) <> 5 THEN EdgeSum = EdgeSum + 1
  1065.     IF VCube(5, 4) <> 5 THEN EdgeSum = EdgeSum + 6
  1066.     IF VCube(5, 2) <> 5 THEN EdgeSum = EdgeSum + 4
  1067.    
  1068. ' now EdgeSum is the sum of faces that need turning
  1069.  
  1070.     SELECT CASE EdgeSum
  1071.     CASE 0
  1072.      EXIT DO
  1073.     CASE 5, 9, 10, 14
  1074.      CommStr$ = "M'BMBM'BBMBBM'BMBM'BBMBB"
  1075.     CASE ELSE
  1076.      CommStr$ = ">"
  1077.     END SELECT
  1078.    
  1079.     GOSUB Interpret
  1080.   
  1081.    LOOP
  1082.    AutoSw = 0: CommStr$ = "": GOSUB Establish
  1083.  
  1084. ' turn off the Auto-switch
  1085.   LINE (294, 200)-STEP(48, 11), 15, BF
  1086.  
  1087.   END SELECT
  1088. '+-------------------------------------------------------------------+
  1089. '▌  THE CUBE SHOULD NOW BE COMPLETELY RESTORED!     PHEW!!!          ▌
  1090. '+-------------------------------------------------------------------+
  1091.  
  1092.  
  1093.  
  1094.  
  1095. '+-------------------------------------------------------------------+
  1096. '▌  THESE ARE MACROS USABLE IN MANUAL SOLUTION                       ▌
  1097. '+-------------------------------------------------------------------+
  1098.  
  1099.  CASE 2
  1100. ' for functions, turn on the MACRO switch
  1101.   IF ASC(x$) > 58 THEN
  1102.    IF ASC(x$) < 69 THEN
  1103.     MacroSw = 1
  1104.    END IF
  1105.   END IF
  1106.  
  1107.   SELECT CASE x$
  1108.  
  1109. ' Phase 2: White on BFR on Right, under its destination
  1110.   CASE CHR$(59) 'F1
  1111.    CommStr$ = "R'B'R": GOSUB Interpret
  1112.  
  1113. ' Phase 2: White on BFR on Front, under its destination
  1114.   CASE CHR$(60) 'F2
  1115.    CommStr$ = "FBF'": GOSUB Interpret
  1116.  
  1117. ' Phase 2: White on BFR on Bottom, under its destination
  1118.   CASE CHR$(61) 'F3
  1119.    CommStr$ = "FBBF'B'FBF'": GOSUB Interpret
  1120.  
  1121. ' Phase 3: Two colours on Front Bottom to go on Front Left
  1122.   CASE CHR$(62) 'F4
  1123.    CommStr$ = "BBM'BL'B'MBL": GOSUB Interpret
  1124.  
  1125. ' Phase 3: Two colours on Front Bottom to go on Front Right
  1126.   CASE CHR$(63) 'F5
  1127.    CommStr$ = "BBM'B'R'BMB'R": GOSUB Interpret
  1128.  
  1129. ' Phase 4: Swap BFL and BAL
  1130.   CASE CHR$(64) 'F6
  1131.    CommStr$ = "R'BL'B'RBL": GOSUB Interpret
  1132.   
  1133. ' Phase 4: Reorient BLF, BRF, BLA, BRA on right
  1134.   CASE CHR$(65) 'F7
  1135.    CommStr$ = "R'B'RB'R'BBRBB": GOSUB Interpret
  1136.  
  1137. ' Phase 4: Reorient BLF, BRF, BLA, BRA on left
  1138.   CASE CHR$(66) 'F8
  1139.    CommStr$ = "L'BLBL'BBLBB": GOSUB Interpret
  1140.   
  1141. ' Phase 5: Swap BL, BR, BA
  1142.   CASE CHR$(67) 'F9
  1143.    CommStr$ = "M'B'MBBM'B'M": GOSUB Interpret
  1144.  
  1145.  
  1146. ' Phase 5: Reorient BL, BA
  1147.   CASE CHR$(68) 'F10
  1148.    
  1149.    CommStr$ = "M'BMBM'BBMBBM'BMBM'BBMBB": GOSUB Interpret
  1150.  
  1151.   CASE "G" 'HOME (=reset)
  1152.  
  1153.    Msg$ = "RESET": GOSUB SetYorNMsg
  1154.    IF x$ = "Y" THEN
  1155.     FOR i = 1 TO 6
  1156.      k = VCube(i, 5)
  1157.      FOR j = 1 TO 4
  1158.       VCube(i, j) = k
  1159.       VCube(i, j + 5) = k
  1160.      NEXT
  1161.     NEXT
  1162.     LINE (283, 141)-STEP(73, 73), 11, BF
  1163.     OpCount = 0
  1164.    END IF
  1165.    x$ = ""
  1166.  
  1167.   CASE "S" 'DEL (=scramble)
  1168.  
  1169.    Msg$ = "SCRAMBLE": GOSUB SetYorNMsg
  1170.    IF x$ = "Y" THEN
  1171.     Scramble = 25
  1172.     DO
  1173.      VFaceNum = INT(6 * RND) + 1
  1174.      GOSUB Rotate
  1175.      Scramble = Scramble - 1
  1176.     LOOP UNTIL Scramble = 0
  1177.     LINE (283, 141)-STEP(73, 73), 11, BF
  1178.     OpCount = 0
  1179.    END IF
  1180.    x$ = ""
  1181.  
  1182.   CASE "K" 'LEFT ARROW
  1183.    HorizontalSwitch = 1
  1184.    GOSUB OrientTurn3
  1185.  
  1186.   CASE "M" 'RIGHT ARROW
  1187.    HorizontalSwitch = 1
  1188.    GOSUB OrientTurn
  1189.  
  1190.   CASE "H" 'UP ARROW
  1191.    HorizontalSwitch = 2
  1192.    GOSUB OrientTurn
  1193.  
  1194.   CASE "P" 'DOWN ARROW
  1195.    HorizontalSwitch = 2
  1196.    GOSUB OrientTurn3
  1197.  
  1198.   END SELECT
  1199.  END SELECT
  1200. ' turn off the MACRO switch
  1201.  IF MacroSw <> 0 THEN
  1202.   MacroSw = 0
  1203.   LINE (290, 200)-STEP(56, 11), 15, BF
  1204.  END IF
  1205.  
  1206. LOOP
  1207.  
  1208. SYSTEM
  1209.  
  1210. '+-------------------------------------------------------------------+
  1211. '▌                         SUBROUTINES                               ▌
  1212. '▌                         ===========                               ▌
  1213. '+-------------------------------------------------------------------+
  1214. '▌ Establish                                                         ▌
  1215. '▌                                                                   ▌
  1216. '+-------------------------------------------------------------------+
  1217. Establish:
  1218.  
  1219. ' find the centres
  1220.  
  1221.  Fg = 4: Bg = 10
  1222.  FOR ix = 1 TO 6
  1223.   jx = VCube(ix, 5)
  1224.   Centres(jx) = ix
  1225.   IF AutoSw + MacroSw = 0 THEN
  1226.    zsLocateGCursor 60, 353 + 16 * jx
  1227.    ziPublish LTRIM$(STR$(ix)), 2, 0
  1228.   END IF
  1229.  NEXT
  1230.  
  1231. ' find the edges
  1232.  
  1233.  FOR ix = 1 TO 6
  1234.   FOR jx = 1 TO 4
  1235.    kx = VCube(ix, jx + jx) 'first colour
  1236.    lx = VAL(MID$("1423", jx, 1)) '(direction:N-E-S-W)
  1237.    mx = Neighbours(lx, ix) '(neighbouring face)
  1238.    nx = Neighbours(lx, 8) 'middle border square
  1239.    px = VCube(mx, nx)'its colour
  1240.    IF kx < px THEN 'look only in sequence
  1241.     ox = 0
  1242.     DO
  1243.      ox = ox + 1
  1244.      IF Edges(ox, 1) = kx THEN
  1245.       IF Edges(ox, 2) = px THEN
  1246.       EXIT DO 'found match!
  1247.       END IF
  1248.      END IF
  1249.     LOOP
  1250.     Edges(ox, 3) = ix  'report new location of piece
  1251.     Edges(ox, 4) = mx
  1252.     Edges(ox, 5) = 0
  1253.  
  1254. ' report whether the edge pieces are in position
  1255.     IF VCube(ix, 5) = kx THEN
  1256.      IF VCube(mx, 5) = px THEN
  1257.       Edges(ox, 5) = 2
  1258.      END IF
  1259.     ELSE
  1260.      IF VCube(ix, 5) = px THEN
  1261.       IF VCube(mx, 5) = kx THEN
  1262.        Edges(ox, 5) = 1
  1263.       END IF
  1264.      END IF
  1265.     END IF
  1266.    END IF
  1267.   NEXT
  1268.  NEXT
  1269.  IF AutoSw + MacroSw = 0 THEN
  1270.   FOR ix = 1 TO 12
  1271.    jx = 353 + 16 * ((ix - 1) MOD 6 + 1)
  1272.    kx = 184 + 139 * ((ix - 1) \ 6)
  1273.    Fg = 4: Bg = 10
  1274.    zsLocateGCursor kx + 32, jx
  1275.    ziPublish LTRIM$(STR$(Edges(ix, 3))), 2, 0
  1276.    ziPublish LTRIM$(STR$(Edges(ix, 4))), 2, 0
  1277.    Fg = 1
  1278.    ziPublish MID$(" +*", Edges(ix, 5) + 1, 1), 2, 0
  1279.   NEXT
  1280.  END IF
  1281.  
  1282. ' find the corner pieces
  1283.  
  1284.  FOR ix = 1 TO 4 STEP 3
  1285.   FOR jx = 1 TO 4 'direction of corner
  1286.    kx = VAL(MID$("1397", jx, 1)) 'cell number
  1287.    lx = VCube(ix, kx)' cell's colour
  1288.    mx = Neighbours(jx, ix)'adjoining side
  1289.    nx = Neighbours(jx, 7)' cell location on adjoining side
  1290.    ox = VCube(mx, nx)' its colour
  1291.    px = VAL(MID$("4123", jx, 1))'other direction of corner
  1292.    qx = Neighbours(px, ix)' other adjoinging side
  1293.    rx = Neighbours(px, 9)' cell location on that side
  1294.    sx = VCube(qx, rx)'its colour
  1295.    tx = ix ' avoid modifying an element used in FOR/NEXT
  1296. ' reorganise the colours into sequence
  1297.    IF lx > ox THEN SWAP lx, ox: SWAP kx, nx: SWAP tx, mx
  1298.    IF ox > sx THEN SWAP ox, sx: SWAP nx, rx: SWAP mx, qx
  1299.    IF lx > ox THEN SWAP lx, ox: SWAP kx, nx: SWAP tx, mx
  1300. ' find the record of this piece and publish it
  1301.    ux = 0
  1302.    DO
  1303.     ux = ux + 1
  1304.     IF Corners(ux, 1) = lx THEN
  1305.      IF Corners(ux, 2) = ox THEN
  1306.       IF Corners(ux, 3) = sx THEN
  1307.        EXIT DO
  1308.       END IF
  1309.      END IF
  1310.     END IF
  1311.    LOOP
  1312.    Corners(ux, 4) = tx
  1313.    Corners(ux, 5) = mx
  1314.    Corners(ux, 6) = qx
  1315.    x$ = ""
  1316.    FOR vx = 1 TO 3
  1317.     x$ = x$ + LTRIM$(STR$(Centres(Corners(ux, vx))))
  1318.    NEXT
  1319.    Corners(ux, 7) = 0
  1320. ' see if the piece is in the correct corner
  1321.    IF INSTR(x$, LTRIM$(STR$(tx))) > 0 THEN
  1322.     IF INSTR(x$, LTRIM$(STR$(mx))) > 0 THEN
  1323.      IF INSTR(x$, LTRIM$(STR$(qx))) > 0 THEN
  1324.       Corners(ux, 7) = 1
  1325. ' see if the piece has the correct orientation as well
  1326.       IF INSTR(x$, LTRIM$(STR$(tx))) = 1 THEN '(only need to match two sides!)
  1327.        IF INSTR(x$, LTRIM$(STR$(mx))) = 2 THEN
  1328.     Corners(ux, 7) = 2
  1329.        END IF
  1330.       END IF
  1331.      END IF
  1332.     END IF
  1333.    END IF
  1334.    IF AutoSw + MacroSw = 0 THEN
  1335.     vx = 337 + 16 * ux
  1336.     Fg = 4: Bg = 10
  1337.     zsLocateGCursor 536, vx
  1338.     Fg = 4: ziPublish LTRIM$(STR$(tx * 100 + mx * 10 + qx)), 2, 0
  1339.     Fg = 1: ziPublish MID$(" +*", Corners(ux, 7) + 1, 1), 2, 0
  1340.    END IF
  1341.   NEXT
  1342.  NEXT
  1343.  
  1344.  RETURN
  1345.  
  1346. '+-------------------------------------------------------------------+
  1347. '▌ ClearBottom                                                       ▌
  1348. '▌                                                                   ▌
  1349. '▌                                                                   ▌
  1350. '+-------------------------------------------------------------------+
  1351. ClearBottom:
  1352.      
  1353.  DO
  1354.   IF VCube(5, 6) <> 2 THEN EXIT DO
  1355.   CommStr$ = "B": GOSUB Interpret
  1356.  LOOP
  1357.  
  1358. RETURN
  1359.  
  1360. '+-------------------------------------------------------------------+
  1361. '▌ Gait                                                              ▌
  1362. '▌                                                                   ▌
  1363. '▌              i/p: PerSecond! (default = 4)                        ▌
  1364. '▌                                                                   ▌
  1365. '+-------------------------------------------------------------------+
  1366. Gait:
  1367.   
  1368.   IF NoGait = 1 THEN
  1369.    NoGait = 0
  1370.    RETURN
  1371.   END IF
  1372.   StopClock! = TIMER + 1 / PerSecond!
  1373.   DO
  1374.    Trial! = TIMER
  1375.   LOOP UNTIL Trial! > StopClock!
  1376.   FOR i = 1 TO 6
  1377.    FOR j = 1 TO 9
  1378.     Hue = ColourTable(VCube(i, j))
  1379.     PAINT (Face(i, j, 1), Face(i, j, 2)), Hue, 0
  1380.    NEXT
  1381.   NEXT
  1382.   PerSecond! = 4
  1383.  
  1384.   RETURN
  1385.  
  1386. '+-------------------------------------------------------------------+
  1387. '▌ Interpret                                                         ▌
  1388. '▌                                                                   ▌
  1389. '+-------------------------------------------------------------------+
  1390. Interpret:
  1391.  
  1392.  DO
  1393.   IF LEN(CommStr$) = 0 THEN EXIT DO
  1394.   x$ = LEFT$(CommStr$, 1)
  1395.   OpCode$ = x$
  1396.   IF MID$(CommStr$, 2, 1) = "'" THEN
  1397.    OpCode$ = x$ + "'"
  1398.    RevFlag = 1
  1399.    CommStr$ = MID$(CommStr$, 3)
  1400.   ELSE
  1401.    RevFlag = 0
  1402.    CommStr$ = MID$(CommStr$, 2)
  1403.   END IF
  1404.   GOSUB ShowOpCode
  1405.  
  1406.   SELECT CASE x$
  1407.   CASE "T"
  1408.    VFaceNum = 2: GOSUB R3orR
  1409.   CASE "H"
  1410.    VFaceNum = 2: GOSUB RorR3
  1411.    VFaceNum = 5: GOSUB R3orR
  1412.    HorizontalSwitch = 1: GOSUB OorO3
  1413.   CASE "B"
  1414.    VFaceNum = 5: GOSUB RorR3
  1415.   CASE "L"
  1416.    VFaceNum = 4: GOSUB R3orR
  1417.   CASE "M"
  1418.    VFaceNum = 4: GOSUB RorR3
  1419.    VFaceNum = 1: GOSUB R3orR
  1420.    HorizontalSwitch = 2: GOSUB OorO3
  1421.   CASE "R"
  1422.    VFaceNum = 1: GOSUB RorR3
  1423.   CASE "F"
  1424.    VFaceNum = 3: GOSUB RorR3
  1425.   CASE "V"
  1426.    VFaceNum = 3: GOSUB R3orR
  1427.    VFaceNum = 6: GOSUB RorR3
  1428.    HorizontalSwitch = 2: GOSUB OorO3
  1429.    HorizontalSwitch = 1: GOSUB OrientTurn3
  1430.    HorizontalSwitch = 2: GOSUB O3orO
  1431.   CASE "A"
  1432.    VFaceNum = 6: GOSUB R3orR
  1433.   CASE "<"
  1434.    HorizontalSwitch = 1
  1435.    GOSUB OrientTurn3: GOSUB Establish
  1436.   CASE ">"
  1437.    HorizontalSwitch = 1
  1438.    GOSUB OrientTurn: GOSUB Establish
  1439.   END SELECT
  1440.   RevFlag = 0
  1441.   GOSUB Gait
  1442.  
  1443.  LOOP UNTIL LEN(CommStr$) = 0
  1444.  
  1445.  GOSUB ShowOpCode
  1446.  RETURN
  1447.  
  1448. OorO3:
  1449.  IF RevFlag = 0 THEN GOSUB OrientTurn ELSE GOSUB OrientTurn3
  1450.  RETURN
  1451.  
  1452. O3orO:
  1453.  IF RevFlag = 0 THEN GOSUB OrientTurn3 ELSE GOSUB OrientTurn
  1454.  RETURN
  1455.  
  1456. RorR3:
  1457.  IF RevFlag = 0 THEN GOSUB Rotate ELSE GOSUB Rotate3
  1458.  RETURN
  1459.  
  1460. R3orR:
  1461.  IF RevFlag = 0 THEN GOSUB Rotate3 ELSE GOSUB Rotate
  1462.  RETURN
  1463.  
  1464. '+-------------------------------------------------------------------+
  1465. '▌ OrientTurn                                                        ▌
  1466. '▌                                                                   ▌
  1467. '+-------------------------------------------------------------------+
  1468. OrientTurn3:
  1469.  
  1470.  GOSUB OrientTurn
  1471.  GOSUB OrientTurn
  1472.  
  1473. OrientTurn:
  1474.  
  1475.  IF HorizontalSwitch = 1 THEN
  1476.   FOR ix = 1 TO 19
  1477.    Orient(ix) = Horizontal(ix)
  1478.   NEXT
  1479.  ELSE
  1480.   FOR ix = 1 TO 19
  1481.    Orient(ix) = Vertical(ix)
  1482.   NEXT
  1483.  END IF
  1484.  
  1485.  ix = 1
  1486.  Destination = 0
  1487.  DO
  1488.   Origin = Orient(ix)
  1489.   Factor = Orient(ix + 1)
  1490.   FOR jx = 1 TO 9
  1491.    VCube(Destination, (jx * Factor) MOD 10) = VCube(Origin, jx)
  1492.   NEXT
  1493.   Destination = Origin
  1494.   ix = ix + 2
  1495.  LOOP UNTIL Orient(ix) = 999
  1496.  
  1497.  RETURN
  1498.  
  1499. '+-------------------------------------------------------------------+
  1500. '▌ Rotate                                                            ▌
  1501. '▌                                                                   ▌
  1502. '▌              i/p: VFaceNum  (1 to 6)                              ▌
  1503. '▌                                                                   ▌
  1504. '+-------------------------------------------------------------------+
  1505. Rotate3:
  1506.  
  1507.  GOSUB Rotate
  1508.  GOSUB Rotate
  1509.  
  1510. Rotate:
  1511.  
  1512.  FOR ix = 1 TO 9
  1513.   VCube(0, ix) = VCube(VFaceNum, ix)
  1514.  NEXT
  1515. ' move back the cells, rotated clockwise 90 degrees
  1516.  FOR ix = 1 TO 9
  1517.   VCube(VFaceNum, ix) = VCube(0, (ix * 7) MOD 10)
  1518.  NEXT
  1519.  
  1520. ' collect bordering cells (on four faces)
  1521.  FOR ix = 1 TO 4
  1522.   NearbyCell = Neighbours(ix, VFaceNum)
  1523.   FOR jx = 7 TO 9
  1524.    kx = ix * 3 + jx - 6
  1525.    Temp(kx) = VCube(NearbyCell, Neighbours(ix, jx))
  1526.   NEXT
  1527.  NEXT
  1528.  
  1529. ' rotate clockwise 90 degrees
  1530.  FOR ix = 1 TO 3
  1531.   Temp(ix) = Temp(ix + 12)
  1532.  NEXT
  1533.  
  1534. ' copy back, having rotated clockwise 90 degrees
  1535.  FOR ix = 1 TO 4
  1536.   NearbyCell = Neighbours(ix, VFaceNum)
  1537.   FOR jx = 7 TO 9
  1538.    kx = ix * 3 + jx - 9
  1539.    VCube(NearbyCell, Neighbours(ix, jx)) = Temp(kx)
  1540.   NEXT
  1541.  NEXT
  1542.  
  1543.  RETURN
  1544. '+-------------------------------------------------------------------+
  1545. '▌                  STANDARD   SUBROUTINES                           ▌
  1546. '▌                  ========   ===========                           ▌
  1547. '+-------------------------------------------------------------------+
  1548. '▌ GetKey                                                            ▌
  1549. '▌                                                                   ▌
  1550. '▌              i/p: x$, lenx                                        ▌
  1551. '▌                                                                   ▌
  1552. '+-------------------------------------------------------------------+
  1553. GetKey:
  1554.  
  1555.  DO
  1556.   DO: LOOP UNTIL LEN(INKEY$) = 0
  1557.   DO: x$ = INKEY$: LOOP UNTIL LEN(x$) > 0
  1558.   DO: LOOP UNTIL LEN(INKEY$) = 0
  1559.   IF x$ = CHR$(27) THEN
  1560.    Msg$ = "QUIT": GOSUB SetYorNMsg
  1561.    IF x$ = "Y" THEN
  1562.     SYSTEM
  1563.    END IF
  1564.    x$ = ""
  1565.   END IF
  1566.  LOOP UNTIL LEN(x$) > 0
  1567.  lenx = LEN(x$)
  1568.  x$ = RIGHT$(x$, 1)
  1569.  
  1570.  RETURN
  1571.  
  1572. '+-------------------------------------------------------------------+
  1573. '▌ Oblong                                                            ▌
  1574. '▌                                                                   ▌
  1575. '▌              i/p: Xcorner,Ycorner,Xwidth,Ywidth,Bg,Fg             ▌
  1576. '▌                                                                   ▌
  1577. '+-------------------------------------------------------------------+
  1578. Oblong:
  1579.  
  1580.  xa = XCorner: xb = YCorner: xc = Xwidth: xd = Ywidth
  1581.  LINE (xa - 5, xb - 5)-STEP(xc + 9, xd + 9), Fg, BF
  1582.  LINE (xa - 1, xb - 1)-STEP(xc + 1, xd + 1), 15, BF
  1583. ' upper left corner
  1584.  LINE (xa - 1, xb - 1)-STEP(1, 1), Fg, BF
  1585.  PSET (xa, xb), 15
  1586.  LINE (xa - 5, xb - 5)-STEP(4, 4), Bg, BF
  1587.  LINE (xa - 4, xb - 4)-STEP(3, 3), Fg, BF
  1588.  LINE (xa - 4, xb - 4)-STEP(1, 1), Bg1, BF
  1589.  PSET (xa - 3, xb - 3), Fg
  1590. ' upper right corner
  1591.  xa = xa + xc - 1
  1592.  LINE (xa + 1, xb - 1)-STEP(-1, 1), Fg, BF
  1593.  PSET (xa, xb), 15
  1594.  LINE (xa + 5, xb - 5)-STEP(-4, 4), Bg, BF
  1595.  LINE (xa + 4, xb - 4)-STEP(-3, 3), Fg, BF
  1596.  LINE (xa + 4, xb - 4)-STEP(-1, 1), Bg, BF
  1597.  PSET (xa + 3, xb - 3), Fg
  1598. ' lower right corner
  1599.  xb = xb + xd - 1
  1600.  LINE (xa + 1, xb + 1)-STEP(-1, -1), Fg, BF
  1601.  PSET (xa, xb), 15
  1602.  LINE (xa + 5, xb + 5)-STEP(-4, -4), Bg, BF
  1603.  LINE (xa + 4, xb + 4)-STEP(-3, -3), Fg, BF
  1604.  LINE (xa + 4, xb + 4)-STEP(-1, -1), Bg, BF
  1605.  PSET (xa + 3, xb + 3), Fg
  1606. ' lower left corner
  1607.  xa = XCorner
  1608.  LINE (xa - 1, xb + 1)-STEP(1, -1), Fg, BF
  1609.  PSET (xa, xb), 15
  1610.  LINE (xa - 5, xb + 5)-STEP(4, -4), Bg, BF
  1611.  LINE (xa - 4, xb + 4)-STEP(3, -3), Fg, BF
  1612.  LINE (xa - 4, xb + 4)-STEP(1, -1), Bg, BF
  1613.  PSET (xa - 3, xb + 3), Fg
  1614.              
  1615.  RETURN
  1616.  
  1617. '+-------------------------------------------------------------------+
  1618. '▌ SetYorNMsg                                                        ▌
  1619. '▌                                                                   ▌
  1620. '▌              i/p: Msg$, (Responses$)                              ▌
  1621. '▌                                                                   ▌
  1622. '▌              o/p: x$ as Y or N (or number 0 - 9)                  ▌
  1623. '▌                                                                   ▌
  1624. '+-------------------------------------------------------------------+
  1625. SetYorNMsg:
  1626.  
  1627.  XCorner = Xmax / 2 - 48 - 8 * LEN(Msg$)
  1628.  YCorner = Ymax - 160
  1629.  Xwidth = 16 * LEN(Msg$) + 16
  1630. ' IF Responses$ = "YN" THEN
  1631.   Xwidth = Xwidth + 80
  1632. ' END IF
  1633.  Ywidth = 22
  1634.  Bg = 11: Fg = 4: GOSUB Oblong
  1635.  zsLocateGCursor XCorner + 8, Ymax - 158
  1636.  x$ = Msg$
  1637.  IF Responses$ = "YN" THEN
  1638.   x$ = x$ + "? Y/N"
  1639.  ELSE
  1640.   x$ = x$ + " 0-9"
  1641.  END IF
  1642.  Fg = 0: ziPublish x$, 2, 2
  1643.  DO
  1644.   DO: LOOP UNTIL LEN(INKEY$) = 0
  1645.   DO: x$ = UCASE$(INKEY$): LOOP UNTIL LEN(x$) > 0
  1646.   DO: LOOP UNTIL LEN(INKEY$) = 0
  1647.  LOOP UNTIL INSTR(Responses$, x$) > 0
  1648.  LINE (XCorner - 5, YCorner - 5)-STEP(Xwidth + 9, Ywidth + 9), 11, BF
  1649.  Bg = 11: Fg = 0: zsLocateGCursor 180, 322: ziPublish "F", 2, 0
  1650.  Responses$ = "YN"
  1651.  
  1652.  RETURN
  1653.  
  1654. '+-------------------------------------------------------------------+
  1655. '▌ ShowOpcode                                                        ▌
  1656. '▌                                                                   ▌
  1657. '▌              i/p: Opcode$, Opcount                                ▌
  1658. '▌                                                                   ▌
  1659. '+-------------------------------------------------------------------+
  1660. ShowOpCode:
  1661.  
  1662.   IF OpCount < 1 THEN
  1663.    FOR ix = 1 TO 3
  1664.     LINE (286 - ix, 144 - ix)-STEP(67 + ix + ix, 67 + ix + ix), 1, B
  1665.     LINE (287, 145)-STEP(65, 65), 15, BF
  1666.    NEXT
  1667.   END IF
  1668.   LINE (287, 162)-STEP(66, 49), 15, BF
  1669.   IF AutoSw = 1 THEN
  1670.   LINE (294, 200)-STEP(48, 12), 4, BF
  1671.    zsLocateGCursor 302, 202
  1672.    Fg = 15: ziPublish "AUTO", 1, 2
  1673.   END IF
  1674.   IF MacroSw = 1 THEN
  1675.   LINE (290, 200)-STEP(56, 12), 4, BF
  1676.    zsLocateGCursor 298, 202
  1677.    Fg = 15: ziPublish "MACRO", 1, 2
  1678.   END IF
  1679.   Bg = 15: Fg = 4
  1680.  
  1681. ' display count
  1682.   IF INSTR("THBLMRFVA", LEFT$(OpCode$, 1)) > 0 THEN
  1683.    OpCount = OpCount + 1
  1684.    xx$ = LTRIM$(STR$(OpCount))
  1685.    zsLocateGCursor 320 - 8 * LEN(xx$), 146
  1686.    Bg = 15: Fg = 1: ziPublish xx$, 2, 0
  1687.   END IF
  1688.  
  1689. ' display the opcode itself
  1690.   zsLocateGCursor 304, 168
  1691.   Bg = 15: Fg = 4: ziPublish OpCode$, 4, 2
  1692.  
  1693.   RETURN
  1694.  
  1695. '<p>
  1696. '<->
  1697. '++++++++++++++++++++++++
  1698. SUB ziPublish (Printstring$, size, italic)
  1699.  
  1700.   xx = POINT(0)
  1701.   yy = POINT(1)
  1702.   IF size THEN
  1703.     Scale = size
  1704.   ELSE
  1705.     Scale = 1
  1706.   END IF
  1707.  
  1708.   LenString = LEN(Printstring$)
  1709.  
  1710.   ExpScale = 8 * Scale
  1711.   limxx = xx + ExpScale * LenString - 1
  1712.   limyy = yy + ExpScale - 1
  1713.  
  1714.   IF italic AND 1 THEN
  1715.     limxx = limxx + 4 * Scale
  1716.   END IF
  1717.  
  1718.  
  1719.   IF italic AND 2 THEN
  1720.   ELSE
  1721.     LINE (xx, yy)-(limxx, limyy), Bg, BF
  1722.   END IF
  1723.  
  1724.  
  1725.   FOR a = 0 TO LenString - 1
  1726.     x = ASC(MID$(Printstring$, a + 1, 1))
  1727.     B = xx + ExpScale * a
  1728.     FOR y = 0 TO 7
  1729.       C = Font(x, y)
  1730.       d = y * Scale
  1731.       e = yy + d
  1732.       IF italic AND 1 THEN
  1733.     f = B + 4 * Scale - (d + Scale - 1) \ 2 - 1
  1734.       ELSE
  1735.     f = B
  1736.       END IF
  1737.       G = 128
  1738.       DO
  1739.     IF C AND G THEN
  1740.       FOR h = 0 TO Scale - 1
  1741.         FOR i = 0 TO Scale - 1
  1742.           PSET (f + h, e + i), Fg
  1743.         NEXT
  1744.       NEXT
  1745.     END IF
  1746.     f = f + Scale
  1747.     G = G \ 2
  1748.       LOOP UNTIL G = 0
  1749.     NEXT
  1750.   NEXT
  1751.   CALL zsLocateGCursor(limxx + 1, yy)
  1752.  
  1753. END SUB
  1754.  
  1755. SUB ziPublishHere (Row, Col, Printstring$, size, italic)
  1756.  
  1757.  IF Row + Col > 0 THEN
  1758.   LOCATE Row, Col
  1759.  END IF
  1760.  CALL zsAlignGCursor
  1761.  CALL ziPublish(Printstring$, size, italic)
  1762.  CALL zsAlignTCursor
  1763.  
  1764. END SUB
  1765.  
  1766. '<p>
  1767. '++++++++++++++++++++++++
  1768. SUB zsAlignGCursor
  1769.  
  1770.   Row = CSRLIN
  1771.   Col = POS(0)
  1772.   GXloc = (Col - 1) * ((Xmax + 1) \ Cols)
  1773.   GYloc = (Row - 1) * ((((Ymax + 1) \ Rows) * Rows + 1) \ Rows)
  1774.   CALL zsLocateGCursor(GXloc, GYloc)
  1775.  
  1776. END SUB
  1777.  
  1778. '<p>
  1779. '++++++++++++++++++++++++
  1780. SUB zsAlignTCursor
  1781.  
  1782.   GXloc = POINT(0)
  1783.   GYloc = POINT(1)
  1784.   a = (Xmax + 1) / Cols
  1785.   B = (Ymax + 1) / Rows
  1786.   Col = (GXloc + a - 1) \ a + 1
  1787.   Row = (GYloc + B - 1) \ B + 1
  1788.   LOCATE Row, Col
  1789.   CALL zsAlignGCursor
  1790.  
  1791. END SUB
  1792.  
  1793. '<p>
  1794. '++++++++++++++++++++++++
  1795. SUB zsLocateGCursor (XCoord, YCoord)
  1796.  
  1797.   GXloc = XCoord
  1798.   GYloc = YCoord
  1799.   PSET (GXloc, GYloc), POINT(GXloc, GYloc)
  1800.  
  1801. END SUB
  1802.  
  1803. '<p>
  1804. '++++++++++++++++++++++++
  1805. SUB zsPastel (XCoord, YCoord, Wide, Deep, colour1, colour2)
  1806.  
  1807.   IF Deep < 2 THEN
  1808.     a = Wide / XYratio!
  1809.   ELSE
  1810.     a = Deep
  1811.   END IF
  1812.  
  1813.   LINE (XCoord, YCoord)-(XCoord + Wide - 1, YCoord + a - 1), colour1, BF
  1814.   FOR B = XCoord TO XCoord + Wide - 1 STEP 2
  1815.     LINE (B, YCoord)-(B, YCoord + a - 1), colour2, , &H5555
  1816.   NEXT
  1817.   FOR B = XCoord + 1 TO XCoord + Wide - 1 STEP 2
  1818.     LINE (B, YCoord)-(B, YCoord + a - 1), colour2, , &HAAAA
  1819.   NEXT
  1820.  
  1821. END SUB
  1822.  
  1823. '<p>
  1824. '++++++++++++++++++++++++
  1825. SUB zsSetScrnMode (Mode, HiRows, HiCols)
  1826.  
  1827. IF Font(1, 1) = 0 THEN
  1828.  FOR i = 0 TO 255
  1829.   FOR j = 0 TO 7
  1830.    Font(i, j) = 0
  1831.   NEXT
  1832.  NEXT
  1833.  
  1834.  i = 0
  1835.  j = i + 1
  1836.  Font(j, 0) = 126: Font(j, 1) = 129: Font(j, 2) = 165: Font(j, 3) = 129
  1837.  Font(j, 4) = 189: Font(j, 5) = 153: Font(j, 6) = 129: Font(j, 7) = 126
  1838.  j = i + 2
  1839.  Font(j, 0) = 126: Font(j, 1) = 255: Font(j, 2) = 219: Font(j, 3) = 255
  1840.  Font(j, 4) = 195: Font(j, 5) = 231: Font(j, 6) = 255: Font(j, 7) = 126
  1841.  j = i + 3
  1842.  Font(j, 0) = 68: Font(j, 1) = 238: Font(j, 2) = 254: Font(j, 3) = 254
  1843.  Font(j, 4) = 124: Font(j, 5) = 56: Font(j, 6) = 16
  1844.  j = i + 4
  1845.  Font(j, 0) = 16: Font(j, 1) = 56: Font(j, 2) = 124: Font(j, 3) = 254
  1846.  Font(j, 4) = 124: Font(j, 5) = 56: Font(j, 6) = 16
  1847.  j = i + 5
  1848.  Font(j, 0) = 24: Font(j, 1) = 60: Font(j, 2) = 219: Font(j, 3) = 255
  1849.  Font(j, 4) = 219: Font(j, 5) = 24: Font(j, 6) = 60
  1850.  j = i + 6
  1851.  Font(j, 0) = 24: Font(j, 1) = 60: Font(j, 2) = 126: Font(j, 3) = 255
  1852.  Font(j, 4) = 126: Font(j, 5) = 24: Font(j, 6) = 60
  1853.  j = i + 7
  1854.  Font(j, 0) = 24: Font(j, 1) = 60: Font(j, 2) = 126: Font(j, 3) = 255
  1855.  Font(j, 4) = 126: Font(j, 5) = 24: Font(j, 6) = 60
  1856.  j = i + 8
  1857.  Font(j, 0) = 255: Font(j, 1) = 255: Font(j, 2) = 195: Font(j, 3) = 195
  1858.  Font(j, 4) = 195: Font(j, 5) = 195: Font(j, 6) = 255: Font(j, 7) = 255
  1859.  
  1860.  i = 10
  1861.  j = i + 4
  1862.  Font(j, 0) = 63: Font(j, 1) = 99: Font(j, 2) = 127: Font(j, 3) = 99
  1863.  Font(j, 4) = 99: Font(j, 5) = 103: Font(j, 6) = 230: Font(j, 7) = 192
  1864.  j = i + 5
  1865.  Font(j, 0) = 219: Font(j, 1) = 219: Font(j, 2) = 60: Font(j, 3) = 231
  1866.  Font(j, 4) = 231: Font(j, 5) = 60: Font(j, 6) = 219: Font(j, 7) = 219
  1867.  j = i + 6
  1868.  Font(j, 0) = 192: Font(j, 1) = 240: Font(j, 2) = 248: Font(j, 3) = 254
  1869.  Font(j, 4) = 248: Font(j, 5) = 240: Font(j, 6) = 192
  1870.  j = i + 7
  1871.  Font(j, 0) = 6: Font(j, 1) = 30: Font(j, 2) = 62: Font(j, 3) = 254
  1872.  Font(j, 4) = 62: Font(j, 5) = 30: Font(j, 6) = 6
  1873.  j = i + 8
  1874.  Font(j, 0) = 48: Font(j, 1) = 120: Font(j, 2) = 252: Font(j, 3) = 48
  1875.  Font(j, 4) = 48: Font(j, 5) = 252: Font(j, 6) = 120: Font(j, 7) = 48
  1876.  j = i + 9
  1877.  Font(j, 0) = 108: Font(j, 1) = 108: Font(j, 2) = 108: Font(j, 3) = 108
  1878.  Font(j, 4) = 108: Font(j, 6) = 108
  1879.  
  1880.  i = 20: j = i
  1881.  Font(j, 0) = 127: Font(j, 1) = 219: Font(j, 2) = 219: Font(j, 3) = 219
  1882.  Font(j, 4) = 123: Font(j, 5) = 27: Font(j, 6) = 27
  1883.  j = i + 1
  1884.  Font(j, 0) = 60: Font(j, 1) = 96: Font(j, 2) = 60: Font(j, 3) = 102
  1885.  Font(j, 4) = 102: Font(j, 5) = 60: Font(j, 6) = 6: Font(j, 7) = 60
  1886.  j = i + 2
  1887.  Font(j, 4) = 254: Font(j, 5) = 254: Font(j, 6) = 254
  1888.  j = i + 3
  1889.  Font(j, 0) = 24: Font(j, 1) = 60: Font(j, 2) = 126: Font(j, 3) = 24
  1890.  Font(j, 4) = 126: Font(j, 5) = 60: Font(j, 6) = 24: Font(j, 7) = 126
  1891.  j = i + 4
  1892.  Font(j, 0) = 48: Font(j, 1) = 120: Font(j, 2) = 252: Font(j, 3) = 48
  1893.  Font(j, 4) = 48: Font(j, 5) = 48: Font(j, 6) = 48
  1894.  j = i + 5
  1895.  Font(j, 0) = 48: Font(j, 1) = 48: Font(j, 2) = 48: Font(j, 3) = 48
  1896.  Font(j, 4) = 252: Font(j, 5) = 120: Font(j, 6) = 48
  1897.  j = i + 6
  1898.  Font(j, 1) = 8: Font(j, 2) = 12: Font(j, 3) = 254
  1899.  Font(j, 4) = 12: Font(j, 5) = 8
  1900.  j = i + 7
  1901.  Font(j, 1) = 32: Font(j, 2) = 96: Font(j, 3) = 254
  1902.  Font(j, 4) = 96: Font(j, 5) = 32
  1903.  j = i + 8
  1904.  Font(j, 1) = 32: Font(j, 2) = 96: Font(j, 3) = 254
  1905.  Font(j, 4) = 96: Font(j, 5) = 32
  1906.  j = i + 9
  1907.  Font(j, 1) = 32: Font(j, 2) = 96: Font(j, 3) = 254
  1908.  Font(j, 4) = 96: Font(j, 5) = 32
  1909.  
  1910.  i = 30: j = i
  1911.  Font(j, 1) = 32: Font(j, 2) = 96: Font(j, 3) = 254
  1912.  Font(j, 4) = 96: Font(j, 5) = 32
  1913.  j = i + 1
  1914.  Font(j, 1) = 32: Font(j, 2) = 96: Font(j, 3) = 254
  1915.  Font(j, 4) = 96: Font(j, 5) = 32
  1916.  j = i + 3
  1917.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 24
  1918.  Font(j, 4) = 24: Font(j, 6) = 24
  1919.  j = i + 4
  1920.  Font(j, 0) = 204: Font(j, 1) = 204: Font(j, 2) = 204
  1921.  j = i + 5
  1922.  Font(j, 0) = 54: Font(j, 1) = 108: Font(j, 2) = 254: Font(j, 3) = 108
  1923.  Font(j, 4) = 254: Font(j, 5) = 108: Font(j, 6) = 216
  1924.  j = i + 6
  1925.  Font(j, 0) = 24: Font(j, 1) = 126: Font(j, 2) = 192: Font(j, 3) = 124
  1926.  Font(j, 4) = 6: Font(j, 5) = 252: Font(j, 6) = 48
  1927.  j = i + 7
  1928.  Font(j, 0) = 194: Font(j, 1) = 198: Font(j, 2) = 12: Font(j, 3) = 24
  1929.  Font(j, 4) = 48: Font(j, 5) = 102: Font(j, 6) = 198
  1930.  j = i + 8
  1931.  Font(j, 0) = 56: Font(j, 1) = 108: Font(j, 2) = 56: Font(j, 3) = 112
  1932.  Font(j, 4) = 222: Font(j, 5) = 204: Font(j, 6) = 118
  1933.  j = i + 9
  1934.  Font(j, 0) = 48: Font(j, 1) = 48: Font(j, 2) = 96
  1935.  
  1936.  i = 40: j = i
  1937.  Font(j, 0) = 12: Font(j, 1) = 24: Font(j, 2) = 48: Font(j, 3) = 48
  1938.  Font(j, 4) = 48: Font(j, 5) = 24: Font(j, 6) = 12
  1939.  j = i + 1
  1940.  Font(j, 0) = 48: Font(j, 1) = 24: Font(j, 2) = 12: Font(j, 3) = 12
  1941.  Font(j, 4) = 12: Font(j, 5) = 24: Font(j, 6) = 48
  1942.  j = i + 2
  1943.  Font(j, 1) = 108: Font(j, 2) = 56: Font(j, 3) = 254
  1944.  Font(j, 4) = 56: Font(j, 5) = 108
  1945.  j = i + 3
  1946.  Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 126
  1947.  Font(j, 4) = 24: Font(j, 5) = 24
  1948.  j = i + 4
  1949.  Font(j, 5) = 24: Font(j, 6) = 24: Font(j, 7) = 48
  1950.  j = i + 5
  1951.  Font(j, 3) = 126
  1952.  j = i + 6
  1953.  Font(j, 5) = 24: Font(j, 6) = 24
  1954.  j = i + 7
  1955.  Font(j, 0) = 2: Font(j, 1) = 6: Font(j, 2) = 12: Font(j, 3) = 24
  1956.  Font(j, 4) = 48: Font(j, 5) = 96: Font(j, 6) = 192
  1957.  j = i + 8
  1958.  Font(j, 0) = 124: Font(j, 1) = 198: Font(j, 2) = 198: Font(j, 3) = 198
  1959.  Font(j, 4) = 198: Font(j, 5) = 198: Font(j, 6) = 124
  1960.  j = i + 9
  1961.  Font(j, 0) = 24: Font(j, 1) = 56: Font(j, 2) = 24: Font(j, 3) = 24
  1962.  Font(j, 4) = 24: Font(j, 5) = 24: Font(j, 6) = 126
  1963.  
  1964.  i = 50: j = i
  1965.  Font(j, 0) = 124: Font(j, 1) = 198: Font(j, 2) = 6: Font(j, 3) = 28
  1966.  Font(j, 4) = 112: Font(j, 5) = 198: Font(j, 6) = 254
  1967.  j = i + 1
  1968.  Font(j, 0) = 124: Font(j, 1) = 198: Font(j, 2) = 6: Font(j, 3) = 28
  1969.  Font(j, 4) = 6: Font(j, 5) = 198: Font(j, 6) = 124
  1970.  j = i + 2
  1971.  Font(j, 0) = 28: Font(j, 1) = 60: Font(j, 2) = 108: Font(j, 3) = 204
  1972.  Font(j, 4) = 254: Font(j, 5) = 12: Font(j, 6) = 12
  1973.  j = i + 3
  1974.  Font(j, 0) = 254: Font(j, 1) = 192: Font(j, 2) = 252: Font(j, 3) = 6
  1975.  Font(j, 4) = 6: Font(j, 5) = 198: Font(j, 6) = 124
  1976.  j = i + 4
  1977.  Font(j, 0) = 60: Font(j, 1) = 96: Font(j, 2) = 192: Font(j, 3) = 252
  1978.  Font(j, 4) = 198: Font(j, 5) = 198: Font(j, 6) = 124
  1979.  j = i + 5
  1980.  Font(j, 0) = 254: Font(j, 1) = 198: Font(j, 2) = 12: Font(j, 3) = 24
  1981.  Font(j, 4) = 48: Font(j, 5) = 48: Font(j, 6) = 48
  1982.  j = i + 6
  1983.  Font(j, 0) = 124: Font(j, 1) = 198: Font(j, 2) = 198: Font(j, 3) = 124
  1984.  Font(j, 4) = 198: Font(j, 5) = 198: Font(j, 6) = 124
  1985.  j = i + 7
  1986.  Font(j, 0) = 124: Font(j, 1) = 198: Font(j, 2) = 198: Font(j, 3) = 126
  1987.  Font(j, 4) = 6: Font(j, 5) = 12: Font(j, 6) = 120
  1988.  j = i + 8
  1989.  Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 5) = 24: Font(j, 6) = 24
  1990.  j = i + 9
  1991.  Font(j, 1) = 24: Font(j, 2) = 24
  1992.  Font(j, 5) = 24: Font(j, 6) = 24: Font(j, 7) = 48
  1993.  
  1994.  i = 60: j = i
  1995.  Font(j, 0) = 12: Font(j, 1) = 24: Font(j, 2) = 48: Font(j, 3) = 96
  1996.  Font(j, 4) = 48: Font(j, 5) = 24: Font(j, 6) = 12
  1997.  j = i + 1
  1998.  Font(j, 2) = 126: Font(j, 5) = 126
  1999.  j = i + 2
  2000.  Font(j, 0) = 48: Font(j, 1) = 24: Font(j, 2) = 12: Font(j, 3) = 6
  2001.  Font(j, 4) = 12: Font(j, 5) = 24: Font(j, 6) = 48
  2002.  j = i + 3
  2003.  Font(j, 0) = 60: Font(j, 1) = 102: Font(j, 2) = 6: Font(j, 3) = 12
  2004.  Font(j, 4) = 24: Font(j, 6) = 24
  2005.  j = i + 4
  2006.  Font(j, 0) = 124: Font(j, 1) = 198: Font(j, 2) = 222: Font(j, 3) = 222
  2007.  Font(j, 4) = 222: Font(j, 5) = 192: Font(j, 6) = 124
  2008.  j = i + 5
  2009.  Font(j, 0) = 56: Font(j, 1) = 108: Font(j, 2) = 198: Font(j, 3) = 198
  2010.  Font(j, 4) = 254: Font(j, 5) = 198: Font(j, 6) = 198
  2011.  j = i + 6
  2012.  Font(j, 0) = 252: Font(j, 1) = 110: Font(j, 2) = 102: Font(j, 3) = 124
  2013.  Font(j, 4) = 102: Font(j, 5) = 110: Font(j, 6) = 252
  2014.  j = i + 7
  2015.  Font(j, 0) = 62: Font(j, 1) = 98: Font(j, 2) = 192: Font(j, 3) = 192
  2016.  Font(j, 4) = 192: Font(j, 5) = 98: Font(j, 6) = 62
  2017.  j = i + 8
  2018.  Font(j, 0) = 248: Font(j, 1) = 108: Font(j, 2) = 102: Font(j, 3) = 102
  2019.  Font(j, 4) = 102: Font(j, 5) = 108: Font(j, 6) = 248
  2020.  j = i + 9
  2021.  Font(j, 0) = 254: Font(j, 1) = 98: Font(j, 2) = 96: Font(j, 3) = 120
  2022.  Font(j, 4) = 96: Font(j, 5) = 98: Font(j, 6) = 254
  2023.  
  2024.  i = 70: j = i
  2025.  Font(j, 0) = 254: Font(j, 1) = 98: Font(j, 2) = 96: Font(j, 3) = 120
  2026.  Font(j, 4) = 96: Font(j, 5) = 96: Font(j, 6) = 240
  2027.  j = i + 1
  2028.  Font(j, 0) = 62: Font(j, 1) = 98: Font(j, 2) = 192: Font(j, 3) = 192
  2029.  Font(j, 4) = 206: Font(j, 5) = 102: Font(j, 6) = 62
  2030.  j = i + 2
  2031.  Font(j, 0) = 198: Font(j, 1) = 198: Font(j, 2) = 198: Font(j, 3) = 254
  2032.  Font(j, 4) = 198: Font(j, 5) = 198: Font(j, 6) = 198
  2033.  j = i + 3
  2034.  Font(j, 0) = 60: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 24
  2035.  Font(j, 4) = 24: Font(j, 5) = 24: Font(j, 6) = 60
  2036.  j = i + 4
  2037.  Font(j, 0) = 30: Font(j, 1) = 12: Font(j, 2) = 12: Font(j, 3) = 12
  2038.  Font(j, 4) = 12: Font(j, 5) = 204: Font(j, 6) = 120
  2039.  j = i + 5
  2040.  Font(j, 0) = 230: Font(j, 1) = 102: Font(j, 2) = 108: Font(j, 3) = 120
  2041.  Font(j, 4) = 120: Font(j, 5) = 108: Font(j, 6) = 230
  2042.  j = i + 6
  2043.  Font(j, 0) = 240: Font(j, 1) = 96: Font(j, 2) = 96: Font(j, 3) = 96
  2044.  Font(j, 4) = 96: Font(j, 5) = 102: Font(j, 6) = 254
  2045.  j = i + 7
  2046.  Font(j, 0) = 198: Font(j, 1) = 238: Font(j, 2) = 254: Font(j, 3) = 214
  2047.  Font(j, 4) = 198: Font(j, 5) = 198: Font(j, 6) = 198
  2048.  j = i + 8
  2049.  Font(j, 0) = 198: Font(j, 1) = 230: Font(j, 2) = 246: Font(j, 3) = 254
  2050.  Font(j, 4) = 222: Font(j, 5) = 206: Font(j, 6) = 198
  2051.  j = i + 9
  2052.  Font(j, 0) = 124: Font(j, 1) = 198: Font(j, 2) = 198: Font(j, 3) = 198
  2053.  Font(j, 4) = 198: Font(j, 5) = 198: Font(j, 6) = 124
  2054.  
  2055.  i = 80: j = i
  2056.  Font(j, 0) = 248: Font(j, 1) = 102: Font(j, 2) = 102: Font(j, 3) = 120
  2057.  Font(j, 4) = 96: Font(j, 5) = 96: Font(j, 6) = 240
  2058.  j = i + 1
  2059.  Font(j, 0) = 124: Font(j, 1) = 198: Font(j, 2) = 198: Font(j, 3) = 214
  2060.  Font(j, 4) = 222: Font(j, 5) = 124: Font(j, 6) = 6
  2061.  j = i + 2
  2062.  Font(j, 0) = 252: Font(j, 1) = 102: Font(j, 2) = 102: Font(j, 3) = 124
  2063.  Font(j, 4) = 120: Font(j, 5) = 108: Font(j, 6) = 230
  2064.  j = i + 3
  2065.  Font(j, 0) = 124: Font(j, 1) = 198: Font(j, 2) = 224: Font(j, 3) = 56
  2066.  Font(j, 4) = 14: Font(j, 5) = 198: Font(j, 6) = 124
  2067.  j = i + 4
  2068.  Font(j, 0) = 126: Font(j, 1) = 90: Font(j, 2) = 24: Font(j, 3) = 24
  2069.  Font(j, 4) = 24: Font(j, 5) = 24: Font(j, 6) = 60
  2070.  j = i + 5
  2071.  Font(j, 0) = 102: Font(j, 1) = 102: Font(j, 2) = 102: Font(j, 3) = 102
  2072.  Font(j, 4) = 102: Font(j, 5) = 102: Font(j, 6) = 60
  2073.  j = i + 6
  2074.  Font(j, 0) = 102: Font(j, 1) = 102: Font(j, 2) = 102: Font(j, 3) = 102
  2075.  Font(j, 4) = 102: Font(j, 5) = 60: Font(j, 6) = 24
  2076.  j = i + 7
  2077.  Font(j, 0) = 198: Font(j, 1) = 198: Font(j, 2) = 198: Font(j, 3) = 214
  2078.  Font(j, 4) = 254: Font(j, 5) = 254: Font(j, 6) = 198
  2079.  j = i + 8
  2080.  Font(j, 0) = 198: Font(j, 1) = 108: Font(j, 2) = 56: Font(j, 3) = 56
  2081.  Font(j, 4) = 108: Font(j, 5) = 198: Font(j, 6) = 198
  2082.  j = i + 9
  2083.  Font(j, 0) = 102: Font(j, 1) = 102: Font(j, 2) = 102: Font(j, 3) = 60
  2084.  Font(j, 4) = 24: Font(j, 5) = 24: Font(j, 6) = 60
  2085.  
  2086.  i = 90: j = i
  2087.  Font(j, 0) = 254: Font(j, 1) = 204: Font(j, 2) = 24: Font(j, 3) = 48
  2088.  Font(j, 4) = 96: Font(j, 5) = 198: Font(j, 6) = 254
  2089.  j = i + 1
  2090.  Font(j, 0) = 60: Font(j, 1) = 48: Font(j, 2) = 48: Font(j, 3) = 48
  2091.  Font(j, 4) = 48: Font(j, 5) = 48: Font(j, 6) = 60
  2092.  j = i + 2
  2093.  Font(j, 0) = 128: Font(j, 1) = 192: Font(j, 2) = 96: Font(j, 3) = 48
  2094.  Font(j, 4) = 24: Font(j, 5) = 12: Font(j, 6) = 6
  2095.  j = i + 3
  2096.  Font(j, 0) = 60: Font(j, 1) = 12: Font(j, 2) = 12: Font(j, 3) = 12
  2097.  Font(j, 4) = 12: Font(j, 5) = 12: Font(j, 6) = 60
  2098.  j = i + 4
  2099.  Font(j, 0) = 24: Font(j, 1) = 60: Font(j, 2) = 102
  2100.  j = i + 5
  2101.  Font(j, 7) = 255
  2102.  j = i + 6
  2103.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 12
  2104.  j = i + 7
  2105.  Font(j, 2) = 56: Font(j, 3) = 12
  2106.  Font(j, 4) = 124: Font(j, 5) = 204: Font(j, 6) = 118
  2107.  j = i + 8
  2108.  Font(j, 0) = 96: Font(j, 1) = 96: Font(j, 2) = 96: Font(j, 3) = 124
  2109.  Font(j, 4) = 102: Font(j, 5) = 102: Font(j, 6) = 124
  2110.  j = i + 9
  2111.  Font(j, 2) = 124: Font(j, 3) = 196
  2112.  Font(j, 4) = 192: Font(j, 5) = 196: Font(j, 6) = 124
  2113.  
  2114.  i = 100: j = i
  2115.  Font(j, 0) = 12: Font(j, 1) = 12: Font(j, 2) = 12: Font(j, 3) = 124
  2116.  Font(j, 4) = 204: Font(j, 5) = 204: Font(j, 6) = 118
  2117.  j = i + 1
  2118.  Font(j, 2) = 120: Font(j, 3) = 204
  2119.  Font(j, 4) = 252: Font(j, 5) = 192: Font(j, 6) = 124
  2120.  j = i + 2
  2121.  Font(j, 0) = 56: Font(j, 1) = 108: Font(j, 2) = 96: Font(j, 3) = 248
  2122.  Font(j, 4) = 96: Font(j, 5) = 96: Font(j, 6) = 240
  2123.  j = i + 3
  2124.  Font(j, 2) = 118: Font(j, 3) = 204
  2125.  Font(j, 4) = 204: Font(j, 5) = 124: Font(j, 6) = 12: Font(j, 7) = 120
  2126.  j = i + 4
  2127.  Font(j, 0) = 224: Font(j, 1) = 96: Font(j, 2) = 96: Font(j, 3) = 124
  2128.  Font(j, 4) = 102: Font(j, 5) = 102: Font(j, 6) = 102
  2129.  j = i + 5
  2130.  Font(j, 0) = 48: Font(j, 2) = 112: Font(j, 3) = 48
  2131.  Font(j, 4) = 48: Font(j, 5) = 48: Font(j, 6) = 120
  2132.  j = i + 6
  2133.  Font(j, 0) = 12: Font(j, 2) = 28: Font(j, 3) = 12
  2134.  Font(j, 4) = 12: Font(j, 5) = 204: Font(j, 6) = 204: Font(j, 7) = 120
  2135.  j = i + 7
  2136.  Font(j, 0) = 224: Font(j, 1) = 96: Font(j, 2) = 102: Font(j, 3) = 108
  2137.  Font(j, 4) = 120: Font(j, 5) = 108: Font(j, 6) = 230
  2138.  j = i + 8
  2139.  Font(j, 0) = 112: Font(j, 1) = 48: Font(j, 2) = 48: Font(j, 3) = 48
  2140.  Font(j, 4) = 48: Font(j, 5) = 48: Font(j, 6) = 120
  2141.  j = i + 9
  2142.  Font(j, 2) = 204: Font(j, 3) = 254
  2143.  Font(j, 4) = 214: Font(j, 5) = 198: Font(j, 6) = 198
  2144.  
  2145.  i = 110: j = i
  2146.  Font(j, 2) = 220: Font(j, 3) = 102
  2147.  Font(j, 4) = 102: Font(j, 5) = 102: Font(j, 6) = 102
  2148.  j = i + 1
  2149.  Font(j, 2) = 60: Font(j, 3) = 102
  2150.  Font(j, 4) = 102: Font(j, 5) = 102: Font(j, 6) = 60
  2151.  j = i + 2
  2152.  Font(j, 2) = 220: Font(j, 3) = 102
  2153.  Font(j, 4) = 102: Font(j, 5) = 124: Font(j, 6) = 96: Font(j, 7) = 240
  2154.  j = i + 3
  2155.  Font(j, 2) = 118: Font(j, 3) = 204
  2156.  Font(j, 4) = 204: Font(j, 5) = 124: Font(j, 6) = 12: Font(j, 7) = 30
  2157.  j = i + 4
  2158.  Font(j, 2) = 220: Font(j, 3) = 118
  2159.  Font(j, 4) = 96: Font(j, 5) = 96: Font(j, 6) = 240
  2160.  j = i + 5
  2161.  Font(j, 2) = 120: Font(j, 3) = 192
  2162.  Font(j, 4) = 120: Font(j, 5) = 12: Font(j, 6) = 120
  2163.  j = i + 6
  2164.  Font(j, 0) = 16: Font(j, 1) = 48: Font(j, 2) = 120: Font(j, 3) = 48
  2165.  Font(j, 4) = 48: Font(j, 5) = 52: Font(j, 6) = 24
  2166.  j = i + 7
  2167.  Font(j, 2) = 204: Font(j, 3) = 204
  2168.  Font(j, 4) = 204: Font(j, 5) = 204: Font(j, 6) = 118
  2169.  j = i + 8
  2170.  Font(j, 2) = 102: Font(j, 3) = 102
  2171.  Font(j, 4) = 102: Font(j, 5) = 60: Font(j, 6) = 24
  2172.  j = i + 9
  2173.  Font(j, 2) = 198: Font(j, 3) = 198
  2174.  Font(j, 4) = 214: Font(j, 5) = 254: Font(j, 6) = 108
  2175.  
  2176.  i = 120: j = i
  2177.  Font(j, 2) = 204: Font(j, 3) = 120
  2178.  Font(j, 4) = 48: Font(j, 5) = 120: Font(j, 6) = 204
  2179.  j = i + 1
  2180.  Font(j, 2) = 204: Font(j, 3) = 204
  2181.  Font(j, 4) = 204: Font(j, 5) = 124: Font(j, 6) = 12: Font(j, 7) = 120
  2182.  j = i + 2
  2183.  Font(j, 2) = 252: Font(j, 3) = 24
  2184.  Font(j, 4) = 48: Font(j, 5) = 96: Font(j, 6) = 252
  2185.  j = i + 3
  2186.  Font(j, 0) = 14: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 112
  2187.  Font(j, 4) = 24: Font(j, 5) = 24: Font(j, 6) = 14
  2188.  j = i + 4
  2189.  Font(j, 0) = 48: Font(j, 1) = 48: Font(j, 2) = 48
  2190.  Font(j, 4) = 48: Font(j, 5) = 48: Font(j, 6) = 48
  2191.  j = i + 5
  2192.  Font(j, 0) = 112: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 14
  2193.  Font(j, 4) = 24: Font(j, 5) = 24: Font(j, 6) = 112
  2194.  j = i + 6
  2195.  Font(j, 1) = 118: Font(j, 2) = 220
  2196.  j = i + 7
  2197.  Font(j, 0) = 16: Font(j, 1) = 56: Font(j, 2) = 108: Font(j, 3) = 198
  2198.  Font(j, 4) = 198: Font(j, 5) = 198: Font(j, 6) = 254
  2199.  j = i + 8
  2200.  Font(j, 0) = 120: Font(j, 1) = 204: Font(j, 2) = 192: Font(j, 3) = 204
  2201.  Font(j, 4) = 120: Font(j, 5) = 48: Font(j, 6) = 24: Font(j, 7) = 112
  2202.  j = i + 9
  2203.  Font(j, 1) = 204: Font(j, 3) = 204
  2204.  Font(j, 4) = 204: Font(j, 5) = 204: Font(j, 6) = 118
  2205.  
  2206.  i = 130: j = i
  2207.  Font(j, 0) = 28: Font(j, 2) = 120: Font(j, 3) = 204
  2208.  Font(j, 4) = 252: Font(j, 5) = 192: Font(j, 6) = 124
  2209.  j = i + 1
  2210.  Font(j, 0) = 48: Font(j, 1) = 204: Font(j, 2) = 120: Font(j, 3) = 12
  2211.  Font(j, 4) = 124: Font(j, 5) = 204: Font(j, 6) = 118
  2212.  j = i + 2
  2213.  Font(j, 0) = 204: Font(j, 2) = 120: Font(j, 3) = 12
  2214.  Font(j, 4) = 124: Font(j, 5) = 204: Font(j, 6) = 118
  2215.  j = i + 3
  2216.  Font(j, 0) = 224: Font(j, 2) = 120: Font(j, 3) = 12
  2217.  Font(j, 4) = 124: Font(j, 5) = 204: Font(j, 6) = 118
  2218.  j = i + 4
  2219.  Font(j, 0) = 48: Font(j, 1) = 48: Font(j, 2) = 120: Font(j, 3) = 12
  2220.  Font(j, 4) = 124: Font(j, 5) = 204: Font(j, 6) = 118
  2221.  j = i + 5
  2222.  Font(j, 1) = 124: Font(j, 2) = 192: Font(j, 3) = 192
  2223.  Font(j, 4) = 124: Font(j, 5) = 24: Font(j, 6) = 120
  2224.  j = i + 6
  2225.  Font(j, 0) = 48: Font(j, 1) = 204: Font(j, 2) = 120: Font(j, 3) = 204
  2226.  Font(j, 4) = 252: Font(j, 5) = 192: Font(j, 6) = 124
  2227.  j = i + 7
  2228.  Font(j, 0) = 204: Font(j, 2) = 120: Font(j, 3) = 204
  2229.  Font(j, 4) = 252: Font(j, 5) = 192: Font(j, 6) = 124
  2230.  j = i + 8
  2231.  Font(j, 0) = 224: Font(j, 2) = 120: Font(j, 3) = 204
  2232.  Font(j, 4) = 252: Font(j, 5) = 192: Font(j, 6) = 124
  2233.  j = i + 9
  2234.  Font(j, 0) = 204: Font(j, 2) = 48: Font(j, 3) = 48
  2235.  Font(j, 4) = 48: Font(j, 5) = 48: Font(j, 6) = 120
  2236.  
  2237.  i = 140: j = i
  2238.  Font(j, 0) = 48: Font(j, 1) = 204: Font(j, 2) = 48: Font(j, 3) = 48
  2239.  Font(j, 4) = 48: Font(j, 5) = 48: Font(j, 6) = 120
  2240.  j = i + 1
  2241.  Font(j, 0) = 224: Font(j, 2) = 48: Font(j, 3) = 48
  2242.  Font(j, 4) = 48: Font(j, 5) = 48: Font(j, 6) = 120
  2243.  j = i + 2
  2244.  Font(j, 0) = 204: Font(j, 2) = 48: Font(j, 3) = 120
  2245.  Font(j, 4) = 204: Font(j, 5) = 252: Font(j, 6) = 204
  2246.  j = i + 3
  2247.  Font(j, 0) = 48: Font(j, 1) = 72: Font(j, 2) = 48: Font(j, 3) = 120
  2248.  Font(j, 4) = 204: Font(j, 5) = 252: Font(j, 6) = 204
  2249.  j = i + 4
  2250.  Font(j, 0) = 56: Font(j, 2) = 124: Font(j, 3) = 96
  2251.  Font(j, 4) = 120: Font(j, 5) = 96: Font(j, 6) = 124
  2252.  j = i + 5
  2253.  Font(j, 1) = 126: Font(j, 2) = 26: Font(j, 3) = 126
  2254.  Font(j, 4) = 216: Font(j, 5) = 218: Font(j, 6) = 126
  2255.  j = i + 6
  2256.  Font(j, 0) = 62: Font(j, 1) = 108: Font(j, 2) = 204: Font(j, 3) = 206
  2257.  Font(j, 4) = 252: Font(j, 5) = 204: Font(j, 6) = 206
  2258.  j = i + 7
  2259.  Font(j, 0) = 24: Font(j, 1) = 102: Font(j, 3) = 60
  2260.  Font(j, 4) = 102: Font(j, 5) = 102: Font(j, 6) = 60
  2261.  j = i + 8
  2262.  Font(j, 1) = 102: Font(j, 3) = 60
  2263.  Font(j, 4) = 102: Font(j, 5) = 102: Font(j, 6) = 60
  2264.  j = i + 9
  2265.  Font(j, 1) = 112: Font(j, 3) = 60
  2266.  Font(j, 4) = 102: Font(j, 5) = 102: Font(j, 6) = 60
  2267.  
  2268.  i = 150: j = i
  2269.  Font(j, 0) = 48: Font(j, 1) = 204: Font(j, 3) = 204
  2270.  Font(j, 4) = 204: Font(j, 5) = 204: Font(j, 6) = 118
  2271.  j = i + 1
  2272.  Font(j, 1) = 224: Font(j, 3) = 204
  2273.  Font(j, 4) = 204: Font(j, 5) = 204: Font(j, 6) = 118
  2274.  j = i + 2
  2275.  Font(j, 1) = 204: Font(j, 3) = 204
  2276.  Font(j, 4) = 204: Font(j, 5) = 124: Font(j, 6) = 12: Font(j, 7) = 120
  2277.  j = i + 3
  2278.  Font(j, 0) = 204: Font(j, 1) = 48: Font(j, 2) = 120: Font(j, 3) = 204
  2279.  Font(j, 4) = 204: Font(j, 5) = 120: Font(j, 6) = 48
  2280.  j = i + 4
  2281.  Font(j, 0) = 204: Font(j, 2) = 204: Font(j, 3) = 204
  2282.  Font(j, 4) = 204: Font(j, 5) = 204: Font(j, 6) = 120
  2283.  j = i + 5
  2284.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 124: Font(j, 3) = 192
  2285.  Font(j, 4) = 192: Font(j, 5) = 124: Font(j, 6) = 24: Font(j, 7) = 24
  2286.  j = i + 6
  2287.  Font(j, 0) = 56: Font(j, 1) = 108: Font(j, 2) = 96: Font(j, 3) = 240
  2288.  Font(j, 4) = 96: Font(j, 5) = 236: Font(j, 6) = 252
  2289.  j = i + 7
  2290.  Font(j, 0) = 204: Font(j, 1) = 204: Font(j, 2) = 120: Font(j, 3) = 48
  2291.  Font(j, 4) = 252: Font(j, 5) = 48: Font(j, 6) = 252: Font(j, 7) = 48
  2292.  j = i + 8
  2293.  Font(j, 0) = 248: Font(j, 1) = 204: Font(j, 2) = 204: Font(j, 3) = 248
  2294.  Font(j, 4) = 204: Font(j, 5) = 222: Font(j, 6) = 204: Font(j, 7) = 206
  2295.  j = i + 9
  2296.  Font(j, 0) = 14: Font(j, 1) = 27: Font(j, 2) = 24: Font(j, 3) = 126
  2297.  Font(j, 4) = 24: Font(j, 5) = 24: Font(j, 6) = 216: Font(j, 7) = 112
  2298.  
  2299.  i = 160: j = i
  2300.  Font(j, 0) = 28: Font(j, 2) = 120: Font(j, 3) = 12
  2301.  Font(j, 4) = 124: Font(j, 5) = 204: Font(j, 6) = 118
  2302.  j = i + 1
  2303.  Font(j, 0) = 28: Font(j, 2) = 48: Font(j, 3) = 48
  2304.  Font(j, 4) = 48: Font(j, 5) = 48: Font(j, 6) = 120
  2305.  j = i + 2
  2306.  Font(j, 1) = 14: Font(j, 3) = 60
  2307.  Font(j, 4) = 102: Font(j, 5) = 102: Font(j, 6) = 60
  2308.  j = i + 3
  2309.  Font(j, 1) = 28: Font(j, 3) = 204
  2310.  Font(j, 4) = 204: Font(j, 5) = 204: Font(j, 6) = 118
  2311.  j = i + 4
  2312.  Font(j, 1) = 252: Font(j, 3) = 220
  2313.  Font(j, 4) = 102: Font(j, 5) = 102: Font(j, 6) = 102
  2314.  j = i + 5
  2315.  Font(j, 0) = 126: Font(j, 2) = 102: Font(j, 3) = 118
  2316.  Font(j, 4) = 126: Font(j, 5) = 110: Font(j, 6) = 102
  2317.  j = i + 6
  2318.  Font(j, 0) = 120: Font(j, 1) = 216: Font(j, 2) = 216: Font(j, 3) = 124
  2319.  Font(j, 5) = 252
  2320.  j = i + 7
  2321.  Font(j, 0) = 120: Font(j, 1) = 204: Font(j, 2) = 204: Font(j, 3) = 120
  2322.  Font(j, 5) = 252
  2323.  j = i + 8
  2324.  Font(j, 0) = 24: Font(j, 2) = 24: Font(j, 3) = 48
  2325.  Font(j, 4) = 96: Font(j, 5) = 102: Font(j, 6) = 60
  2326.  j = i + 9
  2327.  Font(j, 3) = 254: Font(j, 4) = 192: Font(j, 5) = 192
  2328.  
  2329.  i = 170: j = i
  2330.  Font(j, 3) = 254: Font(j, 4) = 6: Font(j, 5) = 6
  2331.  j = i + 1
  2332.  Font(j, 0) = 198: Font(j, 1) = 204: Font(j, 2) = 216: Font(j, 3) = 54
  2333.  Font(j, 4) = 107: Font(j, 5) = 198: Font(j, 6) = 143
  2334.  j = i + 2
  2335.  Font(j, 0) = 198: Font(j, 1) = 204: Font(j, 2) = 218: Font(j, 3) = 54
  2336.  Font(j, 4) = 106: Font(j, 5) = 223: Font(j, 6) = 130
  2337.  j = i + 3
  2338.  Font(j, 0) = 48: Font(j, 1) = 48: Font(j, 3) = 48
  2339.  Font(j, 4) = 48: Font(j, 5) = 48: Font(j, 6) = 48
  2340.  j = i + 4
  2341.  Font(j, 1) = 54: Font(j, 2) = 108: Font(j, 3) = 216
  2342.  Font(j, 4) = 108: Font(j, 5) = 54
  2343.  j = i + 5
  2344.  Font(j, 1) = 216: Font(j, 2) = 108: Font(j, 3) = 54
  2345.  Font(j, 4) = 108: Font(j, 5) = 216
  2346.  j = i + 6
  2347.  Font(j, 0) = 68: Font(j, 1) = 17: Font(j, 2) = 68: Font(j, 3) = 17
  2348.  Font(j, 4) = 68: Font(j, 5) = 17: Font(j, 6) = 68: Font(j, 7) = 17
  2349.  j = i + 7
  2350.  Font(j, 0) = 170: Font(j, 1) = 85: Font(j, 2) = 170: Font(j, 3) = 85
  2351.  Font(j, 4) = 170: Font(j, 5) = 85: Font(j, 6) = 170: Font(j, 7) = 85
  2352.  j = i + 8
  2353.  Font(j, 0) = 187: Font(j, 1) = 238: Font(j, 2) = 187: Font(j, 3) = 238
  2354.  Font(j, 4) = 187: Font(j, 5) = 238: Font(j, 6) = 187: Font(j, 7) = 238
  2355.  j = i + 9
  2356.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 24
  2357.  Font(j, 4) = 24: Font(j, 5) = 24: Font(j, 6) = 24: Font(j, 7) = 24
  2358.  
  2359.  i = 180: j = i
  2360.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 24
  2361.  Font(j, 4) = 24: Font(j, 5) = 248: Font(j, 6) = 24: Font(j, 7) = 24
  2362.  j = i + 1
  2363.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 248
  2364.  Font(j, 4) = 24: Font(j, 5) = 248: Font(j, 6) = 24: Font(j, 7) = 24
  2365.  j = i + 2
  2366.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 54
  2367.  Font(j, 4) = 54: Font(j, 5) = 246: Font(j, 6) = 54: Font(j, 7) = 54
  2368.  j = i + 3
  2369.  Font(j, 5) = 254: Font(j, 6) = 54: Font(j, 7) = 54
  2370.  j = i + 4
  2371.  Font(j, 3) = 248
  2372.  Font(j, 4) = 24: Font(j, 5) = 248: Font(j, 6) = 24: Font(j, 7) = 24
  2373.  j = i + 5
  2374.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 246
  2375.  Font(j, 4) = 6: Font(j, 5) = 246: Font(j, 6) = 54: Font(j, 7) = 54
  2376.  j = i + 6
  2377.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 54
  2378.  Font(j, 4) = 54: Font(j, 5) = 54: Font(j, 6) = 54: Font(j, 7) = 54
  2379.  j = i + 7
  2380.  Font(j, 3) = 254
  2381.  Font(j, 4) = 6: Font(j, 5) = 246: Font(j, 6) = 54: Font(j, 7) = 54
  2382.  j = i + 8
  2383.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 246
  2384.  Font(j, 4) = 6: Font(j, 5) = 254
  2385.  j = i + 9
  2386.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 54
  2387.  Font(j, 4) = 54: Font(j, 5) = 254
  2388.  
  2389.  i = 190: j = i
  2390.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 248
  2391.  Font(j, 4) = 24: Font(j, 5) = 248
  2392.  j = i + 1
  2393.  Font(j, 5) = 248: Font(j, 6) = 24: Font(j, 7) = 24
  2394.  j = i + 2
  2395.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 24
  2396.  Font(j, 4) = 24: Font(j, 5) = 31
  2397.  j = i + 3
  2398.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 24
  2399.  Font(j, 4) = 24: Font(j, 5) = 255
  2400.  j = i + 4
  2401.  Font(j, 5) = 255: Font(j, 6) = 24: Font(j, 7) = 24
  2402.  j = i + 5
  2403.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 24
  2404.  Font(j, 4) = 24: Font(j, 5) = 31: Font(j, 6) = 24: Font(j, 7) = 24
  2405.  j = i + 6
  2406.  Font(j, 5) = 255
  2407.  j = i + 7
  2408.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 24
  2409.  Font(j, 4) = 24: Font(j, 5) = 255: Font(j, 6) = 24: Font(j, 7) = 24
  2410.  j = i + 8
  2411.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 31
  2412.  Font(j, 4) = 24: Font(j, 5) = 31: Font(j, 6) = 24: Font(j, 7) = 24
  2413.  j = i + 9
  2414.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 54
  2415.  Font(j, 4) = 54: Font(j, 5) = 55: Font(j, 6) = 54: Font(j, 7) = 54
  2416.  
  2417.  i = 200: j = i
  2418.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 55
  2419.  Font(j, 4) = 48: Font(j, 5) = 63
  2420.  j = i + 1
  2421.  Font(j, 3) = 63
  2422.  Font(j, 4) = 48: Font(j, 5) = 55: Font(j, 6) = 54: Font(j, 7) = 54
  2423.  j = i + 2
  2424.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 247
  2425.  Font(j, 5) = 255
  2426.  j = i + 3
  2427.  Font(j, 3) = 255: Font(j, 5) = 247: Font(j, 6) = 54: Font(j, 7) = 54
  2428.  j = i + 4
  2429.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 55
  2430.  Font(j, 4) = 48: Font(j, 5) = 55: Font(j, 6) = 54: Font(j, 7) = 54
  2431.  j = i + 5
  2432.  Font(j, 3) = 255: Font(j, 5) = 255
  2433.  j = i + 6
  2434.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 247
  2435.  Font(j, 5) = 247: Font(j, 6) = 54: Font(j, 7) = 54
  2436.  j = i + 7
  2437.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 255
  2438.  Font(j, 5) = 255
  2439.  j = i + 8
  2440.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 54
  2441.  Font(j, 4) = 54: Font(j, 5) = 255
  2442.  j = i + 9
  2443.  Font(j, 3) = 255: Font(j, 5) = 255: Font(j, 6) = 24: Font(j, 7) = 24
  2444.  
  2445.  i = 210: j = i
  2446.  Font(j, 5) = 255: Font(j, 6) = 54: Font(j, 7) = 54
  2447.  j = i + 1
  2448.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 54
  2449.  Font(j, 4) = 54: Font(j, 5) = 63
  2450.  j = i + 2
  2451.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 31
  2452.  Font(j, 4) = 24: Font(j, 5) = 31
  2453.  j = i + 3
  2454.  Font(j, 3) = 31
  2455.  Font(j, 4) = 24: Font(j, 5) = 31: Font(j, 6) = 24: Font(j, 7) = 24
  2456.  j = i + 4
  2457.  Font(j, 5) = 63: Font(j, 6) = 54: Font(j, 7) = 54
  2458.  j = i + 5
  2459.  Font(j, 0) = 54: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 54
  2460.  Font(j, 4) = 54: Font(j, 5) = 255: Font(j, 6) = 54: Font(j, 7) = 54
  2461.  j = i + 6
  2462.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 255
  2463.  Font(j, 4) = 24: Font(j, 5) = 255: Font(j, 6) = 24: Font(j, 7) = 24
  2464.  j = i + 7
  2465.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 24: Font(j, 3) = 24
  2466.  Font(j, 4) = 24: Font(j, 5) = 248
  2467.  j = i + 8
  2468.  Font(j, 5) = 31: Font(j, 6) = 24: Font(j, 7) = 24
  2469.  j = i + 9
  2470.  Font(j, 0) = 255: Font(j, 1) = 255: Font(j, 2) = 255: Font(j, 3) = 255
  2471.  Font(j, 4) = 255: Font(j, 5) = 255: Font(j, 6) = 255: Font(j, 7) = 255
  2472.  
  2473.  i = 220: j = i
  2474.  Font(j, 4) = 255: Font(j, 5) = 255: Font(j, 6) = 255: Font(j, 7) = 255
  2475.  j = i + 1
  2476.  Font(j, 0) = 240: Font(j, 1) = 240: Font(j, 2) = 240: Font(j, 3) = 240
  2477.  Font(j, 4) = 240: Font(j, 5) = 240: Font(j, 6) = 240: Font(j, 7) = 240
  2478.  j = i + 2
  2479.  Font(j, 0) = 15: Font(j, 1) = 15: Font(j, 2) = 15: Font(j, 3) = 15
  2480.  Font(j, 4) = 15: Font(j, 5) = 15: Font(j, 6) = 15: Font(j, 7) = 15
  2481.  j = i + 3
  2482.  Font(j, 0) = 255: Font(j, 1) = 255: Font(j, 2) = 255: Font(j, 3) = 255
  2483.  j = i + 4
  2484.  Font(j, 2) = 118: Font(j, 3) = 220
  2485.  Font(j, 4) = 216: Font(j, 5) = 220: Font(j, 6) = 118
  2486.  j = i + 5
  2487.  Font(j, 1) = 60: Font(j, 2) = 102: Font(j, 3) = 124
  2488.  Font(j, 4) = 102: Font(j, 5) = 124: Font(j, 6) = 96: Font(j, 7) = 96
  2489.  j = i + 6
  2490.  Font(j, 1) = 126: Font(j, 2) = 102: Font(j, 3) = 96
  2491.  Font(j, 4) = 96: Font(j, 5) = 96: Font(j, 6) = 96
  2492.  j = i + 7
  2493.  Font(j, 1) = 254: Font(j, 2) = 108: Font(j, 3) = 108
  2494.  Font(j, 4) = 108: Font(j, 5) = 236
  2495.  j = i + 8
  2496.  Font(j, 0) = 126: Font(j, 1) = 102: Font(j, 2) = 48: Font(j, 3) = 24
  2497.  Font(j, 4) = 48: Font(j, 5) = 102: Font(j, 6) = 126
  2498.  j = i + 9
  2499.  Font(j, 1) = 126: Font(j, 2) = 216: Font(j, 3) = 216
  2500.  Font(j, 4) = 216: Font(j, 5) = 112
  2501.  
  2502.  i = 230: j = i
  2503.  Font(j, 1) = 108: Font(j, 2) = 108: Font(j, 3) = 108
  2504.  Font(j, 4) = 118: Font(j, 5) = 96: Font(j, 6) = 192
  2505.  j = i + 1
  2506.  Font(j, 1) = 118: Font(j, 2) = 220: Font(j, 3) = 216
  2507.  Font(j, 4) = 24: Font(j, 5) = 24: Font(j, 6) = 24
  2508.  j = i + 2
  2509.  Font(j, 0) = 126: Font(j, 1) = 24: Font(j, 2) = 60: Font(j, 3) = 102
  2510.  Font(j, 4) = 102: Font(j, 5) = 60: Font(j, 6) = 24: Font(j, 7) = 126
  2511.  j = i + 3
  2512.  Font(j, 0) = 56: Font(j, 1) = 124: Font(j, 2) = 198: Font(j, 3) = 254
  2513.  Font(j, 4) = 198: Font(j, 5) = 124: Font(j, 6) = 56
  2514.  j = i + 4
  2515.  Font(j, 0) = 56: Font(j, 1) = 108: Font(j, 2) = 198: Font(j, 3) = 198
  2516.  Font(j, 4) = 198: Font(j, 5) = 108: Font(j, 6) = 238
  2517.  j = i + 5
  2518.  Font(j, 0) = 56: Font(j, 1) = 96: Font(j, 2) = 48: Font(j, 3) = 120
  2519.  Font(j, 4) = 204: Font(j, 5) = 204: Font(j, 6) = 120
  2520.  j = i + 6
  2521.  Font(j, 2) = 126: Font(j, 3) = 216: Font(j, 4) = 216: Font(j, 5) = 126
  2522.  j = i + 7
  2523.  Font(j, 0) = 6: Font(j, 1) = 12: Font(j, 2) = 126: Font(j, 3) = 219
  2524.  Font(j, 4) = 219: Font(j, 5) = 126: Font(j, 6) = 48: Font(j, 7) = 96
  2525.  j = i + 8
  2526.  Font(j, 0) = 28: Font(j, 1) = 48: Font(j, 2) = 96: Font(j, 3) = 120
  2527.  Font(j, 4) = 96: Font(j, 5) = 48: Font(j, 6) = 28
  2528.  j = i + 9
  2529.  Font(j, 0) = 60: Font(j, 1) = 102: Font(j, 2) = 102: Font(j, 3) = 102
  2530.  Font(j, 4) = 102: Font(j, 5) = 102: Font(j, 6) = 102
  2531.  
  2532.  i = 240: j = i
  2533.  Font(j, 1) = 126: Font(j, 3) = 126: Font(j, 5) = 126
  2534.  j = i + 1
  2535.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 2) = 126: Font(j, 3) = 24
  2536.  Font(j, 4) = 24: Font(j, 6) = 126
  2537.  j = i + 2
  2538.  Font(j, 0) = 48: Font(j, 1) = 24: Font(j, 2) = 12: Font(j, 3) = 24
  2539.  Font(j, 4) = 48: Font(j, 6) = 126
  2540.  j = i + 3
  2541.  Font(j, 0) = 12: Font(j, 1) = 24: Font(j, 2) = 48: Font(j, 3) = 24
  2542.  Font(j, 4) = 12: Font(j, 6) = 126
  2543.  j = i + 4
  2544.  Font(j, 0) = 56: Font(j, 1) = 108: Font(j, 2) = 108: Font(j, 3) = 96
  2545.  Font(j, 4) = 96: Font(j, 5) = 96: Font(j, 6) = 96: Font(j, 7) = 96
  2546.  j = i + 5
  2547.  Font(j, 0) = 12: Font(j, 1) = 12: Font(j, 2) = 12: Font(j, 3) = 12
  2548.  Font(j, 4) = 12: Font(j, 5) = 108: Font(j, 6) = 108: Font(j, 7) = 56
  2549.  j = i + 6
  2550.  Font(j, 0) = 24: Font(j, 1) = 24: Font(j, 3) = 126
  2551.  Font(j, 5) = 24: Font(j, 6) = 24
  2552.  j = i + 7
  2553.  Font(j, 1) = 118: Font(j, 2) = 220: Font(j, 4) = 118: Font(j, 5) = 220
  2554.  j = i + 8
  2555.  Font(j, 0) = 28: Font(j, 1) = 54: Font(j, 2) = 54: Font(j, 3) = 28
  2556.  j = i + 9
  2557.  Font(j, 3) = 56: Font(j, 4) = 56
  2558.  
  2559.  i = 250: j = i
  2560.  Font(j, 4) = 48
  2561.  j = i + 1
  2562.  Font(j, 0) = 15: Font(j, 1) = 12: Font(j, 2) = 12: Font(j, 3) = 12
  2563.  Font(j, 4) = 204: Font(j, 5) = 108: Font(j, 6) = 60: Font(j, 7) = 28
  2564.  j = i + 2
  2565.  Font(j, 0) = 216: Font(j, 1) = 108: Font(j, 2) = 108: Font(j, 3) = 108
  2566.  Font(j, 4) = 108
  2567.  j = i + 3
  2568.  Font(j, 0) = 56: Font(j, 1) = 12: Font(j, 2) = 24: Font(j, 3) = 48
  2569.  Font(j, 4) = 60
  2570.  j = i + 4
  2571.  Font(j, 2) = 124: Font(j, 3) = 124: Font(j, 4) = 124: Font(j, 5) = 124
  2572.  
  2573.  a$ = CHR$(&H55): B$ = CHR$(&HAA): C$ = CHR$(&HFF): d$ = CHR$(0)
  2574. ' Blue
  2575.  Shades(1, 0) = a$ + d$ + d$ + a$ + B$ + d$ + d$ + B$
  2576.  Shades(1, 1) = a$ + d$ + d$ + C$ + B$ + d$ + d$ + C$
  2577.  Shades(1, 2) = C$ + d$ + d$ + C$ + C$ + d$ + d$ + C$
  2578.  Shades(1, 3) = C$ + B$ + d$ + a$ + C$ + a$ + d$ + B$
  2579.  Shades(1, 4) = C$ + a$ + d$ + C$ + C$ + B$ + d$ + C$
  2580. ' Green
  2581.  Shades(2, 0) = d$ + a$ + d$ + d$ + d$ + B$ + d$ + d$
  2582.  Shades(2, 1) = d$ + B$ + d$ + a$ + d$ + a$ + d$ + B$
  2583.  Shades(2, 2) = d$ + a$ + d$ + C$ + d$ + B$ + d$ + C$
  2584.  Shades(2, 3) = B$ + C$ + B$ + a$ + a$ + C$ + a$ + B$
  2585.  Shades(2, 4) = a$ + C$ + a$ + C$ + B$ + C$ + B$ + C$
  2586. ' Cyan
  2587.  Shades(3, 0) = a$ + a$ + d$ + d$ + B$ + B$ + d$ + d$
  2588.  Shades(3, 1) = B$ + B$ + d$ + a$ + a$ + a$ + d$ + B$
  2589.  Shades(3, 2) = a$ + a$ + d$ + C$ + B$ + B$ + d$ + C$
  2590.  Shades(3, 3) = C$ + C$ + B$ + a$ + C$ + C$ + a$ + B$
  2591.  Shades(3, 4) = C$ + C$ + a$ + C$ + C$ + C$ + B$ + C$
  2592. ' Red
  2593.  Shades(4, 0) = d$ + d$ + a$ + d$ + d$ + d$ + B$ + d$
  2594.  Shades(4, 1) = d$ + d$ + C$ + d$ + d$ + d$ + C$ + d$
  2595.  Shades(4, 2) = d$ + d$ + C$ + a$ + d$ + d$ + C$ + B$
  2596.  Shades(4, 3) = d$ + d$ + C$ + C$ + d$ + d$ + C$ + C$
  2597.  Shades(4, 4) = a$ + a$ + C$ + C$ + B$ + B$ + C$ + C$
  2598. ' Magenta
  2599.  Shades(5, 0) = a$ + d$ + a$ + a$ + B$ + d$ + B$ + B$
  2600.  Shades(5, 1) = a$ + d$ + a$ + C$ + B$ + d$ + B$ + C$
  2601.  Shades(5, 2) = a$ + d$ + C$ + a$ + B$ + d$ + C$ + B$
  2602.  Shades(5, 3) = C$ + d$ + C$ + C$ + C$ + d$ + C$ + C$
  2603.  Shades(5, 4) = C$ + a$ + C$ + C$ + C$ + B$ + C$ + C$
  2604. ' Yellow
  2605.  Shades(6, 0) = d$ + B$ + a$ + d$ + d$ + a$ + B$ + d$
  2606.  Shades(6, 1) = d$ + a$ + a$ + a$ + d$ + B$ + B$ + B$
  2607.  Shades(6, 2) = d$ + B$ + a$ + C$ + d$ + a$ + B$ + C$
  2608.  Shades(6, 3) = B$ + C$ + C$ + a$ + a$ + C$ + C$ + B$
  2609.  Shades(6, 4) = a$ + C$ + C$ + C$ + B$ + C$ + C$ + C$
  2610. ' White
  2611.  Shades(7, 0) = d$ + d$ + d$ + C$ + d$ + d$ + d$ + C$
  2612.  Shades(7, 1) = B$ + B$ + B$ + a$ + a$ + a$ + a$ + B$
  2613.  Shades(7, 2) = a$ + a$ + a$ + C$ + B$ + B$ + B$ + C$
  2614.  Shades(7, 3) = C$ + C$ + C$ + a$ + C$ + C$ + C$ + B$
  2615.  Shades(7, 4) = C$ + C$ + C$ + C$ + C$ + C$ + C$ + C$
  2616.  
  2617. END IF
  2618.  
  2619.   ScrnMode = Mode
  2620.   SELECT CASE Mode
  2621.   CASE 9
  2622.     SCREEN 9
  2623.     IF HiRows THEN
  2624.       Rows = 43
  2625.     ELSE
  2626.       Rows = 25
  2627.     END IF
  2628.     Xmax = 639
  2629.     Ymax = 349
  2630.   CASE 12
  2631.     SCREEN 12
  2632.     IF HiRows THEN
  2633.       Rows = 60
  2634.     ELSE
  2635.       Rows = 30
  2636.     END IF
  2637.     Xmax = 639
  2638.     Ymax = 479
  2639.   CASE 13
  2640.     SCREEN 13
  2641.     Rows = 25
  2642.     Cols = 40
  2643.     Xmax = 319
  2644.     Ymax = 199
  2645.   CASE ELSE
  2646.     RETURN
  2647.   END SELECT
  2648.  
  2649.   IF Mode <> 13 THEN
  2650.     IF HiCols THEN
  2651.       Cols = 80
  2652.     ELSE
  2653.       Cols = 40
  2654.     END IF
  2655.   END IF
  2656.   WIDTH Cols, Rows
  2657.   CLS
  2658.   IF Mode = 9 THEN COLOR Fg, 0
  2659.  
  2660.   LINE (0, 0)-(Xmax, Ymax), Bg, BF
  2661.   LOCATE 1, 1, 0
  2662.   PSET (0, 0), Bg
  2663.   XYratio! = .75 * (Xmax + 1) / (Ymax + 1)
  2664.  
  2665. END SUB
  2666.  
  2667. '<p>
  2668. '++++++++++++++++++++++++
  2669. SUB zsSubstitute (XCoord, YCoord, Wide, Deep, colour1, colour2)
  2670.  
  2671.   IF Deep < 2 THEN
  2672.     a = Wide / XYratio!
  2673.   ELSE
  2674.     a = Deep
  2675.   END IF
  2676.   FOR B = XCoord TO XCoord + Wide - 1
  2677.     FOR C = YCoord TO YCoord + a - 1
  2678.       IF POINT(B, C) = colour1 THEN
  2679.     PSET (B, C), colour2
  2680.       END IF
  2681.     NEXT
  2682.   NEXT
  2683.  
  2684. END SUB
  2685.  
  2686.