--- title: "Galactic Gunner" id: 51885 type: "computer_media" slug: "galactic-gunner" url: "http://localhost/computer_media/galactic-gunner/" markdown_url: "http://localhost/computer_media/galactic-gunner.md" published_at: "2023-08-16T01:42:21+00:00" modified_at: "2026-04-04T20:17:52+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2023/08/SCR-20260404-eapg.png" excerpt: "Scan the galaxy, lead your target, and fire lasers at enemy ships in this machine-code-driven space shooter with five skill levels and a 25-shot limit." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "Timex Computer Corporation" slug: "timex-computer-corporation" taxonomy: "post_tag" url: "http://localhost/tag/timex-computer-corporation/" - 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: "Arcade" slug: "arcade" taxonomy: "genre" url: "http://localhost/type/arcade/" - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_type: "Cassette" download_url: "https://archive.org/download/timex-sinclair-software-archive/Galactic Gunner (1983)(Timex)(US)(TS1000)(Cassette).zip" mediadate: "1983" producer_company: - id: 11401 title: "Timex Computer Corporation" type: "company" url: "http://localhost/company/timex-computer-corporation/" images: - url: "http://localhost/wp-content/uploads/2023/08/SCR-20260404-eapg.png" - url: "http://localhost/wp-content/uploads/2023/08/SCR-20260404-eate.png" related_products: - id: 11832 title: "Galactic Gunner" type: "product" url: "http://localhost/product/atlantic-gunner/" media_type_tags: "Arcade, Game" --- 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: 1. **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. 2. **Lines 43–62:** REM statements containing raw Z80 machine code bytes, loaded into memory and called via `USR`. 3. **Lines 100–540:** Main BASIC program: initialization, title screen, skill-level selection, game setup, and post-game loop. 4. **Lines 1000–1070:** Instructions subroutine. 5. **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 characters - `POKE 19977,0 / 19978,0` — score reset - `POKE 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. - `RAND` at line 110 seeds the random number generator for varied enemy behavior. - `POKE 16418,0` at 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 AT` with multiple `TAB` calls to render a multi-line box on a single `PRINT` statement, reducing line count. ## 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 150302AFF4B1110A7ED52304CDF150C922FF4BCD3D4E3A14CFE1920ECDF150C9000000000021191003A7ED42283918F73AFE4BFE0CCB750C3CD521B1B1B1B1B1B241C1B1B 44 REM 03A564CFE0CAD44ECD914D3A564C3C32564CFE5203BAF32564CC397528F4D11D819ED4BD04CA7ED422017AF32FE4BCDFD50CDE4E3E10328F4D3EB32904DCD914DC324C00000CD914DC3D44ECD144D0914DCDCE5121191003A7ED4228A2918F71B1D1D1C1B1B1B1B1B1B 45 REM 311DA14838438481481813872848228780808080808080809B8080808080808080218240114603AD14CFE0284471910FD3AD04CFE0C8472310FDC90000CDF44CEB21E44C3E4140EDB03DFE0288EB14209EB18EE3AFE4BFE0C80000CDC84FCDF44C22D24C11E44C3E4140EDB03DFE028B1420918F000000ED5BD24C21D44C3E4F5641AFE82827E12231310F5F13DFE0C8EB14209EB18E51B1D241C1B1B1B1B1B 46 REM 10B218240114603A904DFE0284471910FD3A8F4DFE0289472310FD00000ED5BC40133E151200EDB03DFE028C131260918EF000002AC4011B501963112101936BB10FB2AC4011551196323369210FB2323236323369310FBC91B1D1D1C1B1B1B1B1B1B 47 REM 000013AD4E472A94E11A01910FD2294E01717CD594EED5BB4EA7ED52D81922B4E11A17CD594EC9000002AFF4B1716CD594EC93A14C6F26011A16CD594EC900000E5CD7B4E22E40ED433940E1D5E5C3ABAC91B1B1B1B1B1B1B1B1B1B 48 REM F5C5D52AC402378FE028747112101910FD79FE0284472310FDD1C1F1C91B1B1B1B1B1B201C1B1B 49 REM D52A3240545D291929292929192929291929291929291929291911193619223240D1C9 50 REM CD914FCDBB2ED4B8F4DCB4C285EB1816003A14C3C3214CCD474E3E132564CC3574C0021F7DFA7ED5220EAFB9206CD814FC35C4FDC3584F21EFDFA7ED5220143E15B8206CD814FC35C4F4C3584F0000021EFEFA7ED5220EAFB8206CD814FC35C4F5C3584F21EFF7A7ED52C25C4F3E20B9206CD814FC35C4FCED438F4DCD144DCD914DC324C1B1B1D211C1B1B1B1B1B 51 REM 80B8A8A6B380B1AEB2AEB9801A15CD7B4EEB21754F1C0EDB0C91A15CD7B4E6C3602310FBC9 52 REM 377812112322343345445655676678778183AD14CFE630611B84FC31250FE2438611A84FC312503AD04CFEC30611B04FC31250FE3538B11C04FC31250000003AA64F6F3AA74FBD202F3AA54F4711A44F1313131310FACDAB4E3E3A46F260197E32A54FAF32A74FCDAB4E3E7A4C6532A64F0000021A74F34CD5C50C91B1B1D211C1B1B1B1B1B 53 REM 755079507E50825087508B5090509450ED4BD04C214A503AA54F875F160195E2356EBE9000005C396505CC39650CC396504CC396504C396504DC39650DC396505DED43D04CC91C1B1B1B1B1B1B1B1B1B 54 REM 16201B193295531E7CDAB4E3E3A43C4721A85023232310FB11D04C120EDB07E32A54FAF32A74F3E532A64F3E132FE4BC33C4D1B221C1B1B1B1B 55 REM AF32FE4BC3144D00000CDF15065C5CD1851CD3051C110F6C91F1C1B1B1B 56 REM 2AC40233E15F56207EEE80772310F923F13DFE020EFC921191003A7ED42C8918F81B1C1B1B1B1B1B1B1B1B 57 REM ' ' ' ' ' ' ' :' ' ' :' ' ' ' : ' ' ' : ' ' ' ' : ' ' :' ' ' ' ' : ' ' : ' ' ' ' ' ' ' ' ' ' :' ' ' ' ' ' ' ' ' : 58 REM 14113A564CFE22844FE32820114E513E56421CA22CC51CD4C521162513E4632110B22CC51CD4C52116E513E564219E22CC51CD4C521182513E5642112E22CC51CD4C521196513E4662151122CC51CD4C5211AE513E46621141122CC51CD4C52C91B1D1D1C1B1B1B1B1B1B 59 REM 16324A5278324B52ED4BCC51CD7B4EEB3A4B52477EFE128112132310F63A4A523DFE0C8324A5200000EB3A4B524F3E21914F609EB18D41B1B1B1B1B1B1B231C1B 60 REM 1FACD7B4E3E80BECA24C3E8BECA24C3E9BBECA24CC3834C1B1F1C1B1B1B1B1B1B 61 REM 2AB4EC3314E 62 REM CDBB211FDFBA7ED52C2574CCDF44CEB21E44C3E4140EDB03DFE0288EB14209EB18EEC91B1B1B1B1B1B1B1B211C 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 ```