--- title: "Network" id: 56242 type: "computer_media" slug: "network" url: "http://localhost/computer_media/network/" markdown_url: "http://localhost/computer_media/network.md" published_at: "2024-07-22T01:23:02+00:00" modified_at: "2026-03-30T21:44:17+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/07/SCR-20240721-snct.png" excerpt: "A mesmerising line-burst pattern redraws itself endlessly in randomly chosen colour combinations — watch a geometric network bloom from a single screen point." 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: "Art" slug: "art" taxonomy: "genre" url: "http://localhost/type/art/" - name: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" media_contents: - id: 56205 title: "CATS Library Tape 11" type: "computer_media" url: "http://localhost/computer_media/cats-library-tape-11/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Network%20%28198x%29%28TS2068%29%28US%29%28Program%29.zip" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/07/SCR-20240721-snct.png" media_type_tags: "Art, Demo" --- # Network This program draws a radiating line-burst graphic centered on the screen, creating a network or moire pattern. It uses two nested loops to draw lines from a central point (128,88) to points along the bottom edge and then up the right side of the display, with the direction variable `z` flipping between 1 and −1 on each pass to mirror the pattern. Random ink and paper colors are chosen each cycle, with a retry loop ensuring they never match. The finished frame is held briefly with PAUSE 100 before the display is cleared and a new color combination is generated. *** ## Program Analysis ### Program Structure The program is a continuous animation loop. Execution begins at line 10 (a `REM` label), sets up colour and direction state, draws the pattern, pauses, then jumps back to line 20 indefinitely. 1. **Lines 20–55** — Initialise direction variable `z`, pick random ink and paper colours (1–5), retry if they match, then apply colours and clear the screen. 2. **Lines 60–130** — Outer `FOR a=1 TO 2` loop runs the drawing phase twice; on the second pass `z` is negated at line 130, mirroring the geometry. 3. **Lines 70–90** — Inner loop draws lines from centre (128,88) to points along the horizontal axis, stepping every 2 pixels. 4. **Lines 100–120** — Second inner loop draws lines from centre to points along the vertical axis. 5. **Line 140** — Negate `z`, close outer loop, pause 100 frames (~2 seconds), then restart. ### Drawing Geometry All lines originate from the fixed point (128, 88), which is close to the screen centre (the display is 256×176 pixels, so true centre is 128,88 — this is exact). The `DRAW` command takes relative offsets; the expressions `(-127*z)+(x*z)` and `z*-87` etc. scale the endpoint by `z` (±1), so the second pass of the outer loop reflects every line through the origin, producing a symmetrical starburst. ### Key BASIC Idioms - **Direction flip via negation**: `LET z=-z` at line 130 toggles `z` between 1 and −1, avoiding a conditional branch and neatly mirroring the draw operations. - **Colour collision avoidance**: The `IF ink=paper THEN GO TO 30` retry at line 50 is a simple rejection-sampling loop ensuring readable contrast. - **Colour range 1–5**: Using `INT(RND*5)+1` excludes black (0) and white (7), keeping all combinations visually distinct on a non-black, non-white background. - **STEP 2 sampling**: Both loops step by 2 pixels, halving draw time while still producing a dense fan of lines. ### Notable Techniques The outer `FOR a=1 TO 2` loop is an elegant way to draw a mirrored set of lines without duplicating code. On the first iteration (`z=1`) lines radiate toward the lower-left and lower quadrants; after `LET z=-z` (line 130) sets `z=-1`, the second iteration reflects them to the upper-right quadrants, filling the screen with a symmetrical network pattern. The `PAPER` and `INK` statements at line 55 are followed immediately by `CLS`, ensuring the entire screen — including the border attribute area — is repainted in the new colour scheme before drawing begins. ### Variable Summary | Variable | Role | | --- | --- | | `z` | Direction multiplier (1 or −1); mirrors draw geometry on second pass | | `ink` | Random foreground colour (1–5) | | `paper` | Random background colour (1–5), guaranteed ≠ `ink` | | `a` | Outer loop counter (1–2); drives two mirrored drawing passes | | `x` | Horizontal pixel offset (0–254, step 2) | | `y` | Vertical pixel offset (0–175, step 2) | ### Potential Anomalies On the second pass of the outer loop, `z` has already been set to −1 at line 130, but line 130 is *inside* the outer `FOR`/`NEXT` loop (lines 60–140). This means `z` is negated after the first complete set of fan lines and before the second, which is the intended behaviour. However, `z` is also reset to 1 unconditionally at line 20 each time the main loop restarts via `GO TO 20`, so state is always clean at the start of each frame. ## Source Code ``` 10 REM network 20 LET z=1 30 LET ink=INT (RND*5)+1 40 LET paper=INT (RND*5)+1 50 IF ink=paper THEN GO TO 30 55 PAPER paper: INK ink: CLS 60 FOR a=1 TO 2 70 FOR x=0 TO 254 STEP 2 80 PLOT 128,88: DRAW (-127*z)+(x*z),z*-87 90 NEXT x 100 FOR y=0 TO 175 STEP 2 110 PLOT 128,88: DRAW 127*z,z*-87+(y*z) 120 NEXT y 130 LET z=-z 140 NEXT a: PAUSE 100: GO TO 20 9990 SAVE "NETWORK" LINE 10 ```