home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / graph3d.sit / lineAsm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-28  |  2.2 KB  |  134 lines

  1. /*
  2.     Copyright '89    Christopher Moll
  3.     all rights reserved
  4. */
  5.  
  6.  
  7.  
  8. #include <ColorToolbox.h>
  9.  
  10. extern    Boolean            colorQD;
  11. extern    WindowPtr        graphWind;
  12. extern    Boolean        grphOnScrn;
  13.  
  14. static    int    top, left, scrnRowBytes;
  15. static    Point    *grphPnLoc;
  16.  
  17.  
  18. CheckGrphWind()
  19. {
  20.     int    bottom, right;
  21.     Boolean        ScrnHasColor();
  22.     Rect    *bBox;
  23.  
  24.     if (colorQD)
  25.     {
  26.         top = -(*(((CGrafPtr)graphWind)->portPixMap))->bounds.top;
  27.         left = -(*(((CGrafPtr)graphWind)->portPixMap))->bounds.left;
  28.         grphPnLoc = &(((CGrafPtr)graphWind)->pnLoc);
  29.     }
  30.     else
  31.     {
  32.         top = -graphWind->portBits.bounds.top;
  33.         left = -graphWind->portBits.bounds.left;
  34.         grphPnLoc = &(graphWind->pnLoc);
  35.     }
  36.     bBox = &((**(((WindowPeek)graphWind)->contRgn)).rgnBBox);
  37.     bottom = bBox->bottom;
  38.     right = bBox->right;
  39.  
  40.     grphOnScrn = ((bottom < screenBits.bounds.bottom)
  41.         && (right < screenBits.bounds.right))
  42.         && (left > 0);
  43.  
  44.     scrnRowBytes = screenBits.rowBytes;
  45. }
  46.  
  47. pascal void
  48. MLineTo(end)
  49. Point    end;
  50. {
  51.     Point    start;
  52.  
  53.     start = *grphPnLoc;
  54.     *grphPnLoc = end;
  55.     end.h += left;
  56.     end.v += top;
  57.     start.h += left;
  58.     start.v += top;
  59.     Aline(start.h, start.v, end.h, end.v);
  60. }
  61.  
  62. Aline()
  63. {
  64. asm{
  65.     link    a6,#0
  66.  
  67.     MOVEM.L D0-D7/A0-A1,-(A7)
  68.     MOVE.W    8(a6),d4
  69.     CLR.L    d5
  70.     MOVE.W    10(a6),d5
  71.     MOVE.W    12(a6),d6
  72.     MOVE.W    14(a6),d7
  73.     CMP.W   D6,D4
  74.     BLS.S   @lah_1
  75.     EXG     D6,D4
  76.     EXG     D7,D5
  77. lah_1:    MOVE    D6,D2
  78.     SUB     D4,D2
  79.     MOVE    D7,D3
  80.     SUB     D5,D3
  81.     MOVE    scrnRowBytes,D6
  82.     CMP.W   D7,D5
  83.     BLS.S   @lah_2
  84.     NEG     D6
  85.     NEG     D3
  86. lah_2:    MULS    scrnRowBytes,D5
  87.     MOVE.L  0x824,A0
  88.     ADDA.L  D5,A0
  89.     MOVE    D4,D0
  90.     LSR     #3,D0
  91.     ANDI    #0x7E,D0
  92.     ADDA.W  D0,A0
  93.     LSL     #1,D4
  94.     ANDI    #0x1E,D4
  95.     LEA     @masks,a1
  96.     ADD    d4,a1
  97.     MOVE    (a1),d0
  98.     CMP.W   D3,D2
  99.     BHI.S   @lah_6
  100.     MOVE    D3,D1
  101.     MOVE    D3,D7
  102. lah_3:    OR      D0,(A0)
  103.     SUB     D2,D1
  104.     BLS.S   @lah_5
  105. lah_4:    ADDA.W  D6,A0
  106.     DBF     D7,@lah_3
  107.     MOVEM.L (A7)+,D0-D7/A0
  108.     UNLK    A6
  109.     RTS     
  110. lah_5:    ADD     D3,D1
  111.     ROR     #1,D0
  112.     BCC     @lah_4
  113.     ADDQ.L  #2,A0
  114.     BRA     @lah_4
  115. lah_6:    MOVE    D2,D1
  116.     MOVE    D2,D7
  117. lah_7:    OR      D0,(A0)
  118.     SUB     D3,D1
  119.     BLS.S   @lah_10
  120. lah_8:    ROR     #1,D0
  121.     BCC.S   @lah_9
  122.     ADDQ.L  #2,A0
  123. lah_9:    DBF     D7,@lah_7
  124.     MOVEM.L (A7)+,D0-D7/A0
  125.     UNLK    A6
  126.     RTS     
  127. lah_10:    ADD     D2,D1
  128.     ADDA.W  D6,A0
  129.     BRA     @lah_8
  130.  
  131. masks:    DC.W    0x8000,0x4000,0x2000,0x1000,0x800,0x400,0x200,0x100
  132.     DC.W    0x80,0x40,0x20,0x10,8,4,2,1
  133. }
  134. }