Subversion Repositories Kolibri OS

Rev

Rev 2273 | Rev 3177 | 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.         xor     eax,eax
  73.         cmp     [params],al
  74.         je      default
  75.        
  76.         mov     edi,path
  77.         mov     esi,params
  78.         call    copy_1
  79.  
  80.         sub     esi,2
  81.         std
  82. @@:
  83.         lodsb
  84.         dec     edi
  85.         cmp     al,byte '/'
  86.         jnz     @r
  87.        
  88.         mov     [edi-1],byte 0
  89.         mov     edi,inname
  90.         add     esi,2
  91.         push    esi
  92.         call    copy_1
  93.         pop     esi
  94.         mov     edi,outname
  95.         call    copy_1
  96. ;---------------------------------------------------------------------
  97.         call    set_editbox_position_all
  98. ;---------------------------------------------------------------------
  99.         call    draw_window
  100.         call    pack
  101.         jmp     OD_initialization
  102. ;*********************************************************************
  103. default:
  104.         mov     esi,definoutname
  105.         mov     edi,esi
  106.         xor     ecx,ecx
  107.         xor     eax,eax
  108.         dec     ecx
  109.         repnz   scasb
  110.         not     ecx
  111.         dec     ecx
  112.         mov     [innamelen],ecx
  113.         push    ecx
  114.         push    esi
  115.         mov     edi,inname
  116.         rep     movsb
  117.         pop     esi
  118.         pop     ecx
  119.         mov     [outnamelen],ecx
  120.         mov     edi,outname
  121.         rep     movsb
  122. ;---------------------------------------------------------------------
  123.         call    set_editbox_position_all
  124. ;---------------------------------------------------------------------
  125. OD_initialization:
  126. ;OpenDialog     initialisation
  127.         push    dword OpenDialog_data
  128.         call    [OpenDialog_Init]
  129. ;---------------------------------------------------------------------
  130. red:
  131.         call    draw_window
  132. ;--------------------------------------
  133. still:
  134.         mcall   10
  135.         dec     eax
  136.         jz      red
  137.  
  138.         dec     eax
  139.         jz      key
  140.  
  141.         dec     eax
  142.         jz      button
  143.  
  144.         push    dword edit1
  145.         call    [edit_box_mouse]
  146.  
  147.         push    dword edit2
  148.         call    [edit_box_mouse]
  149.  
  150.         push    dword edit3
  151.         call    [edit_box_mouse]
  152.  
  153.         push    dword check1
  154.         call    [check_box_mouse]
  155.        
  156.         jmp     still
  157. ;*********************************************************************
  158. tell_compress_mess:
  159.         push    compressing_len
  160.         pop     ecx
  161.         mov     esi,compressing_str
  162.         call    write_string
  163.         ret
  164. ;*********************************************************************
  165. clear_mess_and_displogo:
  166.         call    refresh_editbox_data
  167. ; clear messages
  168.         call    clear_messages
  169. ; display logo
  170.         mov     esi,info_str
  171.         push    info_len
  172.         pop     ecx
  173.         call    write_string
  174.         ret
  175. ;*********************************************************************
  176. clear_messages:
  177.         xor     eax,eax
  178.         mov     ecx,80*20/4+1
  179.         mov     edi,message_mem
  180.         rep     stosd
  181.         ret
  182. ;*********************************************************************
  183. exit:
  184.         xor     eax,eax
  185.         dec     eax
  186.         mcall
  187. ;*********************************************************************
  188. button:
  189. ; button pressed
  190.         mcall   17
  191.         xchg    al,ah
  192.         cmp     al,7
  193.         jz      but7
  194.  
  195.         dec     eax
  196.         jz      exit
  197.  
  198.         dec     eax
  199.         jnz     nopack
  200.  
  201.         mov     eax,[check1+32]
  202.         test    eax,10b
  203.         jnz     @f
  204.  
  205.         call    pack
  206.         jmp     still
  207. ;--------------------------------------------------------------------- 
  208. @@:
  209.         call    kerpack
  210.         jmp     still  
  211. ;---------------------------------------------------------------------
  212. nopack:
  213.         dec     eax
  214.         jnz     nounpack
  215.        
  216.         call    unpack
  217.         jmp     still
  218. ;--------------------------------------------------------------------- 
  219. but7:
  220.         call    clear_messages
  221. ; display logo
  222.         mov     esi,info_str
  223.         push    info_len
  224.         pop     ecx
  225.         call    write_string
  226. ; display info
  227.         mov     esi,usage_str
  228.         mov     ecx,usage_len
  229.         call    write_string
  230.         jmp     still
  231. ;---------------------------------------------------------------------
  232. nounpack:
  233.         dec     eax
  234.         jnz     still
  235.  
  236.         call    OpenDialog_start
  237.         jmp     still
  238. ;*********************************************************************
  239. OpenDialog_start:
  240.         mov     esi,path
  241.         mov     edi,temp_dir_pach
  242.         call    copy_1 
  243.  
  244.         push    dword OpenDialog_data
  245.         call    [OpenDialog_Start]
  246.         cmp     [OpenDialog_data.status],1
  247.         jne     @f
  248.  
  249.         mov     esi,filename_area
  250.         mov     edi,inname
  251.         call    copy_1
  252.  
  253.         mov     esi,filename_area
  254.         mov     edi,outname
  255.         call    copy_1
  256.        
  257.         mov     esi,temp_dir_pach
  258.         mov     edi,path
  259.         call    copy_1
  260.        
  261.         call    refresh_editbox_data
  262.  
  263.         call    set_editbox_position_all
  264.  
  265.         call    draw_editbox
  266. @@:
  267.         ret
  268. ;*********************************************************************
  269. copy_1:
  270.         xor     eax,eax
  271.         cld    
  272. @@:
  273.         lodsb
  274.         stosb
  275.         test    eax,eax
  276.         jnz     @r
  277.         ret
  278. ;*********************************************************************
  279. refresh_editbox_data:
  280.         mov     esi,inname
  281.         mov     edi,innamelen
  282.         call    refresh_data
  283.  
  284.         mov     esi,outname
  285.         mov     edi,outnamelen
  286.         call    refresh_data
  287.  
  288.         mov     esi,path
  289.         mov     edi,pathlen
  290.         call    refresh_data
  291.  
  292.         ret
  293. ;*********************************************************************
  294. refresh_data:
  295.         push    esi
  296.         xor     eax,eax
  297.         cld    
  298. @@:
  299.         lodsb
  300.         test    eax,eax
  301.         jnz     @r
  302.         pop     eax
  303.         sub     esi,eax
  304.         dec     esi
  305.         mov     [edi],esi
  306.         ret
  307. ;*********************************************************************
  308. set_editbox_position_all:
  309.         mov     ebx,inname
  310.         mov     edi,edit1
  311.         call    set_editbox_position
  312.  
  313.         mov     ebx,outname
  314.         mov     edi,edit2
  315.         call    set_editbox_position
  316.  
  317.         mov     ebx,path
  318.         mov     edi,edit3
  319.         call    set_editbox_position
  320.         ret
  321. ;*********************************************************************
  322. key:
  323.         mcall   2
  324.  
  325.         push    dword edit1
  326.         call    [edit_box_key]
  327.  
  328.         push    dword edit2
  329.         call    [edit_box_key]
  330.  
  331.         push    dword edit3
  332.         call    [edit_box_key]
  333.  
  334.         jmp     still
  335. ;*********************************************************************
  336. get_full_name:
  337.         push    esi
  338.         mov     esi,path
  339.         mov     ecx,[esi-4]
  340.         mov     edi,fullname
  341.         rep     movsb
  342.         mov     al,'/'
  343.         cmp     [edi-1],al
  344.         jz      @f
  345.  
  346.         stosb
  347. ;--------------------------------------
  348. @@:
  349.         pop     esi
  350.         cmp     [esi],al
  351.         jnz     @f
  352.  
  353.         mov     edi,fullname
  354. ;--------------------------------------
  355. @@:
  356.         mov     ecx,[esi-4]
  357.         rep     movsb
  358.         xor     eax,eax
  359.         stosb
  360.         ret
  361. ;*********************************************************************
  362. write_string:
  363. ; in: esi=pointer, ecx=length
  364.         mov     edx,[message_cur_pos]
  365. ;--------------------------------------
  366. x1:
  367.         lea     edi,[message_mem+edx]
  368. ;--------------------------------------
  369. do_write_char:
  370.         lodsb
  371.         cmp     al,10
  372.         jz      newline
  373.  
  374.         stosb
  375.         inc     edx
  376.         loop    do_write_char
  377.         jmp     x2
  378. ;---------------------------------------------------------------------
  379. newline:
  380.         xor     eax,eax
  381.         stosb
  382.         xchg    eax,edx
  383.         push    ecx
  384.         push    eax
  385.         mov     ecx,80
  386.         div     ecx
  387.         pop     eax
  388.         xchg    eax,edx
  389.         sub     edx,eax
  390.         add     edx,ecx
  391.         pop     ecx
  392.         loop    x1
  393. ;--------------------------------------
  394. x2:
  395.         mov     [message_cur_pos],edx
  396. ; update window
  397.         mcall   13,<6,414>,<54,222>,[color_table+20]
  398. ;--------------------------------------
  399. draw_messages:
  400.         mov     ebx,12 shl 16+60
  401.         mov     edi,message_mem
  402. ;--------------------------------------
  403. @@:
  404.         push    edi
  405.         xor     eax,eax
  406.         push    80
  407.         pop     ecx
  408.         repnz   scasb
  409.         sub     ecx,79
  410.         neg     ecx
  411.         mov     esi,ecx
  412.         pop     edi
  413.         mcall   4,,[color_table+32],edi
  414.         add     ebx,10
  415.         add     edi,80
  416.         cmp     edi,message_cur_pos
  417.         jb      @b
  418.  
  419.         ret
  420. ;*********************************************************************
  421. draw_window:
  422. ; start redraw
  423.         mcall   12,1
  424.        
  425.         mcall   48,3,color_table,40
  426. ;--------------------------------------
  427. edit_boxes_set_sys_color edit1,editboxes_end,color_table
  428. check_boxes_set_sys_color check1,check1_end,color_table
  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>,<1, 17>,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   ,<364,6>,,aCompress
  547.         mcall   ,<359,24>,,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. ;---------------------------------------------------------------------