Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
51 mikedld 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
RAW_SIZE equ 350000
11
ICON_SIZE equ 32*32*3
12
GIF_SIZE equ 45000
13
REC_SIZE equ 80
14
ICON_LST equ '/RD/1/ICON2.LST'
15
;ICON_APP equ '/hd/1/me/icon2';
16
ICON_APP equ '/RD/1/ICON2'
17
;ICON_STRIP equ '/HD/1/ME/ICONSTRP.GIF'
18
ICON_STRIP equ '/RD/1/ICONSTRP.GIF'
19
 
20
  use32
21
  org    0x0
22
  db     'MENUET01'     ; 8 byte id
23
  dd     0x01           ; header version
24
  dd     START          ; start of code
25
  dd     I_END          ; size of image
26
  dd     icon_data+0x30000        ; memory for app
27
  dd     icon_data+0x30000        ; esp
28
  dd     I_Param , 0x0  ; I_Param , I_Icon
29
include  'macros.inc'
108 heavyiron 30
include  'lang.inc'
51 mikedld 31
COLOR_ORDER equ MENUETOS
32
include  'gif_lite.inc'
33
;include  'debug.inc'
34
purge newline
35
;******************************************************************************
36
START:                       ; start of execution
37
    mcall 58,finfo
38
    cmp   ebx,GIF_SIZE
39
    ja    close
40
    mov   esi,gif_file
41
    mov   edi,strip_file
42
    mov   eax,icon_data
43
    call  ReadGIF
44
    movzx eax,word[strip_file+10]
45
    shr  eax,5
46
    mov  [icon_count],eax
47
    call load_ic
48
  boot_str:
49
    cmp   [I_Param],dword 'BOOT'
50
    je   load_icon_list2
51
      call  load_icon_list
52
 red:
53
    call draw_window         ; at first, draw the window
54
    mov  esi,[current_icon]
55
    jmp  band
56
still:
57
 
58
    mov  eax,10              ; wait here for event
59
    int  0x40
60
 
61
    cmp  eax,1               ; redraw request ?
62
    je   red
63
    cmp  eax,2               ; key in buffer ?
64
    je   key
65
    cmp  eax,3               ; button in buffer ?
66
    je   button
67
 
68
    jmp  still
69
 
70
  key:                       ; key
71
    mov  eax,2               ; just read it and ignore
72
    int  0x40
73
    jmp  still
74
 
75
  button:                    ; button
76
    mov  eax,17              ; get id
77
    int  0x40
78
 
79
    shr  eax,8
80
 
81
    cmp  eax,1               ; button id=1 ?
82
    je   close
83
  noclose:
84
      mov  esi,[current_icon]
85
      add  esi,12
86
    mov  ebx,[cur_band];eax
87
    cmp  eax,31
88
    jne  .no_back
89
    add  ebx,8
90
    mov  eax,[icon_count]
91
    cmp  eax,ebx
92
    jae  .drwic2
93
    xor  ebx,ebx
94
    jmp  .drwic2
95
  .no_back:
96
    cmp  eax,30
97
    jne  .no_side
98
    test ebx,ebx
99
    jnz  .dec
100
    mov  ebx,[icon_count]
101
         and  ebx,0xfffffff8
102
    add  ebx,8
103
  .dec:
104
    sub  ebx,8
105
  .drwic2:
106
    mov  [cur_band],ebx
107
  .drwic1:
108
    call draw_icon
109
    jmp  still
110
    .no_side:
111
       cmp  eax,32
112
       jne  .no_ico
113
       push ebx
114
       mcall 37,1
115
       pop  ebx
116
          shr  eax,16
117
       sub  eax,33-19
118
          mov  edi,34
119
          xor  edx,edx
120
          div  edi
121
    lea  ecx,[ebx+eax]
122
    cmp  ecx,[icon_count]
123
    jae  still
124
          mov  [sel_icon1],eax
125
          mov  ecx,eax
126
    add  eax,ebx
127
    call itoa
128
          jmp  .drwic1
129
  .no_ico:
130
    cmp  eax,11
131
    jb   no_str
132
    cmp  eax,13
133
    jg   no_str
134
    call read_string
135
    jmp  still
136
  no_str:
137
 
138
 
139
    cmp  eax,21              ; apply changes
140
    jne  no_apply
141
 
142
    ; (1) save list
143
 
144
    mov  ebx,finfo
145
    mov  dword[ebx],1
146
    mov  edx,REC_SIZE
147
    imul edx,dword [icons]
148
    mov  [ebx+8],edx
149
    mov  esi,iconlst
150
    call lst_path
151
    mcall 58
152
 
153
    ; (2) terminate all icons
154
    mov  eax,9
155
    mov  ebx,I_END
156
    mov  ecx,-1
157
    int  0x40
158
    mov  edi,[ebx+30]
159
     newread2:
160
    mov  esi,1
161
   newread:
162
    inc  esi
163
    mov  eax,9
164
    mov  ebx,I_END
165
    mov  ecx,esi
166
    int  0x40
167
    cmp  edi,[ebx+30]
168
    je   newread
169
    cmp  esi,eax
170
    jg   all_terminated
171
 
172
    cmp  [I_END+10],dword 'ICON'
173
    jne  newread
174
    mov  eax,51
175
    cmp  eax,[I_END+42]
176
    jne  newread
177
    cmp  eax,[I_END+46]
178
    jne  newread
179
 
180
    mov  eax,18
181
    mov  ebx,2
