Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM  itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"E



Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\FF\FF

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\B2C

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
DF

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
CF

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
D

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
D

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
CE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
FAE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
FDD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"AE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AF itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4" itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4" itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BF

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
CF

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A\F8\C9\C4\C9\EDBA\C9\ED

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\C9\FD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"E\ED\C9E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E\FC

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
D\FDD\F8\C9\CDE\E8\CDE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\CDE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\CDEAA\C3BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C\B7

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AA\EDAC\F0AAC\C6 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AEE\C9E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C\B4E\FCA\B4D\EE\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C\BC

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\C0E\AEE\C3E\C2\C9E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\C9\CD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"E\CDEE\BE\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E\AF\BE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"B\C2E itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
FE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A\C0

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\C0\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
D

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\CD\C9EB\BE\F7\C2E itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"E\BE\EFE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A\C0\C0\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
D\CD\C9E\BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E\AE\C9\CD\BE\CD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"E\C9\CD\DE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A\C0E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
EE\CDE\AE\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A\C0EE\CD\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\AA

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE\EF\C9\B3E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\C9E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A\C0\B7

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\ED\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
EE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
FA\C2FA\C3D\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\AA

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE\EF\C9\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AE\BEE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
FE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\BE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\B7\EDE\BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
EE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
FE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BF\C4

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\EA\C9\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AED\BEE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E\E2

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
FE\BE\E6\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AE\BE\DAED\BF

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AA\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AA\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AA\CD\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\CDF\CD\C9E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\FCE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\CD\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\CDF\C9\FF\FF\CD\BB

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A\B7\F7\DF\EDE\AF\CD\F5

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AA\B7\E7\DD\EDE\AF\CD\F5\CD\FA

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AA\B7\EF\F7\EDEB\CD\F5

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AA\B7\EF\F5\EDEB\CD\F5\CD\FA

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AA\B7\EF\FD\ED\CD\FA\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\C9EE\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\CB

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\D5

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F\DF

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\D4\ED\B0\D4

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F\EDB

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\E4\CDE\CD\C9\D5E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\F5\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\C9\D4

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\CDD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\EF\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\C9\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\FEE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AEE\C9\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AEE\C9\D4

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AE\BE\BE\BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\DC\C9\C3 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\C9\CD\BE\CDA\FE\EE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\FE\D4

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
FE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\E6

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE\CD\CDA\CDD\C9A\E6

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE\D6

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
DE\E6\C6

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\C6 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\C6

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\C9\DF\FF

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\FF\DE\FF\FF\FF\FF\FF\FF

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\FF itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4" itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4" itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\E0\FF itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\FF\FF itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\ED\B0

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BA\FAA

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\C6

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C\D6 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"FA\D6

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\D6

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
D

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E\BEE\AE\BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\FF\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BEE\AE\BE\E2\BEE\AE\BE\D7\CD\DD\CDB\F9\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AE\EDB

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\ED\B0\C9\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E\CD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"E itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\CD\C9

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\C4

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE\EE\C9\D4

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BA\C2\BE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B\EA\C9E\CAD\D6 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\CA\B9\FF

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AE\BE\F8\C3\B9\FF\C3D\CD

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
EDA\C2

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE\C6 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\EDB

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
F itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\ED\B0\C9\CD\BB

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
C

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
E\CD\C3 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C\CD\CD\B2E\CD\AD\CD\CDF\B3E

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\CD\E1\CD\CD\CDE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE\CADE\BE\DAD\B2\C2

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
D\CDE

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
\BE\C2

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A\EDB\B7\ED

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A\CD\C3 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C 15 REM

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
AAD\C8D\C8\C3\EB\CDF

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
A\C0

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"EE\FE\BB\FE\AE\C4\C0E\FE\BB\FE\AE\C4\C0E\BB

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
B

Galaxy Invaders

Products: Galaxy Invaders
Date: 1982
Type: Cassette
Platform(s): TS 1000
Tags: Arcade, Game

Galaxy Invaders is a Space Invaders-style arcade game featuring seven alien craft that can fire at or crash into the player’s laser base, which can withstand seven hits before being destroyed. The player moves left and right and fires a laser using keys 5, 8, and 0. The bulk of the program is a large machine code routine stored in REM lines 10 and 15, loaded into memory via a USR call at line 30. Game speed is configurable from 1 to 100 and is POKEd into address 16680, which controls the interrupt timing register (the ZX81’s R register delay), with the formula 255 minus twice the input value written directly to that address.


