--- title: "Moving Waves" id: 55587 type: "computer_media" slug: "moving-waves" url: "http://localhost/computer_media/moving-waves/" markdown_url: "http://localhost/computer_media/moving-waves.md" published_at: "2024-06-30T08:15:15+00:00" modified_at: "2026-03-30T21:44:10+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/06/SCR-20240630-elvh.png" excerpt: "A hypnotic animated wave plot uses sine-driven coordinates and an error-trap handler to keep running until something inevitably goes wrong." 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/" indiv: - name: "Everett Pence" slug: "everett-pence" taxonomy: "indiv" url: "http://localhost/indiv/everett-pence/" genre: - name: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" media_contents: - id: 55430 title: "Timex Sinclair Public Domain Library Tape 2004" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-2004/" - id: 64507 title: "CATS Library Tape 9" type: "computer_media" url: "http://localhost/computer_media/cats-library-tape-9/" media_type: "Program" programmers: - name: "Everett Pence" slug: "everett-pence" taxonomy: "indiv" url: "http://localhost/indiv/everett-pence/" mediadate: "1986" images: - url: "http://localhost/wp-content/uploads/2024/06/SCR-20240630-elvh.png" article_media: - id: 46997 title: "Moving Waves" type: "article" url: "http://localhost/article/moving-waves/" media_type_tags: "Demo" --- “Moving Waves” is an animated graphics program that plots a sinusoidally oscillating point on the ZX Spectrum/TS2068 screen, creating a wave-like visual effect. The program uses PLOT and DRAW commands with incrementing angle variable `g` and radius variable `r` to generate the motion. A POKE to address 23692 suppresses the scroll prompt, keeping the display running continuously. An ON ERR handler at line 30 catches errors and prints humorous commentary before issuing NEW to clear memory. The program also contains two POKE statements at line 26 targeting the system variables at 23627–23628, which affect the random number seed. *** ## Program Analysis ### Program Structure The program is loosely organized into three functional areas: initialization, the main animation loop, and an error-handling sequence. Lines 1–9 set up screen attributes and variables. Lines 10–20 form the core animation loop. Lines 26–40 constitute the error handler and cleanup routine. Lines 50 and 9999 are ancillary (a comment and a save command). ### Main Animation Loop The loop begins at line 10 with a bare `PRINT` (which advances the print position) and increments two accumulator variables each iteration. Variable `r` grows by 0.05 each pass, acting as an ever-increasing radius or amplitude modifier. Variable `g` grows by 0.5 each pass, serving as the angle fed to `SIN`. The x-coordinate of the plotted point is thus `130 + r * SIN g`, producing a drifting sinusoidal oscillation. Variable `e` is set to 0 at line 12 and used as the y-coordinate at line 17, so the wave always plots along y=0, while line 16 draws a short vertical reference mark at x=130. ### Key BASIC Idioms and Techniques - `POKE 23692,0` at line 13 resets the scroll counter, preventing the “scroll?” prompt from interrupting the display loop — a standard idiom for continuous-output programs. - `ON ERR GO TO 30` at line 2 (using the TS2068 `ON ERR` extension) provides a structured error trap, diverting any runtime error into the humorous exit sequence. - `PAPER 0: INK 7: BORDER 0: CLS : CLS` at line 7 sets up a black-background, white-ink display with a black border, calling `CLS` twice for thoroughness. - Line 26 uses `POKE 23627,INT RND*255: POKE 23628,INT RND*255` to write random values into the SEED system variable area (23627–23628), re-randomizing the RNG — though this line is only reachable if control flows through it from an error, and it is skipped by the `GO TO 30` in the error handler. ### Control Flow Anomalies Line 26 is unreachable under normal execution. The animation loop jumps from line 20 back to line 10, and the error handler at line 2 directs flow to line 30, bypassing line 26 entirely. The POKE statements there would only execute if control fell through from line 20 sequentially — which never occurs because of the `GO TO 10`. This appears to be dead code, possibly a remnant of an earlier version of the program. The variable `e` is initialized to 0 at line 12 every iteration and never modified before being used in line 17, so the plotted y-coordinate is always 0. Combined with `r` and `g` driving x, the result is a one-dimensional oscillating dot rather than a true two-dimensional wave. ### Error Handling and Termination When an error occurs (most likely an arithmetic overflow as `r` grows without bound, eventually pushing the `PLOT` coordinate outside the valid screen range), control passes to line 30. Lines 30 and 35 print commentary, and line 40 executes `NEW`, wiping the program from memory — an aggressive but definitive termination strategy. ### Variable Summary | Variable | Role | | --- | --- | | `g` | Angle accumulator for SIN, incremented by 0.5 each loop | | `r` | Amplitude/radius accumulator, incremented by 0.05 each loop | | `e` | Y-coordinate placeholder, always 0 | ## Source Code ``` 1 PRINT "Yes my mind is going going gone." 2 ON ERR GO TO 30 3 BEEP 3,33 4 PRINT "I am working with a black and white TV that cost me nothing at all so I am color blind on this CRT " 5 REM Moving waves by Everett Pence 7 PAPER 0: INK 7: BORDER 0: CLS : CLS 9 LET g=0: LET r=0 10 PRINT 11 LET r=r+.05 12 LET e=0 13 POKE 23692,0 15 LET g=g+.5 16 PLOT 130,0: DRAW 0,8 17 PLOT 130+r*SIN g,e 20 GO TO 10 26 POKE 23627,INT RND*255: POKE 23628,INT RND*255 30 PRINT "but what about the person that thought this up!" 35 PRINT "Its not worth it!!!!" 40 NEW 50 REM hey ya'll out there welcome to Texas-land the ability to play around never ceases does it 9999 SAVE "MovingWave" LINE 1 ```