182
    mov  ecx,esi
183
    int  0x40
184
 
185
    jmp  newread2
186
 
187
finfo:
188
        dd 0
189
        dd 0
190
        dd GIF_SIZE/512
191
        dd gif_file
192
        dd icon_data
193
  .path:
194
        db ICON_STRIP,0
195
        rb 31-($-.path)
196
 
197
   all_terminated:
198
 
199
   apply_changes:
200
 
201
    mov  ebx,finfo
202
    mov  dword[ebx],16
203
    mov  dword[ebx+8],boot_str+6
204
    mov  esi,iconname
205
    call lst_path
206
    mcall 58
207
    jmp   still
208
 
209
  no_apply:
210
 
211
    cmp  eax,22                 ; user pressed the 'add icon' button
212
    jne  no_add_icon
213
 
214
    mov  eax,13
215
    mov  ebx,24*65536+270
216
    mov  ecx,(250+8*14)*65536+8
217
    mov  edx,0xffffff
218
    int  0x40
219
    mov  eax,4
220
    mov  ebx,24*65536+250+8*14
221
    mov  ecx,0xff0000
222
    mov  edx,add_text
223
    mov  esi,add_text_len-add_text
224
    int  0x40
225
 
226
    mov  eax,10
227
    int  0x40
228
    cmp  eax,3
229
    jne  still
230
    mov  eax,17
231
    int  0x40
232
    shr  eax,8
233
    cmp  eax,40
234
    jb   no_f
235
    mov  edi,eax
236
    sub  eax,40
237
 
238
    xor  edx,edx  ; bcd -> 10
239
    mov  ebx,16
240
    div  ebx
241
    imul eax,10
242
    add  eax,edx
243
 
244
    mov  ebx,eax
245
    add  ebx,icons_reserved
246
    cmp  [ebx],byte 'x'
247
    je   no_f
248
    mov  [ebx],byte 'x'
249
 
250
    mov  [cur_btn],edi
251
    xor  edx,edx
252
    mov  ebx,10
253
    div  ebx
254
    add  eax,65
255
    add  edx,65
256
    mov  [icon_default+0],dl
257
    mov  [icon_default+1],al
258
 
259
    inc  dword [icons]
260
    mov  edi,[icons]
261
    dec  edi
262
    imul edi,REC_SIZE
263
    add  edi,icon_data
264
 
265
    mov  [current_icon],edi
266
 
267
    mov  esi,icon_default
268
    mov  ecx,REC_SIZE
269
    cld
270
    rep  movsb
271
    mov  esi,[current_icon]
272
    jmp  band
273
  no_f:
274
 
275
    call draw_btns;draw_window
276
 
277
    jmp  still
278
 
279
  no_add_icon:
280
 
281
 
282
    cmp  eax,23                     ; user pressed the remove icon button
283
    jne  no_remove_icon
284
 
285
    mov  eax,13
286
    mov  ebx,24*65536+270
287
    mov  ecx,(250+8*14)*65536+8
288
    mov  edx,0xffffff
289
    int  0x40
290
    mov  eax,4
291
    mov  ebx,24*65536+250+8*14
292
    mov  ecx,0xff0000
293
    mov  edx,rem_text
294
    mov  esi,rem_text_len-rem_text
295
    int  0x40
296
 
297
    mov  eax,10
298
    int  0x40
299
    cmp  eax,3
300
    jne  no_f;ound
301
    mov  eax,17
302
    int  0x40
303
    shr  eax,8
304
    cmp  eax,40
305
    jb   red;no_f;ound
306
    sub  eax,40
307
 
308
    xor  edx,edx
309
    mov  ebx,16
310
    div  ebx
311
    imul eax,10
312
    add  eax,edx
313
 
314
    mov  ebx,eax
315
    add  ebx,icons_reserved
316
    cmp  [ebx],byte 'x'
317
    jne  red
318
    mov  [ebx],byte ' '
319
 
320
    xor  edx,edx
321
    mov  ebx,10
322
    div  ebx
323
    shl  eax,8
324
    mov  al,dl
325
 
326
    add  eax,65*256+65
327
 
328
    mov  esi,icon_data
329
    mov  edi,REC_SIZE
330
    imul edi,[icons]
331
    add  edi,icon_data
332
  news:
333
    cmp  word [esi],ax
334
    je   foundi
335
    add  esi,REC_SIZE
336
    cmp  esi,edi
337
    jb   news
338
    jmp  red
339
 
340
  foundi:
341
 
342
    mov  ecx,edi
343
    sub  ecx,esi
344
 
345
    mov  edi,esi
346
    add  esi,REC_SIZE
347
 
348
    cld
349
    rep  movsb
350
 
351
    dec  [icons]
352
 
353
    mov  eax,icon_data
354
    mov  [current_icon],eax
355
    movzx ebx,word[eax]
356
    sub  bx,'AA'
357
    shl  bl,4
358
    shr  ebx,4
359
    add  ebx,40
360
    mov  [cur_btn],ebx
361
 
362
    jmp  red
363
 
364
  no_remove_icon:
365
 
366
    cmp  eax,40                 ; user pressed button for icon position
367
    jb   no_on_screen_button
368
    mov  edi,eax
369
    sub  eax,40
370
    mov  edx,eax
371
    shl  eax,4
372
    and  edx,0xf
373
    mov  dh,ah
374
    add  edx,65*256+65
375
 
376
    mov  esi,icon_data
377
    mov  ecx,[icons]
378
    cld
