--- title: "13 Colonies" id: 57241 type: "computer_media" slug: "13-colonies" url: "http://localhost/computer_media/13-colonies/" markdown_url: "http://localhost/computer_media/13-colonies.md" published_at: "2024-10-04T07:08:32+00:00" modified_at: "2026-03-30T21:19:06+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/131_13C.png" excerpt: "A patriotic animation cycles through all 13 original colonies with shooting-star effects, then renders a hand-crafted block-graphic colonial flag — all in BASIC." 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 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" - name: "Holiday" slug: "holiday" taxonomy: "genre" url: "http://localhost/type/holiday/" media_contents: - id: 56734 title: "Timex Sinclair Public Domain Library Tape 1003" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1003/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/131_13C.png" article_media: - id: 8112 title: "Decoration of Independence" type: "article" url: "http://localhost/article/decoration-of-independence/" media_type_tags: "Game, Holiday" --- This program displays the original 13 colonies in the order they ratified the Constitution, animating a shooting-star or firework effect for each colony before drawing a representation of the 13-Colonies flag. Each colony name is printed at the bottom of the screen while a character animates upward from a random horizontal position, followed by a burst pattern built from block graphic characters (CHR$ 133, 134, and 6). The flag is rendered using string arrays pre-filled with CHR$ 128 (a solid block graphic) for red and white stripes, CHR$ 8 for green stripes, and CHR$ 155 for a circular star arrangement in the canton area. The program loops continuously after displaying “HAPPY FOURTH OF JULY” until a key is pressed. *** ## Program Analysis ### Program Structure The program has three distinct phases: 1. **Initialization (lines 5–260):** A REM comment describes the program’s purpose; string arrays are dimensioned and pre-filled; the machine switches to SLOW mode for display. 2. **Colony animation loop (lines 270–350):** For each of the 13 colonies, the colony name is printed, a rising character is animated from a random column, a burst is drawn at the top, and the screen is cleared. 3. **Flag display (lines 360–500):** The 13-Colonies flag is drawn using block graphics, a “HAPPY FOURTH OF JULY” message is shown, and the loop restarts after a keypress. ### Array Pre-filling Strategy Lines 190–250 pre-fill three string arrays before the display phase begins: - `B$(F)` (30 chars): each character set to `CHR$ 128` — a solid block, used for red stripes. - `G$(F)` (30 chars): each character set to `CHR$ 8` — used for white/green stripe rows. - `S$(F)` (12 chars): each character set to `CHR$ 128`, used for the solid canton background. By filling these arrays once and then PRINTing them as whole strings, the program avoids repeated character-by-character output during the flag drawing phase. ### Colony Animation Technique For each colony (line 270–350), the program picks a random column `R = RND*20+5` (lines 5–25). A FOR loop (lines 300–320) counts from row 20 up to row 5; at each step it prints `CHR$ 133` (a block graphic resembling a rising spark), then immediately overwrites it with `CHR$ 0` (a space/null character) to erase it, creating the illusion of upward motion. At the apex (line 330), four additional block graphics (`CHR$ 134` and `CHR$ 6`) are printed in a cross/burst pattern around the final position, simulating an explosion or firework burst. The screen is then cleared with `CLS` before the next colony. ### Flag Rendering The flag is built in two passes. Lines 360–410 print alternating rows of `B$` (solid blocks) and `G$` (lighter fill) six times each, plus one final `B$`, producing 13 stripe rows. Lines 420–450 overprint the upper-left canton area with `S$` (12-character solid block strings) to create the blue canton background. Line 460 then places `CHR$ 155` characters (a star UDG or block graphic) in a circular arrangement across several rows and columns to represent the ring of 13 stars in the canton. The positioning uses a combination of `AT row,col` and `TAB` within a single long `PRINT` statement. ### Key BASIC Idioms - `FAST` / `SLOW` (lines 10, 260): Initialization is done in FAST mode to suppress display; animation runs in SLOW mode for visible output. - `IF INKEY$="" THEN GOTO 480` (line 480): Standard busy-wait keypress loop — waits until any key is pressed before restarting the colony animation. - `GOTO 270` (line 500): Returns to the top of the colony loop, creating an infinite cycle. - `DIM C$(13,14)` (line 50): A two-dimensional string array with 13 rows of 14 characters stores the colony names, padded to the fixed length. ### Notable Observations and Anomalies - Line 330 contains a syntax irregularity: `AT 4,R;CHR$ 128;AT 3,R-1;CHR$ 134;5,R-1;CHR$ 6` — the third `AT` keyword appears to be missing before `5,R-1`. On the ZX81/TS1000, omitting `AT` while a row/column pair follows a semicolon may cause unpredictable positioning. - Line 610 is numbered 610, well past line 500, making it unreachable during normal execution — it serves only as a SAVE command embedded in the listing. - `CHR$ 8` used for `G$` is the ZX81 cursor-left control character, not a block graphic; its use as a “stripe” filler likely produces blank or unexpected characters rather than a visible green stripe. - The `RND*20+5` expression (line 290) can produce column values up to 25, which may push burst characters off the right edge of the 32-column screen depending on the value of `R`. ## Source Code ``` 5 REM THE ORIGINAL 13 COLONIES APPEAR IN THE ORDER THAT THEY ENTERED THE UNION, FOLLOWED BY THE FLAG OF THE 13 COLONIES. 10 FAST 20 DIM B$(30) 30 DIM G$(30) 40 DIM S$(12) 50 DIM C$(13,14) 60 LET C$(1)="DELAWARE" 70 LET C$(2)="PENNSYLVANIA" 80 LET C$(3)="NEW JERSEY" 90 LET C$(4)="GEORGIA" 100 LET C$(5)="CONNECTICUT" 110 LET C$(6)="MASSACHUSETTS" 120 LET C$(7)="MARYLAND" 130 LET C$(8)="SOUTH CAROLINA" 140 LET C$(9)="NEW HAMPSHIRE" 150 LET C$(10)="VIRGINIA" 160 LET C$(11)="NEW YORK" 170 LET C$(12)="NORTH CAROLINA" 180 LET C$(13)="RHODE ISLAND" 190 FOR F=1 TO 30 200 LET B$(F)=CHR$ 128 210 LET G$(F)=CHR$ 8 220 NEXT F 230 FOR F=1 TO 12 240 LET S$(F)=CHR$ 128 250 NEXT F 260 SLOW 270 FOR F=1 TO 13 280 PRINT AT 21,10;C$(F) 290 LET R=RND*20+5 300 FOR H=20 TO 5 STEP -1 310 PRINT AT H,R;CHR$ 133;AT H,R;CHR$ 0 320 NEXT H 330 PRINT AT 4,R;CHR$ 128;AT 3,R-1;CHR$ 134;5,R-1;CHR$ 6;AT 3,R+1;CHR$ 6;AT 5,R+1;CHR$ 134 340 CLS 350 NEXT F 360 PRINT AT 5,0; 370 FOR F=1 TO 6 380 PRINT B$ 390 PRINT G$ 400 NEXT F 410 PRINT B$ 420 PRINT AT 6,0; 430 FOR F=1 TO 6 440 PRINT S$ 450 NEXT F 460 PRINT AT 5,6;CHR$ 155;AT 5,5;CHR$ 155;TAB 7;CHR$ 155;AT 6,4;CHR$ 155;TAB 8;CHR$ 155;AT 7,3;CHR$ 155;TAB 9;CHR$ 155;AT 8,3;CHR$ 155;TAB 9;CHR$ 155;AT 9,4;CHR$ 155;TAB 8;CHR$ 155;AT 10,5;CHR$ 155;TAB 7;CHR$ 155 470 PRINT AT 21,7;"HAPPY FOURTH OF JULY" 480 IF INKEY$="" THEN GOTO 480 490 CLS 500 GOTO 270 610 SAVE "1013%1" 620 LIST ```