Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4835 | mario79 | 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 |
||
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 |
||
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 0x0 |
||
31 | db 'MENUET01' |
||
32 | dd 0x01 |
||
33 | dd START |
||
34 | dd IM_END |
||
35 | dd I_END |
||
36 | dd STACK_TOP |
||
37 | dd 0x0 |
||
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' |
||
4857 | mario79 | 45 | include '../../develop/libraries/box_lib/trunk/box_lib.mac' |
4835 | mario79 | 46 | include '../../develop/libraries/box_lib/load_lib.mac' |
47 | @use_library |
||
48 | ;----------------------------------------------------------------------------- |
||
4857 | mario79 | 49 | struct RESULT_SLOT |
50 | text dd ? |
||
51 | read_speed dd ? |
||
52 | write_speed dd ? |
||
53 | chunk_size dd ? |
||
54 | ends |
||
55 | ;----------------------------------------------------------------------------- |
||
4835 | mario79 | 56 | START: |
57 | DEBUGF 1,'FSPEED: start of programm\n' |
||
58 | ;----------------------------------------------------------------------------- |
||
59 | mcall 68,11 |
||
60 | test eax,eax |
||
61 | jz exit |
||
62 | ;----------------------------------------------------------------------------- |
||
63 | load_libraries l_libs_start,end_l_libs |
||
64 | ;if return code =-1 then exit, else nornary work |
||
65 | inc eax |
||
66 | test eax,eax |
||
67 | jz exit |
||
68 | ;----------------------------------------------------------------------------- |
||
69 | ;OpenDialog initialisation |
||
70 | push dword OpenDialog_data |
||
71 | call [OpenDialog_Init] |
||
4857 | mario79 | 72 | |
73 | push check1 |
||
74 | call [init_checkbox] |
||
75 | |||
76 | mcall 40,0x27 |
||
4835 | mario79 | 77 | ;----------------------------------------------------------------------------- |
78 | red: |
||
79 | call draw_window |
||
80 | ;----------------------------------------------------------------------------- |
||
81 | still: |
||
82 | mcall 10 |
||
83 | cmp eax,1 |
||
84 | je red |
||
85 | |||
86 | cmp eax,2 |
||
87 | je key |
||
88 | |||
89 | cmp eax,3 |
||
90 | je button |
||
91 | |||
4857 | mario79 | 92 | push dword check1 |
93 | call [check_box_mouse] |
||
94 | |||
4835 | mario79 | 95 | jmp still |
96 | ;----------------------------------------------------------------------------- |
||
97 | key: |
||
98 | mcall 2 |
||
99 | jmp still |
||
100 | ;----------------------------------------------------------------------------- |
||
101 | button: |
||
102 | mcall 17 |
||
103 | |||
104 | cmp ah,2 |
||
105 | je select_file |
||
106 | |||
107 | cmp ah,3 |
||
108 | je testing |
||
109 | |||
110 | cmp ah,1 |
||
111 | jne still |
||
112 | ;-------------------------------------- |
||
113 | exit: |
||
114 | mcall -1 |
||
115 | ;----------------------------------------------------------------------------- |
||
116 | select_file: |
||
117 | ; invoke OpenDialog |
||
118 | mov [OpenDialog_data.type],dword 0 |
||
119 | push dword OpenDialog_data |
||
120 | call [OpenDialog_Start] |
||
121 | cmp [OpenDialog_data.status],1 |
||
122 | jne still |
||
123 | ; prepare for PathShow |
||
124 | push dword PathShow_data |
||
125 | call [PathShow_prepare] |
||
126 | |||
127 | call draw_PathShow |
||
128 | jmp still |
||
129 | ;----------------------------------------------------------------------------- |
||
130 | draw_PathShow: |
||
131 | mcall 13,<5,400-20>,<5,15>,0xffffff |
||
132 | ; draw for PathShow |
||
133 | push dword PathShow_data |
||
134 | call [PathShow_draw] |
||
135 | ret |
||
136 | ;----------------------------------------------------------------------------- |
||
137 | draw_window: |
||
138 | mcall 48,3,app_colours,4*10 ; get current colors |
||
139 | |||
140 | mcall 12,1 |
||
141 | xor esi,esi |
||
142 | xor ebp,ebp |
||
143 | mov edx,[w_work] ; color of work area RRGGBB,8->color |
||
144 | or edx,0x34000000 |
||
4857 | mario79 | 145 | mcall 0,<100,400>,<100,300>,,,title |
146 | |||
4835 | mario79 | 147 | call draw_PathShow |
4857 | mario79 | 148 | mov eax,[w_work_text] |
149 | or eax,0x80000000 |
||
150 | mov [check1.text_color],eax |
||
151 | push dword check1 |
||
152 | call [check_box_draw] |
||
153 | |||
4835 | mario79 | 154 | mcall 8,<5,80>,<25,15>,2,[w_work_button] |
4857 | mario79 | 155 | mcall ,<400-65,50>,,3 |
156 | mov ecx,[w_work_button_text] |
||
157 | or ecx,0x80000000 |
||
158 | mcall 4,<5+10,25+4>,,s_text |
||
159 | mcall ,<400-65+10,25+4>,,r_text |
||
160 | mov ecx,[w_work_text] |
||
161 | or ecx,0x80000000 |
||
162 | mcall ,<10,47>,,check_box_warning_text |
||
163 | mcall ,<10,65>,,result_table_text |
||
4835 | mario79 | 164 | |
4857 | mario79 | 165 | mov edx,ecx |
166 | and edx,0xffffff |
||
167 | mcall 38,<5,400-15>,<59,59> |
||
168 | ; draw result table |
||
169 | mov ebx,10 shl 16+77 |
||
4835 | mario79 | 170 | mov ebp,result_table |
171 | mov ecx,18 |
||
172 | ;-------------------------------------- |
||
173 | @@: |
||
174 | push ecx |
||
175 | mov ecx,[w_work_text] |
||
176 | or ecx,0x80000000 |
||
4857 | mario79 | 177 | mcall 4,,,[ebp+RESULT_SLOT.text] |
4835 | mario79 | 178 | push ebx |
179 | mov edx,ebx |
||
4857 | mario79 | 180 | add edx,(11*6) shl 16 |
4835 | mario79 | 181 | mov ebx,0x800a0000 |
4857 | mario79 | 182 | mcall 47,,[ebp+RESULT_SLOT.read_speed],,[w_work_text] |
183 | add edx,(16*6) shl 16 |
||
184 | mcall ,,[ebp+RESULT_SLOT.write_speed] |
||
4835 | mario79 | 185 | pop ebx |
186 | add ebx,6+5 |
||
4857 | mario79 | 187 | add ebp,sizeof.RESULT_SLOT |
4835 | mario79 | 188 | pop ecx |
189 | dec ecx |
||
190 | jnz @b |
||
191 | |||
192 | mcall 12,2 |
||
193 | ret |
||
194 | ;-----------------------------------------------------------------------------;----------------------------------------------------------------------------- |
||
195 | testing: |
||
196 | mcall 70,fileinfo |
||
197 | test eax,eax |
||
198 | jz @f |
||
199 | |||
200 | DEBUGF 1,'FSPEED: file not found %s\n',fname |
||
201 | jmp still |
||
202 | ;-------------------------------------- |
||
203 | @@: |
||
204 | DEBUGF 1,'FSPEED: target file %s\n',fname |
||
205 | mov ebp,result_table |
||
206 | mov ecx,18 |
||
207 | ;-------------------------------------- |
||
208 | @@: |
||
209 | push ecx |
||
210 | call read_chunk |
||
4857 | mario79 | 211 | |
4835 | mario79 | 212 | pusha |
213 | call draw_window |
||
214 | popa |
||
4857 | mario79 | 215 | |
216 | call write_chunk |
||
217 | |||
218 | pusha |
||
219 | call draw_window |
||
220 | popa |
||
221 | |||
222 | pop ecx |
||
223 | add ebp,sizeof.RESULT_SLOT |
||
224 | |||
4835 | mario79 | 225 | dec ecx |
226 | jnz @b |
||
227 | |||
228 | jmp still |
||
229 | ;----------------------------------------------------------------------------- |
||
230 | read_chunk: |
||
231 | mov eax,[file_info+32] ; file size |
||
4857 | mario79 | 232 | cmp [ebp+RESULT_SLOT.chunk_size],eax |
4835 | mario79 | 233 | jb @f |
234 | |||
4857 | mario79 | 235 | xor eax,eax ; small file size for current chunk size |
236 | mov [ebp+RESULT_SLOT.read_speed],eax |
||
4835 | mario79 | 237 | ret |
238 | ;-------------------------------------- |
||
239 | @@: |
||
4857 | mario79 | 240 | mcall 68,12,[ebp+RESULT_SLOT.chunk_size] |
4835 | mario79 | 241 | mov [fileread.return],eax |
242 | xor eax,eax |
||
243 | mov [fileread.offset],eax ; zero current offset |
||
244 | mcall 26,9 ; get start time |
||
245 | add eax,1600 ; 16 sec for iterations |
||
246 | mov esi,eax |
||
247 | mov ecx,1 |
||
4857 | mario79 | 248 | mov eax,[ebp+RESULT_SLOT.chunk_size] |
4835 | mario79 | 249 | mov [fileread.size],eax |
250 | ;-------------------------------------- |
||
251 | .loop: |
||
252 | mcall 70,fileread |
||
253 | |||
254 | mcall 26,9 ; check current time |
||
255 | cmp esi,eax |
||
256 | jbe .end |
||
257 | ; correct offset |
||
4857 | mario79 | 258 | mov edx,[ebp+RESULT_SLOT.chunk_size] |
4835 | mario79 | 259 | add [fileread.offset],edx ; current offset |
260 | ; check offset and file size |
||
261 | mov edx,[file_info+32] ; file size |
||
4857 | mario79 | 262 | sub edx,[ebp+RESULT_SLOT.chunk_size] |
4835 | mario79 | 263 | cmp [fileread.offset],edx |
264 | jbe @f |
||
265 | |||
266 | xor edx,edx |
||
267 | mov [fileread.offset],edx ; zero current offset |
||
268 | ;-------------------------------------- |
||
269 | @@: |
||
270 | inc ecx |
||
271 | jmp .loop |
||
272 | ;-------------------------------------- |
||
273 | .end: |
||
4857 | mario79 | 274 | mov eax,[ebp+RESULT_SLOT.chunk_size] |
4837 | mario79 | 275 | xor edx,edx |
4840 | mario79 | 276 | mul ecx |
4837 | mario79 | 277 | shr eax,10+4 ;div 1024 ; div 16 |
278 | shl edx,18 |
||
279 | add eax,edx |
||
4857 | mario79 | 280 | mov [ebp+RESULT_SLOT.read_speed],eax ; speed KB/s |
281 | DEBUGF 1,'FSPEED: read chunk size: %s iterations: %d speed: %d KB/s\n',\ |
||
282 | [ebp+RESULT_SLOT.text],ecx,eax |
||
4835 | mario79 | 283 | mcall 68,13,[fileread.return] |
284 | ret |
||
285 | ;----------------------------------------------------------------------------- |
||
4857 | mario79 | 286 | write_chunk: |
287 | test [check1.flags],dword 10b |
||
288 | jz .exit |
||
289 | |||
290 | mov eax,[file_info+32] ; file size |
||
291 | cmp [ebp+RESULT_SLOT.chunk_size],eax |
||
292 | jb @f |
||
293 | ;-------------------------------------- |
||
294 | .exit: |
||
295 | xor eax,eax ; small file size for current chunk size |
||
296 | mov [ebp+RESULT_SLOT.write_speed],eax |
||
297 | ret |
||
298 | ;-------------------------------------- |
||
299 | @@: |
||
300 | mcall 68,12,[ebp+RESULT_SLOT.chunk_size] |
||
301 | mov [filewrite.data],eax |
||
302 | xor eax,eax |
||
303 | mov [filewrite.offset],eax ; zero current offset |
||
304 | mcall 26,9 ; get start time |
||
305 | add eax,1600 ; 16 sec for iterations |
||
306 | mov esi,eax |
||
307 | mov ecx,1 |
||
308 | mov eax,[ebp+RESULT_SLOT.chunk_size] |
||
309 | mov [filewrite.size],eax |
||
310 | ;-------------------------------------- |
||
311 | .loop: |
||
312 | mcall 70,filewrite |
||
313 | |||
314 | mcall 26,9 ; check current time |
||
315 | cmp esi,eax |
||
316 | jbe .end |
||
317 | ; correct offset |
||
318 | mov edx,[ebp+RESULT_SLOT.chunk_size] |
||
319 | add [filewrite.offset],edx ; current offset |
||
320 | ; check offset and file size |
||
321 | mov edx,[file_info+32] ; file size |
||
322 | sub edx,[ebp+RESULT_SLOT.chunk_size] |
||
323 | cmp [filewrite.offset],edx |
||
324 | jbe @f |
||
325 | |||
326 | xor edx,edx |
||
327 | mov [filewrite.offset],edx ; zero current offset |
||
328 | ;-------------------------------------- |
||
329 | @@: |
||
330 | inc ecx |
||
331 | jmp .loop |
||
332 | ;-------------------------------------- |
||
333 | .end: |
||
334 | mov eax,[ebp+RESULT_SLOT.chunk_size] |
||
335 | xor edx,edx |
||
336 | mul ecx |
||
337 | shr eax,10+4 ;div 1024 ; div 16 |
||
338 | shl edx,18 |
||
339 | add eax,edx |
||
340 | mov [ebp+RESULT_SLOT.write_speed],eax ; speed KB/s |
||
341 | DEBUGF 1,'FSPEED: write chunk size: %s iterations: %d speed: %d KB/s\n',\ |
||
342 | [ebp+RESULT_SLOT.text],ecx,eax |
||
343 | mcall 68,13,[filewrite.data] |
||
344 | ret |
||
345 | ;----------------------------------------------------------------------------- |
||
4835 | mario79 | 346 | include 'idata.inc' |
347 | ;----------------------------------------------------------------------------- |
||
348 | IM_END: |
||
349 | ;----------------------------------------------------------------------------- |
||
350 | include 'udata.inc' |
||
351 | ;----------------------------------------------------------------------------- |
||
352 | I_END: |
||
353 | ;-----------------------------------------------------------------------------59,59>5,400-15>10,65>10,47>400-65+10,25+4>5+10,25+4>400-65,50>25,15>5,80>100,300>100,400>5,15>5,400-20> |