Subversion Repositories Kolibri OS

Rev

Rev 8561 | Rev 8563 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6444 pathoswith 1
;-----------------------;
2
; CPU - process manager ;
3
;-----------------------;
4
 
8561 Kenshin 5
	format	binary as ""
3408 hidnplayr 6
 
8561 Kenshin 7
	use32
8
	org	0x0
9
 
10
	db	"MENUET01"		; 8 byte id
11
	dd	0x01		 ; header version
12
	dd	START		; start of code
13
	dd	IM_END		; size of image
14
	dd	U_END		; memory for app
15
	dd	stack_area		; esp
16
	dd	0x0			; boot parameters
17
	dd	cur_dir_path	 ; path
18
;-------------------------------------------------------------------------------
19
include "lang.inc"
20
include "../../../macros.inc"
21
include "../../../develop/libraries/box_lib/trunk/box_lib.mac"
22
include "../../../KOSfuncs.inc"
23
include "../../../load_lib.mac"
24
;-------------------------------------------------------------------------------
25
DISPLAY_PROCESSES = 20	;number of processes to show
26
;-------------------------------------------------------------------------------
27
WINDOW.WIDTH = PROCESS_TABLE.WIDTH + 10*2
28
WINDOW.HEIGHT = WORK_AREA.HEIGHT + 30
29
WORK_AREA.HEIGHT = CHECKBOX.Y + BUTTON.HEIGHT + 10
30
PROCESS_TABLE:
31
	.X = 10
32
	.Y = 10
33
	.WIDTH = 640
34
	.HEIGHT = DISPLAY_PROCESSES * BUTTON.HEIGHT
35
UNDERTABLE:
36
	.X = PROCESS_TABLE.X
37
	.Y = PROCESS_TABLE.Y + PROCESS_TABLE.HEIGHT + 20
38
BUTTON:
39
	.HEIGHT = 16 + 4
40
EDITBOX:
41
	.X = CHECKBOX.X + 100
42
	.Y = UNDERTABLE.Y + BUTTON.HEIGHT + 25
43
	.WIDTH = 465
44
	.HEIGHT = 15
45
 
46
CHECKBOX:
47
	.X = PROCESS_TABLE.X
48
	.Y = UNDERTABLE.Y + BUTTON.HEIGHT + 25
49
;-------------------------------------------------------------------------------
50
@use_library	;use load lib macros
51
;-------------------------------------------------------------------------------
52
	struc	utf8z	string
53
{
54
	.	db	string, 0
55
	.size = $ - . - 1
56
}
57
 
58
;-------------------------------------------------------------------------------
59
START:				; start of execution
60
	mcall	SF_SYS_MISC,SSF_HEAP_INIT
61
	sys_load_library	library_name, library_path, system_path, myimport
62
	inc	eax
63
	jz	close
64
;-------------------------------------------------------------------------------
65
	mcall	SF_SET_EVENTS_MASK,0x80000027 ;set event
66
;-------------------------------------------------------------------------------
2559 mario79 67
;set window size and position for 0 function
68
;to [winxpos] and [winypos] variables
69
;get screen size
8561 Kenshin 70
	mcall	SF_GET_SCREEN_SIZE
71
	mov	ebx,eax
72
;calculate (x_screen-WINDOW.WIDTH)/2
73
	shr	ebx,16+1
74
	sub	ebx,WINDOW.WIDTH/2
75
	shl	ebx,16
76
	mov	bx,WINDOW.WIDTH
3587 fedesco 77
;winxpos=xcoord*65536+xsize
8561 Kenshin 78
	mov	[winxpos],ebx
79
;calculate (y_screen-WINDOW.HEIGHT)/2
80
	and	eax,0xffff
81
	shr	eax,1
82
	sub	eax,WINDOW.HEIGHT/2
83
	shl	eax,16
84
	mov	ax,WINDOW.HEIGHT
3587 fedesco 85
;winypos=ycoord*65536+ysize
8561 Kenshin 86
	mov	[winypos],eax
87
;-------------------------------------------------------------------------------
88
	init_checkboxes2 check1,check1_end
89
	mcall	SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,40
90
	edit_boxes_set_sys_color edit1,edit1_end,sc		;set color
91
	;check_boxes_set_sys_color2 check1,check1_end,sc ;set color
92
;-------------------------------------------------------------------------------
3587 fedesco 93
align 4
8561 Kenshin 94
;main loop when process name isn"t edited.
3587 fedesco 95
red:
8561 Kenshin 96
	call	draw_window		; redraw all window
97
;-------------------------------------------------------------------------------
3587 fedesco 98
align 4
31 halyavin 99
still:
8561 Kenshin 100
	mcall	SF_WAIT_EVENT_TIMEOUT,100		; wait here for event 1 sec.
6444 pathoswith 101
 
3955 mario79 102
	test	eax,eax
103
	jz	still_end
31 halyavin 104
 
8561 Kenshin 105
	dec	eax			; redraw request ?
106
	jz	red
1205 Lrz 107
 
8561 Kenshin 108
	dec	eax			; key in buffer ?
109
	jz	key
2559 mario79 110
 
8561 Kenshin 111
	dec	eax			; button in buffer ?
112
	jz	button
2559 mario79 113
 
8561 Kenshin 114
	push	dword	edit1
115
	call	[edit_box_mouse]
3587 fedesco 116
 
8561 Kenshin 117
	push	dword[check1.flags]
3587 fedesco 118
 
8561 Kenshin 119
	push	dword	check1
120
	call	[check_box_mouse]
3587 fedesco 121
 
8561 Kenshin 122
	pop	eax
3587 fedesco 123
 
8561 Kenshin 124
	cmp	eax, dword[check1.flags]
125
	jz	still_end
3587 fedesco 126
 
8561 Kenshin 127
	push	dword	check1
128
	call	[check_box_draw]
