03-02-2010, 01:28 PM
To read single sprite you need to:
To read all sprites you should get whole file at once. It can process 30 000 sprites in 1 second:
- open Tibia.spr file
- go to 6+SpriteID*4
- read four-byte address
- read some bytes from file at this address as offset, at least 4KB
- allocate 32*32*4 byte buffer
- pass buffer and readed data to function
- remember to free 'some bytes'
To read all sprites you should get whole file at once. It can process 30 000 sprites in 1 second:
select asm
proc readSprSprite dest, source cld mov esi, [source] mov edi, [dest] add esi, 3 lodsw movzx ecx, ax ; test ecx, ecx it may not be useful ; jz .skip add ecx, esi .petla: push ecx lodsw movzx ecx, ax xor eax, eax ;ONLY RGBA rep stosd ;ONLY RGBA ;mov eax, 0800080h ;RGB color for transparency ;.alpha: ;RGB ; stosw ;RGB ; ror eax, 16 ;RGB ; stosb ;RGB ; ror eax, 16 ;RGB ; loop .alpha ;RGB lodsw movzx ecx, ax .petla2: movsw movsb mov al, 0FFh ;ONLY RGBA stosb ;ONLY RGBA loop .petla2 pop ecx cmp ecx, esi ja .petla .skip: ret endp