Hothouse Plot

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

This program draws a polar rose curve on screen using the parametric equations X = R·cos(T) and Y = R·sin(T), where R = P·sin(N·T). With N set to 456 and P to 20, it produces a dense multi-petalled flower pattern centred at coordinate (31, 21). The program pre-computes 601 data points into DIM arrays during FAST mode, then switches to SLOW mode for plotting, separating calculation from display for efficiency. After a short delay loop (lines 100–110), it loops back to clear the screen and redraw continuously, creating an animated cycling effect.


Program Analysis

Program Structure

The program is divided into four logical phases:

  1. Initialisation (lines 5–40): Sets the petal count N=456, angular step D=2*PI/600, and amplitude P=20; allocates two 601-element arrays.
  2. Computation in FAST mode (lines 40–72): Iterates I from 0 to 600, computing polar coordinates and converting them to Cartesian X/Y values stored in the arrays.
  3. Display in SLOW mode (lines 74–90): Clears the screen and plots all 601 pre-computed points.
  4. Loop and repeat (lines 100–130): A 100-iteration delay loop followed by GOTO 76 continuously redraws the same curve, creating an animation cycle.

Mathematical Technique

The curve is a polar rose defined by R = P * SIN(N * T), where T ranges from 0 to 2π in 600 equal steps. This is converted to screen coordinates via:

  • X(I+1) = R * COS(T) + 31 — centred horizontally at column 31
  • Y(I+1) = R * SIN(T) + 21 — centred vertically at row 21

With N=456 (an even integer), the rose produces 2×456 = 912 petals in theory, though the limited 64×44 pixel ZX81 display resolution means many petals overlap or fall outside the visible area. The amplitude P=20 keeps the curve within the screen bounds.

FAST/SLOW Mode Usage

The program explicitly uses FAST (line 6) during the computationally intensive array-filling loop and switches to SLOW (line 74) only for the display phase. This is a standard ZX81 optimisation: FAST suppresses the display interrupt, allowing the CPU to run at full speed for floating-point calculations, while SLOW re-enables the display driver for visible output.

Array Pre-computation Strategy

Rather than computing and plotting each point in a single pass, all 601 X and Y values are stored in DIM X(601) and DIM Y(601) before any plotting occurs. This costs RAM (each array element occupies 5 bytes in ZX81 floating-point format, so ~6 KB total for both arrays) but cleanly separates the FAST computation phase from the SLOW display phase.

Delay and Animation Loop

Lines 100–110 implement a busy-wait delay via an empty FOR/NEXT loop of 100 iterations. After the delay, GOTO 76 jumps back to the CLS at line 76 rather than line 5, so the arrays are never recomputed — only the screen is cleared and the curve redrawn from the cached data.

Key Variables

VariablePurpose
NPetal frequency parameter (456)
DAngular increment (2π/600)
PAmplitude / petal length (20)
TCurrent angle in radians
RCurrent polar radius
X(), Y()Pre-computed Cartesian coordinates
ILoop counter (dual use: fill and plot)

Notable Anomalies

Line 130 (CLEAR) and lines 140–150 (SAVE / RUN) are never reached during normal execution because GOTO 76 at line 120 creates an infinite loop. These lines serve as a save-and-autostart block appended after the main program logic.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10294-10335.

Related Products

Related Articles

Related Content

Image Gallery

Hothouse Plot

Source Code

   5 REM HOTHOUSE PLOT
   6 FAST 
   7 DIM X(601)
   8 DIM Y(601)
  10 LET N=456
  20 LET D=2*PI/600
  30 LET P=20
  40 FOR I=0 TO 600
  50 LET T=D*I
  55 LET R=P*SIN (N*T)
  60 LET X(I+1)=R*COS T+31
  70 LET Y(I+1)=R*SIN T+21
  72 NEXT I
  74 SLOW 
  76 CLS 
  78 FOR I=1 TO 601
  80 PLOT X(I),Y(I)
  90 NEXT I
 100 FOR I=1 TO 100
 110 NEXT I
 120 GOTO 76
 130 CLEAR 
 140 SAVE "1029%7"
 150 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