Subversion Repositories Kolibri OS

Rev

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