100 DIM df(3),gp(41),gt(41),pf(8),nf(8),sp(4),t(2)
110 DIM mn$(18,12),msv(18),n1v(18),scr$(44*16)
120 vg$="":gc$="":f$="":dl$=""
130 ts=0:tn=0:tm=.5:cf=0:rt=0:spap=0
140 OPEN #5,con_452x148a32x16:BORDER #5,2,7:PAPER #5,0:INK #5,4:CSIZE #5,2,0:OVER #5,1
150 OPEN #3,con_452x34a32x218:BORDER #3,2,7:PAPER #3,4:INK #3,0:CSIZE #3,1,0
160 OPEN #4,con_452x54a32x164:BORDER #4,2,7:PAPER #4,2:INK #4,7:CSIZE #4,2,0
170 WINDOW 452,148,32,16:CSIZE 2,0
300 RESTORE :FOR i=1 TO 32:READ c$
330 FOR i=0 TO 18:READ mn$(i),msv(i),n1v(i)
400 READ start,no
410 a=ALCHP(no*9+2):POKE a,start:POKE a+1,no-1
420 FOR i=1 TO no*9:READ v:POKE a+i+1,v
430 CHAR_USE #5,0,a:CHAR_INC #5,10,9:CLS #5
1000 CLS #4:PRINT #4,"Load a character from tape (Y/N) ?"
1010 uniget "YN"
1020 INPUT #4,\"Character's name"!j$
1040 IF LEN(j$)>16 THEN PRINT "Too long":GO TO 1020
1050 IF gc$=="N" THEN GO TO 1240
1060 OPEN #6,j$
1070 INPUT #6,p$,ts,ex1,tn,cs,ps,t(0),t(1),t(2),c1,p1
1080 CLOSE #6
1090 c=150
1100 GO TO 1400
1240 CLS #4:PRINT #4,"Character types...Choose carefully"\
1250 PRINT #4,"Wizard     (1)" TO 20;"Thinker    (2)"
1260 PRINT #4,"Barbarian  (3)" TO 20;"Warrior    (4)"
1270 PRINT #4,"Cleric     (5)"\"   Key 1-5..."
1280 a="0"&INKEY$(#4,-1)
1290 SELect ON a
1300 =1:    p$="WIZARD"   :p1=2   :c1=.5  :cs=22:ps=28
1310 =2:    p$="THINKER"  :p1=1.5 :c1=.75 :cs=24:ps=26
1320 =3:    p$="BARBARIAN":p1=.5  :c1=2   :cs=28:ps=22
1330 =4:    p$="WARRIOR"  :p1=1   :c1=1.25:cs=26:ps=24
1340 =5:    p$="CLERIC"   :p1=1.25:c1=1   :cs=25:ps=25
1350 =REMAINDER :p$="DOLT":p1=1   :c1=1   :cs=20:ps=20
1360 END SELect 
1370 ex1=5:c=150
1400 PRINT #4,\"Good luck"\\j$!"the"!p$\" "
1410 PAUSE 150
1420 GO SUB 10000
1430 update "",5
1440 GO TO 2000
1500 DEFine PROCedure uniget(vg$)
1505 CURSEN #4
1510 REPeat i:gc$=INKEY$(#4,-1):IF gc$ INSTR vg$ THEN EXIT i
1515 CURDIS #4
1520 END DEFine 
1600 DEFine PROCedure d$(ln$)
1610 IF ln$="" THEN AT #3,0,0:CLS #3,3:ELSE PRINT #3,ln$ TO 65
1630 END DEFine 
1700 DEFine FuNction combat_get
1710 PAUSE 1
1720 CURSEN #3:gc$=INKEY$(#3,50):CURDIS #3
1730 d$ ""
1740 RETurn gc$<>""
1750 END DEFine 
1800 DEFine FuNction sget(p)
1810 RETurn CODE(scr$(p))
1820 END DEFine 
1900 DEFine PROCedure sput(p,v)
1910 LOCal x,y
1920 scr$(p)=CHR$(v):y=(p-1) DIV 44*9:x=(p-1) MOD 44*10
1930 BLOCK #5,10,9,x+2,y+1,spap:CURSOR #5,x,y:BPUT #5,v
1940 END DEFine 
2000 m=w:pk=sget(w):INK #5,7:sput m,128:INK #5,4
2010 c=c+10
2020 IF pk=131 OR pk=132 THEN d$ "Safe on the path...Which way?":GO TO 2050
2030 d$ "Your move...Which direction?"
2050 PAUSE 1:AT #5,(m-1) DIV 44,(m-1) MOD 44
2060 CURSEN #5:gc$=INKEY$(#5,-1):CURDIS #5:IF gc$=CHR$(27) THEN GO TO 17000
2070 a=gc$ INSTR "zxcasdqwe"-1:IF a<0 THEN GO TO 2060
2090 w=m+a MOD 3-1-44*(a DIV 3-1)
2100 tn=tn+1:d$ ""
2110 q=128:q1=sget(w):IF q1=32 OR q1=130 THEN GO TO 2190
2120 IF q1=145 THEN GO TO 18000
2130 IF q1=133 OR q1=134 OR q1=135 THEN tn=tn-1:GO TO 2030
2140 IF q1=136 OR q1=137 OR q1=138 OR q1=139 OR q1=140 THEN GO TO 9000
2150 IF q1=141 OR q1=142 THEN GO TO 9090
2160 IF q1=143 THEN GO TO 15000
2170 IF q1=144 OR (a=4 AND pk=144) THEN q=129:c=c-20:IF c<=0 THEN GO TO 20000
2180 IF q1=146 THEN GO TO 2800
2190 sput m,pk:pk=sget(w):m=w:INK #5,7:sput m,q:INK #5,4
2200 IF pk=131 OR pk=132 THEN update "",5:GO TO 2010
2210 rf=RND(100)
2220 IF rf<33 THEN GO TO 3000
2230 IF rf>75 THEN GO TO 2300
2240 d$ "Nothing of value...Search on"
2250 update "",80
2260 GO TO 2010
2300 rf=RND(1 TO 6)
2310 ON rf GO SUB 2340,2380,2380,2410,2410,2440
2320 update "",80
2330 GO TO 2010
2340 d$ "A circle of EVIL...Depart in haste !"
2350 cs=cs+(fl+1) DIV 2:ps=ps-(fl+1) DIV 2:c=c-20
2360 IF c<=0 THEN GO TO 20000
2370 RETurn 
2380 d$ "A hoard of gold"
2390 ts=ts+INT(RND(100*fl)+100)
2400 RETurn 
2410 d$ "You feel the aura of the deep magic..."
2420 d$ "        ...All around you..."
2430 GO TO 2450
2440 d$ "...A place of ANCIENT power..."
2450 ps=ps+2+INT(fl*p1):cs=cs+1+INT(fl*c1):c=c+25
2460 RETurn 
2800 sput m,32:m=w:pk=32:INK #5,7:sput m,128:INK #5,4
2810 rn=RND(100):d$ ""
2820 IF s=6 AND rn>95 AND t(1)=6 AND t(2)=0 AND rt>25 THEN t(2)=1:GO TO 2870
2830 IF s=5 AND rn>85 AND t(0)=0 THEN t(0)=1:GO TO 2880
2840 IF s=4 AND rn>70 AND t(0)=1 AND t(1)<6 AND fl>t(1) THEN GO TO 2890
2850 IF rn>43 THEN d$ "A worthless bauble":GO TO 2940
2860 d$ "A precious stone !":GO TO 2930
2870 d$ "You find the HELM of EVANNA !":GO TO 2930
2880 d$ "The AMULET of ALARIAN...Empty...":GO TO 2930
2890 d$ "An AMULET stone"
2900 update "d",60
2910 IF rn>85 THEN PRINT #3,"...But the wrong one !":GO TO 2940
2920 PRINT #3,"...The stone fits !":t(1)=t(1)+1
2930 ts=ts+100*(t(0)+t(1)+t(2)+fl)
2940 update "",80
2950 GO TO 2010
3000 d$ "** Beware...Thou hast encountered **"
3010 ms=0:n=0:cf=1
3015 e=39*LN(ex1)/3.14
3020 rf=RND(0 TO 16):IF rf>9 AND RND(100)>85 THEN GO TO 3020
3030 IF q1=144 OR pk=144 THEN rf=RND(17 TO 18)
3040 IF rf=16 AND RND(100)<70 THEN GO TO 3020
3050 IF fl<5 AND rf=15 THEN GO TO 3020
3060 IF mn$(rf,1) INSTR f$=0 THEN GO TO 3020
3070 m$=mn$(rf,2 TO LEN(mn$(rf)))
3120 IF msv(rf)=0 THEN GO TO 3150
3130 ms=INT(cs*.3+msv(rf)*fl^.2/(RND+1))
3140 IF n1v(rf)=0 THEN GO TO 3160
3150 n=INT(n1v(rf)*fl^.2/(RND+1))
3160 u=INT((rf+1)*fl^1.5)
3170 IF rf>13 THEN u=INT((rf-13)*fl^1.5)
3180 d$ FILL$(" ",12-LEN(m$)/2)&"An EVIL "&m$
3190 update "",40
3500 IF RND(100)<60 THEN GO TO 4000
3510 d$ "You have Suprise...Attack or Retreat"
3520 IF NOT combat_get THEN GO TO 3600
3530 IF gc$=="R" OR gc$=CHR$(248) THEN GO TO 3900
3540 IF NOT(gc$=="A" OR gc$=CHR$(232)) THEN GO TO 4000
3550 update "d",30
3570 d$ "*** STRIKE QUICKLY **"
3580 IF combat_get THEN GO TO 3620
3600 d$ "* Too SLOW...Too slow"
3610 hf=0:GO TO 3830
3620 e=39*LN(ex1)/3.14
3625 IF gc$=="/" THEN GO TO 3860
3630 IF gc$=="S" OR gc$=CHR$(232) THEN GO TO 4500
3640 IF ms=0 THEN d$ "Your sword avails you nought here":GO TO 3830
3650 c=c-1
3660 IF c<=0 THEN d$ "You fatally exhaust yourself":GO TO 20000
3670 rf=RND(10)
3680 IF (gc$=="H" OR gc$=CHR$(236)) AND (rf<5 OR cs>ms*4) THEN z=2:GO TO 3730
3690 IF (gc$=="B" OR gc$=CHR$(240)) AND (rf<7 OR cs>ms*4) THEN z=1:GO TO 3730
3700 IF (gc$=="L" OR gc$=CHR$(244)) AND (rf<9 OR cs>ms*4) THEN z=.3:GO TO 3730
3710 d$ "You missed it !"
3720 hf=0:GO TO 3830
3730 IF hf=1 THEN d=ms+RND(8):hf=0:GO TO 3760
3740 d=INT(z*(cs*50*RND-10*ms+e)/100):IF d<0 THEN d=0
3750 IF cs>(ms-d)*4 THEN hf=1
3760 ms=ms-d
3770 d$ "A HIT..."
3780 update "d",60
3790 IF d=0 THEN d$ "But...No damage":hf=0:GO TO 3830
3800 IF ms<=0 THEN GO TO 3860
3810 d$ d&" Damage...";
3820 IF hf=1 THEN PAUSE 30:d$ "The "&m$&" staggers defeated"
3830 update "",110
3840 IF hf=1 THEN GO TO 3570
3850 GO TO 4000
3860 d$ "Killing the monster..."
3870 ex1=ex1+u:hf=0:cf=0
3880 update "",80
3890 GO TO 2010
3900 d$ "Knavish COWARD !":cf=0
3910 GO TO 3880
4000 d$ "The creature attacks..."
4010 update "w",50
4020 IF ms=0 THEN GO TO 4300
4030 IF ms<n AND n>6 AND RND(100)<50 THEN GO TO 4300
4040 ms=ms-1:IF ms<=0 THEN GO TO 4240
4050 rf=RND(1 TO 10)
4060 ON rf GO TO 4070,4080,4090,4100,4110,4110,4120,4120,4130,4140
4070 d$ "It swings at you...And misses":GO TO 4280
4080 d$ "Your blade deflects the blow":GO TO 4280
4090 d$ "...But hesitates, unsure...":GO TO 4280
4100 z=3:d$ "It strikes your head !":GO TO 4150
4110 z=1.5:d$ "Your chest is struck !":GO TO 4150
4120 z=1:d$ "A strike to your sword arm !":GO TO 4150
4130 z=1.3:d$ "A blow to your body !":GO TO 4150
4140 z=.5:d$ "It catches your leg !":GO TO 4150
4150 update "d",60
4160 g=INT(z*(ms*75*RND-10*cs-e)/100)
4170 IF g<0 THEN g=0:d$ "...Saved by your armour !":GO TO 4280
4180 c=c-g
4190 IF g>9 THEN cs=INT(cs-g/6)
4200 IF g=0 THEN d$ "Shaken...But no damage done":GO TO 4280
4210 d$ "You take "&g&" Damage..."
4220 IF cs<=0 OR c<=0 THEN GO TO 20000
4230 GO TO 4280
4240 d$ "...Using its last energy in the attempt"
4250 ex1=INT(ex1+u/2):cf=0
4260 update "",100
4270 GO TO 2010
4280 update "",100
4290 GO TO 3570
4300 d$ "...Hurling a lightning bolt at you !"
4310 g=INT((180*n*RND-ps-e)/100):n=n-5:IF g>5 THEN n=INT(n-g/5)
4320 update "d",80
4330 IF n<=0 THEN n=0:GO TO 4240
4340 IF RND(100)<25 THEN GO TO 4410
4350 IF g<=0 THEN g=0:GO TO 4400
4360 d$ "It strikes home !"
4370 update "",110
4380 c=c-g:IF g>9 THEN ps=INT(ps-g/4)
4390 GO TO 4210
4400 d$ "Your PSI Shield protects you":GO TO 4280
4410 d$ "...Missed you !":GO TO 4280
4500 d$ "Which spell seek Ye ?"
4510 IF NOT combat_get THEN GO TO 3600
4520 IF gc$ INSTR "123">0 THEN GO TO 4540
4530 d$ "No such spell...":GO TO 4640
4540 IF 4*ps*RND<=n THEN GO TO 4590
4550 ON gc$ GO SUB 5000,5200,5400
4560 ON sc GO TO 4620,4640,4660,4570,4600,4580,4590
4570 d$ "It is beyond you":GO TO 4640
4580 d$ "But the spell fails...!":GO TO 4640
4590 d$ "No use, the beast's PSI shields it":GO TO 4640
4600 d$ "The spell saps all your strength"
4610 GO TO 20000
4620 update "",100
4630 GO TO 2010
4640 update "",60
4650 GO TO 4000
4660 update "",60
4670 GO TO 3570
5000 c=c-5:IF c<=0 THEN sc=5:RETurn 
5010 d$ "Sleep you foul fiend that I may escape"
5020 d$ "and preserve my miserable skin"
5030 update "",180
5040 d$ "The creature staggers..."
5050 update "d",50
5060 IF RND(100)<50 THEN GO TO 5090
5070 d$ "The creature collapses...Stunned"
5080 ex1=INT(ex1+u/2):cf=0:sc=1:RETurn 
5090 d$ "But recovers with a snarl !"
5100 sc=2:RETurn 
5200 IF ms>c OR ps<49 OR ex1<1000 THEN sc=4:RETurn 
5210 c=c-10:IF c<=0 THEN sc=5:RETurn 
5220 IF n=0 THEN d$ "The beast has no PSI to attack":sc=2:RETurn 
5230 d$ "With my mind a battle you for my life"
5240 update "",120
5250 rf=RND(100):IF rf<40 AND n>10 THEN sc=6:RETurn 
5260 d=INT((cs*50*rf-5*(ms+n)+e)/200)
5270 IF d<=0 THEN d=0:sc=7:RETurn 
5280 d$ "The PSI-LANCE causes "&(d*2)&" damage"
5290 n=n-3*d:IF n<=0 THEN n=0
5300 ms=ms-d:IF ms<=0 THEN ms=0
5310 IF ms+n>0 THEN sc=2:RETurn 
5320 d$ "Killing the creature"
5330 ex1=ex1+u:cf=0:sc=1:RETurn 
5400 IF ps<77 OR ex1<5000 THEN sc=4:RETurn 
5410 c=c-20:IF c<=0 THEN sc=5:RETurn 
5420 d$ "With the might of my sword I smite thee"
5430 d$ "With the power of my spell I curse thee"
5440 d$ "Burn ye spawn of hell and suffer..."
5450 update "",240
5460 d$ "A bolt of energy lashes at the beast"
5470 update "w",80
5480 IF RND>ps/780*(5-p1) THEN d$ "Missed it !":sc=2:RETurn 
5490 d=INT(cs*ps*RND-10*n*RND)
5500 IF d<=0 THEN d=0:sc=7:RETurn 
5510 IF ms=0 THEN n=n-d:goto5530
5520 ms=ms-d:IF d>10 THEN n=INT(n-d/3)
5530 d$ "Strikes home causing "&d&" Damage"
5540 IF ms+n<0 THEN GO TO 5570
5550 update "d",80
5560 sc=2:RETurn 
5570 d$ "The beast dies screaming !"
5580 ex1=ex1+u:cf=0:sc=1:RETurn 
9000 IF (q1=139 OR q1=140) AND pk=144 THEN d$ "You cannot enter this way":GO TO 9110
9010 FOR i=2 TO 7
9020 pf(i)=0
9030 nf(i)=RND(4 TO 8)
9040 IF nf(i)=5 THEN GO TO 9030
9050 END FOR i
9060 IF s=1 THEN mp=m
9070 pf(2)=RND(1 TO 30)
9080 tf=tn:GO TO 9130
9090 IF tn>tf+RND(1 TO 6) THEN GO TO 9130
9100 d$ "The way is barred !"
9110 tn=tn-1:c=c-10:update "w",100
9120 GO TO 2010
9130 c=c-10:sput m,32:sput w,q
9140 IF q1=141 THEN s=1:fl=1
9150 IF q1=142 AND s=4 THEN s=1:fl=1
9160 IF q1=142 AND s=5 OR s=6 THEN s=s-3:fl=fl-4
9170 IF q1=138 THEN s=2:fl=2
9180 IF q1=136 THEN s=3:fl=3
9190 IF q1=136 OR q1=138 THEN lkp=pf(2)+1+44*RND(1 TO 9)
9200 IF q1=137 THEN s=4:fl=2
9210 IF q1=139 OR q1=140 THEN s=s+3:fl=fl+4:mw=m
9220 ON s GO SUB 10000,12000,12010,14000,14010,14010
9230 update "",5
9240 GO TO 2000
10000 CLS #5:f$="vaegh":fl=1:s=1
10010 scr$=FILL$(CHR$(133),44)
10020 FOR i=1 TO 14:scr$=scr$&CHR$(133)&FILL$(" ",42)&CHR$(133)
10030 scr$=scr$&FILL$(CHR$(133),44)
10040 CURDIS #5:INK #5,2:PRINT #5,scr$;:INK #5,4
10060 IF gp(0)<>0 THEN GO TO 10190
10070 m=2+RND(1 TO 14)*44
10080 l=m:mp=m:w=m:gp(0)=m:gt(0)=145
10090 FOR i=1 TO 41
10100 IF RND(100)>50 THEN pc=131:l1=l-43:ELSE pc=132:l1=l+45
10130 IF l1<44 OR l1>15*44 THEN GO TO 10100
10140 gt(i)=pc
10150 IF i>1 AND gt(i)<>gt(i-1) THEN l1=l+1
10160 gp(i)=l1:l=l1
10170 END FOR i
10180 gt(41)=145
10190 FOR i=0 TO 41:sput gp(i),gt(i)
10220 IF sp(0)<>0 THEN GO TO 10280
10230 FOR i=0 TO 4
10240 n1=RND(2 TO 43)+44*RND(1 TO 14)
10250 IF sget(n1)<>32 OR sget(n1+1)<>32 THEN GO TO 10240
10260 sp(i)=n1
10270 END FOR i
10280 spap=7
10290 sput sp(0),136:sput sp(0)+1,136:sput sp(1),136:sput sp(1)+1,136
10300 sput sp(2),138:sput sp(2)+1,138:sput sp(3),138:sput sp(3)+1,138
10310 sput sp(4),137
10320 spap=0:m=mp:w=m
10330 RETurn 
12000 f$="AFL":pc=130:d2$=CHR$(139):GO TO 12020
12010 f$="FAEHL":pc=135:d2$=CHR$(140)
12020 pk=32:CLS #5:r2$=CHR$(144)
12030 scr$=FILL$(CHR$(141),44)
12040 FOR i=1 TO 14:scr$=scr$&CHR$(141)&FILL$(" ",42)&CHR$(141)
12050 scr$=scr$&FILL$(CHR$(141),44)
12060 l1=lkp:scr$(l1+2 TO l1+4)=r2$&r2$
12070 l1=l1+44:scr$(l1+1 TO l1+5)=FILL$(r2$,5)
12080 l1=l1+44:scr$(l1+0 TO l1+5)=r2$&r2$&"  "&r2$&r2$
12090 l1=l1+44:scr$(l1+0 TO l1+6)=r2$&r2$&d2$&" "&r2$&r2$&r2$
12100 l1=l1+44:scr$(l1+1 TO l1+7)=FILL$(r2$,4)&" "&r2$&r2$
12110 l1=l1+44:scr$(l1+3 TO l1+4)=r2$&r2$
12120 l1=l1+44:scr$(l1+4)=r2$
12130 CURDIS #5:INK #5,4:PRINT #5,scr$;:INK #5,4
12140 FOR i=1 TO 200
12150 l1=RND(2 TO 43)+44*RND(1 TO 14)
12160 IF sget(l1)=32 THEN sput l1,pc
12170 END FOR i
12180 w=19+14*44:sput w,32
12190 IF q1=142 THEN m=mw:w=m
12200 RETurn 
14000 f$="CAGE":p=0:h=nf(fl):pk=32:GO TO 14020
14010 f$="CBE":p=0:h=nf(fl):pk=32:pf(fl)=pf(2)
14020 scr$=" "&FILL$(CHR$(134),21)&FILL$(" ",22)
14030 FOR i=1 TO 13:scr$=scr$&" "&CHR$(134)&FILL$(" ",19)&CHR$(134)&FILL$(" ",22)
14040 scr$=scr$&" "&FILL$(CHR$(134),21)&FILL$(" ",22)
14050 CLS #5:PRINT #5,scr$;
14080 RESTORE :FOR i=1 TO pf(fl):READ v:IF v=100 THEN RESTORE 
14100 l1=46:pc=134
14110 FOR j=1 TO 3
14120 READ df(j):p=p+1
14130 IF df(j)=100 THEN RESTORE :df(j)=3:p=p+1
14140 END FOR j
14150 FOR i=0 TO h
14160 l=l1+44*i:IF l>44*14 THEN GO TO 14260
14170 IF i=1 THEN pc=32
14180 IF df(1)=0 THEN pc=134:GO TO 14200
14190 sput l+df(1),pc:pc=134
14200 IF i=3 THEN pc=32
14210 sput l+df(1)+df(2),pc:pc=134
14220 IF i=4 THEN pc=32
14230 sput l+df(1)+df(2)+df(3),pc:pc=134
14240 END FOR i
14250 l1=l1+44*h+44:GO TO 14110
14260 l1=46:pc=134
14270 FOR j=1 TO 4
14280 l=l1+44*j*(h+1)
14290 FOR k=1 TO 19
14300 IF l>44*13 THEN GO TO 14350
14310 sput l+k,pc
14320 IF k=2 OR k=3*h OR k=17 THEN sput l+k,32:sput l+k-44,32:sput l+k+44,32
14330 END FOR k
14340 END FOR j
14350 IF s=5 OR s=6 THEN GO TO 14380
14360 IF fl/2=INT(fl/2) THEN sput 14*44+4,143:GO TO 14380
14370 sput 20,143
14380 IF fl=2 OR s=5 OR s=6 THEN sput 14*44+9,142:sput 13*44+9,32
14390 IF pf(3)=0 THEN w=13*44+9
14400 AT 3,19:PAPER 7:INK 0
14410 IF s=5 THEN GO TO 14470
14420 IF s=6 THEN GO TO 14450
14430 PRINT " THE BLACK TOWER ":AT 4,19:PRINT "    OF ZAEXON    "
14440 AT 6,19:PRINT " Floor"!fl-1;" ":GO TO 14480
14450 PRINT " VOUNIM'S ":AT 4,19:PRINT "   LAIR   "
14460 GO TO 14480
14470 PRINT "  THE TEMPLE OF  ":AT 4,19:PRINT "  THE Y'NAGIOTH  "
14480 PAPER 0:INK 4
14490 pf(fl+1)=pf(fl)+p
14500 IF fl<4 OR RND(100)<30 THEN RETurn 
14510 FOR i=1 TO RND(2 TO 6)
14520 n1=RND(3 TO 21)+44*RND(1 TO 13)
14530 IF sget(n1)<>32 THEN GO TO 14520
14540 sput n1,146
14550 END FOR i
14560 RETurn 
15000 sput w,128:sput m,32
15010 d$ "A Stairway... Up or Down ?":tv=fl
15020 uniget "UD"
15030 IF gc$=="U" THEN fl=fl+1:ELSE fl=fl-1
15050 IF fl>7 OR fl<2 THEN GO TO 15080
15060 update "d",110
15070 GO TO 9220
15080 d$ "These stairs are blocked !"
15090 update "w",60
15100 fl=tv:GO TO 15010
16000 DEFine PROCedure update(dl$,dl)
16010 PAUSE dl*tm
16020 IF dl$=="D" THEN RETurn 
16030 CLS #3
16040 IF dl$=="W" THEN RETurn 
16050 IF cs>77-INT(2*p1^2.5) THEN cs=77-INT(2*p1^2.5)
16060 IF ps<7 THEN ps=7
16070 IF ps>INT(42*(p1+1)^LN(p1^3.7))+75 THEN ps=INT(42*(p1+1)^LN(p1^3.7))+75
16080 IF c>125-INT(p1*12.5) THEN c=125-INT(p1*12.5)
16090 CLS #4:PRINT #4,j$,p$
16100 PRINT_USING #4,"Treasure   =#####  Combat Str =####\",ts,cs
16110 PRINT_USING #4,"Experience =#####  PSI power  =####\",ex1,ps
16120 PRINT_USING #4,"Turns      =#####  Stamina    =####\",tn,c
16130 IF cf<>1 THEN RETurn 
16140 PAPER #4,7:INK #4,2
16150 PRINT_USING #4,"##############     M Str #### / #### ",m$,ms,n
16160 PAPER #4,2:INK #4,7
16170 END DEFine 
17000 update "w",5
17010 rt=INT(6.7E-2*(ex1*ts/3)^.5+LN(ex1/(tn+1)^1.5)):IF rt>28 THEN rt=28
17020 IF rt<0 THEN rt=0
17030 d$ "Your rating now be "&rt
17040 IF t(2)=1 THEN d$ "You have The HELM of EVANNA"
17050 IF t(0)=1 THEN d$ "AMULET stones... ";t(1)
17060 update "w",250
17070 IF gc$=CHR$(27) THEN c=c-10:gc$="":GO TO 2010
17080 RETurn 
18000 d$ "Thou art safe in a castle":IF cs<20 THEN cs=20
18010 sput m,pk:pk=sget(w):m=w:sput m,q
18020 d$ "Wilt thou leave the Valley (Y/N) ?"
18030 uniget "YN"
18040 update "w",5
18050 GO SUB 17000
18060 update "w",110
18070 IF gc$=="Y" THEN GO TO 19000
18080 c=150:d$ "Thy wounds healed...Thy sword sharp"
18090 d$ "Go as God demand..Trust none other"
18100 update "",120
18110 GO TO 2010
19000 CLS #4:PRINT #4,"Do you wish to save"!j$!"?"
19010 PRINT #4,\"Key Y or N"
19020 uniget "YN"
19030 IF gc$=="N" THEN GO TO 19200
19040 OPEN #6,j$
19050 PRINT #6,p$\ts\ex1\tn\cs\ps\t(0)\t(1)\t(2)\c1\p1
19060 CLOSE #6
19200 CLS #5:CLS #3:CLS #4
19210 d$ "Type RUN to restart the game"
19220 CLEAR:STOP
20000 c=0:cs=0:ps=0:cf=0
20010 update "",110
20020 IF t(1)=6 THEN GO TO 20070
20030 d$ " Oh what a frail shell !"
20040 d$ "  Is this what we call a man ?"
20050 update "w",300
20060 CLS #5:CLS #3:CLS #4:STOP
20070 t(0)=0:t(1)=0:ts=0:cs=30:c=150:ps=30
20080 d$ "ALARIAN's amulet protects thy soul"
20090 d$ "  LIVE AGAIN !!"
20100 update "",150
20110 l=gp(0):mp=l:m=w:s=1:GO TO 9220
21000 DATA 4,7,3,6,4,4,6,5,3,6,0,3,8,4,3,5,5,3,8,3,4,5,0,6,3,6,4,6,4,7,4,100
21010 DATA "AWOLFEN",9,0,"AHOB-GOBLIN",9,0,"AORC",9,0,"EFIRE-IMP",7,3,"GROCK-TROLL",19,0
21020 DATA "EHARPY",10,12,"AOGRE",23,0,"BBARROW-WIGHT",0,25,"HCENTAUR",18,14
21030 DATA "EFIRE-GIANT",26,20,"VTHUNDER-LIZARD",50,0,"CMINOTAUR",35,25,"CWRAITH",0,30
21040 DATA "FWYVERN",36,12,"BDRAGON",50,20,"CRING-WRAITH",0,45,"ABALROG",50,50
21050 DATA "LWATER-IMP",15,15,"LKRAKEN",50,0
22000 DATA 128,19
22010 DATA  0,16,56,16,56,84,16,40,68         :REMark 128 character
22020 DATA 0,32,112,60,0,32,84,8,0            :REMark 129 character in water
22030 DATA 0,0,0,0,0,0,0,84,56                :REMark 130 tufts
22040 DATA 4,8,8,8,8,16,32,32,64              :REMark 131 path up
22050 DATA 64,32,32,32,16,16,8,8,4            :REMark 132 path down
22060 DATA 0,56,56,56,56,56,56,56,0           :REMark 133 valley border
22070 DATA 124,124,124,124,124,124,124,124,124:REMark 134 wall
22080 DATA 0,16,56,84,16,56,84,16,16          :REMark 135 tree
22090 DATA 8,28,28,8,40,112,112,32,32         :REMark 136 woods
22100 DATA 124,92,124,116,124,92,124,84,92    :REMark 137 black tower
22110 DATA 0,84,56,0,84,56,0,84,56            :REMark 138 swamps
22120 DATA 0,0,0,84,124,124,84,116,116        :REMark 139 vounims lair
22130 DATA 16,16,56,56,124,124,84,92,92       :REMark 140 temple of y'hagoint
22140 DATA 0,0,0,0,0,0,0,0,0                  :REMark 141 swamp/wood border
22150 DATA 124,124,108,108,68,68,0,0,0        :REMark 142 doorway
22160 DATA 68,124,68,124,68,124,68,124,68     :REMark 143 stairs
22170 DATA 0,32,84,8,0,32,84,8,0              :REMark 144 water
22180 DATA 84,124,84,124,124,76,76,76,76      :REMark 145 safe castle
22190 DATA 0,0,0,0,0,56,124,68,124            :REMark 146 treasure chest
