Subversion Repositories Kolibri OS

Rev

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