Subversion Repositories Kolibri OS

Rev

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