BI Guide

Products:
Developer(s): Fred Blechman
Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Demo

This program is a collection of eight demonstration routines for beginner and intermediate BASIC programmers, selectable from a menu at line 2000. Routines include a spring-physics simulator using velocity and acceleration variables to create oscillating PLOT/DRAW animations, a color palette browser cycling all eight PAPER colors, a PAPER/INK/BORDER combination display, a square root calculator with audio feedback via BEEP, a “title shoot” that reads pixels from text and redraws them scaled to the screen, a flag graphic built with UDGs and DATA statements, a block-graphic animated dog, and a software digital timer using nested FOR loops. The menu dispatches each routine with RUN rather than GO SUB, meaning each section executes as a self-contained program with its own variable scope. The spring simulator at line 100 applies a simple harmonic motion formula, pulling the drawing point toward the screen center (127, 95) with random damping coefficients.


Program Structure

The program is organized as a menu-driven collection of eight independent routines, each occupying its own line-number range. The entry point is line 10, which immediately transfers control to the menu at line 2000. Each routine is launched with RUN rather than GO SUB, giving each section a clean variable environment but also meaning there is no way to return to the menu automatically — each demo either loops forever or reaches a STOP.

Menu ChoiceStart LineDescription
120Spring oscillator
2220Color palette browser
3420PAPER/INK/BORDER combinations
4620Square root calculator
5800Title shoot (pixel scaling)
61000Flag with UDGs
71200Animated dog
81400Digital timer

Menu Dispatch

Line 2000 uses a multi-line INPUT prompt presenting all eight options, then validates the choice with IF x<1 OR x>8 THEN GO TO 2000. Lines 2010–2080 dispatch with RUN to the appropriate start line. Line 2080 handles choice 8 without an explicit test since all other choices have already been handled — a clean fall-through idiom.

Spring Oscillator (Lines 20–150)

This routine simulates simple harmonic motion in two dimensions. Variables vx and vy accumulate velocity, while ax and ay are random damping/spring constants chosen once per run. The core update at lines 100–110 applies a restoring force proportional to the distance from the screen center (127, 95):

  • vx = vx + (127 - x) / ax
  • vy = vy + (95 - y) / ay

Because ax and ay are non-integer random values and velocity is never damped to zero, the path never exactly repeats, producing a Lissajous-like figure. The ON ERR CONTINUE at line 50 silently suppresses any out-of-range PLOT/DRAW errors when the oscillating point strays near or beyond screen boundaries. Pressing A or a at line 40 stops the routine.

Color Palette and PAPER/INK Demos (Lines 220–510)

The palette demo (lines 240–290) cycles through all eight PAPER colors in a loop, using PRINT with commas to step across columns. The PAPER/INK demo (lines 440–510) uses nested loops over all 64 PAPER/INK combinations and simultaneously sets BORDER to match the ink color, printing a label for each combination. Both routines loop indefinitely via GO TO.

Square Root Calculator (Lines 620–720)

Line 640 uses POKE 23609,100 to set the system variable that controls the INPUT line editing timeout, effectively giving a generous wait for keyboard entry. The routine validates that the input is positive before computing SQR a, and on success plays a two-note BEEP sequence (BEEP .2,0:BEEP .2,7) before looping. Invalid (non-positive) input causes a jump to line 720, which prints an END message using a PRINT AT on the bottom row.

Title Shoot — Pixel Scaling (Lines 800–910)

This routine reads the pixel content of the top portion of the screen (x: 0–127, y: 0–7) using POINT, then redraws each set pixel at a scaled position (2*X, 3*Y+80) in the lower half. The string A$="ISTUG = FUN !!!" is printed at the bottom of the screen at line 810 and its pixel pattern is what gets sampled and reproduced. Lines 860–870 use a FOR a=0 TO 1 loop with DRAW OVER 1 to XOR-draw a line twice, effectively producing a brief flash effect. Line 890 adds a short high-pitched BEEP for each pixel hit.

Flag with UDGs (Lines 1000–1120)

Line 1010 uses RESTORE 1000 and then reads 16 bytes from the DATA at line 1110 into UDG \a (character 144), defining a custom block graphic. The flag pattern is built with alternating rows of s$ (asterisks) and t$ (offset asterisks) printed with PAPER 1 / INK 7 (red background, white ink) to suggest a stars-and-stripes motif. Lines 1060–1090 then read a second DATA sequence (line 1120) to print stripe characters across the display using CHR$ a with alternating PAPER colors. DIM b$(5) and DIM b$(32) are used as a compact way to produce blank strings of known length for filling the stripe area.

