Muffin

Date: 198x
Type: Program
Platform(s): TS 2068

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

VariableRangePurpose
L1–21Length of the character line (columns)
L11–19Screen row for the line
J33–255Character code to display
F0 to L or L-1 to 0Loop 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.

Content

Appears On

Library tape of the Indiana Sinclair Timex User’s Group.

Related Products

Related Articles

Related Content

Image Gallery

Muffin

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

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top