TProgramming Forums

Full Version: [FASM] Tibia sprite to RGB(A)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
To read single sprite you need to:
  1. open Tibia.spr file
  2. go to 6+SpriteID*4
  3. read four-byte address
  4. read some bytes from file at this address as offset, at least 4KB
  5. allocate 32*32*4 byte buffer
  6. pass buffer and readed data to function
  7. 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
Thats freaking sexy.
Reference URL's