Subversion Repositories Kolibri OS

Rev

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