Try these

Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Demo

“Try these” is a collection of seven independent graphical and utility demonstrations, each separated by STOP statements and REM labels. The first routine defines a UDG character “t” as a vertical line (DATA 24,24,24,24,24,24,24,24) using POKE into USR “t”. The drawing demo (lines 60–220) uses symmetrical PLOT and DRAW calls with random starting positions and bouncing velocity increments to produce a kaleidoscopic line pattern. Other segments include a growing circle using the CIRCLE command, a software clock displaying hours, minutes, seconds, and tenths, a polar coordinate plotter that converts angle and radius inputs to pixel coordinates via COS and SIN, and a “mish mash” routine that draws a hollow 4×4 block-character rectangle at random screen positions with random BORDER and INVERSE settings.


Program Structure

The listing is organized as a collection of seven independent routines, each terminated by a STOP statement followed by a REM comment naming the next section. To run any individual demo, the user must either delete the preceding STOP or GO TO the appropriate line number. The SAVE at line 1000 uses LINE 10 so the program auto-runs from the UDG initialization section on load.

LinesSection
10–40UDG “t” initialization (vertical bar sprite)
60–220Bouncing symmetrical line art (“draw”)
240–300Flashing “X” with increasing PAUSE
320–340Misplaced UDG-U printer using TAB CODE INKEY$
360–390Growing circle
400–510Software clock (hours/minutes/seconds/tenths)
530–850Polar coordinate axis and ray plotter
870–990“Mish mash” random bordered rectangle display

UDG Initialization

Lines 1040 define UDG character “t” by poking eight bytes (all 24, binary 00011000) into USR "t" through USR "t"+7. This produces a solid two-pixel-wide vertical stripe centered in the 8×8 cell. The UDG is later referenced as █[UDG-U] in the misplaced-character demo at line 330, though note the listing uses UDG-U rather than UDG-t, suggesting either a typo or a separate UDG slot.

Bouncing Symmetrical Line Art (Lines 60–220)

This section generates a symmetrical pattern by issuing two PLOT calls and two DRAW calls per iteration with swapped x/y arguments, creating four-way reflective symmetry around the screen center. Random velocity components e and m are initialized each pass through the outer loop (which has no explicit outer loop — positions are simply re-randomized at line 60 and the whole pattern runs from GO TO 100, meaning e and m persist between iterations after the first).

  • Lines 160190 clamp x and y to [0, 42].
  • Lines 200210 reverse the velocity when a boundary is reached, creating a bouncing effect.
  • The DRAW targets 52-x, 42-y and 52-y, 42-x — these are relative, not absolute, so the symmetry is approximate rather than geometrically exact.

A subtle issue: lines 6090 re-randomize e, m, x, and y only on the very first execution (before GO TO 100). Since GO TO 100 skips back past lines 6090, the velocities and positions accumulate continuously — this is intentional, producing the bouncing trajectory.

Flashing “X” Demo (Lines 240–300)

A FOR loop from 1 to 100 prints “X” twice per iteration using alternating INK 0 (invisible) and default ink, with PAUSE a between each print. As a increases, the flash rate slows progressively, demonstrating a simple animation timing technique using the loop variable directly as the pause duration.

Misplaced Character Demo (Lines 320–340)

This section exploits TAB CODE INKEY$: the ASCII/character code of any pressed key is used as the TAB column position, so the UDG character is printed at a column determined by which key is held. Line 320 first executes POKE 23692,22 to suppress the “scroll?” prompt by resetting the line counter. The loop at line 340 uses GO TO 320, so the POKE is refreshed on every iteration. The conditional at line 330 prevents a print when no key is pressed.

Growing Circle (Lines 360–390)

A straightforward loop calling CIRCLE a,a,a for a from 0 to 88. Each iteration draws a circle whose center and radius all equal a, so the circles grow and shift diagonally across the screen simultaneously, producing a spiral-like accumulation of arcs.

Software Clock (Lines 400–510)

Four nested FOR loops simulate a clock: hours (0–24), minutes (0–59), seconds (0–59), and tenths (0–9). The display is updated each tenth-second tick via PRINT AT. Line 470 attempts to print a zero for tenths when t>9, but since the inner loop runs t from 0 to 9, t will equal 10 after NEXT t exits — this is correct BASIC behavior, so the zero-reset fires reliably. The “delay” loop at line 480 (FOR d=1 TO 7:NEXT d) is a minimal busy-wait intended to approximate a tenth of a second, though its actual duration depends on processor speed and display overhead. The label spells “MINITS” rather than “MINUTES” — a minor typo in the display string.

Polar Coordinate Plotter (Lines 530–850)

This is the most complex section, implementing an interactive polar-to-Cartesian ray plotter. The user inputs a starting coordinate (sx, sy), a radius r, and an angle theta in degrees. Line 740 converts theta to radians. The loop at lines 750800 steps from 0 to INT(r+.4), computing pixel coordinates with offsets (32, 22) to center the origin on screen.

  • Line 780 performs a bounds check: if y>175 or x>255, the input prompts are reset. Note the condition x>255 AND y>175 is redundant given the preceding OR clauses — it can never add new cases.
  • Lines 630 and 660 use INT(sx+.4) and INT(sy+.4) for rounding input to the nearest integer.
  • After plotting, lines 810820 update sx and sy to the endpoint of the last ray, allowing chained ray drawing from successive inputs.
  • The coordinate axis display at lines 530600 uses dots printed at each column and row to indicate the x and y axes, with labeled endpoints.

“Mish Mash” Demo (Lines 870–990)

This routine uses a DIM a$(4,4) string array to store a 4×4 hollow rectangle pattern made of block graphic characters. Each iteration picks a random screen position (s column 0–28, t row 0–16), sets a random BORDER color, and prints each row with random INVERSE (0 or 1). Pressing “a” triggers STOP. A counter d is incremented each cycle but never displayed — it may be a leftover debugging variable.

Notable Techniques and Anomalies

  • The use of STOP as a section delimiter rather than structuring demos as subroutines is unconventional but functional for a demo collection intended to be run in parts.
  • The rounding idiom INT(x+.4) consistently approximates “round to nearest integer” throughout the polar plotter, though the standard rounding threshold would be +.5 — using +.4 biases slightly toward the floor.
  • The flashing demo uses INK 0 to make text invisible rather than erasing it, which is a neat way to toggle visibility without clearing the screen position.
  • The clock’s tenths loop produces values 0–9 then exits with t=10; the check IF t>9 at line 470 correctly catches this to display a zero, but the printed value is hardcoded as 0 rather than t MOD 10, which happens to be correct only because t always exits at exactly 10.

Image Gallery

Source Code

   10 FOR u= USR "t" TO USR "t"+7
   20 READ t:POKE u,t
   30 NEXT u
   40 DATA 24,24,24,24,24,24,24,24
   50 STOP :REM draw
   60 LET e= RND*4-2
   70 LET m= RND*4-2
   80 LET x= RND*42
   90 LET y= RND*42
  100 PLOT x+10,y
  110 PLOT y+10,x
  120 DRAW 52-x,42-y
  130 DRAW 52-y,42-x
  140 LET y=y+m
  150 LET x=x+e
  160 IF x<0 THEN LET x=0
  170 IF y<0 THEN LET y=0
  180 IF x>42 THEN LET x=42
  190 IF y>42 THEN LET y=42
  200 IF x=0 OR x=42 THEN LET e=-e
  210 IF y=0 OR y=42 THEN LET m=-m
  220 GO TO 100
  230 STOP :REM flashing "x"
  240 FOR a=1 TO 100
  250 INK 0
  260 PRINT AT 10,15;"X"
  270 PAUSE a
  280 PRINT AT 10,15;"X"
  290 PAUSE a
  300 NEXT a
  310 STOP :REM misplaced *█U*
  320 POKE 23692,22
  330 IF INKEY$ <>"" THEN PRINT TAB CODE INKEY$;"█[UDG-U]"
  340 GO TO 320
  350 STOP :REM GROWING CIRCLE
  360 FOR a=0 TO 88
  370 CIRCLE a,a,a
  380 NEXT a
  390 STOP :REM TIMEX  WATCH
  400 FOR h=0 TO 24
  410 FOR m=0 TO 59
  420 FOR s=0 TO 59
  430 FOR t=0 TO 9
  440 PRINT AT 10,1;"HOURS  MINITS  SECONDS  TENTHS"
  450 PRINT AT 11,2;h;"      ";m;"        ";s;"       .";t
  460 NEXT t
  470 IF t>9 THEN PRINT AT 11,28;0
  480 FOR d=1 TO 7:NEXT d
  490 NEXT s
  500 NEXT m
  510 NEXT h
  520 STOP :REM COORDINATES AXIS
  530 FOR f=0 TO 31
  540 PRINT AT 10,f;"."
  550 NEXT f
  560 PRINT AT 11,0;-32; AT 11,30;31
  570 FOR f=0 TO 21
  580 PRINT AT f,16;"."
  590 NEXT f
  600 PRINT AT 0,17;21; AT 21,17;-22
  610 PRINT AT 0,0;"START:";
  620 INPUT sx
  630 LET sx= INT (sx+.4)
  640 PRINT "(";sx;",";
  650 INPUT sy
  660 LET sy= INT (sy+.4)
  670 PRINT sy;")  "
  680 PRINT AT 1,0;"R=";
  690 INPUT r
  700 PRINT r
  710 PRINT "THETA=";
  720 INPUT theta
  730 PRINT theta
  740 LET q=theta* PI/180
  750 FOR f=0 TO INT (r+.4)
  760 LET x=(f* COS q)+32+sx
  770 LET y=(f* SIN q)+22+sy
  780 IF y>175 OR x>255 OR x>255 AND y>175 THEN PRINT AT 1,0;"           "; AT 2,0;"           ":GO TO 680
  790 PLOT x,y
  800 NEXT f
  810 LET sx=x-32
  820 LET sy=y-22
  830 PRINT AT 0,7; INT (sx+.4);","; INT (sy+.4);")  "
  840 PRINT AT 1,0;"          "; AT 2,0;"           "
  850 GO TO 530
  860 STOP :REM MISH MASH
  870 LET d=0:DIM a$(4,4)
  880 LET a$(1)="████"
  890 LET a$(2)="█  █"
  900 LET a$(3)="█  █"
  910 LET a$(4)="████"
  920 LET s= INT (RND*29)
  930 LET t= INT (RND*17)
  940 FOR h=0 TO 3
  950 BORDER INT (RND*7):PRINT INVERSE INT (RND*2); AT t+h,s;a$(h+1)
  960 NEXT h
  970 IF INKEY$="a" THEN STOP 
  980 LET d=d+1
  990 GO TO 920
 1000 SAVE "Try these" LINE 10

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