Subversion Repositories Kolibri OS

Rev

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