Subversion Repositories Kolibri OS

Rev

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