Galactic Gunner is a space-combat shooting game in which the player scans a scrolling galaxy view and fires lasers at moving enemy ships within a time and ammunition limit. The game uses extensive machine code routines embedded in REM statements (lines 43–62), which are invoked via USR calls at lines 490–500 to handle the core gameplay logic including ship movement, collision detection, and scoring. Five skill levels adjust internal machine code parameters by POKEing values derived from the formula N=11-2*I into specific memory addresses. The title screen features large block-graphic text spelling out the game title, and the star-field background in the REM lines (lines 1–42) is rendered using inverse-video period characters to simulate a starfield display.
Program Analysis
Program Structure
The program divides into several clear sections:
- Lines 1–42: REM-based decorative starfield and title graphic data, using inverse-video percent signs (
%) and block graphics to render a star-filled space backdrop with a planet/asteroid graphic. - Lines 43–62: REM statements containing raw Z80 machine code bytes, loaded into memory and called via
USR. - Lines 100–540: Main BASIC program: initialization, title screen, skill-level selection, game setup, and post-game loop.
- Lines 1000–1070: Instructions subroutine.
- Lines 2000–2100: Save and restart utility.
Machine Code Usage
The game’s core logic is entirely implemented in Z80 machine code embedded in REM statements beginning at line 43. Four USR calls invoke these routines:
| Line | USR Address | Purpose (inferred) |
|---|---|---|
| 490 | 21185 ($52C1) | Game initialization / setup |
| 492 | 20029 ($4E3D) | Enemy ship spawning / movement init |
| 494 | 20039 ($4E47) | Secondary ship routine |
| 500 | 19458 ($4C02) | Main game loop (movement, firing, scoring) |
The machine code uses addresses in the $4Cxx–$52xx range, which corresponds to the REM statement data area. Parameters are passed by POKEing values directly into specific addresses within the machine code before the USR calls.
Skill Level System
Lines 340–450 configure the game by POKEing derived values into machine code parameter locations. The formula N = 11 - 2*I (where I is 1–5) produces values 9, 7, 5, 3, 1 for increasing difficulty. These are written to three addresses: 19502, 19635, and 20786, likely controlling enemy ship speed or firing rate. Additional POKEs set fixed parameters such as shot count and timing constants:
POKE 19454,0 / 19455,231 / 19456,3— likely sets a 16-bit timer or counter to 999 ($03E7)POKE 19440,16 / 19856,11— ship display charactersPOKE 19977,0 / 19978,0— score resetPOKE 19981,I— stores skill level for score multiplier (10 × skill level per kill)
Title Screen Graphics
The title screen uses two large-text PRINT statements (lines 130 and 140) built from ZX block graphics characters to render the game title in a pseudo-bitmap font. Lines 1–42 of REM data form a decorative starfield using inverse-video period characters, with a planet graphic formed by \## (solid block) characters in the center-right region (approximately lines 9–28). A spacecraft silhouette near lines 30–33 uses four-quadrant block characters (\''\': \.:\. etc.) to render a small pixel-art ship.
Key BASIC Idioms
LET L=USR n— The return value of the machine code is discarded;LET L=is used purely to invoke the routine.IF INKEY$="" THEN GOTO n— Standard busy-wait for any keypress.LET I=CODE INKEY$-28— Converts the character code of keys “1”–”5″ (codes 29–33) to integers 1–5 in a single expression.RANDat line 110 seeds the random number generator for varied enemy behavior.POKE 16418,0at line 115 clears the FRAMES system variable to reset timing.
Instructions Subroutine
The subroutine at lines 1000–1070 presents four screens of game instructions using PRINT AT with long string literals that rely on the display’s automatic word-wrapping at 32 columns. Each screen waits for any keypress via the IF INKEY$="" THEN GOTO n idiom before continuing.
Save and Restart
Line 2000 contains a SAVE command for preserving the program, and line 2100 returns execution to line 100 to restart the title screen. This two-line block is separate from the main program flow and is intended to be run manually by the user when saving.
Notable Techniques
- The starfield in REM lines 1–42 is purely cosmetic but demonstrates careful use of inverse-video characters and block graphics to create atmosphere without any runtime drawing code.
- Embedding machine code in REM statements is a standard technique that keeps the binary data protected from accidental editing and allows it to be addressed by fixed memory offsets relative to the start of the BASIC program area.
- The game over / play-again logic at lines 510–540 uses
PRINT ATwith multipleTABcalls to render a multi-line box on a singlePRINTstatement, reducing line count.
Content
Source Code
1 REM % % % % %.% % % % % % %.% % % %.% % % % % % % % %.% % % % %.% % % % %.%.% % % % % % % %.% % % % % % %.% % %.% % % % % % %.% % %
2 REM % % % %.% % % %.% % % % % % % % % %.% % % %.% % % % %.% % % % % %.% % % % % % % % %.% % %.% % % % % % % % % %.% % % %.% % % %.%
3 REM % % % %.% % % % % % % % % %.%.% % % % % % %.% % % % %.%.% % % % % %.% % % %.% % % % % %.% % %.% % % % % %.% % % % %.% % %.% % %
4 REM %.% % % % % %.% % % % %.%.% % % % % % %.% % % % %.% % % % % %.% % % % % %.% % % % % %.% % % % % % % % % % % % %.% % % %.% % % %
5 REM % % % % % % % %.% % % % % % % % % % % % %.% % % % % % % % %.% % % % %.% % % % % % % % %.% % % % % % % % % % % %.% % % % %.% % %
6 REM % % %.% % % % % % % % % % % %.% % % % % % % % %.% % % % % %.% % % % % % % % % % % %.% % % % % % % % % %.% % % % % %.% % % % % %
7 REM %.% % % % % % % % % %.% % % % % % % % %.% % % %.% % % % % % %.% % % % % %.% % % % % % % %.% % % % % % % % % %.% % % % % % % % %
8 REM % % % %.% % % % % % % % %.% % % % % % % % % % % %.% % % % %.% % % % % % % % %.% % % % % % % % % %.% % % % % % % % % %.% % % % %
9 REM % % %.% % % % % %.% % % % % ####% % % % % %.% % % % %.% % %.% % % % % % % %.% % % % % % %.% % % % % % % % % % % %.% % % % %.% %
10 REM % % % % %.% % % % % % % ################% % % % % % % %.%.% % % % % % %.% % % % % %.% % % % % % % % % %.% % % % % %.% % % % % %
11 REM % % % % % %.% % % % % ####################% % % %.% % % % % % %.% % % % %.% % % % % % % % % % %.% % % % % % % %.% % % %.% % % %
12 REM % % % % % % % %.% % % % ##########################% % % % %.% % % % % % % % %.% % % % % % % % % % %.% % % %.% % % % % % % % % %
13 REM % % % %.% % % % % % % %.% ##########################% %.% % % % % % % %.% % %.% % % % % % % %.% % % % % % % % % % %.% % % % % %
14 REM %.% % % % %.%.% % % %.% % ##############################%.% % % % % %.% % % % % % % % % %.% % % % % % %.% %.% % % %.% % % % % %.
15 REM % %.% % % % %.% % % % % % % ##############################% %.% % %.% % % % % % % % % % % %.% % %.% % % % % % % %.% % % % % % %
16 REM % % % % %.% % % % % %.% % % % ########################% % % % % %.% % %.% % %.% % % % % % %.% % % % % % % % %.% % % % % % % % %
17 REM % % % % %.% % % % % %.% % % %.##########################%.% % % %.% % % % % % % % % % % %.% % % % % %.% % % %.% %.% % % % %.% %.
18 REM %.% % % % %.% %.% % % % % %.% %.######################%.% % % % % % % % %.% % %.% % % %.% % % % % % %.% %.% % % % % % % % %.% %
19 REM % % %.% % % %.% % %.% % % % % %.% ######% ##########% % % % % % % %.% % % %.% % % % % %.% % % % % % % % % % % % %.% % %.% %.% %
20 REM % %.% % % %.% % % % % % % % % %.% %.##% % % ####%.% % % % %.% % %.% % % % % %.% %.% % % % % %.######%.% % % %.% % % % %.% % %.%
21 REM % % %.% % % % % %.% % % % % %.%.% % % % % % % %.% %.% % %.% %.% % % % % % % % % %.% % % % ##############% % %.% % % %.% % % %.%
22 REM % % % % % % %.% % % % % % % % %.% % % % % % %.% % % % %.% %.% % % % % % %.% %.% % % % % ##################%.% % %.% % % %.% % %
23 REM % % % % % % % % % %.% % % % % % % % %.% % % % % % % %.% % % % % %.% % % % %.% % %.% % ######################% %.% % %.% % % % %
24 REM %.% % % % %.% % %.% % % % % % %.% % % %.% % % % % % % % % % %.% % % % % % % %.% % % ########################% % % % %.% % % % %
25 REM % % % % % % % % % % % % % %.% % % % % % %.% % % % % % %.% % % % %.% % %.% % %.% % % ######################%.% % %.% % %.% % % %.
26 REM % % %.% % % % % %.% % % % % % % % % %.% % % %.% % % %.% % % % % % % %.% %.% % % % %.% ##################% % % %.% % %.% %.% % %
27 REM % % % % % %.% % % % %.% % % % % % % % %.% % % % % % % % % % % % % % % %.% %.% % % % % % %.##########%.% % %.% % %.% % % % %.% %.
28 REM %.% % % %.% % %.% % % % % % % % %.% %.% % % % % % % %.% % % % % % % % % %.% % % % % %.% %.% % ####% % % % % %.% % % % % %.% % %
29 REM % % % % %.% % % % % % %.% % % %.% % % % % % % % %.% % % % %.% % % % %.%.% % % % % % % %.% % % % % % %.% % %.% % % % % % %.% % %
30 REM % % % %.% % % %.% % % % % % % % % %.% % % %.% % % % %.% % % % % %.% % % % % % % % %.% % %.% % % % ''':''':% %.% % % %.% % % %.%
31 REM % % % %.% % % % % % % % % %.%.% % % % % % %.% % % % %.%.% % % % % %.% % % %.% % % % % %.% % %.% % .:. .:.:% % % % %.% % %.% % %
32 REM %.% % % % % %.% % % % %.%.% % % % % % %.% % % % %.% % % % % %.% % % % % %.% % % % % %.% % % % % % '' . '':% % %.% % % %.% % % %
33 REM % % % % % % % %.% % % % % % % % % % % % %.% % % % % % % % %.% % % % %.% % % % % % % % %.% % % % % :. ' .% % % %.% % % % %.% % %
34 REM % % %.% % % % % % % % % % % %.% % % % % % % % %.% % % % % %.% % % % % % % % % % % %.% % % % % % % % % %.% % % % % %.% % % % % %
35 REM %.% % % % % % % % % %.% % % % % % % % %.% % % %.% % % % % % %.% % % % % %.% % % % % % % %.% % % % % % % % % %.% % % % % % % % %
36 REM % % % %.% % % % % % % % %.% % % % % % % % % % % %.% % % % %.% % % % % % % % %.% % % % % % % % % %.% % % % % % % % % %.% % % % %
37 REM % % %.% % % % % % % % % % % %.% % % % % % % % %.% % % % % %.% % % % % % % % % % % %.% % % % % % % % % %.% % % % % %.% % % % % %
38 REM % % % % % % % %.% % % % % % % % % % % % %.% % % % % % % % %.% % % % %.% % % % % % % % %.% % % % % % % % % % % %.% % % % %.% % %
39 REM %.% % % % % %.% % % % %.%.% % % % % % %.% % % % %.% % % % % %.% % % % % %.% % % % % %.% % % % % % % % % % % % %.% % % %.% % % %
40 REM % % % %.% % % % % % % % % %.%.% % % % % % %.% % % % %.%.% % % % % %.% % % %.% % % % % %.% % %.% % % % % %.% % % % %.% % %.% % %
41 REM % % % %.% % % %.% % % % % % % % % %.% % % %.% % % % %.% % % % % %.% % % % % % % % %.% % %.% % % % % % % % % %.% % % %.% % % %.%
42 REM % % % % %.% % % % % % %.% % % %.% % % % % % % % %.% % % % %.% % % % %.%.% % % % % % % %.% % % % % % %.% % %.% % % % % % %.% % %
43 REM 150 3 02AFF4B11 1 0A7ED5230 4CDF150C922FF4BCD3D4E3A 14CFE1920 ECDF150C9 0 0 0 0 0 0 0 0 0 021 1 9 1 0 0 3A7ED4228 3 918F73AFE4BFE 0CCB750C3CD521B1B1B1B1B1B241C1B1B
44 REM 03A564CFE 0CAD44ECD914D3A564C3C32564CFE 5203BAF32564CC397528F4D11 D 819ED4BD04CA7ED422017AF32FE4BCDFD50CD E4E3E10328F4D3E B32904DCD914DC3 24C 0 0 0 0 0CD914DC3D44ECD144D 0914DCDCE5121 1 9 1 0 0 3A7ED4228A2 918F71B1D1D1C1B1B1B1B1B1B
45 REM 311DA148 384 38481 48181 387 28482 28780808080808080809B80808080808080802182401146 03AD14CFE 028 4471910FD3AD04CFE 0C8472310FDC9 0 0 0 0CDF44CEB21E44C3E 4 1 4 0EDB03DFE 028 8EB 142 0 9EB18EE3AFE4BFE 0C8 0 0 0 0CDC84FCDF44C22D24C11E44C3E 4 1 4 0EDB03DFE 028 B 142 0 918F0 0 0 0 0 0ED5BD24C21D44C3E 4F5 6 41AFE 828 27E12231310F5F13DFE 0C8EB 142 0 9EB18E51B1D241C1B1B1B1B1B
46 REM 10 B2182401146 03A904DFE 028 4471910FD3A8F4DFE 028 9472310FD 0 0 0 0 0ED5B C40133E15 120 0EDB03DFE 028 C13 126 0 918EF 0 0 0 0 02A C4011B5 019 6 31121 01936BB10FB2A C401155 119 6 323369210FB232323 6 323369310FBC91B1D1D1C1B1B1B1B1B1B
47 REM 0 0 0 0 13A D4E472A 94E11 A 01910FD22 94E 0 1 717CD594EED5B B4EA7ED52D81922 B4E 11A17CD594EC9 0 0 0 0 02AFF4B 1 716CD594EC93A 14C6F26 0 11A16CD594EC9 0 0 0 0 0E5CD7B4E22 E40ED433940E1D5E5C3AB AC91B1B1B1B1B1B1B1B1B1B
48 REM F5C5D52A C402378FE 028 7471121 01910FD79FE 028 4472310FDD1C1F1C91B1B1B1B1B1B201C1B1B
49 REM D52A3240545D291929292929192929291929291929291929291911193619223240D1C9
50 REM CD914FCDBB 2ED4B8F4DCB4C28 5EB1816 0 03A 14C3C32 14CCD474E3E 132564CC3574C 0 021F7DFA7ED5220 EAFB920 6CD814FC35C4F DC3584F21EFDFA7ED5220143E15B820 6CD814FC35C4F 4C3584F 0 0 0 0 021EFEFA7ED5220 EAFB820 6CD814FC35C4F 5C3584F21EFF7A7ED52C25C4F3E20B920 6CD814FC35C4F CED438F4DCD144DCD914DC3 24C1B1B1D211C1B1B1B1B1B
51 REM 80B8A8A6B380B1AEB2AEB980 1 A15CD7B4EEB21754F 1 C 0EDB0C9 1 A15CD7B4E 6 C36 02310FBC9
52 REM 3 7 7 8 1 2 1 1 2 3 2 2 3 4 3 3 4 5 4 4 5 6 5 5 6 7 6 6 7 8 7 7 8 1 83AD14CFE 630 611B84FC31250FE2438 611A84FC312503AD04CFE C30 611B04FC31250FE3538 B11C04FC31250 0 0 0 0 03AA64F6F3AA74FBD202F3AA54F4711A44F1313131310FACDAB4E3E 3A46F26 0197E32A54FAF32A74FCDAB4E3E 7A4C6 532A64F 0 0 0 0 021A74F34CD5C50C91B1B1D211C1B1B1B1B1B
53 REM 755079507E50825087508B5090509450ED4BD04C214A503AA54F875F16 0195E2356EBE9 0 0 0 0 0 5C39650 5 CC39650 CC39650 4 CC39650 4C39650 4 DC39650 DC39650 5 DED43D04CC91C1B1B1B1B1B1B1B1B1B
54 REM 1620 1 B19 329 5 531 E 7CDAB4E3E 3A43C4721A85023232310FB11D04C 1 2 0EDB07E32A54FAF32A74F3E 532A64F3E 132FE4BC33C4D1B221C1B1B1B1B
55 REM AF32FE4BC3144D 0 0 0 0 0CDF150 6 5C5CD1851CD3051C110F6C91F1C1B1B1B
56 REM 2A C40233E15F5 6207EEE80772310F923F13DFE 020EFC921 1 9 1 0 0 3A7ED42C8 918F81B1C1B1B1B1B1B1B1B1B
57 REM ' ' ' ' ' ' ' :' ' ' :' ' ' ' : ' ' ' : ' ' ' ' : ' ' :' ' ' ' ' : ' ' : ' ' ' ' ' ' ' ' ' ' :' ' ' ' ' ' ' ' ' :
58 REM 14113A564CFE 22844FE 32820114E513E 5 6 421 C A22CC51CD4C521162513E 4 6 32110 B22CC51CD4C52116E513E 5 6 421 9 E22CC51CD4C521182513E 5 6 42112 E22CC51CD4C521196513E 4 6 621 51122CC51CD4C5211AE513E 4 6 621141122CC51CD4C52C91B1D1D1C1B1B1B1B1B1B
59 REM 1 6324A5278324B52ED4BCC51CD7B4EEB3A4B52477EFE 128 112132310F63A4A523DFE 0C8324A52 0 0 0 0 0EB3A4B524F3E21914F 6 0 9EB18D41B1B1B1B1B1B1B231C1B
60 REM 1 F ACD7B4E3E80BECA 24C3E 8BECA 24C3E9BBECA 24CC3834C1B1F1C1B1B1B1B1B1B
61 REM 2A B4EC3314E
62 REM CDBB 211FDFBA7ED52C2574CCDF44CEB21E44C3E 4 1 4 0EDB03DFE 028 8EB 142 0 9EB18EEC91B1B1B1B1B1B1B1B211C
100 CLS
102 POKE 19979,0
104 POKE 19980,0
110 RAND
115 POKE 16418,0
120 PRINT AT 0,11;"WELCOME TO "
130 PRINT AT 2,0; " .''''. .''''. : .''''. .''''. ''':''' ':' .''''. : ... :....: : :....: : : : : '....' : : :..... : : '....' : .:. '....'"
140 PRINT AT 6,0; " .''''. : : :. : :. : :''''' :''''. : ... : : : '. : : '. : :''' :'':' '....' '....' : ': : ': :..... : '. "
170 PRINT AT 10,2;"COPR., PAUL W. CARLSON, 1983"
175 PRINT AT 12,0; "% % %.% % % % % %.% % % % %.% % % % % % % %.% % % % % %.% % % % %.% % %.% ######% % %.% % % % % %.% %.% % % % % % %.% % %.% % %.% %.% % ############% % %.% % ''':''':% % % %.% % % % % % % %.% % % % ################%.% % % .:. .:.:% %.% % % %.% % ####% % % % % ################% % % %.% '' . '':% % %.% % % ##########% %.%.% %.############% %.% % % % :. ' .% %.% % % %.##############% % % % %.########% % % % %.% % % % %.% % % % %.% % ############% % %.% % ######%.% % % % % % % %.% % %.% % % % % % %.########%.% % % % %.% ##% % % %.% % % % %.% % % % % % %.% % %.% % % %.% % %.%.% %.% % % %.% % % % %.% % % %.% % % %.% % %.% % % % %.% % % % % % % % % %.% % % % % % % % % % %.% % % % % % % % % % % %.% % % "
180 PRINT AT 23,0;"DO YOU WANT INSTRUCTIONS? (Y/N)"
200 IF INKEY$="N" THEN GOTO 230
210 IF INKEY$<>"Y" THEN GOTO 200
220 GOSUB 1000
230 CLS
240 PRINT AT 3,9;":'''''''''''''''''''''''''': : SKILL LEVELS : :..........................:"
250 PRINT AT 8,10;"1 = BEGINNER"
260 PRINT AT 10,10;"2 = INTERMEDIATE"
270 PRINT AT 12,10;"3 = ADVANCED"
280 PRINT AT 14,10;"4 = EXPERT"
290 PRINT AT 16,10;"5 = SUPER-EXPERT"
300 PRINT AT 20,7;"PRESS SKILL LEVEL"
310 LET I=CODE INKEY$-28
320 IF I<1 OR I>5 THEN GOTO 310
330 CLS
340 POKE 19981,I
350 LET N=11-2*I
360 POKE 19502,N
370 POKE 19635,N
380 POKE 20786,N
390 POKE 19454,0
400 POKE 19455,231
410 POKE 19456,3
420 POKE 19457,0
430 POKE 19542,0
440 POKE 19855,16
450 POKE 19856,11
460 POKE 19977,0
470 POKE 19978,0
480 PRINT AT 22,2;"TIME:";TAB 20;"SHOTS:";TAB 1;"SCORE: 0";TAB 15;"HIGH SCORE:"
490 LET L=USR 21185
492 LET L=USR 20029
494 LET L=USR 20039
500 LET L=USR 19458
510 PRINT AT 6,8;" ";TAB 8; " GAME OVER ";TAB 8; " ";TAB 8; " PLAY AGAIN? ";TAB 8; " ";TAB 8; " (Y OR N) ";TAB 8; " "
520 IF INKEY$="N" THEN STOP
530 IF INKEY$<>"Y" THEN GOTO 520
540 GOTO 230
1000 CLS
1010 PRINT AT 0,0;"YOUR GOAL: TO GET AS MANY POINTS AS YOU CAN BY DESTROYING AS MANY ENEMY SHIPS AS YOU CAN WITHIN THE TIME LIMIT AND WITH 25 SHOTS. THE POINTS AWARDED FOR EACH SHIP DESTROYED EQUALS 10 TIMES THE SKILL LEVEL."
1020 PRINT AT 8,0;"USE THE 5, 6, 7 AND 8 KEYS TO SCAN THE GALAXY AND USE THE 0 KEY TO FIRE YOUR LASERS. YOUR LASERS WILL NOT PENETRATE INTO A NEBULA (GALACTIC DUST CLOUD)."
1030 PRINT AT 14,0;"IF ANY PART OF THE SHIP IS AT THE INTERSECTION OF THE CROSS- HAIRS WHEN THE LASERS ARRIVE THERE, THE SHIP IS DESTROYED."
1040 PRINT AT 19,0;"YOU MUST LEAD THE SHIP WITH YOUR SCANNER - THE SHIP CONTINUES TO MOVE AS THE LASERS ARE FIRING."
1050 PRINT AT 23,0;"PRESS ANY LETTER TO CONTINUE..."
1060 IF INKEY$="" THEN GOTO 1060
1061 CLS
1062 PRINT AT 10,0;"YOU CAN STOP THE GAME AT ANY TIME BY PRESSING THE ""S"" KEY."
1064 PRINT AT 20,0;"PRESS ANY LETTER TO CONTINUE..."
1066 IF INKEY$="" THEN GOTO 1066
1070 RETURN
2000 SAVE "GUNNE%R"
2100 GOTO 100
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

