home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / talinasm.lha / quickbevel.asm < prev    next >
Encoding:
Assembly Source File  |  1992-03-14  |  4.5 KB  |  169 lines

  1. * ============================================================================ *
  2. *    QuickBevel: Draws a bevel box, given a rectangle and colors.
  3. *
  4. *            QuickBevel(rp, ibox, ulpen, lrpen);
  5. *                       a1  a0    d0     d1
  6. *
  7. *    This function uses PolyDraw to quickly render a bevel box. The horizontal
  8. *    thickness of the vertical lines (2) and the vertical thickness of the
  9. *    horizontal lines (1) has been hard-coded for speed.
  10. * ============================================================================ *
  11.  
  12.             include        "exec/types.i"
  13.             include        "intuition/intuition.i"
  14.             include        "macros.i"
  15.  
  16.             SECTION    quickbevel.asm,CODE
  17.  
  18.             far            data
  19.  
  20.             xdef        _QuickBevel,QuickBevel
  21.  
  22.             xref        _LVOSetAPen,_LVOMove,_LVOPolyDraw,_GfxBase
  23.  
  24. qregs        reg            d2-d7/a2/a6
  25.  
  26. _QuickBevel:
  27.             move.l        4(sp),a1                ; RastPort
  28.             move.l        8(sp),a0                ; IBox
  29.             move.l        12(sp),d0                ; upper left pen
  30.             move.l        16(sp),d1                ; lower left pen
  31. QuickBevel:
  32.             movem.l        qregs,-(sp)
  33.             move.l        a1,a2                    ; a2 <-- copy of rastport
  34.             move.l        d1,d2                    ; d2 <-- lrpen
  35.             move.l        _GfxBase,a6                ; a6 register
  36.  
  37.             moveq        #0,d4                    ; clear upper half of regs
  38.             moveq        #0,d5
  39.             moveq        #0,d6
  40.             moveq        #0,d7
  41.             movem.w        (a0),d4/d5/d6/d7        ; d4 <-- ibox_Left
  42.                                                 ; d5 <-- ibox_Top
  43.                                                 ; d6 <-- ibox_Width
  44.                                                 ; d7 <-- ibox_Height
  45.             add.w        d4,d6                    ; d6 <-- right
  46.             add.w        d5,d7                    ; d7 <-- bottom
  47.             subq.w        #1,d6                    ; d6 <-- left - 1
  48.             subq.w        #1,d7                    ; d7 <-- bottom - 1
  49.  
  50. ;---------- draw upper left part
  51.  
  52.             move.w        d5,-(sp)                ; coords[7] (y) = TOP
  53.             subq.w        #1,d6                    ; subtract 1 from RIGHT
  54.             move.w        d6,-(sp)                ; coords[6] (x) = RIGHT-1
  55.  
  56.             move.w        d5,-(sp)                ; coords[5] (y) = TOP
  57.             move.w        d4,-(sp)                ; coords[4] (x) = LEFT
  58.  
  59.             move.w        d7,-(sp)                ; coords[3] (y) = BOTTOM
  60.             move.w        d4,-(sp)                ; coords[2] (x) = LEFT
  61.  
  62.             subq.w        #1,d7                    ; subtract 1 from BOTTOM
  63.             move.w        d7,-(sp)                ; coords[1] (y) = BOTTOM -1
  64.             addq.w        #1,d4                    ; add 1 to LEFT
  65.             move.w        d4,-(sp)                ; coords[0] (x) = LEFT + 1
  66.  
  67. ;            move.l        d0,d0                    ; upper left pen color
  68.             move.l        a2,a1                    ; a1 <-- rp
  69.             jsr            _LVOSetAPen(a6)            ; set it
  70.  
  71.             move.l        d4,d0                    ; d0 <-- LEFT + 1
  72.             move.l        d5,d1                    ; d1 <-- TOP
  73.             addq.w        #1,d1                    ; d1 <-- TOP + 1
  74.             move.l        a2,a1                    ; a1 <-- rp
  75.             jsr            _LVOMove(a6)            ; Move to cursor coords
  76.  
  77.             moveq        #4,d0                    ; draw 4 points
  78.             move.l        sp,a0                    ; address of coords
  79.             move.l        a2,a1                    ; a1 <-- rp
  80.             jsr            _LVOPolyDraw(a6)        ; draw the line
  81.  
  82.             lea            16(sp),sp
  83.  
  84. ;---------- draw lower right part
  85.  
  86.             addq.w        #1,d7                    ; d7 <-- BOTTOM (fix from before)
  87.             addq.w        #1,d6                    ; d6 <-- RIGHT (fix from before)
  88.  
  89.             move.w        d7,-(sp)                ; coords[7] (y) = BOTTOM
  90.             move.w        d4,-(sp)                ; coords[6] (x) = LEFT + 1
  91.  
  92.             move.w        d7,-(sp)                ; coords[5] (y) = BOTTOM
  93.             move.w        d6,-(sp)                ; coords[4] (x) = RIGHT
  94.  
  95.             move.w        d5,-(sp)                ; coords[3] (y) = TOP
  96.             move.w        d6,-(sp)                ; coords[2] (x) = RIGHT
  97.  
  98.             addq.w        #1,d5                    ; add 1 to top
  99.             move.w        d5,-(sp)                ; coords[1] (y) = TOP + 1
  100.             subq.w        #1,d6                    ; subtract 1 from right
  101.             move.w        d6,-(sp)                ; coords[0] (x) = RIGHT - 1
  102.  
  103.             move.l        d2,d0                    ; lower right pen color
  104.             move.l        a2,a1                    ; a1 <-- rp
  105.             jsr            _LVOSetAPen(a6)            ; set it
  106.  
  107.             move.l        d6,d0                    ; d0 <-- RIGHT - 1
  108.             move.l        d7,d1                    ; d1 <-- BOTTOM
  109.             subq.w        #1,d1                    ; d1 <-- BOTTOM - 1
  110.             move.l        a2,a1                    ; a1 <-- rp
  111.             jsr            _LVOMove(a6)            ; Move to cursor coords
  112.  
  113.             moveq        #4,d0                    ; draw 4 points
  114.             move.l        sp,a0                    ; address of coords
  115.             move.l        a2,a1                    ; a1 <-- rp
  116.             jsr            _LVOPolyDraw(a6)        ; draw the line
  117.  
  118.             lea            16(sp),sp
  119.  
  120.             movem.l        (sp)+,qregs
  121.             rts
  122.  
  123.             end
  124.  
  125. /* original C code */
  126.  
  127. QuickBevel(
  128.     struct RastPort        *rp,                    /* rastport                        */
  129.     struct IBox            *b,                        /* box to render into            */
  130.     int                    ulpen,                    /* upper-left pen                */
  131.     int                    lrpen )                    /* lower-right pen                */
  132. {    WORD                coords[8];                /* coordinates to draw             */
  133.     int                    bottom,
  134.                         right;
  135.  
  136.     bottom = b->Top    + b->Height    - 1;
  137.     right =    b->Left    + b->Width - 1;
  138.  
  139.         /* upper left edges    */
  140.  
  141.     coords[0] = b->Left+1;
  142.     coords[1] = bottom-1;
  143.     coords[2] = b->Left;
  144.     coords[3] = bottom;
  145.     coords[4] = b->Left;
  146.     coords[5] = b->Top;
  147.     coords[6] = right-1;
  148.     coords[7] = b->Top;
  149.  
  150.     SetAPen( rp, ulpen );
  151.     Move( rp, b->Left+1, Top+1 );
  152.     PolyDraw(rp,4,coords);
  153.  
  154.         /* lower right edges    */
  155.  
  156.     coords[0] = right-1;
  157.     coords[1] = top + 1;
  158.     coords[2] = right;
  159.     coords[3] = b->Top;
  160.     coords[4] = right;
  161.     coords[5] = bottom;
  162.     coords[6] = b->Left + 1;
  163.     coords[7] = bottom;
  164.  
  165.     SetAPen( rp, lrpen );
  166.     Move( rp, right-1, bottom-1 );
  167.     PolyDraw(rp,4,coords);
  168. }
  169.