Subversion Repositories Kolibri OS

Rev

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