129
;-------------------------------------------------------------------------------
3587 fedesco 130
align 4
131
show_process_info_1:
8561 Kenshin 132
	mcall	SF_SYSTEM_GET, SSF_TIME_COUNT
133
	add	eax, 100
134
	mov	[time_counter],eax
1205 Lrz 135
 
8561 Kenshin 136
	call	show_process_info	; draw new state of processes
137
	jmp	still
138
;-------------------------------------------------------------------------------
3587 fedesco 139
align 4
2559 mario79 140
still_end:
8561 Kenshin 141
	mcall	SF_SYSTEM_GET,SSF_TIME_COUNT
142
	cmp	[time_counter],eax
143
	ja	still
31 halyavin 144
 
8561 Kenshin 145
	add	eax,100
146
	mov	[time_counter],eax
1212 Lrz 147
 
8561 Kenshin 148
	call	show_process_info	; draw new state of processes
149
	jmp	still
150
;-------------------------------------------------------------------------------
3587 fedesco 151
align 4
8561 Kenshin 152
key:				; key
153
	mcall	SF_GET_KEY
1205 Lrz 154
 
8561 Kenshin 155
	cmp	ah,184		; PageUp
156
	jz	pgdn
1205 Lrz 157
 
8561 Kenshin 158
	cmp	ah,183
159
	jz	pgup			; PageDown
2559 mario79 160
 
8561 Kenshin 161
	cmp	ah,27
162
	jz	close			; Esc
2559 mario79 163
 
8561 Kenshin 164
	push	dword	edit1
165
	call	[edit_box_key]
166
				; Check ENTER with ed_focus edit_box
167
	lea	edi,[edit1]
168
	test	word	ed_flags,ed_focus
169
	jz	still_end
1205 Lrz 170
 
8561 Kenshin 171
	sub	ah,13			; ENTER?
172
	jz	program_start		; RUN a program
1212 Lrz 173
 
8561 Kenshin 174
	jmp	still
175
;-------------------------------------------------------------------------------
3587 fedesco 176
align 4
177
button:
178
; get button id
8561 Kenshin 179
	mcall	SF_GET_BUTTON
180
	mov	bl, al ; save mouse button to bl
181
	shr	eax,8
31 halyavin 182
;id in [10,50] corresponds to terminate buttons.
8561 Kenshin 183
	cmp	eax,10
184
	jb	noterm
31 halyavin 185
 
8561 Kenshin 186
	cmp	eax,50
187
	jg	noterm
3587 fedesco 188
;calculate button index
8561 Kenshin 189
	sub	eax,11
3587 fedesco 190
;calculate process slot
8561 Kenshin 191
	mov	ecx,[tasklist+4*eax]
31 halyavin 192
;ignore empty buttons
8561 Kenshin 193
	test	ecx,ecx
194
	jle	still_end
195
	test	bl, bl ; check mouse button
196
	jz	.terminate
197
	mov	eax, ecx
198
	mov	edi, tinfo.params_buf
4968 0CodErr 199
;; number in eax
200
;; buffer in edi
201
; int2str:
8561 Kenshin 202
	push	0
203
	mov	ecx, 10
6444 pathoswith 204
.push:
8561 Kenshin 205
	xor	edx, edx
206
	div	ecx
207
	add	edx, 48
208
	push	edx
209
	test	eax, eax
210
	jnz	.push
6444 pathoswith 211
.pop:
8561 Kenshin 212
	pop	eax
213
	stosb
214
	test	eax, eax
215
	jnz	.pop
6444 pathoswith 216
; launch tinfo app
8561 Kenshin 217
	mov	ebx, tinfo
218
	mov	eax, SF_FILE
219
	int	64
220
	jmp	show_process_info_1
6444 pathoswith 221
.terminate:
3587 fedesco 222
;terminate application
8561 Kenshin 223
	mcall	SF_SYSTEM,SSF_TERMINATE_THREAD
224
	jmp	show_process_info_1
225
;-------------------------------------------------------------------------------
2559 mario79 226
align 4
227
noterm:
228
;special buttons
8561 Kenshin 229
	dec	eax
230
	jz	close
1212 Lrz 231
 
8561 Kenshin 232
	sub	eax,50
233
	jz	pgdn	;51
31 halyavin 234
 
8561 Kenshin 235
	dec	eax
236
	jz	pgup	;52
1203 Lrz 237
 
8561 Kenshin 238
	dec	eax
239
	jz	reboot	;53
1212 Lrz 240
 
8561 Kenshin 241
	dec	eax
242
	jz	program_start	;54
1212 Lrz 243
 
8561 Kenshin 244
	jmp	still_end
3587 fedesco 245
;buttons handlers
8561 Kenshin 246
;-------------------------------------------------------------------------------
3587 fedesco 247
align 4
2559 mario79 248
pgdn:
8561 Kenshin 249
	sub	[list_start],DISPLAY_PROCESSES
250
	jge	show_process_info_1
251
	mov	[list_start],0
252
	jmp	show_process_info_1
253
;-------------------------------------------------------------------------------
3587 fedesco 254
align 4
2559 mario79 255
pgup:
8561 Kenshin 256
	mov	eax,[list_add]	;maximal displayed process slot
257
	mov	[list_start],eax
258
	jmp	show_process_info_1
259
;-------------------------------------------------------------------------------
3587 fedesco 260
align 4
261
program_start:
8561 Kenshin 262
	mcall	SF_FILE,file_start
263
	jmp	show_process_info_1
264
;-------------------------------------------------------------------------------
3587 fedesco 265
align 4
266
reboot:
8561 Kenshin 267
	mcall	SF_FILE,sys_reboot
31 halyavin 268
;close program if we going to reboot
8561 Kenshin 269
;-------------------------------------------------------------------------------
3587 fedesco 270
align 4
2559 mario79 271
close:
8561 Kenshin 272
	or	eax,SF_TERMINATE_PROCESS ; close this program
