10 ESC$ = CHR$(255)
20 CLS$ = CHR$(12)
30 DEF FNCUR$(X,Y) = ESC$+C+CHR$(X)+CHR$(Y)
40 PRINT ESC$;PF;CLS$;
50 S3 =0
60 N3=0
70 HEIGHT=500
80 KBDCHAR = 0
90 PRINT:PRINT:PRINT
100  PRINT      LUNAR LANDING SIMULATION
110 PRINT        :PRINT
120 PRINT      TYPE '1' FOR INSTRUCTIONS;
130 INPUT A
140 IF A <> 1 THEN 460
150 PRINT CLS$
160 PRINT
170 PRINTYOU ARE LANDING ON THE MOON, YOU HAVE HAD TO ABORT YOUR AUTOMATIC
180 PRINTLANDING PLAN AND HAVE TAKEN OVER MANUAL CONTROL 500 FEET OVER A
190 PRINTGOOD LANDING SITE.
200 PRINT
210 PRINTYOU ARE FALLING AT 50 FTSEC, WITH 120 LBS. OF FUEL  TOTAL ;
220 PRINTDEPLETED AS FOLLOWS:
230 PRINT         AFTER EACH SECOND, THE HEIGHT,VELOCITY AND REMAINING
240 PRINT          FUEL WILL BE REPORTED.
250 PRINT
260 PRINT         ENTER THE NUMBER OF LBS. OF FUEL YOU WISH TO BURN DURING
270 PRINT          THE NEXT SECOND.
280 PRINT          EACH LB. BURNED WILL SLOW THE DESCENT BY 1 FTSEC.
290 PRINT          BURNING 5 LBS OF FUEL WILL MAINTAIN YOUR CURRRENT VELOCITY EXACTLY.
300 PRINT
310 PRINT         MAXIMUM THRUST YOUR ENGINE CAN SUSTAIN IS 30 FTSEC OR
320 PRINT          30 LBS OF FUELSEC.
330 PRINT
340 PRINT         WHEN YOU CONTACT THE LUNAR SURFACE, YOUR DESCENT ENGINE
350 PRINT          WILL AUTOSHUT OFF AND YOU WILL BE GIVEN A READOUT OF
360 PRINT          OF LANDING CONDITIONS.
370 PRINT
380 PRINT         IF YOU ARE OUT OF FUEL, YOU WILL ONLY GET REPORTS UNTIL
390 PRINT          YOU CONTACT THE LUNAR SURFACE
400 PRINT:PRINT
410 PRINT FNCUR$(0,POS(Y)); Strike any key to continue ..;
420 A$=INPUT$(1)
430 PRINT FNCUR$(0,POS(Y));ESC$+EF
440 TIME=0
450 VELOCITY=5
460 PRINT CLS$
470 PRINT ALERT   ALERT   DESCENT PROCEEDURE INITIATED:PRINT
480 IF TIME > 30 THEN PRINT HINT; NO BURN TILL SECOND  4
490 IF TIME = 0 OR VELOCITY = 0 THEN 510
500 IF TIME < 12 THEN PRINT HINT; YOU BURNED LATE FOR A NOVICE
510 PRINT       Lbs of Fuel
520 PRINT         to Burn    SEC    FEET   SPEED    FUEL            PLOT OF DISTANCE
530 PRINT
540 TIME=0
550 HEIGHT=500
560 SPEED=50
570 FUEL=120
580 PRINT USING                                 ;TIME;HEIGHT;SPEED;FUEL;
590 POSITION = HEIGHT15+45
600 IF POSITION > 79 THEN POSITION = 79
610 PRINT TAB(POSITION);*
620 B$ = 
630 PRINT FNCUR$(0,POS(Y)1);
640 FOR I = 1 TO 250
650 ERC = READKBDDIRECT(1,PTR(KBDCHAR))
660 IF ERC = 602 THEN 710
670 IF KBDCHAR = 10 THEN 720
680 IF KBDCHAR = 27 THEN 720
690 PRINT CHR$(KBDCHAR);
700 B$=B$+CHR$(KBDCHAR)
710 NEXT I
720 BURN.TIME=VAL(B$)
730 IF BURN.TIME = 0 THEN PRINT BURN.TIME ELSE PRINT
740 IF BURN.TIME <= 0 THEN 940
750 IF BURN.TIME > 30 THEN 960
760 IF BURN.TIME > FUEL THEN 980
770 VELOCITY=SPEEDBURN.TIME+5
780 FUEL=FUELBURN.TIME
790 HEIGHT = HEIGHT.5*(SPEED+VELOCITY)
800 IF HEIGHT<=0 THEN 1000
810 TIME=TIME+1
820 SPEED=VELOCITY
830 IF FUEL>0 THEN 580
840 IF BURN.TIME=0 THEN 900
850 PRINT  ESC$+AI*** OUT OF FUEL ***+ESC$+AA;
860 PRINT TAB(44) ;
870 POSITION = HEIGHT15+45
880 IF POSITION > 79 THEN POSITION = 79
890 PRINT TAB(POSITION) *
900 PRINT USING                                 ;TIME;HEIGHT;SPEED;FUEL;
910 POSITION = HEIGHT15+45
920 IF POSITION > 79 THEN POSITION = 79
930 PRINT TAB(POSITION) *
940 BURN.TIME=0
950 GOTO 770
960 BURN.TIME=30
970 GOTO 760
980 BURN.TIME=FUEL
990 GOTO 770
1000 PRINT ESC$+AI;*** CONTACT ***;ESC$+AA;
1010 IF VELOCITY <= 20 THEN PRINT TAB(44);*
1020 IF VELOCITY > 20 THEN PRINT  TAB(44);*
1030 IF VELOCITY > 25 THEN PRINT  TAB(44);*
1040 IF VELOCITY > 30 THEN PRINT  TAB(44);oo*
1050 IF VELOCITY > 35 THEN PRINT  TAB(44);o  *
1060 IF VELOCITY > 40 THEN PRINT  TAB(44);.    *
1070 IF VELOCITY > 45 THEN PRINT  TAB(44);.      *
1080 HEIGHT =HEIGHT+.5*(SPEED+VELOCITY)
1090 IF BURN.TIME=5 THEN 1150
1100 Z=SPEED*SPEED+HEIGHT*(102*BURN.TIME)
1110 IF Z<0 THEN 1560
1120 P=SQR(Z)
1130 D=(PSPEED)(5BURN.TIME)
1140 GOTO 1160
1150 D=HEIGHTSPEED
1160 VELOCITY=SPEED+(5BURN.TIME)*D
1170 N3 =N3+1
1180 PRINT
1190 PRINT USING TOUCHDOWN AT               Seconds;TIME+D
1200 PRINT USING LANDING VELOCITY = ,. Feet per Second;VELOCITY
1210 IF VELOCITY < 8 THEN 1240
1220 MPH =  VELOCITY*.6818
1230 PRINT USING THIS IS            ,. MPH,   GROUNDHOG;MPH
1240 IF VELOCITY <> 0 THEN 1280
1250 PRINT CONGRATULATIONS A PERFECT LANDING
1260 S3=S3+8
1270 GOTO 1480
1280 IF VELOCITY < 85 THEN 1310
1290 PRINT:PRINT  YOU HAD TO TRY FOR THAT DO IT RIGHT
1300 GOTO 1480
1310 FOR I1=1 TO 7
1320 S1=2^I1
1330 IF S1 > MPH THEN 1360
1340 NEXT I1
1350 GOTO 1580
1360 PRINT:PRINT SCORE = ;7I1 : PRINT
1370 S3 =S3+7I1
1380 ON I1 GOTO  1390,1420,1430,1440,1450,1460,1480
1390 PRINTNEARLY PERFECT: YOU MUST TRY AGAIN
1400 PRINT                    
1410 GOTO  470
1420 PRINT GOOD.  ( YOU COULD WALK AWAY FROM IT ):GOTO 1480
1430 PRINT ABOUT LIKE HITTING A WALL RUNNING HARD.:GOTO 1480
1440 PRINT OUCH THAT HURT ( THE LANDER ):GOTO 1480
1450 PRINT PUHLEEEZE  MY SOUFFLE:GOTO 1480
1460 PRINT
1470 PRINT  YOU SHOULD REREAD THIS:   FOR EACH:GOTO 290
1480 PRINT 
1490 PRINT  TYPE 1 FOR ANOTHER MISSION.;
1500 INPUT A
1510 IF A=1 THEN 470
1520 PRINT USING FOR  MISSIONS, AVERAGE SCORE = .;N3;S3N3
1530 IF N3>3 AND S3N3>4.5 THEN PRINT GOOD WORK;CHR$(7)
1540 PRINT  CONTROL OUT
1550 SYSTEM
1560 PRINT NEGATIVE ARGUMENT, END OF MISSION.
1570 GOTO 1480
1580 PRINT LOOP OVERFLOW, END MISSION
1590 GOTO 1480
1600 STOP
1610 END
