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

  1. Here is a part of the source i use when i want *fast* lines.
  2. It uses the blitter and writes directly to the DFF regs
  3. (no flames please, i *did* call Ownblitter first)
  4. There are som things left out, like where how to find the address of the 
  5. bitplane to draw in, and where the coordinates comes from, but that
  6. should be easy to fill in.
  7. /$DR.HEX$
  8.  
  9.  
  10. DMACONR=2
  11. BLTCON0=$40
  12. BLTCON1=$42
  13. BLTAMOD=$64
  14. BLTBMOD=$62
  15. BLTCMOD=$60
  16. BLTAPT=$50
  17. BLTCPT=$48
  18. BLTDPT=$54
  19. BLTADAT=$74
  20. BLTBDAT=$72
  21. BLTAFWM=$44
  22. BLTSIZE=$58
  23.  
  24. OwnBlitter=-456
  25. DisownBlitter=-462
  26.  
  27. width=80    ;80 bytes = 640 pixels
  28.  
  29.  
  30.  
  31. Draw_all_lines:
  32.     move.l    4.w,a6
  33.     move.l    (a6),a6
  34.     move.l    (a6),a6    ;get base of Gfxlib
  35.     jsr    OwnBlitter(a6)
  36.     
  37.     lea    $dff000,a6
  38.     move    #$8000,BLTADAT(a6)
  39.     move    #-1,BLTAFWM(a6)
  40.     move    #width,BLTCMOD(a6)
  41.     move    #$FFFF,BLTBDAT(a6)    ;$FFFF=draw , $0000=clear
  42. ;These values are the same for all lines, no need to tell
  43. ;the blitter about them more than once
  44.     
  45.     move.l    <startaddress of bitplane>,a0
  46.     moveq    #<numlines-1>,d7
  47.     bsr.s    drawem
  48.     move.l    4.w,a6
  49.     move.l    (a6),a6
  50.     move.l    (a6),a6
  51.     jmp    DisOwnBlitter(a6)
  52.     
  53.  
  54. drawem:    move    <X0>,d0
  55.     move    <Y0>,d1
  56.     move    <X1>,d2
  57.     move    <Y1>,d3
  58.     
  59.     moveq    #width,d4
  60.     mulu    d1,d4
  61. ;This could be sped up by reading a table with values
  62. ;0,width,width*2,width*3 etc.
  63.     moveq    #-16,d5
  64.     and    d0,d5
  65.     lsr    #3,d5
  66.     add    d5,d4
  67.     add.l    a0,d4
  68.     moveq    #0,d5
  69.     sub    d1,d3
  70.     roxl.b    #1,d5
  71.     tst    d3
  72.     bge.s    y2gy1
  73.     neg    d3
  74. y2gy1:    sub    d0,d2
  75.     roxl.b    #1,d5
  76.     tst    d2
  77.     bge.s    x2gx1
  78.     neg    d2
  79. x2gx1:    move    d3,d1
  80.     sub    d2,d1
  81.     bge.s    dygdx
  82.     exg    d2,d3
  83. dygdx:    roxl.b    #1,d5
  84.     move.b    table(pc,d5.w),d5
  85.     add    d2,d2
  86. wait:    btst    #6,DMACONR(a6)
  87.     bne.s    wait
  88.     move    d2,BLTBMOD(a6)
  89.     sub    d3,d2
  90.     bge.s    signn1
  91.     or.b    #$40,d5
  92. signn1:    move    d2,BLTAPT+2(a6)
  93.     sub    d3,d2
  94.     move    d2,BLTAMOD(a6)
  95.     and    #15,d0                    
  96.     ror    #4,d0
  97.     or    #$bca,d0
  98.     move    d0,BLTCON0(a6)
  99.     move    d5,BLTCON1(a6)
  100.     move.l    d4,BLTCPT(a6)
  101.     move.l    d4,BLTDPT(a6)
  102.     addq    #1,d3
  103.     lsl    #6,d3
  104.     addq    #2,d3
  105.     move    d3,BLTSIZE(a6)    ;GO!
  106.     dbra    d7,drawem    ;do next line
  107.     rts
  108.     
  109. table:    dc.b 1,17,9,21,5,25,13,29    
  110.  
  111.