Subversion Repositories Kolibri OS

Rev

Rev 2559 | Rev 2583 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2559 Rev 2582
Line 1... Line 1...
1
;
1
;
2
;   CPU -process Manager
2
;   CPU -process Manager
3
;
3
;
4
;------------------------------------------------------------------------------
4
;------------------------------------------------------------------------------
-
 
5
; version:	1.80
-
 
6
; last update:  07/04/2012
-
 
7
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
-
 
8
; changes:      Complete elimination of flicker.
-
 
9
;               Using f.0 C = 1 - don't fill working area on window draw.
-
 
10
;               Increasing the size of buttons and a bright color.
-
 
11
;------------------------------------------------------------------------------
5
; version:	1.70
12
; version:	1.70
6
; last update:  04/04/2012
13
; last update:  04/04/2012
7
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
14
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
8
; changes:      Code refactoring and optimization.
15
; changes:      Code refactoring and optimization.
9
;               Added russian language support.
16
;               Added russian language support.
Line 34... Line 41...
34
include 'lang.inc'
41
include 'lang.inc'
35
include '../../../macros.inc'
42
include '../../../macros.inc'
36
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
43
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
37
include '../../../develop/libraries/box_lib/load_lib.mac'
44
include '../../../develop/libraries/box_lib/load_lib.mac'
38
;------------------------------------------------------------------------------
45
;------------------------------------------------------------------------------
39
display_processes=32		; number of processes to show
46
display_processes=24	;32		; number of processes to show
40
window_x_size=524
47
window_x_size=524
41
window_y_size=430
48
window_y_size=430
42
;------------------------------------------------------------------------------
49
;------------------------------------------------------------------------------
43
@use_library	;use load lib macros
50
@use_library	;use load lib macros
44
;------------------------------------------------------------------------------
51
;------------------------------------------------------------------------------
Line 92... Line 99...
92
	jz	key
99
	jz	key
Line 93... Line 100...
93
 
100
 
94
	dec	eax		      ; button in buffer ?
101
	dec	eax		      ; button in buffer ?
Line 95... Line -...
95
	jz	button
-
 
96
 
-
 
97
;	sub	eax,3		      ; If not use mouse - show 
-
 
98
;	jnz	still_end
102
	jz	button
99
 
103
 
Line 100... Line 104...
100
	push	dword edit1
104
	push	dword edit1
Line 177... Line 181...
177
;ignore empty buttons
181
;ignore empty buttons
178
	test	ecx,ecx
182
	test	ecx,ecx
179
	jle	still_end
183
	jle	still_end
180
;terminate application    
184
;terminate application    
181
	mcall	18,2
185
	mcall	18,2
182
	jmp	show_process_info_1	;still_end 
186
	jmp	show_process_info_1 
183
;--------------------------------------
187
;--------------------------------------
184
align 4
188
align 4
185
noterm:
189
noterm:
186
;special buttons
190
;special buttons
187
	dec	eax
191
	dec	eax
Line 203... Line 207...
203
;buttons handlers    
207
;buttons handlers    
204
;------------------------------------------------------------------------------
208
;------------------------------------------------------------------------------
205
align 4	
209
align 4	
206
pgdn:
210
pgdn:
207
	sub	[list_start],display_processes
211
	sub	[list_start],display_processes
208
;	cmp	[list_start],0
-
 
209
	jge	show_process_info_1	;still_end  
212
	jge	show_process_info_1  
210
	mov	[list_start],0
213
	mov	[list_start],0
211
	jmp	show_process_info_1	;still_end  
214
	jmp	show_process_info_1
212
;------------------------------------------------------------------------------
215
;------------------------------------------------------------------------------
213
align 4	
216
align 4	
214
pgup:
217
pgup:
215
	mov	eax,[list_add]  ;maximal displayed process slot
218
	mov	eax,[list_add]  ;maximal displayed process slot
216
	mov	[list_start],eax
219
	mov	[list_start],eax
217
	jmp	show_process_info_1	;still_end  
220
	jmp	show_process_info_1