273
	mcall
274
;-------------------------------------------------------------------------------
3587 fedesco 275
align 4
276
draw_empty_slot:
8561 Kenshin 277
	cmp	[draw_window_flag],1
278
	je	@f
279
	mov	ecx,[curposy]
280
	shl	ecx,16
281
	mov	cx, BUTTON.HEIGHT
282
	mcall	SF_DRAW_RECT, <132, PROCESS_TABLE.WIDTH-131>, , [bar_bacground_color]
2582 mario79 283
@@:
8561 Kenshin 284
	ret
285
;-------------------------------------------------------------------------------
3587 fedesco 286
align 4
31 halyavin 287
draw_next_process:
288
;input:
8561 Kenshin 289
;	edi - current slot
290
;	[curposy] - y position
31 halyavin 291
;output:
8561 Kenshin 292
;	edi - next slot (or -1 if no next slot)
31 halyavin 293
;registers corrupted!
294
;create terminate process button
8561 Kenshin 295
	mov	ecx,[curposy]
296
	shl	ecx,16
297
	mov	cx, BUTTON.HEIGHT
298
	mov	edx,[index]
299
	add	edx,11
300
	mov	esi,0xccddee
301
	test	dword	[index],1
302
	jz	@f
303
	mov	esi,0xaabbcc
6444 pathoswith 304
@@:
8561 Kenshin 305
		add	edx,0x80000000 ; delete a button
306
		mcall	SF_DEFINE_BUTTON ; before create
307
		sub	edx,0x80000000 ; a new one below
308
	mcall	SF_DEFINE_BUTTON,<10,120>
309
	mov	[btn_bacground_color],esi
31 halyavin 310
;draw background for proccess information
8561 Kenshin 311
	mov	edx,0xEFEFF5
312
	test	dword	[index],1
313
	jz	@f
314
	mov	edx,0xffffff
6444 pathoswith 315
@@:
8561 Kenshin 316
	inc	cx
317
 
318
	mcall	SF_DRAW_RECT, <131, PROCESS_TABLE.WIDTH-131>
319
 
320
	mov	[bar_bacground_color],edx
6444 pathoswith 321
;nothing else should be done if there is no process for this button
8561 Kenshin 322
	cmp	edi,-1
323
	jne	.return_1
2582 mario79 324
 
8561 Kenshin 325
	call	draw_empty_slot
326
	or	edi,-1
327
	jmp	.ret
328
;-------------------------------------------------------------------------------
2559 mario79 329
align 4
330
.return_1:
31 halyavin 331
;find process
8561 Kenshin 332
	inc	edi
3587 fedesco 333
;more comfortable register for next loop
8561 Kenshin 334
	mov	ecx,edi
3587 fedesco 335
;precacluate pointer to process buffer
8561 Kenshin 336
	mov	ebx,process_info_buffer
337
;-------------------------------------------------------------------------------
2559 mario79 338
align 4
31 halyavin 339
.find_loop:
8561 Kenshin 340
	cmp	ecx,256
341
	jge	.no_processes
31 halyavin 342
;load process information in buffer
8561 Kenshin 343
	mcall	SF_THREAD_INFO
31 halyavin 344
;if current slot greater than maximal slot,
3587 fedesco 345
;there is no more proccesses.
8561 Kenshin 346
	cmp	ecx,eax
347
	jg	.no_processes
3587 fedesco 348
;if slot state is equal to 9, it is empty.
8561 Kenshin 349
	cmp	[process_info_buffer+process_information.slot_state],9
350
	jnz	.process_found
3587 fedesco 351
 
8561 Kenshin 352
	inc	ecx
353
	jmp	.find_loop
354
;-------------------------------------------------------------------------------
2559 mario79 355
align 4
31 halyavin 356
.no_processes:
8561 Kenshin 357
	call	draw_empty_slot
358
	or	edi,-1
359
	ret
360
;-------------------------------------------------------------------------------
2559 mario79 361
align 4
31 halyavin 362
.process_found:
1266 Lrz 363
;check on/off check box
8561 Kenshin 364
	test	dword	[check1.flags], ch_flag_en
365
	jnz	.no_filter
1266 Lrz 366
 
8561 Kenshin 367
	cmp	dword	[process_info_buffer+10],"ICON"
3779 mario79 368
	jnz	@f
8561 Kenshin 369
	cmp	dword	[process_info_buffer+10+4],0
370
	jz	.return_1
3779 mario79 371
@@:
8561 Kenshin 372
	cmp	dword	[process_info_buffer+10],"IDLE"
3779 mario79 373
	jnz	@f
8561 Kenshin 374
	cmp	dword	[process_info_buffer+10+4],0
375
	jz	.return_1
3779 mario79 376
@@:
8561 Kenshin 377
	cmp	word	[process_info_buffer+10],"OS"
3779 mario79 378
	jnz	@f
8561 Kenshin 379
	cmp	dword	[process_info_buffer+10+2],0
380
	jz	.return_1
3779 mario79 381
@@:
8561 Kenshin 382
	cmp	byte [process_info_buffer+10],"@"
383
	jz	.return_1
384
;-------------------------------------------------------------------------------
2559 mario79 385
align 4
3779 mario79 386
.no_filter:
8561 Kenshin 387
	mov	edi,ecx
388
	mov	[list_add],ecx
3587 fedesco 389
;get processor cpeed
31 halyavin 390
;for percent calculating
8561 Kenshin 391
	mcall	SF_SYSTEM,SSF_GET_CPU_FREQUENCY
392
	xor	edx,edx
393
	mov	ebx,100
394
	div	ebx
31 halyavin 395
;eax = number of operation for 1% now
396
;calculate process cpu usage percent
8561 Kenshin 397
	mov	ebx,eax
