Space Crisis

This file is part of Timex Sinclair Public Domain Library Tape 1001 . Download the collection to get this file.
Developer(s): Ronald Duguid
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Game

Space Crisis is an educational quiz game in which players must correctly name planets of the solar system to decelerate a starship from 18,000 MPH to 1,000 MPH before the ship’s calculated speed also drops to 1,000 MPH — a race against a dual-speed countdown that determines whether the crew survives or crashes on Moonbase 2. The program draws a schematic starfield/ship display using individual PLOT commands to render horizontal and vertical boundary lines on the low-resolution graphics screen. Question selection uses a computed GOTO via LET Q=1200+(QR*4) followed by GOTO Q, routing to one of 27 question blocks covering all nine classical planets (including Pluto). The narrative is delivered through a subroutine at line 2000 that clears the ship’s interior text area by printing blank strings across rows 2–15 in FAST mode, preserving the plotted border graphics. A replay flag variable P at line 18 is used to skip the introductory story sequence on subsequent playthroughs.


Program Analysis

Program Structure

The program is divided into clearly separated narrative and gameplay phases, linked by subroutines and computed jumps. The main flow is:

  1. Initialisation (lines 18–44): All variables zeroed; SA (actual speed) and SC (calculated speed) both set to 18000.
  2. Screen setup and starfield drawing (lines 165–320): Plots border and grid lines using nested FOR/NEXT loops with individual PLOT calls.
  3. Introductory story sequence (lines 322–550): Multi-screen narrative in SLOW mode with PAUSE delays; skipped on replay via flag P=1.
  4. Question loop (lines 990–1465): Core gameplay — question selection, display, answer input, speed adjustment, win/loss detection.
  5. Subroutines: screen-clear (2000), crash message (2500), improper-input handler (3000), play-again (3500).

Computed GOTO for Question Dispatch

The most technically notable feature is the question-routing mechanism. A random number QR is drawn from 1–27, and the correct planet name string Q$ is set by a chain of IF tests (lines 1025–1065). The target line number is then computed:

LET Q=1200+(QR*4) followed by GOTO Q

This maps each of the 27 question slots to a line in the range 1204–1308 in steps of 4, giving three questions per planet. The line numbers 1200, 1204, 1208… 1308 must therefore exist exactly at those values, which they do. This is an efficient dispatch table implemented entirely in BASIC arithmetic.

Dual-Speed Countdown Mechanic

Two speed variables drive the win/loss condition:

VariableLabelStarting ValueDecrement
SASPEED(ACT) — actual speed18000−1000 per correct answer
SCSPEED(CAL) — calculated speed18000−500 per question (right or wrong)

The win condition at line 1390 is SA<=1000 AND SC>=1000 — the player must reduce actual speed to 1000 MPH before the calculated speed falls below 1000 MPH. Since SC drops twice as fast per question as SA drops per correct answer (500 vs 1000), wrong answers are especially costly: the calculated speed still drops while the actual speed does not. The player therefore has at most 34 questions before SC reaches 1000 (18000/500 = 36 steps minus the initial pause steps), requiring at least 17 correct answers.

Screen-Clear Subroutine

Rather than using CLS (which would erase the plotted border graphics), the subroutine at line 2000 blanks only rows 2–15 by printing a 29-space string at each row in FAST mode. The loop increments H from 2 upward and exits at H>=16. This preserves the PLOT-drawn frame while refreshing the text area for each new narrative screen.

Replay Mechanism

The flag variable P is set to 1 at line 3570 when the player chooses to replay. On re-entry at line 20, the initialisation resets speeds and counters but not P itself (it is reset to 0 in the main init block at line 20, then re-checked at line 323: IF P=1 THEN GOTO 990). However, P is set to 0 at line 20 (LET A=0LET P=0), so the skip will never trigger — this is a bug. The intent was presumably to jump past the long story sequence on subsequent plays, but because P is zeroed before the check, the full intro always replays.

Question Repeat Prevention

Line 1015 checks IF QR=K THEN GOTO 1010, where K holds the previous question number. This prevents the same question from appearing twice in a row, though it does not prevent longer-range repeats across the game session.