379
   findl1:
380
    cmp  dx,[esi]
381
    je   foundl1
382
    add  esi,REC_SIZE
383
    loop findl1
384
    jmp  still
385
 
386
   foundl1:
387
 
388
    mov  [current_icon],esi
389
    mov  [cur_btn],edi
390
   band:
391
    add  esi,12
392
    call atoi
393
    and  eax,0xfffff8
394
    mov  [cur_band],eax
395
    call draw_btns
396
 
397
    jmp  still
398
 
399
  no_on_screen_button:
400
 
401
 
402
    jmp  still
403
 
404
 
405
current_icon dd icon_data
406
 
407
 
408
print_strings:
409
 
410
    pusha
411
 
412
    mov  eax,13              ; clear text area
413
    mov  ebx,100*65536+180
414
    mov  ecx,(278+12)*65536+40
415
    mov  edx,0xffffff
416
    int  0x40
417
 
418
          xor  edi,edi
419
    mov  eax,4               ; icon text
420
    mov  ebx,100*65536+278+14
421
    mov  ecx,3
422
  .ll:
423
    push ecx
424
    mov  ecx,0x000000
425
    mov  edx,[current_icon]
426
    add  edx,[positions+edi*4]
427
    movzx esi,byte[str_lens+edi]
428
    inc  edi
429
    int  0x40
430
    add  ebx,14
431
    pop  ecx
432
    loop .ll
433
 
434
    popa
435
    ret
436
 
437
iconlst db ICON_LST,0
438
 
439
load_icon_list:
440
 
441
    mov   edi,icons_reserved   ; clear reserved area
442
    mov   eax,32
443
    mov   ecx,10*9
444
    cld
445
    rep   stosb
446
 
447
    mov   ecx,[icons]          ; set used icons to reserved area
448
    mov   esi,icon_data
449
  ldl1:
450
    movzx ebx,byte [esi+1]
451
    sub   ebx,65
452
    imul  ebx,10
453
    movzx eax,byte [esi]
454
    add   ebx,eax
455
    sub   ebx,65
456
    add   ebx,icons_reserved
457
    mov   [ebx],byte 'x'
458
    add   esi,REC_SIZE
459
    loop  ldl1
460
    ret
461
 
462
lst_path:
463
    mov   ecx,30
464
    mov   edi,finfo.path
465
    rep   movsb
466
    ret
467
 
468
load_ic:
469
    mov   ebx,finfo
470
    mov   dword[ebx+8],(48*REC_SIZE)shr 9+1
471
    mov   dword[ebx+12],icon_data
472
    mov   dword[ebx+16],gif_file
473
    mov   esi,iconlst
474
    call  lst_path
475
    mcall 58
476
    lea   eax,[ebx+10]
477
    xor   edx,edx
478
    mov   ebx,REC_SIZE
479
    div   ebx
480
    mov   [icons],eax
481
        ret
482
 
483
 
484
positions dd 3,16,47
485
str_lens db 8,30,30
486
 
487
read_string:
488
    pusha
489
    sub  eax,11
490
    movzx ecx,byte[str_lens+eax]
491
    mov  [cur_str],ecx
492
    mov  eax,[positions+eax*4]
493
 
494
    mov  edi,[current_icon]
495
    add  edi,eax
496
    mov  [addr],edi
497
 
498
          add  edi,ecx
499
 
500
  .l1:
501
    dec  edi
502
    cmp  byte[edi],' '
503
    jne  .found
504
    mov  byte[edi],'_'
505
    loop .l1
506
    dec  edi
507
  .found:
508
    inc  edi
509
    push  edi
510
    call print_strings
511
 
512
    pop  edi
513
  f11:
514
    mov  eax,10
515
    int  0x40
516
    cmp  eax,2
517
    jz   fbu
518
    jmp  rs_done
519
  fbu:
520
    mov  eax,2
521
    int  0x40
522
    shr  eax,8
523
    cmp  eax,13
524
    je   rs_done
525
    cmp  eax,8
526
    jnz  nobsl
527
    cmp  edi,[addr]
528
    jz   f11
529
    dec  edi
530
    mov  [edi],byte '_'
531
    call print_strings
532
    jmp  f11
533
  nobsl:
534
    cmp  eax,31
535
    jbe  f11
536
    mov  [edi],al
537
    call print_strings
538
 
539
    inc  edi
540
    mov  esi,[addr]
541
    add  esi,[cur_str]
542
    cmp  esi,edi
543
    jnz  f11
544
 
545
   rs_done:
546
 
547
    mov  ecx,[addr]
548
    add  ecx,[cur_str]
549
    sub  ecx,edi
550
    mov  eax,32
551
    cld
552
    rep  stosb
553
    call print_strings
554
    popa
555
    ret
556
 
557
;   *********************************************
558
;   *******  WINDOW DEFINITIONS AND DRAW ********
559
;   *********************************************
560
 
561
 
562
draw_window:
563
 
564
    mov  eax,12                    ; function 12:tell os about windowdraw
565
    mov  ebx,1                     ; 1, start of draw
566
    int  0x40
567
 
568
                                   ; DRAW WINDOW
569
    mov  eax,0
570
    mov  ebx,210*65536+300
571
    mov  ecx,30*65536+390-14
572
    mov  edx,0x03ffffff
573
    mov  esi,0x808899ff
574
    mov  edi,0x008899ff
575
    int  0x40
576
 
577
                                   ; WINDOW LABEL
578
    mov  eax,4
