Subversion Repositories Kolibri OS

Rev

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

  1. ; kpack = Kolibri Packer
  2. ;---------------------------------------------------------------------
  3. ; version:      0.20
  4. ; last update:  08/18/2011
  5. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  6. ; changes:      Checking for "rolled up" window
  7. ;---------------------------------------------------------------------
  8. ; version:      0.20
  9. ; last update:  07/12/2010
  10. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  11. ; changes:      Added code for packing the kernel.mnt
  12. ;---------------------------------------------------------------------
  13. ; version:      0.15
  14. ; last update:  06/11/2010
  15. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  16. ; changes:      1) Window Y=4, B=1
  17. ;               2) Refresh lenght of data after Editbox editing
  18. ;               3) Changed format of start parameter -
  19. ;                    longer path (total length 255 + zero).
  20. ;---------------------------------------------------------------------
  21. ; version:      0.14
  22. ; last update:  03/11/2010
  23. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  24. ; changes:      select path with OpenDialog,
  25. ;               using Box_Lib and Proc_Lib
  26. ;---------------------------------------------------------------------
  27. ; Kpack - Kolibri Packer
  28. ; Kolibri version
  29. ; Written by diamond in 2006, 2007 specially for KolibriOS
  30. ;
  31. ; Disassemled and corrected in 2010 specially for FASM
  32. ;            by Marat Zakiyanov aka Mario79, aka Mario
  33. ;
  34. ; Uses LZMA compression library by Igor Pavlov
  35. ; (for more information on LZMA and 7-Zip visit http://www.7-zip.org)
  36. ; (plain-C packer and ASM unpacker are ported by diamond)
  37. ;---------------------------------------------------------------------
  38. use32
  39.         org     0
  40.  
  41.         db 'MENUET01'
  42.         dd 1
  43.         dd START
  44.         dd IM_END
  45.         dd I_END
  46.         dd stacktop
  47.         dd params
  48.         dd cur_dir_path
  49. ;---------------------------------------------------------------------
  50. include '../../../config.inc'           ;for nightbuild
  51. include '../../../macros.inc'
  52. include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
  53. include '../../../develop/libraries/box_lib/load_lib.mac'
  54.   @use_library
  55.  
  56. START:
  57.         mcall   68,11
  58.         mcall   40,100111b
  59.  
  60. load_libraries l_libs_start,load_lib_end
  61.         cmp eax,-1
  62.         je exit
  63.  
  64.         call    clear_messages
  65. ; set default path = /RD/1/
  66.         mov     esi,defpath
  67.         mov     edi,path
  68.         mov     [edi-4],dword 6
  69.         movsw
  70.         movsd
  71. ; get system window info
  72.         mcall   48,3,color_table,40
  73. ;--------------------------------------
  74.         xor     eax,eax
  75.         cmp     [params],al
  76.         je      default
  77.        
  78.         mov     edi,path
  79.         mov     esi,params
  80.         call    copy_1
  81.  
  82.         sub     esi,2
  83.         std
  84. @@:
  85.         lodsb
  86.         dec     edi
  87.         cmp     al,byte '/'
  88.         jnz     @r
  89.        
  90.         mov     [edi-1],byte 0
  91.         mov     edi,inname
  92.         add     esi,2
  93.         push    esi
  94.         call    copy_1
  95.         pop     esi
  96.         mov     edi,outname
  97.         call    copy_1
  98. ;---------------------------------------------------------------------
  99.         call    set_editbox_position_all
  100. ;---------------------------------------------------------------------
  101.         call    draw_window
  102.         call    pack
  103.         jmp     OD_initialization
  104. ;*********************************************************************
  105. default:
  106.         mov     esi,definoutname
  107.         mov     edi,esi
  108.         xor     ecx,ecx
  109.         xor     eax,eax
  110.         dec     ecx
  111.         repnz   scasb
  112.         not     ecx
  113.         dec     ecx
  114.         mov     [innamelen],ecx
  115.         push    ecx
  116.         push    esi
  117.         mov     edi,inname
  118.         rep     movsb
  119.         pop     esi
  120.         pop     ecx
  121.         mov     [outnamelen],ecx
  122.         mov     edi,outname
  123.         rep     movsb
  124. ;---------------------------------------------------------------------
  125.         call    set_editbox_position_all
  126. ;---------------------------------------------------------------------
  127. OD_initialization:
  128. ;OpenDialog     initialisation
  129.         push    dword OpenDialog_data
  130.         call    [OpenDialog_Init]
  131. ;---------------------------------------------------------------------
  132. red:
  133.         call    draw_window
  134. ;--------------------------------------
  135. still:
  136.         mcall   10
  137.         dec     eax
  138.         jz      red
  139.  
  140.         dec     eax
  141.         jz      key
  142.  
  143.         dec     eax
  144.         jz      button
  145.  
  146.         push    dword edit1
  147.         call    [edit_box_mouse]
  148.  
  149.         push    dword edit2
  150.         call    [edit_box_mouse]
  151.  
  152.         push    dword edit3
  153.         call    [edit_box_mouse]
  154.  
  155.         push    dword check1
  156.         call    [check_box_mouse]
  157.        
  158.         jmp     still
  159. ;*********************************************************************
  160. tell_compress_mess:
  161.         push    compressing_len
  162.         pop     ecx
  163.         mov     esi,compressing_str
  164.         call    write_string
  165.         ret
  166. ;*********************************************************************
  167. clear_mess_and_displogo:
  168.         call    refresh_editbox_data
  169. ; clear messages
  170.         call    clear_messages
  171. ; display logo
  172.         mov     esi,info_str
  173.         push    info_len
  174.         pop     ecx
  175.         call    write_string
  176.         ret
  177. ;*********************************************************************
  178. clear_messages:
  179.         xor     eax,eax
  180.         mov     ecx,80*20/4+1
  181.         mov     edi,message_mem
  182.         rep     stosd
  183.         ret
  184. ;*********************************************************************
  185. exit:
  186.         xor     eax,eax
  187.         dec     eax
  188.         mcall
  189. ;*********************************************************************
  190. button:
  191. ; button pressed
  192.         mcall   17
  193.         xchg    al,ah
  194.         cmp     al,7
  195.         jz      but7
  196.  
  197.         dec     eax
  198.         jz      exit
  199.  
  200.         dec     eax
  201.         jnz     nopack
  202.  
  203.         mov     eax,[check1+32]
  204.         test    eax,10b
  205.         jnz     @f
  206.  
  207.         call    pack
  208.         jmp     still
  209. ;--------------------------------------------------------------------- 
  210. @@:
  211.         call    kerpack
  212.         jmp     still  
  213. ;---------------------------------------------------------------------
  214. nopack:
  215.         dec     eax
  216.         jnz     nounpack
  217.        
  218.         call    unpack
  219.         jmp     still
  220. ;--------------------------------------------------------------------- 
  221. but7:
  222.         call    clear_messages
  223. ; display logo
  224.         mov     esi,info_str
  225.         push    info_len
  226.         pop     ecx
  227.         call    write_string
  228. ; display info
  229.         mov     esi,usage_str
  230.         mov     ecx,usage_len
  231.         call    write_string
  232.         jmp     still
  233. ;---------------------------------------------------------------------
  234. nounpack:
  235.         dec     eax
  236.         jnz     still
  237.  
  238.         call    OpenDialog_start
  239.         jmp     still
  240. ;*********************************************************************
  241. OpenDialog_start:
  242.         mov     esi,path
  243.         mov     edi,temp_dir_pach
  244.         call    copy_1 
  245.  
  246.         push    dword OpenDialog_data
  247.         call    [OpenDialog_Start]
  248.         cmp     [OpenDialog_data.status],1
  249.         jne     @f
  250.  
  251.         mov     esi,filename_area
  252.         mov     edi,inname
  253.         call    copy_1
  254.  
  255.         mov     esi,filename_area
  256.         mov     edi,outname
  257.         call    copy_1
  258.        
  259.         mov     esi,temp_dir_pach
  260.         mov     edi,path
  261.         call    copy_1
  262.        
  263.         call    refresh_editbox_data
  264.  
  265.         call    set_editbox_position_all
  266.  
  267.         call    draw_editbox
  268. @@:
  269.         ret
  270. ;*********************************************************************
  271. copy_1:
  272.         xor     eax,eax
  273.         cld    
  274. @@:
  275.         lodsb
  276.         stosb
  277.         test    eax,eax
  278.         jnz     @r
  279.         ret
  280. ;*********************************************************************
  281. refresh_editbox_data:
  282.         mov     esi,inname
  283.         mov     edi,innamelen
  284.         call    refresh_data
  285.  
  286.         mov     esi,outname
  287.         mov     edi,outnamelen
  288.         call    refresh_data
  289.  
  290.         mov     esi,path
  291.         mov     edi,pathlen
  292.         call    refresh_data
  293.  
  294.         ret
  295. ;*********************************************************************
  296. refresh_data:
  297.         push    esi
  298.         xor     eax,eax
  299.         cld    
  300. @@:
  301.         lodsb
  302.         test    eax,eax
  303.         jnz     @r
  304.         pop     eax
  305.         sub     esi,eax
  306.         dec     esi
  307.         mov     [edi],esi
  308.         ret
  309. ;*********************************************************************
  310. set_editbox_position_all:
  311.         mov     ebx,inname
  312.         mov     edi,edit1
  313.         call    set_editbox_position
  314.  
  315.         mov     ebx,outname
  316.         mov     edi,edit2
  317.         call    set_editbox_position
  318.  
  319.         mov     ebx,path
  320.         mov     edi,edit3
  321.         call    set_editbox_position
  322.         ret
  323. ;*********************************************************************
  324. key:
  325.         mcall   2
  326.  
  327.         push    dword edit1
  328.         call    [edit_box_key]
  329.  
  330.         push    dword edit2
  331.         call    [edit_box_key]
  332.  
  333.         push    dword edit3
  334.         call    [edit_box_key]
  335.  
  336.         jmp     still
  337. ;*********************************************************************
  338. get_full_name:
  339.         push    esi
  340.         mov     esi,path
  341.         mov     ecx,[esi-4]
  342.         mov     edi,fullname
  343.         rep     movsb
  344.         mov     al,'/'
  345.         cmp     [edi-1],al
  346.         jz      @f
  347.  
  348.         stosb
  349. ;--------------------------------------
  350. @@:
  351.         pop     esi
  352.         cmp     [esi],al
  353.         jnz     @f
  354.  
  355.         mov     edi,fullname
  356. ;--------------------------------------
  357. @@:
  358.         mov     ecx,[esi-4]
  359.         rep     movsb
  360.         xor     eax,eax
  361.         stosb
  362.         ret
  363. ;*********************************************************************
  364. write_string:
  365. ; in: esi=pointer, ecx=length
  366.         mov     edx,[message_cur_pos]
  367. ;--------------------------------------
  368. x1:
  369.         lea     edi,[message_mem+edx]
  370. ;--------------------------------------
  371. do_write_char:
  372.         lodsb
  373.         cmp     al,10
  374.         jz      newline
  375.  
  376.         stosb
  377.         inc     edx
  378.         loop    do_write_char
  379.         jmp     x2
  380. ;---------------------------------------------------------------------
  381. newline:
  382.         xor     eax,eax
  383.         stosb
  384.         xchg    eax,edx
  385.         push    ecx
  386.         push    eax
  387.         mov     ecx,80
  388.         div     ecx
  389.         pop     eax
  390.         xchg    eax,edx
  391.         sub     edx,eax
  392.         add     edx,ecx
  393.         pop     ecx
  394.         loop    x1
  395. ;--------------------------------------
  396. x2:
  397.         mov     [message_cur_pos],edx
  398. ; update window
  399.         mcall   13,<6,414>,<54,222>,[color_table+20]
  400. ;--------------------------------------
  401. draw_messages:
  402.         mov     ebx,12 shl 16+60
  403.         mov     edi,message_mem
  404. ;--------------------------------------
  405. @@:
  406.         push    edi
  407.         xor     eax,eax
  408.         push    80
  409.         pop     ecx
  410.         repnz   scasb
  411.         sub     ecx,79
  412.         neg     ecx
  413.         mov     esi,ecx
  414.         pop     edi
  415.         mcall   4,,[color_table+32],edi
  416.         add     ebx,10
  417.         add     edi,80
  418.         cmp     edi,message_cur_pos
  419.         jb      @b
  420.  
  421.         ret
  422. ;*********************************************************************
  423. draw_window:
  424. ; start redraw
  425.         mcall   12,1
  426. ;--------------------------------------
  427. ; define window
  428.         xor     eax,eax
  429.         mov     ecx,100 shl 16+306
  430.         mov     edx,[color_table+20]
  431.         add     edx,34000000h
  432.         xor     esi,esi
  433.         xor     edi,edi
  434.         mcall   ,<100,436>,,,,caption_str
  435.         mcall   9,procinfo,-1
  436.        
  437.         mov     eax,[procinfo+70] ;status of window
  438.         test    eax,100b
  439.         jne     .end   
  440. ;--------------------------------------
  441. ; draw lines and frame
  442.         call    draw_lines
  443. ; draw buttons
  444.         call    draw_bittons
  445. ; draw messages
  446.         call    draw_messages
  447. ; draw editbox's
  448.         mov     eax,[procinfo+42]
  449.         sub     eax,65+72+10
  450.         mov     [edit1.width],eax
  451.         mov     [edit2.width],eax
  452.         mov     [edit3.width],eax
  453.  
  454.         call    draw_editbox
  455. ; end redraw
  456. .end:
  457.         mcall   12,2
  458.         ret
  459. ;*********************************************************************
  460. draw_editbox:
  461.         push    dword edit1
  462.         call    [edit_box_draw]
  463.        
  464.         push    dword edit2
  465.         call    [edit_box_draw]
  466.        
  467.         push    dword edit3
  468.         call    [edit_box_draw]
  469.        
  470.         push    dword check1
  471.         call    [check_box_draw]
  472.         ret
  473. ;*********************************************************************
  474. set_editbox_position:
  475.         mov     esi,ebx
  476.         cld
  477. @@:
  478.         lodsb
  479.         test    al,al
  480.         jne     @r
  481.         sub     esi,ebx
  482.         mov     eax,esi
  483.         dec     eax
  484.         mov     [edi+48], eax  ;ed_size
  485.         mov     [edi+52], eax  ;ed_pos
  486.         ret
  487. ;*********************************************************************
  488. draw_lines:
  489.         mov     ecx,2 shl 16+12*3
  490. ; draw frame for messages data
  491.         push    ecx
  492.         add     ecx,50 shl 16+16
  493.         mcall   38,<3,423>,,[color_table+36]
  494.         add     ecx,224*(1 shl 16+1)
  495.         mcall
  496.         sub     cx,224
  497.         mcall   ,<3,3>
  498.         mcall   ,<423,423>
  499.         pop     ecx
  500.         ret
  501. ;*********************************************************************
  502. draw_bittons:
  503. ; define compress button
  504.         mov     cx,18
  505.         mcall   8,<351,72>,,2,[color_table+36]
  506. ; uncompress button
  507.         add     ecx,18 shl 16
  508.         inc     edx
  509.         mcall
  510.         add     ecx,-12h+0Ah+140000h
  511. ; question button
  512.         push    esi
  513.         mov     dl,7
  514.         mcall   ,<414,9>
  515.         shr     ecx,16
  516.         lea     ebx,[ecx+1A10002h]
  517.         mcall   4,,[color_table+28],aQuestion,1
  518.         pop     esi
  519. ; define settings buttons
  520.         mov     ecx,16*2+2
  521.         shl     ecx,16
  522.         mov     cx,13
  523.         mcall   8,<6,50>,,4
  524. ; text on settings buttons
  525.         mov     ebx,9 shl 16+5
  526.         mov     al,4
  527.         mov     ecx,[color_table+28]
  528.         push    buttons1names
  529.         pop     edx
  530.         push    8
  531.         pop     esi
  532. ;--------------------------------------
  533. @@:
  534.         mcall
  535.         add     edx,esi
  536.         add     ebx,16
  537.         cmp     [edx-6],byte ' '
  538.         jnz     @b
  539. ; text on compress and decompress buttons
  540.         or      ecx,80000000h
  541.         mcall   ,<367,7>,,aCompress
  542.         mcall   ,<359,25>,,aDecompress
  543.         ret
  544. ;*********************************************************************
  545. ;Pack procedures
  546. include 'packpoc.inc'
  547. ;---------------------------------------------------------------------
  548. ;UnPack procedures
  549. include 'upacproc.inc'
  550. ;---------------------------------------------------------------------
  551. ;lzma_compress:
  552. include 'lzma_compress.inc'
  553. ;---------------------------------------------------------------------
  554. ;lzma_set_dict_size:
  555. include 'lzma_set_dict_size.inc'
  556. ;---------------------------------------------------------------------
  557. ;lzma_decompress:
  558. include 'lzma_decompress.inc'
  559. ;---------------------------------------------------------------------
  560. ;kerpack code:
  561. include 'kerpack.inc'
  562. ;---------------------------------------------------------------------
  563. ;initialized variables and constants
  564. include 'const_var.inc'
  565. ;---------------------------------------------------------------------
  566. IM_END:
  567. ;---------------------------------------------------------------------
  568. ;uninitialized data
  569. include 'data.inc'
  570. ;---------------------------------------------------------------------
  571. I_END:
  572. ;---------------------------------------------------------------------