--- title: "ZXMAN" id: 56851 type: "computer_media" slug: "zxman" url: "http://localhost/computer_media/zxman/" markdown_url: "http://localhost/computer_media/zxman.md" published_at: "2024-09-29T07:31:33+00:00" modified_at: "2026-03-30T21:20:46+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/09/319_ZXM.png" excerpt: "Guide your character around a walled grid, dodge a random ghost, and survive until time runs out — all driven by clever character-code arithmetic." 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: "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_contents: - id: 56738 title: "Timex Sinclair Public Domain Library Tape 1007" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1007/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/09/319_ZXM.png" media_type_tags: "Arcade, Game" --- This program implements a two-dimensional maze-like movement game where the player navigates a character around a grid bounded by asterisk walls. Player position is controlled by keys 5, 6, 7, and 8 (the standard ZX directional keys), and the program tracks a score countdown from a starting value derived from CODE “%£” (the pound sign character code). A randomly appearing ghost character threatens the player, and boundary detection ends the game if the player hits the edges of the play area. All coordinate limits and initial positions are derived from character CODE values rather than literal numbers, saving memory and providing a degree of platform-adaptive positioning. *** ## Program Analysis ### Program Structure The program is organised into four logical phases: 1. **Initialisation (lines 10–50):** All key constants are derived from `CODE` of specific characters rather than hard-coded literals. 2. **Screen draw (lines 60–100):** A bordered play field of asterisks is printed, with a title banner. 3. **Game loop (lines 110–200):** A `FOR` loop counts down the score; inside it, player input is read, the player sprite is moved, boundary and goal checks are made, and a ghost is randomly placed. 4. **End states (lines 210–250):** “TIMES UP”, `STOP`, `CLEAR`, `SAVE`, and `RUN` provide restart infrastructure. ### Character-Code Constants Rather than embedding raw numbers, the program derives all key values from `CODE` of printable characters. This is a common memory-saving idiom on Sinclair machines where short expressions can replace longer literal strings in tokenised BASIC. | Variable | Expression | Resolved value | Role | | --- | --- | --- | --- | | `L` | `CODE " "` | 32 | Space character code; used as a general-purpose constant (column 32, loop start, edge detection) | | `A`, `B`, `M` | `CODE "▘"` (block graphic char) | 130 | Initial player row/column and step size — but see anomaly note below | | `I` | `CODE "("` | 40 | Right boundary column | | Loop end/ghost range | `CODE "%£"` (inverse £) | 96 | Score countdown start and ghost random range | | Loop bound line 70 | `CODE "\~~"` | Approximately 14 | Number of rows to draw wall lines | | Bottom edge | `CODE ":"` | 58 | Lower boundary row for kill detection | Note: `A` and `B` are initialised to `CODE "▘"` (130) which far exceeds the ZX81’s screen coordinate space (rows 0–21, columns 0–31). This means the player sprite is placed off-screen at the start, which is a likely bug — the player’s initial position should probably be a small on-screen coordinate. ### Key Input and Movement Movement uses the standard five-key layout. Lines 120–130 update player coordinates: - `INKEY$="6"` increments row `A` (down) - `INKEY$="7"` decrements row `A` (up) - `INKEY$="8"` increments column `B` (right) - `INKEY$="5"` decrements column `B` (left) The player sprite (`"C"`) is printed at position `AT A,B` and then erased with a space on the next iteration (line 160), implementing basic sprite flicker movement without any machine code. ### Game Mechanics The score countdown runs via `FOR F=CODE "%£" TO L STEP -M` (line 110), decrementing from 96 toward 32 with a step of `-M` (which equals 130, making the step far larger than the range — the loop will execute only once or not at all as intended). This is another consequence of the off-screen initial value of `M`. Boundary detection (line 170) kills the player if `A=L` (row 32), `A=CODE ":"` (row 58), `B=L` (column 32), or `B=I` (column 40). These bounds seem plausible for a sub-region of the display but depend on the player actually reaching on-screen coordinates. The ghost (line 190–199) is placed when `E=A` and `B