Texture format

From Trickstart wiki
Revision as of 16:39, 26 December 2020 by Halamix2 (talk | contribs) (Created page with "Engine supports maximum size of 256x256 pixels. On Windows textures use .pc extension, on Dreamcast they use .DC extension {| class="wikitable" !Offset !Size !Description |- |...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Engine supports maximum size of 256x256 pixels. On Windows textures use .pc extension, on Dreamcast they use .DC extension

Offset Size Description
0x0 0x4 Magic, T54 4D 21 1A (TM!\x1A)
0x4 0x2 version, set to 3 for .pc files, 4 for Dreamcast ones
0x6 0x2 width
0x8 0x2 height
0xA 0x2 first pixel
0xC ?? Compressed data, until EOF
  • compressed image data starts at 0xA, see pc_unpack.py for implementation details

version 3 (PC)

  • Each pixel is written on 2 bytes, little endian, after converting to big endian the algorithm looks like this:
  • If the 15th bit is 1, then stream data as long as each compressed pixel 15th bit is set
    • Else
      • If 14th bit is set copy previously unpacked data
        • bits 11-13 - number of pixels to repeat - 2, so if this number is set to 7, then repeat 9 pixels, minimum 2 pixels
        • bits 0-10 - offset - back head for copying that many pixels
        • else - add transparent pixels
          • bits 0-13 - how many transparent pixels to add
  • 00 00 marks the end of compressed data

Version 4 (DC)

  • Uses the same compression as vesion 3, but the resulting files are swizzled for Dreamcast GPUI, so untwiddling is needed

Unpacked image data

Uncompressed image data uses 2 bytes for each pixel, in A1 R5 G5 B5 format. In some places game uses additional file with greyscale alpha channel to compensate for 1bit alpha (5 bits instead of 1).