Program Analysis

Program Structure

The program is split into two layers: a small BASIC loader/setup section (lines 20–94) and a large machine code payload embedded in the REM statements at lines 10 and 15. Line 16 contains a decorative title banner using inverse characters. The BASIC section handles screen setup, the instruction display, speed input, and then hands control to machine code via a GO TO 1 at line 94 — targeting a non-existent line, which is a well-known technique to transfer execution into the machine code that was initialized by the earlier USR call.

Machine Code Loading

Line 30 executes LET X=USR 18177. Address 18177 decimal is 0x4701, which falls within the REM data area of line 10 (the ZX81 stores REM content starting a few bytes into the line, at address 0x4009 for the first REM). The machine code in the REM lines is thus directly executed by the USR call, which sets up the game engine in RAM. The REM at line 10 contains several hundred bytes of Z80 machine code; line 15 continues with additional routines. Together they implement all game logic: alien movement, collision detection, laser handling, scoring, and display.

Speed Control via POKE

Lines 93 and 35 both POKE address 16680 (0x4128). Line 35 writes 252 as an initial value; line 93 writes INT(255 - 2*X) where X is the player’s chosen speed (1–100). Address 16680 is within the system variables area and is used here to control the game loop’s delay constant, effectively scaling game speed. A higher input value results in a lower POKE value and thus a faster game.

Input Validation

Lines 85–91 implement a manual integer-parsing routine for the speed input rather than using VAL. The code checks each character’s CODE value against the range 28–37 (ZX81 digit tokens 0–9), rejects strings longer than 3 characters, and reconstructs the numeric value digit by digit using powers of ten. This avoids the overhead of the BASIC VAL function and also guards against non-numeric input.

  • Line 86: Gets string length into B
  • Line 87–90: Loops over each character, accumulating the numeric value in X using 10**(V-1) weighting on reversed digits
  • Line 91: Rejects zero or values above 100, looping back to re-prompt

Screen Initialization

Lines 62–64 clear the play area by printing spaces across rows 1–21. Line 72 prints the key legend using a combination of block graphics characters for a decorative border. The title at line 70 is displayed entirely in inverse video using the % escape sequences for each character.

Notable Techniques

  • The GO TO 1 at line 94 transfers control into unlisted machine code — a standard technique to invoke an ML game loop from BASIC.
  • The machine code in the REM lines uses Z80 structured code with call/return patterns visible in the hex: sequences of CD (CALL), C9 (RET), ED 53/ED 5B (LD (nn),DE / LD DE,(nn)), indicating well-structured subroutine architecture.
  • The SLOW command at line 20 ensures the display is updated during the game loop, which is necessary for the machine code to produce visible output.
  • The SAVE command at line 69 uses an inverse-video filename.

Key Variables

VariableUsage
XLoop counter, USR return value, parsed speed value
X$Raw string input for speed
BLength of input string
VLoop index for digit parsing

Potential Anomalies

Line 65 jumps to line 72 with GO TO 72, skipping line 69 (the SAVE command) and line 70 (the title print). This means the title banner at line 70 is never displayed during normal program execution — it would only be reached if the program were run from line 70 directly. This is likely intentional: the title was used during development or loading, and line 65 bypasses it to go straight to the instructions screen.

Content

Appears On

Related Products

An excellent version of the classic space game. Protect your seven lives against fleets of hostile invaders, who swoop down...

Related Articles

Related Content

Image Gallery

Galaxy Invaders

