Subversion Repositories Kolibri OS

Rev

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