398
	mov	eax,[process_info_buffer+process_information.cpu_usage]
399
;	cdq
400
	xor	edx,edx ; for CPU more 2 GHz - mike.dld
401
	div	ebx
402
	mov	[cpu_percent],eax
31 halyavin 403
;set text color to display process information
8561 Kenshin 404
;0%	: black
405
;1-80%	: green
31 halyavin 406
;81-100% : red
8561 Kenshin 407
	test	eax,eax
408
	jnz	.no_black
1212 Lrz 409
 
8561 Kenshin 410
	mov	esi, 0x10000000
411
	jmp	.color_set
412
;-------------------------------------------------------------------------------
2559 mario79 413
align 4
3587 fedesco 414
.no_black:
8561 Kenshin 415
	cmp	eax,80
416
	ja	.no_green
1212 Lrz 417
 
8561 Kenshin 418
	mov	esi, 0x10107A30
419
	jmp	.color_set
420
;-------------------------------------------------------------------------------
2559 mario79 421
align 4
31 halyavin 422
.no_green:
8561 Kenshin 423
	mov	esi,0x10AC0000
424
;-------------------------------------------------------------------------------
2559 mario79 425
align 4
31 halyavin 426
.color_set:
427
;show slot number
8561 Kenshin 428
;ecx haven"t changed since .process_found
429
	push	edi
430
	mov	eax, ecx
431
	mov	ebx, [curposy]
432
	add	ebx, 40 shl 16 + 3
433
	mov	ecx, esi
434
	xor	edx, edx
435
	call	draw_ra_dec_number
436
	push	ecx
31 halyavin 437
;show process name
8561 Kenshin 438
	mov	ebx,[curposy]
439
	add	ebx,50*65536+3
440
	mov	ecx, esi
441
	or	ecx, 0x80000000
442
	mcall	SF_DRAW_TEXT,,,process_info_buffer.process_name,11
443
	pop	ecx
444
;show PTID
445
	mov	eax, [process_info_buffer.PID]
446
	add	ebx, 160 shl 16
447
	xor	edx, edx
448
	call	draw_ra_dec_number
31 halyavin 449
;show cpu usage
8561 Kenshin 450
	mov	eax, [process_info_buffer.cpu_usage]
451
	add	ebx, 100 shl 16
452
	call	draw_ra_dec_number
31 halyavin 453
;show cpu percent
8561 Kenshin 454
	mov	eax, [cpu_percent]
455
	add	ebx, 55 shl 16
456
	call	draw_ra_dec_number
31 halyavin 457
;show memory usage
8561 Kenshin 458
	mov	eax, [process_info_buffer.used_memory]
459
	add	ebx, 60 shl 16
460
	call	draw_ra_data_size
461
;show window stack position
462
	movzx	eax, word [process_info_buffer.window_stack_position]
463
	add	ebx, 70 shl 16
464
	call	draw_ra_dec_number
465
;show window x size
466
	movzx	eax, word [process_info_buffer.box.left]
467
	add	ebx, 70 shl 16
468
	call	draw_ra_dec_number
469
;show window y size
470
	movzx	eax, word [process_info_buffer.box.top]
471
	add	ebx, 70 shl 16
472
	call	draw_ra_dec_number
473
	pop	edi
474
;-------------------------------------------------------------------------------
2559 mario79 475
align 4
31 halyavin 476
.ret:
477
;build index->slot map for terminating processes.
8561 Kenshin 478
	mov	eax,[index]
479
	mov	[tasklist+4*eax],edi
480
	ret
481
;-------------------------------------------------------------------------------
3587 fedesco 482
align 4
2559 mario79 483
f11:
3587 fedesco 484
;full update
8561 Kenshin 485
	push	edi
486
	call	draw_window
487
	pop	edi
488
;-------------------------------------------------------------------------------
489
;	*********************************************
490
;	*******	WINDOW DEFINITIONS AND DRAW ********
491
;	*********************************************
3587 fedesco 492
align 4
31 halyavin 493
draw_window:
8561 Kenshin 494
	mcall	SF_REDRAW, SSF_BEGIN_DRAW
2559 mario79 495
; DRAW WINDOW
8561 Kenshin 496
	xor	eax,eax			 ; function 0 : define and draw window
497
	xor	esi,esi
498
	mcall	,[winxpos],[winypos], 0x34FFFFFF,, strings.tmp_window_caption	;0x34ddffdd
2582 mario79 499
 
8561 Kenshin 500
	mcall	SF_THREAD_INFO,process_info_buffer,-1
3587 fedesco 501
 
8561 Kenshin 502
	mov	eax,[ebx+70]
503
	mov	[window_status],eax
504
	test	[window_status],100b		; window is rolled up
505
	jnz	.exit
2583 mario79 506
 
8561 Kenshin 507
	test	[window_status],10b		; window is minimized to panel
508
	jnz	.exit
509
 
510
	mov	eax, strings.process_name
511
	mov	ebx, 130 shl 16 + 5
512
	xor	ecx, ecx
513
	call	draw_ra_text
514
 
515
	mov	eax, strings.ptid
516
	add	ebx, 80 shl 16
517
	call	draw_ra_text
518
 
519
	mov	eax, strings.cpu_usage_cycles
520
	add	ebx, 100 shl 16
521
	call	draw_ra_text
522
 
523
	mov	eax, strings.cpu_usage_percent
524
	add	ebx, 55 shl 16
525
	call	draw_ra_text
526
 
527
	mov	eax, strings.memory_usage
528
	add	ebx, 60 shl 16
529
	call	draw_ra_text
530
 
531
	mov	eax, strings.window_stack_pos
532
	add	ebx, 70 shl 16
533
	call	draw_ra_text
534
 
535
	mov	eax, strings.window_position.x
536
	add	ebx, 70 shl 16
