What's new

TPL texture unpacker/converter

Nemesis

New member
First, a quick intro. I'm Nemesis, and I'm part of the sonic hacking community. I was taking a look at Sonic Mega Collection a few days back, and I was quite surprised to find that there appeared to be absolutely no utilities to work with the TPL texture packs, which I believe are the standard GC texture format. Well, I kinda wanted to take a look at a few of the images, so I wrote a little something to work with the format.

http://homepages.ihug.com.au/~nemesis2k2/programs/tplcnv.exe

This program will unpack any known forms of textures contained in a tpl library (does it stand for texture pack library by any chance?) into seperate files. To use it, just dump it in the same folder as some tpl files, and it'll churn out the individual entries for each. The program is a simple console application written in C.

Right now, the following modes are supported:

0x00000004: RGB565
0x00000005: ARGB1555
0x00000006: ARGB8888
0x00000008: 4BIT palettised
0x00000009: 8BIT palettised
0x0000000E: DXT1

More modes will be added if I come across them. Those six modes are the only ones that are used in both Sonic Mega Collection and Bust a Move 3000, those being the only two GC iso's I have, so I'm out of unknowns to work on.


The program will output most of the individual textures into the DDS image format. In order to use this format you must have either Photoshop or Paint Shop Pro installed on your machine, and you must download some dll's and a photoshop plugin from the following URL's:

http://developer.nvidia.com/attach/5797 -dll's
http://developer.nvidia.com/attach/5798 - plugin

Extract the dll's to your windows\system folder (windows\system32 under XP). Extract the plugin to the plugins folder of either PSP or Photoshop. After that, you should be able to load DDS images.


In addition to the DDS images, right now the program will output both the 4-bit and 8-bit palettised images into standard windows bitmaps. This is nessicary because the DDS format has some limitations relating to palettised textures and image dimensions that the tpl format does not share. While the images can be converted properly to BMP files, this is not ideal, because the alpha information contained in the palette is not accessable through BMP. I'll probably look at the TGA format in more detail over the next day or so and see if that is suitable, and if so, I'll update this program to output the palettised images to TGA instead.


Anyway, yeah. I would normally release the sourcecode for an application like this along with it, but this program was just a quick knockoff, and while I believe it to be bug-free, the structure is so shocking that nobody could get much out of it. I'll be giving out the format specifications anyway, so it's better to just work from that.

I want to note that I will most likely not be writing anything more complex than this to work with this format. If anyone wants a nice graphical editor with a list of contents and things of that nature, someone else will have to do it. I probably won't write anything to convert to TPL either, so if anyone wants to be able to edit textures, someone'll have to write something to convert back. Anyway, here's the jist of the structure:

Code:
tpl format:
- Note, all data is in Big-Endian

0x00 - 0x04:	4 byte identifier (0x0020AF30)
0x04 - 0x08:	Number of entries in file		;int/be
0x08 - 0x0C:	Unknown (always 0x0000000C)		;int/be
0x0C - 0x??:	Header_index[entries]			:int*2/be


Header index:
0x00 - 0x04:	Location of image header in file	;int/be
0x04 - 0x08:	Location of palette header in file	;int/be


Palette header:
0x00 - 0x02:	Number of entries?			;short/be
0x02 - 0x04:	Unknown					;short/be
0x04 - 0x06:	Unknown					;short/be
0x06 - 0x08:	Size of entry?				;short/be
0x08 - 0x0C:	Location of palette in file		;int/be


Image header:
0x00 - 0x02:	Height					;short/be
0x02 - 0x04:	Width					;short/be
0x04 - 0x08:	Format					;int/be
0x08 - 0x0C:	Location of pixel data in file		;int/be
0x0C - 0x10:	Unknown (always 0x00000001)		;int/be
0x10 - 0x14:	Unknown (always 0x00000001)		;int/be
0x14 - 0x18:	Unknown (always 0x00000001)		;int/be
0x18 - 0x1C:	Unknown (always 0x00000001)		;int/be
0x1C - 0x20:	Unknown (always 0x00000000)		;int/be
0x20 - 0x24:	Unknown (always 0x00000000)		;int/be


Format tags:
0x00000004:	RGB565
0x00000005:	ARGB1555
0x00000006:	ARGB8888
0x00000008:	4BIT palettised
0x00000009:	8BIT palettised
0x0000000E:	DXT1

There are a lot of extra considerations that I haven't documented BTW. There wasn't a single mode that didn't require some kind of fiddly modification. A combination of byte order differences, and fancy ways of grouping the pixels into blocks make it a little more difficult than just cut and paste. When dealing with a true 2-bit datatype for example, such as that used in DXT1 compression, you need to perform bitswapping rather than just byteswapping. You then need to worry about where to place that block, because they might decide to arrange every 4x4 pixel block into 2x2 grids of those, or they might decide to arrange individual pixels into 8x4 pixel groups, and then allow the image format to give the textures widths that are not divisible by 8, leaving you to scratch your head over filler bytes, and all that kind of crap. I might end up documenting all these details, but don't count on it.


Anyway, yeah. I hope some people around here can make use of this, considering I spend damn near every waking hour of the last 3 days working on it, and I had all the formats I was interested in done after the first day. Speaking of that, if there are any textures you come across that are unsupported (you will see a message notifying you of an unsupported mode, and an entry number), it might be an idea to mention here what mode number it reported, as well as what game the TPL file you were using it on belonged to. That way I might actually add it before I move on to something else. Also, if you encounter any bugs with this program, mention it here and I'll look into it. Have fun.
 

BlueFalcon7

New member
there was a thread in the general GC emulation section about a model viewer in paper mario 2 but the files were in TPL format, i have quite a few different isos with TPL files made by different companies but the thread is here http://www.emutalk.net/general-gc-e...-pm-ttyd-model-file-format-pet-project-3.html
also there was a program called OPTiX iMAGE STUDIO 4 that was at the link that i posted, it was a game image making program, there used to be one for the GC, Xbox, PS2, DS, and PSP but now v5 is only available its $3,400 and you have to be an authorized game producer and it has not leaked yet. i opened the TPL files in F-Zero GX (which i think are models) with a hex viewer and in ascii it had chains of ...ÿÿÿÿUUUUÿÿÿÿUUUU... and the binary for ÿ is all 1s (11111111) and for U its 01010101 its hard to miss
 

Guru64

New member
Look at the date Nemesis posted. He hasn't been online in a long time and probably won't be coming online anytimes soon.
 

Knuckles

Active member
Moderator
..lol

I didn't even notice.. I never saw that thread before so... damn grave diggers!
 

fantsypants

New member
Does anyone know if these tools or other alternatives to Image Studio exist? Thats A) silly expensive and B) awkward to get for developers.
 

Top