Star Blasters

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

Starblasters is a one-on-one space combat game published in Sync Magazine (January/February 1983), written by Dan Tandberg. The player controls an Earth ship using keys 6 and 7 for vertical movement and key 1 to fire, while an alien ship approaches from the right side of the screen. Gameplay is structured around increasing difficulty waves, with each cleared wave incrementing a wave counter and spawning five more aliens per wave. The program makes extensive use of long pre-built strings (lines 890–970) of block-graphic and inverse-video characters to draw animated laser beams across the screen in a single PRINT statement, a common ZX81 technique for fast horizontal animation. A delay loop controlled by the difficulty setting D (lines 340–350) regulates the player’s firing rate, and the SLOW/FAST keywords are used to switch display modes at appropriate points in the game loop.


Program Analysis

Program Structure

The program is organized into clearly labeled subroutines, each introduced by a REM statement in inverse video. The main control flow is:

  1. Line 20: Call instructions/setup subroutine (line 1370)
  2. Lines 30–60: Initialize totals, wave counter, call game setup (line 800), enter SLOW mode
  3. Line 70: Jump to main game loop at line 190
  4. Lines 190–580: Main movement and combat loop
  5. Lines 800–1160: Game setup, string initialization, star field drawing
  6. Lines 1170–1260: Aliens-win ending
  7. Lines 1270–1360: Player-win / next wave sequence
  8. Lines 1370–1580: Instructions and difficulty selection

Laser Beam Animation Technique

One of the most technically notable aspects is the use of long pre-built strings (lines 890–970) for laser beam animation. Seven strings (A$, C$, E$, F$, G$, H$, I$, J$, X$) are each 32 characters long and filled with different block-graphic or inverse-video patterns. The player laser subroutine (lines 80–140) prints successive substrings of these pre-built strings at the same row using a single compound PRINT AT statement, cycling through patterns to create a flicker/animation effect before clearing with the space string X$. The substring length is controlled by CAT=29-C, so the beam visually extends from the player ship to the right edge of the screen.

Key Variables

VariablePurpose
R, CPlayer ship row and column
RA, CAAlien ship row and column
RX, CX, RAX, CAXPrevious positions for erase-before-redraw
FIREAccumulated firing probability for alien
DIFFAlien firing difficulty increment
DDifficulty level (1–3), also controls delay loop
WAVECurrent wave number, scales alien count and scoring
SHIPSRemaining player lives (starts at 5)
ALIENSAliens remaining in current wave
TOTALCumulative score across waves

Movement and Input Handling

The main loop (lines 190–370) uses a store-old-position / erase-old / draw-new pattern. Lines 200–230 save previous positions into RAX, CAX, RX, CX. The alien moves left one column per frame (CA=CA-1) and drifts vertically with a probabilistic expression at line 260: RA=RA+(RND<.5 AND RA<16)-(RND>.5 AND RA>2). Player vertical movement is polled via INKEY$ at line 280 using the same Boolean arithmetic idiom. The old alien and player positions are erased by printing the space string R$ before drawing at new positions.

Difficulty and Firing Rate

Difficulty D (1=hard, 3=easy) is selected at line 1560 and serves a dual role: it controls the delay loop length (lines 340–350, FOR I=1 TO D) which regulates how quickly the player can fire, and it participates in the alien firing probability increment formula at line 560: DIFF=DIFF+.3/(D*WAVE*5). A lower D means a longer delay before the player can re-fire but also a slower increase in alien firing probability—the interaction makes difficulty tuning non-trivial. The alien fires based on RND<(FIRE+DIFF) at line 310, where FIRE accumulates each frame via line 130.

Explosion Animation

Explosions are rendered using a sequence of eight AT clauses in a single PRINT statement (e.g. lines 390, 480, 600), cycling through block-graphic patterns at the hit location and adjacent rows to simulate a brief expanding flash. This is a classic ZX81 technique to pack animation into minimal code lines.

Overrun Sequence

