Space Scape

This file is part of Timex Sinclair Public Domain Library Tape 1002 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Demo

This program generates a continuous starfield scrolling effect by filling a 32-character string with inverse space characters (CHR$ 128) and then printing a randomly positioned star character (CHR$ 155) on the bottom line. The SLOW command engages the ZX81’s SLOW mode, which allows the display driver to run simultaneously with the program, enabling smooth screen output. Each iteration uses SCROLL to move the display up one line, then PRINT with AT to place a new star at a random column position on row 21. The RND*31 expression produces a random column from 0 to 30, giving a non-uniform star distribution across the width of the screen.


Program Analysis

Program Structure

The program is compact, consisting of an initialisation phase (lines 10–50) and a continuous display loop (lines 60–80). Line 5 contains a REM statement spelling “SPACESCAP” in inverse video, serving as a program title. The main loop never terminates; GOTO 60 causes indefinite repetition.

  1. Lines 10–50: Initialisation — dimensions a 32-character string S$ and fills every position with CHR$ 128 (inverse space), forming a solid black line.
  2. Line 60: Scrolls the entire display up by one character row.
  3. Line 70: Prints the filled string S$ (effectively a blank/inverse line), then overlays a star character (CHR$ 155) at a random column on row 21.
  4. Line 80: Loops back to SCROLL, creating the animation.

Key BASIC Idioms and Techniques

  • CHR$ 128 — Inverse space on the ZX81, producing a filled black cell. Filling S$ with this character creates a solid background line against which the star stands out.
  • CHR$ 155 — A block graphic character used as the “star” pixel. Its exact appearance depends on the character set, but it renders as a bright spot distinct from the inverse-space background.
  • SLOW mode (line 20) — Activates the ZX81’s SLOW display mode, which interleaves CPU execution with display refresh. This prevents the screen from blanking during computation and gives smoother visual output.
  • PRINT S$;AT 21,RND*31;CHR$ 155 — A single PRINT statement combining the background string and star placement. The semicolon suppresses the newline after S$, and AT repositions the cursor mid-statement for efficient star rendering.

Star Distribution

RND*31 produces a value in the range [0, 31), so column 31 (the rightmost) is never selected. This means stars are distributed across columns 0–30 only, leaving the rightmost column perpetually empty. This is a minor cosmetic anomaly rather than a functional bug.

Notable Observations

  • The 32-character DIM S$(32) matches the ZX81’s 32-column display width exactly, ensuring the inverse-space line spans the full row.
  • Because S$ is printed first and then the star is placed with AT, the bottom line always shows exactly one star per scroll cycle, giving a sparse but consistent starfield density.
  • There is no frame-rate control; animation speed depends entirely on SLOW mode timing and the speed of BASIC interpretation.

Line Reference Table

LinePurpose
5REM title “SPACESCAP” in inverse video
10Dimension 32-character string S$
20Enable SLOW display mode
30–50Fill S$ with inverse-space characters
60Scroll display up one row
70Print background line and random star
80Loop back to line 60

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10051 – 10121.

Related Products

Related Articles

Related Content

Image Gallery

Space Scape

Source Code

   5 REM %S%P%A%C%E%S%C%A%P%E
  10 DIM S$(32)
  20 SLOW 
  30 FOR N=1 TO 32
  40 LET S$(N)=CHR$ 128
  50 NEXT N
  60 SCROLL 
  70 PRINT S$;AT 21,RND*31;CHR$ 155
  80 GOTO 60
 100 SAVE "1006%6"
 110 RUN 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top