--- title: "Super Invasion" id: 58455 type: "computer_media" slug: "super-invasion" url: "http://localhost/computer_media/super-invasion/" markdown_url: "http://localhost/computer_media/super-invasion.md" published_at: "2024-11-17T22:07:32+00:00" modified_at: "2026-04-03T12:46:06+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "A three-level Space Invaders-style game that uses a clever POKE formula to set difficulty before handing control to machine code." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Beam Software" slug: "beam-software" taxonomy: "post_tag" url: "http://localhost/tag/beam-software/" - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "Softsync" slug: "softsync" taxonomy: "post_tag" url: "http://localhost/tag/softsync/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Super%20Invasion%20%281981%29%28Beam%20SW%29%28ZX81%20-%201K%29%28US%29%28Program%29.zip" mediadate: "1981" producer_company: - id: 11319 title: "Softsync, Inc." type: "company" url: "http://localhost/company/softsync/" related_products: - id: 14129 title: "Super Invasion" type: "product" url: "http://localhost/product/super-invasion/" media_type_tags: "Game" --- Super Invasion is a machine code game loader that configures difficulty and launches a Space Invaders-style arcade game stored in memory. The BASIC portion is minimal: it prompts the player to select a level from 1 to 3, validates the input, and uses a POKE to write a difficulty parameter into the machine code at address 17178, computed as 30*B−26 (yielding 4, 34, or 64 for levels 1, 2, and 3 respectively). Execution is then transferred to the machine code routine at address 17267 via PRINT USR, which runs the game and never returns a meaningful value to BASIC. The program assumes the machine code is already loaded into RAM above the BASIC area. *** ## Program Analysis ### Program Structure The BASIC listing is a compact five-line loader. Lines 100–130 handle user interaction and input validation, line 140 configures the machine code, and line 1000 launches it. The large gap between line 130 and line 1000 suggests that additional BASIC lines may have been removed or that the numbering was intentional to place the launch statement far from the setup block. ### Difficulty Configuration via POKE Line 140 writes a single byte into the machine code at address 17178 using the formula `30*B-26`. This produces the following values depending on the chosen level: | Level (B) | Value POKEd | | --- | --- | | 1 | 4 | | 2 | 34 | | 3 | 64 | The increasing values most likely represent a speed or timing parameter within the machine code — a larger value could correspond to a faster alien movement cycle or a shorter delay loop count, increasing difficulty. ### Machine Code Invocation Line 1000 uses `PRINT USR 17267` to transfer control to the machine code routine starting at address 17267. The `USR` function calls the address as a subroutine and is expected to return an integer for `PRINT` to display, but in practice the machine code game loop never returns, so the `PRINT` is purely a vehicle for the `USR` call. This is a common idiom for launching machine code from BASIC without using `RAND USR`. ### Input Validation Line 120 enforces the valid range with `IF B<1 OR B>3 THEN GOTO 110`, looping back to the `INPUT` statement until a value of 1, 2, or 3 is entered. Non-numeric input would cause a BASIC error rather than being caught by this guard, but integer inputs outside the range are handled cleanly. ### Notable Techniques - Using `PRINT USR` instead of `RAND USR` to call machine code is an alternative idiom that works equally well when the routine does not return. - The single linear formula `30*B-26` encodes three distinct difficulty values without requiring a lookup table or multiple `IF` branches, keeping the loader extremely compact. - The `CLS` at line 130 clears the screen before the difficulty POKE and game launch, ensuring a clean display when the machine code takes over. ## Source Code ``` 100 PRINT "LEVEL?" 110 INPUT B 120 IF B<1 OR B>3 THEN GOTO 110 130 CLS 140 POKE 17178,30*B-26 1000 PRINT USR 17267 ```