When the alien reaches the player column (C>=CA, line 320), an overrun subroutine begins at line 590. The alien continues moving left off the left edge of the screen while optionally firing, using its own inner loop (lines 610–680). If CA reaches 0 or below, the game jumps to the aliens-win sequence. This is structurally a nested loop within the same program flow, not a GOSUB.

Wave Progression

On clearing a wave (line 1270), WAVE is incremented and ALIENS is set to WAVE*5 at line 1060, so each wave adds five more aliens. Scoring at lines 1190 and 1290 adds WAVE*5-ALIENS (aliens killed this wave) on loss, or WAVE*5 (full wave credit) on win, to a running TOTAL.

Star Field

Lines 1100–1150 scatter 30 random characters across the play area: ten %* (inverse asterisk) and twenty %. (inverse period/dot) characters at random positions using RAND to seed the RNG. Stars are drawn once at setup and are not redrawn during play, meaning ship and laser movements overwrite them.

Notable Bugs and Anomalies

  • Line 870 prints CHR$ (128+CODE STR$ D) to display the difficulty digit as a character at position (20,15). STR$ D converts the numeric difficulty to a string, CODE extracts its ASCII value, and adding 128 produces an inverse-video version of the digit — a compact display trick.
  • Line 1585 contains CLEAR placed after RETURN at line 1580, meaning it is unreachable in normal execution. It appears to be a utility line intended for manual execution before saving.
  • The A$ string at line 890 uses \!! escape sequences which, under zmakebas conventions, represent a stippled/checkerboard block graphic character, producing a dithered beam effect distinct from the solid block characters in other beam strings.
  • Lines 900 and 940 use \!! and \;; respectively. The \;; sequence is not a standard zmakebas block graphic escape; it may represent a specific character code that renders as a particular graphic on the target hardware.

Content

Appears On

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

Related Products

Related Articles

In “Starblasters” you must defend a sector of space from the invading alien spaceships. Your weapon is a powerful ion...

Related Content

Image Gallery

Star Blasters