Key BASIC Idioms

  • FAST/SLOW mode switching is used extensively — FAST for PLOT-intensive drawing and text-clearing loops, SLOW for narrative PRINT and PAUSE sequences.
  • The improper-input handler at line 3000 is a subroutine called from multiple input validation points (lines 920, 3550), providing a consistent “IMPROPER INPUT” response.
  • INPUT B$ followed by string comparison against “Y”/”N” is the standard ZX81 menu idiom used at lines 880–930 and 3520–3560.
  • The TAB keyword within PRINT statements (lines 322, 398) is used to align the three-column status bar at the bottom of the screen.

Anomalies and Notes

  • Line 1360 (IF A$<>Q$ THEN GOTO 1390) is redundant — after line 1355 branches away on equality, execution always reaches 1360 when the answer is wrong, making the conditional unnecessary.
  • Line 1450 (IF SC<1000 THEN GOSUB 2500 at line 1440) is followed by GOSUB 3500 at line 1445 without a RETURN guard, meaning the play-again sequence always runs after a crash, which is correct behaviour.
  • Lines 3585–3600 (CLEAR, SAVE, RUN) are unreachable dead code, never called from any branch in the program.
  • The variable H is reused for two unrelated purposes: row counter in the starfield drawing loops (lines 339–392) and row counter in the screen-clear subroutine (line 2020). This is safe because the subroutine reinitialises H=2 at entry.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10001 – 10050.

Related Products

Related Articles

Seeding the RND function for greater randomness.

Related Content

Image Gallery

Space Crisis

