home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / STFORMAT / STF39A.MSA / PACK_ICE / ICE_DCRU.S < prev    next >
Text File  |  1989-04-06  |  3KB  |  151 lines

  1. ;********************************************* Unpacking routine of PACK-ICE
  2. ; a0 = AdTRESs 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.S    .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.     moveq    #119,d0
  19. .save    move.B    -(a1),-(a3)
  20.     dbf    d0,.save
  21.     move.L    a6,a3
  22.     move.B    -(a5),d7
  23.     bsr.s    .normal_bytes
  24.     move.L    a3,a5
  25.     bsr    .get_1_bit
  26.     bcc.s    .no_picture
  27.     move.W    #$0f9f,d7
  28.     bsr    .get_1_bit
  29.     bcc.s    .ice_00
  30.     moveq    #15,d0
  31.     bsr    .get_d0_bits
  32.     move.W    d1,d7
  33. .ice_00    moveq    #3,d6
  34. .ice_01    move.W    -(a3),d4
  35.     moveq    #3,d5
  36. .ice_02    add.W    d4,d4
  37.     addx.W    d0,d0
  38.     add.W    d4,d4
  39.     addx.W    d1,d1
  40.     add.W    d4,d4
  41.     addx.W    d2,d2
  42.     add.W    d4,d4
  43.     addx.W    d3,d3
  44.     dbra    d5,.ice_02
  45.     dbra    d6,.ice_01
  46.     movem.W    d0-d3,(a3)
  47.     dbra    d7,.ice_00
  48. .no_picture
  49.     movem.L    (sp),d0-a3
  50.  
  51. .move    move.B    (a4)+,(a0)+
  52.     subq.L    #1,d0
  53.     bne.s    .move
  54.     moveq    #119,d0
  55. .TRESt    move.B    -(a3),-(a5)
  56.     dbf    d0,.TRESt
  57. .not_packed    movem.L    (sp)+,d0-a6
  58.     unlk    a3
  59.     rts
  60. .getinfo    moveq    #3,d1
  61. .getbytes    lsl.L    #8,d0
  62.     move.B    (a0)+,d0
  63.     dbf    d1,.getbytes
  64.     rts
  65. .normal_bytes    
  66.     bsr.s    .get_1_bit
  67.     bcc.s    .test_if_end
  68.     moveq.L    #0,d1
  69.     bsr.s    .get_1_bit
  70.     bcc.s    .copy_direkt
  71.     lea.L    .direkt_tab+20(pc),a1
  72.     moveq.L    #4,d3
  73. .nextgb    move.L    -(a1),d0
  74.     bsr.s    .get_d0_bits
  75.     swap.W    d0
  76.     cmp.W    d0,d1
  77.     dbne    d3,.nextgb
  78. .no_more add.L    20(a1),d1
  79. .copy_direkt    move.B    -(a5),-(a6)
  80.     dbf    d1,.copy_direkt
  81. .test_if_end    cmpa.L    a4,a6
  82.     bgt.s    .strings
  83.     rts    
  84. .get_1_bit    add.B    d7,d7
  85.     bne.s    .Bitfound
  86.     move.B    -(a5),d7
  87.     addx.B    d7,d7
  88. .Bitfound    rts    
  89. .get_d0_bits    
  90.     moveq.L    #0,d1
  91. .hole_bit_loop    
  92.     add.B    d7,d7
  93.     bne.s    .on_d0
  94.     move.B    -(a5),d7
  95.     addx.B    d7,d7
  96. .on_d0    addx.W    d1,d1
  97.     dbf    d0,.hole_bit_loop
  98.     rts    
  99. .strings    lea.L    .Length_tab(pc),a1
  100.     moveq.L    #3,d2
  101. .get_length_bit    
  102.     bsr.s    .get_1_bit
  103.     dbcc    d2,.get_length_bit
  104. .no_length_bit    
  105.     moveq.L    #0,d4
  106.     moveq.L    #0,d1
  107.     move.B    1(a1,d2.W),d0
  108.     ext.W    d0
  109.     bmi.s    .no_über
  110. .get_über    bsr.s    .get_d0_bits
  111. .no_über    move.B    6(a1,d2.W),d4
  112.     add.W    d1,d4
  113.     beq.s    .get_offset_2
  114.     lea.L    .more_offset(pc),a1
  115.     moveq.L    #1,d2
  116. .getoffs    bsr.s    .get_1_bit
  117.     dbcc    d2,.getoffs
  118.     moveq.L    #0,d1
  119.     move.B    1(a1,d2.W),d0
  120.     ext.W    d0
  121.     bsr.s    .get_d0_bits
  122.     add.W    d2,d2
  123.     add.W    6(a1,d2.W),d1
  124.     bpl.s    .depack_bytes
  125.     sub.W    d4,d1
  126.     bra.s    .depack_bytes
  127. .get_offset_2    
  128.     moveq.L    #0,d1
  129.     moveq.L    #5,d0
  130.     moveq.L    #-1,d2
  131.     bsr.s    .get_1_bit
  132.     bcc.s    .Less_40
  133.     moveq.L    #8,d0
  134.     moveq.L    #$3f,d2
  135. .Less_40 bsr.s    .get_d0_bits
  136.     add.W    d2,d1
  137. .depack_bytes
  138.     lea.L    2(a6,d4.W),a1
  139.     adda.W    d1,a1
  140.     move.B    -(a1),-(a6)
  141. .dep_b    move.B    -(a1),-(a6)
  142.     dbf    d4,.dep_b
  143.     bra    .normal_bytes
  144. .direkt_tab    dc.L    $7fff000e,$00ff0007,$00070002,$00030001,$00030001
  145.     dc.L     270-1,    15-1,     8-1,     5-1,     2-1
  146. .Length_tab    dc.B    9,1,0,-1,-1
  147.     dc.B    8,4,2,1,0
  148. .more_offset    dc.B      11,   4,   7,  0    ; Bits lesen
  149.     dc.W    $11f,  -1, $1f    ; Standard Offset
  150. ende_ice_decrunch_2
  151.