--- title: "Scrolling Bulletin" id: 57512 type: "computer_media" slug: "scrolling-bulletin" url: "http://localhost/computer_media/scrolling-bulletin/" markdown_url: "http://localhost/computer_media/scrolling-bulletin.md" published_at: "2024-10-05T21:17:34+00:00" modified_at: "2026-04-03T07:58:25+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/267_SB.png" excerpt: "A three-phase scrolling news ticker crawls any message across a single screen row — and even documents its own string length requirements in the demo text." 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: "Home" slug: "home" taxonomy: "genre" url: "http://localhost/type/home/" media_contents: - id: 56737 title: "Timex Sinclair Public Domain Library Tape 1006" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1006/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/267_SB.png" media_type_tags: "Home" --- This program implements a horizontal text ticker (news-bulletin crawler) for a 32-column display, scrolling a message string across row 12 of the screen from right to left. The subroutine at line 1060 handles three phases: an entry phase (characters slide in from the right edge), a mid-scroll phase (a full 32-character window moves through the string), and an exit phase (characters slide off the left edge). Two separate messages, stored in C$ and D$, are displayed in alternating loops via GOTO 20 at line 1000. The delay loops at lines 1080–1090 and 1130–1140 use a short FOR/NEXT with limit 3 to control scroll speed. The program requires the message string to be at least 33 characters long and end with a space, as documented in D$ itself. *** ## Program Analysis ### Program Structure The program is divided into two logical parts: a main loop and a reusable scroll subroutine. - Lines 10–90: Initialisation and message dispatch — sets up two strings (`C$` and `D$`), copies each into `B$`, and calls the scroll subroutine. - Line 1000: `GOTO 20` creates an infinite alternating loop between the two messages. - Lines 1060–1210: The scroll subroutine, which performs all three phases of the ticker animation on row 12. - Lines 1220–1240: Utility lines for saving — not reached during normal execution. ### Scroll Subroutine — Three Phases The subroutine at line 1060 implements a classic ticker in three distinct phases, all printing to `AT 12,` (the middle of a 25-row display): 1. **Entry phase (lines 1060–1100):** Loop variable `F` runs from 0 to 30. Each iteration prints the first `F+1` characters of `B$` at column `31-F`, making the text appear to slide in from the right edge one character at a time. 2. **Mid-scroll phase (lines 1110–1150):** Loop variable `E` runs from 1 to `LEN B$-33`. A 32-character window (`B$(E+1 TO E+32)`) is printed at column 0, advancing through the string. This requires the string to be at least 33 characters long. 3. **Exit phase (lines 1160–1200):** Loop variable `C` runs from 0 to 31. The tail of the string (`B$(C+LEN B$-31 TO LEN B$)`) is printed at column 0, progressively shortening as the text scrolls off the left edge. ### Delay Mechanism Speed is controlled by an inner `FOR D=1 TO 3: NEXT D` loop present in each phase (lines 1080–1090, 1130–1140, 1180–1190). The limit of 3 iterations produces a minimal delay. Combined with the `SLOW` mode set at line 10 (which halts the CPU during display generation), this gives a visible but reasonably fast scroll rate. Increasing the limit of 3 would slow the ticker down. ### String Requirements and Self-Documentation The program imposes two constraints on `B$`: it must be at least 33 characters long (or the mid-scroll loop will not execute, and the slice in the exit phase may produce an error), and its final character must be a space (to avoid a visible hard edge during exit). Unusually, the demonstration string stored in `D$` at line 60 explicitly states both of these requirements as part of its own content, serving as both a test message and inline documentation. ### Variable Usage | Variable | Role | | --- | --- | | `B$` | Working copy of the string passed to the subroutine | | `C$` | First display message (intro/instructions) | | `D$` | Second display message (usage notes) | | `F` | Entry phase loop counter | | `E` | Mid-scroll phase loop counter | | `C` | Exit phase loop counter | | `D` | Inner delay loop counter (reused across all three phases) | ### Notable Techniques and Observations - The reuse of `B$` as an input parameter convention for the subroutine is a clean pattern, given ZX81 BASIC has no proper procedure arguments. - The `CLS` at lines 50 and 90 clears the screen between messages, preventing leftover characters from adjacent print positions. - The exit phase loop runs from 0 to 31 (32 iterations), but each iteration prints a progressively shorter slice ending at `LEN B$`; at `C=31` the slice is a single character (the mandatory trailing space), leaving a clean finish. - There is a potential edge case: if `LEN B$` is exactly 33, the mid-scroll loop runs for exactly one iteration (`E=1`), which is valid but produces almost no mid-scroll phase. - The variable name `C` is reused at line 1160 as the exit-phase counter, which shadows the outer loop variable — this is safe here since the entry phase loop using `F` has already completed, but the naming overlap with `C$` (the string variable) is coincidental and causes no conflict in ZX81 BASIC. ## Source Code ``` 10 SLOW 20 LET C$="IF YOU WANT TO PRINT A NEWS BULLETIN THEN READ ON . " 30 LET B$=C$ 40 GOSUB 1060 50 CLS 60 LET D$="LENGTHEN THIS STRING FOR MORE MESSAGE. 600 CHARACTERS MAY BE USED.USE AT LEAST 33 CHARACTERS. THE FINAL CHARACTER MUST BE A SPACE. " 70 LET B$=D$ 80 GOSUB 1060 90 CLS 1000 GOTO 20 1060 FOR F=0 TO 30 1070 PRINT AT 12,31-F;B$(1 TO F+1) 1080 FOR D=1 TO 3 1090 NEXT D 1100 NEXT F 1110 FOR E=1 TO LEN B$-33 1120 PRINT AT 12,0;B$(E+1 TO E+32) 1130 FOR D=1 TO 3 1140 NEXT D 1150 NEXT E 1160 FOR C=0 TO 31 1170 PRINT AT 12,0;B$(C+LEN B$-31 TO LEN B$) 1180 FOR D=1 TO 3 1190 NEXT D 1200 NEXT C 1210 RETURN 1220 CLEAR 1230 SAVE "1026%7" 1240 RUN ```