218
;------------------------------------------------------------------------------
221
;------------------------------------------------------------------------------
219
align 4	    
222
align 4	    
220
program_start:    
223
program_start:    
221
	mcall	70,file_start
224
	mcall	70,file_start
222
	jmp	show_process_info_1	;still_end
225
	jmp	show_process_info_1
223
;------------------------------------------------------------------------------
226
;------------------------------------------------------------------------------
224
align 4	
227
align 4	
225
reboot:    
228
reboot:    
226
	mcall	70,sys_reboot
229
	mcall	70,sys_reboot
227
;close program if we going to reboot
230
;close program if we going to reboot
Line 230... Line 233...
230
close:
233
close:
231
	or	eax,-1 		; close this program
234
	or	eax,-1 		; close this program
232
	mcall
235
	mcall
233
;------------------------------------------------------------------------------
236
;------------------------------------------------------------------------------
234
align 4	
237
align 4	
-
 
238
draw_empty_slot:	
-
 
239
	cmp	[draw_window_flag],1
-
 
240
	je	@f
-
 
241
	mov	ecx,[curposy]
-
 
242
	shl	ecx,16
-
 
243
	mov	cx,10	; button height
-
 
244
	push	ecx
-
 
245
	add	ecx,3 shl 16
-
 
246
	mcall	13,<11,95>,,[btn_bacground_color]
-
 
247
	pop	ecx
-
 
248
	
-
 
249
	mcall	13,<111,393>,,[bar_bacground_color]
-
 
250
;--------------------------------------
-
 
251
align 4
-
 
252
@@:
-
 
253
	ret
-
 
254
;------------------------------------------------------------------------------
-
 
255
align 4	
235
draw_next_process:
256
draw_next_process:
236
;input:
257
;input:
237
;  edi - current slot
258
;  edi - current slot
238
;  [curposy] - y position
259
;  [curposy] - y position
239
;output:
260
;output:
240
;  edi - next slot (or -1 if no next slot)
261
;  edi - next slot (or -1 if no next slot)
241
;registers corrupted!
262
;registers corrupted!
242
;delete old button
263
;delete old button
-
 
264
	cmp	[draw_window_flag],0
-
 
265
	je	@f
243
	mov	edx,[index]
266
	mov	edx,[index]
244
	add	edx,(1 shl 31)+11
267
	add	edx,(1 shl 31)+11
245
	mcall	8
268
	mcall	8
-
 
269
;--------------------------------------
-
 
270
align 4
-
 
271
@@:
246
;create terminate process button
272
;create terminate process button
247
	mov	ecx,[curposy]
273
	mov	ecx,[curposy]
248
	shl	ecx,16
274
	shl	ecx,16
249
	mov	cx,10
275
	mov	cx,13	; button height
250
	mov	edx,[index]
276
	mov	edx,[index]
251
	add	edx,11
277
	add	edx,11
252
	mov	esi,0xaabbcc
278
	mov	esi,0xccddee	; 0xaabbcc
253
;contrast    
279
;contrast    
254
	test	dword [index],1
280
	test	dword [index],1
255
	jz	.change_color_button
281
	jz	.change_color_button
256
	mov	esi,0x8899aa
282
	mov	esi,0xaabbcc	; 0x8899aa
257
;--------------------------------------
283
;--------------------------------------
258
align 4
284
align 4
259
.change_color_button:
285
.change_color_button:
-
 
286
	cmp	[draw_window_flag],0
-
 
287
	je	@f
260
	mcall	,<10,99>
288
	mcall	8,<10,99>
-
 
289
;--------------------------------------
-
 
290
align 4
-
 
291
@@:
-
 
292
	mov	[btn_bacground_color],esi
261
;draw background for proccess information
293
;draw background for proccess information
262
; ecx was already set
294
; ecx was already set
263
	mov	edx,0x88ff88
295
	mov	edx,0xddffdd	; 0x88ff88
264
;contrast
296
;contrast
265
	test	dword [index],1
297
	test	dword [index],1
266
	jz	.change_color_info
298
	jz	.change_color_info
267
	mov	edx,0xddffdd
