10REM JEWELS by L Knight 1995
20MODE7:VDU23,1,0;0;0;0;:*FX11,0
30PROCV:X=GET
40PROCY:CLS:Z%=200:DIMR%(Z%),B%(Z%),A
%(Z%),D%(30),E%(10),A$(10),B$(5),C%(4):P
ROCW:REPEATB=FALSE:IFA C=FALSE:V%=0:PROC
A(3,"Will you Fight on or Leave (F/L)?",
1):REPEATPROCS:UNTILA$="F"ORA$="L":IFA$=
"F"PROCC:UNTILFALSE
90PROCD:IF(F%>80ANDRND(35)=1)ORF%+RND
(600)>700PROCT
110PROCG:PROCL:IFBANDAPROCC:UNTILFALSE
ELSEIFBUNTILFALSE
140PROCM:IFBANDAPROCC:UNTILFALSEELSEIF
BUNTILFALSE
150PROCN(1):IFBANDAPROCC:UNTILFALSEELS
EIFBUNTILFALSE
170PROCO:IFBANDAPROCC:UNTILFALSEELSEIF
BUNTILFALSE
190D=TRUE:B=FALSE:O%=r%:r%=b%:IFA%(r%)
=0 A=FALSE:C=TRUE:D=TRUE:UNTILFALSE
230PROCD:IFNOTDORNOTFNAELSEPROCJ:IFA$=
"Y"ANDAPROCI:PROCC:UNTILFALSEELSEIFA$="Y
"PROCI:UNTILFALSE
250IFFNA C=FALSEELSEC=TRUE
260IFCPROCE:A=FALSE:UNTILFALSE
270IFa$="F"ELSEPROCP:IFEUNTILFALSEELSE
IFBPROCC:UNTILFALSEELSEUNTILFALSE
280V%=1:PROCC:UNTILFALSE
310DEFPROCW:E%=1:r%=1:O%=1:R%(1)=11100
11:B%(1)=000109:W%=-1:FORI%=0TO28:PRINTT
AB(I%,0)"#";:PRINTTAB(I%,18)"#";:NEXT:FO
RI%=1TO17:PRINTTAB(0,I%)"#";:PRINTTAB(28
,I%)"#";:NEXT:PRINTTAB(0,9)" *";:PRINTTA
B(29,0)CHR$130;"TIME";CHR$135;SPC5:PRINT
TAB(29,2)CHR$130;"YOUR PARTY":PRINTTAB(3
0,3)D$:FORI%=1TO10:READE%(I%),A$(I%),:NE
XT
380DATA70510,dragon,60406,giant,50304,
wizard,50405,troll,40203,bear
390DATA40202,dog,30101,dwarf,30101,hob
bit,50304,wolf,50305,lion
400C%=2:D%(1)=5:D%(2)=6:B%=0:PROCF:E$=
"":FORI%=0TO5:READB$(I%):E$=E$+LEFT$(B$(
I%),1):NEXT
420DATANorth,East,Down,Up,West,South
430A=FALSE:C=TRUE:D=TRUE:ENDPROC
450DEFPROCD:LOCALI%,:IFO%=Z%E%=Z%-1
460W%=W%+1:F%=(W%+E%)/3.5:PROCX:X%=(B%
(r%)DIV100)MOD100:Y%=B%(r%)MOD100:D%=(X%
+ABS(9-Y%))/5+E%DIV40:d%=(B%(O%)DIV100)M
OD100:e%=B%(O%)MOD100:IFA%(O%)=0 S$=CHR$
255ELSES$="O"
510PRINTTAB(d%,18-e%)S$;:PRINTTAB(X%,1
8-Y%)"*";:P%=0:C$="":FORI%=0TO5:IFFNC(I%
,r%)C$=C$+B$(I%)+" "
540NEXT:PROCA(0,CHR$130+"Exits:-"+CHR$
135+C$,0):IFA%(r%)=0PROCA(1,"The cave is
empty",0):PROCB:F$="¶":ENDPROC:ELSEF$="
O"
570B$="":`%=0:FORI%=0TO6STEP2:J%=FNB(r
%,I%):IFJ%>11 J$="s"ELSEJ$=""
610IFJ%>0ANDJ%<11 B$=B$+"a "+A$(J%)+",
":P%=P%+1
620IFJ%>10 B$=B$+STR$(J%-10)+" jewel"+
J$+", "
630IFJ%>10ANDI%=2ANDJ%<40 `%=J%-10
640NEXT:PROCA(1,"The cave contains "+L
EFT$(B$,LENB$-2),0):PROCB:ENDPROC
670DEFFNC(I%,r%):LOCALJ%:J%=(R%(r%)DIV
10^I%)MOD10:IFJ%=1THEN=TRUEELSE=FALSE
700DEFFNB(r%,I%)=(A%(r%)DIV10^I%)MOD10
0
710DEFPROCG:*FX21,0
720PROCA(3,"Which way will you move?",
1):REPEATPROCS:J%=INSTR(E$,A$):UNTILJ%>0
:G%=J%-1:ENDPROC
770DEFPROCL:B=NOTFNC(G%,r%):IFBPROCA(4
,"You can't go that way!",3):PROCB
800ENDPROC
810DEFPROCB:LOCALN%:N%=TIME:REPEATUNTI
LTIME>N%+100:ENDPROC
840DEFPROCM:IFG%<>4ORr%<>1ENDPROC
860PROCA(3,"West is the way out. Do yo
u really want to leave the maze (Y/N)?",
1):REPEATPROCS:UNTILA$="Y"ORA$="N":IFA$=
"N"B=TRUE:ENDPROC
900IFB%>1 s$="s"ELSEs$=""
910IFB%=0PROCA(1,"Hard Luck! Better lu
ck next time",0):GOTO960
920IFB%<25PROCA(1,"You only recovered
"+STR$(B%)+" jewel"+s$,0):PROCB:PROCA(2,
"- but congratulations on getting back s
afely!",0):GOTO960
930IFB%<100PROCA(1,"Quite Good!",0):GO
TO960
940IFB%<200PROCA(1,"Well done!",0)ELSE
PROCA(1,"You did exceedingly well, "+D$,
0)
950PROCA(3,"You recovered "+STR$(B%)+"
jewels!",0)
960PROCB:PROCA(4,"Would you like anoth
er game (Y/N)?",1):REPEATPROCS:UNTILA$="
Y"ORA$="N":IFA$="N"CLS:END:ELSEGOTO40
1000DEFPROCN(K%):LOCALI%,J%:IFG%>2 I%=-
1:J%=2*(5-G%)ELSEI%=1:J%=2*G%
1020c%=B%(r%)+I%*10^J%:b%=0:FORI%=1TOE%
:IFc%=B%(I%)b%=I%:I%=E%
1050NEXT:IFb%>0ENDPROC
1070E%=E%+1:b%=E%:B%(b%)=c%:PROCQ(b%,K%
):ENDPROC
1100DEFPROCR:IFRND(10)>5PROCA(4,"Someon
e has closed that exit!",3)ELSEPROCA(4,"
A rock fall has blocked that exit!",3)
1120VDU7:R%(r%)=R%(r%)-10^G%:PROCB:ENDP
ROC
1160DEFPROCQ(r%,k%):LOCALI%,J%,K%,L%,Y%
:X%=(B%(r%)DIV100)MOD100:Y%=B%(r%)MOD100
:L%=5:F=FALSE:R%(r%)=0:IFY%>1AND(G%=0OR(
RND(20)>4ANDr%<Z%))R%(r%)=R%(r%)+100000
1220IFX%>1AND(G%=1OR(RND(20)>L%ANDr%<Z%
))R%(r%)=R%(r%)+10000
1230IFX%<27AND(G%=4OR(RND(20)>L%ANDr%<Z
%))R%(r%)=R%(r%)+10
1240IFY%<17AND(G%=5OR(RND(20)>4ANDr%<Z%
))R%(r%)=R%(r%)+1
1250IFRND(2)=1ORr%=Z%ENDPROC
1260J%=D%+1:IFJ%>4 J%=4
1270A%(r%)=0:IFr%=Z%ENDPROC
1280FORI%=1TO4:C%(I%)=0:NEXT:FORI%=1TOJ
%:REPEATK%=FND:UNTILK%<>C%(1)ANDK%<>C%(2
)ANDK%<>C%(3)ANDK%<>C%(4):IFK%>10ANDF K%
=0
1310C%(I%)=K%:IFK%>10 F=TRUE
1320A%(r%)=A%(r%)+K%*100^(I%-1):NEXT:EN
DPROC
1350DEFFND:LOCALI%,J%,K%:I%=RND(200):RE
STORE1400:J%=0:REPEATJ%=J%+1:READK%:UNTI
LI%<(K%+3*D%):IFJ%>10 J%=10+FNE
1390=J%
1400DATA1,12,22,35,45,55,68,80,90,101,1
11,121,131,141,151,161,171,181,191,201
1410DEFFNE:LOCALI%:I%=X%^4:I%=I%+RND(I%
*.3)+RND(120000):I%=(I%-100000)/30000:IF
I%<1 I%=1
1450=I%
1460DEFPROCO:B=NOTFNC(5-G%,b%):IFBPROCR
1490ENDPROC
1500DEFFNA:LOCALI%,J%,K%:J%=FALSE:FORI%
=0TO6STEP2:K%=FNB(r%,I%):IFK%>0ANDK%<11
J%=TRUE:I%=6
1550NEXT:=J%
1570DEFPROCE:LOCALI%,J%,K%:J%=FALSE:J$=
"":FORI%=0TO6STEP2:K%=FNB(r%,I%):IFK%>10
B%=B%+K%-10:J%=TRUE
1620IFK%>11 J$="s"
1630NEXT:A%(r%)=0:C=TRUE:IFJ%PROCA(3,"Y
our party takes the jewel"+J$+"!",0):PRO
CB:PROCF
1660ENDPROC
1670DEFPROCP:LOCALI%,J%,K%,£%,a%:K%=10:
FORI%=0TO6STEP2:J%=FNB(r%,I%):IFJ%>0ANDJ
%<11IFJ%<K%K%=J%
1700NEXT:£%=(E%(K%)DIV100)MOD100+F%DIV1
50:a%=(E%(K%)DIV10000)+F%DIV150:IFP%>1 n
$="s are":ELSEn$=" is"
1730I%=RND(6):E=FALSE:IFI%<=£%B=TRUE:V%
=-1:PROCA(3,"The occupant"+n$+" aggressi
ve!",2):PROCB:ENDPROC
1740IFP%>1 n$="s":v$="":ELSEn$="":v$="s
"
1750IFI%<a%E=TRUE:A=FALSE:PROCA(3,"The
occupant"+n$+" ignore"+v$+" you!",0):PRO
CB:ENDPROC
1760FORI%=0TO6STEP2:J%=FNB(r%,I%):IFJ%>
0ANDJ%<11ANDC%<30 C%=C%+1:D%(C%)=J%
1780NEXT:IFP%>1 n$="s are":v$="":ELSEn$
=" is":v$="s"
1800PROCA(3,"The occupant"+n$+" friendl
y",0):PROCB:PROCA(4,"- and join"+v$+" yo
ur party",0):PROCB:PROCF:A=FALSE:C=TRUE:
PROCE:ENDPROC
1810DEFPROCC:LOCALI%,J%:R%=V%:Q%=0+F%DI
V80:A=TRUE:J%=C%:IFJ%>3 J%=3
1830IFP%>1 n$="s are"ELSEn$=" is"
1840PROCA(3,"The occupant"+n$+" fightin
g you",0):PROCB:FORI%=1TOJ%:IFC%>0 R%=R%
+(E%(D%(I%))MOD100)ELSER%=R%+5
1870NEXT:FORI%=0TO6STEP2:J%=FNB(r%,I%):
IFJ%>0ANDJ%<11 Q%=Q%+(E%(J%)MOD100)
1910NEXT:R%=R%+RND(6):Q%=Q%+RND(6):IFR%
=Q%:PROCA(4,"You're still fighting!",0):
PROCB:V%=0:ENDPROC
1940IFR%<Q%PROCZELSEPROC`
1950IFNOTFNA C=TRUE:A=FALSE:PROCE
1960ENDPROC
1970DEFPROCZ:LOCALI%:IFC%=0OR(F%>150AND
RND(12)=1ANDINSTR(B$,"drag")>0)PROCF:PRO
CU
1990IFP%>1 n$="s have"ELSEn$=" has"
2000I%=RND(C%):IFI%<1 I%=1
2010PROCB:PROCA(3,"The occupant"+n$+" k
illed a "+A$(D%(I%)),3):PROCB:IF`%>0PROC
K
2030D%(I%)=D%(C%):C%=C%-1:PROCF:ENDPROC
2060DEFPROC`:LOCALI%:I%=-2:REPEATI%=I%+
2:J%=FNB(r%,I%):UNTILJ%>0ANDJ%<11:PROCA(
4,"Your party killed the "+A$(J%),0):PRO
CB:A%(r%)=A%(r%)-J%*10^I%:PROCD:ENDPROC
2140DEFPROCS:LOCALI%:I%=GET:IFI%>96ANDI
%<123 I%=I%-32
2150A$=CHR$I%:ENDPROC
2160DEFPROCA(A%,A$,S%):*FX21,0
2180A$=A$+" ":PRINTTAB(0,18+A%):REPEATT
%=38:REPEATT%=T%-1:X$=MID$(A$,T%,1):UNTI
LX$=" "ORX$="":A%=A%+1:P$=LEFT$(A$,T%):P
RINTP$;SPC(38-LENP$):A$=MID$(A$,T%+1):UN
TILA%>4:IFS%=0:ENDPROC
2230IFS%=1SOUND1,-15,200,2:ELSEVDU7
2250ENDPROC
2260DEFPROCF:LOCALA$,I%,J%,K%,N%,J$:N%=
0:IFC%=0GOTO2340
2280FORI%=1TO10:K%=0:FORJ%=1TOC%:IFD%(J
%)=I%K%=K%+1
2300NEXT:IFK%=1 N%=N%+1:PROCH(N%,"1 "+A
$(I%))
2320IFK%>1 N%=N%+1:PROCH(N%,STR$(K%)+"
"+A$(I%)+"s"):IFI%=9PROCH(N%,STR$(K%)+"
wolves")
2330NEXT
2340IFB%>1 J$="s"ELSEJ$=""
2350IFB%>0 N%=N%+1:PROCH(N%,STR$(B%)+"
jewel"+J$)
2360FORI%=(N%+1)TO11:PROCH(I%," "):NEXT
:ENDPROC
2370DEFPROCJ:PROCA(3,"Do you want to Ap
proach peacefully, Retreat or Fight (A/R
/F)?",1):REPEATPROCS:UNTILA$="R"ORA$="A"
ORA$="F":IFA$="R"A$="Y":ENDPROC
2410IFA$="A"A$="N":a$="A":ENDPROC
2420A$="N":a$="F":ENDPROC
2430DEFPROCH(N%,A$):PRINTTAB(30,N%+3)A$
;SPC(10-LENA$);:ENDPROC
2450DEFPROCT:LOCALI%,J%:PROCB:IFC%=1END
PROC
2480I%=RND(C%):PROCA(2,"A "+A$(D%(I%))+
" has deserted your team",3):D%(I%)=D%(C
%):C%=C%-1:J%=RND(B%)-B%/2:IFJ%>1PROCA(3
,"- taking "+STR$(J%)+" jewels!",3):B%=B
%-J%
2520VDU7:PROCB:PROCB:PROCF:PROCB:PROCB:
ENDPROC
2530DEFPROCI:LOCALI%:I%=O%:O%=r%:r%=I%:
PROCD:ENDPROC
2550DEFPROCX:LOCALH%,M%:M%=5*(F%MOD12):
H%=(F%DIV12+8)MOD24:PRINTTAB(35,0)RIGHT$
(STR$(100+H%),2);":";RIGHT$(STR$(100+M%)
,2):ENDPROC
2580DEFPROCY:LOCALI%,A$:I%=11:CLS:PRINT
TAB(3,10)"What is your name?":INPUTTAB(3
,12)D$:IFLEND$<11ENDPROC
2610REPEATI%=I%-1:A$=MID$(D$,I%,1):UNTI
LNOT(A$="A"ORA$="E"ORA$="I"ORA$="O"ORA$=
"U")ORI%=1:D$=LEFT$(D$,I%):PRINTTAB(3,14
)"That is rather a long name!"'" We wi
ll call you ";D$:PROCB:PROCB:ENDPROC
2630DEFPROCU:PROCB:PROCA(3,"You have been killed , "+D$+"!",0):SOUND1,-15,1
0,20:PROCD:PROCB:C%=0:B%=0:PRINTTAB(30,3
)SPC9:PROCA(4,"Would you like another ga
me?",1):REPEATPROCS:UNTILA$="Y"ORA$="N":
IFA$="Y"RUN ELSE END
2650DEFPROCK:LOCALI%:I%=RND(B%/2):IFI%<
1ORI%>(B%-3)ORRND(2)=1ENDPROC
2670B%=B%-I%:PROCA(4,"- and taken "+STR
$(I%)+" of your jewels",3):A%(r%)=A%(r%)
+I%*100:PROCB:PROCD:ENDPROC
2700DEFPROCV:PRINTSPC10;CHR$134;CHR$141
;"JEWELS AND CAVES"'SPC10;CHR$134;CHR$14
1;"JEWELS AND CAVES"'
2710PRINT" A collection of priceles
s jewels has been stolen and hidden in
a maze of 450 caves. You and your party
have to recover as many as you can."'
2730PRINT" Some of the caves have o
ccupants. These may be friendly - or th
ey may not!The dragons are the most dang
erous."':PRINT" Most of the jewels (
and most of thedragons) will be found at
the eastern end of the maze."'
2750PRINT" Watch the indicated time
and try not to stay in the maze too l
ate in the evening. Otherwise you might
find it difficult to get out again!"'
:PRINT" Press any key to continue.":
X=GET
2780CLS:PRINT'''"You will be given a ma
p of the maze which will show the ca
ves which have been explored, using t
he following codes:-"'':PRINT"
¶ known to be empty"'" O known to be
occupied"'" * your current location
"''''
2800PRINT"Indicate direction you want t
o move by N, S, E, or W"'''" Press
any key to start.":ENDPROC