Subversion Repositories Kolibri OS

Rev

Rev 1686 | Rev 1702 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ; kpack = Kolibri Packer
  2. ;---------------------------------------------------------------------
  3. ; version:      0.15
  4. ; last update:  06/11/2010
  5. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  6. ; changes:      1) Window Y=4, B=1
  7. ;               2) Refresh lenght of data after Editbox editing
  8. ;               3) Changed format of start parameter -
  9. ;                    longer path (total length 255 + zero).
  10. ;---------------------------------------------------------------------
  11. ; version:      0.14
  12. ; last update:  03/11/2010
  13. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  14. ; changes:      select path with OpenDialog,
  15. ;               using Box_Lib and Proc_Lib
  16. ;---------------------------------------------------------------------
  17. ; Kpack - Kolibri Packer
  18. ; Kolibri version
  19. ; Written by diamond in 2006, 2007 specially for KolibriOS
  20. ;
  21. ; Disassemled and corrected in 2010 specially for FASM
  22. ;            by Marat Zakiyanov aka Mario79, aka Mario
  23. ;
  24. ; Uses LZMA compression library by Igor Pavlov
  25. ; (for more information on LZMA and 7-Zip visit http://www.7-zip.org)
  26. ; (plain-C packer and ASM unpacker are ported by diamond)
  27. ;---------------------------------------------------------------------
  28. use32
  29.         org     0
  30.  
  31.         db 'MENUET01'
  32.         dd 1
  33.         dd START
  34.         dd IM_END
  35.         dd I_END
  36.         dd stacktop
  37.         dd params
  38.         dd cur_dir_path
  39. ;---------------------------------------------------------------------
  40. include '../../../macros.inc'
  41. include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
  42. include '../../../develop/libraries/box_lib/load_lib.mac'
  43.   @use_library
  44.  
  45. START:
  46.         mcall   68,11
  47.         mcall   40,100111b
  48.  
  49. load_libraries l_libs_start,load_lib_end
  50.         cmp eax,-1
  51.         je exit
  52.  
  53.         call    clear_messages
  54. ; set default path = /RD/1/
  55.         mov     esi,defpath
  56.         mov     edi,path
  57.         mov     [edi-4],dword 6
  58.         movsw
  59.         movsd
  60. ; get system window info
  61.         mcall   48,3,color_table,40
  62. ;--------------------------------------
  63.         xor     eax,eax
  64.         cmp     [params],al
  65.         je      default
  66.        
  67.         mov     edi,path
  68.         mov     esi,params
  69.         call    copy_1
  70.  
  71.         sub     esi,2
  72.         std
  73. @@:
  74.         lodsb
  75.         dec     edi
  76.         cmp     al,byte '/'
  77.         jnz     @r
  78.        
  79.         mov     [edi-1],byte 0
  80.         mov     edi,inname
  81.         add     esi,2
  82.         push    esi
  83.         call    copy_1
  84.         pop     esi
  85.         mov     edi,outname
  86.         call    copy_1
  87. ;---------------------------------------------------------------------
  88.         call    set_editbox_position_all
  89. ;---------------------------------------------------------------------
  90.         call    draw_window
  91.         call    pack
  92.         jmp     OD_initialization
  93. ;*********************************************************************
  94. default:
  95.         mov     esi,definoutname
  96.         mov     edi,esi
  97.         xor     ecx,ecx
  98.         xor     eax,eax
  99.         dec     ecx
  100.         repnz   scasb
  101.         not     ecx
  102.         dec     ecx
  103.         mov     [innamelen],ecx
  104.         push    ecx
  105.         push    esi
  106.         mov     edi,inname
  107.         rep     movsb
  108.         pop     esi
  109.         pop     ecx
  110.         mov     [outnamelen],ecx
  111.         mov     edi,outname
  112.         rep     movsb
  113. ;---------------------------------------------------------------------
  114.         call    set_editbox_position_all
  115. ;---------------------------------------------------------------------
  116. OD_initialization:
  117. ;OpenDialog     initialisation
  118.         push    dword OpenDialog_data
  119.         call    [OpenDialog_Init]
  120. ;---------------------------------------------------------------------
  121. red:
  122.         call    draw_window
  123. ;--------------------------------------
  124. still:
  125.         mcall   10
  126.         dec     eax
  127.         jz      red
  128.  
  129.         dec     eax
  130.         jz      key
  131.  
  132.         dec     eax
  133.         jz      button
  134.  
  135.         push    dword edit1
  136.         call    [edit_box_mouse]
  137.  
  138.         push    dword edit2
  139.         call    [edit_box_mouse]
  140.  
  141.         push    dword edit3
  142.         call    [edit_box_mouse]
  143.  
  144.         jmp     still
  145. ;*********************************************************************
  146. clear_messages:
  147.         xor     eax,eax
  148.         mov     ecx,80*20/4+1
  149.         mov     edi,message_mem
  150.         rep     stosd
  151.         ret
  152. ;*********************************************************************
  153. exit:
  154.         xor     eax,eax
  155.         dec     eax
  156.         mcall
  157. ;*********************************************************************
  158. button:
  159. ; button pressed
  160.         mcall   17
  161.         xchg    al,ah
  162.         cmp     al,7
  163.         jz      but7
  164.  
  165.         dec     eax
  166.         jz      exit
  167.  
  168.         dec     eax
  169.         jnz     nopack
  170.  
  171.         call    pack
  172.         jmp     still
  173. ;---------------------------------------------------------------------
  174. nopack:
  175.         dec     eax
  176.         jnz     nounpack
  177.  
  178.         call    unpack
  179.         jmp     still
  180. ;---------------------------------------------------------------------
  181. but7:
  182.         call    clear_messages
  183. ; display logo
  184.         mov     esi,info_str
  185.         push    info_len
  186.         pop     ecx
  187.         call    write_string
  188. ; display info
  189.         mov     esi,usage_str
  190.         mov     ecx,usage_len
  191.         call    write_string
  192.         jmp     still
  193. ;---------------------------------------------------------------------
  194. nounpack:
  195.         dec     eax
  196.         jnz     still
  197.  
  198.         call    OpenDialog_start
  199.         jmp     still
  200. ;*********************************************************************
  201. OpenDialog_start:
  202.         mov     esi,path
  203.         mov     edi,temp_dir_pach
  204.         call    copy_1 
  205.  
  206.         push    dword OpenDialog_data
  207.         call    [OpenDialog_Start]
  208.         cmp     [OpenDialog_data.status],1
  209.         jne     @f
  210.  
  211.         mov     esi,filename_area
  212.         mov     edi,inname
  213.         call    copy_1
  214.  
  215.         mov     esi,filename_area
  216.         mov     edi,outname
  217.         call    copy_1
  218.        
  219.         mov     esi,temp_dir_pach
  220.         mov     edi,path
  221.         call    copy_1
  222.        
  223.         call    refresh_editbox_data
  224.  
  225.         call    set_editbox_position_all
  226.  
  227.         call    draw_editbox
  228. @@:
  229.         ret
  230. ;*********************************************************************
  231. copy_1:
  232.         xor     eax,eax
  233.         cld    
  234. @@:
  235.         lodsb
  236.         stosb
  237.         test    eax,eax
  238.         jnz     @r
  239.         ret
  240. ;*********************************************************************
  241. refresh_editbox_data:
  242.         mov     esi,inname
  243.         mov     edi,innamelen
  244.         call    refresh_data
  245.  
  246.         mov     esi,outname
  247.         mov     edi,outnamelen
  248.         call    refresh_data
  249.  
  250.         mov     esi,path
  251.         mov     edi,pathlen
  252.         call    refresh_data
  253.  
  254.         ret
  255. ;*********************************************************************
  256. refresh_data:
  257.         push    esi
  258.         xor     eax,eax
  259.         cld    
  260. @@:
  261.         lodsb
  262.         test    eax,eax
  263.         jnz     @r
  264.         pop     eax
  265.         sub     esi,eax
  266.         dec     esi
  267.         mov     [edi],esi
  268.         ret
  269. ;*********************************************************************
  270. set_editbox_position_all:
  271.         mov     ebx,inname
  272.         mov     edi,edit1
  273.         call    set_editbox_position
  274.  
  275.         mov     ebx,outname
  276.         mov     edi,edit2
  277.         call    set_editbox_position
  278.  
  279.         mov     ebx,path
  280.         mov     edi,edit3
  281.         call    set_editbox_position
  282.         ret
  283. ;*********************************************************************
  284. key:
  285.         mcall   2
  286.  
  287.         push    dword edit1
  288.         call    [edit_box_key]
  289.  
  290.         push    dword edit2
  291.         call    [edit_box_key]
  292.  
  293.         push    dword edit3
  294.         call    [edit_box_key]
  295.  
  296.         jmp     still
  297. ;*********************************************************************
  298. get_full_name:
  299.         push    esi
  300.         mov     esi,path
  301.         mov     ecx,[esi-4]
  302.         mov     edi,fullname
  303.         rep     movsb
  304.         mov     al,'/'
  305.         cmp     [edi-1],al
  306.         jz      @f
  307.  
  308.         stosb
  309. ;--------------------------------------
  310. @@:
  311.         pop     esi
  312.         cmp     [esi],al
  313.         jnz     @f
  314.  
  315.         mov     edi,fullname
  316. ;--------------------------------------
  317. @@:
  318.         mov     ecx,[esi-4]
  319.         rep     movsb
  320.         xor     eax,eax
  321.         stosb
  322.         ret
  323. ;*********************************************************************
  324. write_string:
  325. ; in: esi=pointer, ecx=length
  326.         mov     edx,[message_cur_pos]
  327. ;--------------------------------------
  328. x1:
  329.         lea     edi,[message_mem+edx]
  330. ;--------------------------------------
  331. do_write_char:
  332.         lodsb
  333.         cmp     al,10
  334.         jz      newline
  335.  
  336.         stosb
  337.         inc     edx
  338.         loop    do_write_char
  339.         jmp     x2
  340. ;---------------------------------------------------------------------
  341. newline:
  342.         xor     eax,eax
  343.         stosb
  344.         xchg    eax,edx
  345.         push    ecx
  346.         push    eax
  347.         mov     ecx,80
  348.         div     ecx
  349.         pop     eax
  350.         xchg    eax,edx
  351.         sub     edx,eax
  352.         add     edx,ecx
  353.         pop     ecx
  354.         loop    x1
  355. ;--------------------------------------
  356. x2:
  357.         mov     [message_cur_pos],edx
  358. ; update window
  359.         mcall   13,<6,414>,<54,222>,[color_table+20]
  360. ;--------------------------------------
  361. draw_messages:
  362.         mov     ebx,12 shl 16+60
  363.         mov     edi,message_mem
  364. ;--------------------------------------
  365. @@:
  366.         push    edi
  367.         xor     eax,eax
  368.         push    80
  369.         pop     ecx
  370.         repnz   scasb
  371.         sub     ecx,79
  372.         neg     ecx
  373.         mov     esi,ecx
  374.         pop     edi
  375.         mcall   4,,[color_table+32],edi
  376.         add     ebx,10
  377.         add     edi,80
  378.         cmp     edi,message_cur_pos
  379.         jb      @b
  380.  
  381.         ret
  382. ;*********************************************************************
  383. draw_window:
  384. ; start redraw
  385.         mcall   12,1
  386. ;--------------------------------------
  387. ; define window
  388.         xor     eax,eax
  389.         mov     ecx,100 shl 16+306
  390.         mov     edx,[color_table+20]
  391.         add     edx,34000000h
  392.         xor     esi,esi
  393.         xor     edi,edi
  394.         mcall   ,<100,436>,,,,caption_str
  395.         mcall   9,procinfo,-1
  396. ;--------------------------------------
  397. ; draw lines and frame
  398.         call    draw_lines
  399. ; draw buttons
  400.         call    draw_bittons
  401. ; draw messages
  402.         call    draw_messages
  403. ; draw editbox's
  404.         mov     eax,[procinfo+42]
  405.         sub     eax,65+72+10
  406.         mov     [edit1.width],eax
  407.         mov     [edit2.width],eax
  408.         mov     [edit3.width],eax
  409.  
  410.         call    draw_editbox
  411. ; end redraw
  412.         mcall   12,2
  413.         ret
  414. ;*********************************************************************
  415. draw_editbox:
  416.         push    dword edit1
  417.         call    [edit_box_draw]
  418.         push    dword edit2
  419.         call    [edit_box_draw]
  420.         push    dword edit3
  421.         call    [edit_box_draw]
  422.         ret
  423. ;*********************************************************************
  424. set_editbox_position:
  425.         mov     esi,ebx
  426.         cld
  427. @@:
  428.         lodsb
  429.         test    al,al
  430.         jne     @r
  431.         sub     esi,ebx
  432.         mov     eax,esi
  433.         dec     eax
  434.         mov     [edi+48], eax  ;ed_size
  435.         mov     [edi+52], eax  ;ed_pos
  436.         ret
  437. ;*********************************************************************
  438. draw_lines:
  439.         mov     ecx,2 shl 16+12*3
  440. ; draw frame for messages data
  441.         push    ecx
  442.         add     ecx,50 shl 16+16
  443.         mcall   38,<3,423>,,[color_table+36]
  444.         add     ecx,224*(1 shl 16+1)
  445.         mcall
  446.         sub     cx,224
  447.         mcall   ,<3,3>
  448.         mcall   ,<423,423>
  449.         pop     ecx
  450.         ret
  451. ;*********************************************************************
  452. draw_bittons:
  453. ; define compress button
  454.         mov     cx,18
  455.         mcall   8,<351,72>,,2,[color_table+36]
  456. ; uncompress button
  457.         add     ecx,18 shl 16
  458.         inc     edx
  459.         mcall
  460.         add     ecx,-12h+0Ah+140000h
  461. ; question button
  462.         push    esi
  463.         mov     dl,7
  464.         mcall   ,<414,9>
  465.         shr     ecx,16
  466.         lea     ebx,[ecx+1A10002h]
  467.         mcall   4,,[color_table+28],aQuestion,1
  468.         pop     esi
  469. ; define settings buttons
  470.         mov     ecx,16*2+2
  471.         shl     ecx,16
  472.         mov     cx,13
  473.         mcall   8,<6,50>,,4
  474. ; text on settings buttons
  475.         mov     ebx,9 shl 16+5
  476.         mov     al,4
  477.         mov     ecx,[color_table+28]
  478.         push    buttons1names
  479.         pop     edx
  480.         push    8
  481.         pop     esi
  482. ;--------------------------------------
  483. @@:
  484.         mcall
  485.         add     edx,esi
  486.         add     ebx,16
  487.         cmp     [edx-6],byte ' '
  488.         jnz     @b
  489. ; text on compress and decompress buttons
  490.         or      ecx,80000000h
  491.         mcall   ,<367,7>,,aCompress
  492.         mcall   ,<359,25>,,aDecompress
  493.         ret
  494. ;*********************************************************************
  495. ;Pack procedures
  496. include 'packpoc.inc'
  497. ;---------------------------------------------------------------------
  498. ;UnPack procedures
  499. include 'upacproc.inc'
  500. ;---------------------------------------------------------------------
  501. ;lzma_compress:
  502. include 'lzma_compress.inc'
  503. ;---------------------------------------------------------------------
  504. ;lzma_set_dict_size:
  505. include 'lzma_set_dict_size.inc'
  506. ;---------------------------------------------------------------------
  507. ;lzma_decompress:
  508. include 'lzma_decompress.inc'
  509. ;---------------------------------------------------------------------
  510. ;initialized variables and constants
  511. include 'const_var.inc'
  512. ;---------------------------------------------------------------------
  513. IM_END:
  514. ;---------------------------------------------------------------------
  515. ;uninitialized data
  516. include 'data.inc'
  517. ;---------------------------------------------------------------------
  518. I_END:
  519. ;---------------------------------------------------------------------