537
	call	draw_ra_text
538
 
539
	mov	eax, strings.window_position.y
540
	add	ebx, 70 shl 16
541
	call	draw_ra_text
2583 mario79 542
 
8561 Kenshin 543
	mcall	SF_SYSTEM_GET,SSF_TIME_COUNT
544
	add	eax,100
545
	mov	[time_counter],eax
2582 mario79 546
 
8561 Kenshin 547
	mov	[draw_window_flag],1
548
	call	show_process_info
549
	mov	[draw_window_flag],0
31 halyavin 550
 
8561 Kenshin 551
	push	dword	edit1
552
	call	[edit_box_draw]
3587 fedesco 553
 
8561 Kenshin 554
	push	dword	check1
555
	call	[check_box_draw]
3587 fedesco 556
 
8561 Kenshin 557
;previous page button, ID = 51:
558
	mov	eax, strings.previous_page
559
	mov	ebx, UNDERTABLE.X shl 16 + UNDERTABLE.Y
560
	mov	ecx, 51
561
	mov	edx, 0xCCDDEE
562
	xor	esi, esi
563
	call	draw_button_with_caption
564
;next page button, ID = 52:
565
	mov	eax, strings.next_page
566
	add	ebx, 10 shl 16
567
	inc	ecx
568
	call	draw_button_with_caption
569
;reboot button, ID = 53:
570
	mov	eax, strings.reboot
571
	add	ebx, 345 shl 16
572
	inc	ecx
573
	call	draw_button_with_caption
574
;run button, ID = 54
575
	mov	eax, strings.run
576
	mov	ebx, (EDITBOX.X + EDITBOX.WIDTH + 10) shl 16 + (EDITBOX.Y + EDITBOX.HEIGHT/2 - BUTTON.HEIGHT/2)
577
	inc	ecx
578
	call	draw_button_with_caption
579
;-------------------------------------------------------------------------------
2583 mario79 580
align 4
581
.exit:
8561 Kenshin 582
	mcall	SF_REDRAW, SSF_END_DRAW
583
	ret
584
;-------------------------------------------------------------------------------
2559 mario79 585
align 4
586
show_process_info:
8561 Kenshin 587
	test	[window_status], 100b		; window is rolled up
588
	jnz	.exit
2583 mario79 589
 
8561 Kenshin 590
	test	[window_status], 10b		; window is minimized to panel
591
	jnz	.exit
2583 mario79 592
 
8561 Kenshin 593
	mov	ecx,DISPLAY_PROCESSES
594
	mov	edi,tasklist
595
	xor	eax,eax
596
	cld
597
	rep	stosd
3938 mario79 598
 
8561 Kenshin 599
	mov	edi,[list_start]
600
	mov	[list_add],edi
601
	mov	dword	[index],0
602
	mov	dword	[curposy],20
603
;-------------------------------------------------------------------------------
2559 mario79 604
align 4
605
.loop_draw:
8561 Kenshin 606
	call	draw_next_process
607
	inc	dword	[index]
608
	add	dword	[curposy],16+4
609
	cmp	[index],DISPLAY_PROCESSES
610
	jl	.loop_draw
611
;-------------------------------------------------------------------------------
2583 mario79 612
align 4
613
.exit:
8561 Kenshin 614
	ret
615
 
616
;-------------------------------------------------------------------------------
617
 
618
draw_ra_dec_number:
619
;-------------------------------------------------------------------------------
620
;draws (posfixed) number with flush right alignment in decimal form
621
;8x16 number + 8x16 UTF8Z text
622
;in:
623
;eax = number
624
;ebx = right margin coordinates (x shl 16 + y)
625
;ecx = 0x00RRGGBB
626
;edx = pointer to postfix string or 0 - no postfix
627
;-------------------------------------------------------------------------------
628
	pusha
629
 
630
	ror	ebx, 16
631
	mov	ebp, eax
632
 
633
	test	edx, edx
634
	jz	.no_postfix
635
 
636
	mov	eax, edx
637
	call	count_utf8z_chars
638
 
639
	test	eax, eax
640
	jz	.no_postfix
641
	push	ecx
642
	lea	eax, [eax*8]
643
	sub	bx, ax
644
	rol	ebx, 16
645
	or	ecx, 0xB0000000
646
	mcall	SF_DRAW_TEXT
647
	ror	ebx, 16
648
	pop	ecx
649
 
650
.no_postfix:
651
	mov	eax, ebp
652
	push	edx
653
 
654
	xor	edi, edi
655
 
656
	mov	esi, 10
657
@@:
658
	xor	edx, edx
659
	div	esi
660
	inc	edi
661
	test	eax, eax
662
	jz	@f
663
	jmp	@b
664
 
665
@@:
666
	pop	edx
667
	mov	esi, ecx
668
	or	esi, 0x10000000
669
	mov	ecx, ebp
670
	mov	edx, ebx
671
	lea	eax, [edi*8]
672
	sub	dx, ax
673
	rol	edx, 16
674
	mcall	SF_DRAW_NUMBER, (11 shl 16) or 0x80000000
675
 
676
	popa
677
	ret
678
;-------------------------------------------------------------------------------
679
 
680
draw_ra_data_size:
681
;-------------------------------------------------------------------------------
682
;draws data size with flush right alignment in following form:
683
;n (for <1024 bytes) or n xB (KB/MB/GB)
684
;8x16 font
685
;in:
686
;eax = number
687
;ebx = right margin coordinates (x shl 16 + y)
688
;ecx = 0x00RRGGBB
689
;-------------------------------------------------------------------------------
690
	pusha
691
 
692
	xor	edx, edx
693
	cmp	eax, 1024
694
	ja	@f
695
	jmp	.draw_text
696
 
697
@@:
698
	cmp	eax, 1024*1024
699
	jae	@f
700
	mov	esi,  1024
