Studies - A. Urzha. The procedure for drawing a circle.

ZX Review #3-4
            ETUDES



(C) Urzha Andrew
Cheboksary, 1996.

 The procedure for drawing a circle.


   I suggest you the procedure for drawing a circle (much 
faster than the standard CIRCLE). 

   In the register pair HL recorded coordinates of the center, 
and in case D - the radius of the circle. 140.


       ORG 50000

       LD HL, 87 * 256 127
And 87 - Y, 127 - X

       LD D, 50
; R

       LD C, 0

       LD B, D
LOOP CALL PLOT

       LD A, B

       NEG

       LD B, A

       CALL PLOT

       LD A, C

       NEG

       LD C, A

       CALL PLOT

       LD A, B

       NEG

       LD B, A

       CALL PLOT

       LD A, C

       LD C, B

       LD B, A

       CALL PLOT

       LD A, C

       NEG

       LD C, A

       CALL PLOT

       LD A, B

       NEG

       LD B, A

       CALL PLOT

       LD A, C

       NEG

       LD C, A

       CALL PLOT

       LD A, C

       LD C, B

       LD B, A

       INC C

       LD A, D

       SUB C

       LD D, A

       JR NC, LOOP

       DEC B

       LD A, D

       ADD A, B

       LD D, A

       LD A, B

       CP C

       JR NC, LOOP

       RET
PLOT PUSH DE

       PUSH BC

       PUSH HL

       LD A, H

       ADD A, B

       LD B, A

       LD A, L

       ADD A, C

       LD C, A

       CALL # 22E5

       POP HL

       POP BC

       POP DE

       RET
2

   The length of the procedure, 93 bytes.

   The idea is taken from the ZX-FORUM 3. Not
doubt that the procedure can be
much easier (especially the first part). Also there is a 
limitation - you can not specify the radius zero.


********************************