Subversion Repositories Kolibri OS

Rev

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