Subversion Repositories Kolibri OS

Rev

Rev 4840 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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