Subversion Repositories Kolibri OS

Rev

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