Subversion Repositories Kolibri OS

Rev

Rev 132 | Rev 184 | 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. ;******************************************************************************
  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'
  30. include  'lang.inc'
  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. add_text db '€†Œˆ’… € Ž‡ˆ–ˆž …ˆ‘Ž‹œ‡“…ŒŽ‰ ˆŠŽŠˆ'
  794. add_text_len:
  795.  
  796. rem_text db '€†Œˆ’… € Ž‡ˆ–ˆž ˆ‘Ž‹œ‡“…ŒŽ‰ ˆŠŽŠˆ'
  797. rem_text_len:
  798.   labelt:
  799.        db ' áâனª  à ¡®ç¥£® á⮫ '
  800.   labellen:
  801. else if lang eq en
  802.   text:
  803.       db 255,255,255,0,   '   TITLE                                       '
  804.       db 255,255,255,0,   '  APP NAME                                     '
  805.       db 255,255,255,0,   ' PARAMETERS                                    '
  806.       db 255,255,255,0,   '                APPLY CHANGES                  '
  807.       db 255,255,255,0,   '      ADD ICON              REMOVE ICON        '
  808.       db 0,0,0,0,         'CLICK BUTTON ON ICON POSITION FOR EDIT         '
  809.       db                  'x' ; <- END MARKER, DONT DELETE
  810. add_text db 'CLICK ON A NOT USED POSITION'
  811. add_text_len:
  812.  
  813. rem_text db 'CLICK ICON POSITION; YOU WANT TO DELETE'
  814. rem_text_len:
  815.   labelt:
  816.        db 'Icon Manager'
  817.   labellen:
  818. else
  819.   text:
  820.       db 255,255,255,0,   '   TITLE                                       '
  821.       db 255,255,255,0,   '  APP NAME                                     '
  822.       db 255,255,255,0,   ' PARAMETER                                     '
  823.       db 255,255,255,0,   '                ANWENDEN                       '
  824.       db 255,255,255,0,   '     HINZUFUEGEN              ENTFERNEN        '
  825.       db 0,0,0,0,         'AUF BUTTON KLICKEN, UM ICON ZU EDITIEREN       '
  826.       db                  'x' ; <- END MARKER, DONT DELETE
  827. add_text db 'AUF UNBENUTZTE ICONPOSITION KLICKEN'
  828. add_text_len:
  829.  
  830. rem_text db 'ICON ANKLICKEN; DAS GELOESCHT WERDEN SOLL'
  831. rem_text_len:
  832.   labelt:
  833.        db 'Icon Manager'
  834.   labellen:
  835.  
  836. end if
  837.  
  838. ;ya    dd 0
  839.  
  840. arrows db '</>'
  841. iconname:
  842.       db ICON_APP,0
  843.  
  844. icon_default:
  845.    db   'AA-SYSXTREE-000-/RD/1/SYSXTREE                '
  846.    db   '-                              *'
  847.    db   13,10
  848.  
  849. rep_text:
  850. if lang eq ru
  851.      db '‡€—Šˆ    -     ˆ‡    , ‚›€ #'
  852. else
  853.      db 'ICONS     -     OF    , SELECTED'
  854. end if
  855.  
  856. rep_text_len:
  857.  
  858. ;//////////////////////////
  859. get_bg_info:
  860.     mov  eax,39
  861.     mov  ebx,4
  862.     int  0x40
  863.     mov  [bgrdrawtype],eax
  864.  
  865.     mov  eax,39     ; get background size
  866.     mov  ebx,1
  867.     int  0x40
  868.     mov  [bgrxy],eax
  869.  
  870.     mov  ebx,eax
  871.     shr  eax,16
  872.     and  ebx,0xffff
  873.     mov  [bgrx],eax
  874.     mov  [bgry],ebx
  875.     ret
  876.  
  877. calc_icon_pos:
  878.     movzx eax,byte [ebp-20]    ; x position
  879.     sub  eax,'A'        ;eax - number of letter
  880.     cmp  eax,4
  881.     jg     no_left
  882.     shl  eax,6 ;imul eax,64
  883.     add  eax,16
  884.     movzx ebx,[warea.left]
  885.     add  eax,ebx
  886.     jmp  x_done
  887.   no_left:
  888.     sub  eax,9
  889.     sal  eax,6 ;imul eax,64
  890.     sub  eax,16+52-1
  891.     movzx ebx,[warea.right]
  892.     add  eax,ebx
  893.   x_done:
  894. ;    mov  [xpos],eax
  895.     mov  [ebp-12],eax
  896.  
  897.     movzx eax,byte [ebp-20+1]  ; y position
  898.     sub  eax,'A'        ; eax - number of letter
  899.     cmp  eax,4
  900.     jg     no_up
  901.     shl  eax,6            ;imul eax,80
  902.     add  eax,16
  903.     movzx ebx,[warea.top]
  904.     add  eax,ebx
  905.     jmp  y_done
  906.   no_up:
  907.     sub  eax,9
  908.     shl  eax,6            ;imul eax,80
  909.     sub  eax,16-1
  910.     movzx ebx,[warea.bottom]
  911.     add  eax,ebx
  912.   y_done:
  913. ;    mov  [ypos],eax
  914.     mov  [ebp-8],eax
  915.     ret
  916.  
  917. ;START2:
  918. load_icon_list2:
  919.         mov  eax,finfo
  920.         mov  dword[eax],16
  921.         mov  dword[eax+8],param_str
  922.     call  get_bg_info
  923.  
  924.         mcall   48,5
  925.         mov     [warea.by_x],eax
  926.         mov     [warea.by_y],ebx
  927.  
  928.         mov     eax,14
  929.         int     0x40
  930.         add     eax,0x00010001
  931.         mov     [scrxy],eax
  932.  
  933. apply_changes2:
  934.  
  935.     mov  edi,[icons]
  936.     mov  esi,icon_data
  937.     mov  ebp,0x5000 ; threads stack starting point
  938.  
  939.   start_new:
  940.     mov eax,[esi]
  941.     mov [ebp-20],eax
  942.     call calc_icon_pos
  943.  
  944.     mov  eax,51
  945.     mov  ebx,1
  946.     mov  ecx,thread
  947. ;    mov  edx,[thread_stack]
  948.     mov  edx,ebp
  949. ;    sub  edx,4
  950. ;    mov  [edx],esi
  951.     mov  dword[ebp-4],esi
  952.     int  0x40
  953. ;    add  [thread_stack],0x100
  954.     add  ebp,0x100
  955.  
  956.     mov  eax,5
  957.     mov  ebx,1
  958. wait_thread_start:         ;wait until thread draw itself first time
  959.     cmp  [create_thread_event],bl
  960.     jz     wait_thread_end
  961.     int  0x40
  962.     jmp  wait_thread_start
  963. wait_thread_end:
  964.     dec  [create_thread_event]     ;reset event
  965.  
  966.  
  967.     add  esi,REC_SIZE
  968.     dec  edi
  969.     jnz  start_new
  970.   close:
  971.     or     eax,-1
  972.     int  0x40
  973.  
  974. thread:
  975. ;   pop  ebp ;ebp - address of our icon
  976.     sub  esp,12
  977.     mov  ebp,esp
  978.     sub  esp,16
  979.     call draw_window2
  980.     mov  [create_thread_event],1
  981.     mov  eax,40
  982.     mov  ebx,010101b
  983.     int  0x40
  984.  
  985. still2:
  986.  
  987.     mov  eax,10
  988.     int  0x40
  989.  
  990.     cmp  eax,1
  991.     je     red2
  992.     cmp  eax,3
  993.     je     button2
  994.     cmp  eax,5
  995.     jne  still2
  996.  
  997.     call  get_bg_info
  998.     mov   eax,5
  999.     mov   ebx,1
  1000.     call  draw_icon2
  1001.  
  1002.     jmp  still2
  1003.  
  1004.   red2:
  1005.         mcall   14
  1006.         add     eax,0x00010001
  1007.         mov     [scrxy],eax
  1008.         mcall   48,5
  1009.         mov     [warea.by_x],eax
  1010.         mov     [warea.by_y],ebx
  1011.         add     ebp,+12
  1012.         call    calc_icon_pos
  1013.         add     ebp,-12
  1014.         mcall   9,I_END,-1
  1015.         mov     eax,[I_END+process_information.x_start]
  1016.         cmp     eax,[ebp+0]
  1017.         jne     @f
  1018.         mov     eax,[I_END+process_information.y_start]
  1019.         cmp     eax,[ebp+4]
  1020.         je      .lp1
  1021.     @@: call    get_bg_info
  1022.         mcall   67,[ebp+0],[ebp+4],51,51
  1023.  
  1024.   .lp1: call    draw_window2
  1025.         jmp     still2
  1026.  
  1027.   key2:
  1028.     mov  eax,2
  1029.     int  0x40
  1030.  
  1031.     jmp  still2
  1032.  
  1033.   button2:
  1034.     mov  eax,17
  1035.     int  0x40
  1036.  
  1037. ;    mcall 55,eax, , ,klick_music
  1038.  
  1039.     mov  esi,[ebp+8]
  1040.           mov  ebx,1
  1041.           mov  edi,finfo.path
  1042.           call fill_paths
  1043.           inc  ebx
  1044.        mov  edi,param_str
  1045.     mov  dword[finfo+8],param_str
  1046.           call fill_paths
  1047.           cmp  byte[edi],0
  1048.     jne  .no0
  1049.     and  dword[finfo+8],0
  1050.   .no0:
  1051. ;    lea  ebx,[ebp+19]
  1052.     mov  ebx,finfo
  1053.     mov  eax,58
  1054.     int  0x40
  1055. ;    dph  eax
  1056.     cmp  eax,1024
  1057.     jae  still2
  1058.     mcall 55,eax, , ,klick_music
  1059.     jmp  still2
  1060.  
  1061. klick_music db 0x85,0x60,0x85,0x70,0x85,0x65,0
  1062.  
  1063. fill_paths:
  1064.         push esi edi
  1065. ;        dps  '>'
  1066.         movzx ecx,byte[str_lens+ebx]
  1067.         add  esi,[positions+ebx*4]
  1068.         push esi
  1069. ;  mov  edx,esi
  1070.         add  esi,ecx
  1071.  
  1072.     .l1:
  1073.         dec  esi
  1074.         cmp  byte[esi],' '
  1075.         jnz   .found
  1076.         loop .l1
  1077.   pop  esi
  1078.   jmp  .noms
  1079.     .found:
  1080.         lea  ecx,[esi+1]
  1081.         pop  esi
  1082.         sub  ecx,esi
  1083.         rep  movsb
  1084.  .noms:
  1085.         and  byte[edi],0
  1086. ;        call debug_outstr
  1087. ;        dps  <'<',13,10>
  1088.         pop  edi esi
  1089.         ret
  1090.  
  1091. atoi:
  1092.         push esi
  1093.         xor  eax,eax
  1094.         xor  ebx,ebx
  1095.   .nxt:
  1096.     lodsb
  1097.     cmp  al,'0'
  1098.     jb   .done
  1099.     cmp  al,'9'
  1100.     ja   .done
  1101.     sub  eax,'0'
  1102.     imul ebx,10
  1103.     add  ebx,eax
  1104.     jmp  .nxt
  1105.   .done:
  1106.       pop  esi
  1107.       mov  eax,ebx
  1108.         ret
  1109.  
  1110. itoa:
  1111. ;        mov  esi,[current_icon]
  1112.         add  esi,2
  1113.     mov ebx,10
  1114.     mov ecx,3
  1115.   .l0:
  1116.     xor edx,edx
  1117.     div ebx
  1118.     add dl,'0'
  1119.     mov [esi],dl
  1120.     dec esi
  1121.     loop .l0
  1122. ;    and byte[esi],0
  1123.         ret
  1124.  
  1125. draw_picture:
  1126.     mov  [image],0x3000
  1127.     mov  edi,[ebp+8]
  1128.     lea  esi,[edi+12]
  1129.     call atoi
  1130.           cmp  eax,[icon_count]
  1131.           ja  toponly.ex
  1132.           imul eax,(32*3*32)
  1133.           lea  edi,[eax+strip_file+12]
  1134.     xor  ebx,ebx
  1135.     xor  ecx,ecx
  1136.     mov  esi,edi;strip_file+12+(32*3*32)*2
  1137.  
  1138.     mov  [pixpos],0
  1139.   newb:
  1140.     push ebx
  1141.     push ecx
  1142.  
  1143.     cmp  ebx,10
  1144.     jb     yesbpix
  1145.     cmp  ebx,42
  1146.     jge  yesbpix
  1147.     cmp  ecx,31;2
  1148.     jg     yesbpix
  1149.  
  1150.     push esi
  1151.     mov  esi,edi
  1152.     add  esi,[pixpos]
  1153.  
  1154. no_correction_pixpos:
  1155.     add  [pixpos],3
  1156.     mov  eax,[esi]
  1157.     and  eax,0xffffff
  1158.  
  1159.     pop  esi
  1160.  
  1161.     cmp eax,0
  1162.     je    yesbpix
  1163.     cmp eax,0xfffcff ;f5f5f5
  1164.     je    yesbpix
  1165.     jmp nobpix
  1166.  
  1167.   yesbpix:
  1168.  
  1169.   stretch:
  1170.     cmp   [bgrdrawtype],dword 2
  1171.     jne   nostretch
  1172. ;    mov   eax,[ypos]
  1173.     mov   eax,[ebp+4]
  1174.     add   eax,ecx
  1175.     imul  eax,[bgry]
  1176.     cdq
  1177.     movzx ebx,word [scrxy]
  1178.     div   ebx
  1179.     imul  eax,[bgrx]
  1180.     push  eax
  1181. ;    mov   eax,[xpos]
  1182.     mov   eax,[ebp+0]
  1183.     add   eax,[esp+8]
  1184.     imul  eax,[bgrx]
  1185.     cdq
  1186.     movzx ebx,word [scrxy+2]
  1187.     div   ebx
  1188.     add   eax,[esp]
  1189.     add   esp,4
  1190.  
  1191.     jmp   notiled
  1192.  
  1193.   nostretch:
  1194.  
  1195.     cmp   [bgrdrawtype],dword 1
  1196.     jne   notiled
  1197. ;    mov   eax,[ypos]
  1198.     mov   eax,[ebp+4]
  1199.     add   eax,ecx
  1200.     cdq
  1201.     movzx ebx,word [bgrxy]
  1202.     div   ebx
  1203.     mov   eax,edx
  1204.     imul  eax,[bgrx]
  1205.     push  eax
  1206. ;    mov   eax,[xpos]
  1207.     mov   eax,[ebp+0]
  1208.     add   eax,[esp+8]
  1209.     movzx ebx,word [bgrxy+2]
  1210.     cdq
  1211.     div   ebx
  1212.     mov   eax,edx
  1213.     add   eax,[esp]
  1214.     add   esp,4
  1215.  
  1216.   notiled:
  1217.  
  1218.     lea  ecx,[eax+eax*2]
  1219.     mov  eax,39
  1220.     mov  ebx,2
  1221.     int  0x40
  1222.  
  1223.   nobpix:
  1224.  
  1225.     pop  ecx
  1226.     pop  ebx
  1227.  
  1228.     mov  edx,eax
  1229.     mov  eax,[image]
  1230.     mov  [eax],edx
  1231.     mov  [eax],dl
  1232.     inc  eax
  1233.     ror  edx,8
  1234.     mov  [eax],dl
  1235.     inc  eax
  1236.     ror  edx,8
  1237.     mov  [eax],dl
  1238.     inc  eax
  1239.     mov  [image],eax
  1240.     inc  ebx
  1241.     mov  eax,[yw]
  1242.     inc  eax
  1243.     cmp  ebx,eax
  1244.     jnz  newb
  1245.     xor  ebx,ebx
  1246.  
  1247.     inc  ecx
  1248.  
  1249.     mov  eax,[ya]
  1250.     add  [pixpos],eax
  1251.  
  1252.     cmp  [top],1
  1253.     jne  notop
  1254.     cmp  ecx,38
  1255.     je     toponly
  1256.  
  1257.   notop:
  1258.  
  1259.     cmp  ecx,52
  1260.     jnz  newb
  1261.  
  1262.   toponly:
  1263.  
  1264.     mov  eax,7
  1265.     mov  ebx,0x3000
  1266.     mov  ecx,52 shl 16 + 52
  1267.     xor  edx,edx
  1268.     int  0x40
  1269.   .ex:
  1270.     mov  [load_pic],0
  1271.     ret
  1272.  
  1273. draw_text:
  1274.  
  1275.     mov  esi,[ebp+8]
  1276.     add  esi,3
  1277.     push edi
  1278.     mov  edi,labelt
  1279.     mov  ecx,8
  1280.     cld
  1281.     rep  movsb
  1282.     pop  edi
  1283.     mov   eax,labelt
  1284.   news2:
  1285.     cmp   [eax],byte 33
  1286.     jb      founde
  1287.     inc   eax
  1288.     cmp   eax,labelt+8;11
  1289.     jb      news2
  1290.    founde:
  1291.     sub   eax,labelt
  1292.     mov   [tl],eax
  1293.  
  1294.     mov   eax,[tl]
  1295.     lea   eax,[eax+eax*2]  ; eax *= char_width/2
  1296.     shl   eax,16
  1297.  
  1298.     mov   ebx,27*65536+42
  1299.     sub   ebx,eax
  1300.  
  1301.     mov   eax,4
  1302.     xor   ecx,ecx         ; black shade of text
  1303.     mov   edx,labelt
  1304.     mov   esi,[tl]
  1305.     add   ebx,1 shl 16      ;*65536+1
  1306.     int   0x40
  1307.     inc   ebx
  1308.     int   0x40
  1309.     add   ebx,1 shl 16
  1310.     int   0x40
  1311.     inc   ebx
  1312.     int   0x40
  1313.     sub   ebx,1 shl 16
  1314.     int   0x40
  1315.     dec   ebx
  1316.     sub   ebx,1 shl 16
  1317.     int   0x40
  1318.     sub   ebx,1 shl 16
  1319.     dec   ebx
  1320.     int   0x40
  1321.     dec   ebx
  1322.     add   ebx,1 shl 16
  1323.     int   0x40
  1324.     inc   ebx
  1325.     mov   ecx,0xffffff
  1326.  
  1327.     int   0x40
  1328.     mov   [draw_pic],0
  1329.     ret
  1330.  
  1331. ;   *********************************************
  1332. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  1333. ;   *********************************************
  1334.  
  1335.  
  1336. draw_window2:
  1337.  
  1338.     mov  eax,12            ; function 12:tell os about windowdraw
  1339.     mov  ebx,1               ; 1, start of draw
  1340.     int  0x40
  1341.  
  1342.                    ; DRAW WINDOW
  1343.     xor  eax,eax             ; function 0 : define and draw window
  1344. ;    mov  ebx,[xpos-2]
  1345.     mov  ebx,[ebp+0-2]
  1346. ;    mov  ecx,[ypos-2]
  1347.     mov  ecx,[ebp+4-2]
  1348.     add  ebx,[yw]           ; [x start] *65536 + [x size]
  1349.     add  ecx,51            ; [y start] *65536 + [y size]
  1350.     mov  edx,0x01000000        ; color of work area RRGGBB,8->color gl
  1351.     int  0x40
  1352.  
  1353.     mov  eax,8      ; button
  1354.     mov  ebx,51
  1355.     mov  ecx,50
  1356.     mov  edx,1+20000000 ; or 0x40000000
  1357.     int  0x40
  1358.  
  1359.     mov  eax,5
  1360.     mov  ebx,1
  1361. draw_icon2:
  1362.     xchg [load_pic],bl
  1363.     test bl,bl
  1364.     je     draw_icon_end
  1365.     int  0x40
  1366.     jmp  draw_icon2
  1367. draw_icon_end:
  1368.  
  1369.     mov  eax,5
  1370.     mov  ebx,1
  1371. draw_icon_2:
  1372.     xchg [draw_pic],bl
  1373.     test bl,bl
  1374.     je     draw_icon_end_2
  1375.     int  0x40
  1376.     jmp  draw_icon_2
  1377. draw_icon_end_2:
  1378.  
  1379.     mov  eax,9
  1380.     mov  ebx,process_table
  1381.     mov  ecx,-1
  1382.     int  0x40
  1383.  
  1384.     call draw_picture
  1385.     call draw_text
  1386.  
  1387.     mov  eax,12
  1388.     mov  ebx,2
  1389.     int  0x40
  1390.  
  1391.     ret
  1392.  
  1393. tl        dd      8
  1394. yw        dd     51
  1395. ya        dd      0
  1396. cur_btn   dd 40
  1397.  
  1398. ;xpos       dd   15
  1399. ;ypos       dd  185
  1400. draw_pic    db      0
  1401. load_pic    db      0
  1402. create_thread_event db 0
  1403.  
  1404.  
  1405. image          dd  0x3000
  1406. ;thread_stack  dd  0x5000
  1407.  
  1408. ;icons dd 0
  1409.  
  1410.  
  1411. I_Param:
  1412.  
  1413.  icon_data = I_END+0x1400
  1414.  process_table = I_END+0x2400
  1415.  
  1416. ;I_END:
  1417.  
  1418. bgrx dd ?
  1419. bgry dd ?
  1420. param_str rb 31
  1421.  
  1422. ;//////////////////////////
  1423.  
  1424. bgrxy        dd    ?
  1425. warea:
  1426.  .by_x:
  1427.   .right  dw ?
  1428.   .left   dw ?
  1429.  .by_y:
  1430.   .bottom dw ?
  1431.   .top    dw ?
  1432. scrxy        dd    ?
  1433. bgrdrawtype  dd    ?
  1434.  
  1435. pixpos dd    ?
  1436. top      dd ?
  1437. icons dd ?
  1438. addr  dd ?
  1439. cur_str    dd ?
  1440. cur_band   dd ?
  1441. sel_icon1  rd 1
  1442. icon_count rd 1
  1443. gif_file  rb  GIF_SIZE
  1444. strip_file rb RAW_SIZE
  1445. ;I_Param:
  1446.  
  1447. ; icon_data = I_END+256
  1448.  
  1449. I_END:
  1450.