Subversion Repositories Kolibri OS

Rev

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