Rev 4837 | Go to most recent revision | Details | Compare with Previous | 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' |
||
45 | include '../../develop/libraries/box_lib/load_lib.mac' |
||
46 | @use_library |
||
47 | ;----------------------------------------------------------------------------- |
||
48 | START: |
||
49 | DEBUGF 1,'FSPEED: start of programm\n' |
||
50 | ;----------------------------------------------------------------------------- |
||
51 | mcall 68,11 |
||
52 | test eax,eax |
||
53 | jz exit |
||
54 | ;----------------------------------------------------------------------------- |
||
55 | load_libraries l_libs_start,end_l_libs |
||
56 | ;if return code =-1 then exit, else nornary work |
||
57 | inc eax |
||
58 | test eax,eax |
||
59 | jz exit |
||
60 | ;----------------------------------------------------------------------------- |
||
61 | ;OpenDialog initialisation |
||
62 | push dword OpenDialog_data |
||
63 | call [OpenDialog_Init] |
||
64 | ;----------------------------------------------------------------------------- |
||
65 | red: |
||
66 | call draw_window |
||
67 | ;----------------------------------------------------------------------------- |
||
68 | still: |
||
69 | mcall 10 |
||
70 | cmp eax,1 |
||
71 | je red |
||
72 | |||
73 | cmp eax,2 |
||
74 | je key |
||
75 | |||
76 | cmp eax,3 |
||
77 | je button |
||
78 | |||
79 | jmp still |
||
80 | ;----------------------------------------------------------------------------- |
||
81 | key: |
||
82 | mcall 2 |
||
83 | jmp still |
||
84 | ;----------------------------------------------------------------------------- |
||
85 | button: |
||
86 | mcall 17 |
||
87 | |||
88 | cmp ah,2 |
||
89 | je select_file |
||
90 | |||
91 | cmp ah,3 |
||
92 | je testing |
||
93 | |||
94 | cmp ah,1 |
||
95 | jne still |
||
96 | ;-------------------------------------- |
||
97 | exit: |
||
98 | mcall -1 |
||
99 | ;----------------------------------------------------------------------------- |
||
100 | select_file: |
||
101 | ; invoke OpenDialog |
||
102 | mov [OpenDialog_data.type],dword 0 |
||
103 | push dword OpenDialog_data |
||
104 | call [OpenDialog_Start] |
||
105 | cmp [OpenDialog_data.status],1 |
||
106 | jne still |
||
107 | ; prepare for PathShow |
||
108 | push dword PathShow_data |
||
109 | call [PathShow_prepare] |
||
110 | |||
111 | call draw_PathShow |
||
112 | jmp still |
||
113 | ;----------------------------------------------------------------------------- |
||
114 | draw_PathShow: |
||
115 | mcall 13,<5,400-20>,<5,15>,0xffffff |
||
116 | ; draw for PathShow |
||
117 | push dword PathShow_data |
||
118 | call [PathShow_draw] |
||
119 | ret |
||
120 | ;----------------------------------------------------------------------------- |
||
121 | draw_window: |
||
122 | mcall 48,3,app_colours,4*10 ; get current colors |
||
123 | |||
124 | mcall 12,1 |
||
125 | xor esi,esi |
||
126 | xor ebp,ebp |
||
127 | mov edx,[w_work] ; color of work area RRGGBB,8->color |
||
128 | or edx,0x34000000 |
||
129 | mcall 0,<100,400>,<100,270>,,,title |
||
130 | call draw_PathShow |
||
131 | mcall 8,<5,80>,<25,15>,2,[w_work_button] |
||
132 | mcall 4,<5+10,25+4>,[w_work_button_text],s_text,s_text.size |
||
133 | mcall 8,<400-65,50>,<25,15>,3,[w_work_button] |
||
134 | mcall 4,<400-65+10,25+4>,[w_work_button_text],r_text,r_text.size |
||
135 | |||
136 | mov ebx,5 shl 16+47 |
||
137 | mov ebp,result_table |
||
138 | mov ecx,18 |
||
139 | ;-------------------------------------- |
||
140 | @@: |
||
141 | push ecx |
||
142 | mov ecx,[w_work_text] |
||
143 | or ecx,0x80000000 |
||
144 | mcall 4,,,[ebp] |
||
145 | push ebx |
||
146 | mov edx,ebx |
||
147 | add edx,50 shl 16 |
||
148 | mov ebx,0x800a0000 |
||
149 | mcall 47,,[ebp+4],,[w_work_text] |
||
150 | pop ebx |
||
151 | add ebx,6+5 |
||
152 | add ebp,12 |
||
153 | pop ecx |
||
154 | dec ecx |
||
155 | jnz @b |
||
156 | |||
157 | mcall 12,2 |
||
158 | ret |
||
159 | ;-----------------------------------------------------------------------------;----------------------------------------------------------------------------- |
||
160 | testing: |
||
161 | mcall 70,fileinfo |
||
162 | test eax,eax |
||
163 | jz @f |
||
164 | |||
165 | DEBUGF 1,'FSPEED: file not found %s\n',fname |
||
166 | jmp still |
||
167 | ;-------------------------------------- |
||
168 | @@: |
||
169 | DEBUGF 1,'FSPEED: target file %s\n',fname |
||
170 | mov ebp,result_table |
||
171 | mov ecx,18 |
||
172 | ;-------------------------------------- |
||
173 | @@: |
||
174 | push ecx |
||
175 | call read_chunk |
||
176 | pop ecx |
||
177 | add ebp,12 |
||
178 | pusha |
||
179 | call draw_window |
||
180 | popa |
||
181 | dec ecx |
||
182 | jnz @b |
||
183 | |||
184 | jmp still |
||
185 | ;----------------------------------------------------------------------------- |
||
186 | read_chunk: |
||
187 | mov eax,[file_info+32] ; file size |
||
188 | cmp [ebp+8],eax ; chunk size |
||
189 | jb @f |
||
190 | |||
191 | xor eax,eax |
||
192 | mov [ebp+4],eax ; small file size for current chunk size |
||
193 | ret |
||
194 | ;-------------------------------------- |
||
195 | @@: |
||
196 | mcall 68,12,[ebp+8] ; chunk size |
||
197 | mov [fileread.return],eax |
||
198 | xor eax,eax |
||
199 | mov [fileread.offset],eax ; zero current offset |
||
200 | mcall 26,9 ; get start time |
||
201 | add eax,1600 ; 16 sec for iterations |
||
202 | mov esi,eax |
||
203 | mov ecx,1 |
||
204 | mov eax,[ebp+8] ; chunk size |
||
205 | mov [fileread.size],eax |
||
206 | ;-------------------------------------- |
||
207 | .loop: |
||
208 | mcall 70,fileread |
||
209 | |||
210 | mcall 26,9 ; check current time |
||
211 | cmp esi,eax |
||
212 | jbe .end |
||
213 | ; correct offset |
||
214 | mov edx,[ebp+8] ; chunk size |
||
215 | add [fileread.offset],edx ; current offset |
||
216 | ; check offset and file size |
||
217 | mov edx,[file_info+32] ; file size |
||
218 | sub edx,[ebp+8] ; chunk size |
||
219 | cmp [fileread.offset],edx |
||
220 | jbe @f |
||
221 | |||
222 | xor edx,edx |
||
223 | mov [fileread.offset],edx ; zero current offset |
||
224 | ;-------------------------------------- |
||
225 | @@: |
||
226 | inc ecx |
||
227 | jmp .loop |
||
228 | ;-------------------------------------- |
||
229 | .end: |
||
230 | mov eax,[ebp+8] |
||
4837 | mario79 | 231 | xor edx,edx |
4840 | mario79 | 232 | mul ecx |
4837 | mario79 | 233 | shr eax,10+4 ;div 1024 ; div 16 |
234 | shl edx,18 |
||
235 | add eax,edx |
||
4835 | mario79 | 236 | mov [ebp+4],eax ; speed KB/s |
237 | DEBUGF 1,'FSPEED: chunk size: %s iterations: %d speed: %d KB/s\n',[ebp],ecx,eax |
||
238 | mcall 68,13,[fileread.return] |
||
239 | ret |
||
240 | ;----------------------------------------------------------------------------- |
||
241 | include 'idata.inc' |
||
242 | ;----------------------------------------------------------------------------- |
||
243 | IM_END: |
||
244 | ;----------------------------------------------------------------------------- |
||
245 | include 'udata.inc' |
||
246 | ;----------------------------------------------------------------------------- |
||
247 | I_END: |
||
248 | ;-----------------------------------------------------------------------------400-65+10,25+4>25,15>400-65,50>5+10,25+4>25,15>5,80>100,270>100,400>5,15>5,400-20> |