This program draws a continuous series of random lines across the screen using PLOT and DRAW, while sounding a tone whose pitch is derived from the difference between the current random coordinates. It initializes two variables, p and q, to track the previous plot position, then repeatedly picks random pixel coordinates (x in 0–255, y in 0–175) and draws a line from the last position to the new one. The OVER 1 mode in line 10 causes each pixel to be XOR’d with the existing display, so lines erase themselves where they overlap, creating an animated interference effect. The BEEP duration is fixed at 0.05 seconds, but pitch varies continuously as (x-y)/10, tying audio output directly to the visual randomness.
Program Analysis
Program Structure
The program is a tight infinite loop across just nine active lines. Initialization (lines 10–14) sets up the OVER mode and seeds the previous-position variables. The main loop (lines 20–60) picks new random coordinates, plots a point, conditionally draws a line from the previous position, updates state, sounds a beep, and jumps back to line 20.
- Lines 10–14: Set OVER 1 (XOR pixel mode), initialize previous coordinates
pandqto 0. - Lines 20–30: Generate random pixel position:
xin [0,255],yin [0,175]. - Lines 40–48: PLOT the new point, compute displacement from previous position, conditionally DRAW the line, update
pandq. - Line 50: Sound a beep whose pitch is
(x-y)/10. - Line 60: Loop back to line 20.
OVER 1 / XOR Drawing Mode
Line 10 sets OVER 1, which causes all subsequent PLOT and DRAW operations to XOR pixels against the existing screen content rather than simply setting them. This means that wherever two lines cross, the pixels cancel out, producing a dynamic interference or “weave” effect as the pattern accumulates. The comment REM or OVER 0 hints that the author considered the alternative solid-draw mode, which would simply paint lines without the cancellation effect.
Conditional DRAW Logic
Lines 42–46 compute the relative displacement r = p - x and s = q - y from the previous point to the current one, then apply a guard condition before drawing:
ris the horizontal displacement (previous x minus current x).sis the vertical displacement (previous y minus current y).- The condition
IF r<>x AND s<>y THEN DRAW r,sskips the draw when the displacement happens to equal the absolute coordinate values — an unusual guard that will rarely trigger but prevents certain degenerate cases. Note that logically the programmer may have intended to skip whenr=0 AND s=0(i.e., no movement), but the actual condition written is different and is effectively almost always true.
Audio Coupling
Line 50 uses BEEP 0.05,(x-y)/10 to produce a short tone for each line segment drawn. The pitch in semitones above middle A is (x-y)/10, which ranges from approximately −17.5 to +25.5 semitones depending on the random coordinates. This tightly couples the audio output to the visual randomness, so the sound texture changes continuously in step with the drawing.
Notable Techniques and Anomalies
| Line | Technique / Note |
|---|---|
10 | OVER 1 for XOR pixel drawing; inline REM documents the alternative |
20 | INT(RND*256) gives uniform integers in [0,255], exactly spanning the horizontal pixel range |
30 | INT(RND*176) gives [0,175], matching the full vertical pixel range |
46 | Guard condition r<>x AND s<>y is logically unusual; likely intended as a zero-displacement check but does not correctly implement one |
48 | Two LET statements on one line separated by : — a common space-saving idiom |
50 | Pitch derived directly from coordinate arithmetic, coupling sound to graphics |
Potential Bug
The DRAW displacement is computed as r = p - x (old minus new) rather than x - p. This means the line is drawn back from the new point toward the old point rather than forward, though since DRAW is symmetric in effect this produces the same visual result. More significantly, the skip condition on line 46 compares displacements to absolute coordinates rather than to zero, so it will not reliably prevent a zero-length draw; however, a zero-length DRAW is harmless.
Content
Source Code
10 OVER 1: REM or OVER 0
12 LET p=0
14 LET q=0
20 LET x=INT (RND*256)
30 LET y=INT (RND*176)
40 PLOT x,y
42 LET r=(p-x)
44 LET s=(q-y)
46 IF r<>x AND s<>y THEN DRAW r,s
48 LET p=x: LET q=y
50 BEEP 0.05,(x-y)/10
60 GO TO 20
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
