Subversion Repositories Kolibri OS

Rev

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

Rev 2128 Rev 2559
Line 1... Line 1...
1
;
1
;
2
;   PROCESS MANAGEMENT
2
;   CPU -process Manager
3
;
3
;
-
 
4
;------------------------------------------------------------------------------
4
;   VTurjanmaa
5
; version:	1.70
-
 
6
; last update:  04/04/2012
-
 
7
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
-
 
8
; changes:      Code refactoring and optimization.
-
 
9
;               Added russian language support.
-
 
10
;               Fix - processes information showing  not been updated during
-
 
11
;               the processing of mouse events.
-
 
12
;------------------------------------------------------------------------------
-
 
13
; Many fix's and changes created by:
-
 
14
;               Diamond, Heavyiron, SPraid, ,
5
;   additions by M.Lisovin lisovin@26.ru
15
;               Leency, IgorA, kaitz
-
 
16
;---------------------------------------------------------------------
6
;   integrated with load_lib.obj by 
17
;   integrated with load_lib.obj by 
-
 
18
;---------------------------------------------------------------------
-
 
19
;   additions by M.Lisovin lisovin@26.ru
-
 
20
;---------------------------------------------------------------------
7
;   Compile with FASM for Menuet
21
;   original author - VTurjanmaa
8
;
-
 
9
 
-
 
-
 
22
;------------------------------------------------------------------------------
10
  use32
23
	use32
11
  org	 0x0
24
	org 0x0
12
	STACK_SIZE=1024
-
 
13
	offset_y=22		; Correction for skin
-
 
14
	offset_x=5
-
 
15
  db	 'MENUET01'			; 8 byte id
25
	db 'MENUET01'		; 8 byte id
16
  dd	 0x01				; header version
26
	dd 0x01			; header version
17
  dd	 START				; start of code
27
	dd START		; start of code
18
  dd	 I_END				; size of image
28
	dd IM_END		; size of image
19
  dd	 U_END+STACK_SIZE	; memory for app
29
	dd U_END		; memory for app
20
  dd	 U_END+STACK_SIZE	; esp
30
	dd stack_area		; esp
21
  dd	 0x0 , 0x0			; I_Param , I_Icon
31
	dd 0x0			; boot parameters
22
 
32
	dd 0x0			; path
-
 
33
;------------------------------------------------------------------------------
23
include 'lang.inc'
34
include 'lang.inc'
24
include '../../../macros.inc'
35
include '../../../macros.inc'
25
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
36
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
26
include '../../../develop/libraries/box_lib/load_lib.mac'
37
include '../../../develop/libraries/box_lib/load_lib.mac'
-
 
38
;------------------------------------------------------------------------------
27
display_processes=32		; number of processes to show
39
display_processes=32		; number of processes to show
-
 
40
window_x_size=524
-
 
41
window_y_size=430
-
 
42
;------------------------------------------------------------------------------
28
@use_library	;use load lib macros
43
@use_library	;use load lib macros
-
 
44
;------------------------------------------------------------------------------
29
START:				; start of execution
45
START:				; start of execution
30
 
46
	mcall	68,11
31
sys_load_library  library_name, cur_dir_path, library_path, system_path, \
47
sys_load_library  library_name, cur_dir_path, library_path, system_path, \
32
err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
48
err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
33
	inc	eax
49
	inc	eax
34
	jz	close
50
	jz	close
35
; calculate window position
-
 
36
; at the center of the screen
51
;------------------------------------------------------------------------------
37
    mcall 40,0x27	;set event
52
	mcall	40,0x27	;set event
-
 
53
;------------------------------------------------------------------------------
-
 
54
;set window size and position for 0 function
-
 
55
;to [winxpos] and [winypos] variables
-
 
56
;get screen size
-
 
57
	mcall	14
-
 
58
	mov	ebx,eax
38
    call calculate_window_pos
59
;calculate (x_screen-window_x_size)/2    
-
 
60
	shr	ebx,16+1
-
 
61
	sub	ebx,window_x_size/2
39
    
62
	shl	ebx,16
-
 
63
	mov	bx,window_x_size
-
 
64
;winxpos=xcoord*65536+xsize    
-
 
65
	mov	[winxpos],ebx
40
;main loop when process name isn't edited.    
66
;calculate (y_screen-window_y_size)/2    
-
 
67
	and	eax,0xffff
41
red:	
68
	shr	eax,1
-
 
69
	sub	eax,window_y_size/2
-
 
70
	shl	eax,16
-
 
71
	mov	ax,window_y_size
-
 
72
;winypos=ycoord*65536+ysize    
-
 
73
	mov	[winypos],eax
-
 
74
;------------------------------------------------------------------------------	
42
	mcall	48,3,sc,40
75
	mcall	48,3,sc,40
43
	edit_boxes_set_sys_color edit1,edit1_end,sc		;set color
76
	edit_boxes_set_sys_color edit1,edit1_end,sc		;set color
44
	check_boxes_set_sys_color check1,check1_end,sc	;set color
77
	check_boxes_set_sys_color check1,check1_end,sc	;set color
-
 
78
;------------------------------------------------------------------------------
45
	xor	ebp,ebp
79
align 4	  
-
 
80
;main loop when process name isn't edited.    
46
	inc	ebp
81
red:	
47
;    mov  ebp,1
-
 
48
    call draw_window		; redraw all window
82
	call	draw_window		; redraw all window
-
 
83
;------------------------------------------------------------------------------
-
 
84
align 4	
49
still:
85
still:
50
    mcall 23,100		; wait here for event 1 sec.
86
	mcall	23,100		; wait here for event 1 sec.
Line 51... Line 87...
51
 
87
 
52
    dec  eax		      ; redraw request ?
88
	dec	eax		      ; redraw request ?
-
 
89
	jz	red
53
    jz	 red
90
 
54
    dec  eax		      ; key in buffer ?
91
	dec	eax		      ; key in buffer ?
-
 
