--- title: "Demos2" id: 71017 type: "computer_media" slug: "demos2" url: "http://localhost/computer_media/demos2/" markdown_url: "http://localhost/computer_media/demos2.md" published_at: "2026-08-26T01:16:11+00:00" modified_at: "2026-08-26T01:17:34+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "Two graphical demos in one program: enter four frequency values to trace Lissajous spirals, or fill a circle using Pythagorean chord calculations." 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/" genre: - name: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Demos2%20%28198x%29%28-%29%28TS2068%29%28US%29%28Program%29.zip" tsrun_member: "Demos2 (198x)(-)(TS2068)(US)(Program).tap" mediadate: "198x" media_type_tags: "Demo" --- # Demos2 Demos2 is a two-part graphical demonstration program offering a Lissajous-style spiral plotter and a filled-circle renderer. The spiral routine accepts four integer parameters (A, B, C, D) that control the sine-wave frequencies along each axis, continuously plotting line segments to trace parametric curves as T increments by 0.01 per iteration. The circle-fill routine uses the Pythagorean relationship (Z = R², ZZ = n², XX = √(Z−ZZ)) to compute chord half-lengths at each horizontal offset, then draws vertical lines across the circle’s interior using paired PLOT/DRAW calls for both the positive and negative x sides. A menu at line 220 routes the user to either demo via RUN targeting specific line numbers. *** ## Program Analysis ### Program Structure The program is organized as three largely independent routines sharing a single file, with a menu dispatcher acting as the entry point at line 220. Execution flow is managed by `RUN` targeting specific line numbers rather than `GO SUB`, which means each demo effectively restarts the interpreter context. The layout is: 1. **Lines 10:** Bootstrap — immediately jumps to the menu at line 220. 2. **Lines 20–100:** Spirals demo. 3. **Lines 110–210:** Circle fill demo. 4. **Lines 220–250:** Menu and dispatcher. 5. **Line 300:** SAVE with auto-run. ### Spirals Routine (Lines 20–100) This routine generates Lissajous figures by parameterizing two points on sine curves and drawing line segments between them. Variables `A` and `B` control the frequencies of the first point (`X1`, `Y1`), while `C` and `D` control the second point (`X2`, `Y2`). The canvas is centered at (125, 87), matching the approximate midpoint of the 256×175 graphics area. The parameter `T` starts at 0 and increments by 0.01 each iteration in an infinite loop via `GO TO 50`. Offsetting the center to (125, 87) rather than (128, 87) is a minor inaccuracy — the true horizontal midpoint of a 256-pixel-wide display is 128 — but the visual effect is negligible. There is no termination condition; the loop runs until the user breaks out manually. ### Circle Fill Routine (Lines 110–210) The fill algorithm draws the circle outline first using the built-in `CIRCLE` command, then fills it by iterating over each horizontal offset `n` from 0 to `R`. For each `n`, the chord half-length `XX` is computed as `SQR(R↑2 - n↑2)`, derived from the Pythagorean theorem. Two vertical strokes are drawn symmetrically: one at `X+n` and one at `X-n`, each starting at the top of the chord (`YY = Y + XX`) and drawing downward by `-XY` where `XY = 2*XX`. A subtle naming collision exists: the INPUT variable on line 130 uses lowercase `x` and `y`, but subsequent lines refer to `X` and `Y`. On this platform BASIC variable names are case-insensitive for numeric scalars, so this causes no runtime error. However, the local variable `xy` (line 188) shadows the earlier use of `y` only in appearance — they are distinct variables (`XY` vs `Y`) and do not conflict. ### Menu and Dispatch (Lines 220–250) The menu uses `PRINT` with multiple apostrophes for blank-line spacing and `TAB 9` for crude centering of the title. Input validation on line 230 rejects values outside 1–2 with a self-referential `GO TO 230`. Dispatch is done with `RUN 20` and `RUN 110` rather than `GO SUB`, meaning no return path exists to the menu once a demo starts — the user must break and restart. The `CLEAR` on line 220 resets variables before each menu display. ### Notable Techniques - Use of `RUN ` as a dispatch mechanism avoids the need for a `GO SUB`/return structure but sacrifices the ability to return to the menu automatically. - The Pythagorean chord calculation in the fill routine is a standard scan-line fill approach adapted for BASIC’s line-drawing primitives. - Intermediate values `Z` and `ZZ` in lines 160–170 store `R↑2` and `n↑2` to avoid recomputing the squares inside the `SQR` call, a minor efficiency optimization. - The spiral loop has no exit condition, which is intentional for a continuous animated demo but means the only way to return to the menu is via a manual BREAK. ### Potential Issues | Line | Issue | Impact | | --- | --- | --- | | 130 | No input range validation for X, Y, or R; values outside the screen area will cause an error on `PLOT`/`DRAW` | Runtime error possible | | 50 | Center X hardcoded as 125 instead of 128 | Slight leftward bias in spiral display | | 100 | Infinite loop with no break condition in spirals | User must manually interrupt | ## Source Code ``` 10 RUN 220 20 REM Spirals 30 CLEAR :INPUT "ENTER 4 NUMBERS BETWEEN 1 AND 20";a,b,c,d 40 LET T=0 50 LET X1=125+125* SIN (A*T) 60 LET Y1=87+87* SIN (B*T) 70 LET X2=125+125* SIN (C*T) 80 LET Y2=87+87* SIN (D*T) 90 PLOT x1,y1:DRAW X2-X1,Y2-Y1 100 LET t=t+.01:GO TO 50 110 REM Circle fill 120 CLS 130 INPUT "x(0-255) ";X,"y(0-255) ";y,"radius ";r 140 CIRCLE X,Y,R 150 FOR n=0 TO R 160 LET Z=R↑2:LET ZZ=n↑2 170 LET XX= SQR (Z-ZZ) 180 LET YY=Y+XX:LET xy=2*XX 190 PLOT X+n,YY:DRAW 0,-XY 200 PLOT X-n,YY:DRAW 0,-XY 210 NEXT n 220 CLEAR :PRINT '''''' TAB 9;"2 Screen Demos"'''"1. Spirals","2. CIRCLE fill" 230 INPUT "Select 1 2 ";z:IF z<1 OR z>2 THEN GO TO 230 240 IF z=1 THEN RUN 20 250 RUN 110 300 SAVE "Demo's*2" LINE 1 ```