Subversion Repositories Kolibri OS

Rev

Rev 2058 | Rev 2262 | 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. ;--------------------------------------
  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.         mov     eax,[check1+32]
  206.         test    eax,10b
  207.         jnz     @f
  208.  
  209.         call    pack
  210.         jmp     still
  211. ;--------------------------------------------------------------------- 
  212. @@:
  213.         call    kerpack
  214.         jmp     still  
  215. ;---------------------------------------------------------------------
  216. nopack:
  217.         dec     eax
  218.         jnz     nounpack
  219.        
  220.         call    unpack
  221.         jmp     still
  222. ;--------------------------------------------------------------------- 
  223. but7:
  224.         call    clear_messages
  225. ; display logo
  226.         mov     esi,info_str
  227.         push    info_len
  228.         pop     ecx
  229.         call    write_string
  230. ; display info
  231.         mov     esi,usage_str
  232.         mov     ecx,usage_len
  233.         call    write_string
  234.         jmp     still
  235. ;---------------------------------------------------------------------
  236. nounpack:
  237.         dec     eax
  238.         jnz     still
  239.  
  240.         call    OpenDialog_start
  241.         jmp     still
  242. ;*********************************************************************
  243. OpenDialog_start:
  244.         mov     esi,path
  245.         mov     edi,temp_dir_pach
  246.         call    copy_1 
  247.  
  248.         push    dword OpenDialog_data
  249.         call    [OpenDialog_Start]
  250.         cmp     [OpenDialog_data.status],1
  251.         jne     @f
  252.  
  253.         mov     esi,filename_area
  254.         mov     edi,inname
  255.         call    copy_1
  256.  
  257.         mov     esi,filename_area
  258.         mov     edi,outname
  259.         call    copy_1
  260.        
  261.         mov     esi,temp_dir_pach
  262.         mov     edi,path
  263.         call    copy_1
  264.        
  265.         call    refresh_editbox_data
  266.  
  267.         call    set_editbox_position_all
  268.  
  269.         call    draw_editbox
  270. @@:
  271.         ret
  272. ;*********************************************************************
  273. copy_1:
  274.         xor     eax,eax
  275.         cld    
  276. @@:
  277.         lodsb
  278.         stosb
  279.         test    eax,eax
  280.         jnz     @r
  281.         ret
  282. ;*********************************************************************
  283. refresh_editbox_data:
  284.         mov     esi,inname
  285.         mov     edi,innamelen
  286.         call    refresh_data
  287.  
  288.         mov     esi,outname
  289.         mov     edi,outnamelen
  290.         call    refresh_data
  291.  
  292.         mov     esi,path
  293.         mov     edi,pathlen
  294.         call    refresh_data
  295.  
  296.         ret
  297. ;*********************************************************************
  298. refresh_data:
  299.         push    esi
  300.         xor     eax,eax
  301.         cld    
  302. @@:
  303.         lodsb
  304.         test    eax,eax
  305.         jnz     @r
  306.         pop     eax
  307.         sub     esi,eax
  308.         dec     esi
  309.         mov     [edi],esi
  310.         ret
  311. ;*********************************************************************
  312. set_editbox_position_all:
  313.         mov     ebx,inname
  314.         mov     edi,edit1
  315.         call    set_editbox_position
  316.  
  317.         mov     ebx,outname
  318.         mov     edi,edit2
  319.         call    set_editbox_position
  320.  
  321.         mov     ebx,path
  322.         mov     edi,edit3
  323.         call    set_editbox_position
  324.         ret
  325. ;*********************************************************************
  326. key:
  327.         mcall   2
  328.  
  329.         push    dword edit1
  330.         call    [edit_box_key]
  331.  
  332.         push    dword edit2
  333.         call    [edit_box_key]
  334.  
  335.         push    dword edit3
  336.         call    [edit_box_key]
  337.  
  338.         jmp     still
  339. ;*********************************************************************
  340. get_full_name:
  341.         push    esi
  342.         mov     esi,path
  343.         mov     ecx,[esi-4]
  344.         mov     edi,fullname
  345.         rep     movsb
  346.         mov     al,'/'
  347.         cmp     [edi-1],al
  348.         jz      @f
  349.  
  350.         stosb
  351. ;--------------------------------------
  352. @@:
  353.         pop     esi
  354.         cmp     [esi],al
  355.         jnz     @f
  356.  
  357.         mov     edi,fullname
  358. ;--------------------------------------
  359. @@:
  360.         mov     ecx,[esi-4]
  361.         rep     movsb
  362.         xor     eax,eax
  363.         stosb
  364.         ret
  365. ;*********************************************************************
  366. write_string:
  367. ; in: esi=pointer, ecx=length
  368.         mov     edx,[message_cur_pos]
  369. ;--------------------------------------
  370. x1:
  371.         lea     edi,[message_mem+edx]
  372. ;--------------------------------------
  373. do_write_char:
  374.         lodsb
  375.         cmp     al,10
  376.         jz      newline
  377.  
  378.         stosb
  379.         inc     edx
  380.         loop    do_write_char
  381.         jmp     x2
  382. ;---------------------------------------------------------------------
  383. newline:
  384.         xor     eax,eax
  385.         stosb
  386.         xchg    eax,edx
  387.         push    ecx
  388.         push    eax
  389.         mov     ecx,80
  390.         div     ecx
  391.         pop     eax
  392.         xchg    eax,edx
  393.         sub     edx,eax
  394.         add     edx,ecx
  395.         pop     ecx
  396.         loop    x1
  397. ;--------------------------------------
  398. x2:
  399.         mov     [message_cur_pos],edx
  400. ; update window
  401.         mcall   13,<6,414>,<54,222>,[color_table+20]
  402. ;--------------------------------------
  403. draw_messages:
  404.         mov     ebx,12 shl 16+60
  405.         mov     edi,message_mem
  406. ;--------------------------------------
  407. @@:
  408.         push    edi
  409.         xor     eax,eax
  410.         push    80
  411.         pop     ecx
  412.         repnz   scasb
  413.         sub     ecx,79
  414.         neg     ecx
  415.         mov     esi,ecx
  416.         pop     edi
  417.         mcall   4,,[color_table+32],edi
  418.         add     ebx,10
  419.         add     edi,80
  420.         cmp     edi,message_cur_pos
  421.         jb      @b
  422.  
  423.         ret
  424. ;*********************************************************************
  425. draw_window:
  426. ; start redraw
  427.         mcall   12,1
  428. ;--------------------------------------
  429. ; define window
  430.         xor     eax,eax
  431.         mov     ecx,100 shl 16+306
  432.         mov     edx,[color_table+20]
  433.         add     edx,34000000h
  434.         xor     esi,esi
  435.         xor     edi,edi
  436.         mcall   ,<100,436>,,,,caption_str
  437.         mcall   9,procinfo,-1
  438.        
  439.         mov     eax,[procinfo+70] ;status of window
  440.         test    eax,100b
  441.         jne     .end   
  442. ;--------------------------------------
  443. ; draw lines and frame
  444.         call    draw_lines
  445. ; draw buttons
  446.         call    draw_bittons
  447. ; draw messages
  448.         call    draw_messages
  449. ; draw editbox's
  450.         mov     eax,[procinfo+42]
  451.         sub     eax,65+72+10
  452.         mov     [edit1.width],eax
  453.         mov     [edit2.width],eax
  454.         mov     [edit3.width],eax
  455.  
  456.         call    draw_editbox
  457. ; end redraw
  458. .end:
  459.         mcall   12,2
  460.         ret
  461. ;*********************************************************************
  462. draw_editbox:
  463.         push    dword edit1
  464.         call    [edit_box_draw]
  465.        
  466.         push    dword edit2
  467.         call    [edit_box_draw]
  468.        
  469.         push    dword edit3
  470.         call    [edit_box_draw]
  471.        
  472.         push    dword check1
  473.         call    [check_box_draw]
  474.         ret
  475. ;*********************************************************************
  476. set_editbox_position:
  477.         mov     esi,ebx
  478.         cld
  479. @@:
  480.         lodsb
  481.         test    al,al
  482.         jne     @r
  483.         sub     esi,ebx
  484.         mov     eax,esi
  485.         dec     eax
  486.         mov     [edi+48], eax  ;ed_size
  487.         mov     [edi+52], eax  ;ed_pos
  488.         ret
  489. ;*********************************************************************
  490. draw_lines:
  491.         mov     ecx,2 shl 16+12*3
  492. ; draw frame for messages data
  493.         push    ecx
  494.         add     ecx,50 shl 16+16
  495.         mcall   38,<3,423>,,[color_table+36]
  496.         add     ecx,224*(1 shl 16+1)
  497.         mcall
  498.         sub     cx,224
  499.         mcall   ,<3,3>
  500.         mcall   ,<423,423>
  501.         pop     ecx
  502.         ret
  503. ;*********************************************************************
  504. draw_bittons:
  505. ; define compress button
  506.         mov     cx,18
  507.         mcall   8,<351,72>,,2,[color_table+36]
  508. ; uncompress button
  509.         add     ecx,18 shl 16
  510.         inc     edx
  511.         mcall
  512.         add     ecx,-12h+0Ah+140000h
  513. ; question button
  514.         push    esi
  515.         mov     dl,7
  516.         mcall   ,<414,9>
  517.         shr     ecx,16
  518.         lea     ebx,[ecx+1A10002h]
  519.         mcall   4,,[color_table+28],aQuestion,1
  520.         pop     esi
  521. ; define settings buttons
  522.         mov     ecx,16*2+2
  523.         shl     ecx,16
  524.         mov     cx,13
  525.         mcall   8,<6,50>,,4
  526. ; text on settings buttons
  527.         mov     ebx,9 shl 16+5
  528.         mov     al,4
  529.         mov     ecx,[color_table+28]
  530.         push    buttons1names
  531.         pop     edx
  532.         push    8
  533.         pop     esi
  534. ;--------------------------------------
  535. @@:
  536.         mcall
  537.         add     edx,esi
  538.         add     ebx,16
  539.         cmp     [edx-6],byte ' '
  540.         jnz     @b
  541. ; text on compress and decompress buttons
  542.         or      ecx,80000000h
  543.         mcall   ,<367,7>,,aCompress
  544.         mcall   ,<359,25>,,aDecompress
  545.         ret
  546. ;*********************************************************************
  547. ;Pack procedures
  548. include 'packpoc.inc'
  549. ;---------------------------------------------------------------------
  550. ;UnPack procedures
  551. include 'upacproc.inc'
  552. ;---------------------------------------------------------------------
  553. ;lzma_compress:
  554. include 'lzma_compress.inc'
  555. ;---------------------------------------------------------------------
  556. ;lzma_set_dict_size:
  557. include 'lzma_set_dict_size.inc'
  558. ;---------------------------------------------------------------------
  559. ;lzma_decompress:
  560. include 'lzma_decompress.inc'
  561. ;---------------------------------------------------------------------
  562. ;kerpack code:
  563. include 'kerpack.inc'
  564. ;---------------------------------------------------------------------
  565. ;initialized variables and constants
  566. include 'const_var.inc'
  567. ;---------------------------------------------------------------------
  568. IM_END:
  569. ;---------------------------------------------------------------------
  570. ;uninitialized data
  571. include 'data.inc'
  572. ;---------------------------------------------------------------------
  573. I_END:
  574. ;---------------------------------------------------------------------