; ; Texture Manager ; align 4 proc find_texture uses ebx ecx, context:dword, h:dword mov ebx,[context] mov ebx,[ebx+offs_cont_shared_state+4] ;ebx = &texture_hash_table mov eax,[h] and eax,0xff shl eax,2 add eax,ebx ;eax = &context.shared_state.texture_hash_table[h % TEXTURE_HASH_TABLE_SIZE] ; [eax] - указатель на текстуру, получаемую через хеш таблицу mov ecx,[h] ; ecx - указатель на искомую текстуру @@: cmp dword[eax],0 je .no_found mov ebx,[eax] cmp dword[ebx+offs_text_handle],ecx je .found mov eax,[ebx+offs_text_next] jmp @b .no_found: xor eax,eax ;ret NULL .found: ret endp align 4 proc free_texture uses eax ebx ecx edx, context:dword, h:dword mov edx,[context] stdcall find_texture,edx,[h] ;t=find_texture(context,h) cmp dword[eax+offs_text_prev],0 ;if (t.prev==NULL) jne .else mov edx,[edx+offs_cont_shared_state+4] ;edx = &context.shared_state.texture_hash_table[0] mov ebx,[eax+offs_text_handle] and ebx,0xff shl ebx,2 add edx,ebx ;edx = &context.shared_state.texture_hash_table[t.handle % TEXTURE_HASH_TABLE_SIZE] mov ebx,[eax+offs_text_next] mov [edx],ebx ;*ht=t.next jmp @f .else: mov ebx,[eax+offs_text_prev] mov ecx,[eax+offs_text_next] mov [ebx+offs_text_next],ecx ;t.prev.next=t.next @@: cmp dword[eax+offs_text_next],0 ;if (t.next!=NULL) je @f mov ebx,[eax+offs_text_next] mov ecx,[eax+offs_text_prev] mov [ebx+offs_text_prev],ecx ;t.next.prev=t.prev @@: xor ebx,ebx mov ecx,[eax+offs_text_images] ;im=&t.images[0] .cycle_0: ;for(i=0;imax) jle @f mov ebx,[edx+offs_text_handle] ;max=t.handle @@: mov edx,[edx+offs_text_next] ;t=t.next jmp .cycle_1 .cycle_1_end: inc ecx jmp .cycle_0 .cycle_0_end: xor ecx,ecx ;i=0 mov esi,[textures] .cycle_2: ;for(i=0;i