home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / talinasm.lha / imagebox.asm < prev    next >
Encoding:
Assembly Source File  |  1991-10-21  |  1.4 KB  |  60 lines

  1. * ============================================================================ *
  2. *    SetupImageIBox: figures the real hit box for a gadget
  3. *
  4. *            SetupImageIBox(box,image,imp_draw)
  5. *                           a0  a1    a2
  6. *
  7. *    This function computes the hit box for an image class, taking the IMP_DRAWFRAME
  8. *    message into account for sieable boxes.
  9. * ============================================================================ *
  10.  
  11.             include        "exec/types.i"
  12.             include        "intuition/intuition.i"
  13.             include        "intuition/imageclass.i"
  14.             include        "macros.i"
  15.  
  16.             SECTION        gadgetbox.asm,CODE
  17.  
  18.             xdef        _SetupImageIBox,SetupImageIBox
  19.  
  20. qregs        reg            d2-d7/a6
  21.  
  22. _SetupImageIBox:
  23.             move.l        a2,-(sp)
  24.             movem.l        8(sp),a0-a2
  25.             bsr            SetupImageIBox
  26.             move.l        (sp)+,a2
  27.             rts
  28.  
  29. SetupImageIBox:
  30.             move.l        ig_LeftEdge(a1),ibox_Left(a0)
  31.             move.l        ig_Width(a1),ibox_Width(a0)
  32.  
  33.             move.w        impd_OffsetX(a2),d1
  34.             add.w        d1,ibox_Left(a0)
  35.             move.w        impd_OffsetY(a2),d1
  36.             add.w        d1,ibox_Top(a0)
  37.  
  38.             cmp.l        #IM_DRAWFRAME,(a2)
  39.             blt.s        1$
  40.             move.w        impd_DimensionsWidth(a2),ibox_Width(a0)
  41.             move.w        impd_DimensionsHeight(a2),ibox_Height(a0)
  42.  
  43. 1$            rts
  44.  
  45.             end
  46.  
  47.     /* original C source */
  48.  
  49. getbox(struct IBox *box, struct Image *img, struct impDraw *msg)
  50. {    *box = *IM_BOX( IM(img) );            /* get Image.Left/Top/Width/Height */
  51.  
  52.     box->Left += msg->imp_Offset.X;
  53.     box->Top  += msg->imp_Offset.Y;
  54.  
  55.     if ( msg->MethodID == IM_DRAWFRAME )
  56.     {    box->Width =    msg->imp_Dimensions.Width;
  57.         box->Height = msg->imp_Dimensions.Height;
  58.     }
  59. }
  60.