701
	div	esi
702
	mov	edx, strings.KB
703
	jmp	.draw_text
704
 
705
@@:
706
	cmp	eax, 1024*1024*1024
707
	jae	@f
708
	mov	esi,  1024*1024
709
	div	esi
710
	mov	edx, strings.MB
711
	jmp	.draw_text
712
 
713
@@:
714
	mov	esi,  1024*1024*1024
715
	div	esi
716
	mov	edx, strings.GB
717
 
718
.draw_text:
719
	call	draw_ra_dec_number
720
 
721
	popa
722
	ret
723
;-------------------------------------------------------------------------------
724
 
725
draw_ra_text:
726
;-------------------------------------------------------------------------------
727
;draws 8x16 UTF8Z text with flush right alignment in decimal form
728
;in:
729
;eax = pointer to text string
730
;ebx = right margin coordinates (x shl 16 + y)
731
;ecx = 0x00RRGGBB
732
;-------------------------------------------------------------------------------
733
	pusha
734
 
735
	ror	ebx, 16
736
	mov	edx, eax
737
 
738
	call	count_utf8z_chars
739
 
740
	test	eax, eax
741
	jz	.ret
742
	lea	eax, [eax*8]
743
	sub	bx, ax
744
	rol	ebx, 16
745
	or	ecx, 0xB0000000
746
	mcall	SF_DRAW_TEXT
747
 
748
.ret:
749
	popa
750
	ret
751
;-------------------------------------------------------------------------------
752
 
753
draw_button_with_caption:
754
;-------------------------------------------------------------------------------
755
;draws button with 8x16 UTF8Z caption in center
756
;in:
757
;eax = pointer to button caption or 0 - no caption
758
;ebx = x shl 16 + y
759
;ecx = 0x00XXXXXX, where XXXXXX - button ID
760
;edx = 0x00RRGGBB - button color
761
;esi = 0x00RRGGBB - text color
762
;out:
763
;eax = width of button
764
;ebx = x+width shl 16 + y
765
;-------------------------------------------------------------------------------
766
	pusha
767
 
768
	xor	ebp, ebp
769
	mov	edi, eax
770
	test	eax, eax
771
	jz	.no_caption_0
772
 
773
	call	count_utf8z_chars
774
	mov	ebp, eax
775
 
776
.no_caption_0:
777
	push	ebx esi
778
	lea	eax, [ebp*8]
779
	mov	esi, edx
780
	mov	edx, ecx
781
	mov	ecx, ebx
782
	shl	ecx, 16
783
	mov	bx, ax
784
	add	bx, 3*2
785
	movzx	eax, bx
786
	mov	dword [esp+4*2+4*7], eax	;out eax = width
787
	add	word [esp+4*2+4*4+2], ax	;out ebx = x+width shl 16 + y
788
	mov	cx, BUTTON.HEIGHT
789
	mcall	SF_DEFINE_BUTTON
790
	pop	esi ebx
791
	test	edi, edi
792
	jz	.no_caption_1
793
	mov	edx, edi
794
	add	ebx, 3 shl 16 + 3
795
	mov	ecx, esi
796
	or	ecx, 0xB0000000
797
	mcall	SF_DRAW_TEXT
798
 
799
.no_caption_1:
800
	popa
801
	ret
802
;-------------------------------------------------------------------------------
803
 
804
count_utf8z_chars:
805
;-------------------------------------------------------------------------------
806
;in:
807
;eax = pointer to UTF8Z string
808
;out:
809
;eax = count of chars (excluding finishing zero) (0 if string is empty or invalid)
810
;-------------------------------------------------------------------------------
811
	push	esi ebx
812
	mov	esi, eax
813
	xor	ebx, ebx
814
 
815
.0:
816
	lodsb
817
	test	al, al
818
	jz	.ok
819
	inc	ebx
820
	cmp	al, 0x7F
821
	ja	@f
822
	jmp	.0
823
@@:
824
	cmp	al, 0xC0
825
	jb	.err
826
	cmp	al, 0xDF
827
	ja	@f
828
	inc	esi
829
	jmp	.0
830
 
831
@@:
832
	cmp	al, 0xEF
833
	ja	@f
834
	inc	esi
835
	inc	esi
836
	jmp	.0
837
 
838
@@:
839
	cmp	al, 0xF7
840
	ja	.err
841
	add	esi, 3
842
	jmp	.0
843
 
844
.ok:
845
	mov	eax, ebx
846
	pop	ebx esi
847
	ret
848
 
849
.err:
850
	xor	eax, eax
851
	pop	ebx esi
852
	ret
853
;-------------------------------------------------------------------------------
854
 
31 halyavin 855
; DATA AREA
8561 Kenshin 856
;-------------------------------------------------------------------------------
857
system_path	db	"/sys/lib/"
858
library_name	db	"box_lib.obj", 0
1205 Lrz 859
 
8561 Kenshin 860
;-------------------------------------------------------------------------------
3587 fedesco 861
align 4
862
myimport:
8561 Kenshin 863
edit_box_draw		dd	aEdit_box_draw
864
edit_box_key		dd	aEdit_box_key
865
edit_box_mouse		dd	aEdit_box_mouse
866
;version_ed		dd	aVersion_ed
1205 Lrz 867
 
8561 Kenshin 868
init_checkbox		dd	aInit_checkbox
869
check_box_draw		dd	aCheck_box_draw
870
check_box_mouse	 dd	aCheck_box_mouse
871
;version_ch		dd	aVersion_ch
1205 Lrz 872
 
8561 Kenshin 873
;option_box_draw	dd	aOption_box_draw
874
;option_box_mouse	dd	aOption_box_mouse
875
;version_op		dd	aVersion_op
1205 Lrz 876
 
8561 Kenshin 877
		dd	0
878
		dd	0
1205 Lrz 879
 