Source Code

   1 REM "SPACE CRISIS"
   2 REM 
   3 REM RONALD DUGUID
   4 REM SYNC MAGAZINE
   5 REM JANUARY/FEBRUARY 1983
   6 REM 
  18 LET P=0
  20 LET A=0
  22 LET G=0
  24 LET H=0
  26 LET J=0
  28 LET K=0
  32 LET M=0
  34 LET N=0
  38 LET Q=0
  40 LET SA=18000
  42 LET SC=18000
  44 LET QR=0
 165 CLS 
 170 FAST 
 175 FOR A=1 TO 60
 180 PLOT A,41
 185 NEXT A
 190 FOR A=1 TO 60
 195 PLOT A,10
 200 NEXT A
 205 FOR A=1 TO 60
 210 PLOT A,4
 215 NEXT A
 220 FOR A=1 TO 60
 225 PLOT A,0
 230 NEXT A
 235 FOR A=1 TO 4
 240 PLOT 1,A
 245 NEXT A
 250 FOR A=1 TO 4
 255 PLOT 22,A
 260 NEXT A
 265 FOR A=1 TO 4
 270 PLOT 44,A
 275 NEXT A
 280 FOR A=1 TO 4
 285 PLOT 60,A
 290 NEXT A
 295 FOR A=1 TO 31
 300 PLOT 1,10+A
 305 NEXT A
 310 FOR A=1 TO 31
 315 PLOT 60,10+A
 320 NEXT A
 322 PRINT AT 18,1;"SPEED(ACT)";TAB 12;"SPEED(CAL)";TAB 23;"CONTROL"
 323 IF P=1 THEN GOTO 990
 324 PRINT AT 20,1;"HYPER-WARP";TAB 12;"HYPER-WARP";TAB 23;"ALEC"
 325 PAUSE 750
 330 SLOW 
 333 PRINT AT 3,2;"ALEC HERE-PREPARE TO LEAVE"
 334 PRINT AT 4,2;"HYPER-WARP. NORMAL SPACE"
 335 PRINT AT 5,2;"IN 27 SECONDS"
 337 PAUSE 350
 338 FAST 
 339 LET H=1
 340 FOR G=1 TO 29
 342 LET J=INT (RND*10)+1
 344 IF J=1 THEN GOTO 350
 346 IF J>=2 THEN GOTO 355
 350 PRINT AT H,G;"%*"
 352 GOTO 360
 355 PRINT AT H,G;"% "
 360 IF G<=28 THEN GOTO 390
 370 LET H=H+1
 375 IF H>=17 THEN GOTO 392
 380 GOTO 340
 390 NEXT G
 396 LET C$="BRIDGE"
 398 PRINT AT 20,1;SA;TAB 6;"/MPH ";TAB 12;SC;TAB 17;"/MPH ";TAB 23;C$
 400 PAUSE 500
 405 SLOW 
 410 PRINT AT 2,2;"ALEC HERE-WE HAVE EMERGED"
 420 PRINT AT 3,2;"FROM HYPER-WARP AND ARE"
 430 PRINT AT 4,2;"NOW MOVING AT A SUB-LIGHT"
 440 PRINT AT 5,2;"SPEED OF 18000/MPH. WE ARE"
 450 PRINT AT 6,2;"APPROACHING OUR SOLAR"
 460 PRINT AT 7,2;"SYSTEM. I WILL TAKE"
 470 PRINT AT 8,2;"CONTROL OF THE SHIP FOR"
 480 PRINT AT 9,2;"DECELERATION TO DOCKING"
 490 PRINT AT 10,2;"APPROACH FOR MOON BASE 2."
 495 PRINT AT 20,23;"ALEC  "
 500 PRINT AT 11,2;"I WILL DE-CONTROL AT 1000"
 510 PRINT AT 12,2;"MPH TO LET THE DOCKING"
 520 PRINT AT 13,2;"COMPUTER TAKE CONTROL OF"
 530 PRINT AT 14,2;"THE SHIP. OUR ETA IS--AWK?"
 540 PRINT AT 15,2;"**MARY HAD A??1+1=2//BLEEP??"
 550 PAUSE 1500
 553 LET H=2
 555 GOSUB 2000
 640 PRINT AT 2,2;"PROFESSOR CYPHER HERE-ALEC,"
 650 PRINT AT 3,2;"YOU HAVE NOT BEEN STUDYING"
 660 PRINT AT 4,2;"YOUR INFORMATION TAPES."
 670 PRINT AT 5,2;"YOU HAVE WRONG ANSWERS ON"
 680 PRINT AT 6,2;"ALL THE QUESTIONS ABOUT"
 690 PRINT AT 7,2;"OUR SOLAR SYSTEM. YOU WILL"
 700 PRINT AT 8,2;"HAVE TO DO THEM OVER."
 710 PRINT AT 10,2;"CAN THE CREW HELP ME?"
 720 PRINT AT 12,2;"OF COURSE THEY CAN. AND, IF"
 730 PRINT AT 13,2;"THE ANSWERS ARE CORRECT, YOU"
 740 PRINT AT 14,2;"CAN CONTROL THE SHIP."
 750 PAUSE 1000
 760 GOSUB 2000
 770 PRINT AT 2,2;"YES, PROFESSOR, AND FOR A"
 780 PRINT AT 3,2;"CORRECT ANSWER, I WILL"
 790 PRINT AT 4,2;"DECELERATE THE SPEED BY"
 800 PRINT AT 5,2;"1000 MPH. THEY MUST REDUCE"
 810 PRINT AT 6,2;"THE SHIP SPEED TO 1000 MPH"
 820 PRINT AT 7,2;"BEFORE THE CALCULATED SPEED"
 830 PRINT AT 8,2;"REACHES 1000 MPH, OR THEY"
 840 PRINT AT 9,2;"WILL CRASH ON MOONBASE 2."
 850 PRINT AT 11,2;"QUESTIONS ARE ANSWERED BY"
 860 PRINT AT 12,2;"ENTERING A PLANET NAME."
 870 PRINT AT 14,2;"ARE YOU READY CREW? Y OR N"
 880 INPUT B$
 890 IF B$="Y" THEN GOTO 990
 900 IF B$="N" THEN GOTO 940
 920 IF B$<>"N" THEN GOSUB 3000
 930 GOTO 870
 940 GOSUB 2500
 950 GOTO 3500
 990 PRINT AT 20,23;"     "
 992 PRINT AT 20,1;SA;TAB 6;"/MPH ";TAB 12;SC;TAB 17;"/MPH ";TAB 23;"ALEC"
