--- title: "Impossible Triangle" id: 56299 type: "computer_media" slug: "impossibletriangle" url: "http://localhost/computer_media/impossibletriangle/" markdown_url: "http://localhost/computer_media/impossibletriangle.md" published_at: "2024-08-04T10:49:54+00:00" modified_at: "2026-03-30T21:43:02+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/08/SCR-20240804-jeqk.png" excerpt: "This drawing program builds a famous geometric paradox on screen step by step, complete with randomized sound effects, before revealing its impossible identity." 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 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Frank Bouldin (W5GAA)" slug: "frank-bouldin" taxonomy: "indiv" url: "http://localhost/indiv/frank-bouldin/" genre: - name: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" media_contents: - id: 56277 title: "Timex Sinclair Public Domain Library Tape 2001" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-2001/" media_type: "Program" programmers: - name: "Frank Bouldin (W5GAA)" slug: "frank-bouldin" taxonomy: "indiv" url: "http://localhost/indiv/frank-bouldin/" download_url: "https://archive.org/download/timex-sinclair-software-archive/ImpossibleTriangle%20%281986%29%28Bouldin%2C%20Frank%29%28TS2068%29%28US%29%28Program%29.zip" mediadate: "1986" images: - url: "http://localhost/wp-content/uploads/2024/08/SCR-20240804-jeqk.png" media_type_tags: "Demo" --- # Impossible Triangle Draws a version of a familiar optical illusion, the [Penrose triangle](https://en.wikipedia.org/wiki/Penrose_triangle). This program draws a version of a familiar optical illusion, the [Penrose triangle](https://en.wikipedia.org/wiki/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. 1. **Init (line 30):** Sets DATA pointer offsets `D=200` and `P=100`, clears screen. 2. **Anchor read (line 40):** RESTOREs to line `P`, reads starting X,Y coordinates, PLOTs the anchor point, advances `P` by 10, then RESTOREs to `D` for vector data. 3. **Vector drawing (lines 50–60):** Reads 10 pairs of DRAW deltas from the current `D` block, each accompanied by a randomized BEEP. 4. **Loop control (lines 60–70):** After four anchor passes (`P=140`), proceeds to reveal; otherwise advances `D` by 20 and repeats. 5. **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 P` reads the anchor coordinates, then `RESTORE D` repositions 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 `, allowing precise mid-program DATA navigation. The variables `P` and `D` act as DATA pointer registers. - **Randomized audio:**`LET B=INT(RND*20)+15` generates a pitch between 15 and 34 for each DRAW segment, giving varied audio feedback while drawing. - **Reveal reuse of X:** After the drawing loop, `X` retains whatever value it last held from the vector DATA. Line 90 repurposes `X` as 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 `X` used 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 increment `LET X=X+1` rather 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. ## 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 ```