home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser 2002 January / STC_CD_01_2002.iso / GAMES / COLUMSRC / DEPACK35.S < prev    next >
Text File  |  1994-01-15  |  6KB  |  285 lines

  1. ;ATOMIK DECRUNCH SOURCE CODE v3.5 (non optimise, pas le temps. sorry...)
  2.  
  3. ;ce depacker est indissociable du programme ATOMIK V3.5 tous les mecs
  4. ;qui garderons se source dans l'espoir de prendre de l'importance
  5. ;en se disant moi je l'ai et pas l'autre sont des lamers.
  6.  
  7. ;MODE=1 depack data from a0 to a0 
  8. ;MODE=0 depack data from a0 to a1 (RESTORE SPACE a 1 inutile! si MODE=0)
  9.  
  10. ;PIC_ALGO = 0 decrunch file not encoded with special picture algorythm.
  11. ;PIC_ALGO = 1 decrunch all files with or without picture algorythm.
  12.  
  13. ;DEC_SPACE = (lesser decrunch space is gived after packing by atomik v3.5)
  14.              
  15. ;RESTORE_SPACE = 1 the allocated decrunch space will be restored .
  16. ;RESTORE_SPACE = 0 the allocated decrunch space will not be restored.
  17.  
  18. ;call it by BSR DEPACK or JSR DEPACK but call it!
  19.  
  20. MODE:    EQU    0
  21. PIC_ALGO:    EQU    0
  22. DEC_SPACE:    EQU    $80     ;MAX IS $7FFE (no odd value!)
  23. RESTORE_SPACE:    EQU    0
  24.  
  25. DEPACK:    movem.l    d0-a6,-(a7)
  26.     cmp.l    #"ATM5",(a0)+
  27.     bne    not_packed
  28.     link    a2,#-28
  29.     move.l    (a0)+,d0
  30.     ifne    MODE
  31.     lea    4(a0,d0.l),a5
  32.     move.l    d0,-(a7)
  33.     elseif
  34.     move.l    a1,a5
  35.     add.l    d0,a5
  36.     endc
  37.     move.l    a5,a4
  38.     ifne    MODE
  39.     ifne    DEC_SPACE
  40.     lea    DEC_SPACE(a4),a5
  41.     endc
  42.     endc
  43.     lea    -$c(a4),a4
  44.     move.l    (a0)+,d0
  45.     move.l    a0,a6
  46.     add.l    d0,a6
  47.     ifne    PIC_ALGO
  48.     moveq    #0,d0
  49.     move.b    -(a6),d0
  50.     move    d0,-2(a2)
  51.     ifne    RESTORE_SPACE
  52.     lsl    #2,d0
  53.     sub    d0,a4
  54.     endc
  55.     elseif
  56.     ifne    RESTORE_SPACE
  57.     clr    -2(a2)
  58.     endc
  59.     subq    #1,a6
  60.     endc
  61.     ifne    RESTORE_SPACE
  62.     lea    buff_marg(pc),a3
  63.     move    -2(a2),d0
  64.     lsl    #2,d0
  65.     add    #DEC_SPACE+$C,d0
  66.     bra.s    .save
  67. .save_m:    move.b    (a4)+,(a3)+
  68.     subq    #1,d0
  69. .save:    bne.s    .save_m
  70.     movem.l    a3-a4,-(a7)
  71.     endc
  72.     ifne    PIC_ALGO
  73.     pea    (a5)
  74.     endc
  75.     move.b    -(a6),d7
  76.     bra    take_type
  77. decrunch:    move    d3,d5
  78. take_lenght:    add.b    d7,d7
  79. .cont_take:    dbcs    d5,take_lenght
  80.     beq.s    .empty1
  81.     bcc.s    .next_cod
  82.     sub    d3,d5
  83.     neg    d5
  84.     bra.s    .do_copy1
  85. .next_cod:    moveq    #3,d6
  86.     bsr.s    get_bit2
  87.     beq.s    .next_cod1
  88.     bra.s    .do_copy
  89. .next_cod1:    moveq    #7,d6
  90.     bsr.s    get_bit2
  91.     beq.s    .next_cod2
  92.     add    #15,d5
  93.     bra.s    .do_copy
  94. .empty1:    move.b    -(a6),d7
  95.     addx.b    d7,d7
  96.     bra.s    .cont_take
  97. .next_cod2:    moveq    #13,d6
  98.     bsr.s    get_bit2
  99.     add    #255+15,d5
  100. .do_copy:    add    d3,d5
  101. .do_copy1:    lea    decrun_table(pc),a4
  102.     move    d5,d2
  103.     bne.s    bigger
  104.     add.b    d7,d7
  105.     bne.s    .not_empty
  106.     move.b    -(a6),d7
  107.     addx.b    d7,d7
  108. .not_empty:    bcs.s    .ho_kesako
  109.     moveq    #1,d6
  110.     bra.s    word
  111. .ho_kesako:    moveq    #3,d6
  112.     bsr.s    get_bit2
  113.     tst.b    -28(a2)
  114.     beq.s    .ho_kesako1
  115.     move.b    10-28(a2,d5.w),-(a5)
  116.     bra    tst_end
  117. .ho_kesako1:    move.b    (a5),d0
  118.     btst    #3,d5
  119.     bne.s    .ho_kesako2
  120.     bra.s    .ho_kesako3
  121. .ho_kesako2:    add.b    #$f0,d5
  122. .ho_kesako3:    sub.b    d5,d0
  123.     move.b    d0,-(a5)
  124.     bra    tst_end
  125. get_bit2:    clr    d5
  126. .get_bits:    add.b    d7,d7
  127.     beq.s    .empty
  128. .cont:    addx    d5,d5
  129.     dbf    d6,.get_bits
  130.     tst    d5
  131.     rts
  132. .empty:    move.b    -(a6),d7
  133.     addx.b    d7,d7
  134.     bra.s    .cont
  135. bigger:    moveq    #2,d6
  136. word:    bsr.s    get_bit2
  137. contus:    move    d5,d4
  138.     move.b    14(a4,d4.w),d6
  139.     ext    d6
  140.     tst.b    1-28(a2)
  141.     bne.s    .spe_ofcod1
  142.     addq    #4,d6
  143.     bra.s    .nospe_ofcod1
  144. .spe_ofcod1:    bsr.s    get_bit2
  145.     move    d5,d1
  146.     lsl    #4,d1
  147.     moveq    #2,d6
  148.     bsr.s    get_bit2
  149.     cmp.b    #7,d5
  150.     blt.s    .take_orof
  151.     moveq    #0,d6
  152.     bsr.s    get_bit2
  153.     beq.s    .its_little
  154.     moveq    #2,d6
  155.     bsr.s    get_bit2
  156.     add    d5,d5
  157.     or    d1,d5
  158.     bra.s    .spe_ofcod2
  159. .its_little:    or.b    2-28(a2),d1
  160.     bra.s    .spe_ofcod3
  161. .take_orof:    or.b    3-28(a2,d5.w),d1
  162. .spe_ofcod3:    move    d1,d5
  163.     bra.s    .spe_ofcod2
  164. .nospe_ofcod1:    bsr.s    get_bit2
  165. .spe_ofcod2:    add    d4,d4
  166.     beq.s    .first
  167.     add    -2(a4,d4.w),d5
  168. .first:    lea    1(a5,d5.w),a4
  169.     move.b    -(a4),-(a5)
  170. .copy_same:    move.b    -(a4),-(a5)
  171.     dbf    d2,.copy_same
  172.     bra.s    tst_end
  173. make_jnk:    add.b    d7,d7
  174.     bne.s    .not_empty
  175.     move.b    -(a6),d7
  176.     addx.b    d7,d7
  177. .not_empty:    bcs.s    string
  178.     move.b    -(a6),-(a5)
  179. tst_end:    cmp.l    a5,a3
  180.     bne.s    make_jnk
  181.     cmp.l    a6,a0
  182.     beq.s    work_done
  183. take_type:    moveq    #0,d6
  184.     bsr    get_bit2
  185.     beq.s    .nospe_ofcod
  186.     move.b    -(a6),d0
  187.     lea    2-28(a2),a1
  188.     move.b    d0,(a1)+
  189.     moveq    #1,d1
  190.     moveq    #6,d2
  191. .next:    cmp.b    d0,d1
  192.     bne.s    .no_off_4b
  193.     addq    #2,d1
  194. .no_off_4b:    move.b    d1,(a1)+
  195.     addq    #2,d1
  196.     dbf    d2,.next
  197.     st    1-28(a2)
  198.     bra.s    .spe_ofcod
  199. .nospe_ofcod:    sf    1-28(a2)
  200. .spe_ofcod:    moveq    #0,d6
  201.     bsr    get_bit2
  202.     beq.s    .relatif
  203.     lea    10-28(a2),a1
  204.     moveq    #15,d0
  205. .next_f:    move.b    -(a6),(a1)+
  206.     dbf    d0,.next_f
  207.     st    -28(a2)
  208.     bra.s    .freq
  209. .relatif:    sf    -28(a2)
  210. .freq:    clr    d3
  211.     move.b    -(a6),d3
  212.     move.b    -(a6),d0
  213.     lsl    #8,d0
  214.     move.b    -(a6),d0
  215.     move.l    a5,a3
  216.     sub    d0,a3
  217.     bra.s    make_jnk
  218. string:    bra    decrunch
  219. work_done:
  220.     ifne    PIC_ALGO
  221.     move.l    (a7)+,a0
  222.     pea    (a2)
  223.     bsr.s    decod_picture
  224.     move.l    (a7)+,a2
  225.     endc
  226.     ifne    RESTORE_SPACE
  227.     movem.l    (a7)+,a3-a4
  228.     endc
  229.     ifne    MODE
  230.     move.l    (a7)+,d0
  231.     bsr    copy_decrun
  232.     endc
  233.     ifne    RESTORE_SPACE
  234.     move    -2(a2),d0
  235.     lsl    #2,d0
  236.     add    #DEC_SPACE+$C,d0
  237.     bra.s    .restore
  238. .restore_m:    move.b    -(a3),-(a4)
  239.     subq    #1,d0
  240. .restore:    bne.s    .restore_m
  241.     endc
  242.     unlk    a2
  243. not_packed:    movem.l    (a7)+,d0-a6
  244.      rts
  245. decrun_table:    dc.w    32,32+64,32+64+256,32+64+256+512,32+64+256+512+1024
  246.     dc.w    32+64+256+512+1024+2048,32+64+256+512+1024+2048+4096
  247.     dc.b    0,1,3,4,5,6,7,8
  248.     ifne    PIC_ALGO
  249. decod_picture:    move    -2(a2),d7
  250. .next_picture:    dbf    d7,.decod_algo
  251.     rts
  252. .decod_algo:    move.l    -(a0),d0
  253.     lea    0(a5,d0.l),a1
  254. .no_odd:    lea    $7d00(a1),a2
  255. .next_planes:    moveq    #3,d6
  256. .next_word:    move    (a1)+,d0
  257.     moveq    #3,d5
  258. .next_bits:    add    d0,d0
  259.     addx    d1,d1
  260.     add    d0,d0
  261.     addx    d2,d2
  262.     add    d0,d0
  263.     addx    d3,d3
  264.     add    d0,d0
  265.     addx    d4,d4
  266.     dbf    d5,.next_bits
  267.     dbf    d6,.next_word
  268.     movem    d1-d4,-8(a1)
  269.     cmp.l    a1,a2
  270.     bne.s    .next_planes
  271.     bra.s    .next_picture
  272.     endc
  273.     ifne    MODE
  274. copy_decrun:    lsr.l    #4,d0
  275.     lea    -12(a6),a6
  276. .copy_decrun:    rept    4
  277.     move.l    (a5)+,(a6)+
  278.     endr
  279.     dbf    d0,.copy_decrun
  280.     rts
  281.     endc
  282.     ifne    RESTORE_SPACE
  283. buff_marg:    dcb.b    $90+DEC_SPACE+$C
  284.     endc
  285.