Source Code

  10 REM \1E\00\00\00\FF\FF\00\00\00\00\00\00\B2\4C\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01\00\00\00\00\00\00\00\00\00\00\00\4D\4F\06\15\2C\4F\06\14\00\00\00\00\00\00\00\00\00\00\00\00\62\4D\0B\06\00\02\49\4D\13\05\00\02\9C\4E\1C\0F\05\03\8A\4E\0A\0F\03\05\6D\4D\16\06\07\02\1A\4E\1E\0B\04\03\0A\4F\06\13\04\01\01\01\2B\4F\06\14\2C\4F\06\14\00\00\2A\F8\40\C9\22\C4\40\C9\ED\5B\7A\45\C9\ED\53\00\00\C9\FD\21\00\40\3E\1E\ED\47\C9\3E\06\0E\FC\0D\20\FD\3D\20\F8\C9\11\10\27\CD\4E\41\11\E8\03\CD\4E\41\11\64\00\CD\4E\41\11\0A\00\CD\4E\41\3A\8A\40\C3\6B\41\3E\00\32\8C\40\B7\2A\8A\40\ED\52\22\8A\40\38\06\21\8C\40\34\18\F0\19\22\8A\40\3A\8C\40\C6\1C\2A\8E\40\77\23\22\8E\40\C9\3E\16\2A\0C\40\23\32\B4\40\06\20\3E\80\77\23\10\FC\23\3A\B4\40\3D\20\EE\C9\21\08\00\22\96\40\2A\0C\40\11\BC\02\19\22\C0\40\3E\AE\77\3E\15\32\C3\40\3E\06\32\C2\40\C9\21\96\40\3E\00\BE\20\01\C9\CD\1E\42\CD\91\43\21\87\40\3E\7E\BE\20\07\CD\48\42\00\00\00\00\21\86\40\3E\AF\BE\20\1B\21\C2\40\3E\01\BE\28\0F\35\3E\80\2A\C0\40\77\2B\22\C0\40\CD\0D\42\00\CD\85\48\C9\3E\7B\BE\20\F7\21\C2\40\3E\1E\BE\28\EF\34\3E\80\2A\C0\40\77\23\22\C0\40\CD\0D\42\CD\85\48\C9\3E\80\BE\20\00\3E\AE\77\C9\77\CD\BE\44\CD\1E\42\C9\CD\DE\48\00\00\00\20\01\C9\21\96\40\35\28\0F\2A\C0\40\3E\2E\77\3E\40\CD\27\41\3E\AE\77\C9\2A\C0\40\3E\89\77\3E\80\CD\27\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\28\06\23\23\23\10\EF\C9\21\B3\40\3E\00\BE\28\01\C9\3E\08\77\2A\C0\40\B7\11\21\00\ED\52\CD\0E\41\3E\95\77\2A\0F\41\23\23\22\0F\41\3A\C2\40\6F\3A\C3\40\3D\67\CD\0E\41\C9\06\02\21\AA\40\22\0F\41\22\0B\41\23\3E\00\BE\20\06\23\23\23\10\EF\C9\CD\0A\41\3E\95\BE\3E\80\77\20\27\2A\0F\41\23\23\23\3E\01\BE\28\1C\35\CD\0A\41\11\21\00\B7\ED\52\3E\80\BE\20\0C\CD\0E\41\3E\95\77\2A\0F\41\23\18\C9\77\2A\0F\41\23\3E\00\77\18\BF\06\03\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\20\0B\2A\0B\41\23\23\23\23\23\10\EA\C9\CD\0A\41\3E\8D\BE\3E\80\77\28\08\21\00\00\CD\0E\41\18\E2\11\21\00\19\CD\0E\41\2A\0F\41\23\23\23\3E\15\BE\28\E6\34\CD\0A\41\3E\80\BE\28\03\77\18\DA\3E\8D\77\18\BF\2A\0C\40\11\01\00\19\22\8E\40\2A\82\40\22\8A\40\CD\30\41\2A\0C\40\11\0F\00\19\22\8E\40\2A\84\40\22\8A\40\CD\30\41\2A\0C\40\11\1C\00\19\22\8E\40\2A\96\40\22\8A\40\CD\30\41\C9\00\00\00\CD\8F\42\CD\25\41\C9\06\86\21\84\40\3E\00\77\23\10\FC\3E\02\32\96\40\CD\76\41\CD\2B\44\CD\8F\41\C9\21\FF\FF\22\86\40\CD\BB\02\22\8A\40\B7\11\F7\DF\ED\52\20\05\3E\AF\CD\F5\43\2A\8A\40\B7\11\E7\DD\ED\52\20\08\3E\AF\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\F7\ED\52\20\05\3E\7B\CD\F5\43\2A\8A\40\B7\11\EF\F5\ED\52\20\08\3E\7B\CD\F5\43\CD\FA\43\2A\8A\40\B7\11\EF\FD\ED\52\20\03\CD\FA\43\C9\00\00\00\00\00\00\21\86\40\77\C9\3E\7E\21\87\40\77\C9\51\00\0F\02\04\05\8E\00\0A\04\04\04\98\00\14\04\04\04\CB\00\05\06\04\03\D5\00\0F\06\04\05\DF\00\19\06\04\03\38\01\0F\09\04\05\01\2A\00\21\01\44\11\D4\40\ED\B0\06\07\21\D4\40\22\0B\41\22\0F\41\ED\5B\0C\40\CD\0A\41\19\CD\0E\41\2A\0B\41\23\23\23\23\23\23\10\E4\CD\76\44\3E\80\CD\27\41\C9\21\D5\40\06\07\3E\00\BE\20\0B\23\23\23\23\23\23\10\F5\CD\2B\44\C9\06\07\21\D4\40\22\0B\41\CD\8D\44\2A\0B\41\23\23\23\23\23\23\10\EF\C9\2A\0B\41\23\3E\00\BE\20\01\C9\CD\0A\41\3E\0B\23\77\21\FE\40\3E\00\BE\20\0C\CD\0A\41\3E\86\77\23\23\3E\06\77\C9\CD\0A\41\3E\06\77\23\23\3E\86\77\C9\21\D4\40\06\07\22\0B\41\23\3E\00\BE\28\10\CD\0A\41\3E\80\BE\28\14\23\BE\28\10\23\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\DC\C9\C3\72\48\11\01\00\19\22\84\40\CD\0A\41\3E\80\77\23\77\23\77\2A\0B\41\23\3E\00\77\C9\CD\BE\44\CD\60\44\3A\FE\40\EE\01\32\FE\40\06\07\21\D4\40\22\0B\41\22\0F\41\23\3E\00\BE\28\03\CD\31\45\2A\0B\41\23\23\23\23\23\23\10\E6\2A\0B\41\23\23\23\23\23\35\20\06\3E\05\77\CD\49\45\CD\8A\45\CD\8D\44\C9\3A\34\40\E6\07\2A\0B\41\23\23\23\23\77\2B\7E\D6\07\30\0D\23\7E\E6\03\C6\00\20\02\C6\01\C6\02\77\C9\DF\FF\00\FF\DE\FF\FF\FF\FF\FF\FF\00\20\00\FF\01\21\00\00\01\22\00\01\01\01\00\01\00\E0\FF\01\FF\21\FF\40\70\01\04\00\2A\0B\41\11\00\41\ED\B0\2A\0B\41\23\23\23\23\46\04\21\6A\45\18\04\23\23\23\23\10\FA\3A\02\41\23\23\86\32\02\41\23\3A\03\41\86\32\03\41\2B\2B\2B\22\14\41\CD\12\41\2A\00\41\19\22\00\41\3A\02\41\C6\00\28\1C\D6\1F\30\18\3A\03\41\D6\02\38\11\D6\14\30\0D\2A\00\41\3E\80\BE\28\18\3E\AE\BE\28\2E\2A\0B\41\23\23\23\23\23\3E\01\77\21\FF\40\46\C9\00\00\00\23\BE\28\07\3E\AE\BE\28\12\18\E2\23\BE\28\07\3E\AE\BE\28\07\18\D7\CD\24\46\18\DD\CD\3B\46\18\F9\CD\0A\41\3E\80\77\23\77\23\77\ED\5B\0B\41\21\00\41\01\04\00\ED\B0\C9\CD\24\46\2A\00\41\3E\08\77\23\77\23\77\CD\1E\42\21\01\41\3E\00\77\CD\24\46\C9\06\02\21\C4\40\22\0F\41\22\0B\41\23\3E\00\BE\28\07\23\23\23\23\10\EE\C9\06\07\21\D4\40\22\0B\41\23\23\3A\C2\40\BE\28\0C\2A\0B\41\23\23\23\23\23\23\10\EA\C9\23\3E\15\96\CA\7D\46\D6\01\32\07\41\CA\B9\46\21\FF\40\70\21\07\41\46\11\21\00\CD\0A\41\23\19\3E\80\BE\20\05\10\F8\C3\B9\46\21\FF\40\46\C3\7D\46\CD\0A\41\11\22\00\19\22\04\41\3E\8D\77\3A\C2\40\32\06\41\2A\0B\41\23\23\23\7E\C6\01\32\07\41\ED\5B\0F\41\01\04\00\21\04\41\ED\B0\C9\CD\BB\02\00\00\00\2A\0C\40\11\10\00\19\22\8E\40\21\86\40\22\88\40\CD\30\41\C3\1C\41\CD\77\43\CD\33\43\21\B2\40\3E\04\77\CD\AD\41\CD\25\41\CD\8F\42\21\B3\40\3E\00\BE\28\01\35\CD\E1\42\CD\55\46\CD\25\41\CD\46\43\21\96\40\3E\00\BE\CA\4D\47\3E\08\BE\DA\4D\47\21\B2\40\35\C2\0D\47\CD\04\45\21\96\40\3E\00\BE\C2\07\47\2A\84\40\ED\5B\82\40\B7\ED\52\38\06\2A\84\40\22\82\40\CD\33\43\C3\1C\41\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C\1C
  15 REM \2A\84\40\3A\28\41\3D\C8\3D\C8\32\28\41\C3\EB\44\35\35\35\CD\8F\42\2A\C0\40\2B\1E\89\7E\73\FE\80\28\08\BB\28\05\FE\AE\C4\C0\48\23\23\7E\73\FE\80\20\08\BB\20\05\FE\AE\C4\C0\48\23\7E\BB\20\02\36\80\2B\2B\2B\2B\7E\BB\C0\36\80\C9\35\35\35\E5\C4\1E\42\E1\C9\35\35\35\35\35\35\35\35\35\35\35\35
  16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO
  20 SLOW 
  30 LET X=USR 18177
  35 POKE 16680,252
  40 FOR X=1 TO 300
  50 NEXT X
  62 FOR X=1 TO 21
  63 PRINT AT X,0;"                                "
  64 NEXT X
  65 GOTO 72
  69 SAVE "GA%L"
  70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% "
  72 PRINT AT 2,0;"KEY    FUNCTION",,"\''\''\''    \''\''\''\''\''\''\''\''"
  74 PRINT " 5     LEFT",," 8     RIGHT",," 0     FIRE LASER"
  76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT   YOUR LASER BASE OR CRASH INTO   IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED."
  78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE   SHOW:"
  80 PRINT ,,"% %M%A%X% %S%C%O%R%E%    % %S%C%O%R%E%    % %L%I%V%E%S% "
  82 PRINT AT 20,0;"INITIAL SPEED?   (1 TO 100. THE SPEED INCREASES DURING THE GAME)"
  84 LET X=0
  85 INPUT X$
  86 LET B=LEN X$
  87 FOR V=1 TO B
  88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84
  89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28)
  90 NEXT V
  91 IF X>=101 OR X=0 THEN GOTO 84
  93 POKE 16680,INT (255-2*X)
  94 GOTO 1

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