299
	mov	edx,0xffffff	; 0xddffdd
268
;--------------------------------------
300
;--------------------------------------
269
align 4
301
align 4
270
.change_color_info:
302
.change_color_info:
-
 
303
	inc	cx
-
 
304
	cmp	[draw_window_flag],0
-
 
305
	je	@f
271
	mcall	13,<110,395>
306
	mcall	13,<110,395>
-
 
307
;--------------------------------------
-
 
308
align 4
-
 
309
@@:
-
 
310
	mov	[bar_bacground_color],edx
272
;nothing else should be done
311
;nothing else should be done
273
;if there is no process for this button    
312
;if there is no process for this button    
274
	test	edi,edi
313
	cmp	edi,-1
-
 
314
	jne	.return_1
-
 
315
 
-
 
316
	call	draw_empty_slot
-
 
317
	or	edi,-1
275
	jl	.ret
318
	jmp	.ret
276
;--------------------------------------
319
;--------------------------------------
277
align 4
320
align 4
278
.return_1:
321
.return_1:
279
;find process
322
;find process
280
	inc	edi
323
	inc	edi
Line 300... Line 343...
300
	inc	ecx
343
	inc	ecx
301
	jmp	.find_loop
344
	jmp	.find_loop
302
;--------------------------------------
345
;--------------------------------------
303
align 4
346
align 4
304
.no_processes:
347
.no_processes:
-
 
348
	call	draw_empty_slot
305
	or	edi,-1
349
	or	edi,-1
306
	ret
350
	ret
307
;--------------------------------------
351
;--------------------------------------
308
align 4
352
align 4
309
.process_found:
353
.process_found:
Line 366... Line 410...
366
;--------------------------------------
410
;--------------------------------------
367
align 4
411
align 4
368
.color_set:
412
.color_set:
369
;show slot number
413
;show slot number
370
;ecx haven't changed since .process_found    
414
;ecx haven't changed since .process_found    
371
;	mov	ecx,edi
415
	push	edi
372
	mov	edx,[curposy]
416
	mov	edx,[curposy]
373
	add	edx,15*65536+1
417
	add	edx,15*65536+3
-
 
418
	mov	esi,[tcolor]
-
 
419
	and	esi,0xffffff
-
 
420
	or	esi,0x40000000
374
	mcall	47,<2,256>,,,[tcolor]
421
	mcall	47,<2,256>,,,,[btn_bacground_color]
375
;show process name
422
;show process name
376
	mov	ebx,[curposy]
423
	mov	ebx,[curposy]
377
	add	ebx,45*65536+1
424
	add	ebx,40*65536+3
-
 
425
	mov	ecx,[tcolor]
-
 
426
	and	ecx,0xffffff
-
 
427
	or	ecx,0x40000000
378
	mcall	4,,[tcolor],process_info_buffer.process_name,11
428
	mcall	4,,,process_info_buffer.process_name,11,[btn_bacground_color]
379
;show pid
429
;show pid
380
	mov	edx,[curposy]
430
	mov	edx,[curposy]
381
	add	edx,125*65536+1
431
	add	edx,125*65536+3
-
 
432
	mov	esi,[tcolor]
-
 
433
	and	esi,0xffffff
-
 
434
	or	esi,0x40000000
382
	mcall	47,<8,256>,[process_info_buffer.PID],,[tcolor]
435
	mcall	47,<8,256>,[process_info_buffer.PID],,,[bar_bacground_color]
383
;show cpu usage
436
;show cpu usage
384
	add	edx,60*65536
437
	add	edx,60*65536
385
	mcall	,,[process_info_buffer.cpu_usage]
438
	mcall	,,[process_info_buffer.cpu_usage]
386
;show cpu percent
439
;show cpu percent
387
	add	edx,60*65536
440
	add	edx,60*65536
Line 401... Line 454...
401
	mov	ecx,[process_info_buffer.box.left]
454
	mov	ecx,[process_info_buffer.box.left]
402
	shl	ecx,16
455
	shl	ecx,16
403
	add	ecx,[process_info_buffer.box.top]
