--- title: "2068 Graphics and Trig" id: 55580 type: "computer_media" slug: "2068-graphics-and-trig" url: "http://localhost/computer_media/2068-graphics-and-trig/" markdown_url: "http://localhost/computer_media/2068-graphics-and-trig.md" published_at: "2024-06-28T02:24:28+00:00" modified_at: "2026-03-30T21:40:49+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/06/SCR-20240627-tigs.png" excerpt: "An interactive trigonometry explorer draws labeled quadrant diagrams, parametric curves, and Lissajous figures using user-supplied SIN and COS multipliers with custom UDG graphics." 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: "Andy Centek (WB8AHX)" slug: "andy-centek" taxonomy: "indiv" url: "http://localhost/indiv/andy-centek/" genre: - name: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" - name: "Graphics" slug: "graphics" taxonomy: "genre" url: "http://localhost/type/graphics/" - name: "Mathematics" slug: "mathematics" taxonomy: "genre" url: "http://localhost/type/mathematics/" 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: "Andy Centek (WB8AHX)" slug: "andy-centek" taxonomy: "indiv" url: "http://localhost/indiv/andy-centek/" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/06/SCR-20240627-tigs.png" - url: "http://localhost/wp-content/uploads/2024/06/SCR-20240627-tiwa.png" article_media: - id: 16069 title: "Basic Graphics on the 2068" type: "article" url: "http://localhost/article/basic-graphics-on-the-2068/" media_type_tags: "Demo, Graphics, Mathematics" --- This program demonstrates trigonometric functions through interactive graphics, drawing coordinate-plane diagrams that illustrate how SIN, COS, and TAN relate to the four quadrants. It offers a three-option menu: a labeled static quadrant diagram with a drawn unit-circle illustration and BEEP tones, a sample animated parametric plot cycling SIN and COS with user-supplied multipliers, and a Lissajous-style figure generator where the user divides PI by custom degree values for each axis. A custom UDG character “a” is defined at startup via POKEd DATA bytes (0,0,0,255,0,0,0,0), producing a single horizontal midline bar used as a visual separator in the trig-sign labels. The subroutine at line 200 generates an animated star-scatter loading screen using RND-positioned asterisks with descending BEEP tones before drawing a parametric spiral pattern. *** ## Program Analysis ### Program Structure The program is organized into several distinct blocks connected by a central menu at line 20. Execution begins at line 8, initializes the display, calls a UDG setup subroutine at line 1000, then calls an animated intro at line 200 before entering the menu loop. | Lines | Role | | --- | --- | | 4–8 | REMs and initialization (PAPER, INK, CLS, GO SUB) | | 10 | GO SUB 1000 — UDG definition | | 14–16 | Title display and first keypress pause | | 20–39 | Main menu (options 1–3, input validation) | | 40–100 | Option 1 — static labeled quadrant/trig diagram with circle and BEEP | | 200–270 | Animated intro subroutine (star scatter + parametric spiral) | | 300–370 | Option 2 subroutine — animated parametric ellipse plot (30×SIN, 20×COS) | | 400–459 | Option 3 entry — user-multiplier parametric plot | | 460–496 | Axis-drawing sub-block for option 3 | | 500–560 | PI-divided-by-degrees Lissajous generator | | 600–660 | Full-parameter Lissajous with user SIN/COS values, step, and PI divisors | | 1000–1015 | UDG “a” definition via READ/POKE/DATA | | 9998–9999 | STOP and SAVE | ### UDG Definition The subroutine at line 1000 defines UDG character `"a"` (char 144) by POKEing 8 bytes read from a DATA statement at line 1010. The data `0,0,0,255,0,0,0,0` produces a single solid horizontal line through the vertical midpoint of the 8×8 cell. This UDG is used repeatedly in lines 57–60 as `\a\a\a\a` — four consecutive UDGs forming a short horizontal rule separating the sign labels for SIN, COS, and TAN in each quadrant. ### Parametric and Lissajous Plotting The core graphical technique throughout is parametric plotting: a loop variable `a` drives both X and Y via SIN and COS, producing ellipses or Lissajous figures depending on the PI divisors chosen. Three distinct plotting modes are present: - **Lines 340–360 (subroutine 300):** Fixed multipliers — `x=30*SIN(a*PI/180)`, `y=20*COS(a*PI/180)` — plotting and drawing from each computed point back to itself, which traces an ellipse. - **Lines 410–455 (option 3):** User-supplied multipliers `s` and `c` for SIN and COS respectively, ranging from 1–35 and 1–30. - **Lines 500–545 and 600–635:** User-supplied PI divisors `d1` and `d2` for SIN and COS independently, enabling true Lissajous figures when the ratio `d1/d2` is non-unity. The loop runs to 720 (two full cycles) to ensure figure closure. ### Bug: Coordinate Multiplication Instead of Addition (Line 535) Line 535 contains a significant bug: `PLOT 128+x,88*y`. The Y coordinate uses multiplication (`88*y`) instead of addition (`88+y`), as used consistently in every other plotting line (e.g., lines 355, 435, 630). When `y` is near 1, the plot Y coordinate will be approximately 88, which coincidentally appears correct; however, for any other value of `y` the plotted point will be wildly wrong or out of range, causing an error or invisible plot. ### Bug: Shadowed Loop Variable in Lines 615–635 Lines 615 and 619 both use `FOR a=...`. The outer loop at line 615 (`FOR a=0 TO 360 STEP 3`) is immediately superseded by the inner loop at line 619 (`FOR a=0 TO 720 STEP s1`), since they share the same variable `a`. The outer loop body never meaningfully iterates — only the axis-drawing at line 617 executes once per outer iteration before the inner loop completes and `NEXT a` at line 635 terminates the inner loop. The outer `NEXT a` is never reached, so the outer loop silently runs once and falls through. This is almost certainly unintended. ### Navigation and Flow Control Menu option 3 at line 36 uses `GO TO 399`, which does not exist as a line number. In Sinclair BASIC, a `GO TO` targeting a non-existent line transfers control to the next line numerically above the target — in this case line 400, the start of the main parametric program. This is a deliberate memory-saving idiom rather than an error. After the Lissajous section at line 560, there is no explicit `GO TO` or `RETURN` — execution falls through directly into the plot-over-functions block starting at line 600. This means completing the PI-by-degrees section always leads into the more detailed Lissajous entry rather than returning to the menu, unless the user chooses option “a” (repeat) at line 555. ### Intro Animation (Lines 200–270) The subroutine at line 200 uses a `FOR x=15 TO 0 STEP -1` loop to scatter asterisks at random screen positions using `INT(RND*2-x)` for the row and `INT(RND*x+x)` for the column, accompanied by descending BEEP pitches. It then executes a double-nested loop (lines 208–245) computing `r=2-(a*SIN(n/3*PI))` and `c=10-(a*COS(n/6*PI))`, drawing from a fixed origin at (120,90) to produce a radiating spiral/fan pattern across 13 angular phases (`n=0 TO 12`). ### Key BASIC Idioms - `OVER 1` in line 61 (and 330, 485) is used inline within a `PRINT AT` statement to toggle XOR pixel mode for the axis labels, allowing them to overlap the drawn axes without fully overwriting the graphics. - `PAUSE 0` at lines 16, 365, and 402 halts execution until a key is pressed. - Degree-to-radian conversion is done explicitly as `a*PI/180` throughout, since the BASIC trigonometric functions take radians. - Input validation loops (e.g., lines 30, 457, 555, 645) re-prompt by `GO TO`-ing back to the `INPUT` line when the response is out of range. ## Source Code ``` 4 REM 2068 graphics and trig 5 REM by 6 REM Andy Centek Garden City, MI 8 PAPER 0: INK 7: CLS : GO SUB 200 10 GO SUB 1000 14 PRINT AT 2,5;"Trig. affects on graphics." 15 PRINT "Showing plots of trig functions in relation to quadrants." 16 PAUSE 0: CLS 20 CLS : PRINT TAB 14;"MENU" 22 PRINT ''"1-Graph with trig functions"'" labeled on graph." 24 PRINT ''"2-Sample program" 26 PRINT ''"3-Run a program" 28 INPUT n 30 IF n<>1 AND n<>2 AND n<>3 THEN GO TO 28 32 IF n=1 THEN GO TO 40 34 IF n=2 THEN GO SUB 300 36 GO TO 399 39 STOP 40 CLS 44 PLOT 0,88: DRAW 255,0 45 PLOT 128,0: DRAW 0,166 50 PRINT AT 0,12;"Quadrants" 55 PRINT AT 0,6;"II";AT 0,23;"I";AT 21,6;"III";AT 21,23;"IV" 57 PRINT AT 2,5;"+SIN ";AT 3,5;"\a\a\a\a";AT 4,5;"-COS ";AT 3,10;"=-TAN " 58 PAUSE 10: PRINT AT 2,20;"+SIN ";AT 3,20;"\a\a\a\a";AT 3,25;"=+TAN ";AT 4,20;"+COS " 59 PAUSE 10: PRINT AT 17,5;"-SIN ";AT 18,5;"\a\a\a\a";AT 18,10;"=+TAN ";AT 19,5;"-COS " 60 PAUSE 10: PRINT AT 17,20;"-SIN ";AT 18,20;"\a\a\a\a";AT 18,25;"=-TAN ";AT 19,20;"-COS " 61 PRINT AT 21,15;"-Y";AT 1,15;"+Y";AT 10,0; OVER 1;"-X";AT 10,30; OVER 1;"+X" 64 PLOT 128,88: DRAW 40,35: PLOT 128,88: DRAW 30,0: DRAW 0,27 65 PRINT AT 7,20;"S";AT 8,20;"i";AT 9,20;"n" 66 PLOT 128,88: DRAW 42,0: DRAW 0,38 67 PRINT AT 6,22;"T";AT 7,22;"a";AT 8,22;"n" 68 PRINT AT 11,17;"Cos" 69 CIRCLE 128,88,40 70 FOR a=-40 TO 40 STEP 1.25: BEEP .01,-a: BEEP .01,+a: NEXT a 97 INPUT "Enter >>m<< ( ret to menu)";a$ 98 IF a$<>"m" THEN GO TO 97 100 GO TO 20 199 STOP 202 PRINT AT 0,4;"Coming up---GRAPHICS " 204 PRINT INVERSE 1;AT 19,0;"I AM COMPUTING--PLEASE WAIT!!" 205 FOR x=15 TO 0 STEP -1: BEEP .01,x: PRINT AT INT (RND*2-x),INT (RND*x+x);"*": NEXT x 206 BRIGHT 1: PAPER 1: INK 7: BORDER 0 208 FOR n=0 TO 12 210 FOR a=0 TO 65 STEP 3 225 LET r=2-(a*SIN (n/3*PI)) 230 LET c=10-(a*COS (n/6*PI)) 235 PLOT 120,90: DRAW c,r 240 NEXT a 245 NEXT n 250 PRINT INVERSE 1;AT 19,0;" ANDY CENTEK, JR. " 260 PRINT AT 1,5;"*";AT 5,3;"*";AT 10,25;"*";AT 20,7;"*" 270 PAUSE 300: CLS : RETURN 300 REM ** DRAW graph ** 305 CLS 310 PLOT 0,88: DRAW 255,0: PLOT 128,0: DRAW 0,166 320 PRINT AT 0,12;"Quadrants" 325 PRINT AT 0,6;"II";AT 0,23;"I";AT 21,6;"III";AT 21,23;"IV" 330 PRINT AT 21,15;"-Y";AT 1,15;"+Y";AT 10,0; OVER 1;"-X";AT 10,30; OVER 1;"+X" 335 PAUSE 100 340 FOR a=0 TO 360 STEP 3 345 LET x=30*SIN (a*PI/180) 350 LET y=20*COS (a*PI/180) 352 PRINT AT 18,5;"X=";INT (x);AT 19,5;"Y=";INT (y) 355 PLOT 128+x,88+y: DRAW x,y 356 PRINT AT 17,20;"A=0 to 360";AT 18,19;"X=20 x SIN A";AT 19,19;"Y=30 x COS A" 357 PAUSE 20: PRINT AT 18,5;"X= ";AT 19,5;"Y= "; 360 NEXT a 365 INPUT "return to menu";a$: PAUSE 0 370 GO TO 20 398 STOP 400 REM ** main program ** 401 CLS : PRINT BRIGHT 1;'"Showing the effects of the"'"multipliers of the SIN and COS." 402 PAUSE 0: INPUT "ENTER multipliers, ONE number for the SIN (1 - 35) and ONE forthe COS. (1 - 30)";s,c 404 PAPER 1: INK 7: BORDER 5 405 CLS 406 GO TO 460 410 FOR a=0 TO 360 STEP 3 420 LET y=c*COS (a*PI/180) 430 LET x=s*SIN (a*PI/180) 435 PLOT 128+x,88+y: DRAW x,y 455 NEXT a 456 INPUT "Another or a new program (a or n)?";q$ 457 IF q$<>"a" AND q$<>"n" THEN GO TO 456 458 IF q$="a" THEN CLS : GO TO 400 459 GO TO 500 460 REM ** draw graph** 461 CLS 465 PLOT 0,88: DRAW 255,0: PLOT 128,0: DRAW 0,166 475 PRINT AT 0,12;"Quadrants" 480 PRINT AT 0,6;"II";AT 0,23;"I";AT 21,6;"III";AT 21,23;"IV" 485 PRINT AT 21,15;"-Y";AT 1,15;"+Y";AT 10,0; OVER 1;"-X";AT 10,30; OVER 1;"+X" 492 PRINT AT 18,2;s;" x SIN";AT 19,2;c;" x COS"; 496 GO TO 410 500 REM ** dividing PI by degrees ** 505 CLS 507 PRINT '''"Dividing PI by degrees(0 to 360)";"Input degrees for..."; 508 INPUT "SIN ";d1: INPUT ;"COS ";d2 509 CLS : PLOT 0,88: DRAW 255,0: PLOT 128,0: DRAW 0,166 510 FOR a=0 TO 720 STEP 2.5 515 PRINT AT 21,0;"PI/";d1;" SIN - PI/";d2;" COS" 525 LET y=25*COS (a*PI/d2) 530 LET x=35*SIN (a*PI/d1) 535 PLOT 128+x,88*y: DRAW x,y 545 NEXT a 550 INPUT "Another or next program(a/n)?";q$ 555 IF q$<>"a" AND q$<>"n" THEN GO TO 550 560 IF q$="a" THEN GO TO 500 600 CLS 605 REM ** plot over functions ** 610 PRINT '"Values for SIN and COS."'" Max. SIN Val. = 120"'" Max. COS Val. =80" 611 PRINT '"Dividing PI by degrees (0-360)" 612 INPUT "SIN";s: INPUT "COS";c: INPUT "STEP ";s1: INPUT "SIN PI / degrees";d1: INPUT "COS PI / degrees";d2 613 IF s>120 OR c>80 THEN CLS : PRINT AT 11,13;"TOO BIG !!": GO TO 610 614 CLS : PRINT AT 19,1;s;" x SIN PI/";d1;AT 20,1;c;" x COS PI/";d2; 615 FOR a=0 TO 360 STEP 3 617 PLOT 0,88: DRAW 255,0: PLOT 128,0: DRAW 0,166 619 FOR a=0 TO 720 STEP s1 620 LET y=c*COS (a*PI/d2) 625 LET x=s*SIN (a*PI/d1) 630 PLOT 128+(x/2),88+(y/2): DRAW x/2,y/2 635 NEXT a 640 INPUT "Another or back to menu ?(a/b) ";q$ 645 IF q$<>"a" AND q$<>"b" THEN GO TO 640 646 IF q$="a" THEN GO TO 612 660 GO TO 20 1000 REM get line USR a 1002 FOR n=0 TO 7 1004 READ a: POKE USR "a"+n,a 1006 NEXT n 1010 DATA 0,0,0,255,0,0,0,0 1015 RETURN 9998 STOP 9999 SAVE "GrafTrig" LINE 1 ```