LUNAR2 ;PROGRAM MOON
100 ;MAIN DRIVER
W *7 S %LN=1 X %TC
W "ATTENTION APOLLO!",!
W "FAILURE IN MAIN COMPUTER DESCENT MODULE...",!
W "MODULE WILL HAVE TO BE LANDED UNDER MANUAL CONTROL",!
W "YOU MAY ADJUST THE RATE OF BURN BETWEEN 0 AND 100 kg/s",!
W *7
D 300 R !,"DO YOU WANT TO TRY AGAIN?",A S PA=0 S:A="Y" PA=1
Q
300 ;DESCENT STAGE
R !,"TYPE 'RETURN' WHEN YOU ARE READY",A,!,"OK" W *7 H 1 D 600
S H=20000,X=68,V=1000,F=3500,T=0,G=1.62,M=3500
S %LN=1,%CO=1 X %TP W "TIME(s) HEIGHT(m) VELOCITY(m/s) FUEL(kg) BURN(kg/s) "
315 S %LN=1,%CO=78 X %TP W !,?2,T,?8,H,?21,V,?36,F,?50 R "?",B," " D:(B>100)!(B<0) 500
F K=1:1:5 S V=V-((P*B*100\1/100)/M*100\1/100)+G,M=M-B,F=F-B,H=H-V D 700 G:H'>0 321 G:F'>0 371
S T=T+5 G 315
321 D:V>20 900 W *7,!!,"TOUCHDOWN AT ",T+K," seconds",!,"LANDING VELOCITY ",V,"m/s",!
G:V>8 325 W *7,"CONGRATULATIONS ON A SAFE LANDING !",! Q
325 G:V>20 327 W *7,"WOULD YOU PLEASE CLEAN BUZZ ALDRIN OFF THE WALLS!",! Q
327 W *7,*7,"YOU HAVE ACHEIVED IMMORTALITY - THEY ARE GOING TO NAME THE CRATER AFTER YOU !",*7,!
Q
371 ;OUT OF FUEL
W *7,!,"OUT OF FUEL",*7 F K=1:1:1000 S V=V+G,H=H-V D 700 G:H'>0 321
Q
500 ;ILLEGAL BURN
G:B>100 513 W !,*7,"ZERO BURN ASSUMED" S B=0 Q
513 W !,*7,"JET TUBES OVERHEATING - REDUCE BURN",*7,! X $P($T(515)," ",2,99) X $P($T(517)," ",2,99) X $P($T(521)," ",2,99) Q
515 W "TUBE BURN OUT" S P=P-200 S:P'>0 F=0
517 W "TWO TUBES BURNT OUT" S P=P-400 S:P'>0 F=0
521 R !,"WHAT NEW BURN ?",B
S %LN=1,%CO=1 X %TP W !
Q
600 ;DISPLAY BACKGROUND
S %LN=1 X %TC
S %LN=19,%CO=1 X %TP W !
W ?22," ^",?53,"/\",!
W ?22,"/ \/\",?52,"/ \",!
W ?7,"/\",?21,"/ \",?51,"/ \",!
W ?6,"/ \/\",?20,"/ \",?47,"/\ / \",!
W "_o___/ \___o_/\/ \________________/ \ \____________________"
S Y=38,X=68 X $P($T(720)," ",2,99) S Z=38,W=68
Q
700 ;DISPLAY LUNAR MODULE
S Y=54-(H/1000\1) S:Y>55 Y=55 S:Y<38 Y=38 I Y=Z,X=W G 725
S %LN=Z-33,%CO=W-30 X %TP W " " S %LN=Z-32,%CO=W-31 X %TP W " " S %LN=Z-31,%CO=W-31 X %TP W " "
720 S %LN=Y-33,%CO=X-30 X %TP W "_" S %LN=Y-32,%CO=X-31 X %TP W "(#)" S %LN=Y-31,%CO=X-31 X %TP W "/-\"
725 S Z=Y,W=X S %LN=1,%CO=1 X %TP W !
Q
900 ;ON THE ROCKS
S %LN=Y-33,%CO=X-31 X %TP W "\M/"
S %LN=Y-32 X %TP W "<@>"
S %LN=Y-31 X %TP W "/W\"
S %LN=1,%CO=1 X %TP F Z=1:1:80 W " "
W ! F Z=1:1:80 W " "
W !!,*7,"CRASH LANDING ON MOON...NO SURVIVORS",*7,!!
S H=0,CR=1
Q