The Tholean Web

Date: 1982
Type: Program
Platform(s): ZX81, TS 1000
Tags: Graphics

Weaves a “Tholean web” (after the Star Trek TV series) on the TS1000 or ZX81: a graphics character travels diagonally and ricochets off the edges of the screen until the whole screen is a lattice. It shows a way to bounce objects off walls in BASIC without machine code, as in a billiards game.

RUN it in SLOW mode and watch; BREAK stops it. Lines 5 to 60 set the character and the limits. The strings in lines 70 to 90 hold the tokens >=, AND and <=, which VAL evaluates. It needs 2K: on a 1K machine it stops with report 4 as the screen fills, as the December 1982 newsletter warned (its 1K version deletes the REMs and changes lines 50 and 60).

The second file is the article’s three-dimensional version: line 120 goes to 180, line 200 prints at X+I, lines 180-220 are added, and line 50 is LET X1=21 – LEN P$, the correction printed in the December 1982 newsletter (without it, a longer P$ stops with report 5). Replace P$ in line 5 with a longer graphics string to see the effect; the article suggests the graphics on 7, G, S, T and 8. The article also suggests adding 115 LET DX=DX+1.6 and 135 LET DX=DX+3.2 (gravity and inelastic bounces); these are not in either file.

No author is printed.

Published in the BCS Sinclair-Timex User Group Newsletter November 1982 (The Tholean Web), with corrections in December 1982 ([Bug Corrections]).

Image Gallery

Source Code

   5 LET P$="■"             (the graphics space character)
  10 LET X=0
  20 LET Y=0
  30 LET DX=1
  40 LET DY=1
  50 LET X1=21
  60 LET Y1=31
  70 LET X$="X >= 0 AND X <= X1"   (>=, AND, and <= are tokens)
  80 LET Y$="Y >= 0 AND Y <= Y1"   (ditto)
  90 LET Z$=X$+"AND"+Y$            (AND is a token)
  99 REM MAIN PROCEDURE
 100 LET X=X+DX
 110 LET Y=Y+DY
 120 IF VAL Z$ THEN GOTO 200
 130 LET DX=DX*(2*VAL X$-1)
 140 LET DY=DY*(2*VAL Y$-1)
 150 LET X=X*VAL X$+X1*(X >= 0)* NOT VAL X$
 160 LET Y=Y*VAL Y$+Y1*(Y >= 0)* NOT VAL Y$
 170 REM OUTPUT FOLLOWS
 200 PRINT AT X,Y; P$;
 250 GOTO 100

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