home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / falcon / sound / dsppaula / ice_unp2.s < prev    next >
Text File  |  1993-05-21  |  3KB  |  180 lines

  1. ;********************************************* Unpacking routine of PACK-ICE
  2. ; a0 = Adress of packed data
  3. ; "bsr" or "jsr" to ice_decrunch_2 with register a0 prepared.
  4. ice_decrunch_2:
  5.     link    a3,#-120
  6.     movem.l    d0-a6,-(sp)
  7.     lea    120(a0),a4
  8.     move.l    a4,a6
  9.     bsr    .getinfo
  10.     cmpi.l    #'ICE!',d0
  11.     bne    .not_packed
  12.     bsr.s    .getinfo
  13.     lea.l    -8(a0,d0.l),a5
  14.     bsr.s    .getinfo
  15.     move.l    d0,(sp)
  16.     adda.l    d0,a6
  17.     move.l    a6,a1
  18.  
  19.     moveq    #119,d0
  20. .save:    move.b    -(a1),-(a3)
  21.     dbf    d0,.save
  22.     move.l    a6,a3
  23.     move.b    -(a5),d7
  24.     bsr.s    .normal_bytes
  25.     move.l    a3,a5
  26.  
  27.  
  28.     bsr    .get_1_bit
  29.     bcc.s    .no_picture
  30.     move.w    #$0f9f,d7
  31.     bsr    .get_1_bit
  32.     bcc.s    .ice_00
  33.     moveq    #15,d0
  34.     bsr    .get_d0_bits
  35.     move.w    d1,d7
  36. .ice_00:    moveq    #3,d6
  37. .ice_01:    move.w    -(a3),d4
  38.     moveq    #3,d5
  39. .ice_02:    add.w    d4,d4
  40.     addx.w    d0,d0
  41.     add.w    d4,d4
  42.     addx.w    d1,d1
  43.     add.w    d4,d4
  44.     addx.w    d2,d2
  45.     add.w    d4,d4
  46.     addx.w    d3,d3
  47.     dbra    d5,.ice_02
  48.     dbra    d6,.ice_01
  49.     movem.w    d0-d3,(a3)
  50.     dbra    d7,.ice_00
  51. .no_picture
  52.     movem.l    (sp),d0-a3
  53.  
  54. .move    move.b    (a4)+,(a0)+
  55.     subq.l    #1,d0
  56.     bne.s    .move
  57.     moveq    #119,d0
  58. .rest    move.b    -(a3),-(a5)
  59.     dbf    d0,.rest
  60. .not_packed:
  61.     movem.l    (sp)+,d0-a6
  62.     unlk    a3
  63.     rts
  64.  
  65. .getinfo: moveq    #3,d1
  66. .getbytes: lsl.l    #8,d0
  67.     move.b    (a0)+,d0
  68.     dbf    d1,.getbytes
  69.     rts
  70.  
  71. .normal_bytes:    
  72.     bsr.s    .get_1_bit
  73.     bcc.s    .test_if_end
  74.     moveq.l    #0,d1
  75.     bsr.s    .get_1_bit
  76.     bcc.s    .copy_direkt
  77.     lea.l    .direkt_tab+20(pc),a1
  78.     moveq.l    #4,d3
  79. .nextgb:    move.l    -(a1),d0
  80.     bsr.s    .get_d0_bits
  81.     swap.w    d0
  82.     cmp.w    d0,d1
  83.     dbne    d3,.nextgb
  84. .no_more: add.l    20(a1),d1
  85. .copy_direkt:    
  86.     move.b    -(a5),-(a6)
  87.     dbf    d1,.copy_direkt
  88. .test_if_end:    
  89.     cmpa.l    a4,a6
  90.     bgt.s    .strings
  91.     rts    
  92.  
  93. .get_1_bit:
  94.     add.b    d7,d7
  95.     bne.s    .bitfound
  96.     move.b    -(a5),d7
  97.     addx.b    d7,d7
  98. .bitfound:
  99.     rts    
  100.  
  101. .get_d0_bits:    
  102.     moveq.l    #0,d1
  103. .hole_bit_loop:    
  104.     add.b    d7,d7
  105.     bne.s    .on_d0
  106.     move.b    -(a5),d7
  107.     addx.b    d7,d7
  108. .on_d0:    addx.w    d1,d1
  109.     dbf    d0,.hole_bit_loop
  110.     rts    
  111.  
  112.  
  113. .strings: lea.l    .length_tab(pc),a1
  114.     moveq.l    #3,d2
  115. .get_length_bit:    
  116.     bsr.s    .get_1_bit
  117.     dbcc    d2,.get_length_bit
  118. .no_length_bit:    
  119.     moveq.l    #0,d4
  120.     moveq.l    #0,d1
  121.     move.b    1(a1,d2.w),d0
  122.     ext.w    d0
  123.     bmi.s    .no_über
  124. .get_über:
  125.     bsr.s    .get_d0_bits
  126. .no_über:    move.b    6(a1,d2.w),d4
  127.     add.w    d1,d4
  128.     beq.s    .get_offset_2
  129.  
  130.  
  131.     lea.l    .more_offset(pc),a1
  132.     moveq.l    #1,d2
  133. .getoffs: bsr.s    .get_1_bit
  134.     dbcc    d2,.getoffs
  135.     moveq.l    #0,d1
  136.     move.b    1(a1,d2.w),d0
  137.     ext.w    d0
  138.     bsr.s    .get_d0_bits
  139.     add.w    d2,d2
  140.     add.w    6(a1,d2.w),d1
  141.     bpl.s    .depack_bytes
  142.     sub.w    d4,d1
  143.     bra.s    .depack_bytes
  144.  
  145.  
  146. .get_offset_2:    
  147.     moveq.l    #0,d1
  148.     moveq.l    #5,d0
  149.     moveq.l    #-1,d2
  150.     bsr.s    .get_1_bit
  151.     bcc.s    .less_40
  152.     moveq.l    #8,d0
  153.     moveq.l    #$3f,d2
  154. .less_40: bsr.s    .get_d0_bits
  155.     add.w    d2,d1
  156.  
  157. .depack_bytes:
  158.     lea.l    2(a6,d4.w),a1
  159.     adda.w    d1,a1
  160.     move.b    -(a1),-(a6)
  161. .dep_b:    move.b    -(a1),-(a6)
  162.     dbf    d4,.dep_b
  163.     bra    .normal_bytes
  164.  
  165.  
  166. .direkt_tab:
  167.     dc.l $7fff000e,$00ff0007,$00070002,$00030001,$00030001
  168.     dc.l     270-1,15-1,8-1,5-1,2-1
  169.  
  170. .length_tab:
  171.     dc.b 9,1,0,-1,-1
  172.     dc.b 8,4,2,1,0
  173.  
  174. .more_offset:
  175.     dc.b      11,4,7,0    ; Bits lesen
  176.     dc.w    $11f,-1,$1f    ; Standard Offset
  177.  
  178. ende_ice_decrunch_2:
  179. ;************************************************** end of unpacking routine
  180.