Texture format: Difference between revisions

From Trickstart wiki
(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 |- |...")
 
No edit summary
Line 1: Line 1:
Engine supports maximum size of 256x256 pixels. On Windows textures use .pc extension, on Dreamcast they use .DC extension
Engine supports maximum size of 256x256 pixels. On Windows textures use .pc extension, on Dreamcast they use .DC extension, and on Playstation2 they use .ps2 extension
{| class="wikitable"
{| class="wikitable"
!Offset
!Offset
Line 11: Line 11:
|0x4
|0x4
|0x2
|0x2
|version, set to 3 for .pc files, 4 for Dreamcast ones
|version, set to 2 for .ps2 files, 3 for .pc, 4 for .dc
|-
|-
|0x6
|0x6
Line 32: Line 32:
* compressed image data starts at 0xA, see pc_unpack.py for implementation details
* compressed image data starts at 0xA, see pc_unpack.py for implementation details


=== version 3 (PC) ===
=== Version 2 (PS2) ===
 
* Not much is known, other that it's vastly different to PC & DC versions
 
=== Version 3 (PC) ===


* Each pixel is written on 2 bytes, little endian, after converting to big endian the algorithm looks like this:
* Each pixel is written on 2 bytes, little endian, after converting to big endian the algorithm looks like this:

Revision as of 14:27, 3 January 2021

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

Offset Size Description
0x0 0x4 Magic, T54 4D 21 1A (TM!\x1A)
0x4 0x2 version, set to 2 for .ps2 files, 3 for .pc, 4 for .dc
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 2 (PS2)

  • Not much is known, other that it's vastly different to PC & DC versions

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).