92
	jz	key
55
    jz	 key
93
 
56
    dec  eax		      ; button in buffer ?
94
	dec	eax		      ; button in buffer ?
Line 57... Line 95...
57
    jz	 button
95
	jz	button
58
 
96
 
-
 
97
;	sub	eax,3		      ; If not use mouse - show 
59
    sub eax,3		      ; If not use mouse - show 
98
;	jnz	still_end
60
    jnz still_end
99
 
-
 
100
	push	dword edit1
61
	push	dword edit1
101
	call	[edit_box_mouse]
-
 
102
	
62
	call	[edit_box_mouse]
103
	push	dword[check1+32]
63
	push	dword[check1+32]
104
	
-
 
105
	push	dword check1
64
	push	dword check1
106
	call	[check_box_mouse]
-
 
107
	
65
	call	[check_box_mouse]
108
	pop	eax
66
	pop	eax
109
	
67
	cmp	eax, dword[check1+32]
-
 
Line -... Line 110...
-
 
110
	cmp	eax, dword[check1+32]
-
 
111
	jz	still_end
-
 
112
	
-
 
113
	push	dword check1
-
 
114
	call	[check_box_draw]
68
	jnz	still_end
115
;--------------------------------------
-
 
116
align 4	
-
 
117
show_process_info_1:	
-
 
118
	mcall	26,9
69
    jmp still	
119
	add	eax,100
70
 
-
 
71
still_end:    
120
	mov	[time_counter],eax
-
 
121
 
-
 
122
	call	show_process_info	; draw new state of processes
-
 
123
	jmp	still
-
 
124
;------------------------------------------------------------------------------
-
 
125
align 4	
-
 
126
still_end:
Line -... Line 127...
-
 
127
	mcall	26,9
-
 
128
	cmp	[time_counter],eax
Line -... Line 129...
-
 
129
	ja	still
-
 
130
 
-
 
131
	add	eax,100
-
 
132
	mov	[time_counter],eax
72
    xor  ebp,ebp		; draw new state of processes
133
 
73
    call draw_window
134
	call	show_process_info	; draw new state of processes
Line 74... Line 135...
74
    jmp  still
135
	jmp	still
75
 
136
;------------------------------------------------------------------------------
-
 
137
align 4	
76
 
138
key:				; key
77
  key:				; key
139
	mcall	2
-
 
140
 
78
    mcall 2
141
	cmp	ah,184 		; PageUp
79
 
142
	jz	pgdn
Line 80... Line 143...
80
    cmp  ah,184 		; PageUp
143
 
81
    jz	 pgdn
144
	cmp	ah,183
82
    cmp  ah,183
145
	jz	pgup			; PageDown
83
    jz	 pgup			; PageDown
146
 
84
    cmp  ah,27
147
	cmp	ah,27
85
    jz	 close			; Esc
148
	jz	close			; Esc
-
 
149
 
86
 
150
	push	dword edit1
87
	push	dword edit1
151
	call	[edit_box_key]
Line 88... Line 152...
88
	call	[edit_box_key]
152
				; Check ENTER with ed_focus edit_box
-
 
153
	lea	edi,[edit1]
89
				; Check ENTER with ed_focus edit_box
154
	test	word ed_flags,ed_focus
90
    lea  edi,[edit1]
155
	jz	still_end 
91
    test word ed_flags,ed_focus
156
 
92
    jz	 still_end 
-
 
93
    sub  ah,13			; ENTER?
157
	sub	ah,13			; ENTER?
94
    jz	 program_start		; RUN a program
158
	jz	program_start		; RUN a program
95
 
-
 
96
    jmp  still
159
 
97
 
160
	jmp	still
98
  button:			
161
;------------------------------------------------------------------------------
-
 
162
align 4	
99
; get button id  
163
button:			
100
    mov  eax,17 		
164
; get button id  
101
    mcall
-
 
102
    shr  eax,8			
165
	mcall	17
103
 
166
	shr	eax,8			
104
;id in [10,50] corresponds to terminate buttons.
-
 
105
    cmp  eax,10
167
;id in [10,50] corresponds to terminate buttons.
106
    jb	 noterm 		
168
	cmp	eax,10
107
    cmp  eax,50
-
 
108
    jg	 noterm
169
	jb	noterm 		
109
 
170
 
110
;calculate button index        
171
	cmp	eax,50
111
    sub  eax,11
172
	jg	noterm
112
    
-
 
113
;calculate process slot    
-
 
114
    mov  ecx,[tasklist+4*eax]
173
;calculate button index        
115
    
174
	sub	eax,11
-
 
175
;calculate process slot    
116
;ignore empty buttons
176
	mov	ecx,[tasklist+4*eax]
117
    test ecx,ecx
177
;ignore empty buttons
118
    jle  still_end
-
 
119
;terminate application    
178
	test	ecx,ecx
120
    mov  eax,18
179
	jle	still_end
121
    mov  ebx,2
180
;terminate application    
Line 122... Line 181...
122
    mcall
181
	mcall	18,2
123
    jmp  still_end 
182
	jmp	show_process_info_1	;still_end 
-
 
183
;--------------------------------------
124
 
184
align 4
125
  noterm:
185
noterm:
126
 
186
;special buttons
127
;special buttons
-
 
128
    dec  eax
187
	dec	eax
129
    jz	 close
188
	jz	close
-
 
189
 
130
 
190
	sub	eax,50
131
    sub  eax,50
191
	jz	pgdn	  ;51
132
    jz	 pgdn	  ;51
-
 
Line -... Line 192...
-
 
192
 
133
    dec  eax
193
	dec	eax
-
 
194
	jz	pgup	  ;52
134
    jz	 pgup	  ;52
195
 
135
;    dec  eax
196
	dec	eax
136
;    jz   read_string
197
	jz	program_start	;53
137
    dec  eax
198
 
138
    jz	 program_start	;53
199
	dec	eax
139
    dec  eax
200
	jz	reboot 	;54
