M*5

This file is part of and Miscellaneous Programs. Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 2068

This is a solar system quiz game in which the player acts as the crew of a spaceship (the M*5) decelerating from warp drive to dock at Moon Base 2. The program presents multiple-choice questions about the nine planets (Mercury through Pluto), and each correct answer reduces the ship’s “actual speed” (SA) by 2000 MPH while each wrong answer reduces the “calculated speed” (SC); if SA drops to 2000 MPH before SC falls below 1000 MPH, the ship docks safely. Numeric variables are used as aliases for constants and subroutine line numbers (e.g. E=1, T=2, S=10, TH=1000, U=230, MB=200, G=2310), saving memory on a RAM-constrained machine. Questions are dispatched via a computed GO TO at line 1180 using the formula 1200+(QR*30)-5, selecting one of 36 question slots spread across 9 planets. The program includes a star-field subroutine (lines 50–110) that randomly prints either “*” or a block-graphic character to create a space backdrop.


Program Structure

The program begins at line 10 with GO TO 2800, which initialises all global variables before jumping to line 400 (the main screen drawing routine). Execution then flows into the story introduction (lines 570–990) and the main quiz loop (lines 1020–2470). Key subroutines are:

  • Lines 50–110 — Star-field renderer (called as GO SUB U, i.e. GO SUB 230… wait, U=230 which is the CLS routine; see below)
  • Lines 180–210 — Score display (GO SUB 180)
  • Lines 200–210 — Print IDENT panel (GO SUB MB, where MB=200)
  • Lines 230–270 — Screen clear (GO SUB U, where U=230)
  • Lines 310–370 — Replay prompt
  • Lines 410–480 — Main screen frame drawing
  • Lines 1020–2310 — Question loop with computed dispatch
  • Lines 2480–2560 — Successful docking/congratulations
  • Lines 2570–2660 — Crash/game-over sequence
  • Lines 2670–2690 — Bad-input error handler
  • Lines 2800–2960 — Initialisation block

Variable Aliases (Memory Optimisation)

Rather than embedding literal numbers throughout the code, the initialisation block at lines 2800–2880 assigns short numeric variables to frequently used constants and subroutine addresses. This reduces token storage for each reference and is a classic technique on RAM-limited machines.

VariableValueRole
E1General constant 1, also used as column/loop start
T2General constant 2
S10General constant 10
TH1000Speed decrement / threshold
R3 (E+T)Row 3 shorthand
U230CLS subroutine address
MB200Print-ident subroutine address
G2310Answer-check destination (end of question block)
P0 (NOT PI)First-play flag
K0 (NOT PI)Last question index (prevents repeat)

NOT PI evaluates to 0 because PI is non-zero, and NOT of any non-zero number returns 0 in Sinclair BASIC. This is used to initialise P and K without storing the literal 0.

Computed GO TO for Question Dispatch

Line 1180 uses the expression GO TO 1200+(QR*30)-5 to jump directly into one of 36 question stubs. QR is a random integer from 1 to 36, and each planet has four questions occupying slots spaced 30 lines apart starting at line 1230. The subtraction of 5 corrects for the 1-based index. All question stubs end with GO TO G (GO TO 2310), routing back to the answer-input and scoring section.

Question Selection and Planet Mapping

Lines 1090–1170 map QR to a planet name string stored in Q$ using cascading IF QR>N checks. Each planet owns four consecutive QR values (1–4, 5–8, …, 33–36). A repeat-prevention check at line 1070 re-rolls if QR=K (the last question asked).

Scoring Mechanics

Two speed variables track the game state:

  • SA — Actual speed, starts at 18000. Decremented by 2000 (TH*T) on a correct answer.
  • SC — Calculated speed, starts at 18000. Decremented by 1000 (TH) on a wrong answer.

Win condition (line 2390): SA <= TH*T (i.e. SA ≤ 2000) AND SC >= TH (i.e. SC ≥ 1000). If the player gets too many wrong answers, SC drops below 1000 first, triggering the crash sequence via GO SUB 300GO SUB 2570.

Star-Field Subroutine

Lines 50–110 iterate over a rectangular region of the screen (rows T to 15, columns E to S*R-E = 29) and print either "*" (with ~50% probability via INT(RND*S)+1 < 2) or a solid block character (). The subroutine is reached via GO SUB U — however, since U=230 this actually calls the CLS subroutine at line 230, not lines 50–110. Lines 50–110 appear to be unreachable dead code unless called from a line number not present in this listing.

Notable Techniques and Idioms

  • Block-graphic border: Lines 430–460 draw a full bordered rectangle using Spectrum block graphic characters (▗, ▄, ▖, ▐, █, ▌, ▝, ▀, ▘) for a polished framed display.
  • String aliases: F$, L$, and S$ hold repeated question fragments (“HAS A MOON NAMED “, “HAS AN ORBIT OF “, ” IN LINE FROM THE SUN”), saving RAM across 36 question lines.
  • FLASH E: Used in the crash sequence (lines 2610–2630) to produce flashing “DANGER” and “CRASH” text, with FLASH 0 to reset.
  • SAVE "M*5" LINE PI (line 2725): LINE PI evaluates to LINE 3 (since INT(PI)=3), so the program auto-runs from line 3 on load — though line 3 does not exist; the nearest line above is line 10, so execution will start there.
  • INVERSE E (i.e. INVERSE 1): Used extensively for highlighted speech labels such as “M*5 HERE” and “CAPTIAN HOOK HERE”.

Content

Related Products

Related Articles

Related Content

Image Gallery

M*5

Source Code

   10 GO TO 2800
   50 FOR N=T TO 15
   60 FOR A=E TO S*R-E
   80 PRINT AT N,A;
   90 IF INT (RND*S)+1<2 THEN PRINT "*": GO TO 110
  100 PRINT "█"
  110 NEXT A: NEXT N: RETURN 
  120 REM PRINT SCORE
  180 PRINT AT S*T,E;SA;AT 20,6;"/MPH ";AT 20,S+T;SC;AT 20,17;"/MPH ";AT 20,23;: RETURN 
  200 REM PRINT IDENT
  210 PRINT AT 20,23;: RETURN 
  230 REM CLS SCREEN
  250 FOR A=15 TO T STEP -E
  260 PRINT AT A,E;"                             "
  270 NEXT A: RETURN 
  310 GO SUB U: REM REPLAY
  320 INPUT "Do you wish to play again (Y/N)?";A$
  340 IF A$(E)="Y" THEN LET P=E: GO TO 2870
  350 IF A$(E)="N" THEN GO TO 2705
  370 GO SUB 2670: GO TO 310
  410 CLS : REM PLOT SCREEN$ 
  430 PRINT '"▗▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▖"
  440 FOR A=E TO 14
  450 PRINT "▐█████████████████████████████▌": NEXT A
  460 PRINT "▝▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▘"
  470 PRINT TAB S;"MAIN SCREEN"'" SPEED(ACT) SPEED(CAL) CONTROL"
  480 PRINT "▗▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▖ ▐          ▐          ▐       ▌ ▝▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▘"
  570 IF P=E THEN GO TO 1020
  580 PRINT AT S*T,E;"WARP-DRIVE";AT 20,S+T;"WARP-DRIVE";AT 20,23;"  M*5  "
  590 PAUSE U
  610 PRINT AT R,T; INVERSE E;"M*5 HERE-PREPARE TO LEAVE";AT 4,T;"WARP-DRIVE. NORMAL SPACE";AT 5,T;"IN 27 SECONDS"
  630 PAUSE U
  640 GO SUB 20
  750 GO SUB 180
  760 PRINT "BRIDGE "
  770 PAUSE TH/R
  790 PRINT AT T,T; INVERSE E;"M*5 HERE-WE HAVE EMERGED";AT PI,T;"FROM WARP-DRIVE AND ARE NOW";AT 4,T;"MOVING AT A SUB-LIGHT SPEED";AT 5,T;"18000/MPH. WE ARE NEARING";AT 6,T;"OUR SOLAR SYSTEM"
  800 PRINT AT 7,T; INVERSE E;"I WILL CONTROL THE SHIP'S";AT 8,T;"DEACCELERATION TO DOCKING";AT 9,T;"APPROACH FOR MOON BASE 2"
  810 GO SUB MB
  820 PRINT "  M*5  "
  830 PRINT AT S,T; INVERSE e;;"I WILL DISENGAGE AT 2000/MPH";AT 11,T;"TO LET THE DOCKING COMPUTER";AT 12,T;"HAVE CONTROL OF OUR SHIP";AT 13,T;"OUR ETA IS--AWRK^MARY HAD";AT 14,T;"A??1+1=3//BLRUP SORRY ABOUT";AT 15,T;"THAT"
  840 PAUSE TH+U
  850 GO SUB U
  860 GO SUB MB
  865 PRINT "BRIDGE"
  870 PRINT AT R,T;"CAPTIAN HOOK HERE-M*5; A";AT 4,T;"CHECK OF YOUR TROUBLE SHOWS";AT 5,T;"MAJOR DATA LOSS ABOUT OUR";AT 6,T;"SOLAR SYSTEM. YOU NEED ALL";AT 7,T;"DATA RE-INPUTTED"
  875 PAUSE 90: GO SUB MB
  876 GO SUB MB
  878 PRINT "  M*5  "
  880 PRINT AT S,T;"CAN THE CREW HELP ME?"
  885 PAUSE 90: GO SUB MB
  886 GO SUB MB
  888 PRINT "BRIDGE"
  890 PRINT AT 12,T;"OF COURSE, WE CAN, AND IF ";AT 13,T;"THE ANSWERS ARE CORRECT";AT 14,T;"YOU CAN CONTROL THE SHIP"
  910 PAUSE TH: GO SUB U
  913 GO SUB MB
  916 PRINT "  M*5  "
  920 PRINT AT R,T;"THANK YOU CAPTIAN, FOR THE";AT 4,T;"CORRECT ANSWER I WILL REDUCE";AT 5,T;"SHIP'S SPEED BY 2000 MPH.";AT 6,T;"WE MUST REDUCE SHIP'S SPEED";AT 7,T;" TO 2000 MPH BEFORE THE";AT 8,T;"CALCULATED SPEED REACHES";AT 9,T;"1000 MPH OR WE WILL CRASH."
  930 PRINT AT S,T;"QUESTIONS ARE ANSWERED BY";AT 11,T;"ENTERING A PLANET NAME"
  940 PAUSE 90
  950 PRINT AT S+R,T;"IS THE CREW READY?  (Y OR N)"
  955 GO SUB MB: PRINT "BRIDGE"
  960 INPUT B$
  965 IF B$="Y" THEN GO TO 1020
  970 IF B$="N" THEN GO TO 1E3
  980 IF B$<>"N" THEN GO SUB 2670
  990 GO TO 940
 1000 GO SUB 2570
 1010 GO TO 300
 1020 GO SUB MB
 1030 PRINT "  M*5  "
 1040 GO SUB 180
 1050 GO SUB U
 1060 PRINT AT R,E;"NAME THE PLANET THAT:";AT 4,T;
 1065 LET QR=INT (RND*36)+E
 1070 IF QR=K THEN GO TO 1010
 1080 LET K=QR
 1090 LET Q$="MERCURY"
 1100 IF QR>4 THEN LET Q$="VENUS"
 1110 IF QR>8 THEN LET Q$="EARTH"
 1120 IF QR>12 THEN LET Q$="MARS"
 1130 IF QR>16 THEN LET Q$="JUPITER"
 1140 IF QR>20 THEN LET Q$="SATURN"
 1150 IF QR>24 THEN LET Q$="URANUS"
 1160 IF QR>28 THEN LET Q$="NEPTUNE"
 1170 IF QR>32 THEN LET Q$="PLUTO"
 1180 GO TO 1200+(QR*30)-5
 1200 REM QUESTIONS
 1230 PRINT "IS 1ST";S$
 1250 GO TO G
 1270 PRINT L$;"88 DAYS"
 1280 GO TO G
 1290 PRINT "HAS A SURFACE TEMPERATURE OF"
 1300 PRINT AT 5,T;"430 DEG. C ON THE DAY SIDE";AT 6,T;"-170 C ON THE NIGHT SIDE"
 1310 GO TO G
 1320 PRINT "HAS THE LONGEST DAY"
 1340 GO TO G
 1360 PRINT "IS 2ND";S$
 1370 GO TO G
 1380 PRINT "IS COVERED WITH THICK CLOUDS";AT 5,T;"OF SULFURIC ACID"
 1400 GO TO G
 1410 PRINT L$;"255 DAYS"
 1430 GO TO G
 1440 PRINT "WAS NAMED FOR A GREEK";AT 5,T;"GODDESS"
 1460 GO TO G
 1470 PRINT "IS 3RD";S$
 1490 GO TO G
 1500 PRINT "IS THE ONLY PLANET KNOWN TO ";AT 5,T;"SUPPORT LIFE"
 1520 GO TO G
 1530 PRINT "IS 149,600,000 KM FROM THE";AT 5,T;"SUN. (APPROX. 93 MILLION";AT 6,T;"MILES)"
 1550 GO TO G
 1560 PRINT L$;"365 DAYS"
 1580 GO TO G
 1590 PRINT "IS 4TH";S$
 1610 GO TO G
 1620 PRINT "IS KNOWN AS THE ""RED PLANET"""
 1640 GO TO G
 1650 PRINT "HAS A VARIABLE SURFACE";AT 5,T;"TEMPERATURE AVERAGING -50";AT 6,T;"DEG. C"
 1670 GO TO G
 1680 PRINT "HAS  CANALS "
 1700 GO TO G
 1720 PRINT "IS 5TH";S$
 1730 GO TO G
 1750 PRINT L$;"11.86 YEARS"
 1760 GO TO G
 1770 PRINT F$;" EUROPA "
 1790 GO TO G
 1800 PRINT "HAS A RED SPOT"
 1820 GO TO G
 1830 PRINT "IS 6TH";S$
 1850 GO TO G
 1860 PRINT "IS THE 2ND LARGEST PLANET IN";AT 5,T;"OUR SOLAR SYSTEM"
 1880 GO TO G
 1890 PRINT "HAS 7 MAJOR RINGS"
 1910 GO TO G
 1920 PRINT F$;"TITAN"
 1940 GO TO G
 1950 PRINT "IS 7TH";S$
 1970 GO TO G
 1980 PRINT "HAS 9 MAJOR RINGS"
 2000 GO TO G
 2010 PRINT "HAS A TEMPERATURE OF -215";AT 5,T;"DEG. C AT THE CLOUD TOPS"
 2030 GO TO G
 2040 PRINT L$;"84 YEARS"
 2060 GO TO G
 2070 PRINT "IS 8TH";S$
 2090 GO TO G
 2100 PRINT F$;" TRITON "
 2120 GO TO G
 2140 PRINT L$;"165 YEARS"
 2150 GO TO G
 2160 PRINT "IS THE 4TH LARGEST"
 2180 GO TO G
 2190 PRINT "IS 9TH";S$
 2210 GO TO G
 2220 PRINT "IS THE COLDEST"
 2240 GO TO G
 2250 PRINT L$;"248 YEARS"
 2270 GO TO G
 2290 PRINT F$;" CHARON "
 2310 GO SUB MB
 2320 PRINT "BRIDGE"
 2330 INPUT " INPUT DATA ";B$
 2340 PRINT AT S-T,R*T;"CREW'S ANSWER-:";B$;AT S,T;"CORRECT ANSWER-:";Q$
 2350 IF B$=Q$ THEN GO TO 2370
 2360 IF B$<>Q$ THEN GO TO 2390
 2370 LET SA=SA-(TH*T)
 2380 PRINT AT S*T,E;"     ";AT S*T,E;SA
 2390 IF SA<=TH*T AND SC>=TH THEN GO TO 2480
 2400 LET SC=SC-TH
 2410 PRINT AT S*T,S+T;"     ";AT S*T,S+T;SC
 2420 PAUSE U
 2425 IF SC=TH THEN GO SUB 2570
 2430 IF SC>=TH THEN GO TO 2460
 2440 GO SUB 300
 2470 GO TO 1050
 2480 GO SUB MB
 2490 PRINT "DOCKING"
 2510 PAUSE U: GO SUB U
 2520 REM LANDING
 2530 PRINT AT R,T;"***CONGRATULATIONS***";AT 4,T;"YOU HAVE SURVIVED THE";AT 5,T;"CRISIS. PREPARE FOR A SAFE";AT 6,T;"LANDING AT MOON BASE 2 AND ";AT 7,T;"ENJOY YOUR STAY"
 2560 PAUSE TH: GO SUB 310
 2570 REM ALL-OVER
 2580 GO SUB U
 2590 PRINT AT T+R,T;"ALL HOPE IS LOST NO ONE CAN";AT 6,T;"HELP US NOW";AT S-T,T;"DISASTER PROCEEDINGS"
 2600 FOR A=E TO S*R
 2610 PRINT AT S-T,24; FLASH E;"NOW";AT R,R+T;"DANGER"; FLASH 0;TAB 21; FLASH E;"DANGER"
 2615 NEXT A
 2630 PRINT AT 14,S+E; FLASH E;"CRASH"
 2650 PAUSE 0
 2660 GO SUB U
 2670 REM BAD INPUT 
 2675 GO SUB U
 2680 PRINT AT R,T; FLASH E;"UNUSABLE INPUT PLEASE WAIT"
 2690 PAUSE TH/T: RETURN 
 2705 CLS 
 2710 PRINT AT S+T,S+T;"GOODBY": PAUSE 120: NEW 
 2725 SAVE "M*5" LINE PI
 2800 LET E=1: LET T=2: LET S=10
 2810 LET TH=1e3
 2820 LET F$="HAS A MOON NAMED "
 2830 LET L$="HAS AN ORBIT OF "
 2840 LET S$=" IN LINE FROM THE SUN"
 2850 LET R=E+T: LET G=2310
 2860 LET P=NOT PI: LET U=230
 2870 LET SA=18E3: LET SC=SA
 2880 LET MB=200: LET K=NOT PI
 2960 GO TO 400

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top