0,0 → 1,2392 |
; ìàêðîñ äëÿ ñèñòåìíîé áèáëèîòåêè box_lib.obj |
; ýëåìåíò TreeList äëÿ Kolibri OS |
; ôàéë ïîñëåäíèé ðàç èçìåíÿëñÿ 01.12.2010 IgorA |
; íà êîä ïðèìåíåíà GPL2 ëèöåíçèÿ |
|
|
sizeof.TreeList equ 20 |
;struct TreeList |
; type dw ? ;+ 0 òèï ýëåìåíòà, èëè èíäåêñ èêîíêè äëÿ óçëà |
; lev db ? ;+ 2 óðîâåíü ýëåìåíòà |
; clo db ? ;+ 3 ôëàã çàêðûòèÿ, èëè îòêðûòèÿ (èìååò ñìûñë äëÿ ðîäèòåëüñêîãî óçëà) |
; perv dd ? ;+ 4 èíäåêñ ïðåäûäóùåãî ýëåìåíòà |
; next dd ? ;+ 8 èíäåêñ ïîñëåäóþùåãî ýëåìåíòà |
; tc dd ? ;+12 âðåì. ñîçäàíèÿ |
; td dd ? ;+16 âðåì. óäàëåíèÿ |
;ends |
|
macro use_tree_list |
{ |
align 4 |
tl_data_init: ;âûäåëíèå ïàìÿòè äëÿ ñòðóêòóð ñïèñêà è îñíîâíîé èíôîðìàöèè (êîíñòðóêòîð) |
push ebp |
mov ebp,esp |
push eax ecx edi |
mov edi,dword[ebp+8] |
|
xor ecx,ecx |
mov cx,tl_info_size |
imul ecx,tl_info_max_count |
invoke mem.alloc,ecx |
mov dword[edi],eax ;êîïèðóåì óêàçàòåëü íà ïîëó÷åíóþ ïàìÿòü â ñòðóêòóðó |
mov tl_data_img,0 ;îáíóëÿåì óêàçàòåëü 'data_img' |
mov tl_data_img_sys,0 ;îáíóëÿåì óêàçàòåëü 'data_img_sys' |
|
mov ecx,sizeof.TreeList |
imul ecx,tl_info_max_count |
invoke mem.alloc,ecx |
mov tl_data_nodes,eax ;êîïèðóåì óêàçàòåëü íà ïîëó÷åíóþ ïàìÿòü â ñòðóêòóðó |
|
push dword edi |
call tl_info_clear |
|
;íàñòðîéêè äî÷åðíåãî ñêðîëëèíãà |
cmp tl_p_scrol,0 |
je @f |
mov eax,tl_p_scrol |
;*** öâåòîâûå íàñòðîéêè *** |
mov ecx,tl_col_bkg |
mov dword[eax+28],ecx ;+28 .bckg_col |
mov ecx,tl_col_zag |
mov dword[eax+32],ecx ;+32 .frnt_col |
mov ecx,tl_col_txt |
mov dword[eax+36],ecx ;+32 .line_col |
;*** íàñòðîéêè ðàçìåðîâ *** |
mov ecx,tl_box_left |
add ecx,tl_box_width |
mov word[eax+2],cx |
mov ecx,tl_box_height |
mov word[eax+4],cx |
mov ecx,tl_box_top |
mov word[eax+6],cx |
@@: |
pop edi ecx eax |
pop ebp |
ret 4 |
|
align 4 |
proc tl_data_clear, tlist:dword ;î÷èñòêà ïàìÿòè ýëåìåíòà (äåñòðóêòîð) |
push edi |
mov edi,dword[tlist] |
cmp tl_data_img,0 |
je @f |
invoke mem.free,tl_data_img ;÷èñòêà ñèñòåìíûõ èêîíîê |
@@: |
cmp tl_data_img_sys,0 |
je @f |
invoke mem.free,tl_data_img_sys ;÷èñòêà ñèñòåìíûõ èêîíîê |
@@: |
invoke mem.free,dword[edi] |
|
invoke mem.free,tl_data_nodes |
pop edi |
ret |
endp |
|
align 4 |
tl_info_clear: ;î÷èñòêà ñïèñêà (èíôîðìàöèè) |
push ebp |
mov ebp,esp |
push eax ecx edi |
mov edi,dword[ebp+8] |
mov tl_ch_tim,0 |
mov dword[edi+34],0 ;ls_tim |
mov tl_tim_undo,0 |
mov tl_cur_pos,0 |
;xor ecx,ecx |
mov ecx,sizeof.TreeList |
imul ecx,tl_info_max_count |
mov eax,tl_data_nodes |
@@: |
mov byte[eax],0 ;÷èñòèì óçëû 0-ìè |
inc eax |
loop @b |
mov eax,tl_data_nodes ;óêàçàòåëü íà 0-é óçåë |
mov dword[eax+8],1 ;óêàçàòåëü next â 0-ì óçëå ïðèðàâíèâàåì ê 1 |
|
cmp tl_p_scrol,0 ;îáðàáîòêà ñêðîëëèíãà |
je @f |
mov eax,tl_p_scrol |
mov dword[eax+24],0 ;+24 .position |
call tb_scrol_resize |
@@: |
pop edi ecx eax |
pop ebp |
ret 4 |
|
|
align 4 |
tl_key: ;ðåàêöèÿ íà êëàâèàòóðó |
push ebp |
mov ebp,esp |
push ebx ecx edi |
mov edi,dword[ebp+8] |
|
mov ebx,tl_el_focus |
cmp dword[ebx],edi |
jne .no_focus ;ýëåìåíò íå â ôîêóñå |
|
push eax |
mov eax,66 |
mov ebx,2 |
int 0x40 ;ïîëó÷èòü ðåæèì ââîäà ñ êëàâèàòóðû |
|
lea ecx,[tl_key_scan] |
cmp eax,1 ;1 = ñêàíêîäû |
je @f |
lea ecx,[tl_key_ascii] |
@@: |
pop eax |
|
xor bx,bx |
cmp ah,byte[ecx] ;Enter |
jne @f |
cmp tl_on_press,0 |
je @f |
call tl_on_press |
@@: |
cmp ah,byte[ecx+1] ;Space |
jne @f |
push dword edi |
call tl_node_close_open |
@@: |
cmp ah,byte[ecx+2] ;Up |
jne @f |
push dword edi |
call tl_cur_perv |
@@: |
cmp ah,byte[ecx+3] ;Down |
jne @f |
push dword edi |
call tl_cur_next |
@@: |
cmp ah,byte[ecx+7] ;Page Up |
jne @f |
push dword edi |
call tl_cur_page_up |
@@: |
cmp ah,byte[ecx+8] ;Page Down |
jne @f |
push dword edi |
call tl_cur_page_down |
@@: |
|
bt tl_style,0 ;tl_key_no_edit |
jc .no_edit |
cmp ah,byte[ecx+4] ;Left |
jne @f |
push dword edi |
call tl_node_lev_dec |
mov bx,1 |
@@: |
cmp ah,byte[ecx+5] ;Right |
jne @f |
push dword edi |
call tl_node_lev_inc |
mov bx,1 |
@@: |
cmp ah,byte[ecx+6] ;Delete |
jne @f |
push dword edi |
call tl_node_delete |
mov bx,1 |
@@: |
.no_edit: |
|
cmp bx,1 |
jne .no_focus |
push dword edi |
call tl_draw |
.no_focus: |
|
pop edi ecx ebx |
pop ebp |
ret 4 |
|
align 4 |
tl_mouse: ;ðåàêöèÿ íà ìûøü |
push ebp |
mov ebp,esp |
pushad |
mov edi,dword[ebp+8] |
|
mov eax,37 |
mov ebx,1 |
int 0x40 |
|
mov ebx,tl_box_left |
shl ebx,16 |
cmp eax,ebx ;ëåâàÿ ãðàíèöà îêíà |
jl .no_in_wnd ;.test_scroll |
|
mov ebx,tl_box_left |
add ebx,tl_box_width |
shl ebx,16 |
cmp eax,ebx ;ïðàâàÿ ãðàíèöà îêíà |
jg .test_scroll |
|
mov ebx,tl_box_top |
add ebx,tl_box_height |
cmp ax,bx ;íèæíÿÿ ãðàíèöà îêíà |
jg .test_scroll |
|
sub ebx,tl_box_height |
add bx,tl_capt_cy |
cmp ax,bx ;âåðõíÿÿ ãðàíèöà îêíà + âûñîòà ïîäïèñè |
jl .test_scroll |
|
push eax ebx |
mov eax,37 |
mov ebx,2 |
int 0x40 |
|
bt eax,0 ;left mouse button press |
pop ebx eax |
jae .no_draw |
|
|
mov esi,tl_el_focus |
mov dword[esi],edi ;set focus |
|
; if '+' or '-' press |
mov esi,eax |
shr esi,16 |
sub esi,tl_box_left ;esi = mouse x coord in element window |
|
and eax,0xffff |
sub ax,bx |
xor edx,edx |
xor ecx,ecx |
mov cx,tl_img_cy |
div ecx |
cmp tl_p_scrol,0 ;ó÷èòûâàåì ñêðîëëèíã |
je @f |
mov edx,tl_p_scrol |
add eax,dword[edx+24] ;äîáàâëÿåì ñêðîëëèíã íà âåðõó |
@@: |
|
mov ecx,eax |
call tl_get_node_count ;eax = node count |
cmp eax,ecx |
jl @f |
mov eax,ecx ;åñëè êóðñîð íå âûøåë çà ïðåäåëû óçëîâ, âîññòàíàâëèâàåì ñòàðîå çíà÷åíèå eax |
@@: |
|
cmp eax,tl_cur_pos ;åñëè íîâîå çíà÷åíèå êóðñîðà ñîâïàëî ñ ïðåäûäóùèì |
je @f ;òî íå ñòèðàåì êóðñîð |
push esi |
mov esi,tl_box_top |
add esi,tl_box_height ;esi = coord bottom border |
call tl_draw_null_cursor ;ñòèðàåì êóðñîð |
pop esi |
@@: |
|
mov tl_cur_pos,eax |
|
; if '+' or '-' press |
call tl_get_cur_node_index ;eax = node index |
cmp eax,2 |
jl .no_open_close ;êóðñîð ñòîèò íà ïóñòîì ìåñòå, áåç óçëîâ |
imul eax,sizeof.TreeList |
add eax,tl_data_nodes |
xor bx,bx |
mov bl,byte[eax+2] ;+2 lev ñîõðàíÿåì óðîâåíü òåêóùåãî óçëà |
inc bx ;+ ïîëå äëÿ êóðñîðà |
|
cmp si,tl_img_cx |
jl .no_open_close ;ìûøåé ïîïàëè íà ëåâîå ïîëå äëÿ êóðñîðà, ãäå òî÷íî íåò '+' è '-' |
mov eax,esi |
xor edx,edx |
xor ecx,ecx |
mov cx,tl_img_cx |
div ecx |
|
cmp ax,bx |
jne .no_open_close |
|
push dword edi |
call tl_node_close_open |
.no_open_close: |
|
mov esi,tl_box_top |
add esi,tl_box_height ;esi = coord bottom border |
call tl_draw_cursor ;ïåðåðèñîâêà êóðñîðà |
call tl_draw_caption_cur_pos |
jmp .no_draw |
;--- mouse event for children scrollbar ---------------------------------------- |
.test_scroll: |
mov edx,tl_p_scrol |
cmp edx,0 |
je .no_in_wnd ;ïîëüçîâàòåëü íå ñîçäàë äî÷åðíåãî ñêðîëëèíãà |
shr ebx,16 |
add bx,word[edx] ;+0 .size_x |
shl ebx,16 |
cmp eax,ebx ;ïðàâàÿ ãðàíèöà îêíà |
jg .no_in_wnd |
|
mov eax,dword[edx+16] ;+16 .max_area |
cmp eax,dword[edx+20] ;+20 .cur_area |
jbe .no_in_wnd ;âñå óçëû ïîïàäàþò â îêíî ñêðîëëèíãà |
push dword edx |
call scroll_bar_vertical.mouse ;scrollbar_ver_mouse |
|
cmp dword[edx+40],0 ;+40 .redraw |
je @f |
mov dword[edx+40],0 ;+40 .redraw |
push dword edi |
call tl_draw ;ïðîèçîøëè èçìåíåíèÿ ñêðîëëèíãà |
@@: |
cmp dword[edx+46],0 ;+46 .delta2 |
jne .no_draw ;ïîïàëè íà ñêðîëëèíã - íå ñíèìàåì ôîêóñ ñ TreeList |
;------------------------------------------------------------------------------- |
.no_in_wnd: ;íå ïîïàëè â îêíî - ïîòåðÿ ôîêóñà (ïðè óñëîâèè ÷òî ôîêóñ áûë íà äàííîì ýåëåìåíòå) |
mov eax,37 ;ïðîâåðÿåì íàæàòîñòü ëþáûõ êíîïîê |
mov ebx,2 |
int 0x40 |
cmp eax,0 ;íè÷å íå íàæàëè eax=0 |
je .no_draw |
|
mov ebx,tl_el_focus |
cmp dword[ebx],edi |
jne .no_draw ;ýëåìåíò íå â ôîêóñå |
mov dword[ebx],0 ;reset focus |
mov esi,tl_box_top |
add esi,tl_box_height ;esi = coord bottom border |
call tl_draw_cursor ;ðèñóåì êóðñîð ñ ïîòåðÿíûì ôîêóñîì |
.no_draw: |
|
popad |
pop ebp |
ret 4 |
|
align 4 |
tl_info_undo: ;îòìåíà äåéñòâèÿ |
push ebp |
mov ebp,esp |
push eax edi |
mov edi,dword[ebp+8] |
mov eax,tl_tim_undo |
cmp tl_ch_tim,eax |
jbe @f |
inc tl_tim_undo |
call tb_scrol_resize ;îáðàáîòêà ñêðîëëèíãà |
@@: |
pop edi eax |
pop ebp |
ret 4 |
|
align 4 |
tl_info_redo: ;ïîâòîð äåéñòâèÿ |
push ebp |
mov ebp,esp |
push edi |
mov edi,dword[ebp+8] |
cmp tl_tim_undo,1 |
jl @f |
dec tl_tim_undo |
call tb_scrol_resize ;îáðàáîòêà ñêðîëëèíãà |
@@: |
pop edi |
pop ebp |
ret 4 |
|
align 4 |
tl_info_set_undo: ;óäàëåíèå îòìåíåííûõ äåéñòâèé |
; push ebp |
; mov ebp,esp |
; push edi |
; mov edi,dword[ebp+8] |
|
; mov [dragk],0 ;çàêàí÷èâàåì âûäåëåíèå îò êëàâèàòóðû |
cmp tl_tim_undo,1 |
jl .no_work |
|
push eax ebx ecx edx |
mov edx,tl_data_nodes |
mov ecx,edx |
add ecx,sizeof.TreeList |
call tl_move_next ;long i=node[0].next; |
mov eax,tl_tim_undo |
sub tl_ch_tim,eax ;ch_tim-=tim_undo; |
mov eax,tl_ch_tim |
cmp [edi+34],eax ;if(ls_tim>ch_tim) |
jle @f |
mov dword[edi+34],0 ;ls_tim=0 |
@@: |
cmp edx,ecx |
jle @f |
|
;if(node[i].tc>ch_tim){ // åñëè ñîçäàíèå ñèìâîëà áûëî îòìåíåíî |
cmp dword[edx+12],eax |
jle .no_u1 |
mov dword[edx+12],0 |
mov dword[edx+16],0 |
|
mov ebx, dword[edx+4] |
imul ebx,sizeof.TreeList |
add ebx, tl_data_nodes ;.next |
push dword[edx+8] ;node[node[i].perv].next=node[i].next; |
pop dword[ebx+8] |
|
mov ebx, dword[edx+8] |
imul ebx,sizeof.TreeList |
add ebx, tl_data_nodes ;.perv |
push dword[edx+4] ;node[node[i].next].perv=node[i].perv; |
pop dword[ebx+4] |
|
.no_u1: |
|
;else if(node[i].td>ch_tim) node[i].td=0; // åñëè óäàëåíèå ñèìâîëà áûëî îòìåíåíî |
cmp dword[edx+16],eax |
jle .no_u2 |
mov dword[edx+16],0 |
.no_u2: |
|
call tl_move_next |
jmp @b |
@@: |
mov tl_tim_undo,0 |
; mov eax,[edi+?] ;co_tim |
; cmp tl_ch_tim,eax ;ch_tim |
; jge @f |
; mov [edi+?],0 ;co_tim |
; @@: |
pop edx ecx ebx eax |
.no_work: |
|
; pop edi |
; pop ebp |
; ret 4 |
ret |
|
align 4 |
tl_draw: ;âûâîä ñïèñêà íà ýêðàí |
push ebp |
mov ebp,esp |
pushad |
;draw dir_list main rect |
mov edi,dword[ebp+8] |
mov ebx,tl_box_left |
shl ebx,16 |
add ebx,tl_box_width |
mov ecx,tl_box_top |
shl ecx,16 |
mov cx,tl_capt_cy |
mov edx,tl_col_zag |
mov eax,13 |
int 0x40 ;draw window caption |
|
add ecx,tl_box_top |
shl ecx,16 |
add ecx,tl_box_height |
sub cx,tl_capt_cy |
mov edx,tl_col_bkg |
int 0x40 ;draw window client rect |
|
cmp tl_capt_cy,9 ;9 - minimum caption height |
jl @f |
mov ebx,edi ;calculate cursor position |
mov eax,tl_cur_pos |
inc eax |
lea edi,[txt_capt_cur] |
add edi,7 |
call tl_convert_to_str |
|
mov edi,ebx |
mov eax,tl_tim_undo |
lea edi,[txt_capt_otm] |
add edi,7 |
call tl_convert_to_str |
mov edi,ebx ;restore edi |
|
mov eax,4 ;draw text captions |
mov ebx,tl_box_left |
shl ebx,16 |
add ebx,5*65536+3 |
add ebx,tl_box_top |
mov ecx,tl_col_txt |
or ecx,0x80000000 |
lea edx,[txt_capt_cur] |
int 0x40 |
|
mov ebx,tl_box_left |
shl ebx,16 |
add ebx,100*65536+3 |
add ebx,tl_box_top |
lea edx,[txt_capt_otm] |
int 0x40 |
@@: |
|
;cycle to nodes |
xor eax,eax |
mov edx,tl_data_nodes |
mov ecx,edx |
add ecx,sizeof.TreeList |
|
;*** ïðîïóñê óçëîâ, êîòîðûå ïðîìîòàíû ñêðîëëèíãîì *** |
cmp tl_p_scrol,0 ;åñëè åñòü óêàçàòåëü íà ñêðîëëèíã |
je .end_c1 |
mov esi,tl_p_scrol |
cmp dword[esi+24],0 ;åñëè ñêðîëëèíã íà âåðõó, âûõîäèì |
je .end_c1 |
@@: |
call tl_iterat_next |
cmp edx,ecx |
jle .end_draw |
inc eax |
cmp eax,dword[esi+24] |
jge .end_c1 |
jmp @b |
.end_c1: |
|
xor eax,eax |
mov esi,tl_box_top |
add esi,tl_box_height ;esi = coord bottom border |
@@: |
call tl_iterat_next |
cmp edx,ecx |
jle @f |
call tl_draw_node |
inc eax |
jmp @b |
@@: |
|
call tl_draw_cursor |
|
mov edi,tl_p_scrol ;ðèñóåì äî÷åðíèé ñêðîëëèíã |
cmp edi,0 ;äëÿ òîãî ÷òî-áû åãî íå ïðèøëîñü ðèñîâàòü â ïîëüçîâàòåëüñêîé ïðîãðàììå |
je .end_draw ;åñëè íåò ñêðîëëèíãà âûõîäèì |
push dword edi |
call scroll_bar_vertical.draw |
|
.end_draw: |
popad |
pop ebp |
ret 4 |
|
;input: |
; ecx = pointer to 1 node struct |
; edx = pointer to some node struct |
; edi = pointer to 'TreeList' struct |
;output: |
; edx = pointer to next node struct |
align 4 |
tl_iterat_next: ;ïåðåõîä íà ñëåäóùèé âèäèìûé óçåë (ïðîïóñêàÿ çàêðûòûå) |
push bx |
mov bl,0x7f |
cmp byte[edx+3],1 |
jne @f |
mov bl,byte[edx+2] |
@@: |
|
cmp tl_tim_undo,0 |
je .else |
|
push eax |
.beg0: |
call tl_move_next |
cmp edx,ecx |
jle @f |
call tl_node_not_vis ;ïðîïóñê óäàëåííûõ è îòìåíåííûõ |
cmp al,1 |
je .beg0 |
cmp bl,byte[edx+2] ;ïðîïóñê çàêðûòûõ |
jl .beg0 |
@@: |
pop eax |
pop bx |
ret |
|
.else: |
call tl_move_next |
cmp edx,ecx |
jle .endif |
cmp dword[edx+16],0 ;td = 'time delete' -> ïðîïóñê óäàëåííûõ |
jne .else |
cmp bl,byte[edx+2] ;ïðîïóñê çàêðûòûõ |
jl .else |
.endif: |
pop bx |
ret |
|
;input: |
; ecx = pointer to 1 node struct |
; edx = pointer to some node struct |
; edi = pointer to 'TreeList' struct |
align 4 |
tl_iterat_next_all: ;ïåðåõîä íà ñëåäóùèé âèäèìûé óçåë (è íà çàêðûòûå òîæå) |
cmp tl_tim_undo,0 |
je .else |
|
push eax |
@@: |
call tl_move_next |
cmp edx,ecx |
jle @f |
call tl_node_not_vis |
cmp al,1 |
je @b |
@@: |
pop eax |
ret |
.else: |
call tl_move_next |
cmp edx,ecx |
jle .endif |
cmp dword[edx+16],0 ;td -> time delete |
jne .else |
.endif: |
ret |
|
;input: |
; ecx = pointer to 1 node struct |
; edx = pointer to some node struct |
; edi = pointer to 'TreeList' struct |
align 4 |
tl_iterat_perv: ;ïåðåõîä íà ïðåäûäóùèé âèäèìûé óçåë (ïðîïóñêàÿ çàêðûòûå) |
push eax |
cmp tl_tim_undo,0 |
je .beg1 |
|
.beg0: |
call tl_move_perv |
cmp edx,ecx |
jle @f |
call tl_node_not_vis ;ïðîïóñê óäàëåííûõ è îòìåíåííûõ |
cmp al,1 |
je .beg0 |
|
.beg1: |
call tl_move_perv |
cmp edx,ecx |
jle @f |
cmp dword[edx+16],0 ;td = 'time delete' -> ïðîïóñê óäàëåííûõ |
jne .beg1 |
|
@@: |
call tl_move_max_clo_par |
pop eax |
ret |
|
|
;input: |
; edx = pointer to some node struct |
; edi = pointer to 'TreeList' struct |
;output: |
; edx = pointer closed parent node with maximum level |
align 4 |
tl_move_max_clo_par: ;íàõîäèò ðîäèòåëüñêèé çàêðûòûé óçåë ìàêñèìàëüíîãî óðîâíÿ |
push eax ebx |
mov eax,edx |
xor ebx,ebx |
.beg: |
call tl_move_par |
cmp byte[edx+3],1 ;ðîäèòåëüñêèé óçåë çàêðûò ? |
jne @f |
mov eax,edx |
@@: |
cmp ebx,edx |
je .end_f |
mov ebx,edx |
jmp .beg |
.end_f: |
mov edx,eax |
pop ebx eax |
ret |
|
;input: |
; edx = pointer to some node struct |
; edi = pointer to 'TreeList' struct |
;output: |
; edx = pointer to next node struct |
align 4 |
tl_move_next: |
mov edx,dword[edx+8] |
imul edx,sizeof.TreeList |
add edx,tl_data_nodes |
ret |
|
;input: |
; edx = pointer to some node struct |
; edi = pointer to 'TreeList' struct |
;output: |
; edx = pointer to perv node struct |
align 4 |
tl_move_perv: |
mov edx,dword[edx+4] |
imul edx,sizeof.TreeList |
add edx,tl_data_nodes |
ret |
|
;input: |
; ecx = |
; edx = pointer to some node struct |
; edi = pointer to 'TreeList' struct |
;output: |
; edx = pointer to parent node struct |
align 4 |
tl_move_par: ;ïåðåäâèãàåìñÿ íà ðîäèòåëüñêèé óçåë, åñëè òàêîãî íåò, òî îñòàâëÿåì ñòàðîå çíà÷åíèå óêàçàòåëÿ |
cmp byte[edx+2],0 |
je .end_f ;óçåë 0-ãî óðîâíÿ íå ìîæåò áûòü äî÷åðíèì |
push eax ebx esi |
mov esi,edx ;copy node pointer (edx) |
mov bl,byte[edx+2] |
@@: |
call tl_move_perv |
cmp edx,ecx |
jle @f ;âñå âûøå ñòîÿùèå óçëû íå ðîäèòåëüñêèå |
call tl_node_not_vis ;ïðîïóñê óäàëåííûõ è îòìåíåííûõ |
cmp al,1 |
je @b |
cmp byte[edx+2],bl |
jl .end_0 ;óäà÷íî íàøëè ðîäèòåëüñêèé óçåë |
jmp @b |
@@: |
mov esi,ebx ;restore node pointer |
.end_0: |
pop esi ebx eax |
.end_f: |
ret |
|
;input: |
; edx = pointer to symbol struct |
; edi = pointer to 'TreeList' struct |
;output: |
; al = 1 if sumbol not visible |
; (node[i].td+tim_Undo<=ch_tim && node[i].td) || (node[i].tc>ch_tim-tim_Undo) |
align 4 |
tl_node_not_vis: ;ïðîâåðÿåò âèäèìûé ëè óêàçàííûé óçåë ñ ó÷åòîì: äîáàâëåíèé, óäàëåíèé, îòìåí äåéñòâèé |
cmp dword[edx+16],0 |
je @f |
mov eax,dword[edx+16] ;eax=node[i].td |
add eax,tl_tim_undo |
cmp eax,tl_ch_tim |
jg @f |
mov al,1 |
ret |
@@: |
|
mov eax,tl_ch_tim |
sub eax,tl_tim_undo |
cmp dword[edx+12],eax ;tc -> time create |
jle @f |
mov al,1 |
ret |
@@: |
xor al,al |
ret |
|
|
;input: |
; edi = pointer to TreeInfo struct |
; esi = coord bottom border |
align 4 |
tl_draw_cursor: ;ðèñóåì êóðñîð íà ýêðàíå |
push eax ebx ecx edx esi |
call tl_get_display_cur_pos ;eax = cursor pos in screen |
cmp eax,0 |
jl .end_f ;êóðñîð íàõîäèòñÿ âûøå îêíà, â îáëàñòè ïðîêðó÷åííîé ñêðîëëèíãîì |
|
cmp tl_data_img_sys,0 ;ñìîòðèì åñòü ëè óêàçàòåëü íà êàðòèíêó ñèñòåìíûõ èêîíîê |
jne @f |
mov ebx,tl_box_left |
shl ebx,16 |
mov bx,tl_img_cx |
xor ecx,ecx |
mov cx,tl_img_cy |
imul ecx,eax |
add ecx,tl_box_top |
add cx,tl_capt_cy |
|
;crop image if on the border |
cmp esi,ecx ;åñëè êóðñîð âíèçó è åãî âîîáùå íå âèäíî |
jl .end_f |
|
sub esi,ecx |
shl ecx,16 |
mov cx,tl_img_cy |
cmp si,tl_img_cy |
jge .crop0 |
mov cx,si ;åñëè êóðñîð âèäåí ÷àñòè÷íî (ïîïàë íà íèæíþþ ãðàíèöó) |
.crop0: |
|
mov edx,tl_col_txt |
mov eax,13 |
int 0x40 ;ðèñóåì ïðîñòîé ïðÿìîóãîëüíèê, ò.ê. íåò ñèñòåìíûõ èêîíîê |
jmp .end_f |
@@: |
mov ebx,tl_data_img_sys |
imul ax,tl_img_cy |
mov edx,tl_box_left |
shl edx,16 |
mov dx,ax |
add edx,tl_box_top |
add dx,tl_capt_cy |
|
mov ecx,tl_el_focus ;ïðîâåðÿåì â ôîêóñå ýëåìåíò èëè íåò |
cmp dword[ecx],edi |
je .focus |
xor eax,eax |
xor ecx,ecx |
mov cx,tl_img_cx |
mov ax,tl_img_cy |
imul eax,ecx |
imul eax,4*3 ;4=icon index 3=rgb |
add ebx,eax |
.focus: |
|
mov cx,tl_img_cx |
shl ecx,16 |
mov cx,tl_img_cy |
|
;crop image if on the border |
cmp si,dx ;åñëè êóðñîð âíèçó è åãî âîîáùå íå âèäíî |
jl .end_f |
|
sub si,dx |
cmp si,tl_img_cy |
jge .crop1 |
mov cx,si ;åñëè êóðñîð âèäåí ÷àñòè÷íî (ïîïàë íà íèæíþþ ãðàíèöó) |
.crop1: |
|
mov eax,7 |
int 0x40 ;ðèñóåì èêîíêó êóðñîðà |
.end_f: |
pop esi edx ecx ebx eax |
ret |
|
;input: |
; edi = pointer to TreeInfo struct |
; esi = coord bottom border |
align 4 |
tl_draw_null_cursor: ;ñòèðàåì êóðñîð íà ýêðàíå |
push eax ebx ecx edx esi |
call tl_get_display_cur_pos ;eax = cursor pos in screen |
cmp eax,0 |
jl .end_f ;êóðñîð íàõîäèòñÿ âûøå îêíà, â îáëàñòè ïðîêðó÷åííîé ñêðîëëèíãîì |
|
mov ebx,tl_box_left |
shl ebx,16 |
mov bx,tl_img_cx |
xor ecx,ecx |
mov cx,tl_img_cy |
imul ecx,eax |
add ecx,tl_box_top |
add cx,tl_capt_cy |
|
;crop image if on the border |
cmp esi,ecx ;åñëè êóðñîð âíèçó è åãî âîîáùå íå âèäíî |
jl .end_f |
|
sub esi,ecx |
shl ecx,16 |
mov cx,tl_img_cy |
cmp si,tl_img_cy |
jge @f |
mov cx,si ;åñëè êóðñîð âèäåí ÷àñòè÷íî (ïîïàë íà íèæíþþ ãðàíèöó) |
@@: |
|
mov edx,tl_col_bkg |
mov eax,13 |
int 0x40 ;ðèñóåì ïðîñòîé ïðÿìîóãîëüíèê ñ ôîíîâûì öâåòîì |
|
.end_f: |
pop esi edx ecx ebx eax |
ret |
|
;input: |
; edi = pointer to TreeInfo struct |
;output: |
; eax = index |
align 4 |
tl_get_display_cur_pos: ;áåðåò ïîçèöèþ êóðñîðà, îòíîñèòåëüíî ýêðàíà |
mov eax,tl_cur_pos |
cmp tl_p_scrol,0 |
je @f |
push ebx |
mov ebx,tl_p_scrol |
mov ebx,dword[ebx+24] |
sub eax,ebx ;îòíèìàåì ïîçèöèþ ñêðîëëèíãà |
pop ebx |
@@: |
ret |
|
;input: |
; eax = node position |
; edx = pointer to some node struct |
; edi = pointer to 'TreeList' struct |
; esi = coord of bottom border |
align 4 |
tl_draw_node: ;ðèñóåò óçåë ñ: êàðòèíêîé, ïîäïèñüþ, èêîíêîé îòêðûòèÿ/çàêðûòèÿ è ëèíèÿìè ê ðîäèò. óçëó |
push eax ebx ecx edx esi |
|
mov ebx,1 ;1 - ìåñòî ïîä êóðñîð |
bt tl_style,2 ;tl_list_box_mode |
jc @f |
inc ebx ;+1 - ìåñòî ïîä çíàê +,- |
add bl,byte[edx+2] ;äîáàâëÿåì óðîâåíü ýëåìåíòà äëÿ åãî ó÷åòà â ëåâîì îòñòóïå èêîíêè |
@@: |
imul bx,tl_img_cx |
add ebx,tl_box_left |
|
shl ebx,16 |
mov bx,tl_img_cx |
xor ecx,ecx |
mov cx,tl_img_cy |
imul ecx,eax |
add ecx,tl_box_top |
add cx,tl_capt_cy |
|
;crop image if on the border |
cmp esi,ecx ;åñëè óçåë âíèçó è åãî âîîáùå íå âèäíî |
jl .end_draw |
|
sub esi,ecx |
shl ecx,16 |
mov cx,tl_img_cy |
cmp si,tl_img_cy |
jge @f |
mov cx,si ;åñëè óçåë âèäåí ÷àñòè÷íî (ïîïàë íà íèæíþþ ãðàíèöó) |
jmp .crop ;ïðîïóñêàåì ðèñîâàíèå íàäïèñè, êîòîðàÿ ñêîðåå âñåãî òîæå âûëåçåò çà íèæíþþ ãðàíèöó |
@@: |
call tl_draw_node_caption |
.crop: |
mov esi,ecx ;save ecx |
|
cmp tl_data_img,0 |
jne .draw_img_n |
push edx |
mov edx,tl_col_txt |
mov eax,13 |
int 0x40 ;draw node rect |
pop edx |
jmp @f |
.draw_img_n: |
push ebx edx esi |
xor esi,esi |
mov si,word[edx] ;get icon type |
mov edx,ebx |
ror ecx,16 |
mov dx,cx |
mov cx,bx |
ror ecx,16 |
mov ebx,3 ;rgb = 3 bytes |
imul bx,tl_img_cx |
imul bx,tl_img_cy |
imul ebx,esi ;esi = icon index |
add ebx,tl_data_img |
|
mov eax,7 |
int 0x40 ;draw node icon '-' |
pop esi edx ebx |
@@: |
|
mov al,byte[edx+2] ;draw minus '-' |
mov ecx,tl_data_nodes |
add ecx,sizeof.TreeList |
|
mov ah,10 ;get icon index '+' or '-' ? |
cmp byte[edx+3],1 |
jne .close |
dec ah |
.close: |
|
call tl_draw_node_icon_opn_clo ;ðèñîâàíèå èêîíêè îòêðûòîãî èëè çàêðûòîãî óçëà |
bt tl_style,1 |
jae .end_draw |
call tl_draw_node_icon_par_lin ;ðèñîâàíèå ëèíèè ê ðîäèòåëüñêîìó ýëåìåíòó |
call tl_draw_node_icon_par_lin_up ;ðèñîâàíèå âåðòèêàëüíîé ëèíèè ê ðîäèòåëüñêîìó ýëåìåíòó |
.end_draw: |
pop esi edx ecx ebx eax |
ret |
|
;input: |
; ecx = pointer to 1 node struct |
; edx = pointer to some node struct |
;... |
align 4 |
tl_draw_node_icon_opn_clo: ;ðèñóåò èêîíêè îòêðûòîãî èëè çàêðûòîãî óçëà (îáû÷íî + èëè -) |
push eax ebx ecx edx esi |
inc al |
call tl_iterat_next_all ;get next visible item |
cmp edx,ecx |
jle @f |
mov ecx,esi ;load ecx |
cmp al,byte[edx+2] |
jne @f |
ror ebx,16 |
sub bx,tl_img_cx |
ror ebx,16 |
cmp tl_data_img_sys,0 |
jne .draw_img_s |
mov edx,tl_col_txt |
mov eax,13 |
int 0x40 ;draw minus rect, if not system icons |
jmp @f |
.draw_img_s: |
mov ecx,esi ;load ecx |
mov edx,ebx |
ror ecx,16 |
mov dx,cx |
mov cx,bx |
ror ecx,16 |
mov ebx,3 ;rgb = 3 bytes |
imul bx,tl_img_cx |
imul bx,tl_img_cy |
shr eax,8 |
and eax,0xff |
imul ebx,eax ;eax = icon index |
add ebx,tl_data_img_sys |
mov eax,7 |
int 0x40 ;draw minus icon '-' |
@@: |
pop esi edx ecx ebx eax |
ret |
|
;input: |
; al = óðîâåíü ýëåìåíòà |
; ecx = pointer to 1 node struct |
; edx = pointer to some node struct |
;... |
align 4 |
tl_draw_node_icon_par_lin: ;ðèñîâàíèå ëèíèè ê ðîäèòåëüñêîìó ýëåìåíòó |
cmp byte[edx+3],1 |
je .close |
push eax ebx ecx edx esi |
cmp al,0 |
je @f |
; dec al |
; call tl_iterat_perv ;get perv visible item |
|
call tl_iterat_next_all ;get next visible item |
cmp edx,ecx |
jle .line3 ;if end of list |
cmp al,byte[edx+2] |
jne .line3 ;jg ??? |
mov eax,3 ;line in middle element |
jmp .line2 |
.line3: |
mov eax,6 ;line in end element |
.line2: |
|
mov ecx,esi ;load ecx |
ror ebx,16 |
sub bx,tl_img_cx |
ror ebx,16 |
cmp tl_data_img_sys,0 |
jne .draw_img_s |
mov edx,tl_col_txt |
mov eax,13 |
int 0x40 ;draw minus rect, if not system icons |
jmp @f |
.draw_img_s: |
; mov ecx,esi ;load ecx |
mov edx,ebx |
ror ecx,16 |
mov dx,cx |
mov cx,bx |
ror ecx,16 |
mov ebx,3 ;rgb = 3 bytes |
imul bx,tl_img_cx |
imul bx,tl_img_cy |
|
; shr eax,8 |
; and eax,0xff |
imul ebx,eax ;eax = icon index |
add ebx,tl_data_img_sys |
mov eax,7 |
int 0x40 ;draw line icon |
@@: |
pop esi edx ecx ebx eax |
.close: |
ret |
|
|
;input: |
; al = óðîâåíü ýëåìåíòà |
; ecx = pointer to 1 node struct |
; edx = pointer to some node struct |
; edi = pointer to 'TreeList' struct |
align 4 |
tl_draw_node_icon_par_lin_up: |
push eax ebx ecx edx |
push esi |
cmp tl_data_img_sys,0 ;if not image |
je @f |
cmp al,0 |
je @f |
|
xor esi,esi ;â si áóäåì íàñ÷èòûâàòü êîë-âî èêîíîê, íóæíûõ äëÿ ïðîðèñîâêè ëèíèè |
;--- öèêë äëÿ âû÷èñëåíèÿ êîëëè÷åñòâà âåðòèêàëüíûõ ëèíèé --- |
.cycle0: |
call tl_iterat_perv ;get perv visible item |
cmp edx,ecx |
jle .cycle1 ;if begin of list |
|
cmp byte[edx+2],al |
jle .cycle0end ;óðîâåíü âåðõíåãî ýëåìåíòà íå òðåáóåò ïðîðèñîâêè |
inc si |
jmp .cycle0 |
.cycle0end: |
cmp si,0 ;si = êîë-âî èêîíîê ëèíèè êîòîðûå íóæíî íàðèñîâàòü ñâåðõó |
je @f |
shl esi,16 |
|
pop ecx ;esi->ecx |
push ecx ;save esi |
|
ror ebx,16 |
sub bx,tl_img_cx |
ror ebx,16 |
|
mov edx,ebx |
ror ecx,16 |
mov dx,cx |
mov cx,bx |
ror ecx,16 |
mov cx,tl_img_cy ;restore size y (if crop) |
mov ebx,3 ;rgb = 3 bytes |
imul bx,tl_img_cx |
imul bx,tl_img_cy |
add ebx,tl_data_img_sys |
|
add esi,tl_box_top |
add si,tl_capt_cy ;si = âåðõíÿÿ ãðàíèöà îêíà |
mov eax,7 |
;--- öèêë äëÿ ðèñîâàíèÿ âåðòèêàëüíîé ëèíèè --- |
.cycle1: |
sub dx,tl_img_cy ;ïîäíèìàåì êîîðäèíàòó y ââåðõ |
cmp dx,si |
jl @f |
cmp esi,0x10000 |
jl @f |
int 0x40 ;draw line icon |
sub esi,0x10000 ;óìåíüøàåì ñ÷åò÷èê èêîíîê |
jmp .cycle1 |
@@: |
pop esi |
pop edx ecx ebx eax |
ret |
|
;input: |
; edi = pointer to TreeInfo struct |
;output: |
; eax = rows |
align 4 |
tl_get_rows_count: |
push ecx edx |
mov eax,tl_box_height |
sub ax,tl_capt_cy |
xor ecx,ecx |
mov cx,tl_img_cy |
xor edx,edx |
div ecx |
pop edx ecx |
ret |
|
;input: |
; eax = node position |
; ebx = [êîîðäèíàòà ïî îñè x]*65536 + [img_cx] |
; ecx = [êîîðäèíàòà ïî îñè y]*65536 + [img_cy] |
; edx = pointer to some node struct |
; edi = pointer to TreeInfo struct |
align 4 |
tl_draw_node_caption: |
push ebx ecx edx esi |
|
xor esi,esi |
mov si,tl_info_size |
cmp si,tl_info_capt_offs |
jle @f ;if caption size <= 0 |
|
push eax |
call tl_get_node_index ;eax = node index |
imul esi,eax |
pop eax |
add si,tl_info_capt_offs |
add esi,dword[edi] |
mov edx,esi |
|
shr ebx,16 |
add bx,tl_img_cx ;ñäâèãàåì íàäïèñü ïî ãîðèçîíòàëè ---> |
add bx,3 ;îòñòóï |
;bx = coord. x |
call tl_strlen ;eax = strlen |
call tl_get_draw_text_len |
mov cx,bx |
ror ecx,16 |
mov ebx,ecx |
add bx,tl_img_cy ;âûðàâíèâèíèå ïî íèæíåé ãðàíèöå èêîíêè |
sub bx,9 ;îòíèìàåì âûñîòó òåêñòà |
mov ecx,tl_col_txt |
and ecx,0xffffff |
; or ecx,0x80000000 ;text is ASCIIZ |
mov eax,4 |
int 0x40 |
@@: |
pop esi edx ecx ebx |
ret |
|
;input: |
; eax = strlen |
; ebx = text coord x |
;output: |
; esi = text len |
align 4 |
tl_get_draw_text_len: |
push eax ecx edx |
mov esi,eax ;áåðåì äëèííó ñòðîêè |
|
mov eax,tl_box_left |
add eax,tl_box_width |
cmp eax,ebx |
jle .text_null ;åñëè ïîäïèñü ïîëíîñòüþ âñÿ çà ýêðàíîì |
sub eax,ebx |
xor edx,edx |
mov ecx,6 ;øèðèíà ñèñòåìíîãî øðèôòà |
div ecx ;ñìîòðèì ñêîëüêî ñèìâîëîâ ìîæåò ïîìåñòèòüñÿ íà ýêðàíå |
|
cmp esi,eax |
jl @f |
mov esi,eax ;åñëè äëèííà òåêñòà ìåíüøå, ÷åì âñå ìåñòî ïîä ñòðîêó |
jmp @f |
.text_null: |
xor esi,esi |
@@: |
pop edx ecx eax |
ret |
|
;input: |
; esi = pointer to string |
;output: |
; eax = strlen |
align 4 |
tl_strlen: |
mov eax,esi |
@@: |
cmp byte[eax],0 |
je @f |
inc eax |
jmp @b |
@@: |
sub eax,esi |
ret |
|
;input: |
;dword[ebp+ 8] - pointer to node info |
;dword[ebp+12] - options |
;dword[ebp+16] - pointer to 'TreeList' struct |
align 4 |
tl_node_add: ;äîáàâèòü óçåë |
push ebp |
mov ebp,esp |
push eax ebx ecx edx edi |
mov edi,dword[ebp+16] |
|
call tl_info_set_undo |
|
mov ebx,sizeof.TreeList |
imul ebx,tl_info_max_count |
add ebx,tl_data_nodes |
;-- |
call tl_get_cur_node_index ;eax=po_t |
imul eax,sizeof.TreeList |
add eax,tl_data_nodes |
mov edx,eax |
call tl_move_perv |
call tl_get_node_index ;eax = index of pointer [edx] |
;-- |
mov edx,sizeof.TreeList |
shl edx,1 |
add edx,tl_data_nodes |
@@: ;for(i=2;i<nodeMax;i++) |
cmp dword [edx+12],0 |
jne .u0 |
cmp dword [edx+16],0 |
jne .u0 |
|
inc tl_ch_tim |
mov cx,word[ebp+14] ;get type |
mov word[edx],cx |
mov cl,byte[ebp+13] |
mov byte[edx+3],cl ;node[i].clo |
mov byte[edx+2], 0 ;node[i].lev=0 |
bt tl_style,2 ;tl_list_box_mode |
jc .l_box_m |
mov cl,byte[ebp+12] |
mov byte[edx+2],cl ;node[i].lev |
.l_box_m: |
push tl_ch_tim ;node[i].tc=ch_tim; |
pop dword[edx+12] |
mov dword[edx+4], eax ;node[i].perv=po_t; |
;*** copy node data *** |
push esi |
xor ecx,ecx |
mov cx,tl_info_size |
mov esi,ecx |
|
push eax |
call tl_get_node_index ;eax = node index |
imul esi,eax |
pop eax |
add esi,dword[edi] |
mov edi,dword[ebp+8] ;pointer to node data |
xchg edi,esi |
rep movsb |
|
mov esi,edi |
mov edi,dword[ebp+16] ;restore edi |
mov cx,tl_info_capt_offs |
cmp cx,tl_info_size |
jge .no_text_data |
cmp tl_info_capt_len,0 ;ïðîâåðÿåì åñòü ëè îãðàíè÷åíèå íà äëèííó ñòðîêè |
je .no_len_ogran |
add cx,tl_info_capt_len |
and ecx,0xffff |
add esi,ecx |
mov cx,tl_info_size |
sub esi,ecx |
.no_len_ogran: |
dec esi |
mov byte[esi],0 |
.no_text_data: |
pop esi ;restore esi |
|
mov ecx,eax |
imul ecx,sizeof.TreeList |
add ecx,tl_data_nodes ; *** ecx = node[po_t] *** |
add ecx,8 ; *** ecx = node[po_t].next *** |
push dword [ecx] ;node[i].next=node[po_t].next; |
pop dword [edx+8] |
|
call tl_get_node_index ;*** eax = i *** |
cmp eax,tl_info_max_count |
jge .u0 |
|
mov [ecx],eax ;node[po_t].next=i; // ññûëêè ïåðåíàïðàâëÿåì |
mov ecx,[edx+8] ; *** ecx = node[i].next *** |
imul ecx,sizeof.TreeList |
add ecx,tl_data_nodes ; *** ecx = node[node[i].next] *** |
mov [ecx+4],eax ;node[node[i].next].perv=i; |
|
call tb_scrol_resize ;îáðàáîòêà ñêðîëëèíãà |
jmp @f |
.u0: |
add edx,sizeof.TreeList |
cmp edx,ebx ;enf of node memory ? |
jle @b |
@@: |
pop edi edx ecx ebx eax |
pop ebp |
ret 12 |
|
;input: |
; edi = pointer to TreeInfo struct |
align 4 |
tb_scrol_resize: |
push eax ecx edx |
cmp tl_p_scrol,0 ;îáðàáîòêà ñêðîëëèíãà |
je @f |
call tl_get_node_count ;eax = node count |
mov ecx,eax |
call tl_get_rows_count |
cmp ecx,eax |
jg .ye_sb |
xor ecx,ecx |
.ye_sb: |
|
mov edx,tl_p_scrol |
mov dword[edx+20],eax ;+20 .cur_area |
mov dword[edx+16],ecx ;+16 .max_area |
push dword edx ;pointer to scroll struct |
call scroll_bar_vertical.draw |
@@: |
pop edx ecx eax |
ret |
|
;input: |
;dword[ebp+ 8] - pointer to node info |
;dword[ebp+12] - pointer to 'TreeList' struct |
align 4 |
tl_node_set_data: |
push ebp |
mov ebp,esp |
push eax ecx edx edi esi |
mov edi,dword[ebp+12] |
call tl_get_cur_node_index ;eax=po_t |
cmp eax,2 |
jl @f |
xor ecx,ecx |
mov cx,tl_info_size |
imul eax,ecx |
add eax,dword[edi] |
mov edi,eax |
mov esi,dword[ebp+8] ;pointer to node data |
rep movsb |
|
mov esi,edi |
mov edi,dword[ebp+12] ;restore edi |
mov cx,tl_info_capt_offs |
cmp cx,tl_info_size |
jge .no_text_data |
mov ax,tl_info_capt_len ;ïðîâåðÿåì åñòü ëè îãðàíè÷åíèå íà äëèííó òåêñòà |
cmp ax,0 |
je .no_limit |
add cx,ax ;cx = tl_info_capt_offs + tl_info_capt_len |
and ecx,0xffff |
xor eax,eax |
mov ax,tl_info_size |
cmp eax,ecx |
jl .no_limit ;ïîëüçîâàòåëü çàäàë ñëèøêîì áîëüøóþ äëèííó òåêñòà |
add esi,ecx |
sub esi,eax |
.no_limit: |
dec esi |
mov byte[esi],0 ;îáíóëÿåì ïîñëåäíèé ñèìâîë ïîäïèñè, ÷òî-áû íå ãëþ÷èëî åñëè ïîëüçîâàòåëü çàäàë íåïðàâèëüíóþ ñòðóêòóðó |
.no_text_data: |
|
@@: |
pop esi edi edx ecx eax |
pop ebp |
ret 8 |
|
;input: |
;dword[ebp+ 8] - pointer to 'TreeList' struct |
align 4 |
tl_node_get_data: ;âçÿòü óêàçàòåëü íà äàííûå óçëà ïîä êóðñîðîì |
push ebp |
mov ebp,esp |
push eax ecx edi |
mov edi,dword[ebp+8] |
call tl_get_cur_node_index ;eax=po_t |
mov dword[ebp+8],0 ;if return 0 pointer |
cmp eax,2 |
jl @f |
xor ecx,ecx |
mov cx,tl_info_size |
imul eax,ecx |
add eax,dword[edi] |
mov dword[ebp+8],eax ;return node data pointer |
@@: |
pop edi ecx eax |
pop ebp |
ret |
|
;input: |
;dword[ebp+ 8] - node index |
;dword[ebp+12] - pointer to 'TreeList' struct |
align 4 |
tl_node_poi_get_info: ;âçÿòü óêàçàòåëü íà ñòðóêòóðó óçëà â óêàçàííîé ïîçèöèè |
push ebp |
mov ebp,esp |
push eax ecx edx edi |
mov edi,dword[ebp+12] |
mov eax,dword[ebp+8] |
|
;cycle to nodes |
mov edx,tl_data_nodes |
mov ecx,edx |
add ecx,sizeof.TreeList |
@@: |
call tl_iterat_next_all |
cmp edx,ecx |
jle @f |
dec eax |
cmp eax,0 |
jg @b |
jmp .find |
@@: |
xor edx,edx |
.find: |
mov dword[ebp+12],edx |
pop edi edx ecx eax |
pop ebp |
ret 4 |
|
;input: |
;dword[ebp+ 8] - node param struct |
;dword[ebp+12] - pointer to 'TreeList' struct |
align 4 |
tl_node_poi_get_next_info: ;âçÿòü óêàçàòåëü íà ñëåäóùóþ ñòðóêòóðó óçëà |
push ebp |
mov ebp,esp |
push ecx edx edi |
mov edi,dword[ebp+12] |
mov edx,dword[ebp+8] |
|
mov ecx,tl_data_nodes |
add ecx,sizeof.TreeList |
|
call tl_iterat_next_all |
cmp edx,ecx |
jg @f |
xor edx,edx |
@@: |
|
mov dword[ebp+12],edx |
pop edi edx ecx |
pop ebp |
ret 4 |
|
;input: |
;dword[ebp+ 8] - node param struct |
;dword[ebp+12] - pointer to 'TreeList' struct |
align 4 |
tl_node_poi_get_data: ;âçÿòü óêàçàòåëü íà äàííûå óçëà |
push ebp |
mov ebp,esp |
push eax ecx edx edi |
mov edi,dword[ebp+12] |
mov edx,dword[ebp+8] |
|
mov dword[ebp+12],0 |
call tl_get_node_index ;eax = node index |
cmp eax,2 |
jl @f |
xor ecx,ecx |
mov cx,tl_info_size |
imul eax,ecx |
add eax,dword[edi] |
mov dword[ebp+12],eax ;return node data pointer |
@@: |
pop edi edx ecx eax |
pop ebp |
ret 4 |
|
;input: |
; edi = pointer 'tl' struct |
;output: |
; eax = index of current node |
align 4 |
tl_get_cur_node_index: ;áåðåò ïîçèöèþ ïîä êóðñîðîì |
push ecx edx |
;cycle to nodes |
xor eax,eax |
mov edx,tl_data_nodes |
mov ecx,edx |
add ecx,sizeof.TreeList |
@@: |
call tl_iterat_next |
cmp edx,ecx |
jle @f |
cmp eax,tl_cur_pos |
je @f |
inc eax |
jmp @b |
@@: |
mov eax,edx |
sub eax,tl_data_nodes |
xor edx,edx |
mov ecx,sizeof.TreeList |
div ecx |
pop edx ecx |
ret |
|
;input: |
; edx = pointer node memory |
; edi = pointer 'tl' struct |
;output: |
; eax = struct index of current node |
align 4 |
tl_get_node_index: ;áåðåò ïîçèöèþ óêàçàííîãî ñèìâîëà |
push ecx edx |
mov eax,edx |
sub eax,tl_data_nodes |
xor edx,edx |
mov ecx,sizeof.TreeList |
div ecx |
pop edx ecx |
ret |
|
align 4 |
tl_node_delete: ;óäàëèòü óçåë |
push ebp |
mov ebp,esp |
push eax edx edi |
mov edi,dword[ebp+8] |
call tl_get_cur_node_index ;eax=po_t |
cmp eax,2 |
jl @f |
imul eax,sizeof.TreeList |
add eax,tl_data_nodes |
mov edx,eax |
inc tl_ch_tim |
mov eax,tl_ch_tim |
mov dword[edx+16],eax |
call tb_scrol_resize ;îáðàáîòêà ñêðîëëèíãà |
@@: |
pop edi edx eax |
pop ebp |
ret 4 |
|
align 4 |
tl_cur_beg: ;ïîñòàâèòü êóðñîð íà ïåðâûé óçåë |
push ebp |
mov ebp,esp |
push edi |
mov edi,dword[ebp+8] |
mov tl_cur_pos,0 |
cmp tl_p_scrol,0 |
je @f |
mov edi,tl_p_scrol |
mov dword[edi+24],0 |
push dword edi |
mov edi,dword[ebp+8] |
call scroll_bar_vertical.draw |
@@: |
pop edi |
|
pop ebp |
ret 4 |
|
align 4 |
tl_cur_next: ;ïåðåíåñòè êóðñîð íà 1 ïîçèöèþ íèæå |
push ebp |
mov ebp,esp |
push eax ebx edi esi |
mov edi,dword[ebp+8] |
call tl_get_node_count ;eax = node count |
;inc eax |
cmp tl_cur_pos,eax |
jge .no_redraw |
mov esi,tl_box_top |
add esi,tl_box_height ;esi = coord bottom border |
call tl_draw_null_cursor ;ñòèðàåì êóðñîð |
inc tl_cur_pos |
|
cmp tl_p_scrol,0 ;if not scrol struct |
je @f |
call tl_get_rows_count ;eax = rows count |
mov ebx,tl_p_scrol |
add eax,dword[ebx+24] ;.position +24 |
cmp tl_cur_pos,eax |
jl @f |
inc dword[ebx+24] ;.position +24 |
push dword ebx |
call scroll_bar_vertical.draw |
|
mov edi,dword[ebp+8] ;restore edi |
push dword edi |
call tl_draw ;ïîëíàÿ ïåðåðèñîâêà îêíà |
jmp .no_redraw |
@@: |
mov edi,dword[ebp+8] ;restore edi |
call tl_draw_cursor ;ïåðåðèñîâêà êóðñîðà |
call tl_draw_caption_cur_pos |
.no_redraw: |
pop esi edi ebx eax |
pop ebp |
ret 4 |
|
|
;input: |
; edi = pointer 'tl' struct |
;output: |
; eax = struct index of current node |
align 4 |
tl_get_node_count: ;áåðåò ÷èñëî âñåõ âèäèìûõ óçëîâ (íå ñ÷èòàÿ çàêðûòûõ äî÷åðíèõ) |
push ecx edx |
;cycle to nodes |
xor eax,eax |
mov edx,tl_data_nodes |
mov ecx,edx |
add ecx,sizeof.TreeList |
@@: |
call tl_iterat_next |
cmp edx,ecx |
jle @f |
inc eax |
jmp @b |
@@: |
pop edx ecx |
ret |
|
;input: |
; edi = pointer 'tl' struct |
;output: |
; eax = struct index of current node |
align 4 |
tl_get_node_count_all: ;áåðåò ÷èñëî âñåõ âèäèìûõ óçëîâ (ñ÷èòàÿ çàêðûòûå äî÷åðíèå) |
push ecx edx |
;cycle to nodes |
xor eax,eax |
mov edx,tl_data_nodes |
mov ecx,edx |
add ecx,sizeof.TreeList |
@@: |
call tl_iterat_next_all |
cmp edx,ecx |
jle @f |
inc eax |
jmp @b |
@@: |
pop edx ecx |
ret |
|
align 4 |
tl_cur_perv: ;ïåðåíåñòè êóðñîð íà 1 ïîçèöèþ âûøå |
push ebp |
mov ebp,esp |
push eax edi esi |
mov edi,dword[ebp+8] |
cmp tl_cur_pos,0 |
je .no_redraw |
mov esi,tl_box_top |
add esi,tl_box_height ;esi = coord bottom border |
call tl_draw_null_cursor ;ñòèðàåì êóðñîð |
dec tl_cur_pos ;äâèãàåì êóðñîð ââåðõ |
|
cmp tl_p_scrol,0 ;åñëè åñòü óêàçàòåëü íà ñêðîëëèíã |
je @f |
mov eax,tl_p_scrol |
cmp dword[eax+24],0 ;åñëè ñêðîëëèíã íà âåðõó, âûõîäèì |
je @f |
mov edi,tl_cur_pos |
cmp edi,dword[eax+24] ;åñëè êóðñîð óøåë âûøå ñêðîëëèíãà, òîãäà îïóñêàåì ñêðîëëèíã |
jge @f |
dec dword[eax+24] |
push dword eax |
mov edi,dword[ebp+8] |
call scroll_bar_vertical.draw |
mov edi,dword[ebp+8] ;restore edi |
push dword edi |
call tl_draw ;ïîëíàÿ ïåðåðèñîâêà îêíà |
jmp .no_redraw |
@@: |
mov edi,dword[ebp+8] ;restore edi |
;mov esi,tl_box_top |
;add esi,tl_box_height ;esi = coord bottom border |
call tl_draw_cursor ;ïåðåðèñîâêà êóðñîðà |
call tl_draw_caption_cur_pos |
.no_redraw: |
pop esi edi eax |
pop ebp |
ret 4 |
|
align 4 |
tl_cur_page_up: ;ïåðåíåñòè êóðñîð íà 1 ñòðàíèöó âûøå |
push ebp |
mov ebp,esp |
push eax edi esi |
mov edi,dword[ebp+8] |
|
cmp tl_p_scrol,0 ;åñëè åñòü óêàçàòåëü íà ñêðîëëèíã |
je .no_redraw |
|
mov esi,tl_p_scrol |
call tl_get_rows_count ;eax = rows count |
|
cmp tl_cur_pos,0 |
jne @f |
cmp dword[esi+24],0 ;åñëè ñêðîëëèíã íà âåðõó, âûõîäèì |
jne @f |
jmp .no_redraw |
@@: |
cmp tl_cur_pos,eax ;ïðîâåðÿåì ïîçèöèþ êóðñîðà è êîë-âî ñòîê íà ñòðàíèöå |
jl @f ;åñëè ìåíüøå, òî ïðèðàâíèâàåì ê 0, ÷òî-áû íå îòíÿòü áîëüøå ÷åì íàäî |
sub tl_cur_pos,eax |
jmp .cursor |
@@: |
mov tl_cur_pos,0 |
.cursor: |
cmp dword[esi+24],eax |
jl @f |
sub dword[esi+24],eax |
jmp .scroll |
@@: |
mov dword[esi+24],0 |
.scroll: |
;ïåðåðèñîâêè îêíà è ñêðîëëèíãà |
push dword edi |
call tl_draw ;draw window |
push dword esi |
call scroll_bar_vertical.draw |
.no_redraw: |
pop esi edi eax |
pop ebp |
ret 4 |
|
align 4 |
tl_cur_page_down: ;ïåðåíåñòè êóðñîð íà 1 ñòðàíèöó íèæå |
push ebp |
mov ebp,esp |
push eax ebx ecx edi esi |
;eax - êîë-âî ñòðîê íà ñòðàíèöå |
;ebx - ìàêñ. ïîçèöèÿ êóðñîðà |
;ecx - ìàêñ. ïîçèöèÿ ñêðîëëèíãà |
mov edi,dword[ebp+8] |
|
cmp tl_p_scrol,0 ;åñëè åñòü óêàçàòåëü íà ñêðîëëèíã |
je .no_redraw |
|
mov esi,tl_p_scrol |
call tl_get_node_count ;eax = node count |
mov ebx,eax |
call tl_get_rows_count ;eax = rows count |
|
mov ecx,ebx |
inc ecx ;åñëè íèæíèé óçåë âèäåí íà ïîëîâèíó |
cmp ecx,eax ;if (ecx>eax) { ecx=ecx-eax } else { ecx=0 } |
jl @f |
sub ecx,eax ;óìåíüøàåì ìàêñèìàëüíóþ ïîçèöèþ ñêðîëëèíãà, òàê ÷òî-áû áûëè âèäíû ïîñëåäíèå óçëû |
jmp .control |
@@: |
xor ecx,ecx ;ecx=0 - âñå óçëû âëàçÿò â ýêðàí, ñêðîëëèíã íå íóæåí |
.control: |
|
cmp tl_cur_pos,ebx ;êóðñîð âíèçó ? |
jl @f |
cmp dword[esi+24],ecx ;ñêðîëëèíã âíèçó ? |
jl @f |
jmp .no_redraw |
@@: |
|
add tl_cur_pos,eax ;ïåðåìåùàåì êóðñîð |
cmp tl_cur_pos,ebx |
jl @f |
mov tl_cur_pos,ebx |
@@: |
|
add dword[esi+24],eax ;ïåðåìåùàåì ñêðîëëèíã |
cmp dword[esi+24],ecx |
jl @f |
mov dword[esi+24],ecx |
@@: |
|
;ïåðåðèñîâêè îêíà è ñêðîëëèíãà |
push dword edi |
call tl_draw ;draw window |
push dword esi |
call scroll_bar_vertical.draw |
.no_redraw: |
pop esi edi ecx ebx eax |
pop ebp |
ret 4 |
|
align 4 |
tl_node_close_open: ;îòêðûòü/çàêðûòü óçåë (ðàáîòàåò ñ óçëàìè êîòîðûå èìåþò äî÷åðíèå óçëû) |
push ebp |
mov ebp,esp |
push eax edx edi |
mov edi,dword[ebp+8] |
call tl_get_cur_node_index ;eax = ïîçèöèÿ óçëà íà êîòîðîì ñòîèò êóðñîð |
cmp eax,2 ;êóðñîð ñòîèò íà óçëå ? |
jl @f |
imul eax,sizeof.TreeList |
add eax,tl_data_nodes |
;eax = óêàçàòåëü íà ñòðóêòóðó óçëà âûáðàííîãî êóðñîðîì |
push dword edi |
push dword eax |
call tl_node_poi_get_next_info |
pop dword edx ;edx = óêàçàòåëü íà ñòðóêòóðó óçëà êîòîðûé èäåò ïîñëå óçëà eax |
cmp edx,0 ;åñòü ëè óçëû íèæå âûáðàííîãî íàìè ? |
je @f |
mov dl,byte[edx+2] ;áåðåì óðîâåíü íèæíåãî óçëà |
cmp byte[eax+2],dl ;+2 = .lev |
jge @f ;åñëè íèæíèå óçëû ìåíüøåãî óðîâíÿ, çíà÷èò îíè íå äî÷åðíèå, êîíåö ôóíêöèè |
xor byte[eax+3],1 ;+3 = .clo *** îòêðûòèå/çàêðûòèå óçëà *** |
call tb_scrol_resize ;îáðàáîòêà ñêðîëëèíãà |
|
push dword edi |
call tl_draw ;îáíîâëåíèå îêíà |
@@: |
pop edi edx eax |
pop ebp |
ret 4 |
|
align 4 |
tl_node_lev_inc: ;óâåëè÷èòü óðîâåíü |
push ebp |
mov ebp,esp |
push eax ecx edx edi |
mov edi,dword[ebp+8] |
bt tl_style,2 ;tl_list_box_mode |
jc @f |
call tl_get_cur_node_index ;eax=po_t |
cmp eax,2 |
jl @f |
mov ecx,tl_data_nodes |
imul eax,sizeof.TreeList |
add eax,ecx ;eax = pointer to some node struct |
add ecx,sizeof.TreeList ;ecx = pointer to 1 node struct |
|
mov edx,eax |
call tl_iterat_perv ;ïðîâåðÿåì åñòü ëè âåðõíèé óçåë |
cmp edx,ecx |
jle @f ;åñëè âåðõíåãî óçëà íåò òî òåêóùèé óçåë íå äâèãàåì |
mov cl,byte[edx+2] ;áåðåì óðîâåíü ðîäèòåëüñêîãî óçëà |
inc cl ;äîáàâëÿåì 1 è ïîëó÷àåì ìàêñèìàëüíîå çíà÷åíèå |
cmp byte[eax+2],cl |
jge @f |
inc byte[eax+2] ;óâåëè÷èâàåì çíà÷åíèå óçëà |
@@: |
pop edi edx ecx eax |
pop ebp |
ret 4 |
|
align 4 |
tl_node_lev_dec: ;óìåíüøèòü óðîâåíü |
push ebp |
mov ebp,esp |
push eax edi |
mov edi,dword[ebp+8] |
call tl_get_cur_node_index ;eax=po_t |
cmp eax,2 |
jl @f |
imul eax,sizeof.TreeList |
add eax,tl_data_nodes |
cmp byte[eax+2],0 |
je @f |
dec byte[eax+2] |
@@: |
pop edi eax |
pop ebp |
ret 4 |
|
align 4 |
tl_node_move_up: ;ïåðåìåùàåì óçåë ââåðõ |
push ebp |
mov ebp,esp |
push eax ebx ecx edx edi esi |
mov edi,dword[ebp+8] |
call tl_get_cur_node_index ;eax=po_t |
cmp eax,2 |
jl @f |
mov ebx,eax ;copy index of node struct |
mov edx,tl_data_nodes |
mov ecx,edx |
add ecx,sizeof.TreeList |
imul eax,sizeof.TreeList |
add eax,edx ;eax = pointer to 2 node struct |
mov edx,eax ;edx = pointer to 2 node struct |
mov esi,eax ;esi = pointer to 2 node struct |
call tl_iterat_perv ;edx = pointer to 1 node struct |
call tl_get_node_index ;eax = index of 1 node struct |
cmp edx,ecx |
jle @f |
cmp dword[edx+8],ebx ;+8 next |
jne .po8 |
call tl_node_move_po6 ;óçëû èäóò ïîäðÿä ìåíÿåì 6 ññûëîê |
jmp .cur_mov |
.po8: |
call tl_node_move_po8 ;óçëû èäóò íå ïîäðÿä ìåíÿåì 8 ññûëîê |
.cur_mov: |
push dword edi |
call tl_cur_perv |
push dword edi |
call tl_draw |
@@: |
pop esi edi edx ecx ebx eax |
pop ebp |
ret 4 |
|
align 4 |
tl_node_move_down: ;ïåðåìåùàåì óçåë âíèç |
push ebp |
mov ebp,esp |
push eax ebx ecx edx edi esi |
mov edi,dword[ebp+8] |
call tl_get_cur_node_index ;eax=po_t |
cmp eax,2 |
jl @f |
mov ebx,eax ;copy index of node struct |
mov edx,tl_data_nodes |
mov ecx,edx |
add ecx,sizeof.TreeList |
imul eax,sizeof.TreeList |
add eax,edx ;eax = pointer to 1 node struct |
mov edx,eax ;edx = pointer to 1 node struct |
mov esi,eax ;esi = pointer to 1 node struct |
call tl_iterat_next ;edx = pointer to 2 node struct |
call tl_get_node_index ;eax = index of 2 node struct |
cmp edx,ecx |
jle @f |
cmp dword[esi+8],eax ;+8 next |
jne .po8 |
xchg eax,ebx ;ìåíÿå ïîðÿäîê ñëåäîâàíèÿ çàìåíÿåìûõ óçëîâ |
xchg edx,esi |
call tl_node_move_po6 ;óçëû èäóò ïîäðÿä ìåíÿåì 6 ññûëîê |
jmp .cur_mov |
.po8: ;à òóò ïîðÿäîê ñëåäîâàíèÿ óçëîâ íå ìåíÿåì |
call tl_node_move_po8 ;óçëû èäóò íå ïîäðÿä ìåíÿåì 8 ññûëîê |
.cur_mov: |
push dword edi |
call tl_cur_next |
push dword edi |
call tl_draw |
@@: |
pop esi edi edx ecx ebx eax |
pop ebp |
ret 4 |
|
align 4 |
tl_node_move_po6: |
mov ecx,edx ;save node pointer |
call tl_move_perv |
mov dword[edx+8],ebx |
|
mov edx,esi |
call tl_move_next |
mov dword[edx+4],eax |
mov edx,ecx ;restore node pointer |
|
;+4 perv |
mov ecx,dword[edx+4] |
mov dword[esi+4],ecx |
;+8 next |
mov ecx,dword[esi+8] |
mov dword[edx+8],ecx |
|
mov dword[edx+4],ebx |
mov dword[esi+8],eax |
ret |
|
;input |
;eax = index 1 node struct |
;ebx = index 2 node struct |
;edx = pointer 1 node struct |
;esi = pointer 2 node struct |
;edi = pointer to 'TreeList' struct |
;output: |
;eax = ? |
;ebx = ? |
;ecx = ? |
align 4 |
tl_node_move_po8: |
; push ecx |
mov ecx,edx ;save node pointer |
call tl_move_perv |
mov dword[edx+8],ebx |
mov edx,ecx |
call tl_move_next |
mov dword[edx+4],ebx |
mov edx,esi |
call tl_move_perv |
mov dword[edx+8],eax |
mov edx,esi |
call tl_move_next |
mov dword[edx+4],eax |
mov edx,ecx ;restore node pointer |
; pop ecx |
|
;+4 perv |
mov eax,dword[edx+4] |
mov ebx,dword[esi+4] |
xchg eax,ebx |
mov dword[edx+4],eax |
mov dword[esi+4],ebx |
;+8 next |
mov eax,dword[edx+8] |
mov ebx,dword[esi+8] |
xchg eax,ebx |
mov dword[edx+8],eax |
mov dword[esi+8],ebx |
ret |
|
;input: |
; edi = pointer to 'TreeList' struct |
align 4 |
tl_draw_caption_cur_pos: |
cmp tl_capt_cy,9 ;9 - minimum caption height |
jl @f |
push eax ebx ecx edx edi esi |
mov ebx,edi ;calculate cursor position |
mov eax,tl_cur_pos |
inc eax |
lea edi,[txt_capt_cur] |
add edi,7 |
call tl_convert_to_str |
mov edi,ebx |
|
mov eax,4 ;draw text captions |
mov ebx,tl_box_left |
shl ebx,16 |
add ebx,5*65536+3 |
add ebx,tl_box_top |
mov ecx,tl_col_txt |
or ecx,0xc0000000 ;0x40000000 çàêðàøèâàòü ôîí öâåòîì edi |
lea edx,[txt_capt_cur] |
mov edi,tl_col_zag |
int 0x40 |
|
pop esi edi edx ecx ebx eax |
@@: |
ret |
|
;input: |
;dword[ebp+ 8] - memory size |
;dword[ebp+12] - pointer to memory |
;dword[ebp+16] - options: 0 - first element, 1 - add next element |
;dword[ebp+20] - pointer to 'TreeList' struct |
;output: |
;dword[ebp+ 8] - error code |
align 4 |
tl_save_mem: |
push ebp |
mov ebp,esp |
push eax ebx ecx edx edi esi |
mov esi,dword[ebp+12] |
mov edi,dword[ebp+20] |
|
cmp dword[ebp+16],0 ;add mode |
je @f |
push dword edi |
push dword esi |
call tl_get_mem_size ;áåðåì ðàçìåð ðàíåå ñîõðàí¸ííûõ äàííûõ |
pop ebx |
add esi,ebx |
@@: |
|
xor ebx,ebx |
mov bx,tl_info_size |
|
call tl_get_node_count_all ;eax = all node count |
|
mov ecx,eax ;âû÷èñëÿåì ñêîëüêî ïàìÿòè äîëæíî áûòü çàïîëíåíî |
imul ecx,ebx ;óìíîæàåì íà ðàçìåð ñòðóêòóðû óçëà |
add ecx,tl_save_load_heder_size+1 ;element header +1 end element sumbol |
add ecx,esi ;äîáàâëÿåì óêàçàòåëü íà íà÷àëî ïàìÿòè (ñ ó÷åòîì ðàíåå çàïèñàííûõ ñòðóêòóð) |
sub ecx,dword[ebp+12] ;îòíèìàåì óêàçàòåëü íà íà÷àëî ïàìÿòè (áåç ðàíåå çàïèñàííûõ ñòðóêòóð) |
cmp ecx,dword[ebp+8] ;ecx = element memory size |
jg .err_mem_size |
|
;save tree params (in header) |
mov dword[esi],'tree' |
mov word[esi+4],bx |
mov dword[esi+6],eax ;element count |
|
mov eax,tl_style |
mov dword[esi+10],eax |
|
mov eax,tl_cur_pos |
mov dword[esi+14],eax |
|
mov ax,tl_info_capt_offs |
mov word[esi+18],ax |
|
mov ax,tl_info_capt_len |
mov word[esi+20],ax |
|
;copy scroll position |
mov edx,tl_p_scrol |
mov eax,dword[edx+24] ;+24 .position |
mov dword[esi+22],eax |
|
add esi,tl_save_load_heder_size ;add header size |
|
;cycle to nodes |
mov edx,tl_data_nodes |
mov ecx,edx |
add ecx,sizeof.TreeList |
@@: |
call tl_iterat_next_all |
cmp edx,ecx |
jle @f |
;save node params |
call tl_get_node_index ;eax = index of pointer [edx] |
mov dword[esi],eax |
|
add esi,4 |
mov eax,dword[edx] ;eax = (type; lev; clo) |
mov dword[esi],eax |
add esi,4 |
|
push dword edi |
push dword edx |
call tl_node_poi_get_data |
pop dword eax |
|
;call tl_node_copy_data |
push ecx edi |
mov edi,eax |
mov ecx,ebx |
xchg esi,edi |
rep movsb |
mov esi,edi |
pop edi ecx |
;add esi,ebx |
jmp @b |
@@: |
mov byte[esi],0 ;end of 'treelist' |
mov dword[ebp+20],0 ;return error code |
jmp @f |
.err_mem_size: |
or dword[ebp+20],tl_err_save_memory_size |
@@: |
pop esi edi edx ecx ebx eax |
pop ebp |
ret 12 |
|
;input: |
;dword[ebp+ 8] - memory size |
;dword[ebp+12] - pointer to memory |
;word[ebp+16] - options: element index |
;word[ebp+18] - options: 2*(add mode)+(init mode) |
;dword[ebp+20] - pointer to 'TreeList' struct |
;output: |
;dword[ebp+ 8] - error code |
align 4 |
tl_load_mem: |
push ebp |
mov ebp,esp |
push eax ebx ecx edx edi esi |
mov esi,dword[ebp+12] |
mov edi,dword[ebp+20] |
|
mov dword[ebp+20],0 ;return error code |
|
xor ecx,ecx |
mov cx,word[ebp+16] |
cmp cx,0 ;load in array mode |
je @f |
; push dword edi |
; push dword esi |
; call tl_get_mem_size ;áåðåì ðàçìåð ðàíåå ñîõðàí¸ííûõ äàííûõ |
; pop ebx |
; add esi,ebx |
.beg_cycle: |
cmp dword[esi],'tree' |
jne .no_tree |
xor ebx,ebx |
mov bx,word[esi+4] |
add bx,8 |
imul ebx,dword[esi+6] |
add ebx,tl_save_load_heder_size |
add esi,ebx |
loop .beg_cycle |
@@: |
|
cmp dword[esi],'tree' |
jne .no_tree |
bt word[ebp+18],1 ;load in add mode |
jc @f |
push dword edi |
call tl_info_clear |
@@: |
|
xor ebx,ebx |
mov bx,word[esi+4] ;info_size |
cmp bx,tl_info_size |
je @f |
or dword[ebp+20],tl_err_load_info_size |
@@: |
mov ecx,dword[esi+6] ;count nodes |
cmp ecx,1 |
jl .end_f |
mov edx,esi ;save header pointer |
add esi,tl_save_load_heder_size |
|
@@: |
;load node params |
push dword edi |
mov eax,dword[esi+4] |
ror eax,16 |
push dword eax ;options (type; lev; clo) |
add esi,8 |
push dword esi |
call tl_node_add |
|
push dword edi |
call tl_cur_next |
;... |
add esi,ebx |
loop @b |
|
bt word[ebp+18],1 ;load in add mode |
jc .no_tree |
mov eax,dword[edx+14] ;set cursor pos |
mov tl_cur_pos,eax |
mov eax,dword[edx+22] ;set scroll pos |
mov ebx,tl_p_scrol |
cmp ebx,0 |
je .end_f |
mov dword[ebx+24],eax ;+24 .position |
push dword ebx ;pointer to scroll struct |
call scroll_bar_vertical.draw |
|
jmp .end_f |
.no_tree: |
mov dword[ebp+20],tl_err_load_caption |
.end_f: |
pop esi edi edx ecx ebx eax |
pop ebp |
ret 12 |
|
;input: |
;dword[ebp+ 8] - pointer to memory |
;dword[ebp+12] - pointer to 'TreeList' struct |
;output: |
;dword[ebp+ 8] - error code |
align 4 |
tl_get_mem_size: ;áåðåò ðàçìåð ïàìÿòè çàíÿòîé ôóíêöèåé tl_save_mem ïðè ñîõðàíåíèè ýëåìåíòîâ |
push ebp |
mov ebp,esp |
push ebx edi esi |
mov esi,dword[ebp+ 8] |
mov edi,dword[ebp+12] |
@@: |
cmp dword[esi],'tree' |
jne @f |
xor ebx,ebx |
mov bx,word[esi+4] |
add bx,8 ;ðàçìåð äîïîëíèòåëüíîé èíôîðìàöèè îá óçëå (èíäåêñ çàïèñè; èíäåêñ èêîíêè, óðîâåíü, ...) |
imul ebx,dword[esi+6] |
add ebx,tl_save_load_heder_size |
add esi,ebx |
jmp @b |
@@: |
sub esi,dword[ebp+ 8] |
mov dword[ebp+12],esi ;âîçâðàùàåì ðàçìåð áëîêà ïàìÿòè |
pop esi edi edx |
pop ebp |
ret 4 |
|
|
;ascii scan key |
; 13 28 Enter |
; 32 57 Space |
; 178 72 Up |
; 177 80 Down |
; 176 75 Left |
; 179 77 Right |
; 182 83 Delete |
; 184 73 Pg Up |
; 183 81 Pg Dn |
|
tl_key_ascii db 13,32,178,177,176,179,182,184,183 |
tl_key_scan db 28,57, 72, 80, 75, 77, 83, 73, 81 |
|
txt_capt_cur db 'âப ',0 |
txt_capt_otm db '⬥ë ',0 |
|
;ýòîò êîä íå ìîé, îí ïðåîáðàçóåò ÷èñëî â ñòðîêó |
;input: |
; eax = value |
; edi = string buffer |
align 4 |
tl_convert_to_str: |
pushad |
mov dword[edi+1],0x20202020 |
call .str |
popad |
ret |
|
align 4 |
.str: |
mov ecx,0x0a ;çàäàåòñÿ ñèñòåìà ñ÷èñëåíèÿ èçìåíÿþòñÿ ðåãèñòðû ebx,eax,ecx,edx âõîäíûå ïàðàìåòðû eax - ÷èñëî |
;ïðåðåâîä ÷èñëà â ASCII ñòðîêó âçîäíûå äàííûå ecx=ñèñòåìà ñ÷èñëåíÿ edi àäðåñ êóäà çàïèñûâàòü, áóäåì ñòðîêó, ïðè÷åì êîíåö ïåðåìåííîé |
cmp eax,ecx ;ñðàâíèòü åñëè â eax ìåíüøå ÷åì â ecx òî ïåðåéòè íà @@-1 ò.å. íà pop eax |
jb @f |
xor edx,edx ;î÷èñòèòü edx |
div ecx ;ðàçäåëèòü - îñòàòîê â edx |
push edx ;ïîëîæèòü â ñòåê |
;dec edi ;ñìåùåíèå íåîáõîäèìîå äëÿ çàïèñè ñ êîíöà ñòðîêè |
call .str;ïåðåéòè íà ñàìó ñåáÿ ò.å. âûçâàòü ñàìó ñåáÿ è òàê äî òîãî ìîìåíòà ïîêà â eax íå ñòàíåò ìåíüøå ÷åì â ecx |
pop eax |
@@: ;cmp al,10 ;ïðîâåðèòü íå ìåíüøå ëè çíà÷åíèå â al ÷åì 10 (äëÿ ñèñòåìû ñ÷èñëåíÿ 10 äàííàÿ êîìàíäà - ëèøíàÿ)) |
;sbb al,$69 ;- ÷åñòíî äàííàÿ èíñòðóêöèÿ ìåíÿ çàñòàâëÿåò çàäóìàòüñÿ ò.å. ÿ íå çíàþ êàê ýòî ðàáîòàåò |
;das ;ïîñëå äàííîé êîìàíäû êàê áû ïðîèñõîäèò óìåíüøåíèå al íà 66h (â êíèãå íàïèñàíî äðóãîå) |
or al,0x30 ;äàííàÿ êîìàíäà êîðî÷å ÷åì äâå âûøå |
stosb ;çàïèñàòü ýëåìåíò èç ðåãèñòðà al â ÿ÷åêó ïàìÿòè es:edi |
ret ;âåðíóòüñÿ ÷åíü èíòåðåñíûé õîä ò.ê. ïîêà â ñòåêå õðàíèòüñÿ êîë-âî âûçîâîâ òî ñòîëüêî ðàç ìû è áóäåì âûçûâàòüñÿ |
} |