Flag

This file is part of Timex Sinclair Public Domain Library Tape 1003 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Demo, Holiday

This program draws a stylized flag graphic on screen using PRINT AT positioning and block graphics characters. It works in three phases: first rendering alternating striped rows across columns 1–26 (rows 5–16), then overlaying a solid region in the upper-left canton (rows 6–10, columns 1–13), and finally using UNPLOT to punch circular or dot patterns into the flag in a grid arrangement. The program uses the ZX81’s UNPLOT command to clear individual pixels, creating a decorative pattern over the stripes. A SAVE command at line 300 stores the program before RUN at line 310 re-executes it.


Program Analysis

Program Structure

The program is divided into four logical sections separated by line-number gaps:

  1. Lines 5–70: Draw the main body of the flag — a horizontal stripe at row 5 and alternating filled/blank rows from 6 to 16 across all 26 columns.
  2. Lines 100–140: Overlay the canton (upper-left rectangle, rows 6–10, columns 1–13) with solid block characters, overwriting the stripe pattern.
  3. Lines 200–270: Use UNPLOT in nested loops to clear individual pixels, creating a decorative dot or star-like pattern across the flag.
  4. Lines 280–310: STOP halts execution; SAVE and RUN follow but are not reached in normal flow.

Flag Rendering — Phase 1 (Lines 10–70)

The outer loop FOR I=1 TO 26 iterates over columns. At each column, line 20 prints a space character ("% " — inverse space, i.e. a filled block) at row 5. The inner loop FOR J=6 TO 16 STEP 2 then prints a block graphic "\##" (a solid 2×2 block character) at even rows and an inverse space at odd rows (J+1), producing a horizontal stripe effect down the flag body.

Canton Overlay — Phase 2 (Lines 100–140)

A second nested loop fills rows 6, 8, and 10 (STEP 2) in columns 1–13 with inverse spaces, creating a solid rectangular canton in the top-left quadrant. This overwrites the stripe pattern laid down in phase 1 for that region.

UNPLOT Decoration — Phase 3 (Lines 200–270)

The outer loop FOR J=23 TO 31 STEP 2 and inner loop FOR I=5 TO 21 STEP 4 address pixel coordinates (note ZX81 pixel addressing). UNPLOT clears individual pixels to create a spaced dot grid. Line 230 conditionally skips line 240 when J=23; line 240 contains a likely bug: UNPLOT I=2,J-1 — the expression I=2 evaluates as a boolean (0 or 1 in ZX81 BASIC) rather than I-2 as presumably intended. This means the second UNPLOT always plots at pixel column 0 or 1 rather than offset from I. Line 260 adds an additional UNPLOT at a fixed column 25 for each J value.

Notable Techniques

  • Inverse space as filled block: "% " (inverse space character) is used as a solid fill — a common ZX81 idiom for drawing filled rectangles without block graphics.
  • Block graphic character: "\##" represents a fully-filled 2×2 block graphic, used for the stripe rows.
  • STEP 2 loops: Both the stripe loop (J=6 TO 16 STEP 2) and the UNPLOT loop (J=23 TO 31 STEP 2) use STEP 2 to address alternating rows/pixels, a space-efficient way to produce patterns.
  • Conditional branching within inner loop: IF J=23 THEN GOTO 250 skips the second UNPLOT on the first pass of the outer loop only.

Bugs and Anomalies

LineIssueEffect
240UNPLOT I=2,J-1I=2 is a boolean expressionAlways UNPLOTs at x-coordinate 0 (false) or 1 (true when I=2), not at I-2 as likely intended

The STOP at line 280 means lines 300 (SAVE) and 310 (RUN) are never executed during normal program flow and appear to be remnants or setup lines.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10122 – 10175.

Related Products

Related Articles

Related Content

Image Gallery

Flag

Source Code

   5 REM FLAG
  10 FOR I=1 TO 26
  20 PRINT AT 5,I;"% "
  30 FOR J=6 TO 16 STEP 2
  40 PRINT AT J,I;"\##"
  50 PRINT AT J+1,I;"% "
  60 NEXT J
  70 NEXT I
 100 FOR I=1 TO 13
 110 FOR J=6 TO 10 STEP 2
 120 PRINT AT J,I;"% "
 130 NEXT J
 140 NEXT I
 200 FOR J=23 TO 31 STEP 2
 210 FOR I=5 TO 21 STEP 4
 220 UNPLOT I,J
 230 IF J=23 THEN GOTO 250
 240 UNPLOT I=2,J-1
 250 NEXT I
 260 UNPLOT 25,J
 270 NEXT J
 280 STOP 
 300 SAVE "1014%1"
 310 RUN 

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

People

No people associated with this content.

Scroll to Top