Draws a version of a familiar optical illusion, the Penrose triangle.
This program draws a version of a familiar optical illusion, the Penrose triangle, with randomized pitch values for accompanying BEEP sounds. The drawing routine iterates through four anchor points (lines 100–130) paired with ten vector segments (lines 200–270), using RESTORE to switch between two DATA pointer positions mid-loop. The reveal phase (line 80) reads character codes from line 300–310 and prints them one at a time along the bottom of the screen — the codes spell out “THE IMPOSSIBLE TRIANGLE.” The program loops continuously, redrawing the figure from scratch each time after the keypress reveal. Random BEEP pitches in the range 15–34 are generated with INT(RND*20)+15, giving an unpredictable audio texture tied to each drawing step.
Program Analysis
Program Structure
The program is organized into four logical phases: initialization, drawing, reveal, and loop. Lines 30–70 handle the drawing phase, iterating over anchor points and vector segments. Line 80–90 manage the reveal and keypress pause. Lines 100–130 and 200–270 hold the geometric DATA, while lines 300–310 hold the ASCII reveal text.
- Init (line 30): Sets DATA pointer offsets
D=200andP=100, clears screen. - Anchor read (line 40): RESTOREs to line
P, reads starting X,Y coordinates, PLOTs the anchor point, advancesPby 10, then RESTOREs toDfor vector data. - Vector drawing (lines 50–60): Reads 10 pairs of DRAW deltas from the current
Dblock, each accompanied by a randomized BEEP. - Loop control (lines 60–70): After four anchor passes (
P=140), proceeds to reveal; otherwise advancesDby 20 and repeats. - Reveal (lines 80–90): RESTOREs to line 300, prints “PRESS ANY KEY”, waits, then prints each character code as
CHR$across the bottom of the screen, waits again, and restarts.
DATA Layout
| Lines | Role | Content |
|---|---|---|
| 100–130 | Anchor points | Four X,Y pairs: (112,102), (20,18), (169,85), (224,3) |
| 200–270 | Vector segments | Four blocks of 10 X,Y DRAW deltas, one block per anchor |
| 300–310 | Reveal text | ASCII codes spelling “THE IMPOSSIBLE TRIANGLE” |
Notable Techniques
- Dual RESTORE trick: Within a single pass of line 40,
RESTORE Preads the anchor coordinates, thenRESTORE Drepositions the DATA pointer to the correct vector block before the FOR loop in line 50. This allows interleaved DATA sections without additional READ variables. - Parameterized RESTORE: TS2068 BASIC supports
RESTORE <line number>, allowing precise mid-program DATA navigation. The variablesPandDact as DATA pointer registers. - Randomized audio:
LET B=INT(RND*20)+15generates a pitch between 15 and 34 for each DRAW segment, giving varied audio feedback while drawing. - Reveal reuse of X: After the drawing loop,
Xretains whatever value it last held from the vector DATA. Line 90 repurposesXas a BEEP pitch counter, incrementing it by 1 per character — a side-effect reuse rather than a deliberate initialization. - PRINT #0 for lower screen: The reveal text and prompt are printed to stream
#0(the lower screen area), keeping the drawn figure undisturbed in the main display area. - PAUSE 0 keypress wait: Used twice in lines 80–90 as an efficient indefinite pause, standard idiom for awaiting any keypress.
Anchor and Vector Structure
The four anchor points (lines 100–130) define starting positions for four segments of the Penrose/impossible triangle outline. Each anchor is paired with 10 DRAW vectors (20 DATA values per block in lines 200–270), building one side or sub-section of the figure per pass through the outer loop. The loop termination condition P=140 correctly detects when all four anchors (100, 110, 120, 130) have been processed, since P starts at 100 and increments by 10 each pass.
Anomalies and Notes
- The variable
Xused as a BEEP pitch in the reveal loop (line 90) is never explicitly initialized for that purpose — it inherits whatever value it held from the last READ in line 50. This is functional but fragile; the ascending pitch sequence is a consequence of the incrementLET X=X+1rather than a deliberate musical design. - The DATA in lines 300–310 contains 23 values, matching the 23 characters of “THE IMPOSSIBLE TRIANGLE”. The FOR loop in line 80 runs
Y=4 TO 26, also 23 iterations, confirming correct sizing.
Content
Source Code
5 REM "What-Iz-It"???
10 REM By Frank Bouldin W5GAA Fort Worth T/S UG (11-18-86)
20 REM For T/S 2068 computer
30 LET D=200: LET P=100: CLS
40 RESTORE P: READ A,B: BEEP .05,34: PLOT A,B: LET P=P+10: RESTORE D
50 FOR N=1 TO 10: LET B=INT (RND*20)+15: READ X: READ Y: DRAW X,Y: BEEP .05,B
60 NEXT N: IF P=140 THEN GO TO 80
70 LET D=D+20: GO TO 40
80 RESTORE 300: PRINT #0;AT 1,10;"PRESS ANY KEY": PAUSE 0: FOR Y=4 TO 26: READ C
90 PRINT #0;AT 1,Y;CHR$ C: BEEP .05,X: LET X=X+1: NEXT Y: PAUSE 0: GO TO 30
100 DATA 112,102
110 DATA 20,18
120 DATA 169,85
130 DATA 224,3
200 DATA 14,21,14,-22,-48,0,46,70,100,-152
210 DATA -13,-16,-197,0,-9,15,96,153,22,0
220 DATA 85,0,-25,34,-11,-18,24,0,-45,0
230 DATA 32,51,70,0,-24,38,10,16,34,-54
240 DATA -19,0,-11,-16,-48,0,-11,-17,11,17
250 DATA -10,15,45,-66,67,0,-23,36,10,16
260 DATA -44,67,-23,-37,24,0,-45,0,35,51
270 DATA -45,-66,11,16,-24,35,14,-20,12,20
300 DATA 84,72,69,32,73,77,80,79,83,83,73,66
310 DATA 76,69,32,84,82,73,65,78,71,76,69
9999 SAVE "WHAT-IZ-IT" LINE 30
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
