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:
- Line 20: Call instructions/setup subroutine (line 1370)
- Lines 30–60: Initialize totals, wave counter, call game setup (line 800), enter SLOW mode
- Line 70: Jump to main game loop at line 190
- Lines 190–580: Main movement and combat loop
- Lines 800–1160: Game setup, string initialization, star field drawing
- Lines 1170–1260: Aliens-win ending
- Lines 1270–1360: Player-win / next wave sequence
- 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
| Variable | Purpose |
|---|---|
R, C | Player ship row and column |
RA, CA | Alien ship row and column |
RX, CX, RAX, CAX | Previous positions for erase-before-redraw |
FIRE | Accumulated firing probability for alien |
DIFF | Alien firing difficulty increment |
D | Difficulty level (1–3), also controls delay loop |
WAVE | Current wave number, scales alien count and scoring |
SHIPS | Remaining player lives (starts at 5) |
ALIENS | Aliens remaining in current wave |
TOTAL | Cumulative 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$ Dconverts the numeric difficulty to a string,CODEextracts its ASCII value, and adding 128 produces an inverse-video version of the digit — a compact display trick. - Line 1585 contains
CLEARplaced afterRETURNat 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
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%>"
1000 LET Z$="%<%=%>"
1010 LET R$="% % % "
1020 REM %I%N%I%T%I%A%L%I%Z%E% % % % % % % % % % % % %
1030 LET SHIPS=5
1040 LET FIRE=0
1050 LET DIFF=0.1
1060 LET ALIENS=WAVE*5
1070 GOSUB 700
1080 GOSUB 750
1090 REM %S%T%A%R%S% % % % % % % % % % % % % % % % % %
1100 RAND
1110 FOR I=1 TO 10
1120 PRINT AT 1+INT (RND*19),INT (RND*31);"%*"
1130 PRINT AT 1+INT (RND*19),INT (RND*31);"%."
1140 PRINT AT 1+INT (RND*19),INT (RND*31);"%."
1150 NEXT I
1160 RETURN
1170 REM %A%L%I%E%N%S% %W%I%N% % % % % % % % % % % % %
1180 FAST
1190 LET TOTAL=TOTAL+WAVE*5-ALIENS
1200 CLS
1210 PRINT AT 4,3;"YOU FAILED---"
1220 PRINT AT 8,3;"THE ALIENS GOT THROUGH."
1230 PRINT AT 12,3;"YOU DESTROYED ";TOTAL;" SHIPS."
1240 PRINT AT 21,3;"(PUSH TO TRY AGAIN.)"
1250 PAUSE 10000
1260 GOTO 30
1270 REM %E%A%R%T%H% %W%I%N%S% % % % % % % % % % % % %
1280 FAST
1290 LET TOTAL=TOTAL+WAVE*5
1300 CLS
1310 LET WAVE=WAVE+1
1320 PRINT AT 8,3;"CONGRATULATIONS---"
1330 PRINT AT 12,3;"A SUCCESSFUL DEFENCE."
1340 PRINT AT 21,3;"(BUT WAVE ";WAVE;" IS ON THE WAY.)"
1350 PAUSE 600
1360 GOTO 50
1370 REM %I%N%S%T%R%U%C%T%I%O%N%S% % % % % % % % % % %
1380 FAST
1390 CLS
1400 PRINT """STARBLASTERS"""
1410 PRINT
1420 PRINT
1430 PRINT
1440 PRINT "USE KEYS 6 AND 7"
1450 PRINT "TO STEER EARTHSHIPS"
1460 PRINT
1470 PRINT "USE KEY 1"
1480 PRINT "TO BLAST ALIENS."
1490 PRINT
1500 PRINT
1510 PRINT "DIFFICULTY:"
1520 PRINT "1 IS HARD"
1530 PRINT "2 IS MEDIUM"
1540 PRINT "3 IS EASY"
1550 PAUSE 10000
1560 LET D=VAL INKEY$
1570 IF D>3 OR D<1 THEN GOTO 1550
1580 RETURN
1585 CLEAR
1590 SAVE "1000%7"
1600 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