People

No people associated with this content.

Scroll to Top
BE\BB\C0\C9\E5\C4 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-51886 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"E\E1\C9 16 REM OOOOOOE""RNDY%I%Y""FY\;;%Y""77%YTAN OOOOOOOOOOOOOOOOOOOOOO 20 SLOW 30 LET X=USR 18177 35 POKE 16680,252 40 FOR X=1 TO 300 50 NEXT X 62 FOR X=1 TO 21 63 PRINT AT X,0;" " 64 NEXT X 65 GOTO 72 69 SAVE "GA%L" 70 PRINT TAB 6;"% %G%A%L%A%X%Y% %I%N%V%A%D%E%R%S% " 72 PRINT AT 2,0;"KEY FUNCTION",,"\''\''\'' \''\''\''\''\''\''\''\''" 74 PRINT " 5 LEFT",," 8 RIGHT",," 0 FIRE LASER" 76 PRINT ,,"THE 7 ALIEN CRAFT CAN FIRE AT YOUR LASER BASE OR CRASH INTO IT.THE BASE CAN WITHSTAND 7 HITSBEFORE IT IS DESTROYED." 78 PRINT ,,"THE 3 NUMBERS ON THE TOP LINE SHOW:" 80 PRINT ,,"% %M%A%X% %S%C%O%R%E% % %S%C%O%R%E% % %L%I%V%E%S% " 82 PRINT AT 20,0;"INITIAL SPEED? (1 TO 100. THE SPEED INCREASES DURING THE GAME)" 84 LET X=0 85 INPUT X$ 86 LET B=LEN X$ 87 FOR V=1 TO B 88 IF CODE X$(V)<28 OR CODE X$(V)>37 OR B>3 THEN GOTO 84 89 LET X=X+10**(V-1)*(CODE X$(B+1-V)-28) 90 NEXT V 91 IF X>=101 OR X=0 THEN GOTO 84 93 POKE 16680,INT (255-2*X) 94 GOTO 1

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

People

No people associated with this content.

Scroll to Top