Subversion Repositories Kolibri OS

Rev

Rev 2673 | Rev 3178 | 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.         push    check1
  65.         call    [init_checkbox]
  66.  
  67.         call    clear_messages
  68. ; set default path = /RD/1/
  69.         mov     esi,defpath
  70.         mov     edi,path
  71.         mov     [edi-4],dword 6
  72.         movsw
  73.         movsd
  74. ; get system window info
  75.         xor     eax,eax
  76.         cmp     [params],al
  77.         je      default
  78.        
  79.         mov     edi,path
  80.         mov     esi,params
  81.         call    copy_1
  82.  
  83.         sub     esi,2
  84.         std
  85. @@:
  86.         lodsb
  87.         dec     edi
  88.         cmp     al,byte '/'
  89.         jnz     @r
  90.        
  91.         mov     [edi-1],byte 0
  92.         mov     edi,inname
  93.         add     esi,2
  94.         push    esi
  95.         call    copy_1
  96.         pop     esi
  97.         mov     edi,outname
  98.         call    copy_1
  99. ;---------------------------------------------------------------------
  100.         call    set_editbox_position_all
  101. ;---------------------------------------------------------------------
  102.         call    draw_window
  103.         call    pack
  104.         jmp     OD_initialization
  105. ;*********************************************************************
  106. default:
  107.         mov     esi,definoutname
  108.         mov     edi,esi
  109.         xor     ecx,ecx
  110.         xor     eax,eax
  111.         dec     ecx
  112.         repnz   scasb
  113.         not     ecx
  114.         dec     ecx
  115.         mov     [innamelen],ecx
  116.         push    ecx
  117.         push    esi
  118.         mov     edi,inname
  119.         rep     movsb
  120.         pop     esi
  121.         pop     ecx
  122.         mov     [outnamelen],ecx
  123.         mov     edi,outname
  124.         rep     movsb
  125. ;---------------------------------------------------------------------
  126.         call    set_editbox_position_all
  127. ;---------------------------------------------------------------------
  128. OD_initialization:
  129. ;OpenDialog     initialisation
  130.         push    dword OpenDialog_data
  131.         call    [OpenDialog_Init]
  132. ;---------------------------------------------------------------------
  133. red:
  134.         call    draw_window
  135. ;--------------------------------------
  136. still:
  137.         mcall   10
  138.         dec     eax
  139.         jz      red
  140.  
  141.         dec     eax
  142.         jz      key
  143.  
  144.         dec     eax
  145.         jz      button
  146.  
  147.         push    dword edit1
  148.         call    [edit_box_mouse]
  149.  
  150.         push    dword edit2
  151.         call    [edit_box_mouse]
  152.  
  153.         push    dword edit3
  154.         call    [edit_box_mouse]
  155.  
  156.         push    dword check1
  157.         call    [check_box_mouse]
  158.        
  159.         jmp     still
  160. ;*********************************************************************
  161. tell_compress_mess:
  162.         push    compressing_len
  163.         pop     ecx
  164.         mov     esi,compressing_str
  165.         call    write_string
  166.         ret
  167. ;*********************************************************************
  168. clear_mess_and_displogo:
  169.         call    refresh_editbox_data
  170. ; clear messages
  171.         call    clear_messages
  172. ; display logo
  173.         mov     esi,info_str
  174.         push    info_len
  175.         pop     ecx
  176.         call    write_string
  177.         ret
  178. ;*********************************************************************
  179. clear_messages:
  180.         xor     eax,eax
  181.         mov     ecx,80*20/4+1
  182.         mov     edi,message_mem
  183.         rep     stosd
  184.         ret
  185. ;*********************************************************************
  186. exit:
  187.         xor     eax,eax
  188.         dec     eax
  189.         mcall
  190. ;*********************************************************************
  191. button:
  192. ; button pressed
  193.         mcall   17
  194.         xchg    al,ah
  195.         cmp     al,7
  196.         jz      but7
  197.  
  198.         dec     eax
  199.         jz      exit
  200.  
  201.         dec     eax
  202.         jnz     nopack
  203.  
  204.         mov     eax,[check1+32]
  205.         test    eax,10b
  206.         jnz     @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. ;---------------------------------------------------------------------