Learning to code 1980s style

When personal computers first came out in the 1980s, there were no free compilers, except BASIC. Most systems came with a BASIC compiler of some sort. Then came the proliferation of  “games” written in BASIC, and published in books that the

One book I had when I was in high-school, was Computer Spacegames (1982), which seemed really cool looking at the cover, but it was actually really crap. But then again, my computer was an Apple IIe, and I had no clue about programming really, I just copied the code into a file, and ran it. Here’s one program – Moonlander.

10 CLS
20 PRINT "MOONLANDER"
30 LET T=0
40 LET H=500
50 LET V=50
60 LET F=120
70 PRINT "TIME";T
75 PRINT "HEIGHT";H
80 PRINT "VELOCITY";V
85 PRINT "FUEL";F
90 IF F=0 THEN GOTO 140
100 PRINT "BURN? (0-30)"
110 INPUT B
120 IF B<0 THEN LET B=0
130 IF B>30 THEN LET B=30
140 IF B>F THEN LET B=F
150 LET V1=V-B+5
160 LET F=F-B
170 IF (V1+V)/2>=H THEN GOTO 220
180 LET H=H-(V1+V)/2
190 LET T=T+1
200 LET V=V1
210 GOTO 70
220 LET V1=V+(5-B)*H/V
230 IF V1>5 THEN PRINT "YOU CRASHED-ALL DEAD"
240 IF V1>1 AND V1<=5 THEN PRINT "OK-BUT SOME INJURIES"
250 IF V1<=1 THEN PRINT "GOOD LANDING"
260 STOP

It taught some basics about program code, most notably IF statements to make decisions,  LET statements to assign values, and of course GOTO. Short programs sometimes worked, but more often than not the longer the program was, the less likelihood it would work.

Want to have fun with [crappy] basic programs? Try this site.

Advertisements

One thought on “Learning to code 1980s style

  1. codeinfig says:
    X CLS
    X="MOONLANDER" : PRINT
    T=0
    H=500
    V=50
    F=120
    
    WHILE
    X="TIME "     : PRINTS 
    X=T           : PRINT
    X="HEIGHT "   : PRINTS
    X=H           : PRINT
    X="VELOCITY " : PRINTS
    X=V           : PRINT
    X="FUEL "     : PRINTS
    X=F           : PRINT
    
    IFEQUAL F 0 
    
    PASS
    ELSE
    X="BURN? (0-30) " : PRINTS
    B LINEINPUT : INT
    IFLESS B 0
    B=0
    RESUME
    IFMORE B 30
    B=30
    RESUME
    
    RESUME
    
    IFMORE B F
    B=F
    RESUME
    
    V1=V MINUS B PLUS 5
    X F MINUS B : SWAP X F
    
    V1V2 V1 PLUS V DIVBY 2
    IFLESS V1V2 H
    PASS
    ELSE
    BREAK
    RESUME
    X=H MINUS V1V2 : SWAP X H
    X=T PLUS 1 : SWAP X T
    V=V1
    WEND
    
    V1=5 MINUS B TIMES H DIVBY V PLUS V
    IFMORE V1 5
    X="YOU CRASHED-ALL DEAD" : PRINT
    RESUME
    
    IFMORE V1 1 
    IFMORE V1 5  
    PASS 
    ELSE 
    X="OK-BUT SOME INJURIES" : PRINT
    RESUME
    RESUME
    
    IFMORE V1 1 
    PASS 
    ELSE 
    X="GOOD LANDING" : PRINT
    RESUME
    
    X END
    

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s