456
	add	ecx,[process_info_buffer.box.top]
404
	add	edx,60*65536
457
	add	edx,60*65536
405
	mcall 
458
	mcall 
-
 
459
	pop	edi
406
;--------------------------------------
460
;--------------------------------------
407
align 4
461
align 4
408
.ret:
462
.ret:
409
;build index->slot map for terminating processes.
463
;build index->slot map for terminating processes.
410
	mov	eax,[index]
464
	mov	eax,[index]
Line 425... Line 479...
425
draw_window:
479
draw_window:
426
	mcall	12, 1		       
480
	mcall	12, 1		       
427
; DRAW WINDOW
481
; DRAW WINDOW
428
	xor	eax,eax				; function 0 : define and draw window
482
	xor	eax,eax				; function 0 : define and draw window
429
	xor	esi,esi
483
	xor	esi,esi
430
	mcall	,[winxpos],[winypos],0x34ddffdd,,title
484
	mcall	,[winxpos],[winypos],0x74ffffff,,title	;0x34ddffdd
-
 
485
 
-
 
486
	mcall	9,process_info_buffer,-1
-
 
487
	mov	eax,[ebx+62]
-
 
488
	inc	eax
-
 
489
	mov	[client_area_x_size],eax
-
 
490
	mov	eax,[ebx+66]
-
 
491
	inc	eax
-
 
492
	mov	[client_area_y_size],eax
-
 
493
 
-
 
494
	mov	ebx,[client_area_x_size]
-
 
495
	mcall	13,,<0,20>,0xffffff
431
; function 4 : write text to window
496
; function 4 : write text to window
432
	xor	ecx,ecx
497
	xor	ecx,ecx
433
	mcall	4,<17,13>,,text,text_len
498
	mcall	4,<17,8>,,text,text_len
Line 434... Line -...
434
 
-
 
435
	push	dword edit1
499
 
Line -... Line 500...
-
 
500
	mcall	13,<0,10>,<20,336>,0xffffff
436
	call	[edit_box_draw]
501
	
437
 
502
	mov	ebx,[client_area_x_size]
-
 
503
	sub	ebx,10+100+395
Line 438... Line 504...
438
	push	dword check1
504
	add	ebx,(10+100+395) shl 16
439
	call	[check_box_draw]
505
	mcall
440
 
506
	
Line -... Line 507...
-
 
507
	mcall	26,9
441
	mcall	26,9
508
	add	eax,100
-
 
509
	mov	[time_counter],eax
-
 
510
 
-
 
511
	mov	[draw_window_flag],1
-
 
512
	call	show_process_info
-
 
513
	mov	[draw_window_flag],0
-
 
514
	
-
 
515
	mov	ebx,[client_area_x_size]
-
 
516
	mov	ecx,[client_area_y_size]
-
 
517
	sub	ecx,20+336
-
 
518
	add	ecx,(20+336) shl 16
-
 
519
	mcall	13,,,0xffffff
-
 
520
 
-
 
521
	push	dword edit1
-
 
522
	call	[edit_box_draw]
442
	add	eax,100
523
 
443
	mov	[time_counter],eax
524
	push	dword check1
444
 
525
	call	[check_box_draw]
445
	call	show_process_info
526
	
446
; previous page button
527
; previous page button
447
	mcall	8,<25,96>,<358,10>,51,0xaabbcc
528
	mcall	8,<25,96>,<361,14>,51,0xccddee	;0xaabbcc
448
; next page button  52
529
; next page button  52
449
	inc	edx
530
	inc	edx
450
	mcall	,<125,96>
531
	mcall	,<125,96>
451
; ">" (text enter) button
532
; ">" (text enter) button
452
	add	ecx,20 shl 16
533
	add	ecx,20 shl 16
453
; run button 53
534
; run button 53
454
	inc	edx
535
	inc	edx
455
	mcall	,<451,50>
536
	mcall	,<456,50>
456
; reboot button    
537
; reboot button    
457
	sub	ebx,120*65536		    
538
	sub	ebx,120*65536		    
458
	add	ebx,60
539
	add	ebx,60
