--- title: "Labyrinth" id: 58413 type: "computer_media" slug: "labyrinth" url: "http://localhost/computer_media/labyrinth/" markdown_url: "http://localhost/computer_media/labyrinth.md" published_at: "2024-11-17T12:46:35+00:00" modified_at: "2026-04-03T07:58:03+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/11/LABRINTH.jpeg" excerpt: "Navigate a procedurally generated 3D maze with machine code rendering — then replay your entire route on a 2D map when you escape." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Labrinth%20%281982%29%28Mindware%29%28TS1000%29%28US%29%28Program%29.zip" mediadate: "1982" producer_company: - id: 11120 title: "Mindware, Inc." type: "company" url: "http://localhost/company/mindware/" images: - url: "http://localhost/wp-content/uploads/2024/11/LABRINTH.jpeg" - url: "http://localhost/wp-content/uploads/2024/11/LABRINTH_3x3.jpeg" - url: "http://localhost/wp-content/uploads/2024/11/LABRINTH_Inst.jpeg" - url: "http://localhost/wp-content/uploads/2024/11/Tape-10.jpg" related_products: - id: 13073 title: "Labyrinth" type: "product" url: "http://localhost/product/labyrinth/" media_type_tags: "Game" --- # Labyrinth Labyrinth is a first-person 3D maze exploration game that procedurally generates a rectangular maze of user-specified dimensions (3–15 wide, 3–9 tall) and renders perspective views as the player navigates. The maze generation algorithm uses a spanning-tree approach stored in a BASIC array, tracking connectivity and wall states across cells with directional passage flags packed into integer values. Machine code routines stored in REM statements (lines 1–50) handle the 3D perspective rendering, called via USR at addresses such as 16525, 16761, 17004, 17228, 17416, 17604, 17680, and 17697. Player movement is controlled with single-key commands (F=forward, L=left, R=right, B=back, H=help, G=give up), and the full route is recorded as a string of coordinate pairs in R$ for post-game replay. After completing the maze, the program reports move count, help requests, and optionally animates the player’s path on a 2D map display. *** ## Program Analysis ### Program Structure The program divides into several functional regions: 1. **Lines 1–50:** Machine code payloads embedded in REM statements, loaded at fixed addresses in the ZX81 display file / system area. 2. **Lines 54–55:** Entry point — clears screen and jumps to initialization at line 2000. 3. **Lines 59–93:** Subroutines handling wall collision detection, movement blocking, and “solid wall / no man’s land” messages. 4. **Lines 100–330:** Main game loop — renders the 3D view via USR calls, polls single-key input, dispatches to turn/move/help routines. 5. **Lines 2000–3890:** Setup and maze generation: collects dimensions, runs the spanning-tree generator, builds wall-flag arrays, then enters the game loop. 6. **Lines 4000–4300:** 2D map display subroutine. 7. **Lines 5000–5390:** End-game sequence: congratulations, move count, help count, route replay, play-again prompt. 8. **Lines 6000–6320:** Small utility subroutines (prompts, pause loops, “please wait” messages). 9. **Line 9000–9020:** CLEAR and SAVE block. ### Machine Code Routines in REM Lines Lines 1–50 contain raw Z80 machine code stored as REM data. The BASIC calls them with `LET Q=USR addr` at several addresses: | USR Address | Role (inferred) | | --- | --- | | 16525 | Render leftmost column of 3D view | | 16761 | Render second column | | 17004 | Render third column | | 17228 | Render fourth column | | 17416 | Render fifth (rightmost) column | | 17604 | Wall/cell state probe (used in subroutines 59–93) | | 17680 | Screen initialization / clear render area | | 17697 | Main render entry point (called at top of game loop) | The result of each USR call is discarded into `Q`, which is used purely as a sink; the routines communicate with BASIC via POKEs to system RAM rather than return values. ### Maze Generation Algorithm The generator (lines 2150–3210) implements a randomized spanning-tree / iterative cell-carving approach. A one-dimensional array `A()` of size `H*V*2+1` is used: the first half stores cell visit order (sequence numbers), and the second half stores passage-direction flags packed as integers (bits representing N/S/E/W openings, values 1, 2, 3). The algorithm scans cells in row-major order (`R`, `S` for column and row). At each unvisited cell it checks which of the four neighbors are already visited and randomly selects a direction to carve. A flag variable `Z` records whether the bottom exit row has been placed, and `Q` is reused as a one-bit “pending south passage” flag. The exit is placed in the bottom row at a random column (line 3210–3220) unless `Z` was already set during generation. ### Wall-Flag Encoding After generation, lines 3640–3870 post-process the array to compute per-cell wall bitmasks. For each cell `L`, the value `A(L)` is modified by: - A north-wall contribution derived from the cell directly to the south (`A(L-H)`), shifted and masked modulo 2. - A west-wall contribution derived from the cell to the right (`A(L-1)`), shifted and masked. - A multiplier of 8 for the north component and 1 for the west component. This yields a compact integer encoding that the machine code renderer interprets to decide which wall segments to draw for each cell face. ### Key BASIC Idioms Several idiomatic techniques appear throughout: - **Computed GOTO:** Line 102 uses arithmetic on INKEY$ comparisons to jump to the correct handler: `GOTO 102+3*(INKEY$="G")+8*(INKEY$="L")+18*(INKEY$="R")+48*(INKEY$="F")+28*(INKEY$="B")+33*(INKEY$="H")`. When no key matches, all terms are zero and the line jumps to itself, spinning until a valid key is pressed. - **Boolean arithmetic as flags:**`T=1` and `G=2` are initialized once and used everywhere as named constants, avoiding magic numbers and allowing expressions like `B+T*(PEEK Z=T)-T*(PEEK Z=3)`. - **USR result sink:**`LET Q=USR addr` is used to call machine code subroutines; the variable `Q` also doubles as a maze-generation flag, relying on context to distinguish uses. - **Route recording:**`R$` accumulates the player’s path as a string of CHR$ encoded X/Y byte pairs (`LET R$=R$+CHR$ X+CHR$ Y`), allowing later playback by decoding with CODE. - **Move counter via string length:** The move count is reported as `LEN R$/G-T` (i.e., `LEN R$/2-1`), since R$ grows by 2 bytes per step and starts with one initial position entry. - **VAL “number” in GOTO:** Line 5390 uses `GOTO T` where `T=1`, branching back to line 1 as a soft reset. ### 2D Map Display Subroutine 4000 draws the maze plan using inverse-video block characters. It iterates rows top-to-bottom (south to north, since Y increases upward), printing wall segments based on the passage flags in array `A(AA+...)` (the second half of the array, indexed from `AA=H*V+1`). The entrance column is printed with a gap in the bottom wall. The player’s current position is overlaid with `"*"` using AT positioning. The help counter `JJ` is incremented each time the map is shown mid-game (line 4250), but not when shown as part of the congratulations sequence (guarded by `Q$(1)="Y"`). ### Notable Techniques and Anomalies - The title banner at lines 2003–2007 is rendered using block graphic escape sequences to spell out “LABYRINTH” in a large pixel-font style using `▖`, `▗`, `▐`, `▘`, `▌`, `▚`, `▝`, and `▀` characters. - Lines 3295 checks the input code against 62 (Y) and 51 (N) — these are ZX81 character codes for “Y” and “N” respectively, providing a stricter validation than a simple string comparison. - The variable `Q` is overloaded: it serves as the USR return-value sink, as a maze-generation “pending south” flag (0/1), and as a holder for INPUT strings (`Q$` is a separate string variable). This dual use of `Q` and `Q$` for unrelated purposes is a potential source of confusion but does not cause bugs given the control flow. - Line 5185 contains `LET Q=LN EXP T` (evaluating to 1) as a deliberate delay within the route replay animation loop, burning CPU cycles to slow the asterisk trail. - The FAST/SLOW switching is used carefully: maze generation runs in FAST mode for speed, display and input in SLOW mode for readable output. - Line 9010 saves the program as `"LABYRINT%H"` — the `%H` produces an inverse-video “H”, which acts as the auto-run flag on the tape header. ## Source Code ``` 1 REM ' '. ' 2 REM 2184403E2BEC8218240AFBECABE402AC40232336861122019368611942193661120019366C3E040 3 REM E£RND7)5 ;.'''Q..7( CLS )%) ';.'''Q''7( CLS /.' 4 REM 218340AFBECAD412AC4023111E01936611200193661194219368611220193686C33041 5 REM E£RND7)Y ;.'''Q..7( CLS )%) ';.'''Q''7( CLS /:'% 6 REM E£RND)Z ;.'<).' ;Q :). ;Q: ( PAUSE /:'% 7 REM 218440AFBEC82AC4023112401961A36832310FB117A21961A3632310FBC98080 12 REM 218240AFBECAAC412AC4023114501936861122019368619368611CE119366112001936619366C3CF41 13 REM E£RND7) . ;.'''Q..7( CLS )ACS ' ;.'''Q''7( CLS /:'% 14 REM 218340AFBECA2422AC4023115E01936611200193661936611CE119368611220193686193686C32542 15 REM E£RND7)%2 ;.'''Q..7( CLS )ACS ' ;.'''Q''7( CLS /:'% 16 REM E£RND)%3 ;.'$)£ ;Q :)+ ;Q: ( PAUSE /:'% 17 REM 5':RND%J%YCOS E£RND7)!! ;.'=Q..7( CLS )%U' ;.'=Q''7( CLS TAN 22 REM 218240AFBECA99422AC402311AB019368611220193686114A1193661120019366C3B842 23 REM 2AC402311CC019368323368311491193632336318780 24 REM 218340AFBECAE5422AC402311BE0193661120019366114A119368611220193686C3443 25 REM 2AC402311DE019368323368311491193632336318780 26 REM E£RND7) THEN ;.',,)( ;Q :)) ;Q: ( PAUSE /:'% 27 REM 5':RND%J%YCOS E£RND7)EXP ;.'(Q..7( CLS )U' ;.'(Q''7( CLS TAN 32 REM 218240AFBECA6D432AC402311EF0193686118119366C38643 33 REM E£RND7) LOAD ;Q..)##' ;Q''/:'% 34 REM 218340AFBECAA7432AC402311FE0193661181193686C3C043 35 REM E£RND7) RETURN ;Q..)##' ;Q''/:'% 36 REM E£RND7) RETURN ;.':')> ;Q :)? ;Q: ( PAUSE /:'% 37 REM 5':RND%J%YCOS E£RND7) LIST ;.':Q..7( CLS ) IF ;.':Q''7( CLS TAN 42 REM 218240AFBECA29442AC40231111119368611C6019366C34244 43 REM E£RND7))' ;Q..)LEN ;Q''/:'% 44 REM 218340AFBECA63442AC4023111E11936611C60193686C37C44 45 REM E£RND7)2' ;Q..)LEN ;Q''/:'% 46 REM E£RND7)2' ;.': )= ;Q :)$ ;Q: ( PAUSE /:'% 47 REM 5':RND%J%YCOS E£RND7)>' ;.'£Q..7( CLS )%U ;.'£Q''7( CLS TAN 49 REM 218640462B528144E79CB39CB191CB7CB7CB74ECB39817710EC4E79CB39CB19111824012134E79CB3FCB3FCB39CB39CB39CB19112134E79CB3FCB39CB39CB19112C9 50 REM E£RND:/.'47Q ( CLS 7$4 PRINT TAN E£RND):''';Q*TAN 0 REM "ZX81 LABYRINTH" 0 REM AXIS SOFTWARE 54 CLS 55 GOTO 2000 59 IF B=O THEN GOTO 72 60 IF B<=V THEN GOTO 63 61 POKE E,G 62 RETURN 63 POKE 16517,A(A+(B-T)*H) 64 LET Q=USR 17604 65 RETURN 72 POKE 16514,O 73 POKE 16515,O 74 POKE 16516,T 75 IF A=W THEN POKE E,O 76 IF PEEK Z<>T AND A=W THEN POKE E,G 78 RETURN 85 IF PEEK E>O THEN GOTO 90 86 LET B=B+T*(PEEK Z=T)-T*(PEEK Z=3) 87 LET A=A+T*(PEEK Z=G)-T*(PEEK Z=4) 88 RETURN 90 PRINT AT 10,10; 91 IF PEEK E=T THEN PRINT "SOLID WALL" 92 IF PEEK E=G THEN PRINT "NO MANS LAND" 93 RETURN 100 IF Y>V THEN GOTO 5000 101 LET Q=USR 17697 102 GOTO 102+3*(INKEY$="G")+8*(INKEY$="L")+18*(INKEY$="R")+48*(INKEY$="F")+28*(INKEY$="B")+33*(INKEY$="H") 105 CLS 107 GOTO 5110 110 POKE Z,PEEK Z-T 111 IF PEEK Z=O THEN POKE Z,4 112 GOTO 185 120 POKE Z,PEEK Z+T 121 IF PEEK Z=5 THEN POKE Z,T 122 GOTO 185 130 POKE Z,PEEK Z+G 131 IF PEEK Z>4 THEN POKE Z,PEEK Z-4 132 GOTO 185 135 PRINT AT 11,11;"HELP COMING" 136 GOSUB 6100 140 GOSUB 4000 141 PRINT "YOU ARE FACING "; 142 IF PEEK Z=T THEN PRINT "NORTH" 143 IF PEEK Z=G THEN PRINT "EAST" 144 IF PEEK Z=3 THEN PRINT "SOUTH" 145 IF PEEK Z=4 THEN PRINT "WEST" 146 PRINT AT (V*G+G)-Y*G,X*G-T;"*" 147 FOR P=T TO 200 148 NEXT P 149 GOTO 185 150 LET A=X 155 LET B=Y 160 GOSUB 59 165 GOSUB 85 170 LET X=A 175 LET Y=B 180 IF PEEK E>O THEN GOTO 100 182 LET R$=R$+CHR$ X+CHR$ Y 185 LET A=X 190 LET B=Y 192 LET Q=USR 17680 195 GOSUB 59 200 LET Q=USR 16525 205 IF PEEK E<>O THEN GOTO 100 210 GOSUB 85 215 GOSUB 59 220 IF PEEK E=G THEN GOTO 100 225 LET Q=USR 16761 230 IF PEEK E<>O THEN GOTO 100 235 GOSUB 85 240 GOSUB 59 245 IF PEEK E=G THEN GOTO 100 250 LET Q=USR 17004 255 IF PEEK E<>O THEN GOTO 100 260 GOSUB 85 265 GOSUB 59 270 IF PEEK E=G THEN GOTO 100 275 LET Q=USR 17228 280 IF PEEK E<>O THEN GOTO 100 285 GOSUB 85 290 GOSUB 59 295 IF PEEK E=G THEN GOTO 100 300 LET Q=USR 17416 305 IF PEEK E<>O THEN GOTO 100 310 GOSUB 85 315 GOSUB 59 320 IF PEEK E=G THEN GOTO 100 325 PRINT AT 11,14;"""?""" 330 GOTO 100 2000 LET Q=USR 17680 2001 PRINT TAB 11;"Z X 8 1";TAB 38;"(C) AXIS SOFTWARE" 2002 PRINT 2003 PRINT "% .% . % % :. % % % % :. % % % % % % % % " 2004 PRINT "% % % % % % % % % % % : % % % % " 2005 PRINT "% % % % % % : '% ' % % : % % '.% % % % % " 2006 PRINT "% % % % % % % % % % :% % % % " 2007 PRINT "% % % % % % :' % % % % % % % % % " 2008 PRINT 2009 PRINT " DIMENSIONS OF THE MAZE" 2010 PRINT 2011 PRINT "ENTER WIDTH ( BETWEEN 3 AND 15 )" 2012 GOSUB 6000 2013 LET O=0 2014 LET T=1 2015 INPUT H$ 2016 RAND 2017 LET G=2 2018 GOTO 2015+10*(H$>"2" AND H$<"A" AND LEN H$=T)+5*(LEN H$=G) 2020 IF H$(T)<>"1" OR H$(G)>"5" OR H$(G)<"0" THEN GOTO 2015 2025 LET H=VAL H$ 2030 PRINT 2035 PRINT "ENTER HEIGHT ( BETWEEN 3 AND 9 )" 2036 GOSUB 6000 2040 INPUT V$ 2045 IF V$<"3" OR V$>"9" OR LEN V$<>T THEN GOTO 2040 2050 LET V=VAL V$ 2060 PRINT 2070 PRINT " PLEASE WAIT WHILE I GO AND MAKETHE MAZE" 2080 GOSUB 6100 2090 FAST 2100 LET A=H*V+T 2102 LET AA=A 2105 LET C=G 2107 LET A$="................................................................" 2110 DIM A(A*C) 2111 LET E=16516 2112 LET JJ=O 2115 LET Q=O 2116 LET Z=Q 2120 LET X=INT (RND*H)+T 2121 LET XX=X 2122 LET Y=O 2125 LET A(A)=X 2130 LET A(X)=T 2135 LET R$=CHR$ X+CHR$ Y 2140 LET R=X 2145 LET S=T 2150 GOTO 2220 2160 IF RO THEN GOTO 2610 2240 IF S-T=O THEN GOTO 2420 2250 IF A(R+(S-G)*H)<>O THEN GOTO 2420 2260 IF R=H THEN GOTO 2320 2270 IF A(R+T+(S-T)*H)<>O THEN GOTO 2320 2280 LET X=INT (RND*3)+T 2290 IF X=T THEN GOTO 2960 2300 IF X=G THEN GOTO 3000 2310 GOTO 3040 2320 IF S<>V THEN GOTO 2350 2330 IF Z=T THEN GOTO 2400 2340 LET Q=T 2345 GOTO 2360 2350 IF A(R+S*H)<>O THEN GOTO 2400 2360 LET X=INT (RND*3)+T 2370 IF X=T THEN GOTO 2960 2380 IF X=G THEN GOTO 3000 2390 GOTO 3110 2400 LET X=INT (RND*G)+T 2410 GOTO 2370 2420 IF R=H THEN GOTO 2540 2430 IF A(R+T+(S-T)*H)<>O THEN GOTO 2540 2440 IF S<>V THEN GOTO 2470 2450 IF Z=T THEN GOTO 2520 2460 LET Q=T 2465 GOTO 2480 2470 IF A(R+S*H)<>O THEN GOTO 2520 2480 LET X=INT (RND*3)+T 2490 IF X=T THEN GOTO 2960 2500 IF X=G THEN GOTO 3040 2510 GOTO 3110 2520 LET X=INT (RND*G)+T 2530 GOTO 2490 2540 IF S<>V THEN GOTO 2570 2550 IF Z=T THEN GOTO 2960 2560 LET Q=T 2565 GOTO 2580 2570 IF A(R+S*H)<>O THEN GOTO 2960 2580 LET X=INT (RND*G)+T 2590 IF X=T THEN GOTO 2960 2600 GOTO 3110 2610 IF S-T=O THEN GOTO 2820 2620 IF A(R+(S-G)*H)<>O THEN GOTO 2820 2630 IF R=H THEN GOTO 2750 2640 IF A(R+T+(S-T)*H)<>O THEN GOTO 2750 2650 IF S<>V THEN GOTO 2680 2660 IF Z=T THEN GOTO 2730 2670 LET Q=T 2675 GOTO 2690 2680 IF A(R+S*H)<>O THEN GOTO 2730 2690 LET X=INT (RND*3)+T 2700 IF X=T THEN GOTO 3000 2710 IF X=G THEN GOTO 3040 2720 GOTO 3110 2730 LET X=INT (RND*G)+T 2740 GOTO 2700 2750 IF S<>V THEN GOTO 2780 2760 IF Z=T THEN GOTO 3000 2770 LET Q=T 2775 GOTO 2790 2780 IF A(R+S*H)<>O THEN GOTO 3000 2790 LET X=INT (RND*G)+T 2800 IF X=T THEN GOTO 3000 2810 GOTO 3110 2820 IF R=H THEN GOTO 2910 2830 IF A(R+T+(S-T)*H)<>O THEN GOTO 2910 2840 IF S<>V THEN GOTO 2870 2850 IF Z=T THEN GOTO 3040 2860 LET Q=T 2865 GOTO 2880 2870 IF A(R+S*H)<>O THEN GOTO 3040 2880 LET X=INT (RND*G)+T 2890 IF X=T THEN GOTO 3040 2900 GOTO 3110 2910 IF S<>V THEN GOTO 2940 2920 IF Z=T THEN GOTO 2160 2930 LET Q=T 2935 GOTO 2950 2940 IF A(R+S*H)<>O THEN GOTO 2160 2950 GOTO 3110 2960 LET A(R-T+(S-T)*H)=C 2970 LET C=C+T 2972 LET A(A+R-T+(S-T)*H)=G 2974 LET R=R-T 2980 IF C=A THEN GOTO 3210 2990 LET Q=O 2995 GOTO 2220 3000 LET A(R+(S-G)*H)=C 3010 LET C=C+T 3020 LET A(A+R+(S-G)*H)=T 3022 LET S=S-T 3024 IF C=A THEN GOTO 3210 3030 LET Q=O 3035 GOTO 2220 3040 LET A(R+T+(S-T)*H)=C 3050 LET C=C+T 3055 IF A(A+R+(S-T)*H)=O THEN GOTO 3070 3060 LET A(A+R+(S-T)*H)=3 3065 GOTO 3080 3070 LET A(A+R+(S-T)*H)=G 3080 LET R=R+T 3090 IF C=A THEN GOTO 3210 3100 GOTO 2610 3110 IF Q=T THEN GOTO 3170 3120 LET A(R+S*H)=C 3122 LET C=C+T 3124 IF A(A+R+(S-T)*H)=O THEN GOTO 3140 3130 LET A(A+R+(S-T)*H)=3 3135 GOTO 3150 3140 LET A(A+R+(S-T)*H)=T 3145 IF R<>H AND RND>.6 THEN LET A(A+R+(S-T)*H)=3 3150 LET S=S+T 3155 IF C=A THEN GOTO 3210 3160 GOTO 2220 3170 LET Z=T 3180 IF A(A+R+(S-T)*H)=O THEN GOTO 3200 3190 LET A(A+R+(S-T)*H)=3 3192 LET Q=O 3194 GOTO 2160 3200 LET A(A+R+(S-T)*H)=T 3202 LET Q=O 3204 LET R=T 3206 GOTO 2210 3210 IF Z<>T THEN LET X=A+INT ((RND*(H-T))+T)+(V-T)*H 3220 IF Z<>T THEN LET A(X)=A(X)+T 3230 CLS 3235 SLOW 3240 PRINT 3245 PRINT "TO MOVE THROUGH THE MAZE TOUCH THE KEYS LISTED BELOW" 3247 PRINT 3250 PRINT " ""F"" - ONE STEP FORWARD" 3252 PRINT " ""L"" - LOOK LEFT" 3254 PRINT " ""R"" - LOOK RIGHT" 3256 PRINT " ""B"" - LOOK BACK" 3258 PRINT " ""H"" - FOR HELP" 3260 PRINT " ""G"" - GIVE UP" 3270 PRINT 3280 PRINT "WOULD YOU LIKE TO SEE THE MAZE PLAN BEFORE YOU START?" 3282 PRINT 3285 PRINT "(Y/N)" 3290 INPUT Q$ 3295 IF (CODE Q$<>62)+(CODE Q$<>51)<>T THEN GOTO 3290 3300 IF Q$(T)<>"Y" THEN GOTO 3610 3305 GOSUB 6300 3310 GOSUB 4000 3315 LET JJ=O 3320 PRINT AT V*G+G,XX*G-T;"*" 3330 PRINT AT 21,O;"STUDY CAREFULLY" 3340 GOTO 3640 3610 GOSUB 6200 3620 FAST 3640 FOR I=T TO A-T 3650 LET J=I+A 3660 LET A(I)=(3-A(J))*G 3670 NEXT I 3710 LET W=INT A(A) 3720 FOR J=T TO V 3730 LET K=(J-T)*H 3740 FOR I=T TO H 3750 LET L=I+K 3760 IF J<>T THEN GOTO 3790 3770 IF I=W THEN GOTO 3820 3780 LET M=T 3785 GOTO 3810 3790 LET M=INT (A(L-H)/G) 3800 LET M=M-INT (M/G)*G 3810 LET A(L)=A(L)+M*8 3820 IF I=T THEN LET M=T 3825 IF I=T THEN GOTO 3850 3830 LET M=INT (A(L-T)/4) 3840 LET M=M-INT (M/G)*G 3850 LET A(L)=A(L)+M 3860 NEXT I 3865 IF J=T THEN GOSUB 6200 3870 NEXT J 3875 CLS 3880 LET X=W 3882 LET Y=O 3884 LET Z=16518 3886 POKE Z,T 3888 SLOW 3890 GOTO 185 4000 CLS 4001 FAST 4003 PRINT 4005 FOR J=V TO T STEP -T 4010 FOR I=T TO H 4020 IF A(AA+I+(J-T)*H)=O OR A(AA+I+(J-T)*H)=G THEN GOTO 4050 4030 PRINT "% "; 4040 GOTO 4060 4050 PRINT "% % "; 4060 NEXT I 4070 PRINT "% " 4080 PRINT "% "; 4090 FOR I=T TO H 4100 IF A(AA+I+(J-T)*H)T THEN PRINT JJ;" TIMES" 5070 IF JJ=T THEN PRINT "ONCE" 5075 PRINT 5100 PRINT A$ 5110 PRINT 5120 PRINT "DO YOU WANT TO SEE YOUR ROUTE?" 5125 PRINT 5127 PRINT "(Y/N)" 5130 INPUT P$ 5132 IF P$="" THEN GOTO 5130 5135 IF P$(T)="N" THEN GOTO 5240 5138 IF P$(T)="Y" THEN GOTO 5140 5139 GOTO 5130 5140 GOSUB 6300 5150 GOSUB 4000 5160 FOR J=T TO LEN R$ STEP G 5170 LET X=CODE R$(J)*G 5175 LET Y=CODE R$(J+T)*G 5180 PRINT AT V*G+G-Y,X-T;"*" 5185 LET Q=LN EXP T 5190 IF J"N" THEN GOTO 5310 5340 PRINT 5350 PRINT "OK, THANKS FOR PLAYING. BYE" 5380 IF INKEY$="" THEN GOTO 5380 5390 GOTO T 6000 PRINT " AND PRESS NEWLINE" 6010 PRINT 6020 RETURN 6100 FOR K=T TO 20 6110 NEXT K 6120 RETURN 6200 CLS 6230 PRINT 6240 PRINT "PLEASE WAIT WHILE I BUILD UP THEENTRANCE TO THE MAZE" 6250 GOSUB 6100 6255 FAST 6270 RETURN 6300 CLS 6305 PRINT 6310 PRINT "OK, HOLD ON" 6315 GOSUB 6100 6320 RETURN 9000 CLEAR 9010 SAVE "LABYRINT%H" 9020 RUN ```