Subversion Repositories Kolibri OS

Rev

Rev 5879 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ; ¬ ªà®á ¤«ï á¨á⥬­®© ¡¨¡«¨®â¥ª¨ box_lib.obj
  2. ; í«¥¬¥­â TreeList ¤«ï Kolibri OS
  3. ; ä ©« ¯®á«¥¤­¨© à § ¨§¬¥­ï«áï 10.11.2015 IgorA
  4. ; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
  5.  
  6.  
  7. sizeof.TreeList equ 20
  8. ;struct TreeList
  9. ;  type dw ? ;+ 0 ⨯ í«¥¬¥­â , ¨«¨ ¨­¤¥ªá ¨ª®­ª¨ ¤«ï 㧫 
  10. ;  lev db ?  ;+ 2 ã஢¥­ì í«¥¬¥­â 
  11. ;  clo db ?  ;+ 3 ä« £ § ªàëâ¨ï, ¨«¨ ®âªàëâ¨ï (¨¬¥¥â á¬ëá« ¤«ï த¨â¥«ì᪮£® 㧫 )
  12. ;  perv dd ? ;+ 4 ¨­¤¥ªá ¯à¥¤ë¤ã饣® í«¥¬¥­â 
  13. ;  next dd ? ;+ 8 ¨­¤¥ªá ¯®á«¥¤ãî饣® í«¥¬¥­â 
  14. ;  tc dd ?   ;+12 ¢à¥¬. ᮧ¤ ­¨ï
  15. ;  td dd ?   ;+16 ¢à¥¬. 㤠«¥­¨ï
  16. ;ends
  17.  
  18. macro use_tree_list
  19. {
  20.  
  21. ;¢ë¤¥«­¨¥ ¯ ¬ï⨠¤«ï áâàãªâãà ᯨ᪠ ¨ ®á­®¢­®© ¨­ä®à¬ æ¨¨ (ª®­áâàãªâ®à)
  22. align 4
  23. proc tl_data_init uses eax ecx edi, tlist:dword
  24.         mov edi,dword[tlist]
  25.  
  26.         xor ecx,ecx
  27.         mov cx,tl_info_size
  28.         imul ecx,tl_info_max_count
  29.         invoke mem.alloc,ecx
  30.         mov tl_data_info,eax ;ª®¯¨à㥬 㪠§ â¥«ì ­  ¯®«ã祭ãî ¯ ¬ïâì ¢ áâàãªâãàã
  31.         mov tl_data_img,0  ;®¡­ã«ï¥¬ 㪠§ â¥«ì 'data_img'
  32.         mov tl_data_img_sys,0 ;®¡­ã«ï¥¬ 㪠§ â¥«ì 'data_img_sys'
  33.  
  34.         mov ecx,sizeof.TreeList
  35.         imul ecx,tl_info_max_count
  36.         invoke mem.alloc,ecx
  37.         mov tl_data_nodes,eax ;ª®¯¨à㥬 㪠§ â¥«ì ­  ¯®«ã祭ãî ¯ ¬ïâì ¢ áâàãªâãàã
  38.  
  39.         stdcall tl_info_clear, edi
  40.  
  41.         ;­ áâனª¨ ¤®ç¥à­¥£® áªà®««¨­£ 
  42.         cmp tl_p_scroll,0
  43.         je @f
  44.                 mov eax,tl_p_scroll
  45.                 ;*** æ¢¥â®¢ë¥ ­ áâனª¨ ***
  46.                 mov ecx,tl_col_bkg
  47.                 mov dword[eax+sb_offs_bckg_col],ecx
  48.                 mov ecx,tl_col_zag
  49.                 mov dword[eax+sb_offs_frnt_col],ecx
  50.                 mov ecx,tl_col_txt
  51.                 mov dword[eax+sb_offs_line_col],ecx
  52.                 ;*** ­ áâனª¨ à §¬¥à®¢ ***
  53.                 mov ecx,tl_box_left
  54.                 add ecx,tl_box_width
  55.                 mov word[eax+2],cx
  56.                 mov ecx,tl_box_height
  57.                 mov word[eax+4],cx
  58.                 mov ecx,tl_box_top
  59.                 mov word[eax+6],cx
  60.         @@:
  61.         ret
  62. endp
  63.  
  64. ;®ç¨á⪠ ¯ ¬ïâ¨ í«¥¬¥­â  (¤¥áâàãªâ®à)
  65. align 4
  66. proc tl_data_clear uses edi, tlist:dword
  67. ;uses eax ???
  68.         mov edi,dword[tlist]
  69.         cmp tl_data_img,0
  70.         je @f
  71.                 invoke mem.free,tl_data_img ;ç¨á⪠ á¨á⥬­ëå ¨ª®­®ª
  72.         @@:
  73.         cmp tl_data_img_sys,0
  74.         je @f
  75.                 invoke mem.free,tl_data_img_sys ;ç¨á⪠ á¨á⥬­ëå ¨ª®­®ª
  76.         @@:
  77.         invoke mem.free,tl_data_info
  78.         invoke mem.free,tl_data_nodes
  79.         ret
  80. endp
  81.  
  82. ;®ç¨á⪠ ᯨ᪠ (¨­ä®à¬ æ¨¨)
  83. align 4
  84. proc tl_info_clear uses eax ecx edi, tlist:dword
  85.         mov edi,dword[tlist]
  86.         mov tl_ch_tim,0
  87.         mov tl_tim_undo,0
  88.         mov tl_cur_pos,0
  89.         mov ecx,sizeof.TreeList
  90.         imul ecx,tl_info_max_count
  91.         mov eax,tl_data_nodes
  92.         @@:
  93.                 mov byte[eax],0 ;ç¨á⨬ 㧫ë 0-¬¨
  94.                 inc eax
  95.                 loop @b
  96.         mov eax,tl_data_nodes ;㪠§ â¥«ì ­  0-© 㧥«
  97.         mov dword[eax+8],1 ;㪠§ â¥«ì next ¢ 0-¬ 㧫¥ ¯à¨à ¢­¨¢ ¥¬ ª 1
  98.  
  99.         cmp tl_p_scroll,0 ;®¡à ¡®âª  áªà®««¨­£ 
  100.         je @f
  101.                 mov eax,tl_p_scroll
  102.                 mov dword[eax+sb_offs_position],0
  103.                 call tb_scrol_resize
  104.         @@:
  105.         ret
  106. endp
  107.  
  108. ;ॠªæ¨ï ­  ª« ¢¨ âãàã
  109. align 4
  110. proc tl_key uses ebx ecx edi, tlist:dword
  111.         mov edi,dword[tlist]
  112.  
  113.         mov ebx,tl_el_focus
  114.         cmp dword[ebx],edi
  115.         jne .no_focus ;í«¥¬¥­â ­¥ ¢ 䮪ãá¥
  116.  
  117.         push eax
  118.         mcall 66,2 ;¯®«ãç¨âì ०¨¬ ¢¢®¤  á ª« ¢¨ âãàë
  119.  
  120.         lea ecx,[tl_key_scan]
  121.         cmp eax,1 ;1 = ᪠­ª®¤ë
  122.         je @f
  123.                 lea ecx,[tl_key_ascii]
  124.         @@:
  125.         pop eax
  126.  
  127.         xor bx,bx
  128.         cmp ah,byte[ecx] ;Enter
  129.         jne @f
  130.         cmp tl_on_press,0
  131.         je @f
  132.                         call tl_on_press
  133.         @@:
  134.         cmp ah,byte[ecx+1] ;Space
  135.         jne @f
  136.                 stdcall tl_node_close_open, edi
  137.         @@:
  138.         cmp ah,byte[ecx+2] ;Up
  139.         jne @f
  140.                 stdcall tl_cur_perv, edi
  141.         @@:
  142.         cmp ah,byte[ecx+3] ;Down
  143.         jne @f
  144.                 stdcall tl_cur_next, edi
  145.         @@:
  146.         cmp ah,byte[ecx+7] ;Page Up
  147.         jne @f
  148.                 stdcall tl_cur_page_up, edi
  149.         @@:
  150.         cmp ah,byte[ecx+8] ;Page Down
  151.         jne @f
  152.                 stdcall tl_cur_page_down, edi
  153.         @@:
  154.  
  155.         bt tl_style,0 ;tl_key_no_edit
  156.         jc .no_edit
  157.                 cmp ah,byte[ecx+4] ;Left
  158.                 jne @f
  159.                         stdcall tl_node_lev_dec, edi
  160.                         mov bx,1
  161.                 @@:
  162.                 cmp ah,byte[ecx+5] ;Right
  163.                 jne @f
  164.                         stdcall tl_node_lev_inc, edi
  165.                         mov bx,1
  166.                 @@:
  167.                 cmp ah,byte[ecx+6] ;Delete
  168.                 jne @f
  169.                         stdcall tl_node_delete, edi
  170.                         mov bx,1
  171.                 @@:
  172.         .no_edit:
  173.  
  174.         cmp bx,1
  175.         jne .no_focus
  176.                 stdcall tl_draw, edi
  177.         .no_focus:
  178.         ret
  179. endp
  180.  
  181. ;ॠªæ¨ï ­  ¬ëèì
  182. align 4
  183. proc tl_mouse, tlist:dword
  184.         pushad
  185.         mov edi,dword[tlist]
  186.  
  187.         mcall 37,1 ;ª®®à¤¨­ âë ¬ëè¨ ®â­®á¨â¥«ì­® ®ª­ 
  188.  
  189.         mov ebx,tl_box_left
  190.         shl ebx,16
  191.         cmp eax,ebx ;«¥¢ ï £à ­¨æ  ®ª­ 
  192.         jl .no_in_wnd ;.test_scroll ­¥ ¯à¨¬¥­ï¥¬
  193.  
  194.                 shr ebx,16
  195.                 add ebx,tl_box_width
  196.                 shl ebx,16
  197.                 cmp eax,ebx ;¯à ¢ ï £à ­¨æ  ®ª­ 
  198.                 jg .test_scroll
  199.  
  200.                 mov ebx,tl_box_top
  201.                 add ebx,tl_box_height
  202.                 cmp ax,bx ;­¨¦­ïï £à ­¨æ  ®ª­ 
  203.                 jg .test_scroll
  204.  
  205.                 sub ebx,tl_box_height
  206.                 add bx,tl_capt_cy
  207.                 cmp ax,bx ;¢¥àå­ïï £à ­¨æ  ®ª­  + ¢ëá®â  ¯®¤¯¨á¨
  208.                 jl .test_scroll
  209.  
  210.                 push eax ebx
  211.                 mcall 37,2
  212.  
  213.                 bt eax,0 ;left mouse button press
  214.                 pop ebx eax
  215.                 jae .no_draw
  216.  
  217.                 mov esi,tl_el_focus
  218.                 mov dword[esi],edi ;set focus
  219.  
  220.                 ; if '+' or '-' press
  221.                 mov esi,eax
  222.                 shr esi,16
  223.                 sub esi,tl_box_left ;esi = mouse x coord in element window
  224.  
  225.                 and eax,0xffff
  226.                 sub ax,bx
  227.                 xor edx,edx
  228.                 xor ecx,ecx
  229.                 mov cx,tl_img_cy
  230.                 div ecx
  231.                 cmp tl_p_scroll,0 ;ãç¨â뢠¥¬ áªà®««¨­£
  232.                 je @f
  233.                         mov edx,tl_p_scroll
  234.                         add eax,dword[edx+sb_offs_position] ;¤®¡ ¢«ï¥¬ áªà®««¨­£ ­  ¢¥àåã
  235.                 @@:
  236.  
  237.                 mov ecx,eax
  238.                 call tl_get_node_count ;eax = node count
  239.                 cmp eax,ecx
  240.                 jl @f
  241.                         mov eax,ecx ;¥á«¨ ªãàá®à ­¥ ¢ë襫 §  ¯à¥¤¥«ë 㧫®¢, ¢®ááâ ­ ¢«¨¢ ¥¬ áâ à®¥ §­ ç¥­¨¥ eax
  242.                 @@:
  243.  
  244.                 cmp eax,tl_cur_pos ;¥á«¨ ­®¢®¥ §­ ç¥­¨¥ ªãàá®à  ᮢ¯ «® á ¯à¥¤ë¤ã騬
  245.                 je @f ;â® ­¥ áâ¨à ¥¬ ªãàá®à
  246.                 push esi
  247.                         mov esi,tl_box_top
  248.                         add esi,tl_box_height ;esi = coord bottom border
  249.                         call tl_draw_null_cursor ;áâ¨à ¥¬ ªãàá®à
  250.                 pop esi
  251.                 @@:
  252.  
  253.                 mov tl_cur_pos,eax
  254.  
  255.                 ; if '+' or '-' press
  256.                 call tl_get_cur_node_index ;eax = node index
  257.                 cmp eax,2
  258.                 jl .no_open_close ;ªãàá®à á⮨⠭  ¯ãá⮬ ¬¥áâ¥, ¡¥§ 㧫®¢
  259.                 imul eax,sizeof.TreeList
  260.                 add eax,tl_data_nodes
  261.                 xor bx,bx
  262.                 mov bl,byte[eax+2] ;+2 lev á®å࠭塞 ã஢¥­ì ⥪ã饣® 㧫 
  263.                 inc bx ;+ ¯®«¥ ¤«ï ªãàá®à 
  264.  
  265.                 cmp si,tl_img_cx
  266.                 jl .no_open_close ;¬ë襩 ¯®¯ «¨ ­  «¥¢®¥ ¯®«¥ ¤«ï ªãàá®à , £¤¥ â®ç­® ­¥â '+' ¨ '-'
  267.                         mov eax,esi
  268.                         xor edx,edx
  269.                         xor ecx,ecx
  270.                         mov cx,tl_img_cx
  271.                         div ecx
  272.  
  273.                         cmp ax,bx
  274.                         jne .no_open_close
  275.  
  276.                         stdcall tl_node_close_open, edi
  277.                 .no_open_close:
  278.  
  279.                 mov esi,tl_box_top
  280.                 add esi,tl_box_height ;esi = coord bottom border
  281.                 call tl_draw_cursor ;¯¥à¥à¨á®¢ª  ªãàá®à 
  282.                 call tl_draw_caption_cur_pos
  283.                 jmp .no_draw
  284. ;--- mouse event for children scrollbar ----------------------------------------
  285. .test_scroll:
  286.         mov edx,tl_p_scroll
  287.         cmp edx,0
  288.         je .no_in_wnd ;¯®«ì§®¢ â¥«ì ­¥ ᮧ¤ « ¤®ç¥à­¥£® áªà®««¨­£ 
  289.                 shr ebx,16
  290.                 add bx,word[edx] ;+0 .size_x
  291.                 shl ebx,16
  292.                 cmp eax,ebx ;¯à ¢ ï £à ­¨æ  ®ª­ 
  293.                 jg .no_in_wnd
  294.  
  295.                 mov eax,dword[edx+sb_offs_max_area]
  296.                 cmp eax,dword[edx+sb_offs_cur_area]
  297.                 jbe .no_in_wnd ;¢á¥ ã§«ë ¯®¯ ¤ îâ ¢ ®ª­® áªà®««¨­£ 
  298.                         stdcall scroll_bar_vertical.mouse, edx ;scrollbar_ver_mouse
  299.  
  300.                         cmp dword[edx+sb_offs_redraw],0
  301.                         je  @f
  302.                                 mov dword[edx+sb_offs_redraw],0
  303.                                 stdcall tl_draw, edi ;¯à®¨§®è«¨ ¨§¬¥­¥­¨ï áªà®««¨­£ 
  304.                         @@:
  305.                         cmp dword[edx+sb_offs_delta2],0
  306.                         jne .no_draw ;¯®¯ «¨ ­  áªà®««¨­£ - ­¥ á­¨¬ ¥¬ 䮪ãá á TreeList
  307. ;-------------------------------------------------------------------------------
  308.         .no_in_wnd:  ;­¥ ¯®¯ «¨ ¢ ®ª­® - ¯®â¥àï 䮪ãá  (¯à¨ ãá«®¢¨¨ ç⮠䮪ãá ¡ë« ­  ¤ ­­®¬ í¥«¥¬¥­â¥)
  309.         mcall 37,2 ;¯à®¢¥à塞 ­ ¦ â®áâì «î¡ëå ª­®¯®ª
  310.         cmp eax,0  ;­¨ç¥£® ­¥ ­ ¦ «¨ eax=0
  311.         je .no_draw
  312.  
  313.                 mov ebx,tl_el_focus
  314.                 cmp dword[ebx],edi
  315.                 jne .no_draw ;í«¥¬¥­â ­¥ ¢ 䮪ãá¥
  316.                         mov dword[ebx],0 ;reset focus
  317.                         mov esi,tl_box_top
  318.                         add esi,tl_box_height ;esi = coord bottom border
  319.                         call tl_draw_cursor ;à¨á㥬 ªãàá®à á ¯®â¥àï­ë¬ 䮪ãᮬ
  320.         .no_draw:
  321.  
  322.         popad
  323.         ret
  324. endp
  325.  
  326. ;®â¬¥­  ¤¥©á⢨ï
  327. align 4
  328. proc tl_info_undo uses eax edi, tlist:dword
  329.         mov edi,dword[tlist]
  330.         mov eax,tl_tim_undo
  331.         cmp tl_ch_tim,eax
  332.         jbe @f
  333.                 inc tl_tim_undo
  334.                 call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
  335.         @@:
  336.         ret
  337. endp
  338.  
  339. ;¯®¢â®à ¤¥©á⢨ï
  340. align 4
  341. proc tl_info_redo uses edi, tlist:dword
  342.         mov edi,dword[tlist]
  343.         cmp tl_tim_undo,1
  344.         jl @f
  345.                 dec tl_tim_undo
  346.                 call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
  347.         @@:
  348.         ret
  349. endp
  350.  
  351. ;㤠«¥­¨¥ ®â¬¥­¥­­ëå ¤¥©á⢨©
  352. ;¢­ãâ७­ïï äã­ªæ¨ï, ­¥ ¤«ï íªá¯®àâ 
  353. align 4
  354. tl_info_set_undo:
  355.   cmp tl_tim_undo,1
  356.   jl .no_work
  357.  
  358.   push eax ebx ecx edx
  359.   mov edx,tl_data_nodes
  360.   mov ecx,edx
  361.   add ecx,sizeof.TreeList
  362.   call tl_move_next ;long i=node[0].next;
  363.   mov eax,tl_tim_undo
  364.   sub tl_ch_tim,eax ;ch_tim-=tim_undo;
  365.   mov eax,tl_ch_tim
  366.     cmp edx,ecx
  367.     jle @f
  368.  
  369.     ;if(node[i].tc>ch_tim){ // ¥á«¨ ᮧ¤ ­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  370.     cmp dword[edx+12],eax
  371.     jle .no_u1
  372.       mov dword[edx+12],0
  373.       mov dword[edx+16],0
  374.  
  375.       mov ebx, dword[edx+4]
  376.       imul ebx,sizeof.TreeList
  377.       add ebx, tl_data_nodes ;.next
  378.       push dword[edx+8] ;node[node[i].perv].next=node[i].next;
  379.       pop dword[ebx+8]
  380.  
  381.       mov ebx, dword[edx+8]
  382.       imul ebx,sizeof.TreeList
  383.       add ebx, tl_data_nodes ;.perv
  384.       push dword[edx+4] ;node[node[i].next].perv=node[i].perv;
  385.       pop dword[ebx+4]
  386.  
  387.     .no_u1:
  388.  
  389.     ;else if(node[i].td>ch_tim) node[i].td=0; // ¥á«¨ 㤠«¥­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  390.     cmp dword[edx+16],eax
  391.     jle .no_u2
  392.       mov dword[edx+16],0
  393.     .no_u2:
  394.  
  395.     call tl_move_next
  396.     jmp @b
  397.   @@:
  398.   mov tl_tim_undo,0
  399. ;  mov eax,[edi+?] ;co_tim
  400. ;  cmp tl_ch_tim,eax ;ch_tim
  401. ;  jge @f
  402. ;    mov [edi+?],0 ;co_tim
  403. ;  @@:
  404.   pop edx ecx ebx eax
  405.   .no_work:
  406.  
  407.   ret
  408.  
  409. ;¢ë¢®¤ ᯨ᪠ ­  íªà ­
  410. align 4
  411. proc tl_draw, tlist:dword
  412.     pushad
  413.     ;draw dir_list main rect
  414.     mov edi,dword[tlist]
  415.     mov ebx,tl_box_left
  416.     shl ebx,16
  417.     add ebx,tl_box_width
  418.     mov ecx,tl_box_top
  419.     shl ecx,16
  420.     mov cx,tl_capt_cy
  421.     mov edx,tl_col_zag
  422.     mcall 13 ;draw window caption
  423.  
  424.     add ecx,tl_box_top
  425.     shl ecx,16
  426.     add ecx,tl_box_height
  427.     sub cx,tl_capt_cy
  428.     mov edx,tl_col_bkg
  429.     int 0x40 ;draw window client rect
  430.  
  431.     cmp tl_capt_cy,9 ;9 - minimum caption height
  432.     jl @f
  433.     mov ebx,edi ;calculate cursor position
  434.     mov eax,tl_cur_pos
  435.     inc eax
  436.     lea edi,[txt_capt_cur]
  437.     add edi,7
  438.     call tl_convert_to_str
  439.  
  440.     mov edi,ebx
  441.     mov eax,tl_tim_undo
  442.     lea edi,[txt_capt_otm]
  443.     add edi,7
  444.     call tl_convert_to_str
  445.     mov edi,ebx ;restore edi
  446.  
  447.     mov eax,4 ;draw text captions
  448.     mov ebx,tl_box_left
  449.     shl ebx,16
  450.     add ebx,5*65536+3
  451.     add ebx,tl_box_top
  452.     mov ecx,tl_col_txt
  453.     or  ecx,0x80000000
  454.     lea edx,[txt_capt_cur]
  455.     int 0x40
  456.  
  457.     mov ebx,tl_box_left
  458.     shl ebx,16
  459.     add ebx,100*65536+3
  460.     add ebx,tl_box_top
  461.     lea edx,[txt_capt_otm]
  462.     int 0x40
  463.     @@:
  464.  
  465.     ;cycle to nodes
  466.     xor eax,eax
  467.     mov edx,tl_data_nodes
  468.     mov ecx,edx
  469.     add ecx,sizeof.TreeList
  470.  
  471.     ;*** ¯à®¯ã᪠㧫®¢, ª®â®àë¥ ¯à®¬®â ­ë áªà®««¨­£®¬ ***
  472.     cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
  473.     je .end_c1
  474.     mov esi,tl_p_scroll
  475.     cmp dword[esi+sb_offs_position],0 ;¥á«¨ áªà®««¨­£ ­  ¢¥àåã, ¢ë室¨¬
  476.     je .end_c1
  477.       @@:
  478.         call tl_iterat_next
  479.         cmp edx,ecx
  480.         jle .end_draw
  481.         inc eax
  482.         cmp eax,dword[esi+sb_offs_position]
  483.         jge .end_c1
  484.         jmp @b
  485.     .end_c1:
  486.  
  487.     xor eax,eax
  488.     mov esi,tl_box_top
  489.     add esi,tl_box_height ;esi = coord bottom border
  490.     @@:
  491.       call tl_iterat_next
  492.       cmp edx,ecx
  493.       jle @f
  494.       call tl_draw_node
  495.       inc eax
  496.       jmp @b
  497.     @@:
  498.  
  499.     call tl_draw_cursor
  500.  
  501.     mov edi,tl_p_scroll ;à¨á㥬 ¤®ç¥à­¨© áªà®««¨­£
  502.     cmp edi,0          ;¤«ï ⮣® çâ®-¡ë ¥£® ­¥ ¯à¨è«®áì à¨á®¢ âì ¢ ¯®«ì§®¢ â¥«ì᪮© ¯à®£à ¬¬¥
  503.     je .end_draw       ;¥á«¨ ­¥â áªà®««¨­£  ¢ë室¨¬
  504.     stdcall scroll_bar_vertical.draw, edi
  505.  
  506.     .end_draw:
  507.     popad
  508.   ret
  509. endp
  510.  
  511. ;¯¥à¥å®¤ ­  á«¥¤ã騩 ¢¨¤¨¬ë© 㧥« (¯à®¯ãáª ï § ªàëâë¥)
  512. ;input:
  513. ; ecx = pointer to 1 node struct
  514. ; edx = pointer to some node struct
  515. ; edi = pointer to 'TreeList' struct
  516. ;output:
  517. ; edx = pointer to next node struct
  518. align 4
  519. tl_iterat_next:
  520.   push bx
  521.   mov bl,0x7f
  522.   cmp byte[edx+3],1
  523.   jne @f
  524.     mov bl,byte[edx+2]
  525.   @@:
  526.  
  527.   cmp tl_tim_undo,0
  528.   je .else
  529.  
  530.   push eax
  531.   .beg0:
  532.     call tl_move_next
  533.     cmp edx,ecx
  534.     jle @f
  535.     call tl_node_not_vis ;¯à®¯ã᪠㤠«¥­­ëå ¨ ®â¬¥­¥­­ëå
  536.     cmp al,1
  537.     je .beg0
  538.     cmp bl,byte[edx+2] ;¯à®¯ã᪠§ ªàëâëå
  539.     jl .beg0
  540.   @@:
  541.   pop eax
  542.   pop bx
  543.   ret
  544.  
  545.   .else:
  546.     call tl_move_next
  547.     cmp edx,ecx
  548.     jle .endif
  549.     cmp dword[edx+16],0 ;td = 'time delete' -> ¯à®¯ã᪠㤠«¥­­ëå
  550.     jne .else
  551.     cmp bl,byte[edx+2] ;¯à®¯ã᪠§ ªàëâëå
  552.     jl .else
  553.   .endif:
  554.   pop bx
  555.   ret
  556.  
  557. ;¯¥à¥å®¤ ­  á«¥¤ã騩 ¢¨¤¨¬ë© 㧥« (¨ ­  § ªàëâë¥ â®¦¥)
  558. ;input:
  559. ; ecx = pointer to 1 node struct
  560. ; edx = pointer to some node struct
  561. ; edi = pointer to 'TreeList' struct
  562. ;output:
  563. ; edx = pointer to next visible node struct
  564. align 4
  565. tl_iterat_next_all:
  566.   cmp tl_tim_undo,0
  567.   je .else
  568.  
  569.   push eax
  570.   @@:
  571.     call tl_move_next
  572.     cmp edx,ecx
  573.     jle @f
  574.     call tl_node_not_vis
  575.     cmp al,1
  576.     je @b
  577.   @@:
  578.   pop eax
  579.   ret
  580.   .else:
  581.     call tl_move_next
  582.     cmp edx,ecx
  583.     jle .endif
  584.     cmp dword[edx+16],0 ;td -> time delete
  585.     jne .else
  586.   .endif:
  587.   ret
  588.  
  589. ;¯¥à¥å®¤ ­  ¯à¥¤ë¤ã騩 ¢¨¤¨¬ë© 㧥« (¯à®¯ãáª ï § ªàëâë¥)
  590. ;input:
  591. ; ecx = pointer to 1 node struct
  592. ; edx = pointer to some node struct
  593. ; edi = pointer to 'TreeList' struct
  594. align 4
  595. tl_iterat_perv:
  596.   push eax
  597.   cmp tl_tim_undo,0
  598.   je .beg1
  599.  
  600.   .beg0:
  601.     call tl_move_perv
  602.     cmp edx,ecx
  603.     jle @f
  604.     call tl_node_not_vis ;¯à®¯ã᪠㤠«¥­­ëå ¨ ®â¬¥­¥­­ëå
  605.     cmp al,1
  606.     je .beg0
  607.  
  608.   .beg1:
  609.     call tl_move_perv
  610.     cmp edx,ecx
  611.     jle @f
  612.     cmp dword[edx+16],0 ;td = 'time delete' -> ¯à®¯ã᪠㤠«¥­­ëå
  613.     jne .beg1
  614.  
  615.   @@:
  616.     call tl_move_max_clo_par
  617.   pop eax
  618.   ret
  619.  
  620. ;­ å®¤¨â த¨â¥«ì᪨© § ªàëâë© ã§¥« ¬ ªá¨¬ «ì­®£® ã஢­ï
  621. ;input:
  622. ; edx = pointer to some node struct
  623. ; edi = pointer to 'TreeList' struct
  624. ;output:
  625. ; edx = pointer closed parent node with maximum level
  626. align 4
  627. proc tl_move_max_clo_par uses eax ebx
  628.   mov eax,edx
  629.   xor ebx,ebx
  630.   .beg:
  631.     call tl_move_par
  632.     cmp byte[edx+3],1 ;த¨â¥«ì᪨© 㧥« § ªàëâ ?
  633.     jne @f
  634.       mov eax,edx
  635.     @@:
  636.     cmp ebx,edx
  637.     je .end_f
  638.       mov ebx,edx
  639.     jmp .beg
  640.   .end_f:
  641.   mov edx,eax
  642.   ret
  643. endp
  644.  
  645. ;input:
  646. ; edx = pointer to some node struct
  647. ; edi = pointer to 'TreeList' struct
  648. ;output:
  649. ; edx = pointer to next node struct
  650. align 4
  651. tl_move_next:
  652.         mov edx,dword[edx+8]
  653.         imul edx,sizeof.TreeList
  654.         add edx,tl_data_nodes
  655.         ret
  656.  
  657. ;input:
  658. ; edx = pointer to some node struct
  659. ; edi = pointer to 'TreeList' struct
  660. ;output:
  661. ; edx = pointer to perv node struct
  662. align 4
  663. tl_move_perv:
  664.         mov edx,dword[edx+4]
  665.         imul edx,sizeof.TreeList
  666.         add edx,tl_data_nodes
  667.         ret
  668.  
  669. ;¯¥à¥¤¢¨£ ¥¬áï ­  த¨â¥«ì᪨© 㧥«, ¥á«¨ â ª®£® ­¥â, â® ®áâ ¢«ï¥¬ áâ à®¥ §­ ç¥­¨¥ 㪠§ â¥«ï
  670. ;input:
  671. ; ecx =
  672. ; edx = pointer to some node struct
  673. ; edi = pointer to 'TreeList' struct
  674. ;output:
  675. ; edx = pointer to parent node struct
  676. align 4
  677. tl_move_par:
  678.         cmp byte[edx+2],0
  679.         je .end_f ;㧥« 0-£® ã஢­ï ­¥ ¬®¦¥â ¡ëâì ¤®ç¥à­¨¬
  680.         push eax ebx esi
  681.         mov esi,edx ;copy node pointer (edx)
  682.         mov bl,byte[edx+2]
  683.         @@:
  684.                 call tl_move_perv
  685.                 cmp edx,ecx
  686.                 jle @f ;¢á¥ ¢ëè¥ áâ®ï騥 ã§«ë ­¥ த¨â¥«ì᪨¥
  687.                 call tl_node_not_vis ;¯à®¯ã᪠㤠«¥­­ëå ¨ ®â¬¥­¥­­ëå
  688.                 cmp al,1
  689.                 je @b
  690.                 cmp byte[edx+2],bl
  691.                 jl .end_0 ;㤠筮 ­ è«¨ த¨â¥«ì᪨© 㧥«
  692.                 jmp @b
  693.         @@:
  694.                 mov esi,ebx ;restore node pointer
  695.         .end_0:
  696.         pop esi ebx eax
  697.         .end_f:
  698.         ret
  699.  
  700. ;¯à®¢¥àï¥â ¢¨¤¨¬ë© «¨ 㪠§ ­­ë© 㧥« á ãç¥â®¬: ¤®¡ ¢«¥­¨©, 㤠«¥­¨©, ®â¬¥­ ¤¥©á⢨©
  701. ;input:
  702. ; edx = pointer to symbol struct
  703. ; edi = pointer to 'TreeList' struct
  704. ;output:
  705. ; al = 1 if sumbol not visible
  706. ; (node[i].td+tim_Undo<=ch_tim && node[i].td) || (node[i].tc>ch_tim-tim_Undo)
  707. align 4
  708. tl_node_not_vis:
  709.   cmp dword[edx+16],0
  710.   je @f
  711.   mov eax,dword[edx+16] ;eax=node[i].td
  712.   add eax,tl_tim_undo
  713.   cmp eax,tl_ch_tim
  714.   jg @f
  715.     mov al,1
  716.     ret
  717.   @@:
  718.  
  719.   mov eax,tl_ch_tim
  720.   sub eax,tl_tim_undo
  721.   cmp dword[edx+12],eax ;tc -> time create
  722.   jle @f
  723.     mov al,1
  724.     ret
  725.   @@:
  726.   xor al,al
  727.   ret
  728.  
  729. ;à¨á㥬 ªãàá®à ­  íªà ­¥
  730. ;input:
  731. ; edi = pointer to TreeInfo struct
  732. ; esi = coord bottom border
  733. align 4
  734. proc tl_draw_cursor uses eax ebx ecx edx esi
  735.         call tl_get_display_cur_pos ;eax = cursor pos in screen
  736.         cmp eax,0
  737.         jl .end_f ;ªãàá®à ­ å®¤¨âáï ¢ëè¥ ®ª­ , ¢ ®¡« á⨠¯à®ªàã祭­®© áªà®««¨­£®¬
  738.  
  739.         cmp tl_data_img_sys,0 ;ᬮâਬ ¥áâì «¨ 㪠§ â¥«ì ­  ª à⨭ªã á¨á⥬­ëå ¨ª®­®ª
  740.         jne @f
  741.                 mov ebx,tl_box_left
  742.                 shl ebx,16
  743.                 mov bx,tl_img_cx
  744.                 xor ecx,ecx
  745.                 mov cx,tl_img_cy
  746.                 imul ecx,eax
  747.                 add ecx,tl_box_top
  748.                 add cx,tl_capt_cy
  749.  
  750.                 ;crop image if on the border
  751.                 cmp esi,ecx ;¥á«¨ ªãàá®à ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
  752.                 jl .end_f
  753.  
  754.                 sub esi,ecx
  755.                 shl ecx,16
  756.                 mov cx,tl_img_cy
  757.                 cmp si,tl_img_cy
  758.                 jge .crop0
  759.                         mov cx,si ;¥á«¨ ªãàá®à ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
  760.                 .crop0:
  761.  
  762.                 mov edx,tl_col_txt
  763.                 mcall 13 ;à¨á㥬 ¯à®á⮩ ¯àאַ㣮«ì­¨ª, â.ª. ­¥â á¨á⥬­ëå ¨ª®­®ª
  764.                 jmp .end_f
  765.         @@:
  766.         mov ebx,tl_data_img_sys
  767.         imul ax,tl_img_cy
  768.         mov edx,tl_box_left
  769.         shl edx,16
  770.         mov dx,ax
  771.         add edx,tl_box_top
  772.         add dx,tl_capt_cy
  773.  
  774.         mov ecx,tl_el_focus ;¯à®¢¥à塞 ¢ 䮪ãá¥ í«¥¬¥­â ¨«¨ ­¥â
  775.         cmp dword[ecx],edi
  776.         je .focus
  777.                 ;¥á«¨ ­¥ ¢ 䮪ãᥠᤢ¨£ ¥¬ ª®®à¤¨­ âë ­  ¨ª®­ªã ­¥  ªâ¨¢­®£® ªãàá®à 
  778.                 xor eax,eax
  779.                 xor ecx,ecx
  780.                 mov cx,tl_img_cx
  781.                 mov ax,tl_img_cy
  782.                 imul eax,ecx
  783.                 imul eax,4*3 ;4=icon index 3=rgb
  784.                 add ebx,eax
  785.         .focus:
  786.  
  787.         mov cx,tl_img_cx
  788.         shl ecx,16
  789.         mov cx,tl_img_cy
  790.  
  791.         ;crop image if on the border
  792.         cmp si,dx ;¥á«¨ ªãàá®à ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
  793.         jl .end_f
  794.  
  795.                 sub si,dx
  796.                 cmp si,tl_img_cy
  797.                 jge .crop1
  798.                         mov cx,si ;¥á«¨ ªãàá®à ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
  799.                 .crop1:
  800.  
  801.                 mcall 7 ;à¨á㥬 ¨ª®­ªã ªãàá®à 
  802.         .end_f:
  803.         ret
  804. endp
  805.  
  806. ;áâ¨à ¥¬ ªãàá®à ­  íªà ­¥
  807. ;input:
  808. ; edi = pointer to TreeInfo struct
  809. ; esi = coord bottom border
  810. align 4
  811. proc tl_draw_null_cursor uses eax ebx ecx edx esi
  812.     call tl_get_display_cur_pos ;eax = cursor pos in screen
  813.     cmp eax,0
  814.     jl .end_f ;ªãàá®à ­ å®¤¨âáï ¢ëè¥ ®ª­ , ¢ ®¡« á⨠¯à®ªàã祭­®© áªà®««¨­£®¬
  815.  
  816.     mov ebx,tl_box_left
  817.     shl ebx,16
  818.     mov bx,tl_img_cx
  819.     xor ecx,ecx
  820.     mov cx,tl_img_cy
  821.     imul ecx,eax
  822.     add ecx,tl_box_top
  823.     add cx,tl_capt_cy
  824.  
  825.     ;crop image if on the border
  826.     cmp esi,ecx ;¥á«¨ ªãàá®à ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
  827.     jl .end_f
  828.  
  829.     sub esi,ecx
  830.     shl ecx,16
  831.     mov cx,tl_img_cy
  832.     cmp si,tl_img_cy
  833.     jge @f
  834.       mov cx,si ;¥á«¨ ªãàá®à ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
  835.     @@:
  836.  
  837.     mov edx,tl_col_bkg
  838.     mcall 13 ;à¨á㥬 ¯à®á⮩ ¯àאַ㣮«ì­¨ª á ä®­®¢ë¬ 梥⮬
  839.  
  840.     .end_f:
  841.   ret
  842. endp
  843.  
  844. ;¡¥à¥â ¯®§¨æ¨î ªãàá®à , ®â­®á¨â¥«ì­® íªà ­ 
  845. ;input:
  846. ; edi = pointer to TreeInfo struct
  847. ;output:
  848. ; eax = index
  849. align 4
  850. tl_get_display_cur_pos:
  851.    mov eax,tl_cur_pos
  852.    cmp tl_p_scroll,0
  853.    je @f
  854.      push ebx
  855.        mov ebx,tl_p_scroll
  856.        mov ebx,dword[ebx+sb_offs_position]
  857.        sub eax,ebx ;®â­¨¬ ¥¬ ¯®§¨æ¨î áªà®««¨­£ 
  858.      pop ebx
  859.   @@:
  860.   ret
  861.  
  862. ;à¨áã¥â 㧥« á: ª à⨭ª®©, ¯®¤¯¨áìî, ¨ª®­ª®© ®âªàëâ¨ï/§ ªàëâ¨ï ¨ «¨­¨ï¬¨ ª த¨â. 㧫ã
  863. ;input:
  864. ; eax = node position
  865. ; edx = pointer to some node struct
  866. ; edi = pointer to 'TreeList' struct
  867. ; esi = coord of bottom border
  868. align 4
  869. proc tl_draw_node uses eax ebx ecx edx esi
  870.         mov ebx,1 ;1 - ¬¥áâ® ¯®¤ ªãàá®à
  871.         bt tl_style,2 ;tl_list_box_mode
  872.         jc @f
  873.                 inc ebx ;+1 - ¬¥áâ® ¯®¤ §­ ª +,-
  874.                 add bl,byte[edx+2] ;¤®¡ ¢«ï¥¬ ã஢¥­ì í«¥¬¥­â  ¤«ï ¥£® ãç¥â  ¢ «¥¢®¬ ®âáâ㯥 ¨ª®­ª¨
  875.         @@:
  876.         imul bx,tl_img_cx
  877.         add ebx,tl_box_left
  878.  
  879.         shl ebx,16
  880.         mov bx,tl_img_cx
  881.         xor ecx,ecx
  882.         mov cx,tl_img_cy
  883.         imul ecx,eax
  884.         add ecx,tl_box_top
  885.         add cx,tl_capt_cy
  886.  
  887.         ;crop image if on the border
  888.         cmp esi,ecx ;¥á«¨ 㧥« ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
  889.         jl .end_draw
  890.  
  891.         sub esi,ecx
  892.         shl ecx,16
  893.         mov cx,tl_img_cy
  894.         cmp si,tl_img_cy
  895.         jge @f
  896.                 mov cx,si ;¥á«¨ 㧥« ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
  897.                 jmp .crop ;¯à®¯ã᪠¥¬ à¨á®¢ ­¨¥ ­ ¤¯¨á¨, ª®â®à ï ᪮॥ ¢á¥£® ⮦¥ ¢ë«¥§¥â §  ­¨¦­îî £à ­¨æã
  898.         @@:
  899.                 call tl_draw_node_caption
  900.         .crop:
  901.         mov esi,ecx ;save ecx
  902.  
  903.         cmp tl_data_img,0
  904.         jne .draw_img_n
  905.                 push edx
  906.                 mov edx,tl_col_txt
  907.                 mcall 13 ;draw node rect
  908.         pop edx
  909.         jmp @f
  910.         .draw_img_n:
  911.         push ebx edx esi
  912.                 xor esi,esi
  913.                 mov si,word[edx] ;get icon type
  914.                 mov edx,ebx
  915.                 ror ecx,16
  916.                 mov dx,cx
  917.                 mov cx,bx
  918.                 ror ecx,16
  919.                 mov ebx,3 ;rgb = 3 bytes
  920.                 imul bx,tl_img_cx
  921.                 imul bx,tl_img_cy
  922.                 imul ebx,esi ;esi = icon index
  923.                 add ebx,tl_data_img
  924.  
  925.                 mcall 7 ;draw node icon '-'
  926.         pop esi edx ebx
  927.         @@:
  928.  
  929.         mov al,byte[edx+2] ;draw minus '-'
  930.         mov ecx,tl_data_nodes
  931.         add ecx,sizeof.TreeList
  932.  
  933.         mov ah,10 ;get icon index '+' or '-' ?
  934.         cmp byte[edx+3],1
  935.         jne .close
  936.                 dec ah
  937.         .close:
  938.  
  939.         call tl_draw_node_icon_opn_clo ;à¨á®¢ ­¨¥ ¨ª®­ª¨ ®âªàë⮣® ¨«¨ § ªàë⮣® 㧫 
  940.         bt tl_style,1
  941.         jae .end_draw
  942.                 call tl_draw_node_icon_par_lin ;à¨á®¢ ­¨¥ «¨­¨¨ ª த¨â¥«ì᪮¬ã í«¥¬¥­âã
  943.                 call tl_draw_node_icon_par_lin_up ;à¨á®¢ ­¨¥ ¢¥à⨪ «ì­®© «¨­¨¨ ª த¨â¥«ì᪮¬ã í«¥¬¥­âã
  944.         .end_draw:
  945.         ret
  946. endp
  947.  
  948. ;à¨áã¥â ¨ª®­ª¨ ®âªàë⮣® ¨«¨ § ªàë⮣® 㧫  (®¡ëç­® + ¨«¨ -)
  949. ;input:
  950. ; al = ã஢¥­ì í«¥¬¥­â 
  951. ; ecx = pointer to 1 node struct
  952. ; edx = pointer to some node struct
  953. ;...
  954. align 4
  955. proc tl_draw_node_icon_opn_clo uses eax ebx ecx edx esi
  956.     inc al
  957.     call tl_iterat_next_all ;get next visible item
  958.     cmp edx,ecx
  959.     jle @f
  960.       mov ecx,esi ;load ecx
  961.       cmp al,byte[edx+2]
  962.       jne @f
  963.       ror ebx,16
  964.       sub bx,tl_img_cx
  965.       ror ebx,16
  966.       cmp tl_data_img_sys,0
  967.       jne .draw_img_s
  968.         mov edx,tl_col_txt
  969.         mcall 13 ;draw minus rect, if not system icons
  970.         jmp @f
  971.       .draw_img_s:
  972.       mov ecx,esi ;load ecx
  973.       mov edx,ebx
  974.       ror ecx,16
  975.       mov dx,cx
  976.       mov cx,bx
  977.       ror ecx,16
  978.       mov ebx,3 ;rgb = 3 bytes
  979.       imul bx,tl_img_cx
  980.       imul bx,tl_img_cy
  981.       shr eax,8
  982.       and eax,0xff
  983.       imul ebx,eax ;eax = icon index
  984.       add ebx,tl_data_img_sys
  985.       mcall 7 ;draw minus icon '-'
  986.     @@:
  987.   ret
  988. endp
  989.  
  990. ;à¨á®¢ ­¨¥ «¨­¨¨ ª த¨â¥«ì᪮¬ã í«¥¬¥­âã
  991. ;input:
  992. ; al = ã஢¥­ì í«¥¬¥­â 
  993. ; ecx = pointer to 1 node struct
  994. ; edx = pointer to some node struct
  995. ;...
  996. align 4
  997. tl_draw_node_icon_par_lin:
  998.   cmp byte[edx+3],1
  999.   je .close
  1000.   push eax ebx ecx edx esi
  1001.     cmp al,0
  1002.     je @f
  1003. ;    dec al
  1004. ;    call tl_iterat_perv ;get perv visible item
  1005.  
  1006.     call tl_iterat_next_all ;get next visible item
  1007.     cmp edx,ecx
  1008.     jle .line3 ;if end of list
  1009.       cmp al,byte[edx+2]
  1010.       jne .line3 ;jg ???
  1011.       mov eax,3 ;line in middle element
  1012.       jmp .line2
  1013.     .line3:
  1014.       mov eax,6 ;line in end element
  1015.     .line2:
  1016.  
  1017.       mov ecx,esi ;load ecx
  1018.       ror ebx,16
  1019.       sub bx,tl_img_cx
  1020.       ror ebx,16
  1021.       cmp tl_data_img_sys,0
  1022.       jne .draw_img_s
  1023.         mov edx,tl_col_txt
  1024.         mcall 13 ;draw minus rect, if not system icons
  1025.         jmp @f
  1026.       .draw_img_s:
  1027. ;      mov ecx,esi ;load ecx
  1028.       mov edx,ebx
  1029.       ror ecx,16
  1030.       mov dx,cx
  1031.       mov cx,bx
  1032.       ror ecx,16
  1033.       mov ebx,3 ;rgb = 3 bytes
  1034.       imul bx,tl_img_cx
  1035.       imul bx,tl_img_cy
  1036.  
  1037. ;      shr eax,8
  1038. ;      and eax,0xff
  1039.       imul ebx,eax ;eax = icon index
  1040.       add ebx,tl_data_img_sys
  1041.       mcall 7 ;draw line icon
  1042.     @@:
  1043.   pop esi edx ecx ebx eax
  1044.   .close:
  1045.   ret
  1046.  
  1047.  
  1048. ;input:
  1049. ; al = ã஢¥­ì í«¥¬¥­â 
  1050. ; ecx = pointer to 1 node struct
  1051. ; edx = pointer to some node struct
  1052. ; edi = pointer to 'TreeList' struct
  1053. align 4
  1054. tl_draw_node_icon_par_lin_up:
  1055.   push eax ebx ecx edx
  1056.   push esi
  1057.     cmp tl_data_img_sys,0 ;if not image
  1058.     je @f
  1059.     cmp al,0
  1060.     je @f
  1061.  
  1062.     xor esi,esi ;¢ si ¡ã¤¥¬ ­ áç¨â뢠âì ª®«-¢® ¨ª®­®ª, ­ã¦­ëå ¤«ï ¯à®à¨á®¢ª¨ «¨­¨¨
  1063. ;--- 横« ¤«ï ¢ëç¨á«¥­¨ï ª®««¨ç¥á⢠ ¢¥à⨪ «ì­ëå «¨­¨© ---
  1064.     .cycle0:
  1065.       call tl_iterat_perv ;get perv visible item
  1066.       cmp edx,ecx
  1067.       jle .cycle1 ;if begin of list
  1068.  
  1069.       cmp byte[edx+2],al
  1070.       jle .cycle0end ;ã஢¥­ì ¢¥àå­¥£® í«¥¬¥­â  ­¥ âॡã¥â ¯à®à¨á®¢ª¨
  1071.       inc si
  1072.       jmp .cycle0
  1073.     .cycle0end:
  1074.       cmp si,0 ;si = ª®«-¢® ¨ª®­®ª «¨­¨¨ ª®â®àë¥ ­ã¦­® ­ à¨á®¢ âì ᢥàåã
  1075.       je @f
  1076.       shl esi,16
  1077.  
  1078.       pop ecx ;esi->ecx
  1079.       push ecx ;save esi
  1080.  
  1081.       ror ebx,16
  1082.       sub bx,tl_img_cx
  1083.       ror ebx,16
  1084.  
  1085.       mov edx,ebx
  1086.       ror ecx,16
  1087.       mov dx,cx
  1088.       mov cx,bx
  1089.       ror ecx,16
  1090.       mov cx,tl_img_cy ;restore size y (if crop)
  1091.       mov ebx,3 ;rgb = 3 bytes
  1092.       imul bx,tl_img_cx
  1093.       imul bx,tl_img_cy
  1094.       add ebx,tl_data_img_sys
  1095.  
  1096.       add esi,tl_box_top
  1097.       add si,tl_capt_cy ;si = ¢¥àå­ïï £à ­¨æ  ®ª­ 
  1098.       mov eax,7
  1099. ;--- 横« ¤«ï à¨á®¢ ­¨ï ¢¥à⨪ «ì­®© «¨­¨¨ ---
  1100.       .cycle1:
  1101.       sub dx,tl_img_cy ;¯®¤­¨¬ ¥¬ ª®®à¤¨­ âã y ¢¢¥àå
  1102.       cmp dx,si
  1103.       jl @f
  1104.         cmp esi,0x10000
  1105.         jl @f
  1106.         int 0x40 ;draw line icon
  1107.         sub esi,0x10000 ;㬥­ìè ¥¬ áç¥â稪 ¨ª®­®ª
  1108.       jmp .cycle1
  1109.     @@:
  1110.   pop esi
  1111.   pop edx ecx ebx eax
  1112.   ret
  1113.  
  1114. ;input:
  1115. ; edi = pointer to TreeInfo struct
  1116. ;output:
  1117. ; eax = rows
  1118. align 4
  1119. tl_get_rows_count:
  1120.   push ecx edx
  1121.     mov eax,tl_box_height
  1122.     sub ax,tl_capt_cy
  1123.     xor ecx,ecx
  1124.     mov cx,tl_img_cy
  1125.     xor edx,edx
  1126.     div ecx
  1127.   pop edx ecx
  1128.   ret
  1129.  
  1130. ;input:
  1131. ; eax = node position
  1132. ; ebx = [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [img_cx]
  1133. ; ecx = [ª®®à¤¨­ â  ¯® ®á¨ y]*65536 + [img_cy]
  1134. ; edx = pointer to some node struct
  1135. ; edi = pointer to TreeInfo struct
  1136. align 4
  1137. tl_draw_node_caption:
  1138.     push ebx ecx edx esi
  1139.  
  1140.     xor esi,esi
  1141.     mov si,tl_info_size
  1142.     cmp si,tl_info_capt_offs
  1143.     jle @f ;if caption size <= 0
  1144.  
  1145.     push eax
  1146.       call tl_get_node_index ;eax = node index
  1147.       imul esi,eax
  1148.     pop eax
  1149.       add si,tl_info_capt_offs
  1150.       add esi,tl_data_info
  1151.       mov edx,esi
  1152.  
  1153.       shr ebx,16
  1154.       add bx,tl_img_cx ;ᤢ¨£ ¥¬ ­ ¤¯¨áì ¯® £®à¨§®­â «¨ --->
  1155.       add bx,3 ;®âáâã¯
  1156.       ;bx = coord. x
  1157.       call tl_strlen ;eax = strlen
  1158.       call tl_get_draw_text_len
  1159.       mov cx,bx
  1160.       ror ecx,16
  1161.       mov ebx,ecx
  1162.       add bx,tl_img_cy ;¢ëà ¢­¨¢¨­¨¥ ¯® ­¨¦­¥© £à ­¨æ¥ ¨ª®­ª¨
  1163.       sub bx,9 ;®â­¨¬ ¥¬ ¢ëá®âã ⥪áâ 
  1164.       mov ecx,tl_col_txt
  1165.       and ecx,0xffffff
  1166. ;      or ecx,0x80000000 ;text is ASCIIZ
  1167.       mcall 4
  1168.     @@:
  1169.     pop esi edx ecx ebx
  1170.   ret
  1171.  
  1172. ;input:
  1173. ; eax = strlen
  1174. ; ebx = text coord x
  1175. ;output:
  1176. ; esi = text len
  1177. align 4
  1178. tl_get_draw_text_len:
  1179.   push eax ecx edx
  1180.     mov esi,eax ;¡¥à¥¬ ¤«¨­­ã áâப¨
  1181.  
  1182.     mov eax,tl_box_left
  1183.     add eax,tl_box_width
  1184.     cmp eax,ebx
  1185.     jle .text_null ;¥á«¨ ¯®¤¯¨áì ¯®«­®áâìî ¢áï §  íªà ­®¬
  1186.     sub eax,ebx
  1187.     xor edx,edx
  1188.     mov ecx,6 ;è¨à¨­  á¨á⥬­®£® èà¨äâ 
  1189.     div ecx ;ᬮâਬ ᪮«ìª® ᨬ¢®«®¢ ¬®¦¥â ¯®¬¥áâ¨âìáï ­  íªà ­¥
  1190.  
  1191.     cmp esi,eax
  1192.     jl @f
  1193.       mov esi,eax ;¥á«¨ ¤«¨­­  ⥪áâ  ¬¥­ìè¥, 祬 ¢á¥ ¬¥áâ® ¯®¤ áâபã
  1194.     jmp @f
  1195.     .text_null:
  1196.       xor esi,esi
  1197.     @@:
  1198.   pop edx ecx eax
  1199.   ret
  1200.  
  1201. ;input:
  1202. ; esi = pointer to string
  1203. ;output:
  1204. ; eax = strlen
  1205. align 4
  1206. tl_strlen:
  1207.   mov eax,esi
  1208.   @@:
  1209.     cmp byte[eax],0
  1210.     je @f
  1211.     inc eax
  1212.     jmp @b
  1213.   @@:
  1214.   sub eax,esi
  1215.   ret
  1216.  
  1217. ;¤®¡ ¢¨âì 㧥«
  1218. ;input:
  1219. ; tlist - 㪠§ â¥«ì ­  áâàãªâãàã «¨áâ 
  1220. ; n_opt - ®¯æ¨¨ ¤®¡ ¢«¥­¨ï
  1221. ; n_info - 㪠§ â¥«ì ­  ¤®¡ ¢«ï¥¬ë¥ ¤ ­­ë¥
  1222. align 4
  1223. proc tl_node_add uses eax ebx ecx edx edi, tlist:dword, n_opt:dword, n_info:dword
  1224.     mov edi,dword[tlist]
  1225.  
  1226.     call tl_info_set_undo
  1227.  
  1228.     mov ebx,sizeof.TreeList
  1229.     imul ebx,tl_info_max_count
  1230.     add ebx,tl_data_nodes
  1231. ;--
  1232.     call tl_get_cur_node_index ;eax=po_t
  1233.     imul eax,sizeof.TreeList
  1234.     add eax,tl_data_nodes
  1235.     mov edx,eax
  1236.     call tl_move_perv
  1237.     call tl_get_node_index ;eax = index of pointer [edx]
  1238. ;--
  1239.     mov edx,sizeof.TreeList
  1240.     shl edx,1
  1241.     add edx,tl_data_nodes
  1242.     @@: ;for(i=2;i<nodeMax;i++)
  1243.       cmp dword [edx+12],0
  1244.       jne .u0
  1245.       cmp dword [edx+16],0
  1246.       jne .u0
  1247.  
  1248.         inc  tl_ch_tim
  1249.         mov ecx,dword[n_opt]
  1250.         ror ecx,16 ;cx = type
  1251.         mov word[edx],cx
  1252.  ;;;mov cl,byte[ebp+13]
  1253.  rol ecx,8 ;cl = close|open
  1254.  mov byte[edx+3],cl  ;node[i].clo
  1255.         mov   byte[edx+2], 0 ;node[i].lev=0
  1256.   bt tl_style,2 ;tl_list_box_mode
  1257.   jc .l_box_m
  1258.     mov cl,byte[n_opt]
  1259.     mov byte[edx+2],cl  ;node[i].lev
  1260.   .l_box_m:
  1261.         push tl_ch_tim       ;node[i].tc=ch_tim;
  1262.         pop  dword[edx+12]
  1263.         mov  dword[edx+4], eax ;node[i].perv=po_t;
  1264.         ;*** copy node data ***
  1265.         push esi
  1266.         xor ecx,ecx
  1267.         mov cx,tl_info_size
  1268.         mov esi,ecx
  1269.  
  1270.         push eax
  1271.           call tl_get_node_index ;eax = node index
  1272.           imul esi,eax
  1273.         pop eax
  1274.         add esi,tl_data_info
  1275.         mov edi,dword[n_info] ;pointer to node data
  1276.         xchg edi,esi
  1277.         rep movsb
  1278.  
  1279.         mov esi,edi
  1280.         mov edi,dword[tlist] ;restore edi
  1281.         mov cx,tl_info_capt_offs
  1282.         cmp cx,tl_info_size
  1283.         jge .no_text_data
  1284.  cmp tl_info_capt_len,0 ;¯à®¢¥à塞 ¥áâì «¨ ®£à ­¨ç¥­¨¥ ­  ¤«¨­­ã áâப¨
  1285.  je .no_len_ogran
  1286.    add cx,tl_info_capt_len
  1287.    and ecx,0xffff
  1288.    add esi,ecx
  1289.    mov cx,tl_info_size
  1290.    sub esi,ecx
  1291.  .no_len_ogran:
  1292.           dec esi
  1293.           mov byte[esi],0
  1294.         .no_text_data:
  1295.         pop esi ;restore esi
  1296.  
  1297.         mov ecx,eax
  1298.         imul ecx,sizeof.TreeList
  1299.         add ecx,tl_data_nodes ; *** ecx = node[po_t] ***
  1300.         add ecx,8   ; *** ecx = node[po_t].next ***
  1301.         push dword [ecx] ;node[i].next=node[po_t].next;
  1302.         pop dword [edx+8]
  1303.  
  1304.         call tl_get_node_index ;*** eax = i ***
  1305.         cmp eax,tl_info_max_count
  1306.         jge .u0
  1307.  
  1308.         mov [ecx],eax ;node[po_t].next=i; // áá뫪¨ ¯¥à¥­ ¯à ¢«ï¥¬
  1309.         mov ecx,[edx+8] ; *** ecx = node[i].next ***
  1310.         imul ecx,sizeof.TreeList
  1311.         add ecx,tl_data_nodes ; *** ecx = node[node[i].next] ***
  1312.         mov [ecx+4],eax ;node[node[i].next].perv=i;
  1313.  
  1314.         call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
  1315.     jmp @f
  1316.       .u0:
  1317.       add edx,sizeof.TreeList
  1318.       cmp edx,ebx ;enf of node memory ?
  1319.       jle @b
  1320.     @@:
  1321.         ret
  1322. endp
  1323.  
  1324. ;input:
  1325. ; edi = pointer to TreeInfo struct
  1326. align 4
  1327. proc tb_scrol_resize uses eax ecx edx
  1328.         cmp tl_p_scroll,0 ;®¡à ¡®âª  áªà®««¨­£ 
  1329.   je @f
  1330.     call tl_get_node_count ;eax = node count
  1331.     mov ecx,eax
  1332.     call tl_get_rows_count
  1333.     cmp ecx,eax
  1334.     jg .ye_sb
  1335.       xor ecx,ecx
  1336.     .ye_sb:
  1337.  
  1338.     mov edx,tl_p_scroll
  1339.     mov dword[edx+sb_offs_cur_area],eax
  1340.     mov dword[edx+sb_offs_max_area],ecx
  1341.                 stdcall scroll_bar_vertical.draw,edx
  1342.   @@:
  1343. ret
  1344. endp
  1345.  
  1346. ;input:
  1347. ;n_info - pointer to node info
  1348. align 4
  1349. proc tl_node_set_data uses eax ecx edx edi esi, tlist:dword, n_info:dword
  1350.     mov edi,dword[tlist]
  1351.     call tl_get_cur_node_index ;eax=po_t
  1352.     cmp eax,2
  1353.     jl @f
  1354.       xor ecx,ecx
  1355.       mov cx,tl_info_size
  1356.       imul eax,ecx
  1357.       add eax,tl_data_info
  1358.       mov edi,eax
  1359.       mov esi,dword[n_info] ;pointer to node data
  1360.       rep movsb
  1361.  
  1362.       mov esi,edi
  1363.       mov edi,dword[tlist] ;restore edi
  1364.       mov cx,tl_info_capt_offs
  1365.       cmp cx,tl_info_size
  1366.       jge .no_text_data
  1367.         mov ax,tl_info_capt_len ;¯à®¢¥à塞 ¥áâì «¨ ®£à ­¨ç¥­¨¥ ­  ¤«¨­­ã ⥪áâ 
  1368.         cmp ax,0
  1369.         je .no_limit
  1370.         add cx,ax ;cx = tl_info_capt_offs + tl_info_capt_len
  1371.         and ecx,0xffff
  1372.         xor eax,eax
  1373.         mov ax,tl_info_size
  1374.         cmp eax,ecx
  1375.         jl .no_limit ;¯®«ì§®¢ â¥«ì § ¤ « ᫨誮¬ ¡®«ìèãî ¤«¨­­ã ⥪áâ 
  1376.         add esi,ecx
  1377.         sub esi,eax
  1378.         .no_limit:
  1379.           dec esi
  1380.           mov byte[esi],0 ;®¡­ã«ï¥¬ ¯®á«¥¤­¨© ᨬ¢®« ¯®¤¯¨á¨, çâ®-¡ë ­¥ £«î稫® ¥á«¨ ¯®«ì§®¢ â¥«ì § ¤ « ­¥¯à ¢¨«ì­ãî áâàãªâãàã
  1381.       .no_text_data:
  1382.  
  1383.     @@:
  1384.         ret
  1385. endp
  1386.  
  1387. ;¢§ïâì 㪠§ â¥«ì ­  ¤ ­­ë¥ 㧫  ¯®¤ ªãàá®à®¬
  1388. ;input:
  1389. ; tlist - pointer to 'TreeList' struct
  1390. ;output:
  1391. ; eax - pointer to node data
  1392. align 4
  1393. proc tl_node_get_data uses ecx edi, tlist:dword
  1394.         mov edi,dword[tlist]
  1395.         call tl_get_cur_node_index ;eax=po_t
  1396.         cmp eax,2
  1397.         jl @f
  1398.                 movzx ecx,tl_info_size
  1399.                 imul eax,ecx
  1400.                 add eax,tl_data_info
  1401.                 jmp .end_f ;return node data pointer
  1402.         @@:
  1403.         xor eax,eax
  1404.         .end_f:
  1405.   ret
  1406. endp
  1407.  
  1408. ;¢§ïâì 㪠§ â¥«ì ­  áâàãªâãàã 㧫  ¢ 㪠§ ­­®© ¯®§¨æ¨¨
  1409. ;input:
  1410. ; tlist - pointer to 'TreeList' struct
  1411. ; node_ind - node index
  1412. ;output:
  1413. ; eax - pointer to node info
  1414. align 4
  1415. proc tl_node_poi_get_info uses ebx ecx edi, tlist:dword, node_ind:dword
  1416.         mov edi,dword[tlist]
  1417.         mov ebx,dword[node_ind]
  1418.  
  1419.         ;cycle to nodes
  1420.         mov eax,tl_data_nodes
  1421.         mov ecx,eax
  1422.         add ecx,sizeof.TreeList
  1423.         @@:
  1424.                 call tl_iterat_next_all
  1425.                 cmp eax,ecx
  1426.                 jle @f
  1427.                 dec ebx
  1428.                 cmp ebx,0
  1429.                 jg @b
  1430.                 jmp .find
  1431.         @@:
  1432.                 xor eax,eax
  1433.         .find:
  1434.         ret
  1435. endp
  1436.  
  1437. ;¢§ïâì 㪠§ â¥«ì ­  á«¥¤ãéãî áâàãªâãàã 㧫 
  1438. ;input:
  1439. ; tlist - pointer to 'TreeList' struct
  1440. ; node_p - node param struct
  1441. ;output:
  1442. ; eax - pointer to next node struct
  1443. align 4
  1444. proc tl_node_poi_get_next_info uses ecx edx edi, tlist:dword, node_p:dword
  1445.         mov edi,dword[tlist]
  1446.         mov edx,dword[node_p]
  1447.  
  1448.         mov ecx,tl_data_nodes
  1449.         add ecx,sizeof.TreeList
  1450.  
  1451.         call tl_iterat_next_all
  1452.         cmp edx,ecx
  1453.         jg @f
  1454.                 xor edx,edx
  1455.         @@:
  1456.         mov eax,edx
  1457.         ret
  1458. endp
  1459.  
  1460. ;¢§ïâì 㪠§ â¥«ì ­  ¤ ­­ë¥ 㧫 
  1461. ;input:
  1462. ; tlist - pointer to 'TreeList' struct
  1463. ; node_p - node param struct
  1464. ;output:
  1465. ; eax - pointer
  1466. align 4
  1467. proc tl_node_poi_get_data uses ecx edx edi, tlist:dword, node_p:dword
  1468.         mov edi,dword[tlist]
  1469.         mov edx,dword[node_p]
  1470.  
  1471.     call tl_get_node_index ;eax = node index
  1472.     cmp eax,2
  1473.     jl @f
  1474.       xor ecx,ecx
  1475.       mov cx,tl_info_size
  1476.       imul eax,ecx
  1477.                 add eax,tl_data_info
  1478.                 jmp .end_f ;return node data pointer
  1479.     @@:
  1480.                 xor eax,eax ;¢®§¢à é ¥¬ 0 ¢ á«ãç ¥ ­¥ 㤠筮£® ¯®¨áª 
  1481.         .end_f:
  1482.         ret
  1483. endp
  1484.  
  1485. ;¡¥à¥â ¯®§¨æ¨î ¯®¤ ªãàá®à®¬
  1486. ;input:
  1487. ; edi = pointer 'tl' struct
  1488. ;output:
  1489. ; eax = index of current node
  1490. align 4
  1491. proc tl_get_cur_node_index uses ecx edx
  1492.         ;cycle to nodes
  1493.         xor eax,eax
  1494.         mov edx,tl_data_nodes
  1495.         mov ecx,edx
  1496.         add ecx,sizeof.TreeList
  1497.         @@:
  1498.                 call tl_iterat_next
  1499.                 cmp edx,ecx
  1500.                 jle @f
  1501.                 cmp eax,tl_cur_pos
  1502.                 je @f
  1503.                 inc eax
  1504.                 jmp @b
  1505.         @@:
  1506.         mov eax,edx
  1507.         sub eax,tl_data_nodes
  1508.         xor edx,edx
  1509.         mov ecx,sizeof.TreeList
  1510.         div ecx
  1511.         ret
  1512. endp
  1513.  
  1514. ;¡¥à¥â ¯®§¨æ¨î 㪠§ ­­®£® ᨬ¢®« 
  1515. ;input:
  1516. ; edx = pointer node memory
  1517. ; edi = pointer 'tl' struct
  1518. ;output:
  1519. ; eax = struct index of current node
  1520. align 4
  1521. tl_get_node_index:
  1522.         push ecx edx
  1523.         mov eax,edx
  1524.         sub eax,tl_data_nodes
  1525.         xor edx,edx
  1526.         mov ecx,sizeof.TreeList
  1527.         div ecx
  1528.         pop edx ecx
  1529.         ret
  1530.  
  1531. ;㤠«¨âì 㧥«
  1532. align 4
  1533. proc tl_node_delete uses eax edx edi, tlist:dword
  1534.         mov edi,dword[tlist]
  1535.         call tl_get_cur_node_index ;eax=po_t
  1536.         cmp eax,2
  1537.         jl @f
  1538.                 imul eax,sizeof.TreeList
  1539.                 add eax,tl_data_nodes
  1540.                 mov edx,eax
  1541.                 inc tl_ch_tim
  1542.                 mov eax,tl_ch_tim
  1543.                 mov dword[edx+16],eax
  1544.                 call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
  1545.         @@:
  1546.         ret
  1547. endp
  1548.  
  1549. ;¯®áâ ¢¨âì ªãàá®à ­  ¯¥à¢ë© 㧥«
  1550. align 4
  1551. proc tl_cur_beg uses edi, tlist:dword
  1552.         mov edi,dword[tlist]
  1553.         mov tl_cur_pos,0
  1554.         cmp tl_p_scroll,0
  1555.         je @f
  1556.                 mov edi,tl_p_scroll
  1557.                 mov dword[edi+sb_offs_position],0
  1558.                 stdcall scroll_bar_vertical.draw, edi
  1559.         @@:
  1560.         ret
  1561. endp
  1562.  
  1563. ;¯¥à¥­¥á⨠ªãàá®à ­  1 ¯®§¨æ¨î ­¨¦¥
  1564. align 4
  1565. proc tl_cur_next uses eax ebx edi esi, tlist:dword
  1566.     mov edi,dword[tlist]
  1567.     call tl_get_node_count ;eax = node count
  1568.     ;inc eax
  1569.     cmp tl_cur_pos,eax
  1570.     jge .no_redraw
  1571.       mov esi,tl_box_top
  1572.       add esi,tl_box_height ;esi = coord bottom border
  1573.       call tl_draw_null_cursor ;áâ¨à ¥¬ ªãàá®à
  1574.       inc tl_cur_pos
  1575.  
  1576.     cmp tl_p_scroll,0 ;if not scrol struct
  1577.     je @f
  1578.     call tl_get_rows_count ;eax = rows count
  1579.     mov ebx,tl_p_scroll
  1580.     add eax,dword[ebx+sb_offs_position]
  1581.     cmp tl_cur_pos,eax
  1582.     jl @f
  1583.       inc dword[ebx+sb_offs_position]
  1584.       stdcall scroll_bar_vertical.draw,ebx
  1585.  
  1586.       stdcall tl_draw,dword[tlist] ;¯®«­ ï ¯¥à¥à¨á®¢ª  ®ª­ 
  1587.       jmp .no_redraw
  1588.     @@:
  1589.       mov edi,dword[tlist] ;restore edi
  1590.       call tl_draw_cursor ;¯¥à¥à¨á®¢ª  ªãàá®à 
  1591.       call tl_draw_caption_cur_pos
  1592.     .no_redraw:
  1593.         ret
  1594. endp
  1595.  
  1596. ;¡¥à¥â ç¨á«® ¢á¥å ¢¨¤¨¬ëå 㧫®¢ (­¥ áç¨â ï § ªàëâëå ¤®ç¥à­¨å)
  1597. ;input:
  1598. ; edi = pointer 'tl' struct
  1599. ;output:
  1600. ; eax = struct index of current node
  1601. align 4
  1602. tl_get_node_count:
  1603. push ecx edx
  1604.         ;cycle to nodes
  1605.         xor eax,eax
  1606.         mov edx,tl_data_nodes
  1607.         mov ecx,edx
  1608.         add ecx,sizeof.TreeList
  1609.         @@:
  1610.                 call tl_iterat_next
  1611.                 cmp edx,ecx
  1612.                 jle @f
  1613.                 inc eax
  1614.                 jmp @b
  1615.         @@:
  1616. pop edx ecx
  1617.         ret
  1618.  
  1619. ;¡¥à¥â ç¨á«® ¢á¥å ¢¨¤¨¬ëå 㧫®¢ (áç¨â ï § ªàëâë¥ ¤®ç¥à­¨¥)
  1620. ;input:
  1621. ; edi = pointer 'tl' struct
  1622. ;output:
  1623. ; eax = struct index of current node
  1624. align 4
  1625. tl_get_node_count_all:
  1626. push ecx edx
  1627.         ;cycle to nodes
  1628.         xor eax,eax
  1629.         mov edx,tl_data_nodes
  1630.         mov ecx,edx
  1631.         add ecx,sizeof.TreeList
  1632.         @@:
  1633.                 call tl_iterat_next_all
  1634.                 cmp edx,ecx
  1635.                 jle @f
  1636.                 inc eax
  1637.                 jmp @b
  1638.         @@:
  1639. pop edx ecx
  1640.         ret
  1641.  
  1642. ;¯¥à¥­¥á⨠ªãàá®à ­  1 ¯®§¨æ¨î ¢ëè¥
  1643. align 4
  1644. proc tl_cur_perv uses eax edi esi, tlist:dword
  1645.         mov edi,dword[tlist]
  1646.         cmp tl_cur_pos,0
  1647.         je .no_redraw
  1648.                 mov esi,tl_box_top
  1649.                 add esi,tl_box_height ;esi = coord bottom border
  1650.                 call tl_draw_null_cursor ;áâ¨à ¥¬ ªãàá®à
  1651.                 dec tl_cur_pos ;¤¢¨£ ¥¬ ªãàá®à ¢¢¥àå
  1652.  
  1653.                 cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
  1654.                 je @f
  1655.                 mov eax,tl_p_scroll
  1656.                 cmp dword[eax+sb_offs_position],0 ;¥á«¨ áªà®««¨­£ ­  ¢¥àåã, ¢ë室¨¬
  1657.                 je @f
  1658.                 mov edi,tl_cur_pos
  1659.                 cmp edi,dword[eax+sb_offs_position] ;¥á«¨ ªãàá®à ã襫 ¢ëè¥ áªà®««¨­£ , ⮣¤  ®¯ã᪠¥¬ áªà®««¨­£
  1660.                 jge @f
  1661.                         dec dword[eax+sb_offs_position]
  1662.                         stdcall scroll_bar_vertical.draw, eax
  1663.                         stdcall tl_draw, dword[tlist] ;¯®«­ ï ¯¥à¥à¨á®¢ª  ®ª­ 
  1664.                         jmp .no_redraw
  1665.                 @@:
  1666.                         mov edi,dword[tlist] ;restore edi
  1667.                         call tl_draw_cursor ;¯¥à¥à¨á®¢ª  ªãàá®à 
  1668.                         call tl_draw_caption_cur_pos
  1669.         .no_redraw:
  1670.         ret
  1671. endp
  1672.  
  1673. ;¯¥à¥­¥á⨠ªãàá®à ­  1 áâà ­¨æã ¢ëè¥
  1674. align 4
  1675. proc tl_cur_page_up uses eax edi esi, tlist:dword
  1676.     mov edi,dword[tlist]
  1677.  
  1678.     cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
  1679.     je .no_redraw
  1680.  
  1681.     mov esi,tl_p_scroll
  1682.     call tl_get_rows_count ;eax = rows count
  1683.  
  1684.     cmp tl_cur_pos,0
  1685.     jne @f
  1686.     cmp dword[esi+sb_offs_position],0 ;¥á«¨ áªà®««¨­£ ­  ¢¥àåã, ¢ë室¨¬
  1687.     jne @f
  1688.       jmp .no_redraw
  1689.     @@:
  1690.       cmp tl_cur_pos,eax ;¯à®¢¥à塞 ¯®§¨æ¨î ªãàá®à  ¨ ª®«-¢® á⮪ ­  áâà ­¨æ¥
  1691.       jl @f ;¥á«¨ ¬¥­ìè¥, â® ¯à¨à ¢­¨¢ ¥¬ ª 0, çâ®-¡ë ­¥ ®â­ïâì ¡®«ìè¥ ç¥¬ ­ ¤®
  1692.         sub tl_cur_pos,eax
  1693.         jmp .cursor
  1694.       @@:
  1695.         mov tl_cur_pos,0
  1696.       .cursor:
  1697.       cmp dword[esi+sb_offs_position],eax
  1698.       jl @f
  1699.         sub dword[esi+sb_offs_position],eax
  1700.         jmp .scroll
  1701.       @@:
  1702.         mov dword[esi+sb_offs_position],0
  1703.       .scroll:
  1704.       ;¯¥à¥à¨á®¢ª¨ ®ª­  ¨ áªà®««¨­£ 
  1705.       stdcall tl_draw, edi ;draw window
  1706.       stdcall scroll_bar_vertical.draw, esi
  1707.     .no_redraw:
  1708.         ret
  1709. endp
  1710.  
  1711. ;¯¥à¥­¥á⨠ªãàá®à ­  1 áâà ­¨æã ­¨¦¥
  1712. align 4
  1713. proc tl_cur_page_down uses eax ebx ecx edi esi, tlist:dword
  1714. ;eax - ª®«-¢® áâப ­  áâà ­¨æ¥
  1715. ;ebx - ¬ ªá. ¯®§¨æ¨ï ªãàá®à 
  1716. ;ecx - ¬ ªá. ¯®§¨æ¨ï áªà®««¨­£ 
  1717.     mov edi,dword[tlist]
  1718.  
  1719.     cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
  1720.     je .no_redraw
  1721.  
  1722.     mov esi,tl_p_scroll
  1723.     call tl_get_node_count ;eax = node count
  1724.     mov ebx,eax
  1725.     call tl_get_rows_count ;eax = rows count
  1726.  
  1727.     mov ecx,ebx
  1728.     inc ecx ;¥á«¨ ­¨¦­¨© 㧥« ¢¨¤¥­ ­  ¯®«®¢¨­ã
  1729.     cmp ecx,eax ;if (ecx>eax) { ecx=ecx-eax } else { ecx=0 }
  1730.     jl @f
  1731.       sub ecx,eax ;㬥­ìè ¥¬ ¬ ªá¨¬ «ì­ãî ¯®§¨æ¨î áªà®««¨­£ , â ª çâ®-¡ë ¡ë«¨ ¢¨¤­ë ¯®á«¥¤­¨¥ 㧫ë
  1732.       jmp .control
  1733.     @@:
  1734.       xor ecx,ecx ;ecx=0 - ¢á¥ ã§«ë ¢« §ïâ ¢ íªà ­, áªà®««¨­£ ­¥ ­ã¦¥­
  1735.     .control:
  1736.  
  1737.     cmp tl_cur_pos,ebx ;ªãàá®à ¢­¨§ã ?
  1738.     jl @f
  1739.     cmp dword[esi+sb_offs_position],ecx ;áªà®««¨­£ ¢­¨§ã ?
  1740.     jl @f
  1741.       jmp .no_redraw
  1742.     @@:
  1743.  
  1744.       add tl_cur_pos,eax ;¯¥à¥¬¥é ¥¬ ªãàá®à
  1745.       cmp tl_cur_pos,ebx
  1746.       jl @f
  1747.         mov tl_cur_pos,ebx
  1748.       @@:
  1749.  
  1750.       add dword[esi+sb_offs_position],eax ;¯¥à¥¬¥é ¥¬ áªà®««¨­£
  1751.       cmp dword[esi+sb_offs_position],ecx
  1752.       jl @f
  1753.         mov dword[esi+sb_offs_position],ecx
  1754.       @@:
  1755.  
  1756.       ;¯¥à¥à¨á®¢ª¨ ®ª­  ¨ áªà®««¨­£ 
  1757.       stdcall tl_draw, edi ;draw window
  1758.       stdcall scroll_bar_vertical.draw, esi
  1759.     .no_redraw:
  1760.         ret
  1761. endp
  1762.  
  1763. ;®âªàëâì/§ ªàëâì 㧥« (à ¡®â ¥â á 㧫 ¬¨ ª®â®àë¥ ¨¬¥îâ ¤®ç¥à­¨¥ 㧫ë)
  1764. align 4
  1765. proc tl_node_close_open uses eax edx edi, tlist:dword
  1766.         mov edi,dword[tlist]
  1767.         call tl_get_cur_node_index ;eax = ¯®§¨æ¨ï 㧫  ­  ª®â®à®¬ á⮨⠪ãàá®à
  1768.         cmp eax,2 ;ªãàá®à á⮨⠭  㧫¥ ?
  1769.         jl @f
  1770.                 imul eax,sizeof.TreeList
  1771.                 add eax,tl_data_nodes
  1772.                 ;eax = 㪠§ â¥«ì ­  áâàãªâãàã 㧫  ¢ë¡à ­­®£® ªãàá®à®¬
  1773.                 push eax
  1774.                         stdcall tl_node_poi_get_next_info, edi,eax
  1775.                         mov edx,eax ;edx = 㪠§ â¥«ì ­  áâàãªâãàã 㧫  ª®â®àë© ¨¤¥â ¯®á«¥ 㧫  eax
  1776.                 pop eax
  1777.                 cmp edx,0 ;¥áâì «¨ ã§«ë ­¨¦¥ ¢ë¡à ­­®£® ­ ¬¨ ?
  1778.                 je @f
  1779.                         mov dl,byte[edx+2] ;¡¥à¥¬ ã஢¥­ì ­¨¦­¥£® 㧫 
  1780.                         cmp byte[eax+2],dl ;+2 = .lev
  1781.                         jge @f ;¥á«¨ ­¨¦­¨¥ ã§«ë ¬¥­ì襣® ã஢­ï, §­ ç¨â ®­¨ ­¥ ¤®ç¥à­¨¥, ª®­¥æ ä㭪樨
  1782.                                 xor byte[eax+3],1 ;+3 = .clo *** ®âªàë⨥/§ ªàë⨥ 㧫  ***
  1783.                                 call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
  1784.  
  1785.                                 stdcall tl_draw, edi ;®¡­®¢«¥­¨¥ ®ª­ 
  1786.         @@:
  1787.         ret
  1788. endp
  1789.  
  1790. ;㢥«¨ç¨âì ã஢¥­ì
  1791. align 4
  1792. proc tl_node_lev_inc uses eax ecx edx edi, tlist:dword
  1793.         mov edi,dword[tlist]
  1794.         bt tl_style,2 ;tl_list_box_mode
  1795.         jc @f
  1796.         call tl_get_cur_node_index ;eax=po_t
  1797.         cmp eax,2
  1798.         jl @f
  1799.                 mov ecx,tl_data_nodes
  1800.                 imul eax,sizeof.TreeList
  1801.                 add eax,ecx ;eax = pointer to some node struct
  1802.                 add ecx,sizeof.TreeList ;ecx = pointer to 1 node struct
  1803.  
  1804.                 mov edx,eax
  1805.                 call tl_iterat_perv ;¯à®¢¥à塞 ¥áâì «¨ ¢¥àå­¨© 㧥«
  1806.                 cmp edx,ecx
  1807.                 jle @f ;¥á«¨ ¢¥àå­¥£® 㧫  ­¥â ⮠⥪ã騩 㧥« ­¥ ¤¢¨£ ¥¬
  1808.                 mov cl,byte[edx+2] ;¡¥à¥¬ ã஢¥­ì த¨â¥«ì᪮£® 㧫 
  1809.                 inc cl ;¤®¡ ¢«ï¥¬ 1 ¨ ¯®«ãç ¥¬ ¬ ªá¨¬ «ì­®¥ §­ ç¥­¨¥
  1810.                 cmp byte[eax+2],cl
  1811.                 jge @f
  1812.                         inc byte[eax+2] ;㢥«¨ç¨¢ ¥¬ §­ ç¥­¨¥ 㧫 
  1813.         @@:
  1814.         ret
  1815. endp
  1816.  
  1817. ;㬥­ìè¨âì ã஢¥­ì
  1818. align 4
  1819. proc tl_node_lev_dec uses eax edi, tlist:dword
  1820.         mov edi,dword[tlist]
  1821.         call tl_get_cur_node_index ;eax=po_t
  1822.         cmp eax,2
  1823.         jl @f
  1824.                 imul eax,sizeof.TreeList
  1825.                 add eax,tl_data_nodes
  1826.                 cmp byte[eax+2],0
  1827.                 je @f
  1828.                 dec byte[eax+2]
  1829.         @@:
  1830.         ret
  1831. endp
  1832.  
  1833. ;¯¥à¥¬¥é ¥¬ 㧥« ¢¢¥àå
  1834. align 4
  1835. proc tl_node_move_up uses eax ebx ecx edx edi esi, tlist:dword
  1836.         mov edi,dword[tlist]
  1837.         call tl_get_cur_node_index ;eax=po_t
  1838.         cmp eax,2
  1839.         jl @f
  1840.                 mov ebx,eax ;copy index of node struct
  1841.                 mov edx,tl_data_nodes
  1842.                 mov ecx,edx
  1843.                 add ecx,sizeof.TreeList
  1844.                 imul eax,sizeof.TreeList
  1845.                 add eax,edx ;eax = pointer to 2 node struct
  1846.                 mov edx,eax ;edx = pointer to 2 node struct
  1847.                 mov esi,eax ;esi = pointer to 2 node struct
  1848.                 call tl_iterat_perv ;edx = pointer to 1 node struct
  1849.                 call tl_get_node_index ;eax = index of 1 node struct
  1850.                 cmp edx,ecx
  1851.                 jle @f
  1852.                         cmp dword[edx+8],ebx ;+8 next
  1853.                         jne .po8
  1854.                                 call tl_node_move_po6 ;ã§«ë ¨¤ãâ ¯®¤àï¤ ¬¥­ï¥¬ 6 ááë«®ª
  1855.                                 jmp .cur_mov
  1856.                         .po8:
  1857.                                 call tl_node_move_po8 ;ã§«ë ¨¤ãâ ­¥ ¯®¤àï¤ ¬¥­ï¥¬ 8 ááë«®ª
  1858.                         .cur_mov:
  1859.                                 push dword edi
  1860.                                 call tl_cur_perv
  1861.                                 push dword edi
  1862.                                 call tl_draw
  1863.         @@:
  1864.         ret
  1865. endp
  1866.  
  1867. ;¯¥à¥¬¥é ¥¬ 㧥« ¢­¨§
  1868. align 4
  1869. proc tl_node_move_down uses eax ebx ecx edx edi esi, tlist:dword
  1870.         mov edi,dword[tlist]
  1871.         call tl_get_cur_node_index ;eax=po_t
  1872.         cmp eax,2
  1873.         jl @f
  1874.                 mov ebx,eax ;copy index of node struct
  1875.                 mov edx,tl_data_nodes
  1876.                 mov ecx,edx
  1877.                 add ecx,sizeof.TreeList
  1878.                 imul eax,sizeof.TreeList
  1879.                 add eax,edx ;eax = pointer to 1 node struct
  1880.                 mov edx,eax ;edx = pointer to 1 node struct
  1881.                 mov esi,eax ;esi = pointer to 1 node struct
  1882.                 call tl_iterat_next ;edx = pointer to 2 node struct
  1883.                 call tl_get_node_index ;eax = index of 2 node struct
  1884.                 cmp edx,ecx
  1885.                 jle @f
  1886.                         cmp dword[esi+8],eax ;+8 next
  1887.                         jne .po8
  1888.                                 xchg eax,ebx ;¬¥­ï¥ ¯®à冷ª á«¥¤®¢ ­¨ï § ¬¥­ï¥¬ëå 㧫®¢
  1889.                                 xchg edx,esi
  1890.                                 call tl_node_move_po6 ;ã§«ë ¨¤ãâ ¯®¤àï¤ ¬¥­ï¥¬ 6 ááë«®ª
  1891.                                 jmp .cur_mov
  1892.                         .po8: ;  âãâ ¯®à冷ª á«¥¤®¢ ­¨ï 㧫®¢ ­¥ ¬¥­ï¥¬
  1893.                                 call tl_node_move_po8 ;ã§«ë ¨¤ãâ ­¥ ¯®¤àï¤ ¬¥­ï¥¬ 8 ááë«®ª
  1894.                         .cur_mov:
  1895.                                 stdcall tl_cur_next, edi
  1896.                                 stdcall tl_draw, edi
  1897.         @@:
  1898.         ret
  1899. endp
  1900.  
  1901. align 4
  1902. tl_node_move_po6:
  1903.   mov ecx,edx ;save node pointer
  1904.   call tl_move_perv
  1905.   mov dword[edx+8],ebx
  1906.  
  1907.   mov edx,esi
  1908.   call tl_move_next
  1909.   mov dword[edx+4],eax
  1910.   mov edx,ecx ;restore node pointer
  1911.  
  1912.   ;+4 perv
  1913.   mov ecx,dword[edx+4]
  1914.   mov dword[esi+4],ecx
  1915.   ;+8 next
  1916.   mov ecx,dword[esi+8]
  1917.   mov dword[edx+8],ecx
  1918.  
  1919.   mov dword[edx+4],ebx
  1920.   mov dword[esi+8],eax
  1921.   ret
  1922.  
  1923. ;input
  1924. ;eax = index 1 node struct
  1925. ;ebx = index 2 node struct
  1926. ;edx = pointer 1 node struct
  1927. ;esi = pointer 2 node struct
  1928. ;edi = pointer to 'TreeList' struct
  1929. ;output:
  1930. ;eax = ?
  1931. ;ebx = ?
  1932. ;ecx = ?
  1933. align 4
  1934. tl_node_move_po8:
  1935. ;  push ecx
  1936.   mov ecx,edx ;save node pointer
  1937.   call tl_move_perv
  1938.   mov dword[edx+8],ebx
  1939.   mov edx,ecx
  1940.   call tl_move_next
  1941.   mov dword[edx+4],ebx
  1942.   mov edx,esi
  1943.   call tl_move_perv
  1944.   mov dword[edx+8],eax
  1945.   mov edx,esi
  1946.   call tl_move_next
  1947.   mov dword[edx+4],eax
  1948.   mov edx,ecx ;restore node pointer
  1949. ;  pop ecx
  1950.  
  1951.   ;+4 perv
  1952.   mov eax,dword[edx+4]
  1953.   mov ebx,dword[esi+4]
  1954.   xchg eax,ebx
  1955.   mov dword[edx+4],eax
  1956.   mov dword[esi+4],ebx
  1957.   ;+8 next
  1958.   mov eax,dword[edx+8]
  1959.   mov ebx,dword[esi+8]
  1960.   xchg eax,ebx
  1961.   mov dword[edx+8],eax
  1962.   mov dword[esi+8],ebx
  1963.   ret
  1964.  
  1965. ;input:
  1966. ; edi = pointer to 'TreeList' struct
  1967. align 4
  1968. tl_draw_caption_cur_pos:
  1969.         cmp tl_capt_cy,9 ;9 - minimum caption height
  1970.         jl @f
  1971.         pushad
  1972.                 mov ebx,edi ;calculate cursor position
  1973.                 mov eax,tl_cur_pos
  1974.                 inc eax
  1975.                 lea edi,[txt_capt_cur]
  1976.                 add edi,7
  1977.                 call tl_convert_to_str
  1978.                 mov edi,ebx
  1979.  
  1980.                 mov ebx,tl_box_left
  1981.                 shl ebx,16
  1982.                 add ebx,5*65536+3
  1983.                 add ebx,tl_box_top
  1984.                 mov ecx,tl_col_txt
  1985.                 or  ecx,0xc0000000 ;0x40000000 § ªà è¨¢ âì ä®­ 梥⮬ edi
  1986.                 lea edx,[txt_capt_cur]
  1987.                 mov edi,tl_col_zag
  1988.                 mcall 4 ;draw text captions
  1989.  
  1990.         popad
  1991.         @@:
  1992.         ret
  1993.  
  1994. ;input:
  1995. ; tlist - pointer to 'TreeList' struct
  1996. ; opt - options: 0 - first element, 1 - add next element
  1997. ; h_mem - pointer to memory
  1998. ; mem_size - memory size
  1999. ;output:
  2000. ; eax - error code
  2001. align 4
  2002. proc tl_save_mem uses ebx ecx edx edi esi, tlist:dword, opt:dword, h_mem:dword, mem_size:dword
  2003.         mov esi,dword[h_mem]
  2004.         mov edi,dword[tlist]
  2005.  
  2006.         cmp dword[opt],0 ;add mode
  2007.         je @f
  2008.                 stdcall tl_get_mem_size, edi,esi ;eax = à §¬¥à à ­¥¥ á®åà ­ñ­­ëå ¤ ­­ëå
  2009.                 add esi,eax
  2010.         @@:
  2011.  
  2012.         xor ebx,ebx
  2013.         mov bx,tl_info_size
  2014.  
  2015.         call tl_get_node_count_all ;eax = all node count
  2016.  
  2017.         mov ecx,eax  ;¢ëç¨á«ï¥¬ ᪮«ìª® ¯ ¬ï⨠¤®«¦­® ¡ëâì § ¯®«­¥­®
  2018.         imul ecx,ebx ;㬭®¦ ¥¬ ­  à §¬¥à áâàãªâãàë 㧫 
  2019.         add ecx,tl_save_load_heder_size+1 ;element header +1 end element sumbol
  2020.         add ecx,esi  ;¤®¡ ¢«ï¥¬ 㪠§ â¥«ì ­  ­ ç «® ¯ ¬ï⨠(á ãç¥â®¬ à ­¥¥ § ¯¨á ­­ëå áâàãªâãà)
  2021.         sub ecx,dword[h_mem] ;®â­¨¬ ¥¬ 㪠§ â¥«ì ­  ­ ç «® ¯ ¬ï⨠(¡¥§ à ­¥¥ § ¯¨á ­­ëå áâàãªâãà)
  2022.         cmp ecx,dword[mem_size] ;ecx = element memory size
  2023.         jg .err_mem_size
  2024.  
  2025.                 ;save tree params (in header)
  2026.                 mov dword[esi],'tree'
  2027.                 mov word[esi+4],bx
  2028.                 mov dword[esi+6],eax ;element count
  2029.  
  2030.                 mov eax,tl_style
  2031.                 mov dword[esi+10],eax
  2032.  
  2033.                 mov eax,tl_cur_pos
  2034.                 mov dword[esi+14],eax
  2035.  
  2036.                 mov ax,tl_info_capt_offs
  2037.                 mov word[esi+18],ax
  2038.  
  2039.                 mov ax,tl_info_capt_len
  2040.                 mov word[esi+20],ax
  2041.  
  2042.                 ;copy scroll position
  2043.                 mov edx,tl_p_scroll
  2044.                 mov eax,dword[edx+sb_offs_position]
  2045.                 mov dword[esi+22],eax
  2046.  
  2047.                 add esi,tl_save_load_heder_size ;add header size
  2048.  
  2049.                 ;cycle to nodes
  2050.                 mov edx,tl_data_nodes
  2051.                 mov ecx,edx
  2052.                 add ecx,sizeof.TreeList
  2053.                 @@:
  2054.                         call tl_iterat_next_all
  2055.                         cmp edx,ecx
  2056.                         jle @f
  2057.                 ;save node params
  2058.                 call tl_get_node_index ;eax = index of pointer [edx]
  2059.                 mov dword[esi],eax
  2060.  
  2061.                 add esi,4
  2062.                 mov eax,dword[edx] ;eax = (type; lev; clo)
  2063.                 mov dword[esi],eax
  2064.                 add esi,4
  2065.  
  2066.                         stdcall tl_node_poi_get_data, edi,edx ;eax - pointer node data
  2067.  
  2068.                 ;call tl_node_copy_data
  2069.                 push ecx edi
  2070.                 mov edi,eax
  2071.                 mov ecx,ebx
  2072.                 xchg esi,edi
  2073.                 rep movsb
  2074.                 mov esi,edi
  2075.                 pop edi ecx
  2076.                 ;add esi,ebx
  2077.                 jmp @b
  2078.         @@:
  2079.         mov byte[esi],0 ;end of 'treelist'
  2080.                 xor eax,eax ;return error code
  2081.         jmp @f
  2082.         .err_mem_size:
  2083.                 mov eax,tl_err_save_memory_size
  2084.         @@:
  2085.         ret
  2086. endp
  2087.  
  2088. ;input:
  2089. ; tlist - pointer to 'TreeList' struct
  2090. ; opt   - options: element index + (2*(add mode)+(init mode)) shl 16
  2091. ; h_mem - pointer to memory
  2092. ; mem_size - memory size
  2093. ;   à §¬¥à ¯ ¬ïâ¨, ¯®ª  ­¥ ¨á¯®«ì§ã¥âáï (­ §­ ç «áï ¤«ï ª®­â஫ï)
  2094. ;   ¤«ï ¥£® ¨á¯®«ì§®¢ ­¨ï ­ã¦­® ¤®à ¡®â âì äã­ªæ¨î
  2095. ;output:
  2096. ; eax - error code
  2097. ;memory header format:
  2098. ;  +0 - (4) 'tree'
  2099. ;  +4 - (2) info size
  2100. ;  +6 - (4) count nodes
  2101. ; +10 - (4) tlist style
  2102. ; +14 - (4) cursor pos
  2103. ; +18 - (2) info capt offs
  2104. ; +20 - (2) info capt len
  2105. ; +22 - (4) scroll pos
  2106. ;memory data format:
  2107. ; +26 - (info size + 8) * count nodes
  2108. align 4
  2109. proc tl_load_mem uses ebx ecx edx edi esi, tlist:dword, opt:dword, h_mem:dword, mem_size:dword
  2110. locals
  2111.         er_code dd ?
  2112. endl
  2113.         mov esi,dword[h_mem]
  2114.         mov edi,dword[tlist]
  2115.  
  2116.         mov dword[er_code],0 ;return error code
  2117.  
  2118.         mov ecx,dword[opt]
  2119.         cmp cx,0 ;load in array mode
  2120.         je @f
  2121.                 ;stdcall tl_get_mem_size, esi,edi ;¡¥à¥¬ à §¬¥à à ­¥¥ á®åà ­ñ­­ëå ¤ ­­ëå
  2122.                 ;add esi,eax
  2123.                 and ecx,0xffff
  2124.                 cld
  2125.                 .beg_cycle:
  2126.                         cmp dword[esi],'tree'
  2127.                         jne .no_tree
  2128.                         xor ebx,ebx
  2129.                         mov bx,word[esi+4]
  2130.                         add bx,8
  2131.                         imul ebx,dword[esi+6]
  2132.                         add ebx,tl_save_load_heder_size
  2133.                         add esi,ebx
  2134.                         loop .beg_cycle
  2135.         @@:
  2136.  
  2137.         cmp dword[esi],'tree'
  2138.         jne .no_tree
  2139.                 bt dword[opt],17 ;load in add mode
  2140.                 jc @f
  2141.                         stdcall tl_info_clear, dword edi
  2142.                 @@:
  2143.  
  2144.                 xor ebx,ebx
  2145.                 mov bx,word[esi+4] ;info_size
  2146.                 cmp bx,tl_info_size
  2147.                 je @f
  2148.                         or dword[er_code],tl_err_load_info_size
  2149.                 @@:
  2150.                 mov ecx,dword[esi+6] ;count nodes
  2151.                 cmp ecx,1
  2152.                 jl .end_f
  2153.                 mov edx,esi ;save header pointer
  2154.                 add esi,tl_save_load_heder_size
  2155.  
  2156.                 cld
  2157.                 @@: ;load node params
  2158.                         mov eax,dword[esi+4]
  2159.                         ror eax,16 ;eax - options (type; lev; clo)
  2160.                         add esi,8
  2161.                         stdcall tl_node_add, edi,eax,esi
  2162.                         stdcall tl_cur_next, edi
  2163. ;...
  2164.                         add esi,ebx
  2165.                         loop @b
  2166.  
  2167.                 bt dword[opt],17 ;load in add mode
  2168.                 jc .no_tree
  2169.                         mov eax,dword[edx+14] ;set cursor pos
  2170.                         mov tl_cur_pos,eax
  2171.                         mov ebx,tl_p_scroll
  2172.                         cmp ebx,0
  2173.                         je .end_f
  2174.                                 mov eax,dword[edx+22] ;set scroll pos
  2175.                                 mov dword[ebx+sb_offs_position],eax
  2176.                                 stdcall scroll_bar_vertical.draw, ebx
  2177.                                 jmp .end_f
  2178.         .no_tree:
  2179.         mov dword[er_code],tl_err_load_caption
  2180.         .end_f:
  2181.         mov eax,dword[er_code]
  2182.         ret
  2183. endp
  2184.  
  2185. ;¡¥à¥â à §¬¥à ¯ ¬ï⨠§ ­ï⮩ ä㭪樥© tl_save_mem ¯à¨ á®åà ­¥­¨¨ í«¥¬¥­â®¢
  2186. ;output:
  2187. ; eax - error code
  2188. align 4
  2189. proc tl_get_mem_size uses ebx edi, tlist:dword, h_mem:dword
  2190.         mov edi,dword[tlist]
  2191.         mov eax,dword[h_mem]
  2192.         @@:
  2193.                 cmp dword[eax],'tree'
  2194.                 jne @f
  2195.                 xor ebx,ebx
  2196.                 mov bx,word[eax+4]
  2197.                 add bx,8 ;à §¬¥à ¤®¯®«­¨â¥«ì­®© ¨­ä®à¬ æ¨¨ ®¡ 㧫¥ (¨­¤¥ªá § ¯¨á¨; ¨­¤¥ªá ¨ª®­ª¨, ã஢¥­ì, ...)
  2198.                 imul ebx,dword[eax+6]
  2199.                 add ebx,tl_save_load_heder_size
  2200.                 add eax,ebx
  2201.                 jmp @b
  2202.         @@:
  2203.         sub eax,dword[h_mem] ;®â­¨¬ ¥¬ 㪠§ â¥«ì ­  ­ ç «® ¯ ¬ïâ¨
  2204.                 ;¨ ¯®«ãç ¥¬ à §¬¥à ¡«®ª  ¯ ¬ïâ¨
  2205.         ret
  2206. endp
  2207.  
  2208.  
  2209. ;ascii scan key
  2210. ;  13    28 Enter
  2211. ;  32    57 Space
  2212. ; 178    72 Up
  2213. ; 177    80 Down
  2214. ; 176    75 Left
  2215. ; 179    77 Right
  2216. ; 182    83 Delete
  2217. ; 184    73 Pg Up
  2218. ; 183    81 Pg Dn
  2219.  
  2220. tl_key_ascii db 13,32,178,177,176,179,182,184,183
  2221. tl_key_scan  db 28,57, 72, 80, 75, 77, 83, 73, 81
  2222.  
  2223. txt_capt_cur db '‘âப       ',0
  2224. txt_capt_otm db 'Žâ¬¥­ë      ',0
  2225.  
  2226. ;íâ®â ª®¤ ­¥ ¬®©, ®­ ¯à¥®¡à §ã¥â ç¨á«® ¢ áâபã
  2227. ;input:
  2228. ; eax = value
  2229. ; edi = string buffer
  2230. align 4
  2231. tl_convert_to_str:
  2232.         pushad
  2233.                 mov dword[edi+1],0x20202020
  2234.                 call .str
  2235.         popad
  2236.         ret
  2237.  
  2238. align 4
  2239. .str:
  2240.   mov ecx,0x0a ;§ ¤ ¥âáï á¨á⥬  áç¨á«¥­¨ï ¨§¬¥­ïîâáï ॣ¨áâàë ebx,eax,ecx,edx ¢å®¤­ë¥ ¯ à ¬¥âàë eax - ç¨á«®
  2241.     ;¯à¥à¥¢®¤ ç¨á«  ¢ ASCII áâப㠢§®¤­ë¥ ¤ ­­ë¥ ecx=á¨á⥬  áç¨á«¥­ï edi  ¤à¥á ªã¤  § ¯¨á뢠âì, ¡ã¤¥¬ áâபã, ¯à¨ç¥¬ ª®­¥æ ¯¥à¥¬¥­­®©
  2242.   cmp eax,ecx  ;áà ¢­¨âì ¥á«¨ ¢ eax ¬¥­ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ ­  @@-1 â.¥. ­  pop eax
  2243.   jb @f
  2244.   xor edx,edx  ;®ç¨áâ¨âì edx
  2245.   div ecx      ;à §¤¥«¨âì - ®áâ â®ª ¢ edx
  2246.   push edx     ;¯®«®¦¨âì ¢ á⥪
  2247.   call .str;¯¥à¥©â¨ ­  á ¬ã ᥡï â.¥. ¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥­â  ¯®ª  ¢ eax ­¥ áâ ­¥â ¬¥­ìè¥ ç¥¬ ¢ ecx
  2248.   pop eax
  2249.   @@: ;cmp al,10 ;¯à®¢¥à¨âì ­¥ ¬¥­ìè¥ «¨ §­ ç¥­¨¥ ¢ al 祬 10 (¤«ï á¨á⥬ë áç¨á«¥­ï 10 ¤ ­­ ï ª®¬ ­¤  - «¨è­ ï))
  2250.   or al,0x30  ;¤ ­­ ï ª®¬ ­¤  ª®à®ç¥  ç¥¬ ¤¢¥ ¢ëè¥
  2251.   stosb       ;§ ¯¨á âì í«¥¬¥­â ¨§ ॣ¨áâà  al ¢ ï祪㠯 ¬ï⨠es:edi
  2252.   ret         ;¢¥à­ãâìáï ®ç¥­ì ¨­â¥à¥á­ë© 室 â.ª. ¯®ª  ¢ á⥪¥ åà ­¨âìáï ª®«-¢® ¢ë§®¢®¢ â® á⮫쪮 à § ¬ë ¨ ¡ã¤¥¬ ¢ë§ë¢ âìáï
  2253. }
  2254.