Jump to content

Novth

New Member
  • Posts

    2
  • Joined

  • Last visited

Reputation

0 Neutral
  1. Novth

    WTE File Format

    The WTE file format is utilized to store both texture data and palettes. Since it has a header, it's always wrapped by a SIR0 container. The file is allowed to lack the texture data and/or the palette. The WTE format is closely related to the 3D engine. The textures are loaded directly into texture VRAM, while the palettes are transformed to 5 bits per channel and then loaded into texture palette VRAM. File Structure While the convention in SIR0 files is to store the data, and then the header, this is in no way enforced or even checked by the game. Due to this, it doesn't matter where the header is relative to everything else. For this reason, the full file structure will not be included to avoid bloating. WTE Header (Total 32 bytes) Offset Length Type Name Description 0x00 4 Signature Sequence of bytes that identifies this file as a WTE file. {0x57, 0x54, 0x45, 0x00} The game tries to check it when loading, but does nothing if the signature doesn't match 0x04 4 uint32le Pointer to Texture Data A pointer to the texture data of the file. The exact format varies depending on the file. The texture is copied as-is from the file into texture VRAM. Can be null if the file doesn't contain a texture. 0x08 4 uint32le Length of Texture Data The length of the texture data, used to know how many bytes to copy from Texture Data. Should be Texture Width * Texture Height, multiplied by how many bytes per texel the format has. For example, a 32x32 texture with 2 texels per byte (0.5 bytes per texel) would be 512 bytes. 0x0C 2 uint16le Texture Params A bitfield used to configure the TEXIMAGE_PARAM register. The values aren't copied directly, so the arrangement is a bit different. The values stored are: 0-2: Shift for the texture width in memory (width = 8 << N) 3-5: Shift for the texture height in memory (height = 8 << N) 8-10: Format of the texture 11: 0 = Clamp horizontally, 1 = Repeat 12: 0 = Clamp vertically, 1 = Repeat 0x0E 2 Padding 0x10 2 uint16le Offset X Unused, but presumed to be the X offset within the stored texture. Should be zero. 0x12 2 uint16le Offset Y Unused, but presumed to be the Y offset within the stored texture. Should be zero. 0x14 2 uint16le Texture Width Unused, but seems to be the width of the texture. Because the textures are stored in row-major order (and by extension the width is required to get the offset of a texel), the width needs to be the same value as the calculated width, which can only be a power of two. This can lead to padding bytes being added if the texture width isn't a power of two already. 0x16 2 uint16le Texture Height Unused, but seems to be the height of the relevant texture contents. Due to the fact the height is not required for calculating offsets within the texture, the texture height might be smaller than the calculated height, and padding bytes don't need to be stored. 0x18 4 uint32le Pointer to Palette A pointer to the palette data of the file. It is stored as a RGBX array, where every component is a byte. The fourth byte is not used at all, and is most likely padding for optimal memory access. 0x1C 2 uint16le Colors in Palette How many colors are stored in the palette. 0x1E 2 Padding Methods The following are some of the methods used by the game to work with WTE files. Address (NA) Signature Description 0x201de4c r0: pointer to result r1: path of WTE file Reads the WTE file at the path pointed by r1, translates the SIR0 contents, and writes pointers to the start of the file and the header in the location pointed by r0. 0x201e0b0 r0: pointer to WTE header r1: texture offset r2: palette index r3: color index Queries the texture and palettes of the WTE header pointed by r0 to be loaded by the game's specialized texture resource manager. The other arguments are directly passed to the querying subroutines to write the data at the correct locations. 0x1ff8130 r0: pointer to texture params r1: texture offset Writes the information stored in the Texture Params pointed by r0, aswell as the texture offset in r1, in the TEXIMAGE_PARAM register. This is only done if the last offset to be passed to the function was different from the one being passed. This function isn't inherently unique to the WTE format, but is included here to corroborate the Texture Params bitfield. 0x1ff81cc r0: pointer to texture params r1: palette offset Uses the texture format in the Texture Params pointed by r0 to adjust the palette offset by the appropriate amount: divided by 8 if the texture format is 2, otherwise divided by 16. This value is then stored in the PLTT_BASE register. The last two notes from above apply.
×
×
  • Create New...