You are in charge of Starship Astron and have just completed a mission in the outer limits of the galaxy. Having already landed your own craft safely you must land your radio controlled drones onto the constantly moving landing platform.
Program Analysis
Cosmos Landing is a ZX81/TS1000 landing simulation game in which the player guides radio-controlled drones onto a moving platform scrolling across the bottom of the screen. The player presses “0” or “1” to move the drone left or right, aiming to align it with a platform that bounces back and forth across the display over ten attempts. Three difficulty levels (Hard, Medium, Easy) are implemented by varying the descent increment per iteration: 0.25, 0.5, or 1.0 rows per loop, giving the player more or fewer steps to correct their approach. The moving platform is rendered using PRINT AT with a star-field backdrop of 50 randomly placed dots drawn in FAST mode before switching back to SLOW for the interactive descent loop. After ten rounds, the program calculates a score ratio and assigns one of six pilot ratings stored in D$.
Program Structure
The program is organised into a main game loop with a subroutine for instructions. The top-level flow is as follows:
- Lines 1–9: Initialise score variables
P(safe landings) andQ(total attempts); offer instructions. - Lines 10–160: Set up each round — choose platform direction
B, drone start columnA, and read difficulty level intoI. - Lines 170–340: Draw the star-field in FAST mode, then run the descent loop in SLOW mode.
- Lines 350–440: Evaluate the landing, update scores, loop for up to 10 rounds.
- Lines 450–580: Display final score and rating; offer another game via
RUN. - Lines 585–720: Instructions subroutine, entered from line 8, returning at line 720.
- Lines 730–750:
CLEARandSAVEutility lines.
Game Mechanics
The drone starts at a random column T (0–27) and descends row by row from row 0 to row 20. The platform moves horizontally, bouncing off columns 2 and 25 using the expression at line 250:
LET B=(A=2)-(A=25)+B*(A>2 AND A<25)
This single-line idiom reverses direction B at the boundaries without any IF statement. A landing is successful only if T=A+1 (line 350), requiring precise alignment. The player steers with “0” (right) and “1” (left) via INKEY$ polled inside the descent loop at line 270.
Difficulty and Descent Speed
Difficulty is implemented by setting I to 0.25, 0.5, or 1.0 for Hard, Medium, or Easy respectively. Row position accumulates as S=S+1/I per loop iteration, so Hard mode takes up to 80 iterations to reach row 20 while Easy takes only 20. This elegantly gives the player more reaction time at lower skill levels.
Key BASIC Idioms
- Boolean arithmetic for direction:
B=(RND>.5)-(RND<.5)at line 10 produces −1, 0, or +1, though 0 is filtered out at line 15. - Wrapping with Boolean:
T=T+(T=0)-(T=28)at line 280 wraps the drone position without conditionals. - FAST/SLOW toggling: Line 160 switches to FAST to draw 50 random stars quickly, then line 240 returns to SLOW for interactive play — a standard ZX81 technique to avoid slow screen rendering during setup.
- INKEY$ polling loop: Lines 7, 110, and 570 each use the
IF INKEY$="" THEN GOTO selfpattern to wait for any keypress.
Scoring and Rating System
After 10 rounds (Q=10), the ratio W=(P/Q)*10 is computed and matched to one of six rating strings. The ratings are:
| W range | Rating |
|---|---|
| W = 10 | SUPREME COMMANDER OF THE WORLD PILOTS ASSOCIATION |
| 7 < W < 10 | SUPREM AIR FLEET COMMANDER |
| 5 < W < 8 | PROFFESSIONAL AIRCRAFT LANDER |
| 3 < W < 6 | AMATEUR AIRCRAFT LANDER |
| 1 < W < 4 | I AM GLAD THIS IS ONLY A COMPUTER SIMULATION |
| W < 2 | DANGEROUS UNCOORDINATED IDIOT |
Note that the range 1 < W < 4 uses a different print path (lines 535–540) that skips the “YOUR RATING IS-” prefix, printing the string alone before jumping to line 560. This appears intentional for comedic effect at that tier.
Bugs and Anomalies
- Double INKEY$ read (lines 7–8): Line 7 waits until a key is pressed, then line 8 checks if that key is “Y”. However, by the time execution reaches line 8 the key may already have been released, causing the “Y” check to fail silently and skip instructions even when intended. A single read into a variable would be more reliable.
- Rating gap at W=2: The conditions
W>1 AND W<4andW<2overlap slightly at non-integer values but leave W exactly equal to 2 uncovered by the lowest tier and ambiguously in the second-lowest tier only — an edge case unlikely in practice since W is always a multiple of 1 (integer landings out of 10). - Spelling errors: “SUPREM” (line 490) and “PROFFESSIONAL” (line 500) are present in the original listing.
- Line 120 INKEY$ race: Like lines 7–8, line 120 checks INKEY$ immediately after line 110 releases the key, which may already be empty; the “0” option for viewing scores may be unreliable.
- Drone display character: The drone is rendered as
<\~~>using the ZX81 block graphic tilde characters, giving a small spacecraft silhouette.
Content
Source Code
1 LET P=0
3 LET Q=0
6 PRINT "DO YOU WANT INSTRUCTIONS"
7 IF INKEY$="" THEN GOTO 7
8 IF INKEY$="Y" THEN GOSUB 585
9 CLS
10 LET B=(RND>.5)-(RND<.5)
15 IF B=0 THEN GOTO 10
20 LET A=INT (RND*23)+2
25 LET E=0
40 LET S=0
50 LET T=INT (RND*28)
60 PRINT AT 8,6;"INPUT DIFFICULTY."
70 PRINT AT 10,8;"1=HARD"
80 PRINT AT 11,8;"2=MEDIUM"
90 PRINT AT 12,8;"3=EASY"
100 IF Q>0 THEN PRINT AT 14,0;"IF YOU WANT A SCORE AND RATING THEN PRESS 0."
110 IF INKEY$="" THEN GOTO 110
120 IF INKEY$="0" THEN GOTO 450
130 IF INKEY$="1" THEN LET I=0.25
140 IF INKEY$="2" THEN LET I=0.5
150 IF INKEY$="3" THEN LET I=1
160 FAST
170 CLS
180 FOR U=1 TO 50
190 LET U1=INT (RND*31)
200 LET U2=INT (RND*17)
210 PRINT AT U2,U1,"."
220 NEXT U
230 PRINT AT 21,0;"% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % "
240 SLOW
250 LET B=(A=2)-(A=25)+B*(A>2 AND A<25)
260 LET A=A+B
270 LET T=T+(INKEY$="0")-(INKEY$="1")
280 LET T=T+(T=0)-(T=28)
290 PRINT AT S,T;"<\~~>"
300 PRINT AT 20,A;" % \;;\;;\;;% "
310 PRINT AT 20,0;" "
320 LET S=S+1/I
330 IF S=20 THEN GOTO 350
340 GOTO 250
350 IF T=A+1 THEN GOTO 380
360 PRINT AT 5,5;"YOU HAVE CRASHED"
370 GOTO 400
380 PRINT AT 5,7;"SAFE LANDING"
390 LET P=P+1
400 LET Q=Q+1
410 IF Q=10 THEN GOTO 450
420 PRINT AT S,T;"<\~~>"
425 PAUSE 200
430 CLS
440 GOTO 20
450 CLS
460 PRINT "YOU LANDED SAFELY ",P;" TIMES OUT OF ",Q
470 LET W=(P/Q)*10
480 IF W=10 THEN LET D$="SUPREME COMMANDER OF THE WORLD PILOTS ASSOCIATION"
490 IF W>7 AND W<10 THEN LET D$="SUPREM AIR FLEET COMMANDER"
500 IF W>5 AND W<8 THEN LET D$="PROFFESSIONAL AIRCRAFT LANDER"
510 IF W>3 AND W<6 THEN LET D$="AMATEUR AIRCRAFT LANDER"
520 IF W>1 AND W<4 THEN LET D$="I AM GLAD THIS IS ONLY A COMPUTER SIMULATION"
530 IF W<2 THEN LET D$="DANGEROUS UNCOORDINATED IDIOT"
535 IF W>1 AND W<4 THEN PRINT D$
540 IF W>1 AND W<4 THEN GOTO 560
550 PRINT "YOUR RATING IS-",D$
560 PRINT AT 8,6;"ANOTHER GO?"
570 IF INKEY$="" THEN GOTO 570
580 RUN
585 CLS
590 PRINT AT 1,8;"COSMOS LANDING"
610 PRINT AT 3,0;"YOU ARE IN CHARGE OF STARSHIP ";
611 PRINT "ASTRON AND HAVE JUST COMPLETED AMISSION IN THE OUTER";
620 PRINT " LIMITS OF THE GALAXY"
630 PRINT AT 7,0;"HAVING ALREADY LANDED YOUR OWN CRAFT SAFELY YOU MUST LAND YOUR";
640 PRINT "RADIO CONTROLLED DRONES ONTO THE CONSTANTLY MOVING LANDING"
650 PRINT "PLATFORM"
660 PRINT "TO OPERATE THE RADIO SIGNAL "
665 PRINT "PRESS 1 FOR LEFT AND 0 FOR RIGHT"
670 PRINT "THERE ARE THREE DIFFERENT"
680 PRINT "LANDING SPEEDS DEPENDING ON HOW SKILLED YOU ARE"
690 PRINT "YOU HAVE TEN DRONES TO LAND"
710 PAUSE 40000
720 RETURN
730 CLEAR
740 SAVE "1031%3"
750 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
