--- title: "Hothouse Plot" id: 56805 type: "computer_media" slug: "hothouse-plot" url: "http://localhost/computer_media/hothouse-plot/" markdown_url: "http://localhost/computer_media/hothouse-plot.md" published_at: "2024-09-29T02:04:07+00:00" modified_at: "2026-03-30T21:21:01+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/09/297_HP.png" excerpt: "A mesmerising polar rose with 456 petals is pre-calculated into arrays and continuously redrawn — see how parametric maths produces intricate floral geometry." 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: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" 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/297_HP.png" media_type_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 | Variable | Purpose | | --- | --- | | `N` | Petal frequency parameter (456) | | `D` | Angular increment (2π/600) | | `P` | Amplitude / petal length (20) | | `T` | Current angle in radians | | `R` | Current polar radius | | `X()`, `Y()` | Pre-computed Cartesian coordinates | | `I` | Loop 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. ## 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 ```