Studies - The procedure for drawing a line.

ZX Review #7-8-9-10
(C) S. Medvedev, g.Uglich


   I would like to offer readers
"Revue," a procedure of drawing the line, the algorithm is 
slightly different from the algorithm procedure of "elementary 
graphs. 140.

; Draw subroutine
; At the entrance: BC - coordinates of the beginning; la line 
(B = Y, C = X) ; DE - coordinates of the end

; Line (D = Y, E = X)

DRAW EXX

          LD BC, # 1C14

          EXX

          LD A, B

          CP D

          JR NC, NO_EXX

          LD B, D

          LD D, A

          LD A, C

          LD C, E

          LD E, A
NO_EXX LD A, C

          SUB E

          JR NC, X_POSIT

          NEG

          EXX

          LD B, # 1D

          EXX
X_POSIT LD L, A
; Offset X

          LD A, B

          SUB D
; A - the Y offset

          CP L

          LD H, L

          LD B, L

          LD HX, B

          LD LX, A

          JR C, DONE

          EXX

          LD C, B

          LD B, # 14

          EXX

          LD H, A

          LD B, A

          LD HX, A

          LD A, L

          LD LX, A
DONE INC H

          INC LX

          EXX

          LD A, B

          LD (COMM), A

          LD A, C

          LD (COMM1), A

          EXX
NEXT PUSH HL

          PUSH DE

          PUSH BC

          CALL PLOT
; 'PLOT' - any procedure your mouth Novki point and the 
coordinates in the DE: ; D-Y, E-X. Recommend the procedure

; A. Astafieva.

          POP BC

          POP DE

          POP HL
COMM INC E; *

          LD A, HX

          SUB LX

          LD HX, A

          JR C, CARRY
COUNT DEC H

          JR NZ, NEXT

          RET
CARRY ADD A, B

          LD HX, A
COMM1 INC D; *

          JR COUNT2


    * - These commands can be
replaced by others, so here
You can simply write NOP.


   As can be seen, the program uses half Register IX, and
owners assemblers, not digesting "mnemonics LX / HX / LY /
HY, could write:
140.
 instead of LD LX, A - DEFB # DD

                    LD L, A

 instead of LD C, HX - DEFB # DD

                    LD C, H
 and t.d.2


   To clear conscience say
that the program was written "in
explanation "procedures from the demo" VIBRATIONS ".


           *