Subversion Repositories Kolibri OS

Rev

Rev 2697 | Rev 9570 | 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. ; version:      3.11
  9. ; last update:  28/05/2012
  10. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  11. ; changes:      Fixed crash when trying to select some of the icons.
  12. ;               (bug 000013)
  13. ;---------------------------------------------------------------------
  14. ; version:      3.10
  15. ; last update:  03/04/2012
  16. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  17. ; changes:      Drawing selection rectangle.
  18. ;               Using new kernel function: 15.9
  19. ;---------------------------------------------------------------------
  20. ; version:      3.01
  21. ; last update:  02/04/2012
  22. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  23. ; changes:      Fix for previous revision - not drawed icons after
  24. ;               startup in certain cases.
  25. ;---------------------------------------------------------------------
  26. ; version:      3.00
  27. ; last update:  02/04/2012
  28. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  29. ; changes:      Program use only 2 threads: draw and mouse
  30. ;               Using new kernel functions: 25, 34, 15.8, 4 (redirect).
  31. ;               Using PNG icons with transparent.
  32. ;---------------------------------------------------------------------
  33. ; version:      2.11
  34. ; last update:  19/03/2012
  35. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  36. ; changes:      The program uses only 140 Kb memory is now.
  37. ;               Some speedup.
  38. ;---------------------------------------------------------------------
  39. ; version:      2.1
  40. ; last update:  17/03/2012
  41. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  42. ; changes:      Global optimization! The program uses
  43. ;               only 161 KB of memory instead of 603 kb is now.
  44. ;---------------------------------------------------------------------
  45. ; version:      2.02
  46. ; last update:  15/03/2012
  47. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  48. ; changes:      some optimisations and code refactoring
  49. ;---------------------------------------------------------------------
  50. ; version:      2.01
  51. ; last update:  27/09/2011
  52. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  53. ; changes:      deactivate the window after click
  54. ;              (working to kernel r.2244 and above)
  55. ;---------------------------------------------------------------------
  56. ; Many fix's and changes created by:
  57. ;               Halyavin, Diamond, Heavyiron,
  58. ;               SPraid, Dunkaist
  59. ;---------------------------------------------------------------------
  60. ; version:      2.00
  61. ; last update:  22/02/2005
  62. ; changed by:   Willow and Mario79
  63. ; changes:      modified for work with new multi-thread ICON.
  64. ;******************************************************************************
  65. ICON_SIZE equ 32*32*4
  66. REC_SIZE equ 80
  67. ICONS_DAT equ '/sys/icons.dat'
  68. ICON_APP equ '/sys/ICON'
  69. ICON_STRIP equ '/rd/1/iconstrp.png'
  70. ;------------------------------------------------------------------------------
  71.         use32
  72.         org 0x0
  73.         db 'MENUET01'   ; 8 byte id
  74.         dd 0x01         ; header version
  75.         dd START        ; start of code
  76.         dd IM_END       ; size of image
  77.         dd I_END        ; memory for app
  78.         dd stack_area   ; esp
  79.         dd I_Param      ; boot parameters
  80.         dd path         ; path
  81. ;------------------------------------------------------------------------------
  82. include 'lang.inc'
  83. include '../../../macros.inc'
  84. include '../../../develop/libraries/box_lib/load_lib.mac'
  85. ;include '../../../debug.inc'
  86. ;------------------------------------------------------------------------------
  87.         @use_library    ;use load lib macros
  88. ;------------------------------------------------------------------------------
  89. START:          ; start of execution
  90.         mcall   68,11
  91. ;--------------------------------------------------------------------- 
  92. load_libraries l_libs_start,end_l_libs
  93.         test    eax,eax
  94.         jnz     close
  95.        
  96. ; unpack deflate
  97.         mov     eax,[unpack_DeflateUnpack2]
  98.         mov     [deflate_unpack],eax
  99. ;---------------------------------------------------------------------
  100. ; get size of file ICONSTRP.PNG
  101.         mcall   70,finfo
  102.         test    eax,eax
  103.         jnz     close
  104. ; get memory for ICONSTRP.PNG
  105.         mov     ecx,[procinfo+32]
  106.         mov     [finfo.size],ecx
  107.         mov     [img_size],ecx
  108.         mcall   68,12
  109.         mov     [finfo.point],eax
  110.         mov     [image_file],eax
  111. ; load ICONSTRP.PNG
  112.         mov     [finfo],dword 0
  113.         mcall   70,finfo
  114.         test    eax,eax
  115.         jnz     close
  116. ; convert PNG to RAW
  117.         xor     eax,eax
  118.         mov     [return_code],eax
  119.  
  120.         push    image_file
  121.         call    [cnv_png_import.Start]
  122.  
  123.         mov     eax,[raw_pointer]
  124.         mov     ebx,[eax+32]
  125.         mov     [strip_file_size],ebx
  126.         mov     eax,[eax+28]
  127.         add     eax,[raw_pointer]
  128.         mov     [strip_file],eax
  129. ; back memeory to system
  130.         mcall   68,13,[finfo.point]
  131.        
  132.         mov     eax,[raw_pointer]
  133.         mov     eax,[eax+8]
  134.         shr     eax,5
  135.         mov     [icon_count],eax
  136.  
  137.         and     eax,0x7
  138.         mov     [cur_band_compensation],eax
  139. ; load ICON.DAT
  140.         call    load_ic
  141. boot_str:
  142.         cmp     [I_Param],dword 'BOOT'
  143.         je      START2
  144. ;------------------------------------------------------------------------------
  145. ; ICON EDITOR MODE - START1 entering label
  146. ;------------------------------------------------------------------------------
  147. START1:
  148.         call    load_icon_list
  149. ;------------------------------------------------------------------------------
  150. align 4
  151. red:
  152.         call    draw_window     ; at first, draw the window
  153.         mov     esi,[current_icon]
  154.         jmp     band
  155. ;------------------------------------------------------------------------------
  156. align 4
  157. still:
  158.         mcall   10      ; wait here for event
  159.         dec     eax     ; redraw request ?
  160.         jz      red
  161.        
  162.         dec     eax     ; key in buffer ?
  163.         jz      key
  164. ;------------------------------------------------------------------------------
  165. align 4
  166. button:
  167.         mcall   17      ; get id
  168.         shr     eax,8
  169.  
  170.         cmp     eax,1   ; button id=1 ?
  171.         je      close
  172.        
  173.         mov     esi,[current_icon]
  174.         add     esi,12
  175.         mov     ebx,[cur_band]
  176.        
  177.         cmp     eax,11
  178.         jb      @f
  179.         cmp     eax,13
  180.         ja      @f
  181.         call    read_string
  182.         jmp     still
  183. ;--------------------------------------
  184. align 4
  185. @@:
  186.         cmp     eax,21  ; apply changes
  187.         je      apply
  188.        
  189.         cmp     eax,22          ; user pressed the 'add icon' button
  190.         je      add_icon
  191.        
  192.         cmp     eax,23  ; user pressed the remove icon button
  193.         je      remove_icon
  194.  
  195.        
  196.         cmp     eax,30  ; left arrow to icons bar
  197.         je      arrow.left
  198.        
  199.         cmp     eax,31  ; right arrow to icons bar
  200.         je      arrow.right
  201.        
  202.         cmp     eax,32
  203.         je      ico
  204.  
  205.         cmp     eax,40  ; user pressed button for icon position
  206.         jae     press_button_for_icon_position
  207.        
  208.         jmp     still
  209. ;------------------------------------------------------------------------------
  210. align 4
  211. arrow:
  212. .right:
  213.  
  214.         mov     eax,[icon_count]
  215.         sub     eax,8
  216.         cmp     ebx,eax
  217.         jae     still   ;.drwic2
  218.  
  219.         add     ebx,1
  220.         jmp     .drwic2
  221. ;--------------------------------------
  222. align 4
  223. .left:
  224.         test    ebx,ebx
  225.         jz      still
  226.  
  227.         sub     ebx,1
  228. ;--------------------------------------
  229. align 4
  230. .drwic2:
  231.         mov     [cur_band],ebx
  232. ;--------------------------------------
  233. align 4
  234. .drwic1:
  235.         call    draw_icon
  236.         jmp     still
  237. ;------------------------------------------------------------------------------
  238. align 4
  239. ico:
  240.         push    ebx
  241.         mcall   37,1
  242.         pop     ebx
  243.         shr     eax,16
  244.         sub     eax,33-19
  245.         mov     edi,34
  246.         xor     edx,edx
  247.         div     edi
  248.         lea     ecx,[ebx+eax]
  249.         cmp     ecx,[icon_count]
  250.         jae     still
  251.  
  252.         mov     ecx,eax
  253.         add     eax,ebx
  254.         call    itoa
  255.         jmp     arrow.drwic1
  256. ;------------------------------------------------------------------------------
  257. align 4
  258. apply:
  259.         ; (1) save list
  260.         mov     ebx,finfo
  261.         mov     dword[ebx],2
  262.         mov     edx,REC_SIZE
  263.         imul    edx,dword [icons]
  264.         mov     [ebx+12],edx
  265.         mov     esi,iconlst
  266.         call    lst_path
  267.         mcall   70
  268.         ; (2) terminate all icons
  269.         or      ecx,-1
  270.         mcall   9,procinfo
  271.         mov     edi,[ebx+30]
  272. ;--------------------------------------
  273. align 4
  274. newread2:
  275.         mov     esi,1
  276. ;--------------------------------------
  277. align 4
  278. newread:
  279.         inc     esi
  280.         mov     ecx,esi
  281.         mcall   9,procinfo
  282.  
  283.         cmp     edi,[ebx+30]
  284.         je      newread
  285.  
  286.         cmp     esi,eax
  287.         jg      .apply_changes
  288.  
  289.         mov     eax,[ebx+10]
  290.         and     eax,not 20202020h
  291.         cmp     eax,'@ICO'
  292.         jz      @f
  293.         cmp     eax,'ICON'
  294.         jne     newread
  295. ;--------------------------------------
  296. align 4
  297. @@:
  298.         xor     eax,eax
  299.         cmp     eax,[ebx+42]
  300.         jne     newread
  301.  
  302.         cmp     eax,[ebx+46]
  303.         jne     newread
  304.  
  305.         mov     ecx,esi
  306.         mcall   18,2
  307.  
  308.         jmp     newread2
  309. ;--------------------------------------
  310. align 4
  311. .apply_changes:
  312.         mov     ebx, finfo_start
  313.         mov     dword [ebx+8], boot_str+6
  314.         mov     esi, iconname
  315.         call    lst_path
  316.         mcall   70
  317.         mcall   68,1
  318.         mcall   15,3
  319.         jmp     still
  320. ;------------------------------------------------------------------------------
  321. align 4
  322. add_icon:
  323.         mov     ebx,24*65536+250+8*14
  324.         mcall   4,,0xc0ff0000,add_text,,0xffffff
  325.  
  326.         mcall   10
  327.         cmp     eax,3
  328.         jne     still
  329.  
  330.         mcall   17
  331.         shr     eax,8
  332.         cmp     eax,40
  333.         jb      no_f
  334.         mov     edi,eax
  335.         sub     eax,40
  336.        
  337.         xor     edx,edx         ; bcd -> 10
  338.         mov     ebx,16
  339.         div     ebx
  340. ; multiply x10
  341.         shl     eax,1           ; multiply x2
  342.         lea     eax,[eax+eax*4] ; multiply x5
  343.         add     eax,edx
  344.        
  345.         mov     ebx,eax
  346.         add     ebx,icons_reserved
  347.         cmp     [ebx],byte 'x'
  348.         je      no_f
  349.         mov     [ebx],byte 'x'
  350.        
  351.         mov     [cur_btn],edi
  352.         xor     edx,edx
  353.         mov     ebx,10
  354.         div     ebx
  355.         add     eax,65
  356.         add     edx,65
  357.         mov     [icon_default+0],dl
  358.         mov     [icon_default+1],al
  359.        
  360.         inc     dword [icons]
  361.         mov     edi,[icons]
  362.         dec     edi
  363.         imul    edi,REC_SIZE
  364.         add     edi,icon_data
  365.        
  366.         mov     [current_icon],edi
  367.  
  368.         mov     esi,icon_default
  369.         mov     ecx,REC_SIZE
  370.         cld
  371.         rep     movsb
  372.         mov     esi,[current_icon]
  373.         jmp     band
  374. ;--------------------------------------
  375. align 4
  376. no_f:
  377.         call    draw_btns       ;draw_window
  378.         jmp     still
  379. ;------------------------------------------------------------------------------
  380. align 4
  381. remove_icon:
  382.         mov     ebx,24*65536+250+8*14
  383.         mcall   4,,0xc0ff0000,rem_text,,0xffffff
  384.        
  385.         mcall   10
  386.         cmp     eax,3
  387.         jne     no_f
  388.  
  389.         mcall   17
  390.         shr     eax,8
  391.         cmp     eax,40
  392.         jb      red
  393.         sub     eax,40
  394.        
  395.         xor     edx,edx
  396.         mov     ebx,16
  397.         div     ebx
  398. ; multiply x10
  399.         shl     eax,1           ; multiply x2
  400.         lea     eax,[eax+eax*4] ; multiply x5
  401.         add     eax,edx
  402.        
  403.         mov     ebx,eax
  404.         add     ebx,icons_reserved
  405.         cmp     [ebx],byte 'x'
  406.         jne     red
  407.         mov     [ebx],byte ' '
  408.        
  409.         xor     edx,edx
  410.         mov     ebx,10
  411.         div     ebx
  412.         shl     eax,8
  413.         mov     al,dl
  414.        
  415.         add     eax,65*256+65
  416.        
  417.         mov     esi,icon_data
  418.         mov     edi,REC_SIZE
  419.         imul    edi,[icons]
  420.         add     edi,icon_data
  421. ;--------------------------------------
  422. align 4
  423. news:
  424.         cmp     word [esi],ax
  425.         je      foundi
  426.         add     esi,REC_SIZE
  427.         cmp     esi,edi
  428.         jb      news
  429.         jmp     red
  430. ;--------------------------------------
  431. align 4
  432. foundi:
  433.         mov     ecx,edi
  434.         sub     ecx,esi
  435.        
  436.         mov     edi,esi
  437.         add     esi,REC_SIZE
  438.        
  439.         cld
  440.         rep     movsb
  441.        
  442.         dec     [icons]
  443.        
  444.         mov     eax,icon_data
  445.         mov     [current_icon],eax
  446.         movzx   ebx,word[eax]
  447.         sub     bx,'AA'
  448.         shl     bl,4
  449.         shr     ebx,4
  450.         add     ebx,40
  451.         mov     [cur_btn],ebx
  452.         jmp     red
  453. ;------------------------------------------------------------------------------
  454. align 4
  455. press_button_for_icon_position:
  456.         mov     edi,eax
  457.         sub     eax,40
  458.         mov     edx,eax
  459.         shl     eax,4
  460.         and     edx,0xf
  461.         mov     dh,ah
  462.         add     edx,65*256+65
  463.         mov     esi,icon_data
  464.         mov     ecx,[icons]
  465.         cld
  466. ;--------------------------------------
  467. align 4
  468. findl1:
  469.         cmp     dx,[esi]
  470.         je      foundl1
  471.         add     esi,REC_SIZE
  472.         loop    findl1
  473.         jmp     still
  474. ;--------------------------------------
  475. align 4
  476. foundl1:
  477.         mov     [current_icon],esi
  478.         mov     [cur_btn],edi
  479. ;--------------------------------------
  480. align 4
  481. band:
  482.         add     esi,12
  483.         call    ASCII_to_icon_number
  484. ;       and     eax,0xfffff8
  485.         cmp     eax,[cur_band_compensation]
  486.         jb      @f
  487.  
  488.         sub     eax,[cur_band_compensation]
  489. ;--------------------------------------
  490. align 4
  491. @@:
  492.         mov     [cur_band],eax
  493.         call    draw_btns
  494.         jmp     still
  495. ;------------------------------------------------------------------------------
  496. align 4
  497. print_strings:
  498.         pusha
  499.         mcall   13,<100,180>,<278+12,40>,0xffffff       ; clear text area
  500.         xor     edi,edi
  501.         mov     eax,4           ; icon text
  502.         mov     ebx,100*65536+278+14
  503.         mov     ecx,3
  504. ;--------------------------------------
  505. align 4
  506. .ll:
  507.         push    ecx
  508.         mov     ecx,0x000000
  509.         mov     edx,[current_icon]
  510.         add     edx,[positions+edi*4]
  511.         movzx   esi,byte[str_lens+edi]
  512.         inc     edi
  513.         mcall
  514.         add     ebx,14
  515.         pop     ecx
  516.         loop    .ll
  517.  
  518.         popa
  519.         ret
  520. ;------------------------------------------------------------------------------
  521. align 4
  522. load_icon_list:
  523.         mov     edi,icons_reserved      ; clear reserved area
  524.         mov     eax,32
  525.         mov     ecx,10*9
  526.         cld
  527.         rep     stosb
  528.  
  529.         mov     ecx,[icons]     ; set used icons to reserved area
  530.         mov     esi,icon_data
  531. ;--------------------------------------
  532. align 4
  533. ldl1:
  534.         movzx   ebx,byte [esi+1]
  535.         sub     ebx,65
  536. ; multiply x10
  537.         shl     ebx,1           ; multiply x2
  538.         lea     ebx,[ebx+ebx*4] ; multiply x5
  539.         movzx   eax,byte [esi]
  540.         add     ebx,eax
  541.         sub     ebx,65
  542.         add     ebx,icons_reserved
  543.         mov     [ebx],byte 'x'
  544.         add     esi,REC_SIZE
  545.         loop    ldl1
  546.         ret
  547. ;------------------------------------------------------------------------------
  548. align 4
  549. lst_path:
  550.         mov     ecx,30
  551.         mov     edi,finfo.path
  552.         rep     movsb
  553.         ret
  554. ;------------------------------------------------------------------------------
  555. align 4
  556. load_ic:
  557.         mov     ebx,finfo
  558.         mov     dword[ebx+12],48*REC_SIZE
  559.         mov     dword[ebx+16],icon_data
  560.         mov     esi,iconlst
  561.         call    lst_path
  562.         mcall   70
  563.         lea     eax,[ebx+10]
  564.         xor     edx,edx
  565.         mov     ebx,REC_SIZE
  566.         div     ebx
  567.         mov     [icons],eax
  568.         ret
  569. ;------------------------------------------------------------------------------
  570. align 4
  571. read_string:
  572.         pusha
  573.         sub     eax,11
  574.         movzx   ecx,byte[str_lens+eax]
  575.         mov     [cur_str],ecx
  576.         mov     eax,[positions+eax*4]
  577.         mov     edi,[current_icon]
  578.         add     edi,eax
  579.         mov     [addr],edi
  580.         add     edi,ecx
  581. ;--------------------------------------
  582. align 4
  583. .l1:
  584.         dec     edi
  585.         cmp     byte[edi],' '
  586.         jne     .found
  587.  
  588.         mov     byte[edi],'_'
  589.         loop    .l1
  590.  
  591.         dec     edi
  592. ;--------------------------------------
  593. align 4
  594. .found:
  595.         inc     edi
  596.         push    edi
  597.         call    print_strings
  598.         pop     edi
  599. ;--------------------------------------
  600. align 4
  601. f11:
  602.         mcall   10
  603.         cmp     eax,2
  604.         jz      fbu
  605.         jmp     rs_done
  606. ;--------------------------------------
  607. align 4
  608. fbu:
  609.         mcall   2
  610.         shr     eax,8
  611.         cmp     eax,13
  612.         je      rs_done
  613.         cmp     eax,8
  614.         jnz     nobsl
  615.         cmp     edi,[addr]
  616.         jz      f11
  617.         dec     edi
  618.         mov     [edi],byte '_'
  619.         call    print_strings
  620.         jmp     f11
  621. ;--------------------------------------
  622. align 4
  623. nobsl:
  624.         cmp     eax,31
  625.         jbe     f11
  626.         mov     [edi],al
  627.         call    print_strings
  628.         inc     edi
  629.         mov     esi,[addr]
  630.         add     esi,[cur_str]
  631.         cmp     esi,edi
  632.         jnz     f11
  633. ;--------------------------------------
  634. align 4
  635. rs_done:
  636.         mov     ecx,[addr]
  637.         add     ecx,[cur_str]
  638.         sub     ecx,edi
  639.         mov     eax,32
  640.         cld
  641.         rep     stosb
  642.         call    print_strings
  643.         popa
  644.         ret
  645. ;------------------------------------------------------------------------------
  646. align 4
  647. key:
  648.         mcall   2       ; just read it and ignore
  649.         jmp     still
  650. ;------------------------------------------------------------------------------
  651. ;   *********************************************
  652. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  653. ;   *********************************************
  654. align 4
  655. draw_window:
  656.         mcall   12,1
  657.         ; DRAW WINDOW
  658.         xor     eax,eax
  659.         xor     esi,esi
  660.         mcall   ,<210,300>,<30,(390-14)>,0x14ffffff,,title
  661.  
  662.         mcall   13,<20,260>,<35,200>,0x3366cc   ; WINDOW AREA
  663.  
  664.         mcall   38,<150,150>,<35,235>,0xffffff  ; VERTICAL LINE ON WINDOW AREA
  665.  
  666.         mcall   ,<20,280>,<135,135>     ; HOROZONTAL LINE ON WINDOW AREA
  667.  
  668.         mcall   8,<20,72>,<(275+1+14),(13-2)>,11,[bcolor]       ;id 11 TEXT ENTER BUTTONS
  669.        
  670.         inc     edx
  671.         add     ecx,14*65536
  672.         mcall                   ; id 12
  673.        
  674.         inc     edx
  675.         add     ecx,14*65536
  676.         mcall                   ; id 13
  677.  
  678.         mcall   ,<20,259>,<(329+2),(15-4)>,21   ; id 21 APPLY AND SAVE CHANGES BUTTON
  679.  
  680.         add     ecx,14*65536
  681.         inc     edx
  682.         mcall   ,<20,(129-2)>   ; id 22 ADD ICON BUTTON
  683.  
  684.         add     ebx,(130+2)*65536
  685.         inc     edx
  686.         mcall                   ; id 23 REMOVE ICON BUTTON
  687.  
  688.         mcall   ,<(20-14),8>,<(260-23),32>,30 + 1 shl 30        ; id 30 IMAGE BUTTON
  689.  
  690.         inc     edx
  691.         add     ebx,(36*7+26) shl 16
  692.         mcall           ; id 31
  693.  
  694.         add     edx,1 + 1 shl 29
  695.         mcall   ,<(33-19),(34*8)>       ; id 32
  696.        
  697.         mcall   4,<(23-15),(273-24)>,0,arrows,1
  698.  
  699.         add     ebx,(36*7+27)shl 16
  700.         add     edx,2
  701.         mcall
  702.  
  703.         dec     edx
  704.         mcall   ,<120,250>
  705.  
  706.         lea     edx,[ebx+8 shl 16]
  707.         mcall   47,0x30000,[icon_count],,0
  708.  
  709.         mov     eax,4
  710.         mov     ebx,24 shl 16+(250+14+14+14)
  711.         mov     ecx,0xffffff
  712.         mov     edx,text
  713.         mov     esi,47
  714. ;--------------------------------------
  715. align 4
  716. .newline:
  717.         mov     ecx,[edx]
  718.         add     edx,4
  719.         mcall
  720.         add     ebx,14
  721.         add     edx,47
  722.         cmp     [edx],byte 'x'
  723.         jne     .newline
  724. ;--------------------------------------
  725. align 4
  726. draw_btns:
  727.         mov     eax,0   ; DRAW BUTTONS ON WINDOW AREA
  728.         mov     ebx,20 shl 16+25
  729.         mov     ecx,35 shl 16+19
  730.         mov     edi,icon_table
  731.         mov     edx,40
  732. ;--------------------------------------
  733. align 4
  734. newbline:
  735.         cmp     [edi],byte 'x'
  736.         jne     no_button
  737.  
  738.         mov     esi,0x5577cc
  739.         cmp     [edi+90],byte 'x'
  740.         jne     nores
  741.  
  742.         mov     esi,0xcc5555
  743.         cmp     edx,[cur_btn]
  744.         jne     nores
  745.  
  746.         mov     esi,0xe7e05a
  747. ;--------------------------------------
  748. align 4
  749. nores:
  750.         push    eax
  751.         mcall   8
  752.         pop     eax
  753. ;--------------------------------------
  754. align 4
  755. no_button:
  756.         add     ebx,26 shl 16
  757.  
  758.         inc     edi
  759.         inc     edx
  760.         inc     al
  761.         cmp     al,9
  762.         jbe     newbline
  763.        
  764.         mov     al,0
  765.         add     edx,6
  766.         ror     ebx,16
  767.         mov     bx,20
  768.         ror     ebx,16
  769.         add     ecx,20 shl 16
  770.         inc     ah
  771.         cmp     ah,8
  772.         jbe     newbline
  773.  
  774.         call    print_strings
  775.         call    draw_icon
  776.         mcall   12,2
  777.         ret
  778. ;------------------------------------------------------------------------------
  779. align 4
  780. draw_icon:
  781.         mcall   13,<(33-20),(34*8+2)>,<(260-24),(37+15-2)>,0xffffff
  782.         mov     esi,[current_icon]
  783.         add     esi,12
  784.         call    ASCII_to_icon_number
  785.         push    eax
  786.         cmp     eax,[cur_band]
  787.         jb      .nou
  788.         sub     eax,[cur_band]
  789.         cmp     eax,7
  790.         ja      .nou
  791.         imul    eax,34 shl 16
  792.         lea     ebx,[eax+(33-19) shl 16]
  793.         mov     bx,34
  794.         mcall   13,,<(236+35),3>,0xff0000
  795.         mov     eax,[esp]
  796. ;--------------------------------------
  797. align 4
  798. .nou:
  799.         mov     eax,[cur_band]
  800.         push    eax
  801.         imul    eax,ICON_SIZE
  802.         mov     ebx,[strip_file]
  803.         add     ebx,eax
  804.         mov     ecx,8
  805.         mov     edx,(33-18) shl 16+238
  806. ;--------------------------------------
  807. align 4
  808. .nxt:
  809.         push    ecx
  810.         pusha
  811.         mov     ebp,0
  812.        
  813.         mov     eax,[strip_file_size]
  814.         add     eax,[strip_file]
  815.         cmp     eax,ebx
  816.         ja      @f
  817. ; draw a rectangle if icon does not exist      
  818.         mov     ebx,edx ; X
  819.         mov     ecx,edx ; Y
  820.         shl     ecx,16
  821.         mov     bx,32
  822.         mov     cx,bx
  823.         xor     edx,edx
  824.         mcall   13
  825.         jmp     .draw_pict_end
  826. ;--------------------------------------
  827. align 4
  828. @@:
  829.         mcall   65,,<32,32>,,32
  830. ;--------------------------------------
  831. align 4
  832. .draw_pict_end:
  833.         popa
  834.         pop     ecx
  835.         add     ebx,ICON_SIZE
  836.         add     edx,34 shl 16
  837.  
  838.         dec     ecx
  839.         jnz     .nxt
  840.  
  841.         mcall   4,<45,280-2>,0,rep_text,rep_text_len-rep_text
  842.         lea     edx,[ebx+(8*5)shl 16]
  843.         pop     ecx
  844.         mcall   47,0x30000,,,0xff
  845.        
  846.         add     ecx,7
  847.         add     edx,(3*8+4)shl 16
  848.         mcall
  849.        
  850.         add     edx,(5*8+4)shl 16
  851.         mcall   ,,[icon_count]
  852.        
  853.         pop     ecx
  854.         add     edx,(10*8+4)shl 16
  855.         mcall   ,,,,0xff0000
  856.         ret
  857. ;------------------------------------------------------------------------------
  858. align 4
  859. close:
  860.         or      eax,-1
  861.         mcall
  862. ;------------------------------------------------------------------------------
  863. ; ICON PROCESSING MODE - START2 entering label
  864. ;------------------------------------------------------------------------------
  865. align 4
  866. START2:
  867.         mcall   40,10000b       ; only Event 5 - draw background
  868.        
  869.         mcall   48,5
  870.         mov     [warea.by_x],eax
  871.         mov     [warea.by_y],ebx
  872.        
  873.         mcall   51,1,START_mouse_thread,stack_mouse_thread
  874.        
  875.         xor     eax,eax
  876.         mov     [x_left],eax
  877.         mov     [y_top],eax
  878.        
  879.         mcall   14
  880.         mov     ebx,eax
  881.         shr     eax,16
  882.         and     ebx,0xffff
  883.         mov     [x_right],eax
  884.         mov     [y_bottom],ebx
  885.         jmp     still2.1
  886. ;------------------------------------------------------------------------------
  887. align 4
  888. still2:
  889.         mcall   10
  890.  
  891.         mcall   15,8
  892.  
  893.         mov     ecx,eax
  894.         shr     ecx,16
  895.         mov     [x_left],ecx
  896.         and     eax,0xffff
  897.         mov     [x_right],eax
  898.  
  899.         mov     ecx,ebx
  900.         shr     ecx,16
  901.         mov     [y_top],ecx
  902.         and     ebx,0xffff
  903.         mov     [y_bottom],ebx
  904.  
  905.         mcall   48,5
  906.         mov     [warea.by_x],eax
  907.         mov     [warea.by_y],ebx
  908. .1:
  909.         mov     ecx,[icons]
  910.         mov     ebx,icon_data
  911. ;--------------------------------------
  912. align 4
  913. .start_new:
  914.         push    ebx ecx
  915.         mov     [adress_of_icon_data],ebx
  916.         mov     eax,[ebx]
  917.         call    calc_icon_pos
  918.         mov     [current_X],ebx
  919.         mov     [current_Y],eax
  920.  
  921.         call    draw_picture
  922.         pop     ecx ebx
  923.         add     ebx,REC_SIZE
  924.         dec     ecx
  925.         jnz     .start_new
  926.         jmp     still2
  927. ;------------------------------------------------------------------------------
  928. align 4
  929. draw_picture:
  930.         mov     eax,[current_X]
  931.         cmp     eax,[x_right]
  932.         ja      .exit
  933.  
  934.         add     eax,52
  935.         cmp     eax,[x_left]
  936.         jb      .exit
  937.  
  938.         mov     eax,[current_Y]
  939.         cmp     eax,[y_bottom]
  940.         ja      .exit
  941.  
  942.         add     eax,52
  943.         cmp     eax,[y_top]
  944.         jb      .exit
  945. ;--------------------------------------
  946. align 4
  947. @@:
  948.         mov     edi,[adress_of_icon_data]
  949.         lea     esi,[edi+12]
  950.         call    ASCII_to_icon_number
  951. ; protect for icon area RAW size limit
  952.         cmp     eax,[icon_count]
  953.         jbe     @f
  954. ;--------------------------------------
  955. align 4
  956. .exit:
  957.         ret
  958. ;--------------------------------------
  959. align 4
  960. @@:
  961.         push    eax
  962.         mcall   68,12,52*52*4+8
  963.         mov     [draw_area],eax
  964.         mov     ebx,52
  965.         mov     [eax],ebx
  966.         mov     [eax+4],ebx
  967.         pop     eax
  968.  
  969.         shl     eax,12          ; multiply x4096
  970.         add     eax,[strip_file]
  971.         mov     esi,eax
  972.  
  973.         mov     edi,[draw_area]
  974.         add     edi,(52-32)/2*4+8
  975.         mov     ebx,32
  976.         cld
  977. ;--------------------------------------
  978. align 4
  979. .y:
  980.         mov     ecx,32
  981.         rep     movsd
  982.        
  983.         add     edi,(52-32)*4
  984.         dec     ebx
  985.         jnz     .y
  986.  
  987.         call    draw_text
  988.        
  989.         mov     edx,[current_X]
  990.         shl     edx,16
  991.         add     edx,[current_Y]
  992.         mov     ebx,[draw_area]
  993.         add     ebx,8
  994.         mcall   25,,<52,52>
  995.         mcall   68,13,[draw_area]
  996.         ret
  997. ;------------------------------------------------------------------------------
  998. align 4
  999. draw_text:
  1000.         mov     esi,[adress_of_icon_data]
  1001.         add     esi,3
  1002.         push    edi
  1003.         mov     edi,title
  1004.         mov     ecx,8/4
  1005.         cld
  1006.         rep     movsd
  1007.         pop     edi
  1008.         mov     eax,title
  1009. ;--------------------------------------
  1010. align 4
  1011. news2:
  1012.         cmp     [eax],byte 33
  1013.         jb      founde
  1014.         inc     eax
  1015.         cmp     eax,title+8     ;11
  1016.         jb      news2
  1017. ;--------------------------------------
  1018. align 4
  1019. founde:
  1020.         sub     eax,title
  1021.         mov     [tl],eax
  1022.        
  1023.         mov     eax,[tl]
  1024.         lea     eax,[eax+eax*2]         ; eax *= char_width/2
  1025.         shl     eax,16
  1026.        
  1027.         mov     ebx,27 shl 16+40
  1028.         sub     ebx,eax
  1029.        
  1030.         xor     ecx,ecx         ; black shade of text
  1031.         or      ecx,0x08000000  ; redirect the output to the user area
  1032.         add     ebx,1 shl 16    ;*65536+1
  1033.        
  1034.         mov     edi,[draw_area]
  1035.         mcall   4,,,title,[tl]
  1036.  
  1037.         inc     ebx
  1038.         mcall
  1039.  
  1040.         add     ebx,1 shl 16
  1041.         mcall
  1042.  
  1043.         inc     ebx
  1044.         mcall
  1045.  
  1046.         sub     ebx,1 shl 16
  1047.         mcall
  1048.  
  1049.         dec     ebx
  1050.         sub     ebx,1 shl 16
  1051.         mcall
  1052.  
  1053.         sub     ebx,1 shl 16
  1054.         dec     ebx
  1055.         mcall
  1056.  
  1057.         dec     ebx
  1058.         add     ebx,1 shl 16
  1059.         mcall
  1060.  
  1061.         inc     ebx
  1062.         mov     ecx,0xffffff            ; white text
  1063.         or      ecx,0x08000000  ; redirect the output to the user area
  1064.         mcall
  1065.         ret
  1066. ;------------------------------------------------------------------------------
  1067. align 4
  1068. ASCII_to_icon_number:
  1069. ;
  1070. ; in:
  1071. ; esi - adress of icon ASCII text number (line start + 12)
  1072. ;
  1073. ; out:
  1074. ; eax - number of icon
  1075. ;
  1076.         push    esi
  1077.         xor     eax,eax
  1078.         xor     ebx,ebx
  1079. ;--------------------------------------
  1080. align 4
  1081. .next:
  1082.         lodsb
  1083.         cmp     al,'0'
  1084.         jb      .done
  1085.         cmp     al,'9'
  1086.         ja      .done
  1087.         sub     eax,'0'
  1088. ; multiply x10
  1089.         shl     ebx,1           ; multiply x2
  1090.         lea     ebx,[ebx+ebx*4] ; multiply x5
  1091.         add     ebx,eax
  1092.         jmp     .next
  1093. ;--------------------------------------
  1094. align 4
  1095. .done:
  1096.         pop     esi
  1097.         mov     eax,ebx
  1098.         ret
  1099. ;------------------------------------------------------------------------------
  1100. align 4
  1101. itoa:
  1102.         add     esi,2
  1103.         mov     ebx,10
  1104.         mov     ecx,3
  1105. ;--------------------------------------
  1106. align 4
  1107. .l0:
  1108.         xor     edx,edx
  1109.         div     ebx
  1110.         add     dl,'0'
  1111.         mov     [esi],dl
  1112.         dec     esi
  1113.         loop    .l0
  1114.         ret
  1115. ;------------------------------------------------------------------------------
  1116. align 4
  1117. calc_icon_pos:
  1118. ; in:
  1119. ; eax - dword [icon_position]
  1120. ; out:
  1121. ; eax - current Y
  1122. ; ebx - current X
  1123.         push    eax
  1124.         movzx   eax,al
  1125.         sub     eax,'A'         ;eax - number of letter
  1126.         cmp     eax,4
  1127.         jg      no_left
  1128.  
  1129.         shl     eax,6   ;imul eax,64
  1130.         add     eax,16
  1131.         movzx   ebx,[warea.left]
  1132.         add     eax,ebx
  1133.         jmp     x_done
  1134. ;--------------------------------------
  1135. align 4
  1136. no_left:
  1137.         sub     eax,9
  1138.         sal     eax,6   ;imul eax,64
  1139.         sub     eax,16+52-1
  1140.         movzx   ebx,[warea.right]
  1141.         add     eax,ebx
  1142. ;--------------------------------------
  1143. align 4
  1144. x_done:
  1145.         mov     ebx,eax
  1146.         pop     eax
  1147.         push    ebx
  1148.         movzx   eax,ah
  1149.         sub     eax,'A'         ; eax - number of letter
  1150.         cmp     eax,4
  1151.         jg      no_up
  1152.  
  1153.         shl     eax,6           ;imul eax,80
  1154.         add     eax,16
  1155.         movzx   ebx,[warea.top]
  1156.         add     eax,ebx
  1157.         jmp     y_done
  1158. ;--------------------------------------
  1159. align 4
  1160. no_up:
  1161.         sub     eax,9
  1162.         shl     eax,6           ;imul eax,80
  1163.         sub     eax,16-1
  1164.         movzx   ebx,[warea.bottom]
  1165.         add     eax,ebx
  1166. ;--------------------------------------
  1167. align 4
  1168. y_done:
  1169.         pop     ebx
  1170.         ret
  1171. ;------------------------------------------------------------------------------
  1172. include 'mouse.inc'
  1173. ;------------------------------------------------------------------------------
  1174. include 'data.inc'
  1175. ;------------------------------------------------------------------------------
  1176. IM_END:
  1177. ;------------------------------------------------------------------------------
  1178. include 'dat_area.inc'
  1179. ;------------------------------------------------------------------------------
  1180. I_END:
  1181. ;------------------------------------------------------------------------------
  1182.