Mike’s Notebook: LINES

Author(s): Michael DiRienzo
Publication: The Plotter
Pub Details: The Plotter v8 n12 (Volume 8, Issue 12)
Date: December 1990
Pages: 5-6

(NOTE: REPRINTING OR REPRODUCING THIS COLUMN WITHOUT THE EXPRESSED WRITTEN PERMISSION OF THE AUTHOR IS HEREBY PROHIBITED. FOR PERMISSION, WRITE THE AUTHOR IN CARE OF THIS PUBLICATION.)

Sinclair BASIC graphics commands PLOT and DRAW have several disadvantages and shortcomings. One of them is that they only address a 256 X 176 pixel screen and cannot draw to the bottom two character lines. Another is that the PLOT command requires absolute coordinate pairs but the DRAW command needs relative offset pairs. This requires a conversion somewhere in the program. This months utility will provide three graphics commands (PLOT, DRAW, and LINE) that will draw to the entire 256 by 192 pixel screen, and all x,y coordinate pairs required are the absolute type. The other change is that the coordinate 0, 0 is at the upper-left corner of the screen. The command syntax is as follows: PRINT USR plot;AT xs,ys PRINT USR draw;AT xe,ye PRINT USR line;AT xs,ys;xe,ye All “X” values are 0 to 255, and all “Y” values are 0 to 191. The variables xs=x start, ys=y start, xe=x end, and ye=y end. As usual, DRAW requires that it be preceeded by PLOT which establishes the starting x,y coordinate. Next, Draw sets the end coordinate pair and connects them with a line. The new command, LINE, requires two coordinate pairs. The first pair sets the x,y start of the line and the second pair sets the end x,y pair and connects them with a line. Study the included example program to see how to use them. Note that the syntax of the new commands is important in terms of commas and semicolons. If you make a syntax error with the new commands, you will get a “Nonsense in Basic” error message. Note that you may use attribute commands in the usual way because each command is called using, “PRINT USR…”. After the design is drawn and the border is plotted, press any key to draw another demo. Be sure to RUN the program from line 300 to POKE in the CODE. You can use RUN after that. The CODE is not relocatable and is 249 bytes long if you want to SAVE it as a separate CODE file. A portion of the plot and draw routines were obtained from the “Advanced 2068 Machine Code“, Volume 1, by Dr. Lloyd Dreger, and were enhanced a bit. I obtained this resource and others by Dr. Dreger from RMG ENTERPRISES. Have fun!

Happy TIMEXing…

“LINES”

By Michael J. Di Rienzo

  10 RANDOMIZE : BORDER 0: PAPER 0: INK 1+RND*6: CLS : OUT 254,1: LET plot=60987: LET line=60990: LET draw=60994
20 LET m=(RND*20)+30
30 FOR e=10 TO 60 STEP .5
40 LET r=e*88/m
50 LET t=PI*100*e/m
60 LET xe=128+1.2*r*COS t
70 LET ye=96+r*SIN t
80 IF ye<0 OR ye>191 OR xe<0 OR xe>255 THEN GO TO 120
90 IF e=10 THEN GO SUB 250
100 GO SUB 240
110 NEXT e
120 FOR n=2 TO 253 STEP 2: PRINT USR plot;n,2: PRINT USR plot;n,189: PRINT USR plot;2,n AND n<=189: PRINT USR plot;253,n AND n<=189: NEXT n
130 PRINT USR line;0,0;255,0: PRINT USR line;255,0;255,191: PRINT USR line;255,191;0,191: PRINT USR line;0,191;0,0
140 PAUSE 0: RUN
240 PRINT USR PLOT;xs,ys: PRINT USR DRAW;xe,ye
250 LET xs=xe: LET ys=ye
260 RETURN
300 CLEAR 60820: LET t=0
310 FOR n=60821 TO 61069
320 READ a: POKE n,a: LET t=t+a
330 NEXT n: IF t<>29525 THEN PRINT FLASH 1;"Data Error! Recheck DATA lines": STOP
340 RUN
350 DATA 125,230,192,31,55,31,15,173,230,248,173,87,124,7,7,7,173,230,199,173,7,7,95,213,122,15,15,15,230,3,246,88,87,237,75,143,92,26,169,160,169,18,209,124,230,7,71,4,62,254,15,16,253,71,58,145,92,79,26,203,65,32,1,160,203,81,32,2,168,47,18,201
360 DATA 1,0,1,0,197,205,149,237,193,17,1,1,120,148,48,4,21,21,237,68,71,121,149,48,4,29,29,237,68,79,176,200,121,184,229,98,107,34,221,237,46,0,56,4,101,107,72,71,34,223,237,96,120,203,63,111,125,129,56,3,184,56,8,144,111,237,91,221,237,24,5,111,237,91,223,237,227,124,130,103,125,131,111,197,205,149,237,193,227,37,32,220,225,201
370 DATA 175,24,6,62,1,24,2,62,2,50,176,92,17,117,33,225,167,237,82,32,250,213,58,176,92,254,2,32,9,237,75,125,92,97,104,195,113,238,205,125,238,97,104,58,176,92,254,1,40,4,205,149,237,201,229,205,125,238,120,65,79,225,205,225,237,201,223,254,59,194,237,27,205,220,27,205,96,38,237,67,125,92,201

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