140
    jz	 reboot 	;54
201
 
-
 
202
	jmp	still_end
141
    jmp  still_end
203
;buttons handlers    
142
    
204
;------------------------------------------------------------------------------
143
;buttons handlers    
205
align 4	
144
 
206
pgdn:
145
  pgdn:
207
	sub	[list_start],display_processes
-
 
208
;	cmp	[list_start],0
146
    sub  [list_start],display_processes
209
	jge	show_process_info_1	;still_end  
147
;    cmp  [list_start],0
210
	mov	[list_start],0
148
    jge  still_end  
-
 
149
    mov  [list_start],0
211
	jmp	show_process_info_1	;still_end  
150
    jmp  still_end  
-
 
151
 
212
;------------------------------------------------------------------------------
-
 
213
align 4	
152
  pgup:
214
pgup:
153
    mov  eax,[list_add]  ;maximal displayed process slot
215
	mov	eax,[list_add]  ;maximal displayed process slot
154
    mov  [list_start],eax
-
 
155
    jmp  still_end  
216
	mov	[list_start],eax
156
    
-
 
157
  program_start:    
217
	jmp	show_process_info_1	;still_end  
-
 
218
;------------------------------------------------------------------------------
158
    mov  eax,70
219
align 4	    
159
    mov  ebx,file_start
220
program_start:    
160
    mcall
221
	mcall	70,file_start
161
    jmp  still_end
222
	jmp	show_process_info_1	;still_end
-
 
223
;------------------------------------------------------------------------------
162
    
224
align 4	
163
  reboot:    
225
reboot:    
164
    mov  eax,70
226
	mcall	70,sys_reboot
165
    mov  ebx,sys_reboot
227
;close program if we going to reboot
166
    mcall
228
;------------------------------------------------------------------------------
167
;close program if we going to reboot
229
align 4	
168
 
230
close:
169
  close:
231
	or	eax,-1 		; close this program
170
    or	 eax,-1 		; close this program
-
 
171
    mcall
-
 
172
 
-
 
173
draw_next_process:
-
 
174
;input:
232
	mcall
175
;  edi - current slot
-
 
176
;  [curposy] - y position
233
;------------------------------------------------------------------------------
177
;output:
234
align 4	
178
;  edi - next slot (or -1 if no next slot)
235
draw_next_process:
179
;registers corrupted!
-
 
180
    
-
 
181
;create button
236
;input:
182
    test  ebp,ebp
-
 
183
    jnz   .nodelete
-
 
184
;delete old button
237
;  edi - current slot
185
    mov   eax,8
-
 
186
    mov   edx,[index]
238
;  [curposy] - y position
187
    add   edx,(1 shl 31)+11
239
;output:
188
    mcall
240
;  edi - next slot (or -1 if no next slot)
189
 
241
;registers corrupted!
190
.nodelete:
242
;delete old button
191
;create terminate process button
243
	mov	edx,[index]
192
    mov   eax,8
244
	add	edx,(1 shl 31)+11
193
    mov   ebx,(15-offset_x)*65536+121-offset_y
245
	mcall	8
194
    mov   ecx,[curposy]
246
;create terminate process button
-
 
247
	mov	ecx,[curposy]
195
	;sub   ecx,1
248
	shl	ecx,16
196
    shl   ecx,16
249
	mov	cx,10
197
    mov   cx,10
250
	mov	edx,[index]
198
    mov   edx,[index]
-
 
199
    add   edx,11
251
	add	edx,11
200
    mov   esi,0xaabbcc
-
 
201
;contrast    
-
 
202
    test  dword [index],1
252
	mov	esi,0xaabbcc
203
    jz	  .change_color_button
253
;contrast    
204
    mov   esi,0x8899aa
254
	test	dword [index],1
205
 
255
	jz	.change_color_button
206
.change_color_button:
256
	mov	esi,0x8899aa
207
    mcall
257
;--------------------------------------
-
 
258
align 4
208
    
259
.change_color_button:
209
;draw background for proccess information
260
	mcall	,<10,99>
210
    mov   eax,13
261
;draw background for proccess information
211
    mov   ebx,(115-offset_x)*65536+395
-
 
212
    ;ecx was already set
262
; ecx was already set
213
    mov   edx,0x88ff88
263
	mov	edx,0x88ff88
214
;contrast
264
;contrast
215
    test  dword [index],1
265
	test	dword [index],1
216
    jz	  .change_color_info
-
 
-
 
266
	jz	.change_color_info
217
    mov   edx,0xddffdd
267
	mov	edx,0xddffdd
218
 
268
;--------------------------------------
-
 
269
align 4
219
.change_color_info:
270
.change_color_info:
220
    mcall
271
	mcall	13,<110,395>
221
    
272
;nothing else should be done
222
;nothing else should be done
273
;if there is no process for this button    
223
;if there is no process for this button    
274
	test	edi,edi
224
    test  edi,edi
-
 
225
    jl	  .ret
275
	jl	.ret
226
    
276
;--------------------------------------
227
;find process
277
align 4
228
.return_1:
278
.return_1:
229
    inc   edi
279
;find process
230
;more comfortable register for next loop    
-
 
231
    mov   ecx,edi
280
	inc	edi
232
;precacluate pointer to process buffer    
-
 
233
    mov   ebx,process_info_buffer
-
 
234
    
281
;more comfortable register for next loop    
235
;find process loop
-
 
236
 
282
	mov	ecx,edi
237
.find_loop:
283
;precacluate pointer to process buffer    
238
    cmp   ecx,256
284
	mov	ebx,process_info_buffer
239
    jge   .no_processes
285
;--------------------------------------
240
    
-
 
241
;load process information in buffer
286
align 4
242
    mov   eax,9
287
.find_loop:
243
;    mov   ebx,process_info_buffer
288
	cmp	ecx,256
Line 244... Line 289...
244
    mcall
289
	jge	.no_processes
245
    
290
;load process information in buffer
-
 
