The Sorcerer’s Castle

Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Game

A text adventure set in an 8×8×8 castle of randomly stocked rooms, where the goal is to find the great crown of Murtceps the sorcerer and leave by the entrance. You choose to be a dwarf, elf, fighter, hobbit or wizard, male or female, share out bonus points among strength, intelligence and dexterity, and spend 60 gold pieces at the armoury on armour, a weapon, a lamp and flares. Single-letter commands move you through the castle and let you fire flares, shine the lamp into the next room, draw a map of the level, open chests and books, drink from pools, gaze into crystal orbs and teleport. Monsters from kobolds to dragons can be fought, bribed with treasure or met with a web, fireball or death spell, and a vendor buys treasure and sells equipment and potions. The crown only appears once you hold the magic ring, which lies in one monster’s room.

Building the castle takes several minutes of BASIC while a hand sweeps round a clock face, and the game is ready when it reaches 12 o’clock. Pressing x during play saves the game to tape. No author is named on screen or in the listing. Murtceps is “Spectrum” spelled backwards, and the listing uses only Spectrum BASIC, which suggests a ZX Spectrum origin.

Program Analysis

Structure

  • Lines 100–540: subroutines for placing rooms, showing your status, waiting for a key, armour damage, looking with the lamp and sound effects.
  • Lines 1000–1180: the introduction, the arrays and the random castle set-up.
  • Lines 1500–1960: race, sex, bonus points and the armoury.
  • Lines 2000–2170: entering a room and dealing with gold, flares, warps, sinkholes and treasure.
  • Lines 2180–2630: the vendor. Lines 2640–3240: combat, spells, bribes and retreat.
  • Lines 4000–4320: the end of each turn, with curses, random events (a sneeze, a frog, a bat) and the command prompt.
  • Lines 5000–5650: death or leaving the castle, with an inventory and the number of turns.
  • Lines 6000–7870: the commands. Lines 7900–7910 set the colours and UDGs, and line 8000 restarts a saved game.
  • Lines 9000–9140: DATA for the 34 room contents, the weapons and armour, the five races and the map UDGs.

The Castle

The castle is a string array c$(8,8,8) with one character per room. Character codes 1–34 index the room descriptions in d$(): the entrance, stairs, pools, chests, gold, flares, warps, sinkholes, orbs and books, twelve monsters, the vendor and eight treasures. A room you have not seen holds its code plus 100, and FN v$() takes the 100 off when you enter, look into or light up the room, so the map shows only what you have found. Each level gets two staircases down, matching stairs up on the level below, and three sinkholes. The crown is hidden in a warp room, and the ring in a monster’s room.

Three empty rooms are cursed. While a curse is active it costs extra turns and lets monsters strike first, drains gold, or hides rooms again. The ruby red, pale pearl and green gem treasures ward off these curses, the opal eye cures blindness and the blue flame frees you from a sticky book. Since e(i,4) is worked out again in every empty room you enter, a curse lifts when you reach another empty room.

Notable Techniques

  • The set-up clock: each room placed adds 0.0187 radians to a hand drawn and erased with DRAW OVER 1. The 336 placements make one full turn, so the hand reaches 12 o’clock as set-up ends.
  • Strings sliced with Boolean expressions handle plurals and optional words, as in " flares"( TO 6+(fl<>1)) in line 320.
  • x$() stores the start and end of each name, so d$(mt,VAL x$(mt,1) TO VAL x$(mt,2 TO )) turns “a kobold” into “kobold”.
  • PEEK 23689 (S POSN) finds the current print line, so error messages can be printed over the prompt.
  • UDGs a–l are line-drawing pieces for the map grid. The map marks your room in inverse and unexplored rooms with a dot.
  • FN l() caps strength, intelligence and dexterity at 18.
  • The x command runs SAVE "castle" LINE 8000, which saves the program with all its variables. On loading, line 8000 restores the colours and UDGs and puts you back in the room.

Potential Issues

  • The bear’s name-slice entry in line 9040 is "30v" instead of a number. VAL "0v" is not a valid number, so the program appears to stop with an error when a bear is named in combat at line 3110.
  • Line 6830 reads IF x<>8 AND y THEN 1 THEN PLOT ..., probably a damaged y<>1. Firing a flare anywhere but the east wall appears to stop the program with an error.
  • Line 7010 has a { (ON ERR) where a semicolon belongs, so the “You can’t see without a lamp!” message appears to end in an error.
  • The help screen lists o twice and does not mention x.
  • Typos on screen include “dissapeared”, “dexexterity” and “achievment”.

This program came from an Oliger (JLO SAFE) disk and was converted to load from tape. The disk-specific SAVE / in line 9998 became a plain SAVE, and the program autostarts at line 1, which begins a fresh game. It was tested in ZEsarUX, where setting up the castle took several minutes before the race menu appeared.

Related Content

Image Gallery

Source Code

    1 GO TO 1000
  100 LET t$=CHR$ i
  110 LET x=FN r(8): LET y=FN r(8): IF c$(x,y,z)<>"e" THEN GO TO 110
  120 LET c$(x,y,z)=t$: PLOT 127,79: DRAW OVER 1;SIN t*78,COS t*78: LET t=t+.0187: PLOT 127,79: DRAW OVER 1;SIN t*78,COS t*78: RETURN 
  150 PRINT "You have:-","Strength    ";st,"Intelligence ";iq,"Dexterity   ";dx,,,: RETURN 
  200 IF INKEY$<>"" THEN GO TO 200
  210 LET r$=INKEY$: IF r$="" THEN GO TO 210
  220 BEEP .05,30: RETURN 
  240 PRINT AT 12,0;
  250 PRINT "You have ";gp;" gold pieces": RETURN 
  300 IF bl=0 THEN PRINT "You are in room ";y;"-";x;", on level ";z,,,
  310 GO SUB 150
  320 PRINT "You are wearing ";w$(av+5),"and carry a lamp, "( TO 10+8*(lf<>0));w$(wv+1)( TO VAL z$(wv+1,2)),fl;" flares"( TO 6+(fl<>1));" + ";gp;" gold pieces"( TO 11+(gp<>1))
  330 LET t=0: FOR i=1 TO 8: IF t(i)=0 THEN GO TO 360
  340 IF t=0 THEN LET t=1: PRINT "You have ";
  350 PRINT d$(i+25)
  360 NEXT i
  370 RETURN 
  390 DRAW 0,-17: DRAW 17,0: DRAW 0,17: DRAW -16,0: DRAW 0,-16: DRAW 15,0: DRAW 0,15: DRAW -14,0: RETURN 
  400 PRINT AT 12,0;: GO SUB 250: PRINT ,,"You are wearing ";w$(av+5),"and carry ";w$(wv+1)( TO VAL z$(wv+1,2));" and a lamp"( TO 1+10*(lf<>0)),: PRINT "Your strength is ";st;", dexterity",dx;" and intelligence ";iq,,,: RETURN 
  440 FOR i=1 TO 20: BEEP .05,0: BEEP .05,4: NEXT i: RETURN 
  450 GO SUB 440: CLS : RETURN 
  460 IF av=0 THEN GO TO 490
  470 LET t=t-av: LET ah=ah-av: IF t<0 THEN LET ah=ah-t: LET t=0
  480 IF ah<0 THEN LET ah=0: LET av=0: PRINT PAPER 6;"Your armour has been destroyed": PRINT 
  490 LET st=st-t: RETURN 
  500 LET c$(x,y,z)=FN v$(): PRINT "Your lamp shines into room ";y;"-";x: PRINT "There you see ";d$(CODE c$(x,y,z)): RETURN 
  520 FOR i=-15 TO 30: BEEP .05,i: NEXT i: RETURN 
  540 FOR i=30 TO -15 STEP -1: BEEP .05,i: NEXT i: RETURN 
 1000 GO SUB 7900: CLS : PRINT AT 0,6; PAPER 2;"The Sorcerers castle": PRINT 
 1005 PRINT PAPER 6;"MURTCEPS"; PAPER 1;" the sorcerer has a hugecastle. Your task is to enter itand find Murtceps' great crown. Your friends won't think much ofyou  if  you  leave  the  castlewithout it."
 1010 PRINT : PRINT "I  recognise  your single lettercommands  such as  n, s, e, w, uand d for  north,  south,  east,west, up and down."
 1015 PRINT : PRINT "You should be able  to  work outthe other ones by  yourself;  ifyou get stuck then you can enterh for help.",,,,"Please wait while the castle  isbeing set up; it will  be  readywhen the clock says 12-o-clock."
 1020 RANDOMIZE 
 1025 DIM c$(8,8,8): DIM d$(34,17): DIM e$(5,7): DIM i$(34): DIM p$(5,7): DIM w$(8,9): DIM x$(34,3): DIM y$(5,8): DIM z$(8,2)
 1030 DIM c(3): DIM e(3,4): DIM r(3): DIM t(8)
 1040 DEF FN r(t)=1+INT (RND*t): DEF FN v$()=CHR$ (CODE (c$(x,y,z))-100*(c$(x,y,z)>"c")): DEF FN l(t)=t*(t<19)+18*(t>18)
 1050 FOR i=1 TO 34: READ d$(i),x$(i),i$(i): NEXT i
 1060 FOR i=1 TO 4: READ w$(i),z$(i),w$(i+4),z$(i+4): NEXT i
 1070 FOR i=1 TO 5: READ p$(i),y$(i),e$(i): NEXT i
 1090 FOR i=1 TO 8: FOR j=1 TO 8: LET c$(i,j)="eeeeeeee": NEXT j: NEXT i
 1100 LET c$(4,1,1)=CHR$ 2
 1105 LET t=0: PLOT 127,79: DRAW OVER 1;0,78
 1110 FOR z=1 TO 7: LET t$="h": FOR i=1 TO 2: GO SUB 110: LET c$(x,y,z+1)="g": NEXT i: FOR i=1 TO 3: LET t$="n": GO SUB 110: NEXT i: NEXT z
 1120 FOR z=1 TO 8: FOR j=1 TO 3: FOR i=105 TO 109: GO SUB 100: NEXT i: FOR i=111 TO 112: GO SUB 100: NEXT i: LET t$="}": GO SUB 110: NEXT j: FOR i=113 TO 124: GO SUB 100: NEXT i: NEXT z
 1130 FOR i=126 TO 133: LET z=FN r(8): GO SUB 100: NEXT i
 1140 LET t$="e": FOR i=1 TO 3: LET z=FN r(8): GO SUB 110: LET e(i,1)=x: LET e(i,2)=y: LET e(i,3)=z: NEXT i
 1150 LET i=112+FN r(12): LET z=FN r(8): GO SUB 100: LET r(1)=x: LET r(2)=y: LET r(3)=z
 1160 LET t$="m": LET z=FN r(8): GO SUB 110: LET c(1)=x: LET c(2)=y: LET c(3)=z
 1170 GO SUB 7910
 1180 LET r$="": LET bl=0: LET bo=0: LET tc=0: LET mc=0: LET m=0: LET h=0: LET vf=0: LET lf=0: LET gp=60: LET fl=0: LET wc=0: LET rf=0: LET cf=0: LET pt=0
 1500 BEEP .5,0: CLS : PRINT "Greetings, bold adventurer,  youmay choose to be:-",,,"   a dwarf",,"   an elf",,"   a fighter",,"   a hobbit",,"or a wizard",,,, INVERSE 1;"Select d,e,f,h or w"
 1510 GO SUB 200
 1520 FOR i=1 TO 5: IF r$=p$(i,1) THEN LET pt=i: LET st=VAL y$(i,2 TO 3): LET iq=VAL y$(i,4 TO 5): LET dx=VAL y$(i,6 TO 7): LET op=VAL y$(i,8)
 1530 NEXT i: IF pt=0 THEN PRINT AT 9,0; PAPER 2;"I said d,e,f,h or w. Try again": BEEP .5,0: GO TO 1510
 1540 CLS : PRINT "Are you male or female?",,, INVERSE 1;"Enter m or f"
 1550 GO SUB 200
 1560 IF r$<>"m" AND r$<>"f" THEN PRINT AT 2,0; PAPER 2;"m or f, stupid": BEEP .5,0: GO TO 1550
 1570 LET sx=0: IF r$="m" THEN LET sx=1
 1580 CLS 
 1590 PRINT "Well now, ";p$(pt): GO SUB 150: PRINT "You have ";op;" more points to","divide as you wish",,,: PRINT INVERSE 1;" Press keys s, i or d once ": PRINT INVERSE 1;" for each point            "
 1600 IF op=0 THEN GO TO 1660
 1610 GO SUB 200: IF r$<>"s" AND r$<>"i" AND r$<>"d" THEN PRINT AT 7,0; PAPER 2;"Is your intelligence really": PAPER 2: PRINT iq;". Enter s, i or d please";"  "( TO 3-LEN STR$ iq): PAPER 1: BEEP .5,0: GO TO 1610
 1620 IF r$="s" THEN LET st=st+1
 1630 IF r$="i" THEN LET iq=iq+1
 1640 IF r$="d" THEN LET dx=dx+1
 1650 LET op=op-1: PRINT AT 0,0;: GO TO 1590
 1660 CLS : PRINT "The local armoury sells:-",,,"   Armour","  Weapons",,,"Platemail 30","Swords  30","Chainmail 20","Maces   20","Leather   10","Daggers 10",,,"Lamps     20","Flares   1 each",,,"All prices are in gold pieces",,,
 1670 GO SUB 250
 1680 PRINT ,,"What armour do you want to buy?",,, INVERSE 1;"Enter p, c or l, or n for none"
 1690 GO SUB 200
 1700 LET av=3*(r$="p")+2*(r$="c")+(r$="l")
 1710 IF av=0 AND r$<>"n" THEN PRINT AT 16,0; PAPER 2;"Just p, c, l or n"; PAPER 1;"             ": BEEP .5,0: GO TO 1690
 1720 LET ah=av*7: LET gp=gp-av*10
 1730 GO SUB 240: PRINT AT 14,5;"weapon": PRINT AT 16,0; INVERSE 1;"Enter s, m or d, or n for none"
 1740 GO SUB 200
 1750 LET wv=3*(r$="s")+2*(r$="m")+(r$="d")
 1760 IF wv=0 AND r$<>"n" THEN PRINT AT 16,0; PAPER 2;"s, m, d or n, fool"; PAPER 1,: BEEP .5,0: GO TO 1740
 1770 LET gp=gp-wv*10
 1780 IF gp<20 THEN GO TO 1830
 1790 GO SUB 240: PRINT AT 14,0;"Do you want to buy a lamp?",,, INVERSE 1;"Enter y or n"; INVERSE 0,,
 1800 GO SUB 200
 1810 IF r$="y" THEN LET lf=1: LET gp=gp-20: GO TO 1830
 1820 IF r$<>"n" THEN PRINT AT 16,0; PAPER 2;"Enter y or n": BEEP .5,0: GO TO 1800
 1830 IF gp<1 THEN GO TO 1950
 1840 GO SUB 240: PRINT AT 14,0;"Do you want to buy any flares?",,, INVERSE 1;"Enter y or n"; INVERSE 0;"                   "
 1850 GO SUB 200
 1860 IF r$="n" THEN GO TO 1950
 1870 IF r$<>"y" THEN PRINT AT 16,0; PAPER 2;"Please answer y or n": BEEP .5,0: GO TO 1850
 1880 PRINT AT 14,0;"How many would you like?",,, INVERSE 1;"Please enter the number and thenpress "; INK 6;"ENTER"
 1890 INPUT r$
 1900 IF r$="" THEN LET r$="0": GO TO 1930
 1910 FOR i=1 TO LEN r$: IF r$(i)<"0" OR r$(i)>"9" THEN LET r$(i)="0"
 1920 NEXT i
 1930 IF VAL r$<1 OR VAL r$>gp THEN PRINT AT 16,0; PAPER 2;"The armourer can't waste all dayserving you, please just enter anumber from 1 to ";gp: BEEP .5,0: GO TO 1890
 1940 LET fl=VAL r$: LET gp=gp-VAL r$
 1950 LET x=4: LET y=1: LET z=1
 1960 CLS : PRINT "You are now entering the castle",,,: GO TO 2010
 2000 CLS 
 2010 GO SUB 300
 2080 LET wc=0: LET t$=FN v$(): LET c$(x,y,z)=t$
 2090 PRINT : PRINT "Here you find ";d$(CODE t$): IF CODE t$<7 OR CODE t$=11 OR CODE t$=12 THEN GO TO 4010
 2100 IF CODE t$=7 THEN LET gp=gp+FN r(10): PRINT "You now have ";gp: GO TO 4000
 2110 IF CODE t$=8 THEN LET fl=fl+FN r(5): PRINT "You now have ";fl: GO TO 4000
 2120 IF CODE t$>9 THEN GO TO 2160
 2130 IF c(1)=x AND c(2)=y AND c(3)=z AND rf=1 THEN PRINT ,, PAPER 2;"You've found it! The great": PRINT PAPER 2;"crown.  But the magic ring": PRINT PAPER 2;"has dissapeared           ": LET rf=0: LET cf=1: LET c(1)=0: GO TO 4000
 2140 GO SUB 520
 2150 LET x=FN r(8): LET y=FN r(8): LET z=FN r(8): GO TO 2000
 2160 IF CODE t$=10 THEN GO SUB 540: LET z=z+1: GO TO 2000
 2170 IF CODE t$>25 AND CODE t$<34 THEN PRINT "It's now yours": LET t(CODE t$-25)=1: LET tc=tc+1: GO TO 4000
 2180 LET mt=CODE t$: IF mt<25 OR vf=1 THEN GO TO 2640
 2190 LET rp=27-PEEK 23689: PRINT "You may trade with, attack or","ignore the vendor",,, INVERSE 1;"Type t, a or i"
 2200 GO SUB 200
 2210 IF r$="i" THEN GO TO 4010
 2220 IF r$="a" THEN PRINT AT rp,0; PAPER 6;"You'll be sorry you did that": LET vf=1: GO TO 2640
 2230 IF r$<>"t" THEN PRINT AT rp,0; PAPER 2;"Nice try, now use t, a or i": BEEP .5,0: GO TO 2200
 2240 IF tc>0 THEN CLS 
 2245 FOR i=1 TO 8: IF t(i)=0 THEN GO TO 2300
 2250 LET t=FN r(i*1500): PRINT AT 0,0;"Will you sell ";d$(i+25),"for ";t;" gold pieces",,, INVERSE 1;"Answer y or n"
 2260 GO SUB 200
 2270 IF r$="n" THEN GO TO 2300
 2280 IF r$<>"y" THEN PRINT AT 3,0; PAPER 2;"Don't mess about, y or n": BEEP .5,0: GO TO 2260
 2290 LET t(i)=0: LET tc=tc-1: LET gp=gp+t
 2300 NEXT i
 2310 IF gp<1000 THEN PRINT : PRINT "You're too poor to buy anything": GO TO 4010
 2320 CLS : PRINT "The vendor is selling:-",,,"    Armour","   Weapons","Platemail 2000","Swords  2000","Chainmail 1500","Maces   1500","Leather   1250","Daggers 1250",,,"Lamps","       1000","Strength, intelligence","or dexexterity potions 1000 each",,"All prices are in gold pieces"
 2330 GO SUB 400: PRINT "Would you like any armour?",,, INVERSE 1;"Enter p, c, l, or n for none"
 2340 GO SUB 200
 2350 IF r$="n" THEN GO TO 2410
 2360 IF r$<>"p" AND r$<>"c" AND r$<>"l" THEN PRINT AT 21,0; PAPER 2;"Enter p, c, l, or n for none"; PAPER 1,: BEEP .5,0: GO TO 2340
 2370 IF r$="p" AND gp>=2000 THEN LET av=3: LET ah=21: LET gp=gp-2000: GO TO 2410
 2380 IF r$="c" AND gp>=1500 THEN LET av=2: LET ah=14: LET gp=gp-1500: GO TO 2410
 2390 IF r$="l" AND gp>=1250 THEN LET av=1: LET ah=7: LET gp=gp-1250: GO TO 2410
 2400 PRINT AT 21,0; PAPER 2;"No credit given; p, c, l, or n": BEEP .5,0: GO TO 2340
 2410 GO SUB 400: PRINT AT 19,15;"a weapon?",,, INVERSE 1;"Enter s, m, d, or n for none"; INVERSE 0,
 2420 GO SUB 200
 2430 IF r$="n" THEN GO TO 2490
 2440 IF r$<>"s" AND r$<>"m" AND r$<>"d" THEN PRINT AT 21,0; PAPER 2;"Just s, m, d, or n please"; PAPER 1,: BEEP .5,0: GO TO 2420
 2450 IF r$="s" AND gp>=2000 THEN LET wv=3: LET gp=gp-2000: GO TO 2490
 2460 IF r$="m" AND gp>=1500 THEN LET wv=2: LET gp=gp-1500: GO TO 2490
 2470 IF r$="d" AND gp>=1250 THEN LET wv=1: LET gp=gp-1250: GO TO 2490
 2480 PRINT AT 21,0; PAPER 2;"Too pricey; enter s, m, d, or n ": BEEP .5,0: GO TO 2420
 2490 IF gp<1000 THEN GO TO 2630
 2500 GO SUB 400: PRINT "Do you want to buy a lamp?",,, INVERSE 1;"Enter y or n"; INVERSE 0,,
 2510 GO SUB 200
 2520 IF r$="n" THEN GO TO 2550
 2530 IF r$<>"y" THEN PRINT AT 21,0; PAPER 2;"Either y or n please"; PAPER 1,: BEEP .5,0: GO TO 2510
 2540 LET lf=1: LET gp=gp-1000
 2550 IF gp<1000 THEN GO TO 2630
 2560 GO SUB 400: PRINT "Fancy a potion?",,,, INVERSE 1;"Type s, i, or d, or n for no"; INVERSE 0,
 2570 GO SUB 200
 2575 IF r$="n" THEN GO TO 2630
 2580 IF r$="s" THEN LET st=FN l(st+FN r(6)): GO TO 2620
 2590 IF r$="i" THEN LET iq=FN l(iq+FN r(6)): GO TO 2620
 2600 IF r$="d" THEN LET dx=FN l(dx+FN r(6)): GO TO 2620
 2610 PRINT AT 21,0; PAPER 2;"Try s, i, d or n please"; PAPER 1,: BEEP .5,0: GO TO 2570
 2620 LET gp=gp-1000: IF gp>999 THEN GO TO 2560
 2630 CLS : GO TO 3990
 2640 GO SUB 450
 2650 LET t3=1: LET t1=INT ((mt-12)/2)+1: LET t2=mt-10
 2660 IF e(1,4)>t(1) OR bl=1 OR dx<FN r(9)+FN r(9) THEN GO TO 3100
 2670 PRINT "You're facing ";d$(mt),"Your strength is ";st: PRINT "and dexterity ";dx: PRINT : PRINT "You may attack or retreat"
 2680 IF t3=1 THEN PRINT "or bribe"
 2685 IF iq>14 THEN PRINT "or cast a spell"
 2690 PRINT : LET rp=24-PEEK 23689: PRINT INVERSE 1;"Enter a, r";: IF t3=1 THEN PRINT INVERSE 1;", b";
 2695 IF iq>14 THEN PRINT INVERSE 1;", c";
 2700 PRINT : PRINT 
 2710 GO SUB 200
 2720 IF r$<>"a" THEN GO TO 2840
 2730 CLS : IF wv=0 THEN PRINT "Hitting it with your hands won'thurt ";d$(mt): PRINT : GO TO 3100
 2740 IF bo=1 THEN PRINT "You can't beat it to death with a book!": PRINT : GO TO 3100
 2750 IF dx<FN r(20)+bl*3 THEN PRINT PAPER 6;"M i s s e d !": PRINT : GO TO 3100
 2760 PRINT "You hit the lousy ";d$(mt,VAL x$(mt,1) TO );"  ": LET t2=t2-wv
 2770 IF (mt=21 OR mt=24) AND FN r(8)=1 THEN PRINT PAPER 6;"Oh no! Your";w$(wv+1)(2 TO VAL z$(wv+1,2));" broke!": PRINT : LET wv=0
 2780 IF t2>0 THEN GO TO 3100
 2790 LET mc=mc-1: PRINT "The ";d$(mt,VAL x$(mt,1) TO VAL x$(mt,2 TO ));" is dead": IF h>m-60 THEN GO TO 2810
 2800 PRINT "You spend an hour or so","eating ";d$(mt, TO VAL x$(mt,2 TO ));" ";e$(FN r(5)): LET h=m
 2810 IF x=r(1) AND y=r(2) AND z=r(3) THEN PRINT : PRINT PAPER 6;"You've found the ring!": LET r(1)=0: LET rf=1
 2820 IF mt=25 THEN BEEP 3,0: CLS : PRINT "You get all the vendor's  wares;a sword, plate armour,  strengthpotion, dexterity potion, intel-ligence potion and a lamp": LET av=3: LET ah=21: LET wv=3: LET st=FN l(st+FN r(6)): LET iq=FN l(iq+FN r(6)): LET dx=FN l(dx+FN r(6)): LET lf=1: GO TO 2835
 2830 LET t=FN r(1000): PRINT "You take his hoard of",t;" gold pieces": LET gp=gp+t
 2835 PRINT : GO SUB 300: GO TO 4000
 2840 IF r$="r" THEN GO TO 3100
 2850 IF r$="c" THEN GO TO 2880
 2860 IF r$="b" THEN GO TO 3010
 2870 PRINT AT rp,0; PAPER 2;"Are you stupid? a, r";: IF t3=1 THEN PRINT PAPER 2;", b";
 2872 IF iq>14 THEN PRINT PAPER 2;" or c";
 2875 GO TO 2700
 2880 IF iq<15 THEN PRINT "You can't cast a spell now.": GO SUB 450: GO TO 2670
 2890 PRINT "Web, fireball or death spell?",,,
 2900 LET rp=24-PEEK 23689: PRINT INVERSE 1;"w, f or d please"
 2910 GO SUB 200
 2920 IF r$<>"w" THEN GO TO 2950
 2930 LET st=st-1: LET wc=FN r(8)+1: IF st<1 THEN GO TO 5000
 2940 CLS : GO TO 3100
 2950 IF r$<>"f" THEN GO TO 2980
 2960 LET t=FN r(7)+FN r(7): LET st=st-1: LET iq=iq-1: IF st<1 OR iq<1 THEN GO TO 5000
 2970 CLS : PRINT "It does ";t;" points damage": LET t2=t2-t: GO TO 2780
 2980 IF r$<>"d" THEN PRINT AT rp,0; PAPER 2;"Nice try, now enter w, f or d": GO TO 2910
 2990 CLS : PRINT PAPER 6;"D E A T H - ";: IF iq<15+FN r(4) THEN PRINT PAPER 6;"Yours.": LET iq=0: GO TO 5000
 3000 PRINT PAPER 6;"His.": LET t2=0: GO TO 2790
 3010 IF tc=0 THEN CLS : PRINT PAPER 6;"AllIwantisyourlife!": PRINT : GO TO 3100
 3020 LET t=FN r(8): IF t(t)=0 THEN GO TO 3020
 3030 PRINT "I want ";d$(t+25, TO VAL x$(t+25,2 TO ));","
 3040 PRINT "Will you give it to me?"
 3050 PRINT : LET rp=27-PEEK 23689: PRINT INVERSE 1;"y or n"
 3060 GO SUB 200: IF r$="n" THEN GO TO 3100
 3070 IF r$<>"y" THEN PRINT AT rp,0; PAPER 2;"y or n": GO TO 3060
 3080 LET t(t)=0: LET tc=tc-1: PRINT "O.K. But don't tell a anyone"
 3090 LET vf=1: IF mt=25 THEN LET vf=0
 3095 GO TO 4010
 3100 LET t3=2: IF wc>0 THEN LET wc=wc-1: IF wc=0 THEN PRINT "The web has just broken"
 3110 PRINT "The ";d$(mt,VAL x$(mt,1) TO VAL x$(mt,2 TO ));: IF wc>0 THEN PRINT " is stuck in the web": GO TO 3150
 3120 PRINT " attacks:": IF dx<FN r(7)+FN r(7)+FN r(7)+bl*3 THEN GO TO 3140
 3130 PRINT "he missed you!": PRINT : GO TO 3150
 3140 PRINT "OUCH!! He hit you!": PRINT : FOR i=1 TO 15: BORDER 7: PAUSE 1: BORDER 1: PAUSE 1: NEXT i: LET t=t1: GO SUB 460: IF st<1 THEN GO TO 5000
 3150 IF r$<>"r" THEN GO TO 2670
 3160 LET t=FN r(3)-2: IF t=0 THEN GO TO 3160
 3170 IF FN r(2)=1 THEN GO TO 3210
 3180 IF x=1 THEN LET x=2: GO TO 3240
 3190 IF x=8 THEN LET x=7: GO TO 3240
 3200 LET x=x+t: GO TO 3240
 3210 IF y=1 THEN LET y=2: GO TO 3240
 3220 IF y=8 THEN LET y=7: GO TO 3240
 3230 LET y=y+t
 3240 PRINT PAPER 6;"You have escaped!": GO SUB 450: GO TO 2010
 3990 PRINT : GO SUB 300: GO TO 4010
 4000 LET c$(x,y,z)=CHR$ 1
 4010 LET m=m+1
 4020 IF rf+cf>0 THEN GO TO 4070
 4030 IF e(1,4)>t(1) THEN LET m=m+1
 4040 IF e(2,4)>t(3) THEN LET gp=gp-FN r(5): IF gp<0 THEN LET gp=0
 4050 IF e(3,4)>t(5) THEN LET x1=x: LET y1=y: LET z1=z: LET x=FN r(8): LET y=FN r(8): LET z=FN r(8): LET c$(x,y,z)=CHR$ (CODE FN v$()+100): LET x=x1: LET y=y1: LET z=z1
 4060 IF c$(x,y,z)=CHR$ 1 THEN FOR i=1 TO 3: LET e(i,4)=(e(i,1)=x)*(e(i,2)=y)*(e(i,3)=z): NEXT i
 4070 LET t=FN r(30)
 4080 IF t=1 THEN PRINT "A A Ahchoo!!   You sneezed"
 4090 IF t=2 THEN PRINT "You stepped on a frog"
 4100 IF t=3 THEN PRINT "You are being watched"
 4110 IF t=4 AND bl=0 THEN PRINT "You see a bat fly by"
 4120 IF t=5 THEN LET t1=(FN r(4)-1)*10+1: PRINT "You hear ";: PRINT "a scream  footsteps thunder   scratching"(t1 TO t1+9)
 4130 IF t=6 THEN LET t1=FN r(13)+12: PRINT "You can smell ";d$(t1)
 4140 IF bl+t(4)=2 THEN PRINT "The opal eye cures","your blindness.": LET bl=0
 4150 IF bo+t(6)=2 THEN PRINT "The blue flame dissolves the","book; your hands are free.": LET bo=0
 4160 PRINT : LET rp=24-PEEK 23689: PRINT INVERSE 1;"What do you want to do?"
 4170 GO SUB 200
 4180 IF r$="n" THEN GO TO 6000
 4190 IF r$="s" THEN GO TO 6100
 4200 IF r$="e" THEN GO TO 6200
 4210 IF r$="w" THEN GO TO 6300
 4220 IF r$="u" THEN GO TO 6400
 4230 IF r$="d" THEN GO TO 6500
 4240 IF r$="m" THEN GO TO 6700
 4250 IF r$="f" THEN GO TO 6800
 4260 IF r$="l" THEN GO TO 7000
 4270 IF r$="o" THEN GO TO 7200
 4280 IF r$="g" THEN GO TO 7400
 4290 IF r$="t" THEN GO TO 7600
 4300 IF r$="h" THEN GO TO 7700
 4310 IF r$="q" THEN GO TO 7800
 4315 IF r$="x" THEN SAVE "castle" LINE 8000: STOP 
 4320 PRINT AT rp,0; PAPER 2;"Sorry, I don't understand that"; PAPER 1;"  ": GO TO 4170
 5000 GO SUB 540: CLS 
 5010 PRINT "Formerly living ";p$(pt): PRINT "You died from an acute lack"
 5020 PRINT "of ";: IF st<1 THEN PRINT "strength"
 5030 IF iq<1 THEN PRINT "intelligence"
 5040 IF dx<1 THEN PRINT "dexterity"
 5050 PRINT : PRINT "When you died you had:-": IF cf=1 THEN PRINT : PRINT "Murtceps' crown"
 5060 LET t=0: GO TO 5550
 5500 GO SUB 520: CLS 
 5510 PRINT "You left the castle with";: IF cf=0 THEN PRINT "out";
 5520 PRINT : PRINT "Murtceps' crown"
 5530 LET t=1: IF cf=0 THEN PRINT "Shame on you!": PRINT : PRINT "You did have the following:-": GO TO 5550
 5540 PRINT "An incredible achievment": PRINT : PRINT "You also had the following:-"
 5550 PRINT : IF t=1 THEN PRINT "Your wretched life"
 5560 IF rf=1 THEN PRINT "The ring"
 5570 FOR i=1 TO 8: IF t(i)=1 THEN PRINT d$(i+25)
 5580 NEXT i
 5590 PRINT w$(wv+1)
 5600 PRINT w$(av+5)
 5610 IF lf<>0 THEN PRINT "a lamp"
 5620 PRINT fl;" flares"
 5630 PRINT gp;" gold pieces"
 5640 PRINT : PRINT "It took you ";m;" turns": PRINT 
 5650 GO TO 7840
 6000 IF c$(x,y,z)=CHR$ 2 THEN GO TO 5500
 6010 IF y<>1 THEN LET y=y-1: GO TO 2000
 6020 PRINT AT rp,0; PAPER 2;"Solid walls that way; try again"; PAPER 1;" ": BEEP .5,0: GO TO 4170
 6100 IF y=8 THEN GO TO 6020
 6110 LET y=y+1: GO TO 2000
 6200 IF x=8 THEN GO TO 6020
 6210 LET x=x+1: GO TO 2000
 6300 IF x=1 THEN GO TO 6020
 6310 LET x=x-1: GO TO 2000
 6400 IF c$(x,y,z)<>CHR$ 3 THEN PRINT AT rp,0; PAPER 2;"No stairs up here; re-enter move": BEEP .5,0: GO TO 4170
 6410 IF z=1 THEN PRINT AT rp,0; PAPER 2;"You can't get on the roof"; PAPER 1;"       ": BEEP .5,0: GO TO 4170
 6420 LET z=z-1: GO TO 2000
 6500 IF c$(x,y,z)=CHR$ 5 THEN GO TO 6600
 6510 IF c$(x,y,z)<>CHR$ 4 THEN PRINT AT rp,0; PAPER 2;"No pool or stairs down here"; PAPER 1;"     ": BEEP .5,0: GO TO 4170
 6520 IF z=8 THEN PRINT AT rp,0; PAPER 2;"You are already at the bottom"; PAPER 1;"  ": BEEP .5,0: GO TO 4170
 6530 LET z=z+1: GO TO 2000
 6600 LET t=FN r(8): CLS : PRINT "You drink from the pool and": IF t<7 THEN PRINT "feel ";
 6610 IF t=1 THEN PRINT "stronger": LET st=FN l(st+FN r(3))
 6620 IF t=2 THEN PRINT "weaker": LET st=st-FN r(3): IF st<1 THEN GO TO 5000
 6630 IF t=3 THEN PRINT "smarter": LET iq=FN l(iq+FN r(3))
 6640 IF t=4 THEN PRINT "dumber": LET iq=iq-FN r(3): IF iq<1 THEN GO TO 5000
 6650 IF t=5 THEN PRINT "nimbler": LET dx=FN l(dx+FN r(3))
 6660 IF t=6 THEN PRINT "clumsier": LET dx=dx-FN r(3): IF dx<1 THEN GO TO 5000
 6670 IF t=7 THEN LET sx=1-sx: PRINT "become a ";"female "(1+sx*2 TO );p$(pt)
 6680 IF t<>8 THEN PRINT : GO TO 2010
 6690 LET t=FN r(5): IF t=pt THEN GO TO 6690
 6695 LET pt=t: PRINT "turn into a ";p$(pt): PRINT : GO TO 2010
 6700 IF bl=1 THEN GO TO 6800
 6710 LET x1=x: LET y1=y: CLS : PRINT "afjfjfjfjfjfjfjfb": FOR y=1 TO 8: PRINT "e";: FOR x=1 TO 8: LET t=CODE c$(x,y,z): IF t>34 THEN LET t=34
 6720 PRINT INVERSE (x=x1) AND (y=y1);i$(t); INVERSE 0;"e";: NEXT x: PRINT : IF y<>8 THEN PRINT "ifkfkfkfkfkfkfkfg"
 6730 NEXT y: PRINT "cfhfhfhfhfhfhfhfd": LET x=x1: LET y=y1: PRINT AT 5,20;y;"-";x;AT 7,18;"Level ";z;AT 16,0: GO TO 4160
 6800 IF bl=1 THEN PRINT AT rp,0; PAPER 6;"You're blind; try something else": GO TO 4170
 6805 IF fl<1 THEN PRINT AT rp,0; PAPER 6;"You don't have any flares, silly": BEEP .5,0: GO TO 4170
 6810 LET fl=fl-1: CLS : IF x<>1 AND y<>1 THEN PLOT 99,172: GO SUB 390
 6820 IF y<>1 THEN PLOT 115,172: GO SUB 390
 6830 IF x<>8 AND y THEN 1 THEN PLOT 131,172: GO SUB 390
 6840 IF x<>1 THEN PLOT 99,156: GO SUB 390
 6850 PLOT 115,156: GO SUB 390
 6860 IF x<>8 THEN PLOT 131,156: GO SUB 390
 6870 IF x<>1 AND y<>8 THEN PLOT 99,140: GO SUB 390
 6880 IF y<>8 THEN PLOT 115,140: GO SUB 390
 6890 IF x<>8 AND y<>8 THEN PLOT 131,140: GO SUB 390
 6900 LET rp=1: LET x1=x: LET y1=y: FOR y=y1-1 TO y1+1: PRINT AT rp,12;: FOR x=x1-1 TO x1+1: IF x<1 OR x>8 OR y<1 OR y>8 THEN PRINT OVER 1;"  ";: GO TO 6930
 6910 LET c$(x,y,z)=FN v$(): LET t=CODE c$(x,y,z)
 6920 PRINT OVER 1;" "; INVERSE (x=x1) AND (y=y1);i$(t);
 6930 NEXT x: LET rp=rp+2: NEXT y: LET x=x1: LET y=y1
 6940 PRINT : IF y<8 THEN PRINT : PRINT 
 6950 GO TO 3990
 7000 IF bl=1 THEN GO TO 6800
 7005 IF lf<>0 THEN LET lf=lf-.01: IF lf<0 THEN LET lf=0: PRINT AT rp-1,0; PAPER 6;"Your lamp has just gone out! "
 7010 IF lf=0 THEN PRINT AT rp,0; PAPER 6;"You can't see without a lamp!"{ PAPER 1;"  ": BEEP .5,0: GO TO 4170
 7020 PRINT AT rp,0;"Where will you shine the lamp?   ",, INVERSE 1;"Answer n, s, e or w";: LET rp=rp+2
 7030 GO SUB 200: IF r$<>"n" AND r$<>"s" AND r$<>"e" AND r$<>"w" THEN PRINT AT rp,0; PAPER 2;"I only understand n, s, e or w": GO TO 7030
 7040 CLS : IF r$<>"n" THEN GO TO 7080
 7050 IF y=1 AND x=4 AND z=1 THEN PRINT "Your lamp shines out of the     castle door": GO TO 3990
 7060 IF y=1 THEN PRINT "To the north is the castle wall": GO TO 3990
 7070 LET y=y-1: GO SUB 500: LET y=y+1: GO TO 3990
 7080 IF r$<>"s" THEN GO TO 7110
 7090 IF y=8 THEN PRINT "Solid walls to the south": GO TO 3990
 7100 LET y=y+1: GO SUB 500: LET y=y-1: GO TO 3990
 7110 IF r$<>"e" THEN GO TO 7140
 7120 IF x=8 THEN PRINT "Just a solid wall to the east": GO TO 3990
 7130 LET x=x+1: GO SUB 500: LET x=x-1: GO TO 3990
 7140 IF x=1 THEN PRINT "There is a solid wall west": GO TO 3990
 7150 LET x=x-1: GO SUB 500: LET x=x+1: GO TO 3990
 7200 IF c$(x,y,z)<>CHR$ 6 THEN GO TO 7260
 7210 CLS : LET c$(x,y,z)=CHR$ 1: LET t=FN r(4): PRINT "You open the chest;"
 7220 IF t=1 THEN LET m=m+20: PRINT PAPER 2;"GAS!"; PAPER 1;" You stagger from the room": PRINT : GO TO 3160
 7230 IF t<4 THEN LET t=FN r(1000): LET gp=gp+t: PRINT "You find ";t;" gold pieces": GO TO 3990
 7240 PRINT "It explodes!": LET t=FN r(6): GO SUB 460: IF st<1 THEN GO TO 5000
 7250 GO TO 3990
 7260 IF c$(x,y,z)<>CHR$ 12 THEN PRINT AT rp,0; PAPER 6;"Open what? Try again"; PAPER 1;"            ": GO TO 4170
 7270 IF bl=1 THEN GO TO 6800
 7280 CLS : LET c$(x,y,z)=CHR$ 1: LET t=FN r(5)
 7290 IF t=1 THEN PRINT FLASH 1;"FLASH!"; FLASH 0;" Oh no! You are now","a blind ";p$(pt): LET bl=1: GO TO 3990
 7300 IF t=2 THEN PRINT "It's a copy of Murtceps' poetry": GO TO 3990
 7310 IF t=3 THEN PRINT "It's a manual of dexterity!": LET dx=18: GO TO 3990
 7320 IF t=4 THEN PRINT "It's a manual of strength!": LET st=18: GO TO 3990
 7330 PRINT "The book sticks to your hands!","Now you can't draw your weapon": LET bo=1: LET c$(x,y,z)=CHR$ 1: GO TO 3990
 7400 IF c$(x,y,z)<>CHR$ 11 THEN PRINT AT rp,0; PAPER 6;"There is no orb to gaze into"; PAPER 1;"    ": GO TO 4170
 7410 IF bl=1 THEN GO TO 6800
 7420 CLS : LET t=FN r(6): PRINT "You see ";
 7430 IF t=1 THEN PRINT "yourself being","killed by ";d$(FN r(13)+12): LET st=st-FN r(2): IF st<1 THEN GO TO 5000
 7440 IF t=2 THEN PRINT "yourself drinking","from a pool and turning","into ";d$(FN r(13)+12)
 7450 IF t=3 THEN PRINT d$(FN r(13)+12): PRINT "gazing back at you"
 7460 IF t=4 THEN LET x1=x: LET y1=y: LET z1=z: LET x=FN r(8): LET y=FN r(8): LET z=FN r(8): LET t$=FN v$(): LET c$(x,y,z)=t$: PRINT d$(CODE t$): PRINT "at ";y;", ";x;", level ";z: LET x=x1: LET y=y1: LET z=z1
 7470 IF t=5 THEN PRINT "the 9-o-clock news"
 7480 IF t<>6 THEN GO TO 3990
 7490 LET x1=FN r(8): LET y1=FN r(8): LET z1=FN r(8): IF FN r(2)=1 THEN LET x1=c(1): LET y1=c(2): LET z1=c(3)
 7500 PRINT "Murtceps crown": PRINT "at ";y1;", ";x1;", level ";z1: GO TO 3990
 7600 IF rf=0 THEN PRINT AT rp,0; PAPER 6;"You need the ring to teleport"; PAPER 1;"  ": GO TO 4170
 7610 CLS : PRINT "You  need  to give me the  threedigit  number  of  the  room youwish to teleport to; first enterthe  number  of  rooms down fromthe top,  then the number acrossfrom the left.   Finally,  enterthe level you wish to go  to.  Iwill  accept only the numbers  1to 8 as input.": PRINT : PRINT INVERSE 1;"1 - 8 please": PRINT 
 7620 GO SUB 200: IF r$<"1" OR r$>"8" THEN GO TO 7620
 7630 LET y=VAL r$: PRINT r$;
 7640 GO SUB 200: IF r$<"1" OR r$>"8" THEN GO TO 7640
 7650 LET x=VAL r$: PRINT r$;
 7660 GO SUB 200: IF r$<"1" OR r$>"8" THEN GO TO 7660
 7670 LET z=VAL r$: PRINT r$: GO SUB 520: GO TO 2000
 7700 CLS : PRINT "Here are the inputs I recognize": PRINT : PRINT "n - go north": PRINT "s - go south": PRINT "e - go east": PRINT "w - go west": PRINT "u - go up stairs": PRINT "d - go down stairs"
 7710 PRINT "l - look (you need a lamp)": PRINT "f - fire a flare": PRINT "m - draw a map": PRINT "o - open a book": PRINT "o - open a chest": PRINT "d - drink from a pool"
 7720 PRINT "g - gaze into an orb": PRINT "t - teleport (you need the ring)h - ask for help": PRINT "q - quit playing"
 7730 GO TO 4160
 7800 PRINT AT rp,0; FLASH 1;"Do you really want to quit? y/n"
 7810 GO SUB 200: IF r$="y" THEN CLS : GO TO 7840
 7820 IF r$="n" THEN PRINT AT rp,0; PAPER 6;"Then don't mess about;  re-enter": GO TO 4170
 7830 PRINT AT rp,0; PAPER 2;"A simple y or n will do, thanks"; PAPER 1;" ": GO TO 4170
 7840 LET rp=26-PEEK 23689: PRINT INVERSE 1;"Do you want another game? y/n":
 7850 GO SUB 200: IF r$="y" THEN RUN 
 7860 IF r$<>"n" THEN PRINT AT rp,0; PAPER 2;"I'll stop playing! Answer y or n": BEEP .5,0: GO TO 7850
 7870 STOP 
 7900 POKE 23609,20: PAPER 1: INK 9: BORDER 1: RETURN 
 7910 FOR i=0 TO 95: READ t: POKE USR "a"+i,t: NEXT i: RETURN 
 8000 GO SUB 7900: RESTORE 9110: GO SUB 7910: GO TO 2000
 9000 DATA "an empty room","413"," ","the entrance","512","E","stairs going up","115","U","stairs going down","117","D"
 9010 DATA "a pool","306","P","a chest","307","C","gold pieces","111","G","flares","106","F"
 9020 DATA "a warp","306","W","a sinkhole","310","S","a crystal orb","313","O","a book","306","B"
 9030 DATA "a kobold","308","M","an orc","406","M","a wolf","306","M","a goblin","308","M"
 9040 DATA "an ogre","407","M","a troll","307","M","a bear","30v","M","a minotaur","310","M"
 9050 DATA "a gargoyle","310","M","a chimera","309","M","a balrog","308","M","a dragon","308","M"
 9060 DATA "a vendor","308","V","the ruby red","112","T","the norn stone","114","T","the pale pearl","114","T"
 9070 DATA "the opal eye","112","T","the green gem","113","T","the blue flame","114","T","the palantir","112","T"
 9080 DATA "the silmaril","112","T","x","101","l"
 9090 DATA "no weapon","19","no armour","19","a dagger","38","leather","17","a mace","36","chainmail","19","a sword","37","plate","15"
 9100 DATA "fighter","71404104","stew.","wizard","60614084","soup.","elf","30608126","burger.","dwarf","51208066","roast.","hobbit","60610106","pie."
 9110 DATA 0,0,0,31,31,24,24,24,0,0,0,248,248,24,24,24,24,24,24,31,31,0,0,0
 9120 DATA 24,24,24,248,248,0,0,0,24,24,24,24,24,24,24,24,0,0,0,255,255,0,0,0
 9130 DATA 24,24,24,248,248,24,24,24,24,24,24,255,255,0,0,0,24,24,24,31,31,24,24,24
 9140 DATA 0,0,0,255,255,24,24,24,24,24,24,255,255,24,24,24,0,0,0,24,24,0,0,0
 9998 SAVE /"CASTLE" LINE 1: BEEP .4,15

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.