459
	sub	ecx,20 shl 16
540
	sub	ecx,20 shl 16
460
	inc	edx
541
	inc	edx
461
	mcall
542
	mcall
462
;"PREV PAGE", "NEXT PAGE" and "REBOOT" labels
543
;"PREV PAGE", "NEXT PAGE" and "REBOOT" labels
463
	xor	ecx,ecx
544
	xor	ecx,ecx
464
	mcall	4,<45,360>,,tbts,tbte-tbts
545
	mcall	4,<45,365>,,tbts,tbte-tbts
465
;"RUN" labels
546
;"RUN" labels
466
	mcall	,<464,380>,,tbts_3,tbte_2-tbts_3
547
	mcall	,<464,385>,,tbts_3,tbte_2-tbts_3
467
;print application name in text box
548
;print application name in text box
468
	mcall	12, 2
549
	mcall	12, 2
469
	ret
550
	ret
470
;------------------------------------------------------------------------------
551
;------------------------------------------------------------------------------
471
align 4
552
align 4
472
show_process_info:
553
show_process_info:
473
	mov	edi,[list_start]
554
	mov	edi,[list_start]
474
	mov	[list_add],edi
555
	mov	[list_add],edi
475
	mov	dword [index],0
556
	mov	dword [index],0
476
	mov	dword [curposy],32
557
	mov	dword [curposy],20
477
;--------------------------------------
558
;--------------------------------------
478
align 4
559
align 4
479
.loop_draw:
560
.loop_draw:
480
	call	draw_next_process
561
	call	draw_next_process
481
	inc	dword [index]
562
	inc	dword [index]
482
	add	dword [curposy],10
563
	add	dword [curposy],14
483
	cmp	[index],display_processes
564
	cmp	[index],display_processes
Line 525... Line 606...
525
;aOption_box_draw	db 'option_box_draw',0
606
;aOption_box_draw	db 'option_box_draw',0
526
;aOption_box_mouse	db 'option_box_mouse',0
607
;aOption_box_mouse	db 'option_box_mouse',0
527
;aVersion_op		db 'version_op',0
608
;aVersion_op		db 'version_op',0
528
;------------------------------------------------------------------------------
609
;------------------------------------------------------------------------------
529
align 4	
610
align 4	
530
check1 check_box 10,378,6,11,0x80AABBCC,0,0,check_text,check_t_e,0;ch_flag_en
611
check1 check_box 10,383,6,11,0x80AABBCC,0,0,check_text,check_t_e,0;ch_flag_en
531
check1_end:
612
check1_end:
532
edit1 edit_box 350,95,376,0xffffff,0x6f9480,0,0xAABBCC,0,start_application_c,\
613
edit1 edit_box 350,95,381,0xffffff,0x6f9480,0,0xAABBCC,0,start_application_c,\
533
   start_application,mouse_dd,ed_focus,start_application_e,start_application_e
614
   start_application,mouse_dd,ed_focus,start_application_e,start_application_e
534
edit1_end:
615
edit1_end:
535
list_start  dd 0
616
list_start  dd 0
536
;------------------------------------------------------------------------------
617
;------------------------------------------------------------------------------
537
align 4	
618
align 4	
Line 626... Line 707...
626
list_add	rd 1
707
list_add	rd 1
627
curposy		rd 1
708
curposy		rd 1
628
index		rd 1
709
index		rd 1
629
tasklist	rd display_processes
710
tasklist	rd display_processes
630
time_counter	rd 1
711
time_counter	rd 1
-
 
712
 
-
 
713
client_area_x_size	rd 1
-
 
714
client_area_y_size	rd 1
-
 
715
bar_bacground_color	rd 1
-
 
716
btn_bacground_color	rd 1
-
 
717
draw_window_flag	rd 1
631
;------------------------------------------------------------------------------
718
;------------------------------------------------------------------------------
632
align 4	
719
align 4	
633
library_path:
720
library_path:
634
process_info_buffer process_information
721
process_info_buffer process_information
635
;------------------------------------------------------------------------------
722
;------------------------------------------------------------------------------