Subversion Repositories Kolibri OS

Rev

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