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 USRinstead ofRAND USRto call machine code is an alternative idiom that works equally well when the routine does not return. - The single linear formula
30*B-26encodes three distinct difficulty values without requiring a lookup table or multipleIFbranches, keeping the loader extremely compact. - The
CLSat line 130 clears the screen before the difficulty POKE and game launch, ensuring a clean display when the machine code takes over.
Content
Image Gallery
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
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.