Subversion Repositories Kolibri OS

Rev

Rev 8576 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6444 pathoswith 1
;-----------------------;
2
; CPU - process manager ;
3
;-----------------------;
4
 
9198 Doczom 5
        format  binary as ""
3408 hidnplayr 6
 
9198 Doczom 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
8561 Kenshin 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
;-------------------------------------------------------------------------------
9198 Doczom 25
DISPLAY_PROCESSES = 20  ;number of processes to show
8561 Kenshin 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:
9198 Doczom 31
        .X = 10
32
        .Y = 10
33
        .WIDTH = 640
34
        .HEIGHT = DISPLAY_PROCESSES * BUTTON.HEIGHT
8561 Kenshin 35
UNDERTABLE:
9198 Doczom 36
        .X = PROCESS_TABLE.X
37
        .Y = PROCESS_TABLE.Y + PROCESS_TABLE.HEIGHT + 20
8561 Kenshin 38
BUTTON:
9198 Doczom 39
        .WIDTH = 130
40
        .HEIGHT = 16 + 4
8561 Kenshin 41
EDITBOX:
9198 Doczom 42
        .X = CHECKBOX.X + 100
43
        .Y = UNDERTABLE.Y + BUTTON.HEIGHT + 20
44
        .WIDTH = 465
45
        .HEIGHT = 23
46
 
8561 Kenshin 47
CHECKBOX:
9198 Doczom 48
        .X = PROCESS_TABLE.X
49
        .Y = UNDERTABLE.Y + BUTTON.HEIGHT + 25
8561 Kenshin 50
;-------------------------------------------------------------------------------
9198 Doczom 51
@use_library    ;use load lib macros
8561 Kenshin 52
;-------------------------------------------------------------------------------
9198 Doczom 53
        struc   utf8z   string
8561 Kenshin 54
{
9198 Doczom 55
        .       db      string, 0
56
        .size = $ - . - 1
8561 Kenshin 57
}
58
 
59
;-------------------------------------------------------------------------------
9198 Doczom 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
8561 Kenshin 65
;-------------------------------------------------------------------------------
9198 Doczom 66
        mcall   SF_SET_EVENTS_MASK,0x80000027 ;set event
8561 Kenshin 67
;-------------------------------------------------------------------------------
2559 mario79 68
;set window size and position for 0 function
69
;to [winxpos] and [winypos] variables
70
;get screen size
9198 Doczom 71
        mcall   SF_GET_SCREEN_SIZE
72
        mov     ebx,eax
8561 Kenshin 73
;calculate (x_screen-WINDOW.WIDTH)/2
9198 Doczom 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
9198 Doczom 79
        mov     [winxpos],ebx
8561 Kenshin 80
;calculate (y_screen-WINDOW.HEIGHT)/2
9198 Doczom 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
9198 Doczom 87
        mov     [winypos],eax
8561 Kenshin 88
;-------------------------------------------------------------------------------
9198 Doczom 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
8561 Kenshin 93
;-------------------------------------------------------------------------------
3587 fedesco 94
align 4
8561 Kenshin 95
;main loop when process name isn"t edited.
3587 fedesco 96
red:
9198 Doczom 97
        call    draw_window             ; redraw all window
98
        mcall   71, 2, strings.window_caption, 3        ;set window caption
8561 Kenshin 99
;-------------------------------------------------------------------------------
3587 fedesco 100
align 4
31 halyavin 101
still:
9198 Doczom 102
        mcall   SF_WAIT_EVENT_TIMEOUT,100               ; wait here for event 1 sec.
6444 pathoswith 103
 
9198 Doczom 104
        test    eax,eax
105
        jz      still_end
31 halyavin 106
 
9198 Doczom 107
        dec     eax                     ; redraw request ?
108
        jz      red
1205 Lrz 109
 
9198 Doczom 110
        dec     eax                     ; key in buffer ?
111
        jz      key
2559 mario79 112
 
9198 Doczom 113
        dec     eax                     ; button in buffer ?
114
        jz      button
2559 mario79 115
 
9198 Doczom 116
        push    dword   edit1
117
        call    [edit_box_mouse]
3587 fedesco 118
 
9198 Doczom 119
        push    dword[check1.flags]
3587 fedesco 120
 
9198 Doczom 121
        push    dword   check1
122
        call    [check_box_mouse]
3587 fedesco 123
 
9198 Doczom 124
        pop     eax
3587 fedesco 125
 
9198 Doczom 126
        cmp     eax, dword[check1.flags]
127
        jz      still_end
3587 fedesco 128
 
9198 Doczom 129
        push    dword   check1
130
        call    [check_box_draw]
8561 Kenshin 131
;-------------------------------------------------------------------------------
3587 fedesco 132
align 4
133
show_process_info_1:
9198 Doczom 134
        mcall   SF_SYSTEM_GET, SSF_TIME_COUNT
135
        add     eax, 100
136
        mov     [time_counter],eax
1205 Lrz 137
 
9198 Doczom 138
        call    show_process_info       ; draw new state of processes
139
        jmp     still
8561 Kenshin 140
;-------------------------------------------------------------------------------
3587 fedesco 141
align 4
2559 mario79 142
still_end:
9198 Doczom 143
        mcall   SF_SYSTEM_GET,SSF_TIME_COUNT
144
        cmp     [time_counter],eax
145
        ja      still
31 halyavin 146
 
9198 Doczom 147
        add     eax,100
148
        mov     [time_counter],eax
1212 Lrz 149
 
9198 Doczom 150
        call    show_process_info       ; draw new state of processes
151
        jmp     still
8561 Kenshin 152
;-------------------------------------------------------------------------------
3587 fedesco 153
align 4
9198 Doczom 154
key:                            ; key
155
        mcall   SF_GET_KEY
1205 Lrz 156
 
9198 Doczom 157
        cmp     ah,184          ; PageUp
158
        jz      pgdn
1205 Lrz 159
 
9198 Doczom 160
        cmp     ah,183
161
        jz      pgup                    ; PageDown
2559 mario79 162
 
9198 Doczom 163
        cmp     ah,27
164
        jz      close                   ; Esc
2559 mario79 165
 
9198 Doczom 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
 
9198 Doczom 173
        sub     ah,13                   ; ENTER?
174
        jz      program_start           ; RUN a program
1212 Lrz 175
 
9198 Doczom 176
        jmp     still
8561 Kenshin 177
;-------------------------------------------------------------------------------
3587 fedesco 178
align 4
179
button:
180
; get button id
9198 Doczom 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.
9198 Doczom 185
        cmp     eax,10
186
        jb      noterm
31 halyavin 187
 
9198 Doczom 188
        cmp     eax,50
189
        jg      noterm
3587 fedesco 190
;calculate button index
9198 Doczom 191
        sub     eax,11
3587 fedesco 192
;calculate process slot
9198 Doczom 193
        mov     ecx,[tasklist+4*eax]
31 halyavin 194
;ignore empty buttons
9198 Doczom 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:
9198 Doczom 204
        push    0
205
        mov     ecx, 10
6444 pathoswith 206
.push:
9198 Doczom 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:
9198 Doczom 214
        pop     eax
215
        stosb
216
        test    eax, eax
217
        jnz     .pop
6444 pathoswith 218
; launch tinfo app
9198 Doczom 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
9198 Doczom 225
        mcall   SF_SYSTEM,SSF_TERMINATE_THREAD
226
        jmp     show_process_info_1
8561 Kenshin 227
;-------------------------------------------------------------------------------
2559 mario79 228
align 4
229
noterm:
230
;special buttons
9198 Doczom 231
        dec     eax
232
        jz      close
1212 Lrz 233
 
9198 Doczom 234
        sub     eax,50
235
        jz      pgdn    ;51
31 halyavin 236
 
9198 Doczom 237
        dec     eax
238
        jz      pgup    ;52
1203 Lrz 239
 
9198 Doczom 240
        dec     eax
241
        jz      reboot  ;53
1212 Lrz 242
 
9198 Doczom 243
        dec     eax
244
        jz      program_start   ;54
1212 Lrz 245
 
9198 Doczom 246
        jmp     still_end
3587 fedesco 247
;buttons handlers
8561 Kenshin 248
;-------------------------------------------------------------------------------
3587 fedesco 249
align 4
2559 mario79 250
pgdn:
9198 Doczom 251
        sub     [list_start],DISPLAY_PROCESSES
252
        jge     show_process_info_1
253
        mov     [list_start],0
254
        jmp     show_process_info_1
8561 Kenshin 255
;-------------------------------------------------------------------------------
3587 fedesco 256
align 4
2559 mario79 257
pgup:
9198 Doczom 258
        mov     eax,[list_add]  ;maximal displayed process slot
259
        mov     [list_start],eax
260
        jmp     show_process_info_1
8561 Kenshin 261
;-------------------------------------------------------------------------------
3587 fedesco 262
align 4
263
program_start:
9198 Doczom 264
        mcall   SF_FILE,file_start
265
        jmp     show_process_info_1
8561 Kenshin 266
;-------------------------------------------------------------------------------
3587 fedesco 267
align 4
268
reboot:
9198 Doczom 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:
9198 Doczom 274
        or      eax,SF_TERMINATE_PROCESS ; close this program
275
        mcall
8561 Kenshin 276
;-------------------------------------------------------------------------------
3587 fedesco 277
align 4
278
draw_empty_slot:
9198 Doczom 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, <141, PROCESS_TABLE.WIDTH-141>, , [bar_bacground_color]
2582 mario79 285
@@:
9198 Doczom 286
        ret
8561 Kenshin 287
;-------------------------------------------------------------------------------
3587 fedesco 288
align 4
31 halyavin 289
draw_next_process:
290
;input:
9198 Doczom 291
;       edi - current slot
292
;       [curposy] - y position
31 halyavin 293
;output:
9198 Doczom 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
9198 Doczom 298
        mov ecx,[curposy]
299
        mcall SF_PUT_PIXEL, PROCESS_TABLE.X, , 0x586468
300
        add ebx, BUTTON.WIDTH
301
        mcall
8576 leency 302
 
9198 Doczom 303
;create terminate process button
304
        ;mov    ecx,[curposy]
305
        shl     ecx,16
306
        mov     cx, BUTTON.HEIGHT
307
        mov     edx,[index]
308
        add     edx,11
309
        mov     esi,0xaabbcc
310
        test    dword   [index],1
311
        jz      @f
312
        mov     esi,0xccddee
6444 pathoswith 313
@@:
9198 Doczom 314
                add     edx,0x80000000 ; delete a button
315
                mcall   SF_DEFINE_BUTTON ; before create
316
                sub     edx,0x80000000 ; a new one below
317
        mcall   SF_DEFINE_BUTTON,
318
        mov     [btn_bacground_color],esi
31 halyavin 319
;draw background for proccess information
9198 Doczom 320
        mov     edx,0xDDDddf
321
        test    dword   [index],1
322
        jz      @f
323
        mov     edx,0xFFFfff
6444 pathoswith 324
@@:
9198 Doczom 325
        ;inc    cx
8561 Kenshin 326
 
9198 Doczom 327
        mcall   SF_DRAW_RECT, <141, PROCESS_TABLE.WIDTH-141>
8561 Kenshin 328
 
9198 Doczom 329
        mov     [bar_bacground_color],edx
6444 pathoswith 330
;nothing else should be done if there is no process for this button
9198 Doczom 331
        cmp     edi,-1
332
        jne     .return_1
2582 mario79 333
 
9198 Doczom 334
        call    draw_empty_slot
335
        or      edi,-1
336
        jmp     .ret
8561 Kenshin 337
;-------------------------------------------------------------------------------
2559 mario79 338
align 4
339
.return_1:
31 halyavin 340
;find process
9198 Doczom 341
        inc     edi
3587 fedesco 342
;more comfortable register for next loop
9198 Doczom 343
        mov     ecx,edi
3587 fedesco 344
;precacluate pointer to process buffer
9198 Doczom 345
        mov     ebx,process_info_buffer
8561 Kenshin 346
;-------------------------------------------------------------------------------
2559 mario79 347
align 4
31 halyavin 348
.find_loop:
9198 Doczom 349
        cmp     ecx,256
350
        jge     .no_processes
31 halyavin 351
;load process information in buffer
9198 Doczom 352
        mcall   SF_THREAD_INFO
31 halyavin 353
;if current slot greater than maximal slot,
3587 fedesco 354
;there is no more proccesses.
9198 Doczom 355
        cmp     ecx,eax
356
        jg      .no_processes
3587 fedesco 357
;if slot state is equal to 9, it is empty.
9198 Doczom 358
        cmp     [process_info_buffer+process_information.slot_state],9
359
        jnz     .process_found
3587 fedesco 360
 
9198 Doczom 361
        inc     ecx
362
        jmp     .find_loop
8561 Kenshin 363
;-------------------------------------------------------------------------------
2559 mario79 364
align 4
31 halyavin 365
.no_processes:
9198 Doczom 366
        call    draw_empty_slot
367
        or      edi,-1
368
        ret
8561 Kenshin 369
;-------------------------------------------------------------------------------
2559 mario79 370
align 4
31 halyavin 371
.process_found:
1266 Lrz 372
;check on/off check box
9198 Doczom 373
        test    dword   [check1.flags], ch_flag_en
374
        jnz     .no_filter
1266 Lrz 375
 
9198 Doczom 376
        cmp     dword   [process_info_buffer+10],"ICON"
377
        jnz     @f
378
        cmp     dword   [process_info_buffer+10+4],0
379
        jz      .return_1
3779 mario79 380
@@:
9198 Doczom 381
        cmp     dword   [process_info_buffer+10],"IDLE"
382
        jnz     @f
383
        cmp     dword   [process_info_buffer+10+4],0
384
        jz      .return_1
3779 mario79 385
@@:
9198 Doczom 386
        cmp     word    [process_info_buffer+10],"OS"
387
        jnz     @f
388
        cmp     dword   [process_info_buffer+10+2],0
389
        jz      .return_1
3779 mario79 390
@@:
9198 Doczom 391
        cmp     byte [process_info_buffer+10],"@"
392
        jz      .return_1
8561 Kenshin 393
;-------------------------------------------------------------------------------
2559 mario79 394
align 4
3779 mario79 395
.no_filter:
9198 Doczom 396
        mov     edi,ecx
397
        mov     [list_add],ecx
3587 fedesco 398
;get processor cpeed
31 halyavin 399
;for percent calculating
9198 Doczom 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
9198 Doczom 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
9198 Doczom 413
;0%     : black
414
;1-80%  : green
31 halyavin 415
;81-100% : red
9198 Doczom 416
        test    eax,eax
417
        jnz     .no_black
1212 Lrz 418
 
9198 Doczom 419
        mov     esi, 0x10000000
420
        jmp     .color_set
8561 Kenshin 421
;-------------------------------------------------------------------------------
2559 mario79 422
align 4
3587 fedesco 423
.no_black:
9198 Doczom 424
        cmp     eax,80
425
        ja      .no_green
1212 Lrz 426
 
9198 Doczom 427
        mov     esi, 0x10107A30
428
        jmp     .color_set
8561 Kenshin 429
;-------------------------------------------------------------------------------
2559 mario79 430
align 4
31 halyavin 431
.no_green:
9198 Doczom 432
        mov     esi,0x10AC0000
8561 Kenshin 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
9198 Doczom 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
9198 Doczom 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
8561 Kenshin 453
;show PTID
9198 Doczom 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
9198 Doczom 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
9198 Doczom 463
        mov     eax, [cpu_percent]
464
        add     ebx, 55 shl 16
465
        call    draw_ra_dec_number
31 halyavin 466
;show memory usage
9198 Doczom 467
        mov     eax, [process_info_buffer.used_memory]
468
        add     ebx, 60 shl 16
469
        call    draw_ra_data_size
8561 Kenshin 470
;show window stack position
9198 Doczom 471
        movzx   eax, word [process_info_buffer.window_stack_position]
472
        add     ebx, 70 shl 16
473
        call    draw_ra_dec_number
8561 Kenshin 474
;show window x size
9198 Doczom 475
        movzx   eax, word [process_info_buffer.box.left]
476
        add     ebx, 70 shl 16
477
        call    draw_ra_dec_number
8561 Kenshin 478
;show window y size
9198 Doczom 479
        movzx   eax, word [process_info_buffer.box.top]
480
        add     ebx, 70 shl 16
481
        call    draw_ra_dec_number
482
        pop     edi
8561 Kenshin 483
;-------------------------------------------------------------------------------
2559 mario79 484
align 4
31 halyavin 485
.ret:
486
;build index->slot map for terminating processes.
9198 Doczom 487
        mov     eax,[index]
488
        mov     [tasklist+4*eax],edi
489
        ret
8561 Kenshin 490
;-------------------------------------------------------------------------------
3587 fedesco 491
align 4
2559 mario79 492
f11:
3587 fedesco 493
;full update
9198 Doczom 494
        push    edi
495
        call    draw_window
496
        pop     edi
8561 Kenshin 497
;-------------------------------------------------------------------------------
9198 Doczom 498
;       *********************************************
499
;       ******* WINDOW DEFINITIONS AND DRAW ********
500
;       *********************************************
3587 fedesco 501
align 4
31 halyavin 502
draw_window:
9198 Doczom 503
        mcall   SF_REDRAW, SSF_BEGIN_DRAW
2559 mario79 504
; DRAW WINDOW
9198 Doczom 505
        xor     eax,eax                  ; function 0 : define and draw window
506
        xor     esi,esi
507
        mcall   ,[winxpos],[winypos], 0x24FFFFFF
2582 mario79 508
 
9198 Doczom 509
        mcall   SF_THREAD_INFO,process_info_buffer,-1
3587 fedesco 510
 
9198 Doczom 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
 
9198 Doczom 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
 
9198 Doczom 552
        mcall   SF_SYSTEM_GET,SSF_TIME_COUNT
553
        add     eax,100
554
        mov     [time_counter],eax
2582 mario79 555
 
9198 Doczom 556
        mov     [draw_window_flag],1
557
        call    show_process_info
558
        mov     [draw_window_flag],0
31 halyavin 559
 
9198 Doczom 560
        push    dword   edit1
561
        call    [edit_box_draw]
3587 fedesco 562
 
9198 Doczom 563
        push    dword   check1
564
        call    [check_box_draw]
3587 fedesco 565
 
8561 Kenshin 566
;previous page button, ID = 51:
9198 Doczom 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
8561 Kenshin 573
;next page button, ID = 52:
9198 Doczom 574
        mov     eax, strings.next_page
575
        add     ebx, 10 shl 16
576
        inc     ecx
577
        call    draw_button_with_caption
8561 Kenshin 578
;reboot button, ID = 53:
9198 Doczom 579
        mov     eax, strings.reboot
580
        add     ebx, 345 shl 16
581
        inc     ecx
582
        call    draw_button_with_caption
8561 Kenshin 583
;run button, ID = 54
9198 Doczom 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
8561 Kenshin 588
;-------------------------------------------------------------------------------
2583 mario79 589
align 4
590
.exit:
9198 Doczom 591
        mcall   SF_REDRAW, SSF_END_DRAW
592
        ret
8561 Kenshin 593
;-------------------------------------------------------------------------------
2559 mario79 594
align 4
595
show_process_info:
9198 Doczom 596
        test    [window_status], 100b           ; window is rolled up
597
        jnz     .exit
2583 mario79 598
 
9198 Doczom 599
        test    [window_status], 10b            ; window is minimized to panel
600
        jnz     .exit
2583 mario79 601
 
9198 Doczom 602
        mov     ecx,DISPLAY_PROCESSES
603
        mov     edi,tasklist
604
        xor     eax,eax
605
        cld
606
        rep     stosd
3938 mario79 607
 
9198 Doczom 608
        mov     edi,[list_start]
609
        mov     [list_add],edi
610
        mov     dword   [index],0
611
        mov     dword   [curposy],20
8561 Kenshin 612
;-------------------------------------------------------------------------------
2559 mario79 613
align 4
614
.loop_draw:
9198 Doczom 615
        call    draw_next_process
616
        inc     dword   [index]
617
        add     dword   [curposy],16+4
618
        cmp     [index],DISPLAY_PROCESSES
619
        jl      .loop_draw
8561 Kenshin 620
;-------------------------------------------------------------------------------
2583 mario79 621
align 4
622
.exit:
9198 Doczom 623
        ret
624
 
8561 Kenshin 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
;-------------------------------------------------------------------------------
9198 Doczom 637
        pusha
8561 Kenshin 638
 
9198 Doczom 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
 
8561 Kenshin 659
.no_postfix:
9198 Doczom 660
        mov     eax, ebp
661
        push    edx
8561 Kenshin 662
 
9198 Doczom 663
        xor     edi, edi
664
 
665
        mov     esi, 10
8561 Kenshin 666
@@:
9198 Doczom 667
        xor     edx, edx
668
        div     esi
669
        inc     edi
670
        test    eax, eax
671
        jz      @f
672
        jmp     @b
8561 Kenshin 673
 
674
@@:
9198 Doczom 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
8561 Kenshin 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
;-------------------------------------------------------------------------------
9198 Doczom 699
        pusha
8561 Kenshin 700
 
9198 Doczom 701
        xor     edx, edx
702
        cmp     eax, 1024
703
        ja      @f
704
        jmp     .draw_text
705
 
8561 Kenshin 706
@@:
9198 Doczom 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
 
8561 Kenshin 714
@@:
9198 Doczom 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
 
8561 Kenshin 722
@@:
9198 Doczom 723
        mov     esi,  1024*1024*1024
724
        div     esi
725
        mov     edx, strings.GB
726
 
8561 Kenshin 727
.draw_text:
9198 Doczom 728
        call    draw_ra_dec_number
729
 
730
        popa
731
        ret
8561 Kenshin 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
;-------------------------------------------------------------------------------
9198 Doczom 742
        pusha
8561 Kenshin 743
 
9198 Doczom 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
 
8561 Kenshin 757
.ret:
9198 Doczom 758
        popa
759
        ret
8561 Kenshin 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
;-------------------------------------------------------------------------------
9198 Doczom 775
        pusha
776
 
777
        xor     ebp, ebp
778
        mov     edi, eax
779
        test    eax, eax
780
        jz      .no_caption_0
8561 Kenshin 781
 
9198 Doczom 782
        call    count_utf8z_chars
783
        mov     ebp, eax
8561 Kenshin 784
 
9198 Doczom 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
 
8561 Kenshin 808
.no_caption_1:
9198 Doczom 809
        popa
810
        ret
8561 Kenshin 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
;-------------------------------------------------------------------------------
9198 Doczom 820
        push    esi ebx
821
        mov     esi, eax
822
        xor     ebx, ebx
823
 
8561 Kenshin 824
.0:
9198 Doczom 825
        lodsb
826
        test    al, al
827
        jz      .ok
828
        inc     ebx
829
        cmp     al, 0x7F
830
        ja      @f
831
        jmp     .0
8561 Kenshin 832
@@:
9198 Doczom 833
        cmp     al, 0xC0
834
        jb      .err
835
        cmp     al, 0xDF
836
        ja      @f
837
        inc     esi
838
        jmp     .0
839
 
8561 Kenshin 840
@@:
9198 Doczom 841
        cmp     al, 0xEF
842
        ja      @f
843
        inc     esi
844
        inc     esi
845
        jmp     .0
846
 
8561 Kenshin 847
@@:
9198 Doczom 848
        cmp     al, 0xF7
849
        ja      .err
850
        add     esi, 3
851
        jmp     .0
852
 
8561 Kenshin 853
.ok:
9198 Doczom 854
        mov     eax, ebx
855
        pop     ebx esi
856
        ret
857
 
8561 Kenshin 858
.err:
9198 Doczom 859
        xor     eax, eax
860
        pop     ebx esi
861
        ret
8561 Kenshin 862
;-------------------------------------------------------------------------------
863
 
31 halyavin 864
; DATA AREA
8561 Kenshin 865
;-------------------------------------------------------------------------------
9198 Doczom 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:
9198 Doczom 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
 
9198 Doczom 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
 
9198 Doczom 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
 
9198 Doczom 886
                dd      0
887
                dd      0
1205 Lrz 888
 
9198 Doczom 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
 
9198 Doczom 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
 
9198 Doczom 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
8561 Kenshin 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,\
9198 Doczom 907
        start_application,mouse_dd,ed_focus,start_application_e,start_application_e
1228 Lrz 908
edit1_end:
9198 Doczom 909
list_start      dd      0
8561 Kenshin 910
;-------------------------------------------------------------------------------
3587 fedesco 911
align 4
748 heavyiron 912
sys_reboot:
9198 Doczom 913
                dd      SSF_START_APP
914
                dd      0
915
                dd      0
916
                dd      0
917
                dd      0
918
                db      "/sys/end",0
8561 Kenshin 919
;-------------------------------------------------------------------------------
920
strings:
340 heavyiron 921
if lang eq de
9198 Doczom 922
        .window_caption         utf8z   "Prozesse v0.2.3 - [Ctrl+Alt+Del]"
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"
930
        .window_position.x      utf8z   "  WIN-X"
931
        .window_position.y      utf8z   "  WIN-Y"
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"
8561 Kenshin 943
;-------------------------------------------------------------------------------
268 kaitz 944
else if lang eq et
9198 Doczom 945
        .window_caption         utf8z   "Protsessid v0.2.3 - [Ctrl+Alt+Del]"
946
 
947
        .process_name           utf8z   "NIMI/LÕPETA"
948
        .ptid                   utf8z   "PID/TID"
949
        .cpu_usage_cycles       utf8z   "CPU(TSÜKLID)"
950
        .cpu_usage_percent      utf8z   "CPU(%)"
951
        .memory_usage           utf8z   "MÄLU"
952
        .window_stack_pos       utf8z   "W-PUHVER"
953
        .window_position.x      utf8z   "  WIN-X"
954
        .window_position.y      utf8z   "  WIN-Y"
955
 
956
        .previous_page          utf8z   "EELMINE LEHT"
957
        .next_page              utf8z   "JÄRGMINE LEHT"
958
        .reboot                 utf8z   "REBOODI SÜSTEEM"
959
        .run                    utf8z   "START"
960
 
961
        .checkbox_caption       utf8z   "System"
962
 
963
        .KB                     utf8z   " KB"
964
        .MB                     utf8z   " MB"
965
        .GB                     utf8z   " GB"
8561 Kenshin 966
;-------------------------------------------------------------------------------
2559 mario79 967
else if lang eq ru
9198 Doczom 968
        .window_caption         utf8z   "Диспетчер процессов v0.2.3 - [Ctrl+Alt+Del]"
969
 
970
        .process_name           utf8z   "ИМЯ/ЗАВЕРШИТЬ"
971
        .ptid                   utf8z   "PID/TID"
972
        .cpu_usage_cycles       utf8z   "CPU(ТАКТЫ)"
973
        .cpu_usage_percent      utf8z   "CPU(%)"
974
        .memory_usage           utf8z   "ПАМЯТЬ"
975
        .window_stack_pos       utf8z   "W-STACK"
976
        .window_position.x      utf8z   "  WIN-X"
977
        .window_position.y      utf8z   "  WIN-Y"
978
 
979
        .previous_page          utf8z   "ПРЕД. СТР."
980
        .next_page              utf8z   "СЛЕД. СТР."
981
        .reboot                 utf8z   "ПЕРЕЗАГРУЗКА"
982
        .run                    utf8z   "ЗАПУСК"
983
 
984
        .checkbox_caption       utf8z   "Системные"
985
 
986
        .KB                     utf8z   " КБ"
987
        .MB                     utf8z   " МБ"
988
        .GB                     utf8z   " ГБ"
8561 Kenshin 989
;-------------------------------------------------------------------------------
3587 fedesco 990
else if lang eq it
9198 Doczom 991
        .window_caption         utf8z   "Gestore processi v0.2.3 - [Ctrl+Alt+Del]"
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"
999
        .window_position.x      utf8z   "  WIN-X"
1000
        .window_position.y      utf8z   "  WIN-Y"
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"
8561 Kenshin 1012
;-------------------------------------------------------------------------------
340 heavyiron 1013
else
9198 Doczom 1014
        .window_caption         utf8z   "Process manager v0.2.3 - [Ctrl+Alt+Del]"
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"
1022
        .window_position.x      utf8z   "  WIN-X"
1023
        .window_position.y      utf8z   "  WIN-Y"
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:
9198 Doczom 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:
9198 Doczom 1049
times 11 db     0 ; at now 4 bytes will be enough, but may be in the future not
4968 0CodErr 1050
align 4
9198 Doczom 1051
sz_tinfo_file_path      db      "/sys/tinfo",0
8561 Kenshin 1052
;-------------------------------------------------------------------------------
4968 0CodErr 1053
align 4
2559 mario79 1054
file_start:
9198 Doczom 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
9198 Doczom 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
9198 Doczom 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
 
9198 Doczom 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
8561 Kenshin 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:
9198 Doczom 1093
        rb      1024
1094
        rb      1024
2559 mario79 1095
stack_area:
31 halyavin 1096
U_END: