--- title: "Muffin" id: 55127 type: "computer_media" slug: "muffin" url: "http://localhost/computer_media/muffin/" markdown_url: "http://localhost/computer_media/muffin.md" published_at: "2024-06-16T23:51:29+00:00" modified_at: "2026-03-30T21:44:12+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/06/SCR-20240616-rgea.png" excerpt: "A hypnotic animation loop draws a random character across a random screen row, then wipes it away — endlessly repeating with fresh values each cycle." 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: "Animation" slug: "animation" taxonomy: "genre" url: "http://localhost/type/animation/" - name: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" media_contents: - id: 54965 title: "ISTUG Public Domain Library 5" type: "computer_media" url: "http://localhost/computer_media/istug-public-domain-library-5/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/06/SCR-20240616-rgea.png" media_type_tags: "Animation, Demo" --- # Muffin This program draws a horizontal line of a randomly chosen printable character across a random row of the screen, then erases it by overwriting with spaces, looping indefinitely. The line length is a random value from 1 to 21 columns, the row is randomly chosen from rows 1 to 19, and the character is selected from the printable ASCII range (codes 33–255). The double comma after each PRINT statement suppresses the newline and advances the print position, building the line one character at a time. The program creates a simple animation effect of a character string appearing and disappearing across the screen. *** ## Program Analysis ### Program Structure The program is a short, self-contained infinite animation loop. After an initial `REM` label at line `10`, it generates three random values, draws a line, then erases it before jumping back to regenerate new values. There are no subroutines or conditional branches. 1. **Initialization (lines 20–40):** Three random variables are computed — line length `L`, screen row `L1`, and character code `J`. 2. **Draw phase (lines 50–80):** A `FOR` loop places `CHR$ J` at successive columns from 0 to `L`, followed by a redundant extra print at column `L`. 3. **Erase phase (lines 90–110):** A reverse `FOR` loop overwrites columns `L-1` down to 0 with spaces. 4. **Loop (line 120):**`GO TO 20` restarts the cycle with newly randomized values. ### Variable Usage | Variable | Range | Purpose | | --- | --- | --- | | `L` | 1–21 | Length of the character line (columns) | | `L1` | 1–19 | Screen row for the line | | `J` | 33–255 | Character code to display | | `F` | 0 to L or L-1 to 0 | Loop counter / column index | ### Notable Techniques - **Double comma in PRINT:** The `,,` after `CHR$ J` in lines `60` and `80` suppresses the automatic newline and moves the cursor to the next column, enabling character-by-character horizontal drawing without repositioning via `AT` each time after the first. - **Random character selection:**`INT(RND*223)+33` spans codes 33–255, covering all printable ASCII characters as well as the block graphics and UDG character set, so the visual output varies widely between cycles. - **In-place erase animation:** Rather than using `CLS`, the erase phase walks backwards across the drawn columns, creating a wipe effect rather than a flash clear. ### Bugs and Anomalies - **Off-by-one / redundant print at line 80:** The `FOR` loop at lines `50–70` already prints at column `L` during its final iteration (`F=L`), so line `80` prints the same character at `AT L1,L` again. This is harmless but redundant. - **Erase starts at L-1, not L:** The erase loop (line `90`) runs from `L-1` down to `0`, leaving the character at column `L` permanently on screen until the next cycle draws over it (if the new line is at least as long) or it persists otherwise. This means the rightmost character is never erased within the current cycle. - **Row range avoids row 0:**`L1` starts at 1, so the top row is never used for drawing — this may be intentional to avoid interfering with system output, or simply an oversight. ## Source Code ``` 10 REM *** MUFFIN 20 LET L=INT (RND*21)+1 30 LET L1=INT (RND*19)+1 40 LET J=INT (RND*223)+33 50 FOR F=0 TO L 60 PRINT AT L1,F;CHR$ J,, 70 NEXT F 80 PRINT AT L1,L;CHR$ J,, 90 FOR F=(L-1) TO 0 STEP -1 100 PRINT AT L1,F;" " 110 NEXT F 120 GO TO 20 ```