Source Code

   1 REM "STARBLASTERS"
   2 REM 
   3 REM DAN TANDBERG
   4 REM SYNC MAGAZINE
   5 REM JANUARY/FEBRUARY 1983
  10 REM 
  20 GOSUB 1370
  30 LET TOTAL=0
  40 LET WAVE=1
  50 GOSUB 800
  60 SLOW 
  70 GOTO 190
  80 REM %Y%O%U% %F%I%R%E% % % % % % % % % % % % % % % 
  90 LET CAT=29-C
 100 LET U=C+3
 110 PRINT AT R,U;A$( TO CAT);AT R,U;C$( TO CAT);AT R,U;E$( TO CAT);AT R,U;F$( TO CAT);AT R,U;G$( TO CAT);AT R,U;X$( TO CAT)
 120 IF R=RA THEN GOTO 470
 130 LET FIRE=FIRE+(.4-D/10)
 140 RETURN 
 150 REM %A%L%I%E%N% %F%I%R%E% % % % % % % % % % % % % 
 160 PRINT AT RA,0;J$( TO CA);AT RA,0;H$( TO CA);AT RA,0;J$( TO CA);AT RA,0;H$( TO CA);AT RA,0;I$( TO CA);AT RA,0;X$( TO CA)
 170 IF R=RA THEN GOTO 380
 180 RETURN 
 190 REM %M%O%V%E% % % % % % % % % % % % % % % % % % % 
 200 LET RAX=RA
 210 LET CAX=CA
 220 LET RX=R
 230 LET CX=C
 240 LET C=C+1
 250 LET CA=CA-1
 260 LET RA=RA+(RND<.5 AND RA<16)-(RND>.5 AND RA>2)
 270 PRINT AT RAX,CAX;R$;AT RA,CA;Z$
 280 LET R=R+(INKEY$="6" AND R<18)-(INKEY$="7" AND R>2)
 290 PRINT AT RX,CX;R$
 300 PRINT AT R,C;Y$
 310 IF RND<(FIRE+DIFF) THEN GOSUB 150
 320 IF C>=CA THEN GOTO 590
 330 REM %D%E%L%A%Y% %F%O%R% %F%I%R%E% % % % % % % % % 
 340 FOR I=1 TO D
 350 NEXT I
 360 IF INKEY$="1" THEN GOSUB 80
 370 GOTO 190
 380 REM %Y%O%U% %H%I%T% % % % % % % % % % % % % % % % 
 390 PRINT AT R,C;"% %.%.% ";AT R,C;"%.%.%.%.";AT R,C;"%.% % %.";AT R,C;"% % % % ";AT R-1,C;"%.% % %.";AT R+1,C;"%.% % %.";AT R-1,C;"% % % % ";AT R+1,C;"% % % % "
 400 LET R=RA-(RA>=10)*INT (RND*D+2)+(RA<10)*INT (RND*D+2)
 410 LET C=0
 420 LET SHIPS=SHIPS-1
 430 PRINT AT 21,3;"SHIPS= ";SHIPS
 440 IF SHIPS<=0 THEN GOTO 1170
 450 LET FIRE=0
 460 GOTO 190
 470 REM %A%L%I%E%N% %H%I%T% % % % % % % % % % % % % % 
 480 PRINT AT R,CA;"% %.%.% ";AT R,CA;"%.%.%.%.";AT R,CA;"%.% % %.";AT R,CA;"% % % % ";AT R-1,CA;"%.% % %.";AT R+1,CA;"%.% % %.";AT R-1,CA;"% % % % ";AT R+1,CA;"% % % % "
 490 LET RA=R-(R>=10)*INT (RND*6)+(R<10)*INT (RND*8)
 500 LET CA=28
 510 LET ALIENS=ALIENS-1
 520 PRINT AT R,C;R$
 530 LET C=0
 540 PRINT AT 21,20;"ALIENS ";ALIENS;" "
 550 IF ALIENS<=0 THEN GOTO 1270
 560 LET DIFF=DIFF+.3/(D*WAVE*5)
 570 LET FIRE=0
 580 GOTO 190
 590 REM %O%V%E%R%R%U%N% % % % % % % % % % % % % % % % 
 600 PRINT AT R,C;"% %.%.% ";AT R,C;"%.%.%.%.";AT R,C;"%.% % %.";AT R,C;"% % % % ";AT R-1,C;"%.% % %.";AT R+1,C;"%.% % %.";AT R-1,C;"% % % % ";AT R+1,C;"% % % % "
 610 PRINT AT RAX,CAX;R$;AT RA,CA;Z$
 620 IF RND>.5 THEN PRINT AT RA,0;J$( TO CA);AT RA,0;H$;AT RA,0;J$( TO CA);AT RA,0;H$( TO CA);AT RA,0;I$( TO CA);AT RA,0;X$( TO CA)
 630 LET RAX=RA
 640 LET CAX=CA
 650 LET CA=CA-1
 660 LET RA=RA+(RA<=9)-(RA>=11)
 670 IF CA<=0 THEN GOTO 1170
 680 GOTO 610
 690 REM %E%N%D% %O%F% %O%V%E%R%R%U%N% % % % % % % % 
 700 REM %S%E%T% %P%O%S%I%T%I%O%N%S% % % % % % % % % 
 710 LET RA=2+2*INT (RND*8)
 720 LET CA=28
 730 PRINT AT 21,20;"ALIENS ";ALIENS
 740 RETURN 
 750 REM %R%E%S%E%T% %Y%O%U%R% %P%O%S%I%T%I%O%N% % % % 
 760 LET R=RA-(RA>=10)*INT (RND*6)+(RA<10)*INT (RND*6)
 770 LET C=1
 780 PRINT AT 21,3;"SHIPS= ";SHIPS
 790 RETURN 
 800 REM %S%E%T%U%P% % % % % % % % % % % % % % % % % % 
 810 FAST 
 820 CLS 
 830 PRINT AT 0,0;"% % % % %S% %T% %A% %R% %B% %L% %A% %S% %T% %E% %R% %S% % % % % "
 840 FOR I=1 TO 20
 850 PRINT AT I,0;"% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % "
 860 NEXT I
 870 PRINT AT 20,15;CHR$ (128+CODE STR$ D)
 880 REM %L%O%N%G% %S%T%R%I%N%G%S% % % % % % % % % % % 
 890 LET A$="\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\.."
 900 LET C$="\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!\!!"
 910 LET E$="%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+"
 920 LET F$="%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%="
 930 LET G$="%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-"
 940 LET H$="\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;\;;"
 950 LET I$="%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%."
 960 LET J$="\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''"
 970 LET X$="% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % "
 980 REM %S%H%O%R%T% %S%T%R%I%N%G%S% % % % % % % % % % 
 990 LET Y$="%<%0%>"
