# Extracted from HP tape image 16-Nov-2003 by Pete Turnbull
# Downloaded from http://www.dunnington.u-net.com/public/startrek/
# and converted to ZX81 BASIC by Erik Olofsen, 2014
# Some optimizations were done to fit it in 16K; but then the emulator
# was modified to allow for 48K...
# To be run with '-r0' option.
1 rem **** hp basic program library ******************************
2 rem
3 rem sttr1: star trek
4 rem
5 rem 36243 rev b -- 10/73
6 rem
7 rem **** contributed program ***********************************
100 rem *****************************************************************
110 rem *** ***
120 rem *** star trek: by mike mayfield, centerline engineering ***
130 rem *** ***
140 rem *** total interaction game - orig. 20 oct 1972
150 rem *** ***
160 rem *****************************************************************
170 rand 1
180 print
print "*** star trek ***"
190 print "do you want instructions (y/n)?"
200 input i$
210 if i$="" then goto 230
let i$=i$(1)
if i$ = "q" or i$ = "q" then stop
if i$ <> "y" and i$ <> "y" then goto 230
rem $m adapts/sttr1i.bas
220 gosub 5820
230 rem ***** program starts here *****
250 print
260 let zr=0
let on=1
let mo=-1
let hf=.5
let tr=3
let et=8
dim g(et,et)
dim c(9,2)
dim k(tr,tr)
dim n(tr)
dim z(et,et)
dim d(et)
dim c$(6)
dim d$(96)
dim a$(tr)
dim z$(72)
dim q$(72)
dim r$(72)
dim s$(48)
290 let t0=int(rnd*20+20)*100
let t=t0
300 let t9=30
310 let d0=zr
320 let e0=3000
let e=e0
330 let p0=10
let p=p0
340 let s9=200
350 let s=zr
let h8=s
370 let q1=int(rnd*et+1)
380 let q2=int(rnd*et+1)
390 let s1=int(rnd*et+1)
400 let s2=int(rnd*et+1)
410 rem let t7=tim(0)+60*tim(1)
let t7=(peek 65535)/60+(peek 65534)+60*(peek 65533)
420 let c(2,1)=mo
let c(3,1)=mo
let c(4,1)=mo
let c(4,2)=mo
let c(5,2)=mo
let c(6,2)=mo
430 let c(1,1)=zr
let c(3,2)=zr
let c(5,1)=zr
let c(7,2)=zr
let c(9,1)=zr
440 let c(1,2)=on
let c(2,2)=on
let c(6,1)=on
let c(7,1)=on
let c(8,1)=on
let c(8,2)=on
let c(9,2)=on
450 gosub 7100
460 let d$="warp enginess.r. sensorsl.r. sensorsphaser cntrlphoton tubesdamage cntrlshield cntrlcomputer"
490 let b9=zr
let k9=zr
500 for i=1 to et
510 for j=1 to et
520 let r1=rnd
530 if r1>.98 then goto 580
540 if r1>.95 then goto 610
550 if r1>.8 then goto 640
560 let k3=zr
570 goto 660
580 let k3=3
590 let k9=k9+3
600 goto 660
610 let k3=2
620 let k9=k9+2
630 goto 660
640 let k3=1
650 let k9=k9+1
660 let r1=rnd
670 if r1>.96 then goto 700
680 let b3=zr
690 goto 720
700 let b3=1
710 let b9=b9+1
720 let s3=int(rnd*et+1)
730 let g(i,j)=k3*100+b3*10+s3
740 let z(i,j)=zr
750 next j
760 next i
770 let k7=k9
775 if b9 <= zr or k9 <= zr then goto 490
780 print "it is stardate ";t
print "you must destroy ";k9;" klingons in ";t9;" stardates with ";b9;" starbases"
810 let k3=zr
let b3=zr
let s3=zr
820 if q1et or q2et then goto 920
830 let x=g(q1,q2)*.01
840 let k3=int(x)
850 let b3=int((x-k3)*10)
860 let s3=g(q1,q2)-int(g(q1,q2)*.1)*10
870 if k3=zr then goto 910
880 if s>200 then goto 910
890 print "combat area condition red"
900 print " shields dangerously low"
910 gosub 7200
920 for i=1 to tr
930 let k(i,3)=zr
940 next i
950 let q$=z$
960 let r$=z$
970 let s$=z$(1 to 48)
980 let a$="<*>"
990 let z1=s1
1000 let z2=s2
1010 gosub 5510
1020 for i=1 to k3
1030 gosub 5380
1040 let a$="+++"
1050 let z1=r1
1060 let z2=r2
1070 gosub 5510
1080 let k(i,1)=r1
1090 let k(i,2)=r2
1100 let k(i,3)=s9
1110 next i
1120 for i=1 to b3
1130 gosub 5380
1140 let a$=">=<"
1150 let z1=r1
1160 let z2=r2
1170 gosub 5510
1180 next i
1190 for i=1 to s3
1200 gosub 5380
1210 let a$=" * "
1220 let z1=r1
1230 let z2=r2
1240 gosub 5510
1250 next i
1260 gosub 4120
1270 print
1275 print "command:"
1280 input i$
if i$ = "q" or i$ = "q" then stop
if i$="" then goto 1310
let a = val i$
1290 if a=0 then goto 1410
if a=1 then goto 1260
if a=2 then goto 2330
if a=3 then goto 2530
if a=4 then goto 2800
if a=5 then goto 3460
if a=6 then goto 3560
if a=7 then goto 4630
1310 print " 0 = set course"
1320 print " 1 = short range sensor scan"
1330 print " 2 = long range sensor scan"
1340 print " 3 = fire phasers"
1350 print " 4 = fire photon torpedoes"
1360 print " 5 = shield control"
1370 print " 6 = damage control report"
1380 print " 7 = call on library computer"
1390 print " q = quit"
1400 goto 1270
# set course
1410 print "course (1-9):"
1420 input i$
if i$ = "" then goto 1270
if i$(1) = "q" or i$(1) = "q" then goto 1270
let c1 = val i$
1430 if c1=zr then goto 1270
1440 if c1<1 or c1 >= 9 then goto 1410
1450 print "warp factor (0-8):"
1460 input i$
if i$ = "" then goto 1270
if i$(1) = "q" or i$(1) = "q" then goto 1270
let w1 = val i$
1470 if w1et then goto 1410
1480 if d(1) >= 0 or w1 <= .2 then goto 1510
1490 print "warp engines are damaged, maximum speed = warp .2"
1500 goto 1410
1510 if k3 <= 0 then goto 1560
1520 gosub 3790
1530 if k3 <= 0 then goto 1560
1540 if s<0 then goto 4000
1550 goto 1610
1560 if e>0 then goto 1610
1570 if s<1 then goto 3920
1580 print "you have ";e;" units of energy"
1590 print "suggest you get some from your shields which have ";s;" units left"
1600 goto 1270
1610 for i=1 to et
1620 if d(i) >= 0 then goto 1640
1630 let d(i)=d(i)+1
1640 next i
1650 if rnd>.2 then goto 1810
1660 let r1=int(rnd*et+1)
1670 if rnd >= hf then goto 1750
1680 let d(r1)=d(r1)-(rnd*5+1)
1690 print
1700 print "damage control report:"
1710 gosub 5610
1720 print " damaged"
1730 print
1740 goto 1810
1750 let d(r1)=d(r1)+(rnd*5+1)
1760 print
1770 print "damage control report:"
1780 gosub 5610
1790 print " state of repair improved"
1800 print
1810 let n=int(w1*et)
1820 let a$=" "
1830 let z1=s1
1840 let z2=s2
1850 gosub 5510
1870 let x=s1
1880 let y=s2
1885 let c2=int(c1)
1890 let x1=c(c2,1)+(c(c2+1,1)-c(c2,1))*(c1-c2)
1900 let x2=c(c2,2)+(c(c2+1,2)-c(c2,2))*(c1-c2)
1910 for i=1 to n
1920 let s1=s1+x1
1930 let s2=s2+x2
1940 if s1= 8.5 or s2= 8.5 then goto 2170
1950 let a$=" "
1960 let z1=s1
1970 let z2=s2
1980 gosub 5680
1990 if z3 <> 0 then goto 2070
2030 print "warp engines shutdown at sector ";s1;",";s2;" due to bad navigation"
2040 let s1=s1-x1
2050 let s2=s2-x2
2060 goto 2080
2070 next i
2080 let a$="<*>"
2083 let s1=int(s1+hf)
2086 let s2=int(s2+hf)
2090 let z1=s1
2100 let z2=s2
2110 gosub 5510
2120 let e=e-n+5
2130 if w1<1 then goto 2150
2140 let t=t+1
2150 if t>t0+t9 then goto 3970
2160 goto 1260
2170 let x=q1*et+x+x1*n
2180 let y=q2*et+y+x2*n
2190 let q1=int(x/et)
2200 let q2=int(y/et)
2210 let s1=int(x-q1*et+hf)
2220 let s2=int(y-q2*et+hf)
2230 if s1 <> 0 then goto 2260
2240 let q1=q1-1
2250 let s1=et
2260 if s2 <> 0 then goto 2290
2270 let q2=q2-1
2280 let s2=et
2290 let t=t+1
2300 let e=e-n+5
2310 if t>t0+t9 then goto 3970
2320 goto 810
# long range sensor scan
2330 if d(3) >= 0 then goto 2370
2340 print "long range sensors are inoperable"
2360 goto 1270
2370 print "long range sensor scan for quadrant ";q1;",";q2
2380 print
print "-------------------"
2390 for i=q1-1 to q1+1
2400 gosub 7300
2410 for j=q2-1 to q2+1
2420 if iet or jet then goto 2460
2430 let n(j-q2+2)=g(i,j)
2440 if d(7)<0 then goto 2460
2450 let z(i,j)=g(i,j)
2460 next j
2470 gosub 7400
2480 print "-------------------"
2490 next i
2500 goto 1270
# fire phasers
2530 if k3 <= 0 then goto 3670
2540 if d(4) >= 0 then goto 2570
2550 print "phaser control is disabled"
2560 goto 1270
2570 if d(7) >= 0 then goto 2590
2580 print "computer failure hampers accuracy"
2590 print "phasers locked on target; energy available=";e
2600 print "number of units to fire:"
2610 input i$
if i$ = "" then goto 1270
if i$(1) = "q" or i$(1) = "q" then goto 1270
let x = val i$
2620 if x <= 0 then goto 1270
2630 if e-x<0 then goto 2570
2640 let e=e-x
2650 gosub 3790
2660 if d(7) >= 0 then goto 2680
2670 let x=x*rnd
2680 for i=1 to tr
2690 if k(i,3) <= 0 then goto 2770
2700 gosub 7000
2705 let h=(x/k3/fnd)*(2*rnd)
2710 let k(i,3)=k(i,3)-h
2720 print h;" unit hit on klingon at sector ";k(i,1);",";k(i,2);" (";k(i,3);" left)"
2740 if k(i,3)>0 then goto 2770
2750 gosub 3690
2760 if k9 <= 0 then goto 4040
2770 next i
2780 if e<0 then goto 4000
2790 goto 1270
# fire photon torpedoes
2800 if d(5) >= 0 then goto 2830
2810 print "photon tubes are not operational"
2820 goto 1270
2830 if p>0 then goto 2860
2840 print "all photon torpedoes expended"
2850 goto 1270
2860 print "torpedo course (1-9):"
2870 input i$
if i$ = "" then goto 1270
if i$(1) = "q" or i$(1) = "q" then goto 1270
let c1 = val i$
2880 if c1=zr then goto 1270
2890 if c1<1 or c1 >= 9 then goto 2860
2895 let c2=int(c1)
2900 let x1=c(c2,1)+(c(c2+1,1)-c(c2,1))*(c1-c2)
2910 let x2=c(c2,2)+(c(c2+1,2)-c(c2,2))*(c1-c2)
2920 let x=s1
2930 let y=s2
2940 let p=p-1
2950 print "torpedo track:"
2960 let x=x+x1
2970 let y=y+x2
2980 if x= 8.5 or y= 8.5 then goto 3420
2990 print " ";x;",";y
3010 let a$=" "
3020 let z1=x
3030 let z2=y
3040 gosub 5680
3050 if z3=zr then goto 3070
3060 goto 2960
3070 let a$="+++"
3080 let z1=x
3090 let z2=y
3100 gosub 5680
3110 if z3=zr then goto 3220
3120 print "*** klingon destroyed ***"
3130 let k3=k3-1
3140 let k9=k9-1
3150 if k9 <= 0 then goto 4040
3160 for i=1 to tr
3170 if int(x+hf) <> k(i,1) then goto 3190
3180 if int(y+hf)=k(i,2) then goto 3200
3190 next i
3200 let k(i,3)=zr
3210 goto 3360
3220 let a$=" * "
3230 let z1=x
3240 let z2=y
3250 gosub 5680
3260 if z3=zr then goto 3290
3270 print "you can""t destroy stars silly"
3280 goto 3420
3290 let a$=">!<"
3300 let z1=x
3310 let z2=y
3320 gosub 5680
3330 if z3=zr then goto 2960
3340 print "*** star base destroyed *** .......congratulations"
3350 let b3=b3-1
3360 let a$=" "
3370 let z1=int(x+hf)
3380 let z2=int(y+hf)
3390 gosub 5510
3400 let g(q1,q2)=k3*100+b3*10+s3
3410 goto 3430
3420 print "torpedo missed"
3430 gosub 3790
3440 if e<0 then goto 4000
3450 goto 1270
# shield control
3460 print
3465 if d(7) >= 0 then goto 3490
3470 print "shield control is non-operational"
3480 goto 1270
3490 print "energy available = ";e+s;"; number of units to shields:"
3500 input i$
if i$="" then goto 1270
if i$(1) = "q" or i$(1) = "q" then goto 1270
let x = val i$
3510 if x <= 0 then goto 1270
3520 if e+s-x<0 then goto 3490
3530 let e=e+s-x
3540 let s=x
3550 goto 1270
# damage control report
3560 if d(6) >= 0 then goto 3590
3570 print "damage control report is not available"
3580 goto 1270
3590 print
3600 print "device state of repair"
3610 for l=1 to et
3620 gosub 5610
3640 next l
3650 goto 1270
3670 print "short range sensors report no klingons in this quadrant"
3680 goto 1270
3690 print "klingon at sector ";k(i,1);",";k(i,2);" destroyed ****"
3710 let k3=k3-1
3720 let k9=k9-1
3730 let a$=" "
3740 let z1=k(i,1)
3750 let z2=k(i,2)
3760 gosub 5510
3770 let g(q1,q2)=k3*100+b3*10+s3
3780 return
# status
3790 if c$ <> "docked" then goto 3820
3800 print "star base shields protect the enterprise"
3810 return
3820 if k3 <= 0 then goto 3910
3830 for i=1 to tr
3840 if k(i,3) <= 0 then goto 3900
3850 gosub 7000
3855 let h=(k(i,3)/fnd)*(2*rnd)
3860 let s=s-h
3870 print h;" unit hit on enterprise at sector ";k(i,1);",";k(i,2);" (";s;" left)"
3890 if s<0 then goto 4000
3900 next i
3910 return
3920 print "the enterprise is dead in space; if you survive all impending"
3930 print "attack you will be demoted to the rank of private"
3940 if k3 <= 0 then goto 4020
3950 gosub 3790
3960 goto 3940
3970 print
3980 print "it is stardate ";t
3990 goto 4020
4000 print
4010 print "the enterprise has been destroyed; the federation will be conquered"
4020 print "there are still ";k9;" klingon battle cruisers"
4030 stop
4040 print
4050 print "the last klingon battle cruiser in the galaxy has been destroyed"
4060 print "the federation has been saved $$$"
4070 print
4080 print "your efficiency rating = ";((k7/(t-t0))*1000)
4090 let t1=(peek 65535)/60+(peek 65534)+60*(peek 65533)
4100 print "your actual time of mission = ";int(1000*(t1-t7))/1000;" minutes"
4110 stop
# short range sensor scan
4120 for i=s1-1 to s1+1
4130 for j=s2-1 to s2+1
4140 if iet or jet then goto 4200
4150 let a$=">!<"
4160 let z1=i
4170 let z2=j
4180 gosub 5680
4190 if z3=1 then goto 4240
4200 next j
4210 next i
4220 let d0=zr
4230 goto 4310
4240 let d0=1
4250 let c$="docked"
4260 let e=3000
4270 let p=10
4280 print "shields dropped for docking purposes"
4290 let s=zr
4300 goto 4380
4310 if k3>0 then goto 4350
4320 if e= 0 then goto 4430
4390 print
4400 print "*** short range sensors are out ***"
4410 print
4420 goto 4530
4430 print
print " ----1---2---3---4---5---6---7---8--"
4440 print " 1 .";q$(1 to 3);".";q$(4 to 6);".";q$(7 to 9);".";q$(10 to 12);".";q$(13 to 15);".";q$(16 to 18);".";q$(19 to 21);".";q$(22 to 24)+"."
4450 print " 2 .";q$(25 to 27);".";q$(28 to 30);".";q$(31 to 33);".";q$(34 to 36);".";q$(37 to 39);".";q$(40 to 42);".";q$(43 to 45);".";q$(46 to 48);". stardate ";t
4460 print " 3 .";q$(49 to 51);".";q$(52 to 54);".";q$(55 to 57);".";q$(58 to 60);".";q$(61 to 63);".";q$(64 to 66);".";q$(67 to 69);".";q$(70 to 72);". condition ";c$
4470 print " 4 .";r$(1 to 3);".";r$(4 to 6);".";r$(7 to 9);".";r$(10 to 12);".";r$(13 to 15);".";r$(16 to 18);".";r$(19 to 21);".";r$(22 to 24);". quadrant ";q1;",";q2
4480 print " 5 .";r$(25 to 27);".";r$(28 to 30);".";r$(31 to 33);".";r$(34 to 36);".";r$(37 to 39);".";r$(40 to 42);".";r$(43 to 45);".";r$(46 to 48);". sector ";s1;",";s2
4490 print " 6 .";r$(49 to 51);".";r$(52 to 54);".";r$(55 to 57);".";r$(58 to 60);".";r$(61 to 63);".";r$(64 to 66);".";r$(67 to 69);".";r$(70 to 72);". energy ";e
4500 print " 7 .";s$(1 to 3);".";s$(4 to 6);".";s$(7 to 9);".";s$(10 to 12);".";s$(13 to 15);".";s$(16 to 18);".";s$(19 to 21);".";s$(22 to 24);". torpedoes ";p
4510 print " 8 .";s$(25 to 27);".";s$(28 to 30);".";s$(31 to 33);".";s$(34 to 36);".";s$(37 to 39);".";s$(40 to 42);".";s$(43 to 45);".";s$(46 to 48);". shields ";s
4520 print " -----------------------------------"
4530 return
# call on library computer
4630 if d(8) >= 0 then goto 4660
4640 print "computer disabled"
4650 goto 1270
4660 print
print "computer active and awaiting command:"
4670 input i$
if i$="" then goto 4690
if i$ = "q" or i$ = "q" then goto 1270
let a = val i$
4680 if a=0 then goto 4740
if a=1 then goto 4830
if a=2 then goto 4880
4690 print "functions available from computer"
4700 print " 0 = cumulative galactic record"
4710 print " 1 = status report"
4720 print " 2 = photon torpedo data"
print " q = return"
4730 goto 4660
# cumulative galactic record
4740 print "computer record of galaxy:"
4760 print " 1 2 3 4 5 6 7 8"
4770 print " ----- ----- ----- ----- ----- ----- ----- -----"
4780 for i=1 to et
4790 gosub 7600
4800 print " ----- ----- ----- ----- ----- ----- ----- -----"
4810 next i
4820 goto 1270
# status report
4830 print
print "status report:"
print
4840 print "number of klingons left = ";k9
4850 print "number of stardates left = ";(t0+t9)-t
4860 print "number of starbases left = ";b9
4870 let t1=(peek 65535)/60+(peek 65534)+60*(peek 65533)
4872 print "your actual time of mission = ";int(1000*(t1-t7))/1000;" minutes"
4875 goto 3560
# photon torpedo data
4880 print
4890 let h8=zr
4900 for i=1 to tr
4910 if k(i,3)<=zr then goto 5260
4920 let c1=s1
4930 let a=s2
4940 let w1=k(i,1)
4950 let x=k(i,2)
4960 goto 5010
4970 print "you are at quadrant ( ";q1;",";q2;" ) sector ( ";s1;",";s2;" )"
4990 print "ship""s x coordinate:"
input i$
if i$ = "" then goto 1270
if i$(1) = "q" or i$(1) = "q" then goto 1270
let c1 = val i$
print "ship""s y coordinate:"
input i$
if i$ = "" then goto 1270
if i$(1) = "q" or i$(1) = "q" then goto 1270
let a = val i$
print "target""s x coordinate:"
input i$
if i$ = "" then goto 1270
if i$(1) = "q" or i$(1) = "q" then goto 1270
let w1 = val i$
print "target""s y coordinate:"
input i$
if i$ = "" then goto 1270
if i$(1) = "q" or i$(1) = "q" then goto 1270
let x = val i$
5010 let x=x-a
if x=zr then goto 4990
5020 let a=c1-w1
5030 if xzr then goto 5070
5060 if a=zr then goto 5150
5070 let c1=1
5080 if abs(a) <= abs(x) then goto 5110
5090 print "direction = ";c1+(((abs(a)-abs(x))+abs(a))/abs(a))
5100 goto 5240
5110 print "direction = ";c1+(abs(a)/abs(x))
5120 goto 5240
5130 if a>zr then goto 5170
5140 if x=zr then goto 5190
5150 let c1=5
5160 goto 5080
5170 let c1=3
5180 goto 5200
5190 let c1=7
5200 if abs(a) >= abs(x) then goto 5230
5210 print "direction =";c1+(((abs(x)-abs(a))+abs(x))/abs(x))
5220 goto 5240
5230 print "direction = ";c1+(abs(x)/abs(a))
5240 print "distance = ";sqr(x*x+a*a)
5250 if h8=on then goto 5320
5260 next i
5270 let h8=zr
5280 print "do you want to use the calculator (y/n)?"
5290 input i$
if i$="" then goto 5280
let i$=i$(1)
if i$="q" or i$="q" then goto 1270
if i$="y" or i$="y" then goto 4970
if i$ <> "n" and i$ <> "n" then goto 5280
5320 goto 1270
# generate random and empty position
5380 let r1=int(rnd*et+on)
5390 let r2=int(rnd*et+on)
5400 let a$=" "
5410 let z1=r1
5420 let z2=r2
5430 gosub 5680
5440 if z3=zr then goto 5380
5450 return
# rem ****** insertion in string array for quadrant ******
5510 let s8=z1*24+z2*3-26
5530 if s8>72 then goto 5560
5540 let q$(s8 to s8+2)=a$
5550 goto 5600
5560 if s8>144 then goto 5590
5570 let r$(s8-72 to s8-70)=a$
5580 goto 5600
5590 let s$(s8-144 to s8-142)=a$
5600 return
# rem **** prints device name from array *****
5610 let s8=l*12-11
5640 print d$(s8 to s8+11);" ";d(l)
5650 return
# rem ******* string comparison in quadrant array **********
5680 let z1=int(z1+hf)
5685 let z2=int(z2+hf)
5690 let s8=z1*24+z2*3-26
5700 let z3=zr
5710 if s8>72 then goto 5750
5720 if q$(s8 to s8+2) <> a$ then goto 5810
5730 let z3=on
5740 goto 5810
5750 if s8>144 then goto 5790
5760 if r$(s8-72 to s8-70) <> a$ then goto 5810
5770 let z3=on
5780 goto 5810
5790 if s$(s8-144 to s8-142) <> a$ then goto 5810
5800 let z3=on
5810 return
# implement fnd function
7000 let arg1=(k(i,1)-s1)
let arg2=(k(i,2)-s2)
let fnd=sqr(arg1*arg1+arg2*arg2)
7010 return
# clear damages
7100 for i=1 to et
7110 let d(i)=zr
7120 next i
7130 return
# clear information on klingons
7200 for i=1 to tr
7210 for j=1 to tr
7220 let k(i,j)=zr
7230 next j
7240 next i
7250 return
# clear scan data
7300 for l=1 to tr
7310 let n(l)=zr
7320 next l
7330 return
# print a sensor scan line
7400 let l$ = ": : : :"
7410 let nn=n(1)
7420 gosub 7700
7430 let l$(3 to 5) = n$
7440 let nn=n(2)
7450 gosub 7700
7460 let l$(9 to 11) = n$
7470 let nn=n(3)
7480 gosub 7700
7490 let l$(15 to 17) = n$
7500 print l$
7510 return
# print galactic record line
7600 let l$=chr$ (i+28)
7610 for l=on to et
7620 let nn=z(i,l)
7630 gosub 7700
7640 let l$=l$+" "+n$
7650 next l
7660 print l$
7670 return
# three-digit str$
7700 let nnn = int(nn/100)
let n$ = chr$ (nnn+28)
let nn = nn-nnn*100
let nnn = int(nn/10)
let n$ = n$+chr$ (nnn+28)
let nn = nn-nnn*10
let n$ = n$+chr$ (nn+28)
return