Module tpc

Module tpc 

Source
Expand description

TPC binary texture-container support. TPC binary reader and writer.

TPC (texture pack container) is KotOR’s native texture container format. This module currently focuses on container-level parity: header fields, payload boundaries, and optional trailing TXI footer bytes.

§KotOR Notes

  • Canonical K1 pixel-type mappings are explicit and enforced.
  • Unknown pixel-type combinations are rejected by default.
  • Mip payload sizing follows K1 native shift semantics (>> 1 per level without clamping), so extra mip levels after dimensions collapse to zero contribute zero additional bytes.

§Format Layout

+------------------------------+ 0x0000
| Header (128 bytes)           |
+------------------------------+ 0x0080
| Texture payload              |
| (mip/layer data)             |
+------------------------------+
| Optional TXI footer bytes    |
+------------------------------+

§Header (128 bytes)

0x00..0x04  data_size      (u32 LE)
0x04..0x08  alpha_test     (f32 LE)
0x08..0x0A  width          (u16 LE)
0x0A..0x0C  height         (u16 LE)
0x0C..0x0D  pixel_type     (u8)
0x0D..0x0E  mipmap_count   (u8)
0x0E..0x80  reserved       (114 bytes)

Structs§

Tpc
In-memory TPC container.
TpcHeader
TPC header fields.
TpcPixelFormatCode
Raw TPC pixel encoding code derived from pixel_type + compression state.

Enums§

TpcBinaryError
Errors produced while parsing or serializing TPC binary data.
TpcHeaderPixelFormat
Header-derived TPC texture payload format classification.

Functions§

read_tpc
Reads TPC data from a reader.
read_tpc_from_bytes
Reads TPC data from bytes.
write_tpc
Writes TPC data to a writer.
write_tpc_to_vec
Serializes TPC data to a byte vector.