579
    mov  ebx,8*65536+8
580
    mov  ecx,0x10ffffff
581
    mov  edx,labelt
582
    mov  esi,labellen-labelt
583
    int  0x40
584
 
585
    mov  eax,13                    ; WINDOW AREA
586
    mov  ebx,20*65536+260
587
    mov  ecx,35*65536+200
588
    mov  edx,0x3366cc
589
    int  0x40
590
 
591
    mov  eax,38                    ; VERTICAL LINE ON WINDOW AREA
592
    mov  ebx,150*65536+150
593
    mov  ecx,35*65536+235
594
    mov  edx,0xffffff
595
    int  0x40
596
 
597
    mov  eax,38                    ; HOROZONTAL LINE ON WINDOW AREA
598
    mov  ebx,20*65536+280
599
    mov  ecx,135*65536+135
600
    mov  edx,0xffffff
601
    int  0x40
602
 
603
    mov  eax,8                     ; TEXT ENTER BUTTONS
604
    mov  ebx,20*65536+72
605
    mov  ecx,(275+1+14)*65536+13-2
606
    mov  edx,11
607
    mov  esi,[bcolor]
608
    int  0x40
609
    inc  edx
610
    add  ecx,14*65536
611
    int  0x40
612
    inc  edx
613
    add  ecx,14*65536
614
    int  0x40
615
 
616
;    mov  eax,8                     ; APPLY AND SAVE CHANGES BUTTON
617
    mov  ebx,20*65536+259
618
    mov  ecx,(329+2)*65536+15-4
619
    mov  edx,21
620
    mov  esi,[bcolor]
621
    int  0x40
622
 
623
;    mov  eax,8                     ; ADD ICON BUTTON
624
    mov  ebx,20*65536+129-2
625
    add  ecx,14*65536
626
    inc  edx
627
    int  0x40
628
 
629
;    mov  eax,8                     ; REMOVE ICON BUTTON
630
    add  ebx,(130+2)*65536
631
    inc  edx
632
    int  0x40
633
 
634
    mcall ,<20-14,8>,<260-23,32>,30+1 shl 30    ; IMAGE BUTTON
635
    inc  edx
636
    add  ebx,(36*7+26) shl 16
637
    mcall
638
    add  edx,1+1 shl 29
639
    mov  ebx,(33-19) shl 16+(34*8)
640
    mcall
641
    mcall 4,<23-15,273-24>,0,arrows,1
642
    add  ebx,(36*7+27)shl 16
643
    add  edx,2
644
    mcall
645
    dec  edx
646
    mcall ,<120,250>
647
    lea  edx,[ebx+8 shl 16]
648
    mov  ecx,[icon_count]
649
    mcall 47,0x30000,,,0
650
 
651
;;
652
    mov  ebx,24*65536+250+14+14+14
653
    mov  ecx,0xffffff
654
    mov  edx,text
655
    mov  esi,47
656
  newline:
657
    mov  ecx,[edx]
658
    add  edx,4
659
    mov  eax,4
660
    int  0x40
661
    add  ebx,14
662
    add  edx,47
663
    cmp  [edx],byte 'x'
664
    jne  newline
665
draw_btns:
666
;;
667
    mov  eax,0                     ; DRAW BUTTONS ON WINDOW AREA
668
    mov  ebx,20*65536+25
669
    mov  ecx,35*65536+19
670
    mov  edi,icon_table
671
    mov  edx,40
672
   newbline:
673
 
674
    cmp  [edi],byte 'x'
675
    jne  no_button
676
 
677
    mov  esi,0x5577cc
678
    cmp  [edi+90],byte 'x'
679
    jne  nores
680
    mov  esi,0xcc5555
681
    cmp  edx,[cur_btn]
682
    jne  nores
683
    mov  esi,0xe7e05a
684
  nores:
685
 
686
    push eax
687
    mov  eax,8
688
    int  0x40
689
    pop  eax
690
 
691
  no_button:
692
 
693
    add  ebx,26*65536
694
 
695
    inc  edi
696
    inc  edx
697
 
698
    inc  al
699
    cmp  al,9
700
    jbe  newbline
701
    mov  al,0
702
 
703
    add  edx,6
704
 
705
    ror  ebx,16
706
    mov  bx,20
707
    ror  ebx,16
708
    add  ecx,20*65536
709
 
710
    inc  ah
711
    cmp  ah,8;9
712
    jbe  newbline
713
    call print_strings
714
    call draw_icon
715
    mov  eax,12                    ; function 12:tell os about windowdraw
716
    mov  ebx,2                     ; 2, end of draw
717
    int  0x40
718
 
719
    ret
720
 
721
draw_icon:
722
    mcall 13,<33-20,34*8+2>,<260-24,37+15-2>,0xffffff
723
    mov  esi,[current_icon]
724
    add  esi,12
725
    call atoi
726
    push eax
727
    cmp  eax,[cur_band]
728
    jb   .nou
729
    sub  eax,[cur_band]
730
    cmp  eax,7
731
    ja   .nou
732
    imul eax,34 shl 16
733
    lea  ebx,[eax+(33-19) shl 16]
734
    mov  bx,34
735
    mcall 13,,<236+35,3>,0xff0000
736
    mov  eax,[esp]
737
  .nou:
738
    mov  eax,[cur_band]
739
    and  eax,0xfffffff8
740
    push eax
741
    imul eax,ICON_SIZE
742
    lea  ebx,[strip_file+12+eax]
743
    mov  ecx,8
