Subversion Repositories Kolibri OS

Rev

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