Talk:TPL (File Format)

From Custom Mario Kart
Jump to navigation Jump to search

Please don't use 'short' 'int' or 'long' as types, because the are different on different systems.

  • short is usually 16 or 32 bit. short is always <= int
  • int is the natural word size, usually 16, 32 oder 64 bit.
  • long is usually 32 or 64 bit, but perhaps also 128 bit. long is always >= int.

Better is to use U8, U16, U24, U32, .... for unsigned and char, S16, S32, ... for signed values. These names are not normed, but very often defined per typedef.

Wiimm 23:05, 30 April 2011 (CEST)

Interlacing?

I can't see anything wrong with the file you mentioned.

Chadderz 15:12, 24 June 2011 (CEST)

Bad-savebanner.tpl.png
I have tested my export implementation with different files and exact one looks curios:


Wiimm 17:49, 24 June 2011 (CEST)
You've got the width and height the wrong way round. Easy mistake, height comes first in the file.
Chadderz 21:36, 24 June 2011 (CEST)
Oh yeah, we say in german: "I couldn't see the forest because of many trees". I was tired (to many hours at the pc) when I found that and haven't seen this detail. And it was the only tpl in my test scenario with different height and width.
Wiimm 22:37, 24 June 2011 (CEST)
Don't worry, this problem was in several versions of the SZS Modifier. It took a while before I realised anything was wrong, because they're mostly square. We have that saying also, although it's shortened to "I couldn't see the forest for the trees".
Chadderz 09:10, 25 June 2011 (CEST)

Suggestion

Why not create a page which explains which tpl is what? I would like to help if someone starts it :D MrSkopelos27 19:37, 21 January 2012 (CEST)

See the category:Filesystem hierarchy and edit the pages.
Wiimm 21:10, 21 January 2012 (CET)

Missing header sections?

First 4 bytes are 0x0020AF30, then 4 bytes for the Number of Images field, and then 4 more bytes for the offset to the image offset table.

The image offset table in the TPL file I'm looking at starts at 0x0000000C, and has one entry. This entry has image but no palette (RGBA8, not an indexed color image).

The image header starts at 0x00000020, and has height and width of 0x0300 and 0x0400 (I created this TPL file with BrawlBox, using an 800x600 image on my PC as the source). The format is 0x00000006 (RGBA8), and the offset to the image data is 0x00000060. And indeed that's where I find the image data.

However, there's 2 additional 1byte values (though they may actually be part of a multibyte field, for which only one byte has any data) I can see in my hex editor, between the end of the image header, and the start of the image data. These bytes of data are at offsets (relative to the start of the file) 0x37 and 0x3B. The values stored at both of these locations are 0x01. This is NOT documented in this TPL wiki article. According to the to this article, there should not be anything at all between the image header and the image data, meaning that if it the image header points to some distant point in the file for the image data, all the data in the middle should be zeroed (0x00).

I'm considering that since this file was saved by BrawlBox, not an official Nintendo product, that BrawlBox may in fact save additional data for its own use in the file, but I have no idea what it is used for. Maybe somebody here could shed some light on this extra data. Animedude5555 (talk) 23:46, 3 February 2016 (UTC)


I found out what's missing now. I finally found a leaked copy of Nintendo's official Revolution SDK on the net and downloaded that. In there I found this C header file tpl.h which has the complete description of the TPL file format. Below I've pasted the C typedef for the TPL Image Header.

typedef struct
{
    u16             height;
    u16             width;

    u32             format;
    Ptr             data;

    GXTexWrapMode   wrapS;
    GXTexWrapMode   wrapT;

    GXTexFilter     minFilter;
    GXTexFilter     magFilter;

    float           LODBias;

    u8              edgeLODEnable;
    u8              minLOD;
    u8              maxLOD;
    u8              unpacked;

} TPLHeader, *TPLHeaderPtr;

Animedude5555 (talk) 03:06, 4 February 2016 (UTC)

I've now added the above information to the table describing the Image Header on the main page for this topic.Animedude5555 (talk) 03:25, 4 February 2016 (UTC)

I've now done the same thing regarding the Palette Header, adding information from the official tpl.h file about the Palette Header to the table on the main page for this topic. And just for your reference, here's the typedef for that structure from the tpl.h file.

typedef struct
{
    u16             numEntries;
    u8              unpacked;
    u8              pad8;

    GXTlutFmt       format;
    Ptr             data;

} TPLClutHeader, *TPLClutHeaderPtr;

Animedude5555 (talk) 03:31, 4 February 2016 (UTC)

After a fast review: Your headers look like the headers I used in my tools: SVN
-- Wiimm (talk) 15:17, 5 February 2016 (UTC)