home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / talinasm.lha / writergb.asm < prev    next >
Encoding:
Assembly Source File  |  1992-02-08  |  3.5 KB  |  125 lines

  1. ;WritePlanarRGB(RGBArray *values, PLANEPTR *planearray, WORD bytes)
  2. ;                a0                    a1                    d2
  3.  
  4.  
  5.             xdef        _WritePlanarRGB
  6.  
  7. SREGS        reg            d2/d3/d4/a2/a3/a4
  8.  
  9. _WritePlanarRGB:
  10.             movem.l        SREGS,-(sp)
  11.  
  12.             moveq        #0,d1                        ; index into output planes
  13.  
  14.             move.l        d2,d3                        ; d3 <== bytes per row
  15.             bra.s        70$
  16. 40$
  17.  
  18. ; load up 24 bits of data each register
  19.  
  20. ; first triplet
  21.             move.b        2(a0),d4                    ; load up blue byte
  22.             swap        d4                            ; put in byte 2
  23.             move.b        1(a0),d4                    ; load up green byte
  24.             lsl.w        #8,d4                        ; put in byte 1
  25.             move.b        0(a0),d4                    ; load up red byte in byte 0
  26. ; second triplet
  27.             move.b        5(a0),d5                    ; load up blue byte
  28.             swap        d4                            ; put in byte 2
  29.             move.b        4(a0),d5                    ; load up green byte
  30.             lsl.w        #8,d4                        ; put in byte 1
  31.             move.b        3(a0),d5                    ; load up red byte in byte 0
  32. ; third triplet
  33.             move.b        8(a0),d6                    ; load up blue byte
  34.             swap        d4                            ; put in byte 2
  35.             move.b        7(a0),d6                    ; load up green byte
  36.             lsl.w        #8,d4                        ; put in byte 1
  37.             move.b        6(a0),d6                    ; load up red byte in byte 0
  38. ; fourth triplet
  39.             move.b        11(a0),d7                    ; load up blue byte
  40.             swap        d4                            ; put in byte 2
  41.             move.b        10(a0),d7                    ; load up green byte
  42.             lsl.w        #8,d4                        ; put in byte 1
  43.             move.b        9(a0),d7                    ; load up red byte in byte 0
  44.  
  45.             lea            12(a0),a0                    ; after we're done, do next 4 trips
  46.  
  47.             move.l        a1,a4                        ; a4 <== start of Plane pointers
  48.             moveq        #23,d2                        ; now, loop 24 times
  49.  
  50. 50$            moveq        #0,d0                        ; clear out d0
  51.  
  52.             lsr.l        #1,d4                        ; 1st pixel
  53.             addx.b        d0,d0
  54.             lsr.l        #1,d5                        ; 2nd pixel
  55.             addx.b        d0,d0
  56.             lsr.l        #1,d6                        ; 3rd pixel
  57.             addx.b        d0,d0
  58.             lsr.l        #1,d7                        ; 4th pixel
  59.             addx.b        d0,d0
  60.  
  61.             lsl.w        #4,d0                        ; put in upper half
  62.  
  63.             move.l        (a4)+,a2                    ; a2 <== next bitplane pointer
  64.             move.b        d0,(a2,d1.l)                ; d0 <== next pixel data word
  65.  
  66.             dbra        d2,50$                        ; loop to next plane
  67.  
  68. ; load up 24 bits of data each register (again)
  69.  
  70. ; first triplet
  71.             move.b        2(a0),d4                    ; load up blue byte
  72.             swap        d4                            ; put in byte 2
  73.             move.b        1(a0),d4                    ; load up green byte
  74.             lsl.w        #8,d4                        ; put in byte 1
  75.             move.b        0(a0),d4                    ; load up red byte in byte 0
  76. ; second triplet
  77.             move.b        5(a0),d5                    ; load up blue byte
  78.             swap        d4                            ; put in byte 2
  79.             move.b        4(a0),d5                    ; load up green byte
  80.             lsl.w        #8,d4                        ; put in byte 1
  81.             move.b        3(a0),d5                    ; load up red byte in byte 0
  82. ; third triplet
  83.             move.b        8(a0),d6                    ; load up blue byte
  84.             swap        d4                            ; put in byte 2
  85.             move.b        7(a0),d6                    ; load up green byte
  86.             lsl.w        #8,d4                        ; put in byte 1
  87.             move.b        6(a0),d6                    ; load up red byte in byte 0
  88. ; fourth triplet
  89.             move.b        11(a0),d7                    ; load up blue byte
  90.             swap        d4                            ; put in byte 2
  91.             move.b        10(a0),d7                    ; load up green byte
  92.             lsl.w        #8,d4                        ; put in byte 1
  93.             move.b        9(a0),d7                    ; load up red byte in byte 0
  94.  
  95.             lea            12(a0),a0                    ; after we're done, do next 4 trips
  96.  
  97.             move.l        a1,a4                        ; a4 <== start of Plane pointers
  98.             moveq        #23,d2                        ; now, loop 24 times
  99.  
  100. 60$            moveq        #0,d0                        ; clear out d0
  101.  
  102.             lsr.l        #1,d4                        ; 1st pixel
  103.             addx.b        d0,d0
  104.             lsr.l        #1,d5                        ; 2nd pixel
  105.             addx.b        d0,d0
  106.             lsr.l        #1,d6                        ; 3rd pixel
  107.             addx.b        d0,d0
  108.             lsr.l        #1,d7                        ; 4th pixel
  109.             addx.b        d0,d0
  110.  
  111.             lsl.w        #4,d0                        ; put in upper half
  112.  
  113.             move.l        (a4)+,a2                    ; a2 <== next bitplane pointer
  114.             or.b        d0,(a2,d1.l)                ; d0 <== next pixel data word
  115.  
  116.             dbra        d2,60$                        ; loop to next plane
  117.  
  118.             addq        #1,d1                        ; next byte
  119. 70$            dbra        d3,40$                        ; loop to next word
  120.  
  121.             movem.l        (sp)+,SREGS
  122.             rts
  123.  
  124.             end
  125.