Subversion Repositories Kolibri OS

Rev

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