Color Show

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

Color Show is a random color display program that plots colored spaces across the screen using a constrained random walk. The program uses RANDOMIZE to seed the random number generator, then continuously selects a random paper color (0–8) and performs up to 20 steps of a two-dimensional random walk, printing colored spaces at each position. Variables `a` and `b` track the current screen position, clamped to the ranges 1–20 (rows) and 1–30 (columns) respectively to keep output within the display area. A subroutine at line 400 draws a rectangular border using PLOT and DRAW commands before the main loop begins.


Program Structure

The program is divided into two functional sections: an initialization subroutine (lines 410–460) that draws a screen border, and the main loop (lines 110–380) that performs the random color walk. Control flows as follows:

  1. Line 50 calls the border-drawing subroutine at line 400 (which begins executing at line 410).
  2. Line 110 seeds the random number generator with RANDOMIZE.
  3. Lines 120 sets the initial screen coordinates: row a=10, column b=20.
  4. Lines 160–380 form an infinite outer loop via GO TO 160, picking a new color and walk length each iteration.
  5. Lines 210–370 are the inner FOR loop executing up to n steps of the random walk.

Border Subroutine

The subroutine at lines 410–460 draws a closed rectangle using PLOT and four DRAW commands covering the full 256×176 pixel screen area. The GO SUB 400 at line 50 targets line 400, which does not exist — execution falls through to line 410, a well-known BASIC technique to save memory by avoiding an otherwise unnecessary line.

Random Walk Mechanics

Each outer loop iteration picks a random paper color c in the range 0–8 and a random step count n in the range 0–19. The inner loop moves the cursor by incrementing or decrementing a (row) or b (column) based on a random direction d (0–3):

  • d=0: move down (a+1)
  • d=1: move up (a-1)
  • d=2: move right (b+1)
  • d=3: move left (b-1)

After each move, boundary clamping is applied to keep a within 1–20 and b within 1–30, preventing PRINT AT from causing an out-of-range error.

Key BASIC Idioms and Techniques

  • PAPER c followed by PRINT AT a,b;" " — printing a space with a set paper color is the standard method for painting colored character cells without using INK.
  • The boundary clamp uses four successive IF statements (lines 280–310) rather than structured min/max functions, which is typical for the BASIC dialect in use.
  • Large line-number gaps (e.g., 50, 110, 120, 160…) leave room for future insertions without renumbering.

Bugs and Anomalies

IssueDetail
Missing RANDOMIZE argumentRANDOMIZE at line 110 with no argument uses the system clock/frame counter, which is the intended behavior for non-deterministic seeds.
Color range includes 8INT(RND*9) yields 0–8; color 8 is typically “transparent” or system-dependent, which may produce unexpected results depending on the current ink/paper state.
Walk position not reset per colora and b are only initialized once at line 120; the walk continues from its last position across color changes, which is likely intentional for visual continuity.

Content

Appears On

Related Products

Related Articles

Related Content

Image Gallery

Source Code

   1 REM RANDOM COLORS
  50 GO SUB 400
 110 RANDOMIZE 
 120 LET a=10:LET b=20
 160 LET c= INT (RND*9)
 170 LET n= INT (RND*20)
 210 FOR x=0 TO n
 220 LET d= INT (RND*4)
 230 IF d=0 THEN LET a=a+1
 240 IF d=1 THEN LET a=a-1
 250 IF d=2 THEN LET b=b+1
 260 IF d=3 THEN LET b=b-1
 280 IF b >=30 THEN LET b=30
 290 IF b <=1 THEN LET b=1
 300 IF a >=20 THEN LET a=20
 310 IF a <=1 THEN LET a=1
 350 PAPER c
 360 PRINT AT a,b;" "
 370 NEXT x
 380 GO TO 160
 410 PLOT 0,0
 420 DRAW 255,0
 430 DRAW 0,175
 440 DRAW -255,0
 450 DRAW 0,-175
 460 RETURN 

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

People

No people associated with this content.

Scroll to Top