291
	mcall	9
246
;if current slot greater than maximal slot,
292
;if current slot greater than maximal slot,
247
;there is no more proccesses.    
293
;there is no more proccesses.    
248
    cmp   ecx,eax
294
	cmp	ecx,eax
249
    jg	  .no_processes
295
	jg	.no_processes
-
 
296
;if slot state is equal to 9, it is empty.    
250
    
297
	cmp	[process_info_buffer+process_information.slot_state],9
251
;if slot state is equal to 9, it is empty.    
298
	jnz	.process_found
252
    cmp   [process_info_buffer+process_information.slot_state],9
299
    
253
    jnz   .process_found
300
	inc	ecx
254
    
301
	jmp	.find_loop
255
    inc   ecx
302
;--------------------------------------
256
    jmp   .find_loop
303
align 4
257
    
304
.no_processes:
-
 
305
	or	edi,-1
258
.no_processes:
306
	ret
259
    or	 edi,-1
307
;--------------------------------------
-
 
308
align 4
260
    ret
309
.process_found:
261
    
310
;check on/off check box
-
 
311
	push	edi
262
.process_found:
312
	lea	edi,[check1]
263
;check on/off check box
313
	test	dword ch_flags,ch_flag_en
-
 
314
	pop	edi
264
    push edi
315
	jnz	@f
265
    lea  edi,[check1]
316
 
266
    test dword ch_flags,ch_flag_en
317
	cmp	dword [process_info_buffer+10],'ICON'
267
    pop  edi
318
	jz	.return_1 
268
    jnz   @f
-
 
269
    cmp   dword [process_info_buffer+10],'ICON'
319
 
270
    jz	  .return_1 
320
	cmp	dword [process_info_buffer+10],'OS/I'
271
    cmp   dword [process_info_buffer+10],'OS/I'
-
 
272
    jz	  .return_1
-
 
273
    cmp   byte [process_info_buffer+10],'@'
321
	jz	.return_1
274
    jz	  .return_1
-
 
275
 
322
 
276
 
323
	cmp	byte [process_info_buffer+10],'@'
277
@@: mov  edi,ecx
324
	jz	.return_1
278
    mov  [list_add],ecx
-
 
279
    
325
;--------------------------------------
280
;get processor cpeed    
326
align 4
281
;for percent calculating
327
@@:
282
    mov  eax,18
328
	mov	edi,ecx
283
    mov  ebx,5
329
	mov	[list_add],ecx
284
    mcall
330
;get processor cpeed    
285
    
-
 
286
    xor  edx,edx
331
;for percent calculating
287
    mov  ebx,100
332
	mcall	18,5
288
    div  ebx
-
 
289
    
333
	xor	edx,edx
290
;eax = number of operation for 1% now
334
	mov	ebx,100
291
;calculate process cpu usage percent
335
	div	ebx
292
    mov  ebx,eax
336
;eax = number of operation for 1% now
293
    mov  eax,[process_info_buffer+process_information.cpu_usage]
337
;calculate process cpu usage percent
294
;    cdq
338
	mov	ebx,eax
295
    xor edx,edx ; for CPU more 2 GHz - mike.dld 
339
	mov	eax,[process_info_buffer+process_information.cpu_usage]
-
 
340
;	cdq
296
 
341
	xor	edx,edx ; for CPU more 2 GHz - mike.dld 
297
    div  ebx
342
	div	ebx
-
 
343
	mov	[cpu_percent],eax
298
    mov  [cpu_percent],eax
344
;set text color to display process information
299
    
345
;([tcolor] variable)
300
;set text color to display process information
346
;0%      : black    
301
;([tcolor] variable)
347
;1-80%   : green
-
 
348
;81-100% : red
302
;0%      : black    
349
	test	eax,eax
303
;1-80%   : green
350
	jnz	.no_black
-
 
351
 
304
;81-100% : red
352
	mov	[tcolor],eax
305
    test eax,eax
353
	jmp	.color_set
306
    jnz  .no_black
354
;--------------------------------------
-
 
355
align 4
-
 
356
.no_black:   
307
    mov  [tcolor],eax
357
	cmp	eax,80
308
    jmp  .color_set
-
 
309
 
358
	ja	.no_green
310
.no_black:   
-
 
311
    cmp  eax,80
-
 
312
    ja	 .no_green
359
 
313
    mov  dword [tcolor],0x107a30
360
	mov	dword [tcolor],0x107a30
314
    jmp  .color_set
361
	jmp	.color_set
315
 
362
;--------------------------------------
316
.no_green:
363
align 4
317
    mov  dword [tcolor],0xac0000
-
 
318
.color_set:
-
 
319
 
364
.no_green:
320
;show slot number
-
 
321
    mov  eax,47 	       
365
	mov	dword [tcolor],0xac0000
322
    mov  ebx,2*65536+1*256
366
;--------------------------------------
323
;ecx haven't changed since .process_found    
-
 
324
;    mov  ecx,edi
367
align 4
325
    mov  edx,[curposy]
-
 
326
    add  edx,(20-offset_x)*65536+1
-
 
327
    mov  esi,[tcolor]
-
 
328
    mcall
368
.color_set:
329
    
-
 
330
;show process name
-
 
331
    mov  eax,4
-
 
332
    mov  ebx,[curposy]
369
;show slot number
333
    add  ebx,(50-offset_x)*65536+1
370
;ecx haven't changed since .process_found    
334
    mov  ecx,[tcolor]
371
;	mov	ecx,edi
335
    mov  edx,process_info_buffer.process_name
-
 
336
    mov  esi,11
-
 
337
    mcall
372
	mov	edx,[curposy]
338
    
-
 
339
;show pid
373
	add	edx,15*65536+1
340
    mov  eax,47
374
	mcall	47,<2,256>,,,[tcolor]
341
    mov  ebx,8*65536+1*256
-
 
342
    mov  ecx,[process_info_buffer.PID]
375
;show process name
343
    mov  edx,[curposy]
-
 
344
    add  edx,(130-offset_x)*65536+1
-
 
345
    mov  esi,[tcolor]
376
	mov	ebx,[curposy]
346
    mcall
377
	add	ebx,45*65536+1
347
    
-
 
348
;show cpu usage
378
	mcall	4,,[tcolor],process_info_buffer.process_name,11
349
    mov  ecx,[process_info_buffer.cpu_usage]
-
 
350
    add  edx,60*65536
-
 
351
    mcall
379
;show pid
352
    
380
	mov	edx,[curposy]
353
;show cpu percent
-
 
354
    mov  ebx,3*65536+0*256
381
	add	edx,125*65536+1
355
    mov  ecx,[cpu_percent]
382
	mcall	47,<8,256>,[process_info_buffer.PID],,[tcolor]
356
    add  edx,60*65536
383
;show cpu usage
357
    mcall
384
	add	edx,60*65536
358
    
385
	mcall	,,[process_info_buffer.cpu_usage]
359
;show memory start - obsolete
-
 
360
    mov  ebx,8*65536+1*256
386
;show cpu percent
361
    mov  ecx,[process_info_buffer.memory_start]
-
 
362
    add  edx,30*65536
387
	add	edx,60*65536
363
    mcall
388
	mcall	,<3,0>,[cpu_percent]
364
    
-
 
365
;show memory usage
389
;show memory start - obsolete
366
    mov  ecx,[process_info_buffer.used_memory]
390
	add	edx,30*65536
367
    inc  ecx
391
	mcall	,<8,256>,[process_info_buffer.memory_start]
368
    add  edx,60*65536
392
;show memory usage
369
    mcall
393
	mov	ecx,[process_info_buffer.used_memory]
370
    
394
	inc	ecx
-
 
395
	add	edx,60*65536
371
;show window stack and value
396
	mcall
372
    mov  ecx,dword [process_info_buffer.window_stack_position]
397
;show window stack and value
373
    add  edx,60*65536
398
	add	edx,60*65536
374
    mcall
399
	mcall	,,dword [process_info_buffer.window_stack_position]
375
    
400
;show window xy size
376
;show window xy size
401
	mov	ecx,[process_info_buffer.box.left]
377
    mov  ecx,[process_info_buffer.box.left]
-
 
378
    shl  ecx,16
-
 
379
    add  ecx,[process_info_buffer.box.top]
-
 
380
    add  edx,60*65536
402
	shl	ecx,16
381
    mcall    
-
 
382
	    
-
 
383
.ret:
403
	add	ecx,[process_info_buffer.box.top]
384
;build index->slot map for terminating processes.
-
 
385
    mov  eax,[index]
-
 
386
    mov  [tasklist+4*eax],edi	     
-
 
387
    ret
-
 
388
 
-
 
389
;read_string:
-
 
390
;clean string
-
 
391
;    mov  edi,start_application
-
 
392
;    xor  eax,eax
-
 
393
;    mov  ecx,60
404
	add	edx,60*65536
394
;    cld
405
	mcall 
395
;    rep  stosb
406
;--------------------------------------
396
;    call print_text
-
 
397
 
-
 
398
;    mov  edi,start_application
-
 
399
;edi now contains pointer to last symbol       
407
align 4
400
;    jmp  still1
408
.ret:
401
 
-
 
402
;read string main loop
-
 
403
 
-
 
404
  f11:
-
 
405
;full update  
-
 
406
    push edi
-
 
407
	xor	ebp,ebp
-
 
408
	inc	ebp
-
 
409
;    mov  ebp,1
-
 
410
    call draw_window
-
 
411
    pop  edi
-
 
412
;
409
;build index->slot map for terminating processes.
413
;  still1:  
-
 
414
;wait for message  
-
 
415
;    mov  eax,23
-
 
416
;    mov  ebx,100
-
 
417
;    mcall
-
 
418
;    cmp  eax,1
-
 
419
;    je   f11
-
 
420
;if no message - update process information    
-
 
421
;    cmp  eax,0
-
 
422
;    jnz  .message_received
-
 
423
;    push edi                ;edi should be saved since draw_window
-
 
424
;    xor  ebp,ebp            ;corrupt registers
-
 
425
;    call draw_window
-
 
426
;    pop  edi
-
 
427
;    jmp  still1
-
 
428
;    
-
 
429
;.message_received:
-
 
430
;    cmp  eax,2
-
 
431
;    jne  read_done          ;buttons message
-
 
432
;read char    
-
 
433
;    mov  eax,2
-
 
434
;    mcall
-
 
435
;    shr  eax,8
-
 
436
    
-
 
437
;if enter pressed, exit read string loop    
-
 
438
;    cmp  eax,13
-
 
439
;    je   read_done
-
 
440
;if backslash pressed?    
-
 
441
;    cmp  eax,8
-
 
442
;    jnz  nobsl
-
 
443
;decrease pointer to last symbol    
-
 
444
;    cmp  edi,start_application
-
 
445
;    jz   still1
-
 
446
;    dec  edi
-
 
447
;fill last symbol with space because
-
 
448
;print_text show all symbols    
-
 
449
;    mov  [edi],byte 32
-
 
450
;    call print_text
-
 
451
;    jmp  still1
-
 
452
;    
-
 
453
;  nobsl:
-
 
454
;write new symbol  
-
 
455
;    mov  [edi],al
-
 
456
;display new text
-
 
457
;    call print_text
-
 
458
;increment pointer to last symbol
-
 
459
;    inc  edi
-
 
460
;compare with end of string    
-
 
461
;    mov  esi,start_application
-
 
462
;    add  esi,60
-
 
463
;    cmp  esi,edi
-
 
464
;    jnz  still1
-
 
465
 
-
 
466
;exiting from read string loop
-
 
467
;
-
 
468
;  read_done:
-
 
469
;terminate string for file functions
-
 
470
;    mov  [edi],byte 0
-
 
471
 
-
 
472
;    call print_text
-
 
473
;    jmp  still
-
 
474
 
-
 
475
;
-
 
476
;print_text:
-
 
477
;display start_application string
-
 
478
 
-
 
479
;    pushad
-
 
480
    
-
 
481
;display text background
-
 
482
;    mov  eax,13
-
 
483
;    mov  ebx,64*65536+62*6
-
 
484
;    mov  ecx,400*65536+12
-
 
485
;    mov  edx,0xffffcc  ;0xeeeeee
-
 
486
;    mcall
-
 
487
    
-
 
488
;display text    
-
 
489
;    mov  eax,4                  
-
 
490
;    mov  edx,start_application  ;from start_application string
-
 
491
;    mov  ebx,70*65536+402       ;text center-aligned
-
 
492
;    xor  ecx,ecx                ;black text
-
 
493
;    mov  esi,60                 ;60 symbols
-
 
494
;    mcall
-
 
495
 
-
 
496
;    popad
-
 
497
;    ret
-
 
498
 
-
 
499
window_x_size=524
-
 
500
window_y_size=430
-
 
501
 
-
 
502
calculate_window_pos:
-
 
503
;set window size and position for 0 function
-
 
504
;to [winxpos] and [winypos] variables
-
 
505
 
-
 
506
;get screen size
-
 
507
    mov  eax,14
-
 
508
    mcall
-
 
509
    mov  ebx,eax
-
 
510
    
-
 
511
;calculate (x_screen-window_x_size)/2    
-
 
512
    shr  ebx,16+1
-
 
513
    sub  ebx,window_x_size/2
-
 
514
    shl  ebx,16
-
 
515
    mov  bx,window_x_size
-
 
516
;winxpos=xcoord*65536+xsize    
-
 
517
    mov  [winxpos],ebx
-
 
518
    
-
 
519
;calculate (y_screen-window_y_size)/2    
410
	mov	eax,[index]
520
    and  eax,0xffff
411
	mov	[tasklist+4*eax],edi	     
521
    shr  eax,1
412
	ret
522
    sub  eax,window_y_size/2
-
 
523
    shl  eax,16
413
;------------------------------------------------------------------------------
524
    mov  ax,window_y_size
414
align 4	
525
;winypos=ycoord*65536+ysize    
-
 
526
    mov  [winypos],eax
-
 
527
    
-
 
528
    ret
-
 
529
 
-
 
530
;   *********************************************
-
 
531
;   *******  WINDOW DEFINITIONS AND DRAW ********
415
f11:
532
;   *********************************************
-
 
533
 
416
;full update  
534
align 16
417
	push	edi
535
draw_window:
418
	call	draw_window
536
;ebp=1 - redraw all
419
	pop	edi
537
;ebp=0 - redraw only process information
-
 
538
 
-
 
539
    test ebp,ebp
-
 
540
    jz	 .show_process_info
-
 
541
    
-
 
542
    mcall 12, 1		       
420
;------------------------------------------------------------------------------
543
 
-
 
544
	; DRAW WINDOW
421
;   *********************************************
545
    xor  eax,eax				; function 0 : define and draw window
-
 
546
    mov  ebx,[winxpos]			; [x start] *65536 + [x size]
422
;   *******  WINDOW DEFINITIONS AND DRAW ********
547
    mov  ecx,[winypos]			; [y start] *65536 + [y size]
-
 
Line 548... Line 423...
548
    mov  edx,0x34ddffdd			; color of work area RRGGBB,8->color
423
;   *********************************************
549
    mov  edi,title				; WINDOW CAPTION;
424
align 4	
-
 
425
draw_window:
550
    mcall
426
	mcall	12, 1		       
551
 
427
; DRAW WINDOW
Line 552... Line 428...
552
				   
428
	xor	eax,eax				; function 0 : define and draw window
553
    add  eax,4					; function 4 : write text to window
-
 
554
    mov  ebx,(22-offset_x)*65536+35-offset_y
-
 
555
    xor  ecx,ecx
-
 
556
    mov  edx,text
-
 
557
    mov  esi,text_len
-
 
558
    mcall
-
 
559
 
-
 
560
	push	dword edit1
-
 
561
	call	[edit_box_draw]
-
 
562
	push	dword check1
-
 
563
	call	[check_box_draw]
-
 
564
 
-
 
565
align 16
-
 
566
.show_process_info:
429
	xor	esi,esi
567
    mov  edi,[list_start]
430
	mcall	,[winxpos],[winypos],0x34ddffdd,,title
568
    mov  [list_add],edi
-
 
569
    mov  dword [index],0
-
 
Line -... Line 431...
-
 
431
; function 4 : write text to window
570
    mov  dword [curposy],54-offset_y
432
	xor	ecx,ecx
571
 
-
 
572
.loop_draw:
433
	mcall	4,<17,13>,,text,text_len
573
    call draw_next_process
-
 
574
    inc  dword [index]
-
 
575
    add  dword [curposy],10
-
 
576
    cmp  [index],display_processes
434
 
577
    jl	 .loop_draw
-
 
578
    
435
	push	dword edit1
579
    test ebp,ebp
436
	call	[edit_box_draw]
580
    jz	 .end_redraw
-
 
581
    mov  eax,8
437
 
582
    mov  esi,0xaabbcc
-
 
583
				    
438
	push	dword check1
584
; previous page button
-
 
585
    mov  ebx,(30-offset_x)*65536+96
-
 
586
    mov  ecx,(380-offset_y)*65536+10
-
 
587
    mov  edx,51
439
	call	[check_box_draw]
588
    mcall
-
 
589
				    
440
 
590
; next page button  52
441
	mcall	26,9
591
    mov  ebx,(130-offset_x)*65536+96
-
 
592
    inc  edx
442
	add	eax,100
593
    mcall
443
	mov	[time_counter],eax
594
			      
444
 
595
; ">" (text enter) button
445
	call	show_process_info
596
;    mov  ebx,30*65536+20
446
; previous page button
597
    add  ecx,20 shl 16
447
	mcall	8,<25,96>,<358,10>,51,0xaabbcc
598
;    inc  edx
-
 
599
;    mcall
448
; next page button  52
600
				    
-
 
601
; run button 53
-
 
602
    mov  ebx,(456-offset_x)*65536+50
449
	inc	edx
603
    inc  edx
-
 
604
    mcall
450
	mcall	,<125,96>
605
 
-
 
606
; reboot button    
-
 
607
    sub  ebx,120*65536		    
-
 
608
    add  ebx,60
-
 
609
    sub  ecx,20 shl 16
-
 
610
    inc  edx
-
 
611
    mcall
-
 
612
    
-
 
613
;"PREV PAGE", "NEXT PAGE" and "REBOOT" labels
-
 
614
    mov  eax,4
-
 
615
    mov  ebx,(50-offset_x)*65536+382-offset_y
451
; ">" (text enter) button
616
    xor  ecx,ecx
-
 
617
    mov  edx,tbts
-
 
618
    mov  esi,tbte-tbts
-
 
619
    mcall
-
 
620
 
452
	add	ecx,20 shl 16
621
;">" labels
-
 
622
;    mov  eax,4
-
 
623
;    mov  ebx,40*65536+402
453
; run button 53
624
;    xor  ecx,ecx
-
 
625
;    mov  edx,tbts_2
-
 
626
;    mov  esi,1
454
	inc	edx
627
;    mcall
-
 
628
 
-
 
629
;"RUN" labels
455
	mcall	,<451,50>
-
 
456
; reboot button    
-
 
457
	sub	ebx,120*65536		    
-
 
458
	add	ebx,60
-
 
459
	sub	ecx,20 shl 16
-
 
460
	inc	edx
-
 
461
	mcall
-
 
462
;"PREV PAGE", "NEXT PAGE" and "REBOOT" labels
-
 
463
	xor	ecx,ecx
630
;    mov  eax,4
464
	mcall	4,<45,360>,,tbts,tbte-tbts
-
 
465
;"RUN" labels
-
 
466
	mcall	,<464,380>,,tbts_3,tbte_2-tbts_3
-
 
467
;print application name in text box
-
 
468
	mcall	12, 2
-
 
469
	ret
-
 
470
;------------------------------------------------------------------------------
631
    mov  ebx,(475-offset_x)*65536+402-offset_y
471
align 4
-
 
472
show_process_info:
632
    xor  ecx,ecx
473
	mov	edi,[list_start]
-
 
474
	mov	[list_add],edi
633
    mov  edx,tbts_3
475
	mov	dword [index],0
634
    mov  esi,tbte_2-tbts_3
476
	mov	dword [curposy],32
635
    mcall
477
;--------------------------------------
Line 636... Line 478...
636
 
478
align 4
637
;print application name in text box
479
.loop_draw:
638
;    call print_text
480
	call	draw_next_process
639
 
481
	inc	dword [index]
-
 
482
	add	dword [curposy],10
640
    mcall 12, 2
483
	cmp	[index],display_processes
641
    
484
	jl	.loop_draw
642
.end_redraw:
-
 
643
    ret
485
	ret
644
 
486
;------------------------------------------------------------------------------
645
 
487
; DATA AREA
646
; DATA AREA
488
;------------------------------------------------------------------------------
Line 681... Line 523...
681
;aVersion_ch      db 'version_ch',0
523
;aVersion_ch		db 'version_ch',0
Line 682... Line 524...
682
 
524
 
683
;aOption_box_draw  db 'option_box_draw',0
525
;aOption_box_draw	db 'option_box_draw',0
684
;aOption_box_mouse db 'option_box_mouse',0
526
;aOption_box_mouse	db 'option_box_mouse',0
-
 
527
;aVersion_op		db 'version_op',0
-
 
528
;------------------------------------------------------------------------------
685
;aVersion_op       db 'version_op',0
529
align 4	
686
check1 check_box 10,(400-offset_y),6,11,0x80AABBCC,0,0,check_text,check_t_e,0;ch_flag_en
530
check1 check_box 10,378,6,11,0x80AABBCC,0,0,check_text,check_t_e,0;ch_flag_en
-
 
531
check1_end:
687
check1_end:
532
edit1 edit_box 350,95,376,0xffffff,0x6f9480,0,0xAABBCC,0,start_application_c,\
688
edit1 edit_box 350,(100-offset_x),(398-offset_y),0xffffff,0x6f9480,0,0xAABBCC,0,start_application_c,start_application,mouse_dd,ed_focus,start_application_e,start_application_e
533
   start_application,mouse_dd,ed_focus,start_application_e,start_application_e
689
edit1_end:
534
edit1_end:
-
 
535
list_start  dd 0
690
list_start  dd 0
536
;------------------------------------------------------------------------------
691
 
537
align 4	
692
sys_reboot:
538
sys_reboot:
693
	    dd 7
539
	    dd 7
694
	    dd 0
540
	    dd 0
695
	    dd 0
541
	    dd 0
696
	    dd 0
542
	    dd 0
697
	    dd 0
543
	    dd 0
698
	    db '/sys/end',0
-
 
-
 
544
	    db '/sys/end',0
699
 
545
;------------------------------------------------------------------------------
700
if lang eq de
546
if lang eq de
701
text:
547
text:
702
  db 'NAME/BEENDEN        PID     CPU-LAST   % '
548
	db 'NAME/BEENDEN        PID     CPU-LAST   % '
703
  db 'SPEICHER START/NUTZUNG  W-STACK   W-SIZE'
549
	db 'SPEICHER START/NUTZUNG  W-STACK   W-SIZE'
Line 704... Line 550...
704
text_len = $-text
550
text_len = $-text
705
 
551
 
706
tbts:	db  'SEITE ZURUECK       SEITE VOR                      REBOOT SYSTEM'
-
 
707
tbte:
552
tbts:	db 'SEITE ZURUECK       SEITE VOR                      REBOOT SYSTEM'
708
;tbts_2  db  '>'
553
tbte:
709
tbts_3	db  'START'
554
tbts_3	db 'START'
710
tbte_2:
555
tbte_2:
711
check_text db '@ gehoren/aus'
556
check_text	db '@ on/off'
712
check_t_e=$-check_text
-
 
-
 
557
check_t_e=$-check_text
713
title  db   'Prozesse  - Ctrl/Alt/Del',0
558
title	db 'Prozesse  - Ctrl/Alt/Del',0
714
 
559
;--------------------------------------
715
else if lang eq et
560
else if lang eq et
716
text:
561
text:
717
  db 'NIMI/LÕPETA         PID    CPU-KASUTUS %   '
562
	db 'NIMI/LÕPETA         PID    CPU-KASUTUS %   '
Line 718... Line 563...
718
  db 'MÄLU ALGUS/KASUTUS  W-PUHVER  W-SUURUS'
563
	db 'MÄLU ALGUS/KASUTUS  W-PUHVER  W-SUURUS'
719
text_len = $-text
564
text_len = $-text
720
 
-
 
721
tbts:	db  'EELMINE LEHT   JÄRGMINE LEHT                     REBOODI SÜSTEEM'
565
 
722
tbte:
566
tbts:	db 'EELMINE LEHT   JÄRGMINE LEHT                     REBOODI SÜSTEEM'
723
;tbts_2 db  '>'
567
tbte:
724
tbts_3	db  'START'
568
tbts_3	db 'START'
725
tbte_2:
569
tbte_2:
-
 
570
check_text	db '@ on/off'
-
 
571
check_t_e=$-check_text
-
 
572
title	db 'Protsessid - Ctrl/Alt/Del'
-
 
573
;--------------------------------------
-
 
574
else if lang eq ru
-
 
575
text:
Line -... Line 576...
-
 
576
	db 'ˆŒŸ/‡€‚…˜ˆ’œ      PID     CPU-‡€ƒ“‡Š€ %  '
-
 
577
	db '€ŒŸ’œ €—€‹Ž/‚‘…ƒŽ  W-STACK    W-SIZE'
-
 
578
text_len = $-text
-
 
579
 
-
 
580
tbts:	db '…„.‘’        ‘‹…„.‘’                          ……‡€ƒ“‡Š€'
-
 
581
tbte:
-
 
582
tbts_3	db '‡€“‘Š'
-
 
583
tbte_2:
726
check_text db '@ on/off'
584
check_text	db '@ ¢ª«/¢ëª«'
727
check_t_e=$-check_text
585
check_t_e=$-check_text
728
title  db   'Protsessid - Ctrl/Alt/Del'
586
title	db '„¨á¯¥âç¥à ¯à®æ¥áᮢ - Ctrl/Alt/Del',0
729
 
587
;--------------------------------------
730
else
588
else
Line 731... Line 589...
731
text:
589
text:
732
  db 'NAME/TERMINATE      PID     CPU-USAGE  %   '
590
	db 'NAME/TERMINATE      PID     CPU-USAGE  %   '
733
  db 'MEMORY START/USAGE  W-STACK    W-SIZE'
-
 
734
text_len = $-text
591
	db 'MEMORY START/USAGE  W-STACK    W-SIZE'
735
 
592
text_len = $-text
736
tbts:	db  'PREV PAGE       NEXT PAGE                         REBOOT SYSTEM'
593
 
737
tbte:
594
tbts:	db 'PREV PAGE       NEXT PAGE                         REBOOT SYSTEM'
738
;tbts_2  db  '>'
595
tbte:
Line 739... Line 596...
739
tbts_3	db  'RUN'
596
tbts_3	db ' RUN'
-
 
597
tbte_2:
-
 
598
check_text	db '@ on/off'
740
tbte_2:
599
check_t_e=$-check_text
-
 
600
title	db 'Process manager - Ctrl/Alt/Del',0
-
 
601
 
-
 
602
end if
-
 
603
;------------------------------------------------------------------------------
741
check_text db '@ on/off'
604
align 4	
742
check_t_e=$-check_text
605
file_start:
743
title  db   'Processes - Ctrl/Alt/Del',0
606
	dd 7
744
 
607
	dd 0
745
end if
608
	dd 0
746
file_start: dd 7
609
	dd 0
747
	    dd 0,0,0,0
-
 
-
 
610
	dd 0
748
start_application: db '/sys/LAUNCHER',0
611
start_application: db '/sys/LAUNCHER',0
-
 
612
start_application_e=$-start_application-1
-
 
613
;                   times 60 db 0
749
start_application_e=$-start_application-1
614
	rb 60
750
;                   times 60 db 0
615
start_application_c=$-start_application-1
751
rb	60
616
;------------------------------------------------------------------------------
752
start_application_c=$-start_application-1
617
IM_END:
753
 
618
;------------------------------------------------------------------------------
754
I_END:
619
align 4	
755
sc system_colors
620
sc system_colors
756
winxpos  rd 1
621
winxpos		rd 1
757
winypos  rd 1
622
winypos		rd 1
758
mouse_dd	rd 1
623
mouse_dd	rd 1
-
 
624
cpu_percent	rd 1
-
 
625
tcolor		rd 1
-
 
626
list_add	rd 1
-
 
627
curposy		rd 1
759
cpu_percent rd 1
628
index		rd 1
-
 
629
tasklist	rd display_processes
-
 
630
time_counter	rd 1
760
tcolor	    rd 1
631
;------------------------------------------------------------------------------
761
list_add    rd 1
632
align 4	
-
 
633
library_path:
762
curposy     rd 1
634
process_info_buffer process_information
-
 
635
;------------------------------------------------------------------------------
-
 
636
align 4	
-
 
637
cur_dir_path:
763
index	    rd 1
638
	rb 1024
-
 
639
;------------------------------------------------------------------------------