10 SCREEN 128 20 Z1=TI 100 XC=160:YC=120 110 R=118:T1=R/16:X=R:Y=0 120 PSET XC+X,YC+Y,0 121 PSET XC+X,YC-Y,0 122 PSET XC-X,YC+Y,0 123 PSET XC-X,YC-Y,0 124 PSET XC+Y,YC+X,0 125 PSET XC+Y,YC-X,0 126 PSET XC-Y,YC+X,0 127 PSET XC-Y,YC-X,0 130 Y=Y+1 140 T1=T1+Y 150 T2=T1-X 160 IF T2 >= 0 THEN T1=T2:X=X-1 170 IF X>=Y THEN 120 200 PRINT TI-Z1The general idea here is that the algorithm draws one point per row, starting at the right side of the circle, going down. T1 and T2 are used to curve the point inward, toward the center column, as Y increases. Once the angle reaches 45 degrees, you can no longer draw an unbroken curve, so the algorithm ends. To draw the rest of the circle, you simply need to repeat the curve and mirror X, then Y, and then X and Y.
As far as I know, this is the fastest way to approximate a circle with single pixel accuracy. If you're willing to reduce the accuracy, you can actually get pretty fast with SIN/COS, but you need to use fewer than 46 segments (increment by Pi/23 radians) to match the Midpoint algorithm. At this point, you will se noticeable segmentation.
For the largest circle you can draw fully on screen, this takes 53 jiffies, or .88 seconds. This gets faster as the circle gets smaller. You can get similar performance out of a SIN/COS algorithm, if you draw an arc at 4° increments.
All times are for a circle drawn at (160,120) with a radius of 118 pixels:
Midpoint: 53 jiffies (0.88 seconds)
SIN/COS 360 cycles: 179 jiffies (2.45 seconds)
SIN/COS 4° steps: 91 jiffies (.77 seconds)
Finally, if you want to fill a circle, you can take advantage of the fact that the midpoint algorithm draws per-row:
10 SCREEN 128 20 Z1=TI 100 XC=160:YC=120 110 R=118:T1=R/16:X=R:Y=0 120 LINE XC+X,YC+Y,XC-X,YC+Y,0 122 LINE XC+Y,YC+X,XC-Y,YC+X,0 124 LINE XC+X,YC-Y,XC-X,YC-Y,0 126 LINE XC+Y,YC-X,XC-Y,YC-X,0 130 Y=Y+1 140 T1=T1+Y 150 T2=T1-X 160 IF T2 >= 0 THEN T1=T2:X=X-1 170 IF X>=Y THEN 120 200 PRINT TI-Z1Surprisingly, this only takes 48 jiffies. It's actually faster than just drawing the outside arc! This is because it uses fewer BASIC statements, and as we already know, BASIC's biggest bottleneck is in the parsing and dispatching of statements.