Animated Dog (Lines 1200–1300)

The dog graphic is drawn using block graphics characters across four rows (AT 0–3), scrolling horizontally as variable Y increments from 0 to 27. At each horizontal position, a random “ARF!” bark is printed at a random screen location via PRINT AT RND*14+7, RND*27;"ARF!". The inner loop at lines 1290–1300 erases five characters of the previous dog position by printing spaces before advancing y. PI is used as a convenient approximation of 3 (its integer value when used in AT row/column context, which truncates to 3).

Digital Timer (Lines 1400–1550)

The timer uses four nested FOR loops representing hours (h), minutes (m), seconds (s), and tenths (t). Because BASIC loop execution is not calibrated to real time, the “tenths” are approximate — line 1510 inserts a short busy-wait loop (FOR d=1 TO 7:NEXT d) to slow the innermost loop, but actual timing depends on interpreter speed. Pressing A or a is detected via INKEY$ at line 1490, which then prints a CONTINUE prompt and halts. Hours are not bounded by a FOR loop; instead, h is incremented at line 1540 and the minute loop restarts via GO TO 1460.

Notable Techniques and Idioms

  • RUN used for menu dispatch rather than GO SUB, clearing all variables on each launch.
  • ON ERR CONTINUE used defensively in the spring oscillator to suppress graphics boundary errors.
  • PI used as a column/row offset (evaluates to approximately 3 in integer contexts) in AT coordinates — a space-saving idiom.
  • DIM b$(n) used to generate a blank string of length n for printing spacer lines.
  • RESTORE 1000 at line 1010 targets the line containing the menu INPUT statement, not a DATA line — this is a potential anomaly, as the READ loop immediately following would read from the nearest DATA after line 1000, which is line 1110. The RESTORE target is unusual but harmless since the interpreter searches forward for the first DATA statement.
  • Block graphics characters are used throughout for the dog sprite, leveraging the character set for compact sprite definition without UDGs.

Potential Issues

  • The SAVE "B/I guide" LINE 1 at line 3000 targets line 1, which does not exist in the listing; the program starts at line 5. This means the auto-run line number would fail to find its target on load, and execution would fall through to the next available line.
  • The timing of the digital timer is not calibrated and will vary depending on system load and interpreter speed; the “tenths” label is approximate at best.
  • In the title shoot routine, PLOT 0,0 at line 870 moves the DRAW origin to (0,0) before the DRAW OVER 1, meaning the flash line always starts from the screen corner rather than the scaled pixel position — this appears to be a bug in the intended effect.

Content

Appears On

Related Products

Related Articles

Related Content

Image Gallery