\n1000 LET Z$="%<%=%>"
\n1010 LET R$="% % % "
\n1020 REM %I%N%I%T%I%A%L%I%Z%E% % % % % % % % % % % % % 
\n1030 LET SHIPS=5
\n1040 LET FIRE=0
\n1050 LET DIFF=0.1
\n1060 LET ALIENS=WAVE*5
\n1070 GOSUB 700
\n1080 GOSUB 750
\n1090 REM %S%T%A%R%S% % % % % % % % % % % % % % % % % % 
\n1100 RAND 
\n1110 FOR I=1 TO 10
\n1120 PRINT AT 1+INT (RND*19),INT (RND*31);"%*"
\n1130 PRINT AT 1+INT (RND*19),INT (RND*31);"%."
\n1140 PRINT AT 1+INT (RND*19),INT (RND*31);"%."
\n1150 NEXT I
\n1160 RETURN 
\n1170 REM %A%L%I%E%N%S% %W%I%N% % % % % % % % % % % % % 
\n1180 FAST 
\n1190 LET TOTAL=TOTAL+WAVE*5-ALIENS
\n1200 CLS 
\n1210 PRINT AT 4,3;"YOU FAILED---"
\n1220 PRINT AT 8,3;"THE ALIENS GOT THROUGH."
\n1230 PRINT AT 12,3;"YOU DESTROYED ";TOTAL;" SHIPS."
\n1240 PRINT AT 21,3;"(PUSH TO TRY AGAIN.)"
\n1250 PAUSE 10000
\n1260 GOTO 30
\n1270 REM %E%A%R%T%H% %W%I%N%S% % % % % % % % % % % % % 
\n1280 FAST 
\n1290 LET TOTAL=TOTAL+WAVE*5
\n1300 CLS 
\n1310 LET WAVE=WAVE+1
\n1320 PRINT AT 8,3;"CONGRATULATIONS---"
\n1330 PRINT AT 12,3;"A SUCCESSFUL DEFENCE."
\n1340 PRINT AT 21,3;"(BUT WAVE ";WAVE;" IS ON THE WAY.)"
\n1350 PAUSE 600
\n1360 GOTO 50
\n1370 REM %I%N%S%T%R%U%C%T%I%O%N%S% % % % % % % % % % % 
\n1380 FAST 
\n1390 CLS 
\n1400 PRINT """STARBLASTERS"""
\n1410 PRINT 
\n1420 PRINT 
\n1430 PRINT 
\n1440 PRINT "USE KEYS 6 AND 7"
\n1450 PRINT "TO STEER EARTHSHIPS"
\n1460 PRINT 
\n1470 PRINT "USE KEY 1"
\n1480 PRINT "TO BLAST ALIENS."
\n1490 PRINT 
\n1500 PRINT 
\n1510 PRINT "DIFFICULTY:"
\n1520 PRINT "1 IS HARD"
\n1530 PRINT "2 IS MEDIUM"
\n1540 PRINT "3 IS EASY"
\n1550 PAUSE 10000
\n1560 LET D=VAL INKEY$
\n1570 IF D>3 OR D<1 THEN GOTO 1550
\n1580 RETURN 
\n1585 CLEAR 
\n1590 SAVE "1000%7"
\n1600 RUN 

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

Scroll to Top