Subversion Repositories Kolibri OS

Rev

Rev 1688 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;*********************************************************************
  2. unpack:
  3. ;       call    clear_edit_points
  4. ;       and     [curedit],0
  5. ; clear messages
  6.         call    clear_messages
  7. ; display logo
  8.         mov     esi,info_str
  9.         push    info_len
  10.         pop     ecx
  11.         call    write_string
  12.  
  13. ; load input file
  14.         mov     esi,inname
  15.         call    get_full_name
  16.         mov     ebx,fn70block
  17.         mov     [ebx],dword 5
  18.         and     [ebx+4],dword 0
  19.         and     [ebx+8],dword 0
  20.         and     [ebx+12],dword 0
  21.         mov     [ebx+16],dword file_attr
  22.         mcall   70
  23.         test    eax,eax
  24.         jnz     infileerr
  25.  
  26.         mov     ecx,[insize]
  27.         test    ecx,ecx
  28.         jz      infileerr
  29.  
  30. ;       mov     ecx,[memf]
  31. ;       mov     [infile],ecx
  32. ;       add     ecx,eax
  33. ;       mov     [outfile],ecx
  34. ;       mov     [outfilebest],ecx
  35. ;       mcall   64,1
  36. ;       test    eax,eax
  37. ;       jnz     memf1
  38.  
  39.         mcall   68,12
  40.  
  41.         mov     [infile],eax
  42.  
  43.         mov     ebx,fn70block
  44.         mov     [ebx],byte 0
  45.         mov     [ebx+16],eax
  46.         mov     eax,[insize]
  47.         mov     [ebx+12],eax
  48.  
  49.         mcall   70
  50.         test    eax,eax
  51.         jnz     infileerr
  52.  
  53.         mov     eax,[infile]
  54.         cmp     [eax],dword 'KPCK'
  55.         jz      @f
  56. ;--------------------------------------
  57. unpack_err:
  58.         call    return_memory
  59.         mov     esi,notpacked_str
  60.         push    notpacked_len
  61.         pop     ecx
  62.         jmp     write_string
  63. ;---------------------------------------------------------------------
  64. @@:
  65. ;       mov     ecx,[outfile]
  66. ;       add     ecx,dword [eax+4]
  67. ;       mcall   64,1
  68. ;       test    eax,eax
  69. ;       jnz     memf1
  70.  
  71.         mov     ecx,[eax+4]
  72.         add     ecx,[insize]
  73.  
  74.         mcall   68,20,,[infile]
  75.  
  76.         mov     [infile],eax
  77.         add     eax,[insize]
  78.         mov     [outfile],eax
  79.         mov     [outfilebest],eax
  80.  
  81.  
  82.         mov     esi,[infile]
  83.         mov     eax,[esi+8]
  84.         push    eax
  85.         and     al,0C0h
  86.         cmp     al,0C0h
  87.         pop     eax
  88.         jz      unpack_err
  89.  
  90.         and     al,not 0C0h
  91.         dec     eax
  92.         jnz     unpack_err
  93.  
  94.         mov     eax,[esi+4]
  95.         mov     [outsize],eax
  96.         push    eax
  97.         push    [outfile]
  98.         add     esi,11
  99.         push    esi
  100.         mov     eax,[esi+1]
  101.         xchg    al,ah
  102.         ror     eax,16
  103.         xchg    al,ah
  104.         mov     [esi+1],eax
  105.         call    lzma_decompress
  106.         mov     esi,[infile]
  107.         test    [esi+8],byte 80h
  108.         jnz     uctr1
  109.  
  110.         test    [esi+8],byte 40h
  111.         jz      udone
  112.  
  113.         add     esi,[insize]
  114.         sub     esi,5
  115.         lodsd
  116.         mov     ecx,eax
  117.         jecxz   udone
  118.  
  119.         mov     dl,[esi]
  120.         mov     esi,[outfile]
  121. ;--------------------------------------
  122. uc1:
  123.         lodsb
  124.         sub     al,0E8h
  125.         cmp     al,1
  126.         ja      uc1
  127.  
  128.         cmp     [esi],dl
  129.         jnz     uc1
  130.  
  131.         lodsd
  132.         shr     ax,8
  133.         ror     eax,16
  134.         xchg    al,ah
  135.         sub     eax,esi
  136.         add     eax,[outfile]
  137.         mov     [esi-4],eax
  138.         loop    uc1
  139.         jmp     udone
  140. ;---------------------------------------------------------------------
  141. uctr1:
  142.         add     esi,[insize]
  143.         sub     esi,5
  144.         lodsd
  145.         mov     ecx,eax
  146.         jecxz   udone
  147.  
  148.         mov     dl,[esi]
  149.         mov     esi,[outfile]
  150. ;--------------------------------------
  151. uc2:
  152.         lodsb
  153. ;--------------------------------------
  154. @@:
  155.         cmp     al,15
  156.         jnz     uf
  157.  
  158.         lodsb
  159.         cmp     al,80h
  160.         jb      @b
  161.  
  162.         cmp     al,90h
  163.         jb      @f
  164. ;--------------------------------------
  165. uf:
  166.         sub     al,0E8h
  167.         cmp     al,1
  168.         ja      uc2
  169. ;--------------------------------------
  170. @@:
  171.         cmp     [esi],dl
  172.         jnz     uc2
  173.  
  174.         lodsd
  175.         shr     ax,8
  176.         ror     eax,16
  177.         xchg    al,ah
  178.         sub     eax,esi
  179.         add     eax,[outfile]
  180.         mov     [esi-4],eax
  181.         loop    uc2
  182. ;--------------------------------------
  183. udone:
  184.         mov     esi,unpacked_ok
  185.         push    unpacked_len
  186.         pop     ecx
  187.         call    write_string
  188.         jmp     saveout
  189. ;*********************************************************************
  190. return_memory:
  191.         mov     ecx,[infile]
  192.         test    ecx,ecx
  193.         jz      @f
  194.         mcall   68,13,
  195.         xor     eax,eax
  196.         mov     [infile],eax
  197. @@:
  198.         ret
  199. ;*********************************************************************