Subversion Repositories Kolibri OS

Rev

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