Invasion Force is a Space Invaders-style game in which the player defends Earth against alien attackers using laser bases, controlling movement with keys 1, 3, and 9. The program is unusual in that virtually all of its logic is encoded within REM statements, with the executable BASIC consisting of only a handful of lines including a SAVE, SLOW, and a single LET statement that transfers control into machine code via USR. The REM lines contain both the game’s machine code routines (stored as tokenized BASIC keyword bytes) and the screen graphics for the aliens, spaceship, force field, and player ship. Line 10’s REM holds the title screen artwork built from block graphics characters, while lines 420, 430, 460, and 500 contain the game’s instruction text. The entry point at line 620 calls USR 23118, jumping directly into the machine code embedded in the REMs.
Program Analysis
Program Structure
The visible BASIC listing is extremely minimal — only three executable lines exist:
- Line 600:
SAVE "INVASIO[N]"— saves the program to tape - Line 610:
SLOW— switches to slow (display-contended) mode - Line 620:
LET L=USR 23118— transfers execution to machine code at address 23118
Everything else — graphics, game logic, screen data, instruction text, and all routines — is packed into REM statements occupying lines 10 through 590. This is the classic ZX81 technique of storing machine code in REMs, since REM line bodies are not parsed or executed by the BASIC interpreter and can hold arbitrary byte sequences.
Machine Code via REM Statements
Address 23118 is the memory location immediately following the system variables area on a 16K ZX81, which is where the program text begins. The first REM line (line 10) starts at that address. The USR 23118 call therefore jumps directly into the bytes stored in line 10’s REM body, which must begin with valid Z80 machine code. All subsequent REM lines (20 through 590) contain further machine code, data tables, and string resources read by the running Z80 program.
Because REM bodies can hold any byte value (including values that look like BASIC keywords when disassembled as tokens), the zmakebas listing renders much of the machine code as a mixture of BASIC keyword names, block graphic escapes, and punctuation — this is purely an artifact of token rendering and does not represent actual BASIC statements.
Embedded Graphics and Text
Line 10’s REM contains the title screen artwork constructed from block graphic characters, depicting the alien mothership, the player’s laser base, the force field, and a BONUS display. Lines 20’s REM holds a further screen layout including the score and ship-lives display. Human-readable instruction text appears in several REM lines:
- Line 240: game-over message (“THE INVASION HAS BEEN COMPLETED…”)
- Line 400: success message (“WELL DONE. YOU HAVE DESTROYED THE SPACE SHIP…”)
- Lines 420/430: main instructions including controls (key 1 = left, key 3 = right, key 9 = fire)
- Line 460: secondary instructions describing bomb ships and force field mechanics
- Line 500: difficulty selection screen (Beginner or Expert)
- Lines 540/560: high score display and name entry prompts
These text blocks are terminated with * or + characters, which serve as sentinel bytes for the machine code string-printing routines to detect end-of-message.
Key BASIC Idioms
The three-line executable section is intentionally terse. SLOW before the USR call is significant: it ensures the display driver is running so the machine code can use normal display output. The result of USR is assigned to L to satisfy the BASIC syntax requirement that USR appear in an expression context; the value of L is irrelevant since the machine code never returns in normal gameplay.
Gameplay Details (from Instruction Text)
According to the embedded instruction REMs, the game involves:
- Three laser bases as the player’s lives
- A moving force field that must be breached to fire at the aliens
- A main alien ship whose damage can be repaired if the player hits black “blobs” in the force field
- Bomb ships (rendered as a block graphic pair) that drop asterisk projectiles
- A BONUS counter that decrements, ending the game when it reaches zero
- A high score table with name entry (up to 12 characters)
- Beginner and Expert difficulty modes
Notable Techniques
- REM-as-machine-code: The entire game engine is a single contiguous block of Z80 code distributed across REMs starting at line 10, entered via
USR 23118. - Sentinel-terminated strings: Instruction and message text embedded in REMs uses
*or+as terminators rather than length-prefixed strings, a common Z80 practice. - SLOW mode activation: Explicitly called before
USRto guarantee the display interrupt is active when machine code begins. - Minimal BASIC wrapper: Only three lines of BASIC are needed — save, mode-set, and launch — keeping the interpreter overhead effectively zero during gameplay.
Anomalies and Observations
Line 30 through 590 contain REM bodies that, when rendered as BASIC tokens, produce nonsensical keyword sequences (e.g., RETURN COS GOSUB CONT). This is expected and correct: these are Z80 opcodes and data bytes whose numeric values happen to coincide with BASIC keyword token codes. They are not BASIC statements and are never executed by the BASIC interpreter.
The SAVE line (600) saves the program before SLOW and USR are reached, meaning a fresh load will correctly re-enter at line 600 and proceed through the initialization sequence again.
Content
Image Gallery
Source Code
10 REM "▛▀▀▀▀▀▜ ▟▙ ▌BONUS▐ ▄▟▜▛▙▄ ▌15000▐ ▄▛▛▛▜▜▜▄ ▙▄▄▄▄▄▟ ▄███[~~][~~]███▄ ▟[▒]▒[▒]▒[▒]▒[▒]▒[▒]▒▙ ▜██████████▛ ▜████████▛ ▄\,,\,,\,,\,,\,,\,,\,,▄\,,\,,\,,\,,\,,\,,\,,▄\,,\,,\,,\,,\,,\,,\,,▄\,,\,,\,,\,,\,,\,,\,,▀\~~\~~\~~\~~\~~\~~\~~▀\~~\~~\~~\~~\~~\~~\~~▀\~~\~~\~~\~~\~~\~~\~~▀\~~\~~\~~\~~\~~\~~\~~*"
20 REM AT 12,0;" \,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,\,,▒SCORE=000000▒SHIPS : ▗ ▗ ▗ ▒\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~▒▗▛▙▗▛▙▗▛▙ ▒"
30 REM E£RND)▄RND# RETURN#4▘7, RETURN*C▒ RETURN"COS #7</ GOSUB )2PI/ CONT
40 REM E£RND▘#▘\,,#MWRND▞37#F#7( RAND UWRND#TAN .
50 REM E£RND▘#▘\,,#MWRND▞37#F#7( RAND UWRND#TAN .
60 REM E£RND▘[(] \,,#MWRND▞\,,7#F#7( RAND UWRND#TAN .
70 REM E£RND▘# \,,# RETURN▌COS RETURN0C▖X#TAN Y9#F/ GOTO
80 REM E£RND▘[(]▝\,,6:RNDTAN
90 REM E:RNDY▗#▘4 \,,#Y▛7#7Y▙#TAN
100 REM E:RNDY #▘4 \,,#Y 7#7Y #TAN
110 REM LN [V]▝# E:RND RETURN CLEARC= RETURN RUN ""77# RETURN#COS LN ##E:RND76:RNDTAN FF# RETURN#COS LN ##E:RNDF6:RNDTAN
120 REM LN [V]▝# RETURN CLS""E£RND▘[A] \,,# RETURN▒C▞ RETURN▐COS 7/ PRINT E:RND▘ TO COPY\,,Y▐#TAN
130 REM E£RND▘▜ \,,7# RETURN#COS RETURN▟C▛ RETURN▐4 NEXT Q TAN ▘" \,,/ REM ...
140 REM E£RND▘[9] \,,7# RETURN▒COS RETURN▐4 RUN ▘ TO COPY\,,# RETURN TAB ##Q▐▘5 \,,Q TAN .
150 REM RETURN\~~4>Q ▘ TO COPY\,,Q ▘PI \,,Q*7Q*TAN RETURN*4▛▘5 \,,Q TAN RETURN▀C\,,Q ▘5 \,,Q TAN #)#███████████████
160 REM E£RND▘[?] \,,Q▟▘" \,,Q▙TAN
170 REM E£RND▘[R]▝\,,F# RETURN[~~]COS RETURN*4 RUN ▘5 \,,# RETURN 4\~~Q*▘ TO COPY\,,Q / SLOW RETURN▐4▖Q />= RETURN\,,4▒▘ TO COPY\,,Q /SQR ###......
180 REM E£RND▘[?] \,,7# RETURN▙COS RETURN▐4 RUN ▘ TO COPY\,,# RETURN[~~]C▛▘5 \,,Q TAN ###██
190 REM ▘5 \,,Q E£RND▘" \,,##5[$]RND▞▛VAL ▘£ GOSUB [K]▘+ FAST##\,,## LPRINT "\,,AT ( FOR TAN █████████████████
200 REM E:RND▘ TO COPY\,,Q ▘4 \,,Q 77Q ▞\~~VAL ▞\~~E:RND#)4 ;#7#7#VAL ▞\~~VAL ▞ COPY( RETURNAT ( SAVE AT ( FASTAT ( TO LN ###[/]#....
210 REM E£RND▘ FAST▝\,,7# RETURN▒C7 RETURN▗4 PLOT Q ▘4 \,,Q 7Q 7Q LN ##LN ##▞;VAL ▞ COPY( RETURNAT ( SAVE TAN # THEN#.........[.]...
220 REM E£RND▘ THEN▝\,,)WRND▘▞ GOSUB [K]▞4VAL ▞/E£RNDVAL ▞377#F#( RAND 7Q 7AT ( LOAD AT ( NEWLN )#E£RND▘ RUN ▝\,,▞47Q\~~( CLS▞:VAL ▘CHR$ ▝E£RND\,,##▘[P]▝E£RND\,, GOSUB [S]E£RND▞47Q ( CLS▞=VAL ▞ COPY( RETURNAT ( SAVE AT (CHR$ ###.....................
230 REM E£RND▘#▝\,,Q▞▘▌ \,,Q▚▘. \,,Q▟▘▛ \,,Q▙E£RND##5 SCROLL#, RETURN#4▘<# RETURN*C▌><7/ LIST <5WRND▘▞ GOSUB [K]<Y>>LN ##▞\~~VAL ▞ COPYVAL ▞ COPY( RETURNAT ( SAVE AT ( PAUSE ###.......................................
240 REM THE INVASION HAS BEEN COMPLETED. THE ALIEN FORCE IS DOMINANT. THE GAME IS OVER.YOU SCORED: <*
250 REM E£RND▘[£]▘\,,7# RETURN#COS RETURN▐4 RUN ▘ TO COPY\,,# RETURN ""▘5 \,,Q ▘[Y] COPY\,,Q▐TAN .....
260 REM E£RND▘# \,,7# RETURN▐ASN THEN# RETURN0""/ POKE
270 REM E#RND FAST#I\~~AT [R] GOSUB PIDDR GOSUB #6#RND#TAN ███████████
280 REM LN ▀#ACS #COS ACS #COS E£RND▘▒▘\,,▞>7# RETURN▄COS ( RAND E£RND▘\,,▘\,,Q▄7Q▙TAN .....
290 REM E£RND▘ LLIST ▝\,,# RETURN=COS W RETURNAC▝#TAN Y0#F/ LOAD █
300 REM E£RND▘D▘\,,7# RETURN#COS RETURN▐4 RUN ▘ TO COPY\,,# RETURN▄C▞ RETURN▙""[J]#F[J]#7#▘4 \,,#7#LN 3#TAN ..................
310 REM E£RND▘C▘\,,F# RETURN#COS RETURN▙4 RUN 7#FQ▄FQ / GOSUB .....
320 REM E£RND▘B▘\,,# RETURN▄""Q 7Q TAN ██████
330 REM E£RND▘▒▘\,,7# RETURN#COS RETURN▄4 RUN FASTLN ▀# LPRINT ▞;[S]C▖( CLS/ DIM ▘5 \,,Q▌\,,#Q▌MWRND\,,#Q▌MXRND\,,Q*▞▘VAL ▞ COPY( RETURNAT ( SAVE ▘ TO COPY\,,UXRND#\,,UWRND#\,,Q \,,/[O]..............
340 REM Y=M*#MU#TAN
350 REM )WRNDE£RND▘# \,,▘▌ GOSUB [K]E£RND▞▖VAL ▞▛7Q ( CLS▘, \,,AT ( LET ▞$VAL E£RND7# RETURN▟4 IF F#7Q 7# RETURN▙4 IF Q 7#▞▌VAL ▞ ( RETURNAT ( SAVE AT ( AND ▞\~~VAL E£RND▘9 \,,▞£7#F#7( RAND Q ▘$ \,,▞£F#7#F( RAND Q ▞▌VAL ▞ ( RETURNAT ( SAVE AT (SGN ▞▒VAL E£RND▘# \,,▞"7#F#7( RAND Q ▘£ \,,▞"F#7#F( RAND Q ▞▌VAL ▞ ( RETURNAT ( SAVE AT (SGN #W#████████████████
360 REM ▞▞VAL E£RND▘# \,,▞\~~7#F#7( RAND Q ▘" \,,▞\~~F#7#F( RAND Q ▞▌VAL ▞ ( RETURNAT ( SAVE AT (SGN ▞▖VAL E£RND▘["] \,,▞\,,7#F#7( RAND Q ▘\~~ \,,▞\,,F#7#F( RAND Q ▞▌VAL ▞ ( RETURNAT ( SAVE AT (SGN #TAB #...........................
370 REM ▞\,,VAL ▘D▘E£RND\,,##▘▒▘E£RND\,, GOSUB [S]E£RND7# RETURN#C▖Q / PLOT ▞=VAL ▞ ( RETURNAT ( SAVE AT (PEEK #C#██████████████████████████████████████████████
380 REM E£RND7Q▛▞▌7Q▀( CLS7Q▜▘. \,,Q▌7QB7QO7QN7QU7QS7Q▐▘. \,,Q▌▘▞ \,,Q▐▘. \,,Q▙▞▌7Q▄( CLS7Q▟E£RND▘# \,,##5WRND▘▌ GOSUB [K]#[▒]#.
390 REM LN ##LN D#▞\~~VAL ▞ ( RETURNAT ( SAVE E£RND▘# \,,7# RETURN▐C▞ RETURN04 TO / POKE E£RND)$#7<# RETURN#4▘7, RETURN*C▀#/ LIST ▞\~~VAL ▞ COPYVAL ▞ COPY( RETURNAT ( SAVE AT ( PAUSE E£RND)▙RND<7# RETURN#4▘7, RETURN*C▀#/ LIST F)1PI7<# RETURN#4▘7, RETURNSC▀#/ LIST LN ##LN ### PRINT #████
400 REM WELL DONE.YOU HAVE DESTROYED THE SPACE SHIP AND SLOWED DOWN THE INVASION. SUPERIOR FORCES ARE ON THEIR WAY TO CONQUOR YOUR PLANET*
410 REM U*# RETURN▙C▌LEN ▌M*#UU# RETURN▖C▌LEN RETURNMU####.................
420 REM INVASION FORCE \~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~ AUTHOR : SIMON WADSWORTH COPYRIGHT 1982 : ARTIC COMPUTING YOU ARE THE SOLE DEFENDER OFTHE EARTH AGAINST A HUGE ARMY OFHOSTILE ALIENS. YOU HAVE THREE LASER BASES WITH WHICH TO THWART THE ATTACK.*
430 REM THE MAIN OBJECTIVE IS TO MAKE A HOLE IN THE MOVING FORCE-FIELD AND TO FIRE AT THE ALIENS THROUGH IT.THEN YOU MUST DESTROYTHE MAIN SHIP BY SHOOTING THE THIN LINES OF GREY WHICH ARE SETINTO THE TOP OF THE SHIP. BEWARE OF THE BLACK BLOBS INTHE FORCE FIELD.IF YOU HIT ONE THEN ALL DAMAGE DONE TO THE MAINSHIP IS REPAIRED. PRESS ANY KEY FOR FURTHUR INSTRUCTIONS "
440 REM ▞4VAL E£RND7▞/VAL ▞37#F#7( RAND Q AT 77( LOAD AT ( FASTTAN LN [V]▝# RETURN COPYC SAVE LN [V]▝# RETURN COPY4 SAVE TAN .................
450 REM LN P#E£RND)B## RETURN#4▘7, RETURN*4▖)##, RETURN"C▌#7</ CONT LN ##LN P#E£RND)6## RETURN#4▘7, RETURN+C▌#7</ LIST LN )#LN ##LN J#TAN ▞▝VAL ▞ COPYVAL ▞ COPY( RETURNAT ( SAVE AT ( PAUSE TAN ........................................................................
460 REM " INVASION FORCE \~~\~~\~~\~~\~~\~~\~~\~~\~~\~~ \~~\~~\~~\~~\~~\~~\~~ THIS IS MAIN SHIP OF THE ALIENS. A BOMB SHIP IS A ▄▙ AND DROPS ASTERISKS (*) ON YOUR SHIP. THIS IS YOUR SHIP : ▗ CONTROLS : ▗▛▙ [1]-LEFT,[3]-RIGHT AND [9]-FIRE. THE GAME IS OVER WHEN YOU HAVE RUN OUT OF SHIPS OR THE BONUS REACHES ZERO. PRESS ANY KEY TO START THE GAME+"
480 REM LN ##LN ##LN ##LN [9]#LN [/]#LN TAB #LN TAN #LN DIM #LN \,,#LN D#LN [?]#LN ##LN [4]#LN ASN #LN POKE #...................................................................................
490 REM ▞4VAL E£RND▘*▀\,,▞/VAL ▞3F#7#F( RAND Q AT FF( LOAD AT ( LLIST TAN ...........
500 REM INVASION FORCE \~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~\~~ TO WHICH OF THESE CATEGORIES DO YOU BELONG ? [B]EGINNER OR [E]XPERT*
510 REM E£RND)### RETURN#4▘7, RETURN*C▌#7</ LIST LN [V]▝# RETURN CLSC" RETURN#4 POKE Y▘M#RND/▖Y / RUN LN P#TAN .......................................
520 REM U#RND RETURN COS ▞;VAL ▞ COPY( RETURNAT ( SAVE TAN ...............
530 REM E£RND▘ STEP ▝LN ##TAN
540 REM THE HIGHEST SCORE TODAY IS < 005000 > BY ▌ NOBODY YET ▐ PRESS ANY KEY TO CONTINUE*
550 REM )J#E£RND▘# \,,# RETURN#4▘7, RETURN*C▌#7</ LIST LN ##LN J#TAN ...................
560 REM WELL DONE.YOU HAVE BEATEN THE HIGH SCORE.PLEASE ENTER YOUR NAME.(12 LETTERS MAXIMUM) ▌ ▐*
570 REM 5VRND)##7<, RETURN COS #[S]C PLOT SQR LN TAB #LN P#E£RND▘▒▘\,,)["]#7<# RETURN#4▘7, RETURN*C▀#/ LIST )##5WRND▘▞ GOSUB [K]# CONT #.................................................................
580 REM E£RND▘SGN ▘\,, FASTLN [V]▝G4 IF LN [V]▝###=C RUN LN [X]▛# RETURN#CB RETURN#4( LPRINT FASTF# RETURN▌4▀ LPRINT / OR Q SGN /USR ACS #4SGN LPRINT PRINT # RETURN▐4▀ LET /LEN LET #7/AT LPRINT E£RND▘SGN ▘\,,) RAND #▘£ GOSUB [K]▘( LPRINT \,, FASTTAN ...
590 REM LN ##LN [.]#LN ##LN ##LN ##LN [9]#LN [/]#LN TAB #LN TAN #LN DIM #LN \,,#LN D#LN [?]#LN ##LN [4]#LN ASN #LN POKE #LN [U]#LN ##LN ,#LN [~~]#LN NEW#LN REM #LN D#LN [Z]#LN SLOW#LN ▘#LN RAND #/TAB ..........
600 SAVE "INVASIO[N]"
610 SLOW
620 LET L=USR 23118
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.