This program is a multi-section abstract graphics demonstration that cycles through several distinct drawing routines. The first section (lines 10–100) uses PLOT and DRAW with OVER 1 (XOR drawing mode) to create a pair of overlapping line-sweep patterns across the full screen. The second section (lines 200–380) draws a continuously mutating four-sided figure by PEEKing the current pen position from system variables at addresses 23677–23678 (COORDS X and Y) to chain successive DRAW commands into a closed shape, while bouncing the origin point off screen boundaries. The third section (lines 400–500) uses arrays to animate two triangles with INVERSE toggling, and the fourth section (lines 600–800) draws a spinning or rotating line figure built from four symmetric FOR loops converging on a central region, toggling INVERSE each full cycle. A final section (lines 810–880) generates random-step line fans from the screen center and edges before clearing and repeating.
Program Analysis
Program Structure
The program is organized as five self-contained graphical routines that run sequentially, though only one contains an explicit loop back to restart it. There is no menu or user input — execution simply falls through from one section to the next.
| Lines | Section | Description |
|---|---|---|
| 10–100 | Line Sweep (OVER 1) | Two-pass XOR line fan across full screen |
| 200–380 | Bouncing Quad | Chained DRAW using COORDS PEEKs, bouncing origin |
| 400–500 | Triangle Animation | Array-driven dual triangles with INVERSE toggling |
| 600–800 | Rotating Star | Four-loop radial line figure with INVERSE cycling |
| 810–880 | Random Fan | Random-step line fans from center and edges |
Note the significant line number gaps (100→200, 380→400, 500→600, 800→810): these are deliberate spacing choices to keep sections visually separated and to allow future expansion.
Section 1: XOR Line Fan (Lines 10–100)
OVER 1 at line 10 enables XOR pixel drawing throughout. Lines 20–50 sweep t from 0 to 100 in steps of 0.753, drawing pairs of lines from the bottom and top of the screen that converge toward the center, creating a moiré-like pattern. Lines 70–100 repeat with t running from −50 to 150, effectively shifting the fan and producing interference with the first pass due to XOR mode. The step value 0.753 is carefully chosen to produce a dense but non-repeating fan within the screen’s 256-pixel width. The PAUSE 500 at line 60 holds the completed first pass for about 10 seconds before clearing.
Section 2: Bouncing Quad with COORDS PEEK (Lines 200–380)
This section exploits the ZX Spectrum system variables COORDS at addresses 23677 (X) and 23678 (Y), which hold the coordinates of the last PLOTted or DRAWn point. After a PLOT x+10,y, each subsequent DRAW at lines 260–290 reads the current pen position via PEEK 23677 and PEEK 23678 to compute relative displacements, forming a closed four-segment figure. This chains four lines into a quadrilateral without needing to track position in BASIC variables.
The origin point (x,y) bounces off screen edges: lines 320–350 clamp values to [0,175], and lines 360–370 negate the step variables e and m on boundary contact. There is a minor bug at line 370: the upper boundary check uses y=190 instead of y=175, meaning the top boundary is never actually triggered and m only negates on y=0.
Section 3: Dual Triangle Animation (Lines 400–500)
Two 1D arrays x(6) and y(6) define the vertices of two triangles. Lines 430–440 initialize the six vertices at corners and midpoints of the screen. At line 450, INVERSE RND*1 randomly selects normal or inverse drawing mode, since RND*1 produces a value in [0,1) which, when passed to INVERSE, is truncated to either 0 or 1. Lines 460–470 draw two closed triangles by plotting and chaining three DRAW calls per triangle. Line 480 updates all six vertices in a single compound LET statement, shrinking and shifting them. The loop terminates at line 500 when x(6)>=128, halting after roughly 128 iterations.
Section 4: Rotating Star Figure (Lines 600–800)
Four FOR loops (lines 630–650, 660–690, 700–730, 740–770) each draw a set of lines radiating from a common region near screen center. The loops step in opposite directions on alternating axes to produce rotational symmetry. After all four loops complete, a is toggled with NOT a at line 780, and INVERSE a at line 790 flips the drawing attribute before looping back to line 620 indefinitely. This produces an alternating normal/inverse pulsing animation as lines accumulate on screen without clearing.
Section 5: Random Line Fan (Lines 810–880)
Lines 810–880 generate two sets of line fans: one sweeping horizontally from center point (128,175) and (128,0), and one sweeping vertically from (255,88) and (0,88). The step sizes a and b are randomized each cycle via RND*10+1, giving variable density. After both fans are drawn, PAUSE 100 holds the display for about 5 seconds before CLS and GO TO 810 restart the loop. Note the inconsistent capitalization NEXT W (uppercase) at line 870 versus w (lowercase) used throughout — this is accepted by the interpreter as variable names are case-insensitive in this context.
Notable Techniques
- OVER 1 / XOR drawing: Used in section 1 to create moiré interference patterns between two line-sweep passes.
- PEEK 23677/23678 (COORDS): Reads the hardware-maintained current drawing position to chain DRAW commands without manual coordinate tracking.
- INVERSE RND*1: Compact idiom for randomly toggling inverse video mode by exploiting integer truncation of a [0,1) random value.
- NOT a for toggling: Uses the logical NOT function to flip a binary flag between 0 and 1 each cycle.
- Compound LET: Line 480 packs ten assignments into one statement, saving memory at the cost of readability.
- Non-integer STEP values: Steps of 0.753 and 7.5 produce dense, non-repeating patterns suited to the screen’s pixel resolution.
Bugs and Anomalies
- Line 370: boundary check
y=190should likely bey=175to match the screen height; as written, the upper Y bounce never fires. - Line 380:
GO TO 260skips the initialPLOTat line 250 on subsequent iterations, meaning the chained DRAW calls depend on the previous draw endpoint rather than a freshly PLOTted origin — this may be intentional to create continuous curves. - Line 870:
NEXT Wuses uppercase while the loop variable is declared lowercasew; functionally harmless but inconsistent. - Lines 100 and 500 fall through to the next section with no explicit
GO TO, relying on sequential execution — if a section is jumped into directly, initialization from prior lines may be missing.
Content
Source Code
10 CLS : INK 0: PAPER 7: BORDER 7: OVER 1
20 FOR t=0 TO 100 STEP .753
30 PLOT t+50,0: DRAW 50-t,175
40 PLOT t+50,175: DRAW 50-t,-175
50 NEXT t
60 PAUSE 500: CLS
70 FOR t=-50 TO 150 STEP .753
80 PLOT t+50,0: DRAW 50-t,175
90 PLOT t+50,175: DRAW 50-t,-175
100 NEXT t
200 PAPER 7: BORDER 7: INK 0: CLS
210 LET e=RND*10-2
220 LET m=RND*10-2
230 LET x=RND*255
240 LET y=RND*175
250 PLOT x+10,y
260 DRAW x+10-PEEK 23677,y-PEEK 23678
270 DRAW (255-y)-PEEK 23677,(175-x)-PEEK 23678
280 DRAW (y+10)-PEEK 23677,x-PEEK 23678
290 DRAW (255-x)-PEEK 23677,(175-y)-PEEK 23678
300 LET y=y+m
310 LET x=x+e
320 IF x<0 THEN LET x=0
330 IF y<0 THEN LET y=0
340 IF x>175 THEN LET x=175
350 IF y>175 THEN LET y=175
360 IF x=0 OR x=175 THEN LET e=-e
370 IF y=0 OR y=190 THEN LET m=-m
380 GO TO 260
400 PAPER 7: BORDER 7: INK 0: CLS
410 LET count=0
420 DIM x(6): DIM y(6)
430 LET x(1)=0: LET x(2)=255: LET x(3)=x(1): LET x(4)=x(2): LET x(5)=x(1): LET x(6)=x(2)
440 LET y(1)=0: LET y(2)=88: LET y(3)=175: LET y(4)=y(1): LET y(5)=y(2): LET y(6)=y(3)
450 INVERSE RND*1
460 PLOT x(1),y(1): DRAW x(2)-x(1),y(2)-y(1): DRAW x(3)-x(2),y(3)-y(2): DRAW x(1)-x(3),y(1)-y(3)
470 PLOT x(4),y(4): DRAW x(5)-x(4),y(5)-y(4): DRAW x(6)-x(5),y(6)-y(5): DRAW x(4)-x(6),y(4)-y(6)
480 LET y(1)=y(1)+1: LET x(1)=x(1)+1: LET y(3)=y(3)-1: LET x(5)=x(5)+1: LET y(4)=y(4)+1: LET x(4)=x(4)-1: LET x(2)=x(2)-1: LET x(3)=x(3)+1: LET x(6)=x(6)-1: LET y(6)=y(6)-1
490 LET count=count+1
500 IF x(6)>=128 THEN GO TO 450
600 INK 0: PAPER 7: BORDER 7: INVERSE 0: CLS
610 LET a=0
620 LET i=120: LET j=-.75: LET l=75
630 FOR k=112 TO 40 STEP -8
640 LET j=j+7.5
650 PLOT i,j: DRAW k-i,l-j: NEXT k
660 LET i=32: LET j=75: LET k=120
670 FOR l=82.5 TO 150 STEP 7.5
680 LET i=i+8
690 PLOT i,j: DRAW k-i,l-j: NEXT l
700 LET i=120: LET j=157: LET l=75
710 FOR k=128 TO 200 STEP 8
720 LET j=j-7.5
730 PLOT i,j: DRAW k-i,l-j: NEXT k
740 LET i=208: LET j=75: LET k=120
750 FOR l=67.5 TO 0 STEP -7.5
760 LET i=i-8
770 PLOT i,j: DRAW k-i,l-j: NEXT l
780 LET a=NOT a
790 INVERSE a
800 GO TO 620
810 LET a=RND*10+1: LET b=RND*10+1
820 FOR w=0 TO 255 STEP b
830 PLOT 128,175: DRAW 127-w,-175
840 PLOT 128,0: DRAW 127-w,175: NEXT w
850 FOR w=0 TO 175 STEP a
860 PLOT 255,88: DRAW -255,87-w
870 PLOT 0,88: DRAW 255,87-w: NEXT W
880 PAUSE 100: CLS : GO TO 810
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

