Subversion Repositories Kolibri OS

Rev

Rev 633 | Rev 2245 | 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.  
  959.     mov  eax,10
  960.     mcall
  961.  
  962.     cmp  eax,1
  963.     je     red2
  964.     cmp  eax,3
  965.     je     button2
  966.  
  967.     call  get_bg_info
  968.     mov   eax,5
  969.     mov   ebx,1
  970.     call  draw_icon2
  971.  
  972.     jmp  still2
  973.  
  974.   red2:
  975.         mcall   14
  976.         add     eax,0x00010001
  977.         mov     [scrxy],eax
  978.         mcall   48,5
  979.         mov     [warea.by_x],eax
  980.         mov     [warea.by_y],ebx
  981.         add     ebp,+12
  982.         call    calc_icon_pos
  983.         add     ebp,-12
  984.         mcall   9,I_END,-1
  985.         mov     eax,[I_END+process_information.box.left]
  986.         cmp     eax,[ebp+0]
  987.         jne     @f
  988.         mov     eax,[I_END+process_information.box.top]
  989.         cmp     eax,[ebp+4]
  990.         je      .lp1
  991.     @@: call    get_bg_info
  992.         mcall   67,[ebp+0],[ebp+4],51,51
  993.  
  994.   .lp1: 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.     mov  esi,[ebp+8]
  1005.           mov  ebx,1
  1006.           mov  edi,finfo.path
  1007.           call fill_paths
  1008.           inc  ebx
  1009.        mov  edi,param_str
  1010.     mov  dword[finfo_start+8],edi
  1011.           call fill_paths
  1012.           cmp  byte[edi],0
  1013.     jne  .no0
  1014.     and  dword[finfo_start+8],0
  1015.   .no0:
  1016.     mov  ebx,finfo_start
  1017.     mov  eax,70
  1018.     mcall
  1019.     jmp  still2
  1020.  
  1021. fill_paths:
  1022.         push esi edi
  1023. ;        dps  '>'
  1024.         movzx ecx,byte[str_lens+ebx]
  1025.         add  esi,[positions+ebx*4]
  1026.         push esi
  1027.         add  esi,ecx
  1028.  
  1029.     .l1:
  1030.         dec  esi
  1031.         cmp  byte[esi],' '
  1032.         jnz   .found
  1033.         loop .l1
  1034.   pop  esi
  1035.   jmp  .noms
  1036.     .found:
  1037.         lea  ecx,[esi+1]
  1038.         pop  esi
  1039.         sub  ecx,esi
  1040.         rep  movsb
  1041.  .noms:
  1042.         and  byte[edi],0
  1043. ;        call debug_outstr
  1044. ;        dps  <'<',13,10>
  1045.         pop  edi esi
  1046.         ret
  1047.  
  1048. atoi:
  1049.         push esi
  1050.         xor  eax,eax
  1051.         xor  ebx,ebx
  1052.   .nxt:
  1053.     lodsb
  1054.     cmp  al,'0'
  1055.     jb   .done
  1056.     cmp  al,'9'
  1057.     ja   .done
  1058.     sub  eax,'0'
  1059.     imul ebx,10
  1060.     add  ebx,eax
  1061.     jmp  .nxt
  1062.   .done:
  1063.       pop  esi
  1064.       mov  eax,ebx
  1065.         ret
  1066.  
  1067. itoa:
  1068.         add  esi,2
  1069.     mov ebx,10
  1070.     mov ecx,3
  1071.   .l0:
  1072.     xor edx,edx
  1073.     div ebx
  1074.     add dl,'0'
  1075.     mov [esi],dl
  1076.     dec esi
  1077.     loop .l0
  1078.         ret
  1079.  
  1080. draw_picture:
  1081.     mov  [image],0x3000
  1082.     mov  edi,[ebp+8]
  1083.     lea  esi,[edi+12]
  1084.     call atoi
  1085.           cmp  eax,[icon_count]
  1086.           ja  toponly.ex
  1087.           imul eax,(32*3*32)
  1088.           lea  edi,[eax+strip_file+8]
  1089.     xor  ebx,ebx
  1090.     xor  ecx,ecx
  1091.     mov  esi,edi;strip_file+8+(32*3*32)*2
  1092.  
  1093.     mov  [pixpos],0
  1094.   newb:
  1095.     push ebx
  1096.     push ecx
  1097.  
  1098.     cmp  ebx,10
  1099.     jb     yesbpix
  1100.     cmp  ebx,42
  1101.     jge  yesbpix
  1102.     cmp  ecx,31;2
  1103.     jg     yesbpix
  1104.  
  1105.     push esi
  1106.     mov  esi,edi
  1107.     add  esi,[pixpos]
  1108.  
  1109. no_correction_pixpos:
  1110.     add  [pixpos],3
  1111.     mov  eax,[esi]
  1112.     and  eax,0xffffff
  1113.  
  1114.     pop  esi
  1115.  
  1116.     cmp eax,0
  1117.     je    yesbpix
  1118.     cmp eax,0xfffcff ;f5f5f5
  1119.     je    yesbpix
  1120.     jmp nobpix
  1121.  
  1122.   yesbpix:
  1123.  
  1124.   stretch:
  1125.     cmp   [bgrdrawtype],dword 2
  1126.     jne   nostretch
  1127.     mov   eax,[ebp+4]
  1128.     add   eax,ecx
  1129.     imul  eax,[bgry]
  1130.     cdq
  1131.     movzx ebx,word [scrxy]
  1132.     div   ebx
  1133.     imul  eax,[bgrx]
  1134.     push  eax
  1135.     mov   eax,[ebp+0]
  1136.     add   eax,[esp+8]
  1137.     imul  eax,[bgrx]
  1138.     cdq
  1139.     movzx ebx,word [scrxy+2]
  1140.     div   ebx
  1141.     add   eax,[esp]
  1142.     add   esp,4
  1143.  
  1144.     jmp   notiled
  1145.  
  1146.   nostretch:
  1147.  
  1148.     cmp   [bgrdrawtype],dword 1
  1149.     jne   notiled
  1150.     mov   eax,[ebp+4]
  1151.     add   eax,ecx
  1152.     cdq
  1153.     movzx ebx,word [bgrxy]
  1154.     div   ebx
  1155.     mov   eax,edx
  1156.     imul  eax,[bgrx]
  1157.     push  eax
  1158.     mov   eax,[ebp+0]
  1159.     add   eax,[esp+8]
  1160.     movzx ebx,word [bgrxy+2]
  1161.     cdq
  1162.     div   ebx
  1163.     mov   eax,edx
  1164.     add   eax,[esp]
  1165.     add   esp,4
  1166.  
  1167.   notiled:
  1168.  
  1169.     lea  ecx,[eax+eax*2]
  1170.     mov  eax,39
  1171.     mov  ebx,2
  1172.     mcall
  1173.  
  1174.   nobpix:
  1175.  
  1176.     pop  ecx
  1177.     pop  ebx
  1178.  
  1179.     mov  edx,eax
  1180.     mov  eax,[image]
  1181.     mov  [eax],edx
  1182.     mov  [eax],dl
  1183.     inc  eax
  1184.     ror  edx,8
  1185.     mov  [eax],dl
  1186.     inc  eax
  1187.     ror  edx,8
  1188.     mov  [eax],dl
  1189.     inc  eax
  1190.     mov  [image],eax
  1191.     inc  ebx
  1192.     mov  eax,[yw]
  1193.     inc  eax
  1194.     cmp  ebx,eax
  1195.     jnz  newb
  1196.     xor  ebx,ebx
  1197.  
  1198.     inc  ecx
  1199.  
  1200.     mov  eax,[ya]
  1201.     add  [pixpos],eax
  1202.  
  1203.     cmp  [top],1
  1204.     jne  notop
  1205.     cmp  ecx,38
  1206.     je     toponly
  1207.  
  1208.   notop:
  1209.  
  1210.     cmp  ecx,52
  1211.     jnz  newb
  1212.  
  1213.   toponly:
  1214.  
  1215.     mov  eax,7
  1216.     mov  ebx,0x3000
  1217.     mov  ecx,52 shl 16 + 52
  1218.     xor  edx,edx
  1219.     mcall
  1220.   .ex:
  1221.     mov  [load_pic],0
  1222.     ret
  1223.  
  1224. draw_text:
  1225.  
  1226.     mov  esi,[ebp+8]
  1227.     add  esi,3
  1228.     push edi
  1229.     mov  edi,title
  1230.     mov  ecx,8
  1231.     cld
  1232.     rep  movsb
  1233.     pop  edi
  1234.     mov   eax,title
  1235.   news2:
  1236.     cmp   [eax],byte 33
  1237.     jb      founde
  1238.     inc   eax
  1239.     cmp   eax,title+8;11
  1240.     jb      news2
  1241.    founde:
  1242.     sub   eax,title
  1243.     mov   [tl],eax
  1244.  
  1245.     mov   eax,[tl]
  1246.     lea   eax,[eax+eax*2]  ; eax *= char_width/2
  1247.     shl   eax,16
  1248.  
  1249.     mov   ebx,27*65536+40
  1250.     sub   ebx,eax
  1251.  
  1252.     mov   eax,4
  1253.     xor   ecx,ecx         ; black shade of text
  1254.     mov   edx,title
  1255.     mov   esi,[tl]
  1256.     add   ebx,1 shl 16      ;*65536+1
  1257.     mcall
  1258.     inc   ebx
  1259.     mcall
  1260.     add   ebx,1 shl 16
  1261.     mcall
  1262.     inc   ebx
  1263.     mcall
  1264.     sub   ebx,1 shl 16
  1265.     mcall
  1266.     dec   ebx
  1267.     sub   ebx,1 shl 16
  1268.     mcall
  1269.     sub   ebx,1 shl 16
  1270.     dec   ebx
  1271.     mcall
  1272.     dec   ebx
  1273.     add   ebx,1 shl 16
  1274.     mcall
  1275.     inc   ebx
  1276.     mov   ecx,0xffffff
  1277.  
  1278.     mcall
  1279.     mov   [draw_pic],0
  1280.     ret
  1281.  
  1282. ;   *********************************************
  1283. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  1284. ;   *********************************************
  1285.  
  1286.  
  1287. draw_window2:
  1288.  
  1289.     mov  eax,12            ; function 12:tell os about windowdraw
  1290.     mov  ebx,1               ; 1, start of draw
  1291.     mcall
  1292.  
  1293.                    ; DRAW WINDOW
  1294.     xor  eax,eax             ; function 0 : define and draw window
  1295.     mov  ebx,[ebp+0-2]
  1296.     mov  ecx,[ebp+4-2]
  1297.     add  ebx,[yw]           ; [x start] *65536 + [x size]
  1298.     add  ecx,51            ; [y start] *65536 + [y size]
  1299.     mov  edx,0x41000000        ; color of work area RRGGBB,8->color gl
  1300.     mcall
  1301.  
  1302.     mov  eax,8      ; button
  1303.     mov  ebx,51
  1304.     mov  ecx,50
  1305.     mov  edx,0x40000002
  1306.     mcall
  1307.  
  1308.     mov  eax,5
  1309.     mov  ebx,1
  1310. draw_icon2:
  1311.     xchg [load_pic],bl
  1312.     test bl,bl
  1313.     je     draw_icon_end
  1314.     mcall
  1315.     jmp  draw_icon2
  1316. draw_icon_end:
  1317.  
  1318.     mov  eax,5
  1319.     mov  ebx,1
  1320. draw_icon_2:
  1321.     xchg [draw_pic],bl
  1322.     test bl,bl
  1323.     je     draw_icon_end_2
  1324.     mcall
  1325.     jmp  draw_icon_2
  1326. draw_icon_end_2:
  1327.  
  1328.     mov  eax,9
  1329.     mov  ebx,process_table
  1330.     mov  ecx,-1
  1331.     mcall
  1332.  
  1333.     call draw_picture
  1334.     call draw_text
  1335.  
  1336.     mov  eax,12
  1337.     mov  ebx,2
  1338.     mcall
  1339.  
  1340.     ret
  1341.  
  1342. tl        dd      8
  1343. yw        dd     51
  1344. ya        dd      0
  1345. cur_btn   dd 40
  1346.  
  1347. draw_pic    db      0
  1348. load_pic    db      0
  1349. create_thread_event db 0
  1350.  
  1351.  
  1352. image          dd  0x3000
  1353.  
  1354. I_Param:
  1355.  
  1356.  icon_data = I_END+0x1400
  1357.  process_table = I_END+0x2400
  1358.  
  1359. bgrx dd ?
  1360. bgry dd ?
  1361. param_str rb 31
  1362.  
  1363. ;//////////////////////////
  1364.  
  1365. bgrxy        dd    ?
  1366. warea:
  1367.  .by_x:
  1368.   .right  dw ?
  1369.   .left   dw ?
  1370.  .by_y:
  1371.   .bottom dw ?
  1372.   .top    dw ?
  1373. scrxy        dd    ?
  1374. bgrdrawtype  dd    ?
  1375.  
  1376. pixpos dd    ?
  1377. top      dd ?
  1378. icons dd ?
  1379. addr  dd ?
  1380. cur_str    dd ?
  1381. cur_band   dd ?
  1382. sel_icon1  rd 1
  1383. icon_count rd 1
  1384. gif_file  rb  GIF_SIZE
  1385. strip_file rb RAW_SIZE
  1386.  
  1387. IncludeUGlobals
  1388.  
  1389. I_END:
  1390.