Moving Waves

This file is part of CATS Library Tape 9, and Timex Sinclair Public Domain Library Tape 2004. Download the collection to get this file.
Developer(s): Everett Pence
Date: 1986
Type: Program
Platform(s): TS 2068
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

VariableRole
gAngle accumulator for SIN, incremented by 0.5 each loop
rAmplitude/radius accumulator, incremented by 0.05 each loop
eY-coordinate placeholder, always 0

Content

Appears On

Capital Area Timex Sinclair User Group’s Library Tape.
One of a series of library tapes compiled from multiple user groups.

Related Products

Related Articles

Related Content

Image Gallery

Moving Waves

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

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

Scroll to Top