--- title: "Bouncing Text" id: 54970 type: "computer_media" slug: "input" url: "http://localhost/computer_media/input/" markdown_url: "http://localhost/computer_media/input.md" published_at: "2024-06-10T01:44:45+00:00" modified_at: "2026-03-30T21:29:16+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2019/02/20230809-041332.jpg" excerpt: "Type any short phrase and watch it bounce across the screen paired with its inverse-video twin in an endless, scrolling light show." 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 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" media_contents: - id: 54964 title: "ISTUG Public Domain Library 6" type: "computer_media" url: "http://localhost/computer_media/istug-public-domain-library-6/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/06/SCR-20260330-myhz.png" media_type_tags: "Demo" --- # Bouncing Text This program creates a bouncing-text effect by repeatedly printing a user-supplied string (up to 20 characters) paired with its inverse-video mirror across the screen. The POKE at address 23692 disables the “scroll?” prompt, preventing the display from pausing when it reaches the bottom. Row position `e` bounces between 0 and 20, and column position `d` bounces between 0 and 30, each reversing sign when they exceed their boundary. The combined normal and INVERSE 1 rendering doubles the visual width of the text on each print. *** ## Program Analysis ### Program Structure The program is organized into three logical phases: initialization (lines 10–40), display (line 50), and position update with wraparound (lines 60–100). The main loop runs from line 50 back to line 50 via `GO TO 50` at line 100, producing a continuous animation with no exit condition. 1. **Lines 10–20:** Set display attributes (black ink, white paper, border 7), clear screen, and collect the user’s string into `a$`. 2. **Line 30:**`POKE 23692,255` sets the scroll counter to its maximum value, suppressing the “scroll?” prompt. 3. **Lines 40–50:** Initialize column (`d`) and row (`e`) to zero, then print the string twice — once normally, once in `INVERSE 1` — at the current screen position. 4. **Lines 60–100:** Increment row and column counters, reverse their sign when they exceed the screen boundaries, and loop back. ### Bouncing Algorithm The bounce logic uses a sign-flip technique rather than a direction flag. When `e` exceeds 20 it is replaced with `-e`, and when `d` exceeds 30 it becomes `-d`. While this does reverse direction, the approach has a notable anomaly: the counters can take on negative values, which are valid `AT` row/column arguments only so long as they resolve to legal screen coordinates. Negative `AT` coordinates will cause an error (“B Integer out of range”) once the magnitude drifts outside the 0–20 / 0–31 screen bounds, so in practice the bounce only works cleanly during the initial positive sweep. ### Key BASIC Idioms - `POKE 23692,255` — the standard system-variable poke to defeat the scroll prompt; the value decrements with each line scrolled, so 255 gives the maximum headroom before it must be re-poked. - `INVERSE 1` inline within a `PRINT` statement — toggles inverse video mid-statement without needing a separate `PRINT` line, producing the two-tone text pair. - The `INPUT` statement uses the `'` separator to issue a newline before the input cursor, keeping the prompt and entry on separate lines. ### Notable Techniques Printing at a fixed `AT e,d` position on every iteration means the program does not clear the screen between frames; old text remains visible, giving a trail effect rather than a clean animation. This is intentional for the “light show” aesthetic but means the display fills quickly. ### Bugs and Anomalies | Line | Issue | Effect | | --- | --- | --- | | `70` | `LET e=-e` when `e>20` can produce a negative row such as `-21` | Subsequent `PRINT AT e,d` will raise error “B Integer out of range” once the negated value is used | | `90` | Same sign-flip issue for column `d` when `d>30` | Same potential out-of-range error on the column axis | | `30` | Scroll counter poked only once, not inside the loop | After 255 scroll events the “scroll?” prompt will reappear | ## Source Code ``` 10 OVER 0: INK 0: PAPER 7: BORDER 7: CLS 20 INPUT "Enter 1 - 20 characters"'a$ 30 POKE 23692,255 40 LET d=0: LET e=0 50 PRINT AT e,d;a$; INVERSE 1;a$ 60 LET e=e+1 70 IF e>20 THEN LET e=-e 80 LET d=d+1 90 IF d>30 THEN LET d=-d 100 GO TO 50 ```