Subversion Repositories Kolibri OS

Rev

Rev 1209 | Rev 1214 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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