Skip to content

Commit 91d3155

Browse files
committed
Add Kaitai Struct definition for texture data files (.tex)
1 parent 464e59d commit 91d3155

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

docs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Kaitai Struct allows you to define binary formats in a YAML-based `.ksy` file, w
2121
| [`animation.ksy`](/docs/animation.ksy) | `.ani` | Animation data (keyframes, actor references, camera animation) |
2222
| [`wdb.ksy`](/docs/wdb.ksy) | `.wdb` | World database (textures, parts, models, ROI hierarchies, LODs) |
2323
| [`dta.ksy`](/docs/dta.ksy) | `.dta` | Animation data (world animation info, model placement) |
24+
| [`tex.ksy`](/docs/tex.ksy) | `.tex` | Texture data (named textures with palette and pixel data) |
2425

2526
## Using the Tools
2627

@@ -50,6 +51,9 @@ ksv /path/to/lego/data/world.wdb wdb.ksy
5051

5152
# View an animation data file
5253
ksv samples/BLDRINF.DTA dta.ksy
54+
55+
# View a texture data file
56+
ksv samples/Dbfrfn.tex tex.ksy
5357
```
5458

5559
### Kaitai Struct Dump (ksdump)
@@ -74,6 +78,9 @@ ksdump --format yaml /path/to/lego/data/world.wdb wdb.ksy
7478

7579
# Dump an animation data file to JSON
7680
ksdump --format json samples/BLDRINF.DTA dta.ksy
81+
82+
# Dump a texture data file to JSON
83+
ksdump --format json samples/Dbfrfn.tex tex.ksy
7784
```
7885

7986
## Sample Files
@@ -84,5 +91,6 @@ The [`samples/`](/docs/samples/) directory contains example files for testing:
8491
- `History.gsi` - Sample score history data
8592
- `pns065rd.ani` - Sample animation file
8693
- `BLDRINF.DTA` - Sample animation data file
94+
- `Dbfrfn.tex` - Sample texture data file (dune buggy front fender)
8795

8896
Note: The world database (`world.wdb`) can be found in your LEGO Island installation at `lego/data/world.wdb`.

docs/samples/Dbfrfn.tex

16.1 KB
Binary file not shown.

docs/tex.ksy

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
meta:
2+
id: tex
3+
title: Texture Data File
4+
application: LEGO Island
5+
file-extension: tex
6+
license: CC0-1.0
7+
endian: le
8+
9+
doc: |
10+
Texture data format for LEGO Island (1997). Contains one or more named
11+
textures with 8-bit indexed color image data.
12+
13+
Texture data is embedded in SI (Interleaf) container files and parsed by
14+
LegoTexturePresenter::Read(). Each texture consists of a length-prefixed
15+
name followed by image data with a color palette and pixel indices.
16+
17+
The image format is shared with the world database (world.wdb) texture
18+
data, using the same LegoImage and LegoPaletteEntry serialization.
19+
20+
File structure:
21+
1. Texture count
22+
2. Named texture entries - name + palette + pixel data
23+
24+
seq:
25+
- id: num_textures
26+
type: u4
27+
doc: Number of textures in this file.
28+
- id: textures
29+
type: named_texture
30+
repeat: expr
31+
repeat-expr: num_textures
32+
doc: Array of named textures.
33+
34+
types:
35+
named_texture:
36+
doc: |
37+
A named texture with 8-bit indexed color image data.
38+
seq:
39+
- id: name_length
40+
type: u4
41+
doc: Length of the texture name buffer in bytes.
42+
- id: name
43+
type: str
44+
size: name_length
45+
encoding: ASCII
46+
terminator: 0
47+
doc: |
48+
Texture name (e.g., "dbfrfn.gif"). The name is a null-terminated
49+
C string within the allocated buffer. Bytes after the null
50+
terminator are unused padding and consumed but not included
51+
in the string value.
52+
- id: image
53+
type: image
54+
doc: The texture image data.
55+
56+
image:
57+
doc: |
58+
An 8-bit indexed color image with palette. Parsed by LegoImage::Read().
59+
seq:
60+
- id: width
61+
type: u4
62+
doc: Image width in pixels.
63+
- id: height
64+
type: u4
65+
doc: Image height in pixels.
66+
- id: palette_size
67+
type: u4
68+
doc: Number of entries in the color palette (max 256).
69+
- id: palette
70+
type: palette_entry
71+
repeat: expr
72+
repeat-expr: palette_size
73+
doc: Color palette entries.
74+
- id: pixels
75+
size: width * height
76+
doc: |
77+
Pixel data as palette indices. Each byte is an index into
78+
the palette array.
79+
80+
palette_entry:
81+
doc: RGB color palette entry. Parsed by LegoPaletteEntry::Read().
82+
seq:
83+
- id: red
84+
type: u1
85+
doc: Red component (0-255).
86+
- id: green
87+
type: u1
88+
doc: Green component (0-255).
89+
- id: blue
90+
type: u1
91+
doc: Blue component (0-255).

0 commit comments

Comments
 (0)