home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 514b.lha / line+fill / linedraweropt < prev   
Text File  |  1991-06-08  |  2KB  |  44 lines

  1. In article <1991Apr29.110534.10198@cs.umu.se> dvljrt@cs.umu.se (Joakim Rosqvist) writes:
  2. >Here is my inner loop:
  3. >    BSET  d7,(a0)     ;Plot pixel.  12 cycles
  4. >    ADD   d6,a0       ;Go to the next scanline. 8 cycles
  5. >    SUB   d3,d5       ;This routine always goes one pixel down and sometimes
  6. >              ;(every second time for 292 deg) one pixels right.
  7. >              ;d3 is MIN(dx,dy) that is dx in this case.  4 cycles
  8. >    BPL.S over        ;See if it is time to go right. 9 cycles
  9. >              ;(8 or 10 depending on wheter it branches)
  10. >    ADD   d4,d5       ;d4 is MAX(dx,dy)=dy in this case.  4/2=2 cycles
  11. >    SUBQ  #1,d7       ;One pixel right  4/2=2 cycles
  12. >    BPL.S over        ;If 0<d7<6 do next pixel 10/2=5 cycles
  13. >    MOVEQ #7,d7       ;restart from bit 7.  4/2/8=0.25 cycles
  14. >    ADDQ  #1,a0       ;go to next byte.  8/2/8=0.5 cycles
  15. >over:
  16.  
  17.     Another good optimization for CPU driven lines is to do further examination of
  18. the slope. For instance, suppose you are drawing a near vertical line.
  19.     If DX<DY/n, then there are at least n-1 vertical steps (I think I've got this
  20. right..I don't have the code here) between each horizontal step. So, you can do, say
  21. 2 vertical steps at a time with no check in between:
  22.  
  23.     BSET d7,(a0)
  24.     ADD d6,a0
  25.     BSET d7,(a0)
  26.     SUB    d3,d5            ; d3 contains twice the dx!
  27.     BPL.s    over
  28.  
  29.     The end conditions are a little hairy, but you can still win by doing this.
  30.  
  31.     For lines that are near horizontal or vertical, and are long, you win by
  32. doing a divide (at least on the 80xxx, you do), and using quick horizontal or vertical
  33. fills between each transition.
  34.  
  35.     -- 
  36. *-------------------------------------------*---------------------------*
  37. |Chris Green - Graphics Software Engineer   - chrisg@commodore.COM      f
  38. |                  Commodore-Amiga          - uunet!cbmvax!chrisg       n
  39. |My opinions are my own, and do not         - killyouridolssonicdeath   o
  40. |necessarily represent those of my employer.- itstheendoftheworld       r
  41. *-------------------------------------------*---------------------------d
  42.  
  43.  
  44.