home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Programming / powerd / lib / chunky.lha / chunky_ppc / CopyChunkyMask.ass < prev    next >
Encoding:
Text File  |  1980-04-15  |  1.4 KB  |  73 lines

  1. # copies chunky data from source to destination with clipping, leaves colour 0
  2.  
  3. # CopyChunkyMask(dst:r3:PTR TO chunky,dx:r4:LONG,dy:r5:LONG,
  4. #            src:r6:PTR TO chunky,sx:r7:LONG,sy:r8:LONG,
  5. #            w:r9:LONG,h:r10:LONG)
  6.  
  7.     .text
  8.     .global    _CopyChunkyMask
  9. _CopyChunkyMask:
  10.     mr.    r11,r4    # clip left
  11.     blt    .ok1
  12.     li    r4,0
  13.     sub    r7,r7,r11
  14. .ok1:
  15.     mr.    r11,r5    # clip top
  16.     blt    .ok2
  17.     li    r5,0
  18.     sub    r8,r8,r11
  19. .ok2:
  20.     lwz    r0,0(r3)    # clip right
  21.     sub.    r11,r0,r4
  22.     blt    .finish        # whole source is behind right side of the dest
  23.     add.    r11,r4,r9
  24.     blt    .finish        # whole source is behind left side of the dest
  25.     sub.    r11,r0,r11
  26.     bgt    .ok3
  27.     add    r9,r9,r11
  28. .ok3:
  29.     lwz    r0,4(r3)    # clip bottom
  30.     sub.    r11,r0,r5
  31.     blt    .finish        # whole source is below the dest
  32.     add.    r11,r5,r10
  33.     blt    .finish        # whole source is above the dest
  34.     sub.    r11,r0,r11
  35.     bgt    .ok4
  36.     add    r10,r10,r11
  37. .ok4:
  38.     lwz    r0,0(r3)
  39.     mullw    r5,r5,r0
  40.     add    r5,r5,r4    # offset of the first pixel in the dest
  41.     lwz    r3,8(r3)
  42.     add    r3,r3,r5    # jump to the offset
  43.     sub    r4,r0,r9    # rest width of the dest
  44.  
  45.     lwz    r0,0(r6)
  46.     mullw    r8,r8,r0
  47.     add    r8,r8,r7    # offset of the first pixel in the source
  48.     lwz    r6,8(r6)
  49.     add    r6,r6,r8    # jump to the offset
  50.     sub    r7,r0,r10    # rest width of the source
  51.  
  52.     mr    r11,r9    # store width
  53. .loopy:
  54.     mr    r9,r11    # restore width
  55.     subi    r3,r3,1
  56.     subi    r6,r6,1
  57. .loopx:
  58.     lbzu    r0,1(r6)
  59.     mr.    r0,r0
  60.     beq    .skip    # skip colour 0
  61.     stbu    r0,1(r3)
  62. .skip:
  63.     subic.    r9,r9,1
  64.     bgt    .loopx
  65.  
  66.     add    r3,r3,r4    # add the rest
  67.     add    r6,r6,r7
  68.  
  69.     subic.    r10,r10,1
  70.     bgt    .loopy
  71.  
  72. .finish:    blr
  73.