Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;********************************
2
;*                              *
3
;*     DESKTOP ICON MANAGER     *
4
;*                              *
5
;*  Compile with flat assembler *
6
;*                              *
7
;********************************
8
;  22.02.05 was modified for work with new multi-thread ICON.
9
;******************************************************************************
10
  use32
11
  org    0x0
12
  db     'MENUET01'     ; 8 byte id
13
  dd     0x01           ; header version
14
  dd     START          ; start of code
15
  dd     I_END          ; size of image
16
  dd     0x2000        ; memory for app
17
  dd     0x2000        ; esp
18
  dd     I_Param , 0x0  ; I_Param , I_Icon
19
include  'lang.inc'
20
include  'macros.inc'
21
;******************************************************************************
22
 
23
START:                       ; start of execution
24
 
25
    call load_icon_list
26
 
27
    call check_parameters
28
 
29
 red:
30
    call draw_window         ; at first, draw the window
31
 
32
still:
33
 
34
    mov  eax,10              ; wait here for event
35
    int  0x40
36
 
37
    cmp  eax,1               ; redraw request ?
38
    je   red
39
    cmp  eax,2               ; key in buffer ?
40
    je   key
41
    cmp  eax,3               ; button in buffer ?
42
    je   button
43
 
44
    jmp  still
45
 
46
  key:                       ; key
47
    mov  eax,2               ; just read it and ignore
48
    int  0x40
49
    jmp  still
50
 
51
  button:                    ; button
52
    mov  eax,17              ; get id
53
    int  0x40
54
 
55
    shr  eax,8
56
 
57
    cmp  eax,1               ; button id=1 ?
58
    jne  noclose
59
    mov  eax,-1              ; close this program
60
    int  0x40
61
  noclose:
62
 
63
    cmp  eax,11
64
    jb   no_str
65
    cmp  eax,13
66
    jg   no_str
67
    call read_string
68
    jmp  still
69
  no_str:
70
 
71
 
72
    cmp  eax,21              ; apply changes
73
    jne  no_apply
74
 
75
    ; (1) save list
76
 
77
    mov  eax,33
78
    mov  ebx,icon_lst
79
    mov  ecx,icon_data
80
    mov  edx,52
81
    imul edx,dword [icons]
82
    mov  esi,0
83
    int  0x40
84
 
85
 
86
    ; (2) terminate all icons
87
 
88
    mov  esi,1
89
   newread:
90
    inc  esi
91
    mov  eax,9
92
    mov  ebx,I_END
93
    mov  ecx,esi
94
    int  0x40
95
    cmp  esi,eax
96
    jg   all_terminated
97
 
98
    cmp  [I_END+10],dword 'ICON'
99
    jne  newread
100
    cmp  [I_END+14],dword '    '
101
    jne  newread
102
 
103
    mov  eax,18
104
    mov  ebx,2
105
    mov  ecx,esi
106
    int  0x40
107
 
108
;    mov  eax,5
109
;    mov  ebx,5
110
;    int  0x40
111
 
112
    mov  esi,1
113
 
114
    jmp  newread
115
 
116
   all_terminated:
117
 
118
   apply_changes:
119
 
120
    mov  eax,19
121
    mov  ebx,icon_name
122
    mov  ecx,icon_start_parameters
123
    int  0x40
124
 
125
;    mov  eax,5
126
;    mov  ebx,3
127
;    int  0x40
128
 
129
    jmp   still
130
 
131
;    mov  eax,-1
132
;    int  0x40
133
 
134
  no_apply:
135
 
136
 
137
    cmp  eax,22                 ; user pressed the 'add icon' button
138
    jne  no_add_icon
139
 
140
    mov  eax,13
141
    mov  ebx,24*65536+270
142
    mov  ecx,250*65536+10
143
    mov  edx,0xffffff
144
    int  0x40
145
    mov  eax,4
146
    mov  ebx,24*65536+250
147
    mov  ecx,0xff0000
148
    mov  edx,add_text
149
    mov  esi,add_text_len-add_text
150
    int  0x40
151
 
152
    mov  eax,10
153
    int  0x40
154
    cmp  eax,3
155
    jne  still
156
    mov  eax,17
157
    int  0x40
158
    shr  eax,8
159
    cmp  eax,40
160
    jb   no_f
161
    sub  eax,40
162
 
163
    xor  edx,edx  ; bcd -> 10
164
    mov  ebx,16
165
    div  ebx
166
    imul eax,10
167
    add  eax,edx
168
 
169
    mov  ebx,eax
170
    add  ebx,icons_reserved
171
    cmp  [ebx],byte 'x'
172
    je   no_f
173
    mov  [ebx],byte 'x'
174
 
175
    xor  edx,edx
176
    mov  ebx,10
177
    div  ebx
178
    add  eax,65
179
    add  edx,65
180
    mov  [icon_default+0],dl
181
    mov  [icon_default+1],al
182
 
183
    inc  dword [icons]
184
    mov  edi,[icons]
185
    dec  edi
186
    imul edi,52
187
    add  edi,icon_data
188
 
189
    mov  [current_icon],edi
190
 
191
    mov  esi,icon_default
192
    mov  ecx,52
193
    cld
194
    rep  movsb
195
 
196
  no_f:
197
 
198
    call draw_window
199
 
200
    jmp  still
201
 
202
  no_add_icon:
203
 
204
 
205
    cmp  eax,23                     ; user pressed the remove icon button
206
    jne  no_remove_icon
207
 
208
    mov  eax,13
209
    mov  ebx,24*65536+270
210
    mov  ecx,250*65536+10
211
    mov  edx,0xffffff
212
    int  0x40
213
    mov  eax,4
214
    mov  ebx,24*65536+250
215
    mov  ecx,0xff0000
216
    mov  edx,rem_text
217
    mov  esi,rem_text_len-rem_text
218
    int  0x40
219
 
220
    mov  eax,10
221
    int  0x40
222
    cmp  eax,3
223
    jne  no_found
224
    mov  eax,17
225
    int  0x40
226
    shr  eax,8
227
    cmp  eax,40
228
    jb   no_found
229
    sub  eax,40
230
 
231
    xor  edx,edx
232
    mov  ebx,16
233
    div  ebx
234
    imul eax,10
235
    add  eax,edx
236
 
237
    mov  ebx,eax
238
    add  ebx,icons_reserved
239
    cmp  [ebx],byte 'x'
240
    jne  no_found
241
    mov  [ebx],byte ' '
242
 
243
    xor  edx,edx
244
    mov  ebx,10
245
    div  ebx
246
    shl  eax,8
247
    mov  al,dl
248
 
249
    add  eax,65*256+65
250
 
251
    mov  esi,icon_data
252
    mov  edi,52
253
    imul edi,[icons]
254
    add  edi,icon_data
255
  news:
256
    cmp  word [esi],ax
257
    je   foundi
258
    add  esi,52
259
    cmp  esi,edi
260
    jb   news
261
    jmp  no_found
262
 
263
  foundi:
264
 
265
    mov  ecx,edi
266
    sub  ecx,esi
267
 
268
    mov  edi,esi
269
    add  esi,52
270
 
271
    cld
272
    rep  movsb
273
 
274
    dec  [icons]
275
 
276
    mov  eax,icon_data
277
    mov  [current_icon],eax
278
 
279
  no_found:
280
 
281
    call draw_window
282
 
283
    jmp  still
284
 
285
 
286
 
287
  no_remove_icon:
288
 
289
 
290
    cmp  eax,40                 ; user pressed button for icon position
291
    jb   no_on_screen_button
292
 
293
    sub  eax,40
294
    mov  edx,eax
295
    shl  eax,4
296
    and  edx,0xf
297
    mov  dh,ah
298
    add  edx,65*256+65
299
 
300
    mov  esi,icon_data
301
    mov  ecx,[icons]
302
    cld
303
   findl1:
304
    cmp  dx,[esi]
305
    je   foundl1
306
    add  esi,50+2
307
    loop findl1
308
    jmp  still
309
 
310
   foundl1:
311
 
312
    mov  [current_icon],esi
313
 
314
    call print_strings
315
 
316
    jmp  still
317
 
318
  no_on_screen_button:
319
 
320
 
321
    jmp  still
322
 
323
 
324
current_icon dd icon_data
325
 
326
 
327
print_strings:
328
 
329
    pusha
330
 
331
    mov  eax,13              ; clear text area
332
    mov  ebx,100*65536+100
333
    mov  ecx,278*65536+40
334
    mov  edx,0xffffff
335
    int  0x40
336
 
337
    mov  eax,4               ; icon text
338
    mov  ebx,100*65536+278
339
    mov  ecx,0x000000
340
    mov  edx,[current_icon]
341
    add  edx,33
342
    mov  esi,12
343
    int  0x40
344
 
345
    mov  eax,4               ; icon application
346
    add  ebx,14
347
    mov  edx,[current_icon]
348
    add  edx,19
349
    mov  esi,12
350
    int  0x40
351
 
352
    mov  eax,4               ; icon bmp
353
    add  ebx,14
354
    mov  edx,[current_icon]
355
    add  edx,5
356
    mov  esi,12
357
    int  0x40
358
 
359
    popa
360
 
361
    ret
362
 
363
 
364
icon_lst db 'ICON    LST'
365
 
366
load_icon_list:
367
 
368
 
369
    pusha
370
 
371
    mov   eax,6
372
    mov   ebx,icon_lst
373
    mov   ecx,0
374
    mov   edx,-1
375
    mov   esi,icon_data
376
    int   0x40
377
 
378
    add   eax,10
379
    xor   edx,edx
380
    mov   ebx,52
381
    div   ebx
382
    mov   [icons],eax
383
 
384
    mov   edi,icons_reserved   ; clear reserved area
385
    mov   eax,32
386
    mov   ecx,10*10
387
    cld
388
    rep   stosb
389
 
390
    mov   ecx,[icons]          ; set used icons to reserved area
391
    mov   esi,icon_data
392
    cld
393
  ldl1:
394
    movzx ebx,byte [esi+1]
395
    sub   ebx,65
396
    imul  ebx,10
397
    movzx eax,byte [esi]
398
    add   ebx,eax
399
    sub   ebx,65
400
    add   ebx,icons_reserved
401
    mov   [ebx],byte 'x'
402
    add   esi,50+2
403
    loop  ldl1
404
 
405
    popa
406
 
407
    ret
408
 
409
 
410
check_parameters:
411
 
412
    cmp   [I_Param],dword 'BOOT'
413
    je    chpl1
414
    ret
415
   chpl1:
416
 
417
    mov   eax,21
418
    jmp   apply_changes
419
 
420
 
421
positions dd 33,19,5
422
 
423
read_string:
424
 
425
    pusha
426
 
427
    sub  eax,11
428
    shl  eax,2
429
    add  eax,positions
430
    mov  eax,[eax]
431
 
432
    mov  esi,[current_icon]
433
    add  esi,eax
434
    mov  [addr],esi
435
 
436
    mov  edi,[addr]
437
    mov  eax,'_'
438
    mov  ecx,12
439
    cld
440
    rep  stosb
441
 
442
    call print_strings
443
 
444
    mov  edi,[addr]
445
  f11:
446
    mov  eax,10
447
    int  0x40
448
    cmp  eax,2
449
    jz   fbu
450
    jmp  rs_done
451
  fbu:
452
    mov  eax,2
453
    int  0x40
454
    shr  eax,8
455
    cmp  eax,13
456
    je   rs_done
457
    cmp  eax,8
458
    jnz  nobsl
459
    cmp  edi,[addr]
460
    jz   f11
461
    dec  edi
462
    mov  [edi],byte '_'
463
    call print_strings
464
    jmp  f11
465
  nobsl:
466
    cmp  eax,31
467
    jbe  f11
468
    cmp  eax,97
469
    jb   keyok
470
    sub  eax,32
471
  keyok:
472
    mov  [edi],al
473
    call print_strings
474
 
475
    add  edi,1
476
    mov  esi,[addr]
477
    add  esi,12
478
    cmp  esi,edi
479
    jnz  f11
480
 
481
   rs_done:
482
 
483
    mov  ecx,[addr]
484
    add  ecx,12
485
    sub  ecx,edi
486
    mov  eax,32
487
    cld
488
    rep  stosb
489
 
490
    call print_strings
491
 
492
    popa
493
 
494
    ret
495
 
496
 
497
 
498
;   *********************************************
499
;   *******  WINDOW DEFINITIONS AND DRAW ********
500
;   *********************************************
501
 
502
 
503
draw_window:
504
 
505
    mov  eax,12                    ; function 12:tell os about windowdraw
506
    mov  ebx,1                     ; 1, start of draw
507
    int  0x40
508
 
509
                                   ; DRAW WINDOW
510
    mov  eax,0
511
    mov  ebx,210*65536+300
512
    mov  ecx,30*65536+390
513
    mov  edx,0x03ffffff
514
    mov  esi,0x808899ff
515
    mov  edi,0x008899ff
516
    int  0x40
517
 
518
                                   ; WINDOW LABEL
519
    mov  eax,4
520
    mov  ebx,8*65536+8
521
    mov  ecx,0x10ffffff
522
    mov  edx,labelt
523
    mov  esi,labellen-labelt
524
    int  0x40
525
 
526
    mov  eax,13                    ; WINDOW AREA
527
    mov  ebx,20*65536+260
528
    mov  ecx,35*65536+200
529
    mov  edx,0x3366cc
530
    int  0x40
531
 
532
    mov  eax,38                    ; VERTICAL LINE ON WINDOW AREA
533
    mov  ebx,150*65536+150
534
    mov  ecx,35*65536+235
535
    mov  edx,0xffffff
536
    int  0x40
537
 
538
    mov  eax,38                    ; HOROZONTAL LINE ON WINDOW AREA
539
    mov  ebx,20*65536+280
540
    mov  ecx,135*65536+135
541
    mov  edx,0xffffff
542
    int  0x40
543
 
544
    mov  eax,8                     ; TEXT ENTER BUTTONS
545
    mov  ebx,20*65536+72
546
    mov  ecx,275*65536+13
547
    mov  edx,11
548
    mov  esi,[bcolor]
549
    int  0x40
550
    inc  edx
551
    add  ecx,14*65536
552
    mov  eax,8
553
    int  0x40
554
    inc  edx
555
    add  ecx,14*65536
556
    mov  eax,8
557
    int  0x40
558
 
559
    mov  eax,8                     ; APPLY AND SAVE CHANGES BUTTON
560
    mov  ebx,20*65536+259
561
    mov  ecx,329*65536+15
562
    mov  edx,21
563
    mov  esi,[bcolor]
564
    int  0x40
565
 
566
    mov  eax,8                     ; ADD ICON BUTTON
567
    mov  ebx,20*65536+129
568
    add  ecx,14*2*65536
569
    inc  edx
570
    int  0x40
571
 
572
    mov  eax,8                     ; REMOVE ICON BUTTON
573
    add  ebx,130*65536
574
    inc  edx
575
    int  0x40
576
 
577
    mov  eax,0                     ; DRAW BUTTONS ON WINDOW AREA
578
    mov  ebx,20*65536+25
579
    mov  ecx,35*65536+19
580
    mov  edi,icon_table
581
    mov  edx,40
582
   newbline:
583
 
584
    cmp  [edi],byte 'x'
585
    jne  no_button
586
 
587
    mov  esi,0x5577cc
588
    cmp  [edi+100],byte 'x'
589
    jne  nores
590
    mov  esi,0xcc5555
591
  nores:
592
 
593
    push eax
594
    mov  eax,8
595
    int  0x40
596
    pop  eax
597
 
598
  no_button:
599
 
600
    add  ebx,26*65536
601
 
602
    inc  edi
603
    inc  edx
604
 
605
    inc  al
606
    cmp  al,9
607
    jbe  newbline
608
    mov  al,0
609
 
610
    add  edx,6
611
 
612
    ror  ebx,16
613
    mov  bx,20
614
    ror  ebx,16
615
    add  ecx,20*65536
616
 
617
    inc  ah
618
    cmp  ah,9
619
    jbe  newbline
620
 
621
    mov  ebx,24*65536+250
622
    mov  ecx,0xffffff
623
    mov  edx,text
624
    mov  esi,47
625
  newline:
626
    mov  ecx,[edx]
627
    add  edx,4
628
    mov  eax,4
629
    int  0x40
630
    add  ebx,14
631
    add  edx,47
632
    cmp  [edx],byte 'x'
633
    jne  newline
634
 
635
    call print_strings
636
 
637
    mov  eax,12                    ; function 12:tell os about windowdraw
638
    mov  ebx,2                     ; 2, end of draw
639
    int  0x40
640
 
641
    ret
642
 
643
 
644
; DATA AREA
645
 
646
 
647
str1   db   '                   '
648
str2   db   '                   '
649
 
650
bcolor dd 0x335599
651
 
652
icon_table:
653
 
654
    times 4  db  'xxxx  xxxx'
655
    times 2  db  '          '
656
    times 1  db  '          '
657
    times 2  db  'xxxx  xxxx'
658
    times 1  db  '          '
659
 
660
icons_reserved:
661
 
662
    times 10 db  '          '
663
 
664
if lang eq ru
665
  text:
666
      db 0,0,0,0,         '€†Œˆ’… € Ž‡ˆ–ˆž ˆŠŽŠˆ „‹Ÿ …„€Š’ˆŽ‚€ˆŸ   '
667
      db 0,0,0,0,         '                                               '
668
      db 255,255,255,0,   '   ’…Š‘’                                       '
669
      db 255,255,255,0,   ' Žƒ€ŒŒ€                                     '
670
      db 255,255,255,0,   ' ‚Œ ”€‰‹                                      '
671
      db 0,0,0,0,         '                                               '
672
      db 255,255,255,0,   '                 ˆŒ…ˆ’œ                     '
673
      db 0,0,0,0,         '                                               '
674
      db 255,255,255,0,   '      „Ž€‚ˆ’œ              “„€‹ˆ’œ            '
675
      db                  'x' ; <- END MARKER, DONT DELETE
676
 
677
  labelt:
678
       db ' áâŕŽŠŞ  ŕ ĄŽçĽŁŽ á⎍ '
679
  labellen:
680
else
681
  text:
682
      db 0,0,0,0,         'CLICK ON THE UNUSED ICON POSITION TO EDIT      '
683
      db 0,0,0,0,         '                                               '
684
      db 255,255,255,0,   '   ’…Š‘’                                       '
685
      db 255,255,255,0,   ' Žƒ€ŒŒ€                                     '
686
      db 255,255,255,0,   ' ‚Œ ”€‰‹                                      '
687
      db 0,0,0,0,         '                                               '
688
      db 255,255,255,0,   '                 ˆŒ…ˆ’œ                     '
689
      db 0,0,0,0,         '                                               '
690
      db 255,255,255,0,   '      „Ž€‚ˆ’œ              “„€‹ˆ’œ            '
691
      db                  'x' ; <- END MARKER, DONT DELETE
692
 
693
  labelt:
694
       db ' áâŕŽŠŞ  ŕ ĄŽçĽŁŽ á⎍ '
695
  labellen:
696
end if
697
 
698
icons dd 0
699
 
700
addr  dd 0
701
ya    dd 0
702
 
703
add_text db '€†Œˆ’… € Ž‡ˆ–ˆž …ˆ‘Ž‹œ‡“…ŒŽ‰ ˆŠŽŠˆ'
704
add_text_len:
705
 
706
rem_text db '€†Œˆ’… € Ž‡ˆ–ˆž ˆ‘Ž‹œ‡“…ŒŽ‰ ˆŠŽŠˆ'
707
rem_text_len:
708
 
709
icon_name:
710
      db 'ICON       '
711
 
712
icon_start_parameters:
713
      db   25,1,1,1
714
      db   35,1,1,1
715
      db   'WRITE   BMP'
716
      db   'EDITOR     '
717
      db   'EDITOR  ',0,0
718
 
719
icon_default:
720
      db   'AA - TIP.BMP     - SETUP       - SETUP           *',13,10
721
 
722
I_Param:
723
 
724
 icon_data = I_END+256
725
 
726
I_END: