Subversion Repositories Kolibri OS

Rev

Rev 7899 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;*****************************************************************************
  2. ; File Speed - for Kolibri OS
  3. ; Copyright (c) 2014, Marat Zakiyanov aka Mario79, aka Mario
  4. ; All rights reserved.
  5. ;
  6. ; Redistribution and use in source and binary forms, with or without
  7. ; modification, are permitted provided that the following conditions are met:
  8. ;        * Redistributions of source code must retain the above copyright
  9. ;          notice, this list of conditions and the following disclaimer.
  10. ;        * Redistributions in binary form must reproduce the above copyright
  11. ;          notice, this list of conditions and the following disclaimer in the
  12. ;          documentation and/or other materials provided with the distribution.
  13. ;        * Neither the name of the <organization> nor the
  14. ;          names of its contributors may be used to endorse or promote products
  15. ;          derived from this software without specific prior written permission.
  16. ;
  17. ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
  18. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  21. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. ;*****************************************************************************
  28. ;-----------------------------------------------------------------------------
  29.         use32
  30.         org 0
  31.         db 'MENUET01'
  32.         dd 1
  33.         dd START
  34.         dd IM_END
  35.         dd I_END
  36.         dd STACK_TOP
  37.         dd 0
  38.         dd cur_dir_path
  39. ;-----------------------------------------------------------------------------
  40. include 'lang.inc'
  41. include '../../macros.inc'
  42. define __DEBUG__ 1
  43. define __DEBUG_LEVEL__ 1
  44. include '../../debug-fdo.inc'
  45. include '../../develop/libraries/box_lib/trunk/box_lib.mac'
  46. include '../../KOSfuncs.inc'
  47. include '../../load_lib.mac'
  48.         @use_library
  49. ;-----------------------------------------------------------------------------
  50. struct  RESULT_SLOT
  51.         text            dd ?
  52.         read_speed      dd ?
  53.         write_speed     dd ?
  54.         chunk_size      dd ?
  55. ends
  56. ;-----------------------------------------------------------------------------
  57. START:
  58.         DEBUGF 1,'FSPEED: start of programm\n'
  59. ;----------------------------------------------------------------------------- 
  60.         mcall   68,11
  61.         test    eax,eax
  62.         jz      exit   
  63. ;----------------------------------------------------------------------------- 
  64. load_libraries l_libs_start,end_l_libs
  65. ;if return code =-1 then exit, else nornary work
  66.         inc     eax
  67.         test    eax,eax
  68.         jz      exit
  69. ;-----------------------------------------------------------------------------
  70. ;OpenDialog     initialisation
  71.         push    dword OpenDialog_data
  72.         call    [OpenDialog_Init]
  73.  
  74.         push    check1
  75.         call    [init_checkbox]
  76.  
  77.         mcall   40,0x27
  78. ;-----------------------------------------------------------------------------
  79. red:
  80.         call    draw_window
  81. ;-----------------------------------------------------------------------------
  82. still:
  83.         mcall   10
  84.         cmp     eax,1
  85.         je      red
  86.  
  87.         cmp     eax,2
  88.         je      key
  89.  
  90.         cmp     eax,3
  91.         je      button
  92.  
  93.         push    dword check1
  94.         call    [check_box_mouse]
  95.  
  96.         jmp     still
  97. ;-----------------------------------------------------------------------------
  98. key:
  99.         mcall   2
  100.         jmp     still
  101. ;-----------------------------------------------------------------------------
  102. button:
  103.         mcall   17
  104.  
  105.         cmp     ah,2
  106.         je      select_file
  107.  
  108.         cmp     ah,3
  109.         je      testing
  110.  
  111.         cmp     ah,1
  112.         jne     still
  113. ;--------------------------------------
  114. exit:
  115.         mcall   -1
  116. ;-----------------------------------------------------------------------------
  117. select_file:
  118. ; invoke OpenDialog
  119.         mov     [OpenDialog_data.type],dword 0
  120.         push    dword OpenDialog_data
  121.         call    [OpenDialog_Start]
  122.         cmp     [OpenDialog_data.status],1
  123.         jne     still
  124. ; prepare for PathShow
  125.         push    dword PathShow_data
  126.         call    [PathShow_prepare]
  127.  
  128.         call    draw_PathShow
  129.         jmp     still
  130. ;-----------------------------------------------------------------------------
  131. draw_PathShow:
  132.         mcall   13,<5,400-20>,<5,15>,0xffffff
  133. ; draw for PathShow
  134.         push    dword PathShow_data
  135.         call    [PathShow_draw]
  136.         ret
  137. ;-----------------------------------------------------------------------------
  138. draw_window:
  139.         mcall   48,3,app_colours,4*10   ; get current colors
  140.  
  141.         mcall   12,1
  142.         xor     esi,esi
  143.         xor     ebp,ebp
  144.         mov     edx,[w_work]    ; color of work area RRGGBB,8->color
  145.         or      edx,0x34000000
  146.         mcall   0,<100,400>,<100,300>,,,title
  147.  
  148.         call    draw_PathShow
  149.         mov     eax,[w_work_text]
  150.         or      eax,0x80000000
  151.         mov     [check1.text_color],eax
  152.         push    dword check1
  153.         call    [check_box_draw]
  154.        
  155.         mcall   8,<5,80>,<25,15>,2,[w_work_button]
  156.         mcall   ,<400-65,50>,,3
  157.         mov     ecx,[w_work_button_text]
  158.         or      ecx,0x80000000
  159.         mcall   4,<5+10,25+4>,,s_text
  160.         mcall   ,<400-65+10,25+4>,,r_text
  161.         mov     ecx,[w_work_text]
  162.         or      ecx,0x80000000
  163.         mcall   ,<10,47>,,check_box_warning_text
  164.         mcall   ,<10,65>,,result_table_text
  165.        
  166.         mov     edx,ecx
  167.         and     edx,0xffffff
  168.         mcall   38,<5,400-15>,<59,59>
  169. ; draw result table    
  170.         mov     ebx,10 shl 16+77
  171.         mov     ebp,result_table
  172.         mov     ecx,18
  173. ;--------------------------------------
  174. @@:
  175.         push    ecx
  176.         mov     ecx,[w_work_text]
  177.         or      ecx,0x80000000 
  178.         mcall   4,,,[ebp+RESULT_SLOT.text]
  179.         push    ebx
  180.         mov     edx,ebx
  181.         add     edx,(11*6) shl 16
  182.         mov     ebx,0x800a0000
  183.         mcall   47,,[ebp+RESULT_SLOT.read_speed],,[w_work_text]
  184.         add     edx,(16*6) shl 16
  185.         mcall   ,,[ebp+RESULT_SLOT.write_speed]
  186.         pop     ebx
  187.         add     ebx,6+5
  188.         add     ebp,sizeof.RESULT_SLOT
  189.         pop     ecx
  190.         dec     ecx
  191.         jnz     @b
  192.  
  193.         mcall   12,2
  194.         ret
  195. ;-----------------------------------------------------------------------------;-----------------------------------------------------------------------------
  196. testing:
  197.         mcall   70,fileinfo
  198.         test    eax,eax
  199.         jz      @f
  200.        
  201.         DEBUGF 1,'FSPEED: file not found %s\n',fname
  202.         jmp     still
  203. ;--------------------------------------
  204. @@:
  205.         DEBUGF 1,'FSPEED: target file %s\n',fname
  206.         mov     ebp,result_table
  207.         mov     ecx,18
  208. ;--------------------------------------
  209. @@:
  210.         push    ecx
  211.         call    read_chunk
  212.  
  213.         pusha
  214.         call    draw_window
  215.         popa
  216.  
  217.         call    write_chunk
  218.  
  219.         pusha
  220.         call    draw_window
  221.         popa
  222.  
  223.         pop     ecx
  224.         add     ebp,sizeof.RESULT_SLOT
  225.  
  226.         dec     ecx
  227.         jnz     @b
  228.  
  229.         jmp     still
  230. ;-----------------------------------------------------------------------------
  231. read_chunk:
  232.         mov     eax,[file_info+32] ; file size
  233.         cmp     [ebp+RESULT_SLOT.chunk_size],eax
  234.         jb      @f
  235.        
  236.         xor     eax,eax ; small file size for current chunk size
  237.         mov     [ebp+RESULT_SLOT.read_speed],eax
  238.         ret
  239. ;--------------------------------------
  240. @@:
  241.         mcall   68,12,[ebp+RESULT_SLOT.chunk_size]
  242.         mov     [fileread.return],eax
  243.         xor     eax,eax
  244.         mov     [fileread.offset],eax ; zero current offset
  245.         mcall   26,9 ; get start time
  246.         add     eax,1600 ; 16 sec for iterations
  247.         mov     esi,eax
  248.         mov     ecx,1
  249.         mov     eax,[ebp+RESULT_SLOT.chunk_size]
  250.         mov     [fileread.size],eax
  251. ;--------------------------------------
  252. .loop:
  253.         mcall   70,fileread
  254.        
  255.         mcall   26,9 ; check current time
  256.         cmp     esi,eax
  257.         jbe     .end
  258. ; correct offset       
  259.         mov     edx,[ebp+RESULT_SLOT.chunk_size]
  260.         add     [fileread.offset],edx ; current offset
  261. ; check offset and file size   
  262.         mov     edx,[file_info+32] ; file size
  263.         sub     edx,[ebp+RESULT_SLOT.chunk_size]
  264.         cmp     [fileread.offset],edx
  265.         jbe     @f     
  266.        
  267.         xor     edx,edx
  268.         mov     [fileread.offset],edx ; zero current offset
  269. ;--------------------------------------
  270. @@:
  271.         inc     ecx
  272.         jmp     .loop
  273. ;--------------------------------------
  274. .end:  
  275.         mov     eax,[ebp+RESULT_SLOT.chunk_size]
  276.         xor     edx,edx
  277.         mul     ecx
  278.         shr     eax,10+4 ;div 1024 ; div 16
  279.         shl     edx,18
  280.         add     eax,edx
  281.         mov     [ebp+RESULT_SLOT.read_speed],eax ; speed KB/s  
  282.         DEBUGF 1,'FSPEED: read chunk size: %s iterations: %d speed: %d KB/s\n',\
  283.                 [ebp+RESULT_SLOT.text],ecx,eax
  284.         mcall   68,13,[fileread.return]
  285.         ret
  286. ;-----------------------------------------------------------------------------
  287. write_chunk:
  288.         test    [check1.flags],dword 10b
  289.         jz      .exit
  290.  
  291.         mov     eax,[file_info+32] ; file size
  292.         cmp     [ebp+RESULT_SLOT.chunk_size],eax
  293.         jb      @f
  294. ;--------------------------------------
  295. .exit:
  296.         xor     eax,eax ; small file size for current chunk size
  297.         mov     [ebp+RESULT_SLOT.write_speed],eax
  298.         ret
  299. ;--------------------------------------
  300. @@:
  301.         mcall   68,12,[ebp+RESULT_SLOT.chunk_size]
  302.         mov     [filewrite.data],eax
  303.         xor     eax,eax
  304.         mov     [filewrite.offset],eax ; zero current offset
  305.         mcall   26,9 ; get start time
  306.         add     eax,1600 ; 16 sec for iterations
  307.         mov     esi,eax
  308.         mov     ecx,1
  309.         mov     eax,[ebp+RESULT_SLOT.chunk_size]
  310.         mov     [filewrite.size],eax
  311. ;--------------------------------------
  312. .loop:
  313.         mcall   70,filewrite
  314.        
  315.         mcall   26,9 ; check current time
  316.         cmp     esi,eax
  317.         jbe     .end
  318. ; correct offset       
  319.         mov     edx,[ebp+RESULT_SLOT.chunk_size]
  320.         add     [filewrite.offset],edx ; current offset
  321. ; check offset and file size   
  322.         mov     edx,[file_info+32] ; file size
  323.         sub     edx,[ebp+RESULT_SLOT.chunk_size]
  324.         cmp     [filewrite.offset],edx
  325.         jbe     @f     
  326.        
  327.         xor     edx,edx
  328.         mov     [filewrite.offset],edx ; zero current offset
  329. ;--------------------------------------
  330. @@:
  331.         inc     ecx
  332.         jmp     .loop
  333. ;--------------------------------------
  334. .end:  
  335.         mov     eax,[ebp+RESULT_SLOT.chunk_size]
  336.         xor     edx,edx
  337.         mul     ecx
  338.         shr     eax,10+4 ;div 1024 ; div 16
  339.         shl     edx,18
  340.         add     eax,edx
  341.         mov     [ebp+RESULT_SLOT.write_speed],eax ; speed KB/s 
  342.         DEBUGF 1,'FSPEED: write chunk size: %s iterations: %d speed: %d KB/s\n',\
  343.                 [ebp+RESULT_SLOT.text],ecx,eax
  344.         mcall   68,13,[filewrite.data]
  345.         ret
  346. ;-----------------------------------------------------------------------------
  347. include 'idata.inc'
  348. ;-----------------------------------------------------------------------------
  349. IM_END:
  350. ;-----------------------------------------------------------------------------
  351. include 'udata.inc'
  352. ;-----------------------------------------------------------------------------
  353. I_END:
  354. ;-----------------------------------------------------------------------------
  355.