10 MODE 7
20 PROCset`up
30 PROCtitle
40 PROClook
50 REPEAT
60 REPEAT
70 INPUT"What now",c$
80 IF LEN(c$)=0 THEN PRINT"Eh?"
90 UNTIL LEN(c$)>0
100 PRINTSTRING$(39,"-")
110 PROCanalise
120 PROCtime`passing
130 UNTIL dead OR won
140 PROCfinish
150 RUN
160
170 DEF PROCset`up
180 DIM place$(9)
190 FOR i=1 TO 9
200 READ place$(i)
210 NEXT i
220 DATA in a hut,in a garden
230 DATA in a shrubbery,on a path
240 DATA on a lane,in a forest
250 DATA at a dead end,at diamond cast
le
260 DATA in a dark passage
270 DIM newpos(9,4)
280 FOR i=1 TO 9
290 FOR j=1 TO 4
300 READ newpos(i,j)
310 NEXT j
320 NEXT i
330 DATA 0,2,0,0,0,0,5,1,0,0,6,0
340 DATA 0,5,7,0,2,6,0,4,3,0,9,5
350 DATA 4,0,0,0,0,9,0,0,6,0,0,8
360 DIM item$(6),itemname$(6),itempos(
6)
370 FOR i=1 TO 6
380 READ item$(i),itemname$(i),itempos
(i)
390 NEXT i
400 DATA a lamp,LAMP,5
410 DATA the great diamond,DIAMOND,7
420 DATA a sharp knife,KNIFE,3
430 DATA a hammer,HAMMER,1
440 DATA a mean looking gremlin,GREMLI
N,4
450 DATA a nasty little pixie,PIXIE,9
460 DIM com$(7)
470 FOR i=1 TO 7
480 READ com$(i)
490 NEXT
500 DATA GET,TAKE,ON,LIGHT,OFF,DROP,KI
LL
510 DIM direct$(4)
520 FOR i=1 TO 4
530 READ direct$(i)
540 NEXT
550 DATA North,East,South,West
560 DIM bright$(2)
570 bright$(0)="( It's off )"
580 bright$(1)="( It's shining dimly )
"
590 bright$(2)="( It's shining brightl
y )"
600 on=FALSE
610 reallit=2.9
620 lit=2
630 position=1
640 dead=FALSE
650 won=FALSE
660 moves=0
670 score=30
680 carried=0
690 ENDPROC
700
710 DEF PROCtitle
720 PRINT:PRINT
730 PRINTCHR$132;" *************
************"
740 PRINTCHR$132;" ***************
**************"
750 FORDH=1TO2:PRINTCHR$132;" **** `";
CHR$133;CHR$141;"Return Of The Diamond";
CHR$140;CHR$132;"` ****":NEXTDH
760 PRINTCHR$132;" ***************
**************"
770 PRINTCHR$132;" *************
************"
780 ENDPROC
790
800 DEF PROClook
810 IF (position=6 OR position=9) AND
(NOT on OR (itempos(1)<>position AND it
empos(1)<>0)) THEN PRINT"It is pitch dar
k.":ENDPROC
820 PRINT
830 PRINT"You are ";place$(position)
840 PRINT
850 PRINT"Exits :"
860 FOR i=1 TO 4
870 IF newpos(position,i)>0 THEN PRINT
direct$(i);":";
880 NEXT i
890 PRINT
900 PRINT
910 PRINT"You can see :"
920 printed=FALSE
930 FOR i=1 TO 6
940 IF itempos(i)=position THEN PRINT
item$(i):printed=TRUE
950 IF itempos(i)=position AND i=1 AND
NOT on THEN PRINT bright$(0)
960 IF itempos(i)=position AND i=1 AND
on THEN PRINT bright$(lit)
970 NEXT i
980 IF NOT printed THEN PRINT"nothing.
"
990 ENDPROC
1000
1010 DEF PROCanalise
1020 IF LEN(c$)=1 THEN IF INSTR("NESW",
c$)>0 THEN PROCmove:ENDPROC
1030 IF c$="LOOK" THEN PROClook:ENDPROC
1040 IF LEFT$(c$,3)="INV" THEN PROCinve
ntory:ENDPROC
1050 IF c$="SCORE" THEN PRINT"Your scor
e is ";score;".":ENDPROC
1060 IF c$="MOVES" THEN PRINT"Moves mad
e : ";moves:ENDPROC
1070 PROCother`commands
1080 ENDPROC
1090
1100 DEF PROCtime`passing
1110 score=score-1
1120 moves=moves+1
1130 dimmed=FALSE
1140 IF on THEN reallit=reallit-0.1:dim
med=TRUE
1150 lit=INT(reallit)
1160 IF dimmed AND lit=0 THEN PRINT"You
r lamp just went out.":on=FALSE
1170 won=(position=8 AND itempos(2)=8)
1180 ENDPROC
1190
1200 DEF PROCmove
1210 dir=INSTR("NESW",c$)
1220 IF newpos(position,dir)=0 THEN PRI
NT"You can't move in that direction.":EN
DPROC
1230 IF (position=6 OR position=9) AND
(NOT on OR (itempos(1)<>position AND ite
mpos(1)<>0)) THEN PRINT"You have fallen
into a snake pit!":dead=TRUE:ENDPROC
1240 position=newpos(position,dir)
1250 PROClook
1260 ENDPROC
1270
1280 DEF PROCinventory
1290 PRINT
1300 PRINT
1310 PRINT"You are carrying :"
1320 printed=FALSE
1330 FOR i=1 TO 6
1340 IF itempos(i)=0 THEN PRINT item$(i
):printed=TRUE
1350 IF itempos(i)=0 AND i=1 AND NOT on
THEN PRINT bright$(0)
1360 IF itempos(i)=0 AND i=1 AND on THE
N PRINT bright$(lit)
1370 NEXT i
1380 IF NOT printed THEN PRINT"nothing.
"
1390 ENDPROC
1400
1410 DEF PROCother`commands
1420 comno=FNcommand
1430 thingno=FNthing
1440 IF comno=0 OR thingno=0 THEN PRINT
"Sorry.I don't understand.":ENDPROC
1450 ON comno GOTO 1460,1460,1470,1470,
1480,1490,1500
1460 PROCtake:ENDPROC
1470 PROClight:ENDPROC
1480 PROCoff:ENDPROC
1490 PROCdrop:ENDPROC
1500 PROCkill:ENDPROC
1510 ENDPROC
1520
1530 DEF FNcommand
1540 no=0:i=0
1550 REPEAT
1560 i=i+1
1570 IF LEFT$(c$,LEN(com$(i)))=com$(i)
THEN no=i
1580 UNTIL no>0 OR i=7
1590 =no
1600
1610 DEF FNthing
1620 no=0:i=0
1630 REPEAT
1640 i=i+1
1650 IF RIGHT$(c$,LEN(itemname$(i)))=it
emname$(i) THEN no=i
1660 UNTIL no>0 OR i=6
1670 =no
1680
1690 DEF PROCtake
1700 IF itempos(thingno)<>position THEN
PRINT"I don't see that here.":ENDPROC
1710 IF thingno=5 OR thingno=6 THEN PRI
NT"You'll be lucky!":ENDPROC
1720 IF carried=3 THEN PRINT"You can't
carry any more.":ENDPROC
1730 itempos(thingno)=0
1740 PRINT"O.K."
1750 carried=carried+1
1760 ENDPROC
1770
1780 DEF PROClight
1790 IF itempos(thingno)<>0 THEN PRINT"
I would if you had it.":ENDPROC
1800 IF thingno<>1 THEN PRINT"You're jo
king!":ENDPROC
1810 IF on THEN PRINT"It's already on."
:ENDPROC
1820 IF lit=0 THEN PRINT"It won't relig
ht.":ENDPROC
1830 PRINT"O.K."
1840 on=TRUE
1850 ENDPROC
1860
1870 DEF PROCoff
1880 IF itempos(thingno)<>0 THEN PRINT"
You're not carrying that.":ENDPROC
1890 IF thingno<>1 THEN PRINT"Come off
it!":ENDPROC
1900 IF NOT on THEN PRINT"It's already
off.":ENDPROC
1910 PRINT"O.K."
1920 on=FALSE
1930 ENDPROC
1940
1950 DEF PROCdrop
1960 IF itempos(thingno)<>0 THEN PRINT"
But you haven't got that.":ENDPROC
1970 itempos(thingno)=position
1980 PRINT"O.K."
1990 carried=carried-1
2000 ENDPROC
2010
2020 DEF PROCkill
2030 IF itempos(thingno)<>position THEN
PRINT"I don't see that here.":ENDPROC
2040 IF thingno=5 THEN PROCkill`gremlin
:ENDPROC
2050 IF thingno=6 THEN PROCkill`pixie:E
NDPROC
2060 PRINT"You're joking!"
2070 ENDPROC
2080
2090 DEF PROCkill`gremlin
2100 IF itempos(3)=0 THEN PRINT"You sla
sh your knife at the gremlin and kill it
easily.":itempos(5)=-1:score=score+10:E
NDPROC
2110 IF itempos(4)=0 THEN PRINT"You thr
ow your hammer at the gremlin,but it cat
ches it and throws it back.":ENDPROC
2120 PRINT"You fight the gremlin bare h
anded,but only succeed in getting killed
."
2130 dead=TRUE
2140 ENDPROC
2150
2160 DEF PROCkill`pixie
2170 IF itempos(4)=0 THEN PRINT"You thr
ow your hammer at the pixie......A hit!"
:itempos(6)=-1:score=score+10:ENDPROC
2180 IF itempos(3)=0 THEN PRINT"You sla
sh your knife at the pixie but it dodges
.":ENDPROC
2190 PRINT"You fight the pixie bare han
ded but it is stronger than you thou
ght.You get killed."
2200 dead=TRUE
2210 ENDPROC
2220
2230 DEF PROCfinish
2240 PRINT
2250 PRINT
2260 IF won THEN PRINT" Congratulat
ions!!!```You won!!!"
2270 IF dead THEN PRINT" Pathetic!!
!```You lost!!!":score=0
2280 PRINT
2290 PRINT
2300 PRINT" You took ";moves;" moves,
"
2310 PRINT" and your final score was
";score;"."
2320 PRINT" Press SPACE to play again
."
2330 REPEAT
2340 UNTIL INKEY$(0)=" "
2350 ENDPROC