home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / TOXIC / TOXIC01.MSA / PROGRAMS / ICE_TRP1.S < prev    next >
Encoding:
Text File  |  1987-04-22  |  6.5 KB  |  264 lines

  1. ;------------------------------------
  2. ; ICE Packer v2.31 'TRAP #1' Depacker
  3. ;------------------------------------
  4.  
  5.     opt    o+,ow-,a+        ; Optimierung einschalten
  6. start:    movea.l    #stackend,sp
  7.     move.l    sp,d0
  8.     subi.l    #start-$120,d0
  9.     move.l    d0,-(sp)
  10.     pea    start-$100(pc)
  11.     clr.w    -(sp)
  12.     move.w    #$4a,-(sp)
  13.     trap    #1
  14.     adda.w    #$c,sp
  15.  
  16.     bsr.s    super
  17.     bsr    print_me
  18.  
  19.     move.l    $84.w,old_trap1+2    ;store & change TRAP #1 vector
  20.     move.l    #my_trap1,$84.w
  21.     bsr.s    user
  22.     pea    null(pc)
  23.     pea    null(pc)
  24.     pea    file_name(pc)
  25.     move.w    #0,-(sp)
  26.     move.w    #$4b,-(sp)
  27.     trap    #1
  28.     lea.l    16(sp),sp
  29.     bsr.s    super
  30.     move.l    old_trap1+2(pc),$84.w
  31.     bsr.s    user
  32.     clr.w    -(sp)
  33.     trap    #1
  34.  
  35. null:    dc.l 0,0
  36.  
  37. file_name    dc.b 'Killcld.bog',0    ; nachgeladenes Programm (pexec)
  38.     EVEN 
  39.  
  40.  
  41. super:    clr.l    -(sp)        ;supervisor state
  42.     move.w    #$20,-(sp)
  43.     trap    #1
  44.     addq.l    #6,sp
  45.     move.l    d0,d7
  46.     rts    
  47.  
  48. user:    move.l    d7,-(sp)        ;user state
  49.     move.w    #$20,-(sp)
  50.     trap    #1
  51.     addq.l    #6,sp
  52.     rts    
  53.  
  54. my_trap1: 
  55.     movea.l    sp,a0
  56.     btst    #$d,(sp)
  57.     bne.s    supervisor
  58.     move.l    usp,a0
  59.     subq.l    #6,a0
  60. supervisor:    
  61.     addq.l    #6,a0
  62.     cmpi.w    #$3f,(a0)     ; read
  63.     beq.s    func_3f
  64. old_trap1:    
  65.     jmp    0.l
  66.  
  67. func_3f:    
  68.     move.l    8(a0),puffer
  69.     move.l    2(sp),ret_addr5+2    ; Returnadresse
  70.     move.l    #read,2(sp)
  71.     bra.s    old_trap1
  72.  
  73. read:    tst.w    2(sp)
  74.     bmi.s    ret_addr5     ; device handle->do nothing
  75.     movem.l    d1-d7/a0-a6,-(sp)
  76.     movea.l    puffer(pc),a0    ; Puffer
  77.     bsr.s    ice_decrunch_2
  78.     movem.l    (sp)+,d1-d7/a0-a6
  79. ret_addr5:    
  80.     jmp    0.l
  81.  
  82. ;********************************************* Unpackroutine von ICE-PACK
  83. ; Eingabe: a0 = Adresse gepackter Daten
  84. ice_decrunch_2:
  85.     link    a3,#-120
  86.     movem.l    d0-a6,-(sp)
  87.     lea    120(a0),a4    ; a4 = Anfang entpackte Daten
  88.     move.l    a4,a6        ; a6 = Ende entpackte Daten
  89.     bsr.s    .getinfo
  90.     cmpi.l    #'ICE!',d0    ; Kennung gefunden?
  91.     bne    .not_packed
  92.     bsr.s    .getinfo        ; gepackte Länge holen
  93.     lea.l    -8(a0,d0.l),a5    ; a5 = Ende der gepackten Daten
  94.     bsr.s    .getinfo        ; ungepackte Länge holen (original)
  95.     move.l    d0,(sp)        ; Originallänge: später nach d0
  96.     adda.l    d0,a6        ; a6 = Ende entpackte Daten
  97.     move.l    a6,a1
  98.  
  99.     moveq    #119,d0        ; 120 Bytes hinter entpackten Daten
  100. .save:    move.b    -(a1),-(a3)    ; in sicheren Bereich sichern
  101.     dbf    d0,.save
  102.     move.l    a6,a3        ; merken für Picture decrunch
  103.     move.b    -(a5),d7        ; erstes Informationsbyte
  104.     bsr.s    .normal_bytes
  105.     move.l    a3,a5        ; für 120 Bytes restore
  106.  
  107. .no_picture
  108.     movem.l    (sp),d0-a3    ; hole nötige Register
  109.  
  110. .move    move.b    (a4)+,(a0)+
  111.     subq.l    #1,d0
  112.     bne.s    .move
  113.     moveq    #119,d0        ; um überschriebenen Bereich
  114. .rest    move.b    -(a3),-(a5)    ; wieder herzustellen
  115.     dbf    d0,.rest
  116. .not_packed:
  117.     movem.l    (sp)+,d0-a6
  118.     unlk    a3
  119.     rts
  120.  
  121. .getinfo: moveq    #3,d1        ; ein Langwort vom Anfang
  122. .getbytes: lsl.l    #8,d0        ; der Daten lesen
  123.     move.b    (a0)+,d0
  124.     dbf    d1,.getbytes
  125.     rts
  126.  
  127. .normal_bytes:    
  128.     bsr.s    .get_1_bit
  129.     bcc.s    .test_if_end    ; Bit %0: keine Daten
  130.     moveq.l    #0,d1        ; falls zu copy_direkt
  131.     bsr.s    .get_1_bit
  132.     bcc.s    .copy_direkt    ; Bitfolge: %10: 1 Byte direkt kop.
  133.     lea.l    .direkt_tab+20(pc),a1
  134.     moveq.l    #4,d3
  135. .nextgb:    move.l    -(a1),d0        ; d0.w Bytes lesen
  136.     bsr.s    .get_d0_bits
  137.     swap.w    d0
  138.     cmp.w    d0,d1        ; alle gelesenen Bits gesetzt?
  139.     dbne    d3,.nextgb    ; ja: dann weiter Bits lesen
  140. .no_more: add.l    20(a1),d1     ; Anzahl der zu übertragenen Bytes
  141. .copy_direkt:    
  142.     move.b    -(a5),-(a6)    ; Daten direkt kopieren
  143.     dbf    d1,.copy_direkt    ; noch ein Byte
  144. .test_if_end:    
  145.     cmpa.l    a4,a6        ; Fertig?
  146.     bgt.s    .strings        ; Weiter wenn Ende nicht erreicht
  147.     rts    
  148.  
  149. ;************************** Unterroutinen: wegen Optimierung nicht am Schluß
  150.  
  151. .get_1_bit:
  152.     add.b    d7,d7        ; hole ein bit
  153.     bne.s    .bitfound     ; quellfeld leer
  154.     move.b    -(a5),d7        ; hole Informationsbyte
  155.     addx.b    d7,d7
  156. .bitfound:
  157.     rts    
  158.  
  159. .get_d0_bits:    
  160.     moveq.l    #0,d1        ; ergebnisfeld vorbereiten
  161. .hole_bit_loop:    
  162.     add.b    d7,d7        ; hole ein bit
  163.     bne.s    .on_d0        ; in d7 steht noch Information
  164.     move.b    -(a5),d7        ; hole Informationsbyte
  165.     addx.b    d7,d7
  166. .on_d0:    addx.w    d1,d1        ; und übernimm es
  167.     dbf    d0,.hole_bit_loop    ; bis alle Bits geholt wurden
  168.     rts    
  169.  
  170. ;************************************ Ende der Unterroutinen
  171.  
  172.  
  173. .strings: lea.l    .length_tab(pc),a1    ; a1 = Zeiger auf Tabelle
  174.     moveq.l    #3,d2        ; d2 = Zeiger in Tabelle
  175. .get_length_bit:    
  176.     bsr.s    .get_1_bit
  177.     dbcc    d2,.get_length_bit    ; nächstes Bit holen
  178. .no_length_bit:    
  179.     moveq.l    #0,d4        ; d4 = Überschuß-Länge
  180.     moveq.l    #0,d1
  181.     move.b    1(a1,d2.w),d0    ; d2: zw. -1 und 3; d3+1: Bits lesen
  182.     ext.w    d0        ; als Wort behandeln
  183.     bmi.s    .no_über        ; kein Überschuß nötig
  184. .get_über:
  185.     bsr.s    .get_d0_bits
  186. .no_über:    move.b    6(a1,d2.w),d4    ; Standard-Länge zu Überschuß add.
  187.     add.w    d1,d4        ; d4 = String-Länge-2
  188.     beq.s    .get_offset_2    ; Länge = 2: Spezielle Offset-Routine
  189.  
  190.  
  191.     lea.l    .more_offset(pc),a1 ; a1 = Zeiger auf Tabelle
  192.     moveq.l    #1,d2
  193. .getoffs: bsr.s    .get_1_bit
  194.     dbcc    d2,.getoffs
  195.     moveq.l    #0,d1        ; Offset-Überschuß
  196.     move.b    1(a1,d2.w),d0    ; request d0 Bits
  197.     ext.w    d0        ; als Wort
  198.     bsr.s    .get_d0_bits
  199.     add.w    d2,d2        ; ab jetzt: Pointer auf Worte
  200.     add.w    6(a1,d2.w),d1    ; Standard-Offset zu Überschuß add.
  201.     bpl.s    .depack_bytes    ; keine gleiche Bytes: String kop.
  202.     sub.w    d4,d1        ; gleiche Bytes
  203.     bra.s    .depack_bytes
  204.  
  205.  
  206. .get_offset_2:    
  207.     moveq.l    #0,d1        ; Überschuß-Offset auf 0 setzen
  208.     moveq.l    #5,d0        ; standard: 6 Bits holen
  209.     moveq.l    #-1,d2        ; Standard-Offset auf -1
  210.     bsr.s    .get_1_bit
  211.     bcc.s    .less_40        ; Bit = %0
  212.     moveq.l    #8,d0        ; quenty fourty: 9 Bits holen
  213.     moveq.l    #$3f,d2        ; Standard-Offset: $3f
  214. .less_40: bsr.s    .get_d0_bits
  215.     add.w    d2,d1        ; Standard-Offset + Über-Offset
  216.  
  217. .depack_bytes:            ; d1 = Offset, d4 = Anzahl Bytes
  218.     lea.l    2(a6,d4.w),a1    ; Hier stehen die Originaldaten
  219.     adda.w    d1,a1        ; Dazu der Offset
  220.     move.b    -(a1),-(a6)    ; ein Byte auf jeden Fall kopieren
  221. .dep_b:    move.b    -(a1),-(a6)    ; mehr Bytes kopieren
  222.     dbf    d4,.dep_b     ; und noch ein Mal
  223.     bra    .normal_bytes    ; Jetzt kommen wieder normale Bytes
  224.  
  225.  
  226. .direkt_tab:
  227.     dc.l $7fff000e,$00ff0007,$00070002,$00030001,$00030001    ; Anzahl 1-Bits
  228.     dc.l     270-1,    15-1,     8-1,     5-1,     2-1    ; Anz. Bytes
  229.  
  230. .length_tab:
  231.     dc.b 9,1,0,-1,-1        ; Bits lesen
  232.     dc.b 8,4,2,1,0        ; Standard-Länge - 2 (!!!)
  233.  
  234. .more_offset:
  235.     dc.b      11,   4,   7,  0    ; Bits lesen
  236.     dc.w    $11f,  -1, $1f    ; Standard Offset
  237.  
  238. ende_ice_decrunch_2:
  239. ;*************************************************** Ende der Unpackroutine
  240.  
  241. print_me    pea    message
  242.     move.w    #9,-(sp)
  243.     trap    #1
  244.     addq.l    #6,sp
  245.     
  246. wait_key    move.w    #7,-(sp)
  247.     trap    #1
  248.     addq.l    #2,sp
  249.     rts
  250.  
  251. message    dc.b    27,69,27,112
  252.     dc.b    "Slasher Bog of The Bog Brothers.",27,113,13,10
  253.     dc.b    "--------------------------------",13,10,10
  254.     dc.b    "Presents: The Killing Cloud",13,10,10
  255.     dc.b    "Packed with:  ICE Packer v2.31",13,10,10,0
  256.     even
  257.  
  258.     section    bss
  259. puffer:        ds.l 1
  260.         ds.b 500
  261. stackend:     ds.b 20
  262.  
  263.  
  264.