Subversion Repositories Kolibri OS

Rev

Rev 1751 | Rev 2475 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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