744
    mov  edx,(33-18) shl 16+238
745
  .nxt:
746
    push ecx
747
    mcall 7,,<32,32>
748
    pop  ecx
749
    add  ebx,ICON_SIZE
750
    add  edx,34 shl 16
751
    loop .nxt
752
 
753
    mcall 4,<45,280-2>,0,rep_text,rep_text_len-rep_text
754
    lea  edx,[ebx+(8*5)shl 16]
755
    pop  ecx
756
    mcall 47,0x30000,,,0xff
757
    add  ecx,7
758
    add  edx,(3*8+4)shl 16
759
    mcall
760
    mov  ecx,[icon_count]
761
    add  edx,(5*8+4)shl 16
762
    mcall
763
    pop  ecx
764
    add  edx,(10*8+4)shl 16
765
    mcall ,,,,0xff0000
766
    ret
767
 
768
; DATA AREA
769
 
770
 
771
bcolor dd 0x335599
772
 
773
icon_table:
774
 
775
    times 4  db  'xxxx  xxxx'
776
    times 2  db  '          '
777
    times 1  db  '          '
778
    times 2  db  'xxxx  xxxx'
779
;    times 1  db  '          '
780
 
781
icons_reserved:
782
    times 9  db  '          '
783
 
784
if lang eq ru
785
  text:
786
      db 255,255,255,0,   '   ’…Š‘’                                       '
787
      db 255,255,255,0,   ' Žƒ€ŒŒ€                                     '
788
      db 255,255,255,0,   ' €€Œ…’›                                     '
789
      db 255,255,255,0,   '                 ˆŒ…ˆ’œ                     '
790
      db 255,255,255,0,   '      „Ž€‚ˆ’œ              “„€‹ˆ’œ            '
791
      db 0,0,0,0,         '€†Œˆ’… € Ž‡ˆ–ˆž ˆŠŽŠˆ „‹Ÿ …„€Š’ˆŽ‚€ˆŸ   '
792
      db                  'x' ; <- END MARKER, DONT DELETE
793
 
794
  labelt:
795
       db ' áâனª  à ¡®ç¥£® á⮫ '
796
  labellen:
797
else
798
  text:
799
      db 255,255,255,0,   '   TITLE                                       '
800
      db 255,255,255,0,   '  APP NAME                                     '
801
      db 255,255,255,0,   ' PARAMETERS                                    '
802
      db 255,255,255,0,   '                APPLY CHANGES                  '
803
      db 255,255,255,0,   '      ADD ICON              REMOVE ICON        '
804
      db 0,0,0,0,         '€†Œˆ’… € Ž‡ˆ–ˆž ˆŠŽŠˆ „‹Ÿ …„€Š’ˆŽ‚€ˆŸ   '
805
      db                  'x' ; <- END MARKER, DONT DELETE
806
 
807
  labelt:
808
       db 'Icon Manager'
809
  labellen:
810
end if
811
 
812
;ya    dd 0
813
 
814
add_text db '€†Œˆ’… € Ž‡ˆ–ˆž …ˆ‘Ž‹œ‡“…ŒŽ‰ ˆŠŽŠˆ'
815
add_text_len:
816
 
817
rem_text db '€†Œˆ’… € Ž‡ˆ–ˆž ˆ‘Ž‹œ‡“…ŒŽ‰ ˆŠŽŠˆ'
818
rem_text_len:
819
arrows db ''
820
iconname:
821
      db ICON_APP,0
822
 
823
icon_default:
824
   db   'AA-SYSXTREE-000-/RD/1/SYSXTREE                '
825
   db   '-                              *'
826
   db   13,10
827
 
828
rep_text:
829
if lang eq ru
830
     db '‡€—Šˆ    -     ˆ‡    , ‚›€ #'
831
else
832
     db 'ICONS     -     OF    , SELECTED'
833
end if
834
 
835
rep_text_len:
836
 
837
;//////////////////////////
838
get_bg_info:
839
    mov  eax,39
840
    mov  ebx,4
841
    int  0x40
842
    mov  [bgrdrawtype],eax
843
 
844
    mov  eax,39     ; get background size
845
    mov  ebx,1
846
    int  0x40
847
    mov  [bgrxy],eax
848
 
849
    mov  ebx,eax
850
    shr  eax,16
851
    and  ebx,0xffff
852
    mov  [bgrx],eax
853
    mov  [bgry],ebx
854
    ret
855
 
856
calc_icon_pos:
857
    movzx eax,byte [ebp-20]    ; x position
858
    sub  eax,'A'        ;eax - number of letter
859
    cmp  eax,4
860
    jg     no_left
861
    shl  eax,6 ;imul eax,64
862
    add  eax,16
863
    movzx ebx,[warea.left]
864
    add  eax,ebx
865
    jmp  x_done
866
  no_left:
867
    sub  eax,9
868
    sal  eax,6 ;imul eax,64
869
    sub  eax,16+52-1
870
    movzx ebx,[warea.right]
871
    add  eax,ebx
872
  x_done:
873
;    mov  [xpos],eax
874
    mov  [ebp-12],eax
875
 
876
    movzx eax,byte [ebp-20+1]  ; y position
877
    sub  eax,'A'        ; eax - number of letter
878
    cmp  eax,4
879
    jg     no_up
880
    shl  eax,6            ;imul eax,80
881
    add  eax,16
882
    movzx ebx,[warea.top]
883
    add  eax,ebx
884
    jmp  y_done
885
  no_up:
