home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / misc / imagefx_sdk / sas / scanlib / chunkizebm.asm < prev    next >
Encoding:
Assembly Source File  |  1994-08-01  |  2.8 KB  |  118 lines

  1. ;-------------------------------------------------------------------------
  2. ;
  3. ;  Functions to convert from bitplane format to chunky format
  4. ;
  5.  
  6.  
  7.                 SECTION chunkize,CODE
  8.  
  9.  
  10. ;-------------------------------------------------------------------------
  11. ;
  12. ;  Chunkizer (UBYTE **planes, UBYTE *output, int width, int depth)
  13. ;             a0              a1             d0         d1
  14. ;
  15. ;  Generic bitplane-to-chunky converter.  There must be 8 elements
  16. ;  in the planes array, and they will be modified by this function.
  17. ;  Output is where to store chunky data, width is the number of
  18. ;  pixels to convert, and depth is the number of bitplanes.
  19. ;
  20. ;  Assumes starting at leftmost edge of plane pointers.
  21.  
  22.  
  23.                 xdef    _Chunkizer
  24. _Chunkizer:
  25.                 movem.l    d2/d4-d6/a2-a4,-(sp)
  26.  
  27.         moveq    #7,d6            ; Init Bit offset.
  28.                 bra.s    7$
  29.  
  30.         ; Column loop.
  31. 1$        moveq    #0,d2            ; Init color to zero.
  32.         moveq    #1,d4            ; Init color mask.
  33.  
  34.         move.l    a0,a3            ; Point to planes.
  35.         move.w    d1,d5            ; Init plane counter.
  36.         bra.s    4$
  37.  
  38.         ; Plane loop.
  39. 2$        move.l    (a3)+,a4        ; Get plane pointer.
  40.         btst.b    d6,(a4)            ; Color plane set?
  41.         beq.s    3$            ; Nope - skip it.
  42.         add.w    d4,d2            ; Yes - add in color mask.
  43. 3$        add.w    d4,d4            ; Increment color mask.
  44. 4$        dbf    d5,2$
  45.  
  46.         ; Bump to next column.
  47.         subq.w    #1,d6            ; Next bit over.
  48.         bpl.s    5$
  49.         moveq    #7,d6            ; Byte change...
  50.         move.l    a0,a3
  51.                 move.w  d1,d5
  52.                 bra.s   42$
  53. 41$        addq.l    #1,(a3)+
  54. 42$             dbf     d5,41$
  55.  
  56. 5$        move.b  d2,(a1)+
  57.  
  58. 7$              dbf    d0,1$
  59.  
  60.         movem.l    (sp)+,d2/d4-d6/a2-a4
  61.         rts
  62.  
  63.  
  64.  
  65.  
  66.                 include 'exec/types.i'
  67.                 include 'graphics/gfx.i'
  68.  
  69.  
  70. ;-------------------------------------------------------------------------
  71. ;
  72. ;  ChunkizeBMRow (struct BitMap *bm, UBYTE *output, int width, int row)
  73. ;                 a0                 a1             d0         d1
  74. ;
  75. ;  Convert a scanline from a BitMap to chunky 8-bit per pixel format.
  76. ;  Calls Chunkize() above.
  77.  
  78.  
  79.                 xdef    _ChunkizeBMRow
  80. _ChunkizeBMRow:
  81.                 movem.l d2/a2-a4,-(sp)
  82.  
  83.                 move.l  a0,a2
  84.  
  85.                 clr.l   -(sp)
  86.                 clr.l   -(sp)
  87.                 clr.l   -(sp)
  88.                 clr.l   -(sp)
  89.                 clr.l   -(sp)
  90.                 clr.l   -(sp)
  91.                 clr.l   -(sp)
  92.                 clr.l   -(sp)
  93.                 move.l  sp,a0
  94.  
  95.                 mulu    bm_BytesPerRow(a2),d1
  96.  
  97.                 lea     bm_Planes(a2),a3
  98.                 move.l  a0,a4
  99.                 moveq   #0,d2
  100.                 move.b  bm_Depth(a2),d2
  101.                 bra.s   2$
  102. 1$              move.l  (a3)+,(a4)
  103.                 add.l   d1,(a4)+
  104. 2$              dbf     d2,1$
  105.  
  106.                 moveq   #0,d1
  107.                 move.b  bm_Depth(a2),d1
  108.  
  109.                 bsr.s   _Chunkizer
  110.  
  111.                 lea     32(sp),sp
  112.  
  113.                 movem.l (sp)+,d2/a2-a4
  114.                 rts
  115.  
  116.  
  117.         end
  118.