Source Code

    5 REM \{6}\{6}\{6}\{6} Timex Sinclair 2068   Beginner/Intermediate Guide routines\{6}by Fred Blechman\{6}\{6}
   10 RUN 2000
   20 REM SPRING
   30 LET x= RND*250:LET y= RND*160
   40 IF INKEY$="A" OR INKEY$="a" THEN STOP 
   50 ON ERR CONTINUE 
   60 LET vx=0:LET vy=vx
   70 LET ax= RND*50+5:LET ay= RND*50+5
   80 PLOT x,y
  100 LET vx=vx+(127-x)/ax:LET x=x+vx
  110 LET vy=vy+(95-y)/ay:LET y=y+vy
  130 DRAW vx,vy
  150 GO TO 100
  220 REM \{6}\{6}\{6}\{6}         Color Palette\{6}\{6}
  240 CLS 
  250 FOR p=0 TO 7:PAPER p
  260 PRINT , BRIGHT 1,
  270 PRINT , BRIGHT 1,
  280 NEXT p
  290 PAUSE 100:GO TO 250
  420 REM \{6}\{6}\{6}\{6}         PAPER &INK \{6}\{6}
  440 CLS 
  450 FOR p=0 TO 7:PAPER p
  460 FOR i=0 TO 7:INK i:BORDER i
  470 PRINT "PAPER ";p;"/INK ";i,
  480 NEXT i:NEXT p
  490 PAPER 7:INK 0
  500 PAUSE 300
  510 GO TO 440
  620 REM \{6}\{6}\{6}\{6}The Square Root Program\{6}\{6}
  640 POKE 23609,100
  650 PRINT "Positive Number? ";
  660 INPUT a:PRINT a
  670 IF a <=0 THEN GO TO 720
  680 LET x= SQR a
  690 PRINT :PRINT "Square Root= ";x
  700 PRINT "--------------------------------"'
  710 BEEP .2,0:BEEP .2,7:GO TO 650
  720 PRINT ' AT 21,10;" END "
  800 CLS :LET A$="ISTUG = FUN !!!"
  810 PRINT AT 21,0;A$
  820 FOR X=0 TO 127
  830 FOR Y=0 TO 7
  840 IF NOT POINT (X,Y) THEN GO TO 910
  850 PLOT 2*X,3*Y+80
  860 FOR a=0 TO 1
  870 PLOT 0,0:DRAW OVER 1;2*X,3*Y+79:NEXT a
  890 BEEP .01,7
  900 PLOT 2*X,3*Y+81
  910 NEXT Y:NEXT x:STOP 
 1000 BORDER 6:PAPER 7:CLS 
 1010 RESTORE 1000:FOR j=0 TO 15:READ a:POKE USR "\a"+j,a:NEXT j
 1020 LET s$="* * * * * *":REM spaces betweenasterisks
 1030 LET t$=" "+s$( TO 10)
 1040 PRINT PAPER 1; INK 7;s$'t$'s$'t$'s$'t$'s$'t$'s$
 1050 DIM b$(5)
 1060 FOR j=0 TO 16:READ a
 1070 FOR k=11*(j <=9) TO 26:PRINT PAPER 7*(j<16); INK 2; AT j,k; CHR$ a;:NEXT k:PRINT PAPER 6;b$
 1080 NEXT j:DIM b$(32)
 1090 FOR j=0 TO 4:PRINT PAPER 6;b$:NEXT j
 1100 STOP 
 1110 DATA 0,a,a,a,a,a,255,a,0,a,255,a,a,a,a,a
 1120 DATA 143,131,144,143,128,145,131,144,143,128,145,131,144,143,128,145,131
 1200 REM \{6}\{6}\{6}\{6}         Vicious Doggie\{6}\{6}
 1210 CLS :PRINT AT 5,4;"BEWARE! VICIOUS DOGGIE!!"
 1220 FOR Y=0 TO 27
 1230 PRINT AT 0,Y+ PI;"\ ."
 1240 PRINT AT 1,Y;"\ :\  \  \: \::"
 1250 PRINT AT 2,Y;"\::\::\::\::"
 1260 PRINT AT 3,Y;"\ :\  \  \: "
 1270 IF Y=27 THEN PAUSE 100:GO TO 1200
 1280 PRINT AT RND*14+7, RND*27;"ARF!"
 1290 FOR f=0 TO PI
 1300 PRINT AT f,y;"     ":NEXT f:NEXT y
 1400 REM \{6}\{6}\{6}\{6}     Digital Timer\{6}\{6}
 1420 CLS :PRINT AT 8, PI;"D I G I T A L  T I M E R"
 1430 PRINT AT 11,0;"Hours  Minutes  Seconds  Tenths"
 1440 PRINT AT 18,4;"Press the <A> key to stop.."
 1450 LET h=0
 1460 FOR m=0 TO 59
 1470 FOR s=0 TO 59
 1480 FOR t=0 TO 9
 1490 LET a$= INKEY$
 1500 IF a$="a" OR a$="A" THEN PRINT AT 21,0;"PRESS <\{18}\{1}CONTINUE\{18}\{0}>TO CONTINUE":STOP 
 1510 FOR d=1 TO 7:NEXT d
 1520 PRINT AT 12,2;h;"       ";m;"        ";s;"      .";t;" "
 1530 NEXT t:NEXT s:NEXT m
 1540 LET h=h+1
 1550 GO TO 1460
 2000 INPUT "1 for Spring"'"2 for Color Palette"'"3 for Paper & Ink"'"4 for Square Root"'"5 for Title Shoot"'"6 for a Flag"'"7 for Vicious Doggie"'"8 for Digital Timer"'x:IF x<1 OR x>8 THEN GO TO 2000
 2010 IF x=1 THEN RUN 20
 2020 IF x=2 THEN RUN 220
 2030 IF x=3 THEN RUN 420
 2040 IF x=4 THEN RUN 620
 2050 IF x=5 THEN RUN 800
 2060 IF x=6 THEN RUN 1000
 2070 IF x=7 THEN RUN 1200
 2080 RUN 1400
 3000 SAVE "B/I guide" LINE 1

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

Scroll to Top