home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / iffconverter / decompic.a.bak < prev    next >
Text File  |  1997-01-07  |  2KB  |  132 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.         nop
  85.         nop
  86.         nop
  87.         dbf    d0,copy_1
  88.  
  89.         tst.w    d3        0 bytes to do?
  90.         bne.s    FinishPlane    No
  91.         
  92.         nop
  93.         nop
  94.         nop
  95.         dbf    d4,FinishRaster
  96.         
  97.         nop
  98.         nop
  99.         nop
  100.         dbf    d5,FinishAll
  101.  
  102.         move.l    (SP)+,a4        Get that one back!
  103.         rts
  104.         
  105. Decompress
  106.         neg.w    d0
  107.         move.b    (a0)+,d1
  108.         sub.w    d0,d3        Result is bytes to do.
  109.         subq.w    #1,d3        A little correction.
  110. copy_2
  111.         move.b    d1,(a5)+
  112.         nop
  113.         nop
  114.         nop
  115.         dbf    d0,copy_2
  116.         
  117.         tst.w    d3
  118.         bne.s    FinishPlane
  119.         
  120.         nop
  121.         nop
  122.         nop
  123.         dbf    d4,FinishRaster
  124.         
  125.         nop
  126.         nop
  127.         nop
  128.         dbf    d5,FinishAll
  129.         
  130.         move.l    (SP)+,a4        Get that one back!
  131.         rts
  132.