886
    sub  eax,9
887
    shl  eax,6            ;imul eax,80
888
    sub  eax,16-1
889
    movzx ebx,[warea.bottom]
890
    add  eax,ebx
891
  y_done:
892
;    mov  [ypos],eax
893
    mov  [ebp-8],eax
894
    ret
895
 
896
;START2:
897
load_icon_list2:
898
        mov  eax,finfo
899
        mov  dword[eax],16
900
        mov  dword[eax+8],param_str
901
    call  get_bg_info
902
 
903
        mcall   48,5
904
        mov     [warea.by_x],eax
905
        mov     [warea.by_y],ebx
906
 
907
        mov     eax,14
908
        int     0x40
909
        add     eax,0x00010001
910
        mov     [scrxy],eax
911
 
912
apply_changes2:
913
 
914
    mov  edi,[icons]
915
    mov  esi,icon_data
916
    mov  ebp,0x5000 ; threads stack starting point
917
 
918
  start_new:
919
    mov eax,[esi]
920
    mov [ebp-20],eax
921
    call calc_icon_pos
922
 
923
    mov  eax,51
924
    mov  ebx,1
925
    mov  ecx,thread
926
;    mov  edx,[thread_stack]
927
    mov  edx,ebp
928
;    sub  edx,4
929
;    mov  [edx],esi
930
    mov  dword[ebp-4],esi
931
    int  0x40
932
;    add  [thread_stack],0x100
933
    add  ebp,0x100
934
 
935
    mov  eax,5
936
    mov  ebx,1
937
wait_thread_start:         ;wait until thread draw itself first time
938
    cmp  [create_thread_event],bl
939
    jz     wait_thread_end
940
    int  0x40
941
    jmp  wait_thread_start
942
wait_thread_end:
943
    dec  [create_thread_event]     ;reset event
944
 
945
 
946
    add  esi,REC_SIZE
947
    dec  edi
948
    jnz  start_new
949
  close:
950
    or     eax,-1
951
    int  0x40
952
 
953
thread:
954
;   pop  ebp ;ebp - address of our icon
955
    sub  esp,12
956
    mov  ebp,esp
957
    sub  esp,16
958
    call draw_window2
959
    mov  [create_thread_event],1
960
    mov  eax,40
961
    mov  ebx,010101b
962
    int  0x40
963
 
964
still2:
965
 
966
    mov  eax,10
967
    int  0x40
968
 
969
    cmp  eax,1
970
    je     red2
971
    cmp  eax,3
972
    je     button2
973
    cmp  eax,5
974
    jne  still2
975
 
976
    call  get_bg_info
977
    mov   eax,5
978
    mov   ebx,1
979
    call  draw_icon2
980
 
981
    jmp  still2
982
 
983
  red2:
984
        mcall   14
985
        add     eax,0x00010001
986
        mov     [scrxy],eax
987
        mcall   48,5
988
        mov     [warea.by_x],eax
989
        mov     [warea.by_y],ebx
990
        add     ebp,+12
991
        call    calc_icon_pos
992
        add     ebp,-12
993
        mcall   9,I_END,-1
994
        mov     eax,[I_END+process_information.x_start]
995
        cmp     eax,[ebp+0]
996
        jne     @f
997
        mov     eax,[I_END+process_information.y_start]
998
        cmp     eax,[ebp+4]
999
        je      .lp1
1000
    @@: call    get_bg_info
1001
        mcall   67,[ebp+0],[ebp+4],51,51
1002
 
1003
  .lp1: call    draw_window2
1004
        jmp     still2
1005
 
1006
  key2:
1007
    mov  eax,2
1008
    int  0x40
1009
 
1010
    jmp  still2
1011
 
1012
  button2:
1013
    mov  eax,17
1014
    int  0x40
1015
 
1016
;    mcall 55,eax, , ,klick_music
1017
 
1018
    mov  esi,[ebp+8]
1019
          mov  ebx,1
1020
          mov  edi,finfo.path
1021
          call fill_paths
1022
          inc  ebx
1023
       mov  edi,param_str
1024
    mov  dword[finfo+8],param_str
1025
          call fill_paths
1026
          cmp  byte[edi],0
1027
    jne  .no0
1028
    and  dword[finfo+8],0
1029
  .no0:
1030
;    lea  ebx,[ebp+19]
1031
    mov  ebx,finfo
1032
    mov  eax,58
1033
    int  0x40
1034
;    dph  eax
1035
    cmp  eax,1024
1036
    jae  still2
1037
    mcall 55,eax, , ,klick_music
1038
    jmp  still2
1039
 
1040
klick_music db 0x85,0x60,0x85,0x70,0x85,0x65,0
1041
 
1042
fill_paths:
1043
        push esi edi
1044
;        dps  '>'
1045
        movzx ecx,byte[str_lens+ebx]
1046
        add  esi,[positions+ebx*4]
1047
        push esi
1048
;  mov  edx,esi
1049
        add  esi,ecx
1050
 
1051
    .l1:
1052
        dec  esi
1053
        cmp  byte[esi],' '
1054
        jnz   .found
1055
        loop .l1
1056
  pop  esi
1057
  jmp  .noms
1058
    .found:
1059
        lea  ecx,[esi+1]
1060
        pop  esi
1061
        sub  ecx,esi
1062
        rep  movsb
1063
 .noms:
1064
        and  byte[edi],0
1065
;        call debug_outstr
1066
;        dps  <'<',13,10>
1067
        pop  edi esi
