Subversion Repositories Kolibri OS

Rev

Rev 539 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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