Page 1 of 1

Lunar Lander (CP/M Altair 4K Version)

Posted: Fri Mar 09, 2018 4:32 am
by GeorgeMcGinn
While I wait for my Altair 8800 Clone kit to arrive, I've started to look at the BASIC programs that run on the CP/M operating system.

I remember the first Altair I purchased in 1976. Using the Altair 8800 I learned operating systems, assembler, and machine language. Using the control panel in the front allowed me to learn how to keep the IBM 360/67 mainframe running when it received a hard stop. Using the 360's front panel, the switches on its front panel served the same purpose as the Altair, and I came up with ways to jumpstart the system after it froze due to a data exception or data protection error.

Some programs requires a lot of changes, but the Lunar Lander only required a few changes to get it running in SmartBASIC.

This is another text-based version of the game. Unlike the last one I posted (was a Z80 based BASIC version) was supposed to have a graph of its flight, but did not work. This one works.

Enjoy!

Code: Select all

100 REM----------------------------------------------------
101 REM       L  A  N  D  E  R
102 REM----------------------------------------------------
103 REM        JUNE 16, 1977
104 REM THIS VERSION OF LUNAR LANDER IS COURTESY OF
105 REM THE IMSAI COMPANY.
106 REM
300 S3 =0
310 N3=0
320 H=500
430 IF H<=0 THEN 1560
1010 PRINT "LUNAR LANDING SIMULATION"
1020 PRINT "----- ------- ----------"
1030 PRINT "TYPE '1' FOR INSTRUCTIONS";
1040 INPUT A
1050 IF A<>1 THEN 1260
1060 PRINT
1070 PRINT "YOU ARE LANDING ON THE MOON, YOUR HAVE HAD TO"
1075 PRINT "ABORT YOUR AUTOMATIC LANDING PLAN AND HAVE TAKEN"
1077 PRINT "OVER MANUAL CONTROL 500 FT. OVER A GOOD LANDING"
1080 PRINT "SPOT. YOU ARE FALLING AT 50 FT/SEC, WITH 120 LBS"
1090 PRINT "OF FUEL TOTAL; DEPLETED AS FOLLOWS:"
1120 PRINT "(1) AFTER EACH SECOND, THE HEIGHT,VELOCITY AND"
1130 PRINT "REMAINING FUEL WILL BE REPORTED."
1140 PRINT "(2) NEXT, A/?/ WILL BE TYPED. ENTER THE NUMBER"
1150 PRINT "OF LBS OF FUEL YOU WISH TO BURN DURING THE NEXT"
1160 PRINT "SECOND. EACH LB BURNED WILL SLOW THE DESCENT BY"
1170 PRINT "1 FT/SEC. 5 LBS OF FUEL WILL MAINTAIN YOUR CUR-"
1175 PRINT "RENT VELOCITY EXACTLY."
1180 PRINT "(3) MAXIMUM THRUST YOUR ENGINE CAN SUSTAIN IS"
1185 PRINT "30 FT/SEC OR 30 LBS OF FUEL/SEC."
1200 PRINT  "(4) WHEN YOU CONTACT THE LUNAR SURFACE, YOUR"
1210 PRINT "DESCENT ENGINE WILL AUTO-SHUT OFF AND YOU WILL"
1220 PRINT "BE GIVEN A READOUT OF LANDING CONDITIONS."
1230 PRINT "(5) IF OUT OF FUEL, ONLY REPORTS UNTIL"
1235 PRINT "YOU CONTACT THE LUNAR SURFACE"
1240 T=0
1245 V1=-5
1250 PRINT
1260 PRINT "ALERT! ALERT! DESCENT PROCEEDURE INITIATED!"
1265 IF T>30 THEN PRINT "HINT; NO BURN TILL SECOND # 4"
1266 IF T=0 THEN 1290
1267 IF V1=0 THEN 1290
1268 IF T<12 THEN PRINT "HINT; YOU BURNED LATE FOR A NOVICE"
1290 PRINT "SEC  FEET   SPEED    FUEL       PLOT OF DISTANCE"
1300 PRINT
1310 T=0
1320 H=500
1330 V=50
1340 F=120
1350 PRINT T;TAB(4);H;TAB(12);V;TAB(20);F;TAB(29);
1352 PRINT "I";TAB(H/15+29);"*";TAB(67)
1360 INPUT B
1370 IF B<0 THEN 1500
1380 IF B>30 THEN 1520
1390 IF B >F THEN 1540
1400 V1=V-B+5
1410 F=F-B
1420 H = H-.5*(V+V1)
1430 IF H<=0 THEN 1560
1440 T=T+1
1450 V=V1
1460 IF F>0 THEN 1350
1470 IF B=0 THEN 1490
1480 PRINT TAB(29);"***** OUT OF FUEL *****"
1490 PRINT T;TAB(4);H;TAB(12);V;TAB(20);F;TAB(29);
1492 PRINT "I";TAB(H/15+29);"."
1500 B=0
1510 GOTO 1400
1520 B=30
1530 GOTO 1390
1540 B=F
1550 GOTO 1400
1560 PRINT "*** CONTACT ***";
1562 IF V1>20 THEN PRINT TAB(29);"0"
1563 IF V1>25 THEN PRINT TAB(29);"00"
1564 IF V1>30 THEN PRINT TAB(29);"000"
1565 IF V1>35 THEN PRINT TAB(29);"0  ."
1566 IF V1>40 THEN PRINT TAB(29);".    ."
1567 IF V1>45 THEN PRINT TAB(29);"."
1570 H =H+.5*(V+V1)
1580 IF B=5 THEN 1610
1585 Z=V*V+H*(10-2*B)
1587 IF Z<0 THEN 1770
1588 P=SQR(Z)
1590 D=(P-V)/(5-B)
1600 GOTO 1620
1610 D=H/V
1620 V1=V+(5-B)*D
1625 N3 =N3+1
1630 PRINT "TOUCHDOWN AT "; T+D;"SECONDS"
1640 PRINT "LANDING VELOCITY=";V1;"FT/SEC"
1641 IF V1>8 THEN PRINT "OR ";V1*.5938;" MPH, GROUNDHOG";
1642 IF V1<>0 THEN 1648
1644 PRINT "CONGRATULATIONS! A PERFECT LANDING"
1645 S3=S3+8
1646 GOTO 1710
1648 IF V1<85 THEN 1654
1650 PRINT!PRINT "YOU HAD TO TRY FOR THAT! DO IT RIGHT"
1652 GOTO 1260
1654 FOR I1=1 TO 7
1656 GOTO 2000
1657 IF S1>V1 THEN 1660
1658 NEXT I1
1659 GOTO 1790
1660 PRINT ";   SCORE = ";7-I1
1661 S3 =S3+7-I1
1662 GOTO 3000
1664 PRINT "NEARLY PERFECT: YOU MUST TRY AGAIN!"
1666 PRINT "                    ----"
1668 GOTO  1260
1670 PRINT "GOOD.  ( YOU COULD WALK AWAY FROM IT )"!GOTO 1710
1672 PRINT "ABOUT LIKE HITTING THE WALL RUNNING HARD."!GOTO 1710
1674 PRINT "OUCH! THAT HURT! ( THE LANDER )"!GOTO 1710
1676 PRINT "PUH-LEEEZE!  MY SOUFFLE'!"!GOTO 1710
1678 PRINT " YOU SHOULD REREAD THIS:   FOR EACH"!GOTO 1160
1710 PRINT "*"
1720 PRINT " TYPE 1 FOR ANOTHER MISSION.";
1730 INPUT A
1740 IF A=1 THEN 1260
1745 PRINT "FOR ";N3;" MISSIONS, AVERAGE SCORE =";S3/N3
1746 IF N3<3 THEN 1750
1747 IF S3/N3>4.5 THEN PRINT "GOOD WORK!"
1750 PRINT " CONTROL OUT"
1760 STOP
1770 PRINT "NEGATIVE ARGUMENT, END OF MISSION."
1780 GOTO 1710
1790 PRINT "LOOP OVERFLOW, END MISSION"
1800 GOTO 1710
1810 STOP
2000 REM POWER X^Y PATCH
2010 S1=2
2040 FOR I9=1 TO I1 STEP 1
2050 S1=S1*2
2060 NEXT I9
2070 GOTO 1657
3000 REM ON GOTO PATCH FOR LINE 1662
3005 IF I1=1 THEN 1664
3010 IF I1=2 THEN 1670
3015 IF I1=3 THEN 1672
3020 IF I1=4 THEN 1674
3025 IF I1=5 THEN 1676
3030 IF I1=6 THEN 1678
3035 IF I1=7 THEN 1710

Re: Lunar Lander (CP/M Altair 4K Version)

Posted: Sat Mar 10, 2018 11:04 am
by Henko
No Altair 8800 simulator in the (Dutch) app store.

Re: Lunar Lander (CP/M Altair 4K Version)

Posted: Mon Mar 12, 2018 12:40 am
by GeorgeMcGinn
There is no simulator that I know of.

I ordered a hardware kit to rebuild the Altair 8800.

The program was converted from the CP/M BASIC that ran on the Altair 8800.

Henko wrote:
Sat Mar 10, 2018 11:04 am
No Altair 8800 simulator in the (Dutch) app store.