1068
        ret
1069
 
1070
atoi:
1071
        push esi
1072
        xor  eax,eax
1073
        xor  ebx,ebx
1074
  .nxt:
1075
    lodsb
1076
    cmp  al,'0'
1077
    jb   .done
1078
    cmp  al,'9'
1079
    ja   .done
1080
    sub  eax,'0'
1081
    imul ebx,10
1082
    add  ebx,eax
1083
    jmp  .nxt
1084
  .done:
1085
      pop  esi
1086
      mov  eax,ebx
1087
        ret
1088
 
1089
itoa:
1090
;        mov  esi,[current_icon]
1091
        add  esi,2
1092
    mov ebx,10
1093
    mov ecx,3
1094
  .l0:
1095
    xor edx,edx
1096
    div ebx
1097
    add dl,'0'
1098
    mov [esi],dl
1099
    dec esi
1100
    loop .l0
1101
;    and byte[esi],0
1102
        ret
1103
 
1104
draw_picture:
1105
    mov  [image],0x3000
1106
    mov  edi,[ebp+8]
1107
    lea  esi,[edi+12]
1108
    call atoi
1109
          cmp  eax,[icon_count]
1110
          ja  toponly.ex
1111
          imul eax,(32*3*32)
1112
          lea  edi,[eax+strip_file+12]
1113
    xor  ebx,ebx
1114
    xor  ecx,ecx
1115
    mov  esi,edi;strip_file+12+(32*3*32)*2
1116
 
1117
    mov  [pixpos],0
1118
  newb:
1119
    push ebx
1120
    push ecx
1121
 
1122
    cmp  ebx,10
1123
    jb     yesbpix
1124
    cmp  ebx,42
1125
    jge  yesbpix
1126
    cmp  ecx,31;2
1127
    jg     yesbpix
1128
 
1129
    push esi
1130
    mov  esi,edi
1131
    add  esi,[pixpos]
1132
 
1133
no_correction_pixpos:
1134
    add  [pixpos],3
1135
    mov  eax,[esi]
1136
    and  eax,0xffffff
1137
 
1138
    pop  esi
1139
 
1140
    cmp eax,0
1141
    je    yesbpix
1142
    cmp eax,0xfffcff ;f5f5f5
1143
    je    yesbpix
1144
    jmp nobpix
1145
 
1146
  yesbpix:
1147
 
1148
  stretch:
1149
    cmp   [bgrdrawtype],dword 2
1150
    jne   nostretch
1151
;    mov   eax,[ypos]
1152
    mov   eax,[ebp+4]
1153
    add   eax,ecx
1154
    imul  eax,[bgry]
1155
    cdq
1156
    movzx ebx,word [scrxy]
1157
    div   ebx
1158
    imul  eax,[bgrx]
1159
    push  eax
1160
;    mov   eax,[xpos]
1161
    mov   eax,[ebp+0]
1162
    add   eax,[esp+8]
1163
    imul  eax,[bgrx]
1164
    cdq
1165
    movzx ebx,word [scrxy+2]
1166
    div   ebx
1167
    add   eax,[esp]
1168
    add   esp,4
1169
 
1170
    jmp   notiled
1171
 
1172
  nostretch:
1173
 
1174
    cmp   [bgrdrawtype],dword 1
1175
    jne   notiled
1176
;    mov   eax,[ypos]
1177
    mov   eax,[ebp+4]
1178
    add   eax,ecx
1179
    cdq
1180
    movzx ebx,word [bgrxy]
1181
    div   ebx
1182
    mov   eax,edx
1183
    imul  eax,[bgrx]
1184
    push  eax
1185
;    mov   eax,[xpos]
1186
    mov   eax,[ebp+0]
1187
    add   eax,[esp+8]
1188
    movzx ebx,word [bgrxy+2]
1189
    cdq
1190
    div   ebx
1191
    mov   eax,edx
1192
    add   eax,[esp]
1193
    add   esp,4
1194
 
1195
  notiled:
1196
 
1197
    lea  ecx,[eax+eax*2]
1198
    mov  eax,39
1199
    mov  ebx,2
1200
    int  0x40
1201
 
1202
  nobpix:
1203
 
1204
    pop  ecx
1205
    pop  ebx
1206
 
1207
    mov  edx,eax
1208
    mov  eax,[image]
1209
    mov  [eax],edx
1210
    mov  [eax],dl
1211
    inc  eax
1212
    ror  edx,8
1213
    mov  [eax],dl
1214
    inc  eax
1215
    ror  edx,8
1216
    mov  [eax],dl
1217
    inc  eax
1218
    mov  [image],eax
1219
    inc  ebx
1220
    mov  eax,[yw]
1221
    inc  eax
1222
    cmp  ebx,eax
1223
    jnz  newb
1224
    xor  ebx,ebx
1225
 
1226
    inc  ecx
1227
 
1228
    mov  eax,[ya]
1229
    add  [pixpos],eax
1230
 
1231
    cmp  [top],1
1232
    jne  notop
1233
    cmp  ecx,38
1234
    je     toponly
1235
 
1236
  notop:
1237
 
1238
    cmp  ecx,52
1239
    jnz  newb
1240
 
1241
  toponly:
1242
 
1243
    mov  eax,7
1244
    mov  ebx,0x3000
1245
    mov  ecx,52 shl 16 + 52
1246
    xor  edx,edx
1247
    int  0x40
1248
  .ex:
1249
    mov  [load_pic],0
1250
    ret
1251
 
1252
draw_text:
1253
 
1254
    mov  esi,[ebp+8]
1255
    add  esi,3
1256
    push edi
1257
    mov  edi,labelt
1258
    mov  ecx,8
1259
    cld
1260
    rep  movsb
1261
    pop  edi
1262
    mov   eax,labelt
1263
  news2:
1264
    cmp   [eax],byte 33
1265
    jb      founde
1266
    inc   eax
1267
    cmp   eax,labelt+8;11
1268
    jb      news2
1269
   founde:
1270
    sub   eax,labelt
1271
    mov   [tl],eax
1272
 
1273
    mov   eax,[tl]
1274
    lea   eax,[eax+eax*2]  ; eax *= char_width/2
1275
    shl   eax,16
1276
 
1277
    mov   ebx,27*65536+42
1278
    sub   ebx,eax
1279
 
1280
    mov   eax,4
1281
    xor   ecx,ecx         ; black shade of text
1282
    mov   edx,labelt
1283
    mov   esi,[tl]
1284
    add   ebx,1 shl 16      ;*65536+1
1285
    int   0x40
1286
    inc   ebx
1287
    int   0x40
1288
    add   ebx,1 shl 16
1289
    int   0x40
1290
    inc   ebx
1291
    int   0x40
1292
    sub   ebx,1 shl 16
1293
    int   0x40
1294
    dec   ebx
1295
    sub   ebx,1 shl 16
1296
    int   0x40
1297
    sub   ebx,1 shl 16
1298
    dec   ebx
1299
    int   0x40
1300
    dec   ebx
1301
    add   ebx,1 shl 16
1302
    int   0x40
1303
    inc   ebx
1304
    mov   ecx,0xffffff
1305
 
1306
    int   0x40
1307
    mov   [draw_pic],0
1308
    ret
1309
 
1310
;   *********************************************
1311
;   *******  WINDOW DEFINITIONS AND DRAW ********
1312
;   *********************************************
1313
 
1314
 
1315
draw_window2:
1316
 
1317
    mov  eax,12            ; function 12:tell os about windowdraw
1318
    mov  ebx,1               ; 1, start of draw
1319
    int  0x40
1320
 
1321
                   ; DRAW WINDOW
1322
    xor  eax,eax             ; function 0 : define and draw window
1323
;    mov  ebx,[xpos-2]
1324
    mov  ebx,[ebp+0-2]
1325
;    mov  ecx,[ypos-2]
1326
    mov  ecx,[ebp+4-2]
1327
    add  ebx,[yw]           ; [x start] *65536 + [x size]
1328
    add  ecx,51            ; [y start] *65536 + [y size]
1329
    mov  edx,0x01000000        ; color of work area RRGGBB,8->color gl
1330
    int  0x40
1331
 
1332
    mov  eax,8      ; button
1333
    mov  ebx,51
1334
    mov  ecx,50
1335
    mov  edx,1+20000000 ; or 0x40000000
1336
    int  0x40
1337
 
1338
    mov  eax,5
1339
    mov  ebx,1
1340
draw_icon2:
1341
    xchg [load_pic],bl
1342
    test bl,bl
1343
    je     draw_icon_end
1344
    int  0x40
1345
    jmp  draw_icon2
1346
draw_icon_end:
1347
 
1348
    mov  eax,5
1349
    mov  ebx,1
1350
draw_icon_2:
1351
    xchg [draw_pic],bl
1352
    test bl,bl
1353
    je     draw_icon_end_2
1354
    int  0x40
1355
    jmp  draw_icon_2
1356
draw_icon_end_2:
1357
 
1358
    mov  eax,9
1359
    mov  ebx,process_table
1360
    mov  ecx,-1
1361
    int  0x40
1362
 
1363
    call draw_picture
1364
    call draw_text
1365
 
1366
    mov  eax,12
1367
    mov  ebx,2
1368
    int  0x40
1369
 
1370
    ret
1371
 
1372
tl        dd      8
1373
yw        dd     51
1374
ya        dd      0
1375
cur_btn   dd 40
1376
 
1377
;xpos       dd   15
1378
;ypos       dd  185
1379
draw_pic    db      0
1380
load_pic    db      0
1381
create_thread_event db 0
1382
 
1383
 
1384
image          dd  0x3000
1385
;thread_stack  dd  0x5000
1386
 
1387
;icons dd 0
1388
 
1389
 
1390
I_Param:
1391
 
1392
 icon_data = I_END+0x1400
1393
 process_table = I_END+0x2400
1394
 
1395
;I_END:
1396
 
1397
bgrx dd ?
1398
bgry dd ?
1399
param_str rb 31
1400
 
1401
;//////////////////////////
1402
 
1403
bgrxy        dd    ?
1404
warea:
1405
 .by_x:
1406
  .right  dw ?
1407
  .left   dw ?
1408
 .by_y:
1409
  .bottom dw ?
1410
  .top    dw ?
1411
scrxy        dd    ?
1412
bgrdrawtype  dd    ?
1413
 
1414
pixpos dd    ?
1415
top      dd ?
1416
icons dd ?
1417
addr  dd ?
1418
cur_str    dd ?
1419
cur_band   dd ?
1420
sel_icon1  rd 1
1421
icon_count rd 1
1422
gif_file  rb  GIF_SIZE
1423
strip_file rb RAW_SIZE
1424
;I_Param:
1425
 
1426
; icon_data = I_END+256
1427
 
1428
I_END: