[address omitted]
May 6, 1990
Dear George,
Well, it’s May, so it must be time for me to write again. Not quite; I haven’t gotten my May Sinc-Link yet. But I did recieve my May issue of Byte recently, and it had something I thought was so interesting I just had to try it.
Have you ever noticed just how bad the CIRCLE command is on our computers? It is very slow, and especially for small circles it isn’t even accurate. In this month’s Byte they had an article on graphics for the IBM, and included a listing in the Pascal language of an efficient circle routine. I decided I just had to convert it to our machine code and try it out.
Actually, I made a few changes to try and optimize it for ml, so it isn’t strictly the same as the original. I also threw in error checking. And to save a few POKEs, I made it use the current PLOT position as its center. Setting the radius still requires a POKE, but that didn’t seem too bad.
As you might expect, I did have the computer test the accuracy of this routine. As near as practical, it is totally accurate. That is to say, it rounds off the same way as a BASIC program using SQR to compute values would. That means, it draws a circle of radius 1 as a small square, but those are the limits of the display.
And the routine is fast. Since it doesn’t actually use any SQR or SIN and COS, it doesn’t use the ml calculator routines at all. And it will draw a large circle, as large as the screen will hold, so fast I can’t see it working. It just appears on the screen.
I can see that this might be useful for people who want to work in graphics with their programs. It is only good for circles, of course, but it is fast enough to do a reasonable immitation of a bouncing ball, for example.
I set up the routine to leave the PLOT position unchanged. So for instance, if you wanted to draw several circles with the same center, all you have to do is POKE the new radius and call the routine. To set colours, you will have to use the standard commands, and then change them back when you are done.
I am not about to try and explain how it works, if you want to know, pick up the May, 1990 BYTE magazine and read page 282.
That is it for now. I may have something else in a couple of weeks, after I get this month’s Sinc-Link. But until then, take care.
Oh, I had time to work on it because college is over already. I should still be here for the foreseeable future, though. Bye for now.
Sincerely,
Steven V. Gunhouse
1 REM Hex Loader for Circle
2 REM with demo
5 CLS : PRINT AT 10,5;"Reading Circle CODE"
6 LET A=10: LET B=11: LET C=12: LET D=13: LET E=14: LET F=15
7 LET x=23300
8 READ a$: IF a$="End" THEN GOTO 10
9 FOR i=1 TO LEN a$ STEP 3: POKE x,16*VAL a$(i)+VAL a$(i+1): LET x=x+1: NEXT i: GOTO 8
10 CLS : PRINT "Demo using CIRCLE Command:"
11 FOR i=3 TO 87 STEP 3: CIRCLE 128,88,i: NEXT i
12 PAUSE 30
15 CLS : PRINT "Now using the Circle ml:"
16 FOR i=3 TO 87 STEP 3: PLOT INVERSE 1;128,88: POKE 23299,i: RANDOMIZE USR 23300: NEXT i
20 STOP
1000 DATA "2A 7D 5C 4D 3A 03 5B 57"
1001 DATA "7D BA 38 60 82 38 5D 7C"
1002 DATA "BA 38 59 82 38 56 FE B0"
1003 DATA "30 52 47 7A 1E 00 CB 22"
1004 DATA "F5 C5 E5 D5 C5 CD 3E 26"
1005 DATA "C1 D1 78 92 B8 28 08 47"
1006 DATA "D5 C5 CD 3E 26 C1 D1 79"
1007 DATA "93 B9 28 13 4F D5 C5 CD"
1008 DATA "3E 26 C1 D1 78 82 B8 28"
1009 DATA "06 47 D5 CD 3E 26 D1 E1"
1010 DATA "C1 F1 1C BB 28 02 30 04"
1011 DATA "05 15 82 15 BB 28 06 38"
1012 DATA "04 0C 93 1C 1C 1D F5 78"
1013 DATA "BC 30 B6 F1 22 7D 5C C9"
1014 DATA "End"
For the Bouncing Ball demo, copy the previous program except lines 10 to 16 (or type DELETE 10,16) and enter:
2 REM with bouncing ball demo
10 CLS : BORDER 6
11 LET r=10: LET x=r: LET y=r: LET d=2: LET e=17
12 OVER 1: POKE 23299,r
13 PLOT INVERSE 1;x,y: RANDOMIZE USR 23300
14 IF x+d<r THEN LET d=ABS d
15 IF x+d+r>255 THEN LET d=-d
16 IF y+e<r THEN LET e=ABS e: GOTO 18
17 LET e=e-1
18 LET x=x+d: LET y=y+e: RANDOMIZE USR 23300: PLOT INVERSE 1;x,y: RANDOMIZE USR 23300
19 GOTO 14
Media
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.