\n1000 GOSUB 2000
\n1003 PRINT AT 2,1;"NAME THE PLANET THAT:"
\n1010 LET QR=INT (RND*27)+1
\n1015 IF QR=K THEN GOTO 1010
\n1020 LET K=QR
\n1025 IF QR<=3 THEN LET Q$="MERCURY"
\n1030 IF QR>3 AND QR<=6 THEN LET Q$="VENUS"
\n1035 IF QR>6 AND QR<=9 THEN LET Q$="EARTH"
\n1040 IF QR>9 AND QR<=12 THEN LET Q$="MARS"
\n1045 IF QR>12 AND QR<=15 THEN LET Q$="JUPITER"
\n1050 IF QR>15 AND QR<=18 THEN LET Q$="SATURN"
\n1055 IF QR>18 AND QR<=21 THEN LET Q$="URANUS"
\n1060 IF QR>21 AND QR<=24 THEN LET Q$="NEPTUNE"
\n1065 IF QR>24 AND QR<=27 THEN LET Q$="PLUTO"
\n1070 LET Q=1200+(QR*4)
\n1075 GOTO Q
\n1200 REM %S%O%L%A%R% %Q%U%E%S%T%I%O%N%S% % % % % % % % 
\n1204 PRINT AT 3,2;"IS FIRST IN LINE FROM THE"
\n1205 PRINT AT 4,2;"SUN."
\n1207 GOTO 1350
\n1208 PRINT AT 3,2;"REVOLVES AROUND THE SUN ONCE"
\n1209 PRINT AT 4,2;"EVERY 88 DAYS."
\n1211 GOTO 1350
\n1212 PRINT AT 3,2;"HAS A SURFACE TEMPERATURE OF"
\n1213 PRINT AT 4,2;"430 DEG. C ON THE DAY SIDE;"
\n1214 PRINT AT 5,2;"-170 C ON THE NIGHT SIDE."
\n1215 GOTO 1350
\n1216 PRINT AT 3,2;"IS 2ND IN LINE FROM THE SUN."
\n1219 GOTO 1350
\n1220 PRINT AT 3,2;"IS COVERED WITH THICK CLOUDS"
\n1221 PRINT AT 4,2;"OF SULFURIC ACID."
\n1223 GOTO 1350
\n1224 PRINT AT 3,2;"REVOLVES AROUND THE SUN ONCE"
\n1225 PRINT AT 4,2;"EVERY 225 DAYS."
\n1227 GOTO 1350
\n1228 PRINT AT 3,2;"IS 3RD IN LINE FROM THE SUN."
\n1231 GOTO 1350
\n1232 PRINT AT 3,2;"IS THE ONLY PLANET KNOWN TO"
\n1233 PRINT AT 4,2;"SUPPORT LIFE."
\n1235 GOTO 1350
\n1236 PRINT AT 3,2;"IS 149,600,000 KM FROM THE"
\n1237 PRINT AT 4,2;"SUN. (APPROX. 93 MILLION"
\n1238 PRINT AT 5,2;"MILES.)"
\n1239 GOTO 1350
\n1240 PRINT AT 3,2;"IS 4TH IN LINE FROM THE SUN."
\n1243 GOTO 1350
\n1244 PRINT AT 3,2;"IS KNOWN AS-THE RED PLANET."
\n1247 GOTO 1350
\n1248 PRINT AT 3,2;"HAS A VARIABLE SURFACE"
\n1249 PRINT AT 4,2;"TEMPERATURE AVERAGING MINUS"
\n1250 PRINT AT 5,2;"50 DEG C."
\n1251 GOTO 1350
\n1252 PRINT AT 3,2;"IS 5TH IN LINE FROM THE SUN."
\n1255 GOTO 1350
\n1256 PRINT AT 3,2;"REVOLVES AROUND THE SUN ONCE"
\n1257 PRINT AT 4,2;"EVERY 11.86 YEARS."
\n1259 GOTO 1350
\n1260 PRINT AT 3,2;"HAS A MAJOR MOON NAMED-"
\n1261 PRINT AT 4,2;"EUROPA."
\n1263 GOTO 1350
\n1264 PRINT AT 3,2;"IS 6TH IN LINE FROM THE SUN."
\n1267 GOTO 1350
\n1268 PRINT AT 3,2;"IS THE 2ND LARGEST PLANET IN"
\n1269 PRINT AT 4,2;"OUR SOLAR SYSTEM."
\n1271 GOTO 1350
\n1272 PRINT AT 3,2;"HAS SEVEN RINGS."
\n1275 GOTO 1350
\n1276 PRINT AT 3,2;"IS 7TH IN LINE FROM THE SUN."
\n1279 GOTO 1350
\n1280 PRINT AT 3,2;"HAS NINE RINGS."
\n1283 GOTO 1350
\n1284 PRINT AT 3,2;"HAS A TEMPERATURE OF -215"
\n1285 PRINT AT 4,2;"DEG. C AT THE CLOUD TOPS."
\n1287 GOTO 1350
\n1288 PRINT AT 3,2;"IS 8TH IN LINE FROM THE SUN."
\n1291 GOTO 1350
\n1292 PRINT AT 3,2;"HAS A MOON NAMED-TRITON."
\n1295 GOTO 1350
\n1296 PRINT AT 3,2;"REVOLVES AROUND THE SUN ONCE"
\n1297 PRINT AT 4,2;"EVERY 165 YEARS."
\n1299 GOTO 1350
\n1300 PRINT AT 3,2;"IS 9TH IN LINE FROM THE SUN."
\n1303 GOTO 1350
\n1304 PRINT AT 3,2;"IS THE SMALLEST PLANET IN"
\n1305 PRINT AT 4,2;"OUR SOLAR SYSTEM."
\n1307 GOTO 1350
\n1308 PRINT AT 3,2;"HAS A MOON NAMED-CHARON."
\n1350 INPUT A$
\n1353 PRINT AT 8,2;"   YOUR ANSWER-";A$
\n1354 PRINT AT 10,2;"CORRECT ANSWER-";Q$
\n1355 IF A$=Q$ THEN GOTO 1365
\n1360 IF A$<>Q$ THEN GOTO 1390
\n1365 LET SA=SA-1000
\n1375 PRINT AT 20,1;"     "
\n1385 PRINT AT 20,1;SA
\n1390 IF SA<=1000 AND SC>=1000 THEN GOTO 1500
\n1400 LET SC=SC-500
\n1420 PRINT AT 20,12;"     "
\n1430 PRINT AT 20,12;SC
\n1433 PAUSE 500
\n1435 IF SC>=1000 THEN GOTO 1450
\n1440 IF SC<1000 THEN GOSUB 2500
\n1445 GOSUB 3500
\n1460 GOSUB 2000
\n1465 GOTO 1003
\n1500 REM %S%A%F%E% %L%A%N%D%I%N%G% % % % % % % % % % % 
\n1510 PRINT AT 20,23;"DOCKING"
\n1520 PAUSE 250
\n1535 GOSUB 2000
\n1540 PRINT AT 2,2;"******CONGRATULATIONS******"
\n1550 PRINT AT 4,2;"YOU HAVE SURVIVED THE"
\n1560 PRINT AT 5,2;"CRISIS. PREPARE, NOW, FOR A"
\n1570 PRINT AT 6,2;"SAFE LANDING ON MOONBASE 2."
\n1580 PAUSE 1000
\n1590 GOSUB 3500
\n1998 REM %N%E%X%T% %L%I%N%E% %E%N%D%S% %P%R%O%G%R%A%M% 
\n1999 STOP 
\n2000 REM %C%L%E%A%R% %S%H%I%P%"%S% %S%C%R%E%E%N% % % % 
\n2010 FAST 
\n2020 LET H=2
\n2030 PRINT AT H,1;"                             "
\n2040 LET H=H+1
\n2050 IF H>=16 THEN GOTO 2085
\n2060 GOTO 2030
\n2085 SLOW 
\n2090 RETURN 
\n2500 REM %C%R%A%S%H% %M%E%S%S%A%G%E% % % % % % % % % % 
\n2505 GOSUB 2000
\n2510 PRINT AT 2,2;"ALL HOPE IS GONE."
\n2512 PRINT AT 3,2;"PREPARE FOR DISASTER."
\n2515 PAUSE 100
\n2520 PRINT AT 6,2;"GOODBY   GOODBY   GOODBY"
\n2530 PAUSE 500
\n2540 PRINT AT 14,11;"**CRASH**"
\n2545 PAUSE 250
\n2550 RETURN 
\n3000 REM %I%M%P%R%O%P%E%R% %I%N%P%U%T% %R%O%U%T%I%N%E% 
\n3001 GOSUB 2000
\n3010 PRINT AT 2,2;"*IMPROPER INPUT-PLEASE WAIT*"
\n3020 PAUSE 500
\n3030 GOSUB 2000
\n3040 RETURN 
\n3500 CLS 
\n3510 PRINT "DO YOU WISH TO PLAY AGAIN?"
\n3515 PRINT "Y OR N"
\n3520 INPUT B$
\n3530 IF B$="Y" THEN GOTO 3570
\n3540 IF B$="N" THEN GOTO 1999
\n3550 IF B$<>"N" THEN GOSUB 3000
\n3560 GOTO 3500
\n3570 LET P=1
\n3580 GOTO 20
\n3585 CLEAR 
\n3590 SAVE "1000%9"
\n3600 RUN 

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

Scroll to Top