Microworld

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

This program generates a randomly seeded landscape of vertical bar-chart columns across the screen, then overlays a scrolling animated border and a title in inverse video. The landscape is drawn in FAST mode using PLOT to render columns of pixels, with each column reaching a random height between 1 and 41 pixels. The title string T$ (defaulting to “MICROWORLD”) is printed in inverse video by adding 128 to each character code, centred on line 21. The scrolling effect is created by repeatedly printing a four-character string S$ (built from CHR$ 0, 9, 8, 9) across row 0 in an infinite loop, producing a moving pattern of ZX81 block-graphic characters.


Program Analysis

Program Structure

The program divides into four logical phases:

  1. Initialisation (lines 10–50): Dimensions a three-character string E$, builds the scrolling pattern string S$, and sets the title T$.
  2. Landscape generation (lines 60–130): Runs in FAST mode, iterating over 61 columns (M = 0 to 60) and plotting a random-height column of pixels in each.
  3. Title and border setup (lines 140–210): Prints the title in inverse video on row 21, then enters the scroll loop for row 0.
  4. Scrolling loop (lines 180–220): An infinite GOTO loop that sweeps S$ across positions 0–28 of row 0, creating a marquee-like animation.

Landscape Generation

The outer loop (M = 0 TO 60) steps through horizontal pixel columns. For each column, the inner loop plots from pixel row 0 up to INT(RND*40)+1, giving a random height of 1–41 pixels. Using FAST mode suppresses the display driver during drawing, dramatically speeding up the PLOT calls. The RAND at line 70 (no argument) seeds the random number generator from the system clock, so each run produces a different landscape.

Inverse-Video Title

The ZX81 encodes inverse characters as the normal character code plus 128. Lines 150–170 loop over each character of T$, printing CHR$(CODE T$(N)+128) to produce each letter in inverse video. The AT 21, 15-(LEN T$/2) at line 140 attempts to horizontally centre the title; because LEN T$/2 uses integer division the centering is approximate, and for a 10-character title like “MICROWORLD” it evaluates to column 10 — one cell left of true centre on a 32-column display.

Scrolling Header

The string S$ is assembled as CHR$ 0 + CHR$ 9 + CHR$ 8 + CHR$ 9. On the ZX81, character codes 0–10 are space and graphic block characters; this four-character sequence forms a small animated pattern. Printing it at successive columns 0–28 of row 0 in a tight FOR/NEXT/GOTO loop creates a leftward-sweeping marquee. E$ (three spaces, from DIM E$(3)) is printed at column 29 to clear the tail end of row 0 each cycle.

Key Variables

VariablePurpose
T$Customisable title string, printed in inverse video
S$Four-char graphic pattern used for the scrolling header
E$Three-space string used to blank the trailing characters of row 0
MHorizontal pixel column counter (0–60) for landscape drawing
NReused: pixel row counter during plotting; character index during title print; scroll position during animation

Notable Techniques and Observations

  • Reusing loop variable N for three distinct purposes (plotting height, title character index, scroll position) is a common ZX81 memory-saving idiom.
  • The landscape is drawn with PLOT rather than character-cell graphics, giving pixel-level resolution on the 64×44 pixel grid.
  • The title is user-customisable via the REM-documented T$ assignment at line 50, a common convention for configurable BASIC programs of this era.
  • The scroll loop has no exit condition; the program runs indefinitely until interrupted by the user.
  • The centering formula 15-(LEN T$/2) performs integer division, so for odd-length titles the result is biased one column to the right.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10176 – 10210.

Related Products

Related Articles

Related Content

Image Gallery

Microworld

Source Code

  10 DIM E$(3)
  20 LET S$=CHR$ 0+CHR$ 9+CHR$ 8+CHR$ 9
  30 REM T$ IS THE TITLE.
  40 REM IT CAN BE CHANGED.
  50 LET T$="MICROWORLD"
  60 FAST 
  70 RAND 
  80 FOR M=0 TO 60
  90 FOR N=0 TO INT (RND*40)+1
 100 PLOT M,N
 110 NEXT N
 120 NEXT M
 130 SLOW 
 140 PRINT AT 21,15-(LEN T$/2);
 150 FOR N=1 TO LEN T$
 160 PRINT CHR$ (CODE T$(N)+128);
 170 NEXT N
 180 FOR N=1 TO 28
 190 PRINT AT 0,N;S$
 200 NEXT N
 210 PRINT AT 0,29;E$
 220 GOTO 180
 230 SAVE "1018%1"
 240 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