In article <1991Apr29.110534.10198@cs.umu.se> dvljrt@cs.umu.se (Joakim Rosqvist) writes:
>Here is my inner loop:
>    BSET  d7,(a0)     ;Plot pixel.  12 cycles
>    ADD   d6,a0       ;Go to the next scanline. 8 cycles
>    SUB   d3,d5       ;This routine always goes one pixel down and sometimes
>		      ;(every second time for 292 deg) one pixels right.
>		      ;d3 is MIN(dx,dy) that is dx in this case.  4 cycles
>    BPL.S over        ;See if it is time to go right. 9 cycles
>		      ;(8 or 10 depending on wheter it branches)
>    ADD   d4,d5       ;d4 is MAX(dx,dy)=dy in this case.  4/2=2 cycles
>    SUBQ  #1,d7       ;One pixel right  4/2=2 cycles
>    BPL.S over        ;If 0<d7<6 do next pixel 10/2=5 cycles
>    MOVEQ #7,d7       ;restart from bit 7.  4/2/8=0.25 cycles
>    ADDQ  #1,a0       ;go to next byte.  8/2/8=0.5 cycles
>over:

	Another good optimization for CPU driven lines is to do further examination of
the slope. For instance, suppose you are drawing a near vertical line.
	If DX<DY/n, then there are at least n-1 vertical steps (I think I've got this
right..I don't have the code here) between each horizontal step. So, you can do, say
2 vertical steps at a time with no check in between:

	BSET d7,(a0)
	ADD d6,a0
	BSET d7,(a0)
	SUB	d3,d5			; d3 contains twice the dx!
	BPL.s	over

	The end conditions are a little hairy, but you can still win by doing this.

	For lines that are near horizontal or vertical, and are long, you win by
doing a divide (at least on the 80xxx, you do), and using quick horizontal or vertical
fills between each transition.

	-- 
*-------------------------------------------*---------------------------*
|Chris Green - Graphics Software Engineer   - chrisg@commodore.COM      f
|                  Commodore-Amiga          - uunet!cbmvax!chrisg       n
|My opinions are my own, and do not         - killyouridolssonicdeath   o
|necessarily represent those of my employer.- itstheendoftheworld       r
*-------------------------------------------*---------------------------d


