Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: LUNAR1

LUNAR1.m

Go to the documentation of this file.
LUNAR1 ;PROGRAM MOON
100 ;MAIN DRIVER
 S %LN=1 X %TC
 W *7,"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 "AND THE DIRECTIONAL BURN BETWEEN -100 AND +100 kg/s",!
 W "POSITIVE BURNS MAKE THE MODULE TRAVEL TO THE RIGHT",!,*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 W !,"OK",*7 H 1 D 600
 S H=20000,X=34,V=1000,F=4800,T=0,G=16400,M=6000
 S CR=0,D=0,DI="->",XV=200,%LN=1,%CO=1 X %TP
 W "TIME(s) HEIGHT(m) VELOCITY(m/s)        FUEL(kg) BURN(kg/s) DIRECTION (kg/s)",!
314 W ?2,T,?8,H,?21,V," + ",XV,DI,?40,F
 R ?50,"?",B:5,?57,"?",BH:5,"   "
 D:(B>100)!(B<0) 500 S BI=BH D:BH>100!(BH<0) 2000
 F K=1:1:5 D 400,800 G:+CR=1 327 G:H'>0 321 G:F'>0 371
 D 700 S T=T+5 G 314
321 S H=-1000 D 700 W *7,!!,"TOUCHDOWN AT ",T+K," seconds",!,"LANDING VELOCITY ",V,"m/s",!
 W "HORIZONTAL ",XV,"m/s",!,"FUEL ",F,"kg",!
 G:(V>8)!(XV>2) 325 W *7,*7,*7,"CONGRATULATIONS ON A SAFE LANDING !",! Q
325 G:V>20 327 W "WOULD YOU PLEASE CLEAN BUZZ ALDRIN OFF THE WALLS!",! Q
327 W "YOU HAVE ACHEIVED IMMORTALITY - THEY ARE GOING TO NAME THE CRATER AFTER YOU !",! Q
371 S %LN=1,%CO=1 X %TP W "TIME(s) HEIGHT(m) VELOCITY(m/s) ",?50,"** OUT OF FUEL ***",!,*7,*7
381 F J=1:1:5 S B=0 D 400,800 G:+CR=1 327 D 700 G:H'>0 321
 S T=T+5,%LN=1,%CO=78 X %TP W ! W ?2,T,?8,H,?21,V," + ",XV,DI G 381
 Q
400 S B=B-.25+($P($H,",",2)#6/10) I B<0 S B=0
 I B>F S B=F
 S H=H-V
 S C=H\1000+100
 S V=V+$J(G/(C*C)-(P*B/M),0,2)
 S M=M-B,F=F-B
 Q
500 ;ILLEGAL BURN
 S:B<0 B=0 S:B>100 B=100
 Q
600 ;DISPLAY BACKGROUND
 S %LN=1 X %TC
 S NO=1
 S %LN=24 X %TC
 F Z=1:1:80 W "_"
 F Y=1:1:10 I $N(^MON(+NO,+Y,+-1))>0 F X=34:1:109 I $D(^(+X)) S %LN=25-Y,%CO=X-31 X %TP W ^(+X)
 S Y=38,X=34 X $P($T(720)," ",2,99) S W=X,Z=38
 Q
700 ;DISPLAY LUNAR MODULE
 S Y=54-(H\1000) 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
800 I BI>F S BH=$J(BH/BI*F,0,2),BI=F
 S XV=XV+$J(P-100*BH/M+($P($H,",",2)#5/3)-.5,0,2) S DI="->" S:XV<0 DI="<-" S M=M-BI,F=F-BI
 S D=D+XV,X=D\1000+34,X2=X-34 S:X<34 X=34 S:X>109 X=109
 ;Q:H>5000
 I H<0 S H=0
 I $D(^MON(NO,H\1000+1,X+1)) D 900
 Q
900 S %LN=Y-31,%CO=X-31 X %TP W "\M/"
 S %LN=%LN-1 X %TP W "<@>"
 S %LN=%LN-1 X %TP W "/W\"
 S %LN=1,%CO=1 X %TP,%TCL
 S %LN=2 X %TP,%TCL
 W *7,*7,*7,!!,"CRASH LANDING ON MOON...NO SURVIVORS",!!
 S H=0,CR=1
 Q
2000 ;DIRECTIONAL BURN CORRECTION
 S:BH<0 BI=-BI S:BH>100 BH=100,BI=100 S:BH<-100 BI=100,BH=-100
 Q