--- title: "Leprechaun’s Gold" id: 72398 type: "computer_media" slug: "leprechauns-gold" url: "http://localhost/computer_media/leprechauns-gold/" markdown_url: "http://localhost/computer_media/leprechauns-gold.md" published_at: "2026-10-23T07:47:09+00:00" modified_at: "2026-10-23T07:47:09+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/10/leprechaun-1.png" excerpt: "Find your way through a first-person 3D maze to a leprechaun's pot of gold while the Green Goblin waits to send dawdlers back to the start." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Clyde Bish" slug: "clyde-bish" taxonomy: "indiv" url: "http://localhost/indiv/clyde-bish/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_type: "Program" programmers: - name: "Clyde Bish" slug: "clyde-bish" taxonomy: "indiv" url: "http://localhost/indiv/clyde-bish/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Leprechaun%27s%20Gold%20%281983%29%28Bish%2C%20Clyde%29%28TS2068%29%28US%29%28Program%29.zip" tsrun_member: "Leprechaun's Gold (1983)(Bish, Clyde)(TS2068)(US)(Program)/Leprechaun's Gold (1983)(Bish, Clyde)(TS2068)(US)(Program).tap" mediadate: "1983" images: - url: "http://localhost/wp-content/uploads/2026/10/leprechaun-1.png" - url: "http://localhost/wp-content/uploads/2026/10/leprechaun-3.png" - url: "http://localhost/wp-content/uploads/2026/10/leprechaun-5.png" related_content: - id: 10285 title: "ZX Computing" type: "periodical" url: "http://localhost/periodical/zx-computing/" media_type_tags: "Game" license: false --- # Leprechaun’s Gold A first-person maze game. Each section of the maze is drawn in perspective with `PLOT` and `DRAW`: straight corridors, openings to the left or right, junctions, and dead ends that send you back to the start. Press `5` to turn left, `7` to go forward and `8` to turn right. A small walking figure shows each move, and turning too early walks you into the wall. You have only a moment to choose at each prompt; wait too long and the Green Goblin appears and sends you back to the start. The difficulty level from 1 to 10 sets how long the maze is. At the centre the gold is shown with “CURSES! You’ve found the GOLD”. REMs give the title as “Leprachaun’s Gold”, the source as *ZX Computing*, June/July 1983, and the author as Clyde Bish. The title screen spells it Leprechaun’s Gold. ## Program Analysis ### Structure - Lines 190–280: the main loop over the maze string. Each section’s code picks a drawing routine with `GO SUB VAL x$(i)*100+1000`. - Lines 1001–1710: one routine per kind of section, each drawing the view and asking for a move. Line 1700 is the dead end. - Lines 2000–5000: walking and turning animations, the timed key prompt (3000) and the goblin. - Lines 6000–6015: title, constants and difficulty. Line 8000 builds the maze string `x$` from random section codes. - Lines 9910–9950: the UDGs. ### UDGs stored in a REM The walking figure, the goblin and the gold are UDGs whose bytes are typed into the REM in line 9950. Line 9940 points the UDG system variable at that REM by reading `NXTLIN` (23637) while line 9940 runs, so no POKE loop or DATA is needed. ## Notable Techniques - Line 6010 builds every constant from `NOT` and `SGN` arithmetic (`a=0`, `s=1`, `b=2`, `k=4`, `l=8`, `m=16` and so on), and the drawing lines use those variables instead of numbers. - The routine addresses are held in variables too (`d=2000`, `e=3000`, `f=4000`, `g=4600`, `h=4800`), so calls read `GO SUB e`. - The time limit is a `FOR` loop polling `INKEY$` (line 3000), not a `PAUSE`. ## Potential Issues - Line 6005 calls `GO SUB 9000`, which does not exist. Execution falls through to the REM at 9910 and the UDG set-up at 9940, so it works. - The goblin’s time limit is short, so you have to answer each prompt quickly. This program came from an Oliger (JLO SAFE) disk, a copy of the SNUG library disk 13/14, and was converted to load from tape. Lines 200, 205 and 260 had to be repaired. The disk copy computed the routine address as `VAL x$(i)*VAL "100+1000"`, which multiplies by 1100 (apparently from a faulty attempt to save memory with `VAL`), and the game stopped at once with “4 Out of memory”. They now use `*100+1000`. It was tested in ZEsarUX, walking and turning through the maze. ## Source Code ``` 5 REM >> LEPRACHAUN'S GOLD << * ZX COMPUTING, June/July 1983 9 REM by Clyde Bish 10 190 LET y$=" " 200 FOR i=s TO y: GO SUB VAL x$(i)*100+1000: IF n>b*v THEN GO TO 200 205 LET i=i+s: GO SUB VAL x$(i)*100+1000: IF x$(i)="7" OR n>b*v THEN GO TO 200 210 IF y$(i)=" " AND x$(i+b)="7" THEN LET y$(i)=b$: LET r=RND: LET x$(i+b)=("8" AND r<.3)+("7" AND r>=.3): GO TO 280 220 IF y$(i)=" " AND x$(i+b)<>"7" THEN LET y$(i)=b$: GO TO 280 230 IF y$(i)<>" " AND x$(i+b)="8" AND y$(i)=b$ THEN LET i=i+b: GO TO 280 260 IF y$(i)<>" " AND y$(i)<>b$ AND x$(i+b)<>"7" THEN GO SUB INT (RND*INT PI)*100+1000: GO SUB 1700: GO TO 200 270 IF y$(i)<>" " AND y$(i)<>b$ AND x$(i+b)="7" THEN LET y$(i)=b$: LET i=i+b: LET x$(i)="8" 280 NEXT i: GO TO 7000 1001 CLS : PLOT 47,m+m: DRAW 128,a: PLOT 47,103: DRAW 128,a: PLOT x,a: DRAW m+m,m: DRAW a,119: DRAW -u,u: PLOT 240,a: DRAW -o,m+m: DRAW a,71: DRAW q,q 1010 LET p=w-s: GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1015 IF b$<>"7" THEN LET p=w: GO SUB d: GO TO 1000 1020 LET c=s: LET p=m+b: GO SUB h 1051 CLS : PLOT m,m+m: DRAW 159,a: PLOT m,103: DRAW 159,a: PLOT x,a: DRAW a,167: DRAW -l,l: PLOT 240,a: DRAW -o,m+m: DRAW a,71: DRAW q,q 1060 LET p=m+b: GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1065 IF b$<>"5" THEN LET p=w-s: GO SUB d: GO TO 1050 1070 GO SUB g: PAUSE j: RETURN 1101 CLS : PLOT v-s,m+m: DRAW 128,a: PLOT v-s,103: DRAW 128,a: PLOT x,a: DRAW o,m+m: DRAW a,q-s: DRAW -q,q: PLOT 240,a: DRAW -32,m: DRAW a,119: DRAW u,u 1110 LET p=w-s: GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1115 IF b$<>"7" THEN LET p=w: GO SUB d: GO TO 1100 1120 LET c=s: LET p=m+b: GO SUB h 1151 CLS : PLOT v,m+m: DRAW 159,a: PLOT v,103: DRAW 159,a: PLOT x,a: DRAW o,32: DRAW a,q-s: DRAW -q,q: PLOT 240,a: DRAW a,167: DRAW l,l 1160 GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1165 IF b$<>"8" THEN LET p=w-s: GO SUB d: GO TO 1150 1170 GO SUB g: PAUSE j: CLS : RETURN 1201 CLS : PLOT 15,0: DRAW 64,32: FOR n=2 TO 8 STEP 2: PLOT 2*n+80,n+32: NEXT n: PLOT 239,0: DRAW -64,32: FOR n=2 TO 8 STEP 2: PLOT -2*n+175,n+32: NEXT n: PLOT 8,175: DRAW 72,-72: FOR n=4 TO 16 STEP 4: PLOT 80+n,103-n: NEXT n: PLOT 248,175: DRAW -72,-72: FOR n=4 TO 16 STEP 4: PLOT 175-n,103-n: NEXT n 1205 PRINT AT l+k,l+k;"CONTINUE";AT x-s,l+k;"FORWARDS" 1210 LET p=w-s: GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1215 IF b$<>"7" THEN GO SUB d: GO TO 1201 1230 LET p=m+b: LET c=a: GO SUB h: RETURN 1301 CLS : PLOT 240,0: DRAW -32,16: DRAW 0,119: DRAW 40,40: PLOT 207,32: DRAW -32,0: DRAW 0,71: DRAW 32,0: PLOT 175,32: DRAW -16,8: FOR n=2 TO 8 STEP 2: PLOT -2*n+159,n+39: NEXT n: PLOT 175,103: DRAW -16,-16: FOR n=4 TO 16 STEP 4: PLOT 159-n,87-n: NEXT n: IF x$(i)="6" THEN GO TO 1402 1310 PLOT 15,0: DRAW 80,40: FOR n=2 TO 8 STEP 2: PLOT 2*n+96,n+40: NEXT n: PLOT 8,175: DRAW 88,-88: FOR n=4 TO 16 STEP 4: PLOT n+96,87-n: NEXT n 1320 LET p=w-s: GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1325 IF b$<>"7" THEN LET p=w: GO SUB d: GO TO 1300 1330 LET c=s: LET p=m+b: GO SUB h 1350 CLS : PLOT 240,0: DRAW 0,167: DRAW 8,8: PLOT 239,32: DRAW -64,0: DRAW 0,71: DRAW 64,0: PLOT 175,32: DRAW -16,8: FOR n=2 TO 6 STEP 2: PLOT -2*n+159,n+40: NEXT n: PLOT 175,103: DRAW -16,-16: FOR n=4 TO 16 STEP 4: PLOT 159-n,87-n: NEXT n: IF x$(i)="6" THEN GO TO 1451 1360 PLOT 15,0: DRAW 80,40: FOR n=2 TO 8 STEP 2: PLOT 2*n+96,n+40: NEXT n: PLOT 8,175: DRAW 88,-88: FOR n=4 TO 16 STEP 4: PLOT 96+n,87-n: NEXT n 1370 LET p=w-b: GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1372 IF b$<>"8" AND b$<>"7" THEN GO SUB d: GO TO 1350 1375 IF b$<>"7" THEN GO SUB g: PAUSE j 1378 IF b$<>"8" THEN LET p=m+s: LET c=a: GO SUB h 1380 RETURN 1401 CLS 1402 PLOT 15,0: DRAW 32,16: DRAW 0,119: DRAW -40,40: PLOT 48,32: DRAW 32,0: DRAW 0,71: DRAW -32,0: PLOT 80,32: DRAW 16,6: FOR n=2 TO 8 STEP 2: PLOT 2*n+96,n+40: NEXT n: PLOT 80,103: DRAW 16,-16: FOR n=4 TO 16 STEP 4: PLOT n+96,87-n: NEXT n: IF x$(i)="6" THEN GO TO 1610 1410 PLOT 240,0: DRAW -80,40: FOR n=2 TO 8 STEP 2: PLOT -2*n+159,n+40: NEXT n: PLOT 248,175: DRAW -88,-88: FOR n=4 TO 16 STEP 4: PLOT 159-n,87-n: NEXT n 1420 LET p=w-s: GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1425 IF b$<>"7" THEN LET p=w: GO SUB d: GO TO 1400 1430 LET c=s: LET p=w-b: GO SUB h 1450 CLS 1451 PLOT 15,0: DRAW 0,167: DRAW -8,8: PLOT 16,32: DRAW 64,0: DRAW 0,71: DRAW -64,0: PLOT 80,32: DRAW 16,8: FOR n=2 TO 8 STEP 2: PLOT 2*n+96,n+40: NEXT n: PLOT 80,103: DRAW 16,-16: FOR n=4 TO 16 STEP 4: PLOT 96+n,87-n: NEXT n: IF x$(i)="6" THEN GO TO 1660 1460 PLOT 239,0: DRAW -80,40: FOR n=2 TO 8 STEP 2: PLOT -2*n+159,n+40: NEXT n: PLOT 247,175: DRAW -88,-88: FOR n=4 TO 16 STEP 4: PLOT 159-n,87-n: NEXT n 1470 GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1472 IF b$<>"5" AND b$<>"7" THEN LET p=w-s: GO SUB d: GO TO 1450 1475 IF b$<>"7" THEN GO SUB g: PAUSE j 1478 IF b$<>"5" THEN LET c=a: LET p=m+s: GO SUB h 1480 RETURN 1501 CLS : PLOT u+l,m+m: DRAW k*u,a: PLOT u+l,103: DRAW k*u,a: PLOT x,a: DRAW m+m,m: DRAW a,119: DRAW -u,u: PLOT 240,a: DRAW -32,m: DRAW a,119: DRAW u,u 1510 LET p=w-s: GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1515 IF b$<>"7" THEN LET p=w: GO SUB d: GO TO 1500 1520 LET c=s: LET p=w-b: GO SUB h 1551 CLS : PLOT m,m+m: DRAW 224,a: PLOT m,135: DRAW 224,a: PLOT x,a: DRAW a,167: DRAW -l,l: PLOT 240,a: DRAW a,167: DRAW l,l 1560 GO SUB f: GO SUB e: IF b>n*v THEN RETURN 1565 IF b$<>"8" AND b$<>"5" THEN LET p=w-s: GO SUB d: GO TO 1550 1570 GO SUB g: PAUSE j: RETURN 1601 GO TO 1300 1610 LET p=w-s: GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1615 IF b$<>"7" THEN LET p=w: GO SUB d: GO TO 1600 1620 LET c=s: LET p=w-b: GO SUB h 1650 GO TO 1350 1660 GO SUB f: GO SUB e: IF n>b*v THEN RETURN 1665 IF b$<>"7" AND b$<>"8" AND b$<>"5" THEN GO TO 1650 1670 IF b$="7" THEN LET p=m+s: GO SUB h: RETURN 1680 IF b$="8" OR b$="5" THEN GO SUB g: PAUSE j: RETURN 1701 CLS : PLOT o,w+k: DRAW 127,a: PLOT o,119: DRAW 127,a: PLOT x,a: DRAW u+l,w+k: DRAW a,v+x: DRAW -48,u+l: PLOT 240,a: DRAW -48,w+k: DRAW a,95: DRAW u+l,u+l: IF i>y THEN RETURN 1710 GO SUB f: PRINT AT l+b,l+t;"DEAD END";AT m-b,x-k;"Back to the";AT m+s,x-s;"START": PAUSE b*v: RETURN 2000 IF b$<>"7" THEN GO SUB 5000 2001 CLS : PLOT a,m+m: DRAW 255,a: PLOT a,135: DRAW 255,a: PRINT AT l+b,l+t;"PASSAGE";AT m-k,m-b;"WALL" 2005 LET p=w-b: GO SUB f 2008 IF b$="7" THEN GO TO 2020 2010 PRINT AT w,x-k;"TURN";AT w,w-b;"BACK";AT w+s,l+t;"Press ";("8" AND b$="5")+("5" AND b$="8"): PAUSE a: IF INKEY$<>"5" AND b$="8" OR INKEY$<>"8" AND b$="5" THEN CLS : GO TO 2001 2015 PRINT AT w,x-k;" ";AT w,w-b;" ";AT w+s,l+t;" ": PAUSE b*x: PRINT AT w-s,m;"d";AT w,m;("f" AND b$="8")+("e" AND b$="5"): PAUSE b*x: CLS : RETURN 2020 PRINT AT w+s,l+t;"TRY AGAIN": PAUSE b*x: CLS : RETURN 3000 PRINT AT w,b*t;"WHICH";AT w,w-b;"WAY?";AT w+s,b*t;"Press";AT w+s,w-b;"5,7 or 8": FOR n=s TO b*v: IF INKEY$<>"" THEN GO TO 3050 3010 NEXT n 3020 PRINT AT x,l+k; INK k;"o";AT m,l+k;"O";AT m+s,l+k;"b": PAUSE b*x: PRINT AT k+t,x-k;"TOO SLOW!";AT l+b,m-b;"The";AT x-k,l+b; INK k;"GREEN GOBLIN";AT m-k,m-t; INK a;"sends you";AT x-b,l+b;"BACK TO THE";AT m-b,l+k;" START ": PAUSE v+w: RETURN 3050 LET b$=INKEY$: IF b$="0" THEN STOP 3055 IF b$<>"7" AND b$<>"8" AND b$<>"5" THEN GO TO 3000 3060 PRINT AT w,l+b;" ";AT w,w-b;" ";AT w+s,l+b;" ";AT w+s,w-b;" ": PAUSE w: RETURN 4001 PRINT AT p,m;"O";AT p+s,m;"c";AT p+b,m;"b": RETURN 4600 LET p=w-s: GO SUB 5000: FOR n=(m AND b$="8")+(x AND b$="5") TO (w+l AND b$="8")+(INT PI AND b$="5") STEP (b$="8")-(b$="5"): PRINT AT w-b,n;"gh";AT w-s,n;"ij";AT w,n;("kl" AND b$="8")+("mn" AND b$="5"): PAUSE l: PRINT AT w-b,n;(" O" AND b$="8")+("O " AND b$="5");AT w-s,n;(" d" AND b$="8")+("d " AND b$="5");AT w,n;(" e" AND b$="8")+("f " AND b$="5"): PAUSE t: NEXT n: PRINT AT w-b,n;("g" AND b$="8")+("h " AND b$="5");AT w-s,n;("i" AND b$="8")+("j " AND b$="5");AT w,n;("k" AND b$="8")+("n " AND b$="5"): PAUSE l: PRINT AT w-b,n;" ";AT w-s,n;" ";AT w,n;" ": RETURN 4800 PRINT AT p,m;"o";AT p+s,m;"O";AT p+b,m;"p";AT p+INT PI,m;" ": PAUSE w: PRINT AT p-s,m;"q";AT p,m;"r";AT p+s,m;"s";AT p+b,m;" ": PAUSE w 4810 IF c=s THEN LET c=a: RETURN 4820 PRINT AT p-s,m;"t";AT p,m;" ";AT p+s,m;" ": PAUSE w: LET c=a: RETURN 5000 PRINT AT p,m;"d";AT p+s,m;("e" AND b$="8")+("f" AND b$="5"): PAUSE b*x: RETURN 6000 BORDER 4: PRINT AT 1,5; INK 4;"::::::::::::::::::::::::::::::::::::::::::";AT 2,5;":: ::";AT 3,5;"::::::::::::::::::::::::::::::::::::::::::";AT 2,6; INK 0; PAPER 6;" LEPRECHAUN'S GOLD ";AT 5,0; PAPER 7;"Can you make your way to the centre, and find the GOLD?"''TAB 5;"Press 5 to turn left";TAB 11;"7 to move forwards";TAB 11;"8 to turn right";TAB 10;"(0 to quit)"'"Don't turn too early - you'll walk into the wall!"''"BEWARE!"'"The "; INK 4;"GREEN GOBLIN"; INK 0;" will be following you. Don't take too long making a decision or he'll catch up and send you back to the start." 6005 DEF FN h(x)=INT (x/256): DEF FN l(x)=x-256*FN h(x): GO SUB 9000 6010 LET d=2000: LET e=3000: LET f=d+d: LET g=4600: LET h=4800: LET j=50: LET a=NOT d: LET s=SGN d: LET b=s+s: LET k=b+b: LET l=k+k: LET m=l+l: LET o=m*k: LET q=o+l: LET t=k+s: LET u=t*l: LET v=u+u: LET w=k*t: LET x=t*INT PI 6015 PRINT "PRESS ANY KEY TO BEGIN": PAUSE 0: CLS : INPUT "ENTER difficulty level (1 to 10)";z: PRINT "PREPARING MAZE": LET y=z*b+l: GO SUB 8000: GO TO 190 7000 GO SUB 1700: PRINT AT m,x; INK 6;"::::";AT m+s,x-b; INK k;"::::::::::::";AT m+b,x-b;"::::::::::::";AT w-s,m-t; INK a;"O";AT w,m-t;"c";AT w+s,m-t;"b";AT 16,21; INK 4;"o";AT 17,21;"O";AT 18,21;"b" 7010 PRINT AT 9,17; INK 4;"CURSES!";AT 11,18; INK 0;"You've";AT 12,19;"Found";AT 13,21;"the";AT 14,20; INK 6;"GOLD" 7020 PAUSE 100: PRINT AT 1,5;"PRESS 1 TO PLAY AGAIN": PAUSE 0: IF INKEY$="1" THEN CLS : GO TO 6015 7999 STOP 8000 LET x$=" ": FOR i=s TO y STEP b: LET x$(i)=STR$ INT (RND*INT PI+.5): LET x$(i+s)=STR$ INT (RND*k+INT PI+.5): IF i"7" AND RND<.4 THEN LET x$(i+s)="7" 8010 NEXT i: RETURN 9910 REM UDG's 9940 LET x=VAL "(PEEK 23637+PEEK 23638*256)+6": POKE 23675,FN l(x): POKE 23676,FN h(x): RETURN 9950 REM