home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / iffconverter / decompic.a < prev    next >
Text File  |  1997-01-07  |  2KB  |  114 lines

  1. **
  2. **     $VER: DecomPic.a V1.00 (24-06-95)
  3. **
  4. **     Author:  Gerben Venekamp
  5. **     Updates: 24-06-95  Version 1.00     Initial Module
  6. **
  7. **  DecomPic.a decompresses, if necessary, an ILBM Picture.
  8. **
  9.  
  10.  
  11.         XDEF    _DecompressPic
  12.         
  13.         INCLUDE    "include:exec/macros.i"
  14.         INCLUDE    "include:datatypes/pictureclass.i"
  15.         INCLUDE    "include:intuition/screens.i"
  16.         
  17.         SECTION    Decomp,code
  18. ****
  19. *
  20. *  pre:  A0 -> Pointer to BodyData.
  21. *        A1 -> Pointer to BitMapHeader.
  22. *        A2 -> Pointer to Screen structure.
  23. *        A3 -> Pointer to allocated memory to store bitplane addresses.
  24. *  post: None.
  25. *
  26. ****
  27. _DecompressPic
  28.         move.l    a4,-(SP)          We Need to keep this one!
  29.         lea    (sc_ViewPort,a2),a4
  30.         move.l    (vp_RasInfo,a4),a4
  31.         move.l    (ri_BitMap,a4),a4   Get BitMap Structure.
  32. HardStop
  33.         CLEAR    D6
  34.         move.w    (bm_BytesPerRow,a4),d6
  35.         lea    (bm_Planes,a4),a4   Get BitMap Addresses.
  36.         move.l    a3,a5
  37.         CLEAR    D1
  38.         move.b    (bmh_Depth,a1),d1
  39.         subq.w    #1,d1
  40.         move.w    d1,d7          For later use.
  41. CopyBitplaneAddresses
  42.         move.l    (a4)+,(a5)+
  43.         dbf    d1,CopyBitplaneAddresses
  44.         
  45.         cmp.b    #cmpNone,(bmh_Compression,a1)
  46.         beq.s    Do_cmpNone
  47.         cmp.b    #cmpByteRun1,(bmh_Compression,a1)
  48.         beq.s    Do_cmpByteRun1
  49. ; What should we do if None of the above compression types have
  50. ; been selected?
  51.         move.l    (SP)+,a4        Get that one back!
  52.         
  53.         rts
  54.  
  55. Do_cmpNone
  56.         move.l    (SP)+,a4        Get that one back!
  57.         rts
  58.         
  59. Do_cmpByteRun1
  60.         move.w    (bmh_Height,a1),d5
  61.         move.w    (bmh_Width,a1),d2
  62.         add.w    #15,d2
  63.         lsr.w    #4,d2
  64.         add.w    d2,d2
  65.         
  66.         subq.w    #1,d5
  67. FinishAll
  68.         move.l    a3,a4
  69.         move.w    d7,d4
  70. FinishRaster
  71.         move.l    (a4),a5
  72.         add.l    d6,(a4)+
  73.         
  74.         move.w    d2,d3
  75. FinishPlane
  76.         move.b    (a0)+,d0
  77.         ext.w    d0        Make Signed Word.
  78.         bmi.s    Decompress
  79.         
  80.         sub.w    d0,d3        Result is bytes to do.
  81.         subq.w    #1,d3        A little correction.
  82. copy_1
  83.         move.b    (a0)+,(a5)+    Litteral copy
  84.         dbf    d0,copy_1
  85.  
  86.         tst.w    d3        0 bytes to do?
  87.         bne.s    FinishPlane    No
  88.         
  89.         dbf    d4,FinishRaster
  90.         
  91.         dbf    d5,FinishAll
  92.  
  93.         move.l    (SP)+,a4        Get that one back!
  94.         rts
  95.         
  96. Decompress
  97.         neg.w    d0
  98.         move.b    (a0)+,d1
  99.         sub.w    d0,d3        Result is bytes to do.
  100.         subq.w    #1,d3        A little correction.
  101. copy_2
  102.         move.b    d1,(a5)+
  103.         dbf    d0,copy_2
  104.         
  105.         tst.w    d3
  106.         bne.s    FinishPlane
  107.         
  108.         dbf    d4,FinishRaster
  109.         
  110.         dbf    d5,FinishAll
  111.         
  112.         move.l    (SP)+,a4        Get that one back!
  113.         rts
  114.