8561 Kenshin 880
aEdit_box_draw		db	"edit_box",0
881
aEdit_box_key		db	"edit_box_key",0
882
aEdit_box_mouse	 db	"edit_box_mouse",0
883
;aVersion_ed		db	"version_ed",0
1205 Lrz 884
 
8561 Kenshin 885
aInit_checkbox		db	"init_checkbox2",0
886
aCheck_box_draw	 db	"check_box_draw2",0
887
aCheck_box_mouse	db	"check_box_mouse2",0
888
;aVersion_ch		db	"version_ch",0
1205 Lrz 889
 
8561 Kenshin 890
;aOption_box_draw	db	"option_box_draw",0
891
;aOption_box_mouse	db	"option_box_mouse",0
892
;aVersion_op		db	"version_op",0
893
;-------------------------------------------------------------------------------
3587 fedesco 894
align 4
8561 Kenshin 895
check1 check_box2 CHECKBOX.X shl 16 + 12, CHECKBOX.Y shl 16 + 12, 6, 0x80D6DEE7, 0x4C5258, 0xB0000000, strings.checkbox_caption, ch_flag_top
1266 Lrz 896
check1_end:
8561 Kenshin 897
edit1 edit_box EDITBOX.WIDTH, EDITBOX.X, EDITBOX.Y, 0xffffff, 0x6f9480, 0, 0xAABBCC, 0, start_application_c,\
898
	start_application,mouse_dd,ed_focus,start_application_e,start_application_e
1228 Lrz 899
edit1_end:
8561 Kenshin 900
list_start	dd	0
901
;-------------------------------------------------------------------------------
3587 fedesco 902
align 4
748 heavyiron 903
sys_reboot:
8561 Kenshin 904
		dd	SSF_START_APP
905
		dd	0
906
		dd	0
907
		dd	0
908
		dd	0
909
		db	"/sys/end",0
910
;-------------------------------------------------------------------------------
911
strings:
340 heavyiron 912
if lang eq de
8561 Kenshin 913
	.window_caption		utf8z	"Prozesse  - [Ctrl+Alt+Del]"
914
	.tmp_window_caption	db	"Process manager v0.2 - [Ctrl+Alt+Del]", 0
915
 
916
	.process_name		utf8z	"NAME/BEENDEN"
917
	.ptid			utf8z	"PID/TID"
918
	.cpu_usage_cycles	utf8z	"CPU(ZYKLEN)"
919
	.cpu_usage_percent	utf8z	"CPU(%)"
920
	.memory_usage		utf8z	"SPEICHER"
921
	.window_stack_pos	utf8z	"W-STACK"
922
	.window_position.x	utf8z	"W-POS-X"
923
	.window_position.y	utf8z	"W-POS-Y"
924
 
925
	.previous_page		utf8z	"SEITE ZURUECK"
926
	.next_page		utf8z	"SEITE VOR"
927
	.reboot			utf8z	"REBOOT SYSTEM"
928
	.run			utf8z	"START"
929
 
930
	.checkbox_caption	utf8z	"System"
931
 
932
	.KB			utf8z	" KB"
933
	.MB			utf8z	" MB"
934
	.GB			utf8z	" GB"
935
;-------------------------------------------------------------------------------
268 kaitz 936
else if lang eq et
8561 Kenshin 937
	.window_caption		utf8z	"Protsessid v0.2 - [Ctrl+Alt+Del]"
938
	.tmp_window_caption	db	"Process manager v0.2 - [Ctrl+Alt+Del]", 0
939
 
8562 Kenshin 940
	.process_name		utf8z	"NIMI/LÕPETA"
8561 Kenshin 941
	.ptid			utf8z	"PID/TID"
8562 Kenshin 942
	.cpu_usage_cycles	utf8z	"CPU(TSÜKLID)"
8561 Kenshin 943
	.cpu_usage_percent	utf8z	"CPU(%)"
8562 Kenshin 944
	.memory_usage		utf8z	"MÄLU"
8561 Kenshin 945
	.window_stack_pos	utf8z	"W-PUHVER"
946
	.window_position.x	utf8z	"W-POS-X"
947
	.window_position.y	utf8z	"W-POS-Y"
948
 
949
	.previous_page		utf8z	"EELMINE LEHT"
8562 Kenshin 950
	.next_page		utf8z	"JÄRGMINE LEHT"
951
	.reboot			utf8z	"REBOODI SÜSTEEM"
8561 Kenshin 952
	.run			utf8z	"START"
953
 
954
	.checkbox_caption	utf8z	"System"
955
 
956
	.KB			utf8z	" KB"
957
	.MB			utf8z	" MB"
958
	.GB			utf8z	" GB"
959
;-------------------------------------------------------------------------------
2559 mario79 960
else if lang eq ru
8562 Kenshin 961
	.window_caption		utf8z	"Диспетчер процессов v0.2 - [Ctrl+Alt+Del]"
8561 Kenshin 962
	.tmp_window_caption	db	"Process manager v0.2 - [Ctrl+Alt+Del]", 0
963
 
8562 Kenshin 964
	.process_name		utf8z	"ИМЯ/ЗАВЕРШИТЬ"
8561 Kenshin 965
	.ptid			utf8z	"PID/TID"
8562 Kenshin 966
	.cpu_usage_cycles	utf8z	"CPU(ТАКТЫ)"
8561 Kenshin 967
	.cpu_usage_percent	utf8z	"CPU(%)"
8562 Kenshin 968
	.memory_usage		utf8z	"ПАМЯТЬ"
8561 Kenshin 969
	.window_stack_pos	utf8z	"W-STACK"
970
	.window_position.x	utf8z	"W-POS-X"
971
	.window_position.y	utf8z	"W-POS-Y"
972
 
8562 Kenshin 973
	.previous_page		utf8z	"ПРЕД. СТР."
974
	.next_page		utf8z	"СЛЕД. СТР."
975
	.reboot			utf8z	"ПЕРЕЗАГРУЗКА"
976
	.run			utf8z	"ЗАПУСК"
8561 Kenshin 977
 
8562 Kenshin 978
	.checkbox_caption	utf8z	"Системные"
8561 Kenshin 979
 
8562 Kenshin 980
	.KB			utf8z	" КБ"
981
	.MB			utf8z	" МБ"
982
	.GB			utf8z	" ГБ"
8561 Kenshin 983
;-------------------------------------------------------------------------------
3587 fedesco 984
else if lang eq it
8561 Kenshin 985
	.window_caption		utf8z	"Gestore processi v0.2 - [Ctrl+Alt+Del]"
986
	.tmp_window_caption	db	"Process manager v0.2 - [Ctrl+Alt+Del]", 0
987
 
988
	.process_name		utf8z	"NOME-PROGRAMMA"
989
	.ptid			utf8z	"PID/TID"
990
	.cpu_usage_cycles	utf8z	"CPU(CICLI)"
991
	.cpu_usage_percent	utf8z	"CPU(%)"
992
	.memory_usage		utf8z	"MEMORY"
993
	.window_stack_pos	utf8z	"W-STACK"
994
	.window_position.x	utf8z	"W-POS-X"
995
	.window_position.y	utf8z	"W-POS-Y"
996
 
997
	.previous_page		utf8z	"INDIETRO"
998
	.next_page		utf8z	"AVANTI"
999
	.reboot			utf8z	"RIAVVIA SISTEMA"
1000
	.run			utf8z	"START"
1001
 
1002
	.checkbox_caption	utf8z	"System"
1003
 
1004
	.KB			utf8z	" KB"
1005
	.MB			utf8z	" MB"
1006
	.GB			utf8z	" GB"
1007
;-------------------------------------------------------------------------------
340 heavyiron 1008
else
8561 Kenshin 1009
	.window_caption		utf8z	"Process manager v0.2 - [Ctrl+Alt+Del]"
1010
	.tmp_window_caption	db	"Process manager v0.2 - [Ctrl+Alt+Del]", 0
1011
 
1012
	.process_name		utf8z	"NAME/TERMINATE"
1013
	.ptid			utf8z	"PID/TID"
1014
	.cpu_usage_cycles	utf8z	"CPU(CYCLES)"
1015
	.cpu_usage_percent	utf8z	"CPU(%)"
1016
	.memory_usage		utf8z	"MEMORY"
1017
	.window_stack_pos	utf8z	"W-STACK"
1018
	.window_position.x	utf8z	"W-POS-X"
1019
	.window_position.y	utf8z	"W-POS-Y"
1020
 
1021
 
1022
	.previous_page		utf8z	"PREV PAGE"
1023
	.next_page		utf8z	"NEXT PAGE"
1024
	.reboot			utf8z	"REBOOT SYSTEM"
1025
	.run			utf8z	"RUN"
1026
 
1027
	.checkbox_caption	utf8z	"System"
1028
 
1029
	.KB			utf8z	" KB"
1030
	.MB			utf8z	" MB"
1031
	.GB			utf8z	" GB"
135 diamond 1032
end if
8561 Kenshin 1033
;-------------------------------------------------------------------------------
3587 fedesco 1034
align 4
4968 0CodErr 1035
tinfo:
8561 Kenshin 1036
			dd	SSF_START_APP
1037
			dd	0
1038
.params		dd	.params_buf
1039
			dd	0
1040
			dd	0
1041
			db	0
1042
.file_path		dd	sz_tinfo_file_path
4968 0CodErr 1043
align 4
1044
.params_buf:
8561 Kenshin 1045
times 11 db	0 ; at now 4 bytes will be enough, but may be in the future not
4968 0CodErr 1046
align 4
8561 Kenshin 1047
sz_tinfo_file_path	db	"/sys/tinfo",0
1048
;-------------------------------------------------------------------------------
4968 0CodErr 1049
align 4
2559 mario79 1050
file_start:
8561 Kenshin 1051
	dd	SSF_START_APP
1052
	dd	0
1053
	dd	0
1054
	dd	0
1055
	dd	0
1056
start_application: db	"/sys/LAUNCHER",0
1205 Lrz 1057
start_application_e=$-start_application-1
8561 Kenshin 1058
;			times 60 db	0
1059
	rb	60
1205 Lrz 1060
start_application_c=$-start_application-1
8561 Kenshin 1061
;-------------------------------------------------------------------------------
2559 mario79 1062
IM_END:
8561 Kenshin 1063
;-------------------------------------------------------------------------------
3587 fedesco 1064
align 4
1228 Lrz 1065
sc system_colors
8561 Kenshin 1066
winxpos	 rd	1
1067
winypos	 rd	1
1068
mouse_dd	rd	1
1069
cpu_percent	rd	1
1070
list_add	rd	1
1071
curposy	 rd	1
1072
index		rd	1
1073
tasklist	rd	DISPLAY_PROCESSES
1074
time_counter	rd	1
2582 mario79 1075
 
8561 Kenshin 1076
window_status		rd	1
1077
client_area_x_size	rd	1
1078
client_area_y_size	rd	1
1079
bar_bacground_color	rd	1
1080
btn_bacground_color	rd	1
1081
draw_window_flag	rd	1
1082
;-------------------------------------------------------------------------------
3587 fedesco 1083
align 4
2559 mario79 1084
library_path:
31 halyavin 1085
process_info_buffer process_information
8561 Kenshin 1086
;-------------------------------------------------------------------------------
3587 fedesco 1087
align 4
2559 mario79 1088
cur_dir_path:
8561 Kenshin 1089
	rb	1024
1090
	rb	1024
2559 mario79 1091
stack_area:
31 halyavin 1092
U_END: