Giter Club home page Giter Club logo

tibia71sprextractor's Introduction

Tibia71SprExtractor

Reverse engineered as part of a bigger project to learn more about the Tibia 7.1 client, mostly for fun.

Images at the end of the readme show how the Tibia client reads a single sprite.

.spr structure

  • U32 Version
  • U16 Sprite count (SC)
  • U32[SC] sprite start byte positions in file
  • Sprite[SC] sprite structures

Sprite structure:

  • U8 Transparent R
  • U8 Transparent G
  • U8 Transparent B
  • U16 Byte length
  • PixelData[Byte length] Sequence of PixelData

PixelData structure:

  • U16 Amount of transparent pixels to skip ahead
  • U16 Amount of colorful pixels to write before next PixelData or EOF
  • Pixel[Colorful pixels]

Pixel structure:

  • U8 Red
  • U8 Green
  • U8 Blue

Reading Tibia.spr:

Every sprite is 32x32.

Read U32 version
Read U16 SpriteCount
Loop i = 0..SpriteCount - 1
	SpritePositions[i] = Read U32 byte pos of sprite in file
Loop i = 0..SpriteCount - 1 
	If SpritePositions[i] < 1 Then Skip
	TransparentRed   = Read U8
	TransparentGreen = Read U8
	TransparentBlue  = Read U8
    SpriteEnd        = (Current byte position in file) + (Read U16 byte length)
	Sprite           = Create new Bitmap
	CurrentPixel     = 0
	Loop while current byte position in file < SpriteEnd
        TransparentPixelCount = Read U16
		CurrentPixel         += TransparentPixelCount
        ColorfulPixelCount    = Read U16
		Loop j = 0..ColorfulPixelCount
			Red   = Read U8
			Green = Read U8
			Blue  = Read U8
			X = CurrentPixel % 32
			Y = CurrentPixel / 32
			WritePixel(Sprite, X, Y, Red, Green, Blue)

Credits

@jo3bingham -- fairly certain I read one of their threads about Tibia file structures on an OT forum (although for another version of the client, it was still very helpful)

Tibia.exe -- everything else

Tibia.exe reading single sprite:

Initializating sprite:

Init sprite

Reading sprite:

Read sprite

tibia71sprextractor's People

Contributors

szune avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.