Updated Splashpack structure, added imhex project

This commit is contained in:
2025-04-03 17:52:14 +02:00
parent 6c1a0854c7
commit fa747ad786
5 changed files with 115 additions and 60 deletions

View File

@@ -4,7 +4,7 @@ All numeric values are stored in littleendian format. All offsets are counted
---
## 1. File Header (12 bytes)
## 1. File Header (16 bytes)
| Offset | Size | Type | Description |
| ------ | ---- | ------ | ----------------------------------- |
@@ -13,7 +13,7 @@ All numeric values are stored in littleendian format. All offsets are counted
| 0x04 | 2 | uint16 | Number of Exporter descriptors |
| 0x06 | 2 | uint16 | Number of Texture Atlas descriptors |
| 0x08 | 2 | uint16 | Number of CLUT descriptors |
| 0x0A | 2 | uint16 | Reserved (always 0) |
| 0x0A | 3*2 | uint16 | Reserved (always 0) |
---
@@ -21,18 +21,19 @@ All numeric values are stored in littleendian format. All offsets are counted
The metadata section comprises three groups of descriptors.
### 2.1 Exporter Descriptors (56 bytes each)
### 2.1 GameObject Descriptors (56 bytes each)
Each exporter descriptor stores the transform and mesh metadata for one GameObject.
Each gameobject descriptor stores the transform and mesh metadata for one GameObject.
| Offset (per entry) | Size | Type | Description |
| ------------------ | ---- | ------ | --------------------------------- |
| 0x00 | 4 | int | X coordinate (Fixed-point) |
| 0x04 | 4 | int | Y coordinate (Fixed-point) |
| 0x08 | 4 | int | Z coordinate (Fixed-point) |
| 0x0C | 36 | int[9] | 3×3 Rotation matrix (Fixed-point) |
| 0x30 | 4 | int | **Mesh Data Offset Placeholder** |
| 0x34 | 4 | int | Triangle count in the mesh |
| 0x00 | 4 | int | **Mesh Data Offset** |
| 0x04 | 4 | int | X coordinate (Fixed-point) |
| 0x08 | 4 | int | Y coordinate (Fixed-point) |
| 0x0C | 4 | int | Z coordinate (Fixed-point) |
| 0x10 | 36 | int[9] | 3×3 Rotation matrix (Fixed-point) |
| 0x28 | 4 | uint16 | Triangle count in the mesh |
| 0x2A | 2 | uint16 | Reserved |
### 2.2 Texture Atlas Descriptors (12 bytes each)
@@ -46,18 +47,18 @@ Each texture atlas descriptor holds atlas layout data and a placeholder for the
| 0x08 | 2 | uint16 | Atlas position X relative to VRAM origin |
| 0x0A | 2 | uint16 | Atlas position Y relative to VRAM origin |
### 2.3 CLUT Descriptors (520 bytes each)
### 2.3 CLUT Descriptors (12 bytes each)
CLUTs are the only data which is stored in the Metadata section.
For each CLUT (Color Lookup Table) associated with an atlas texture that has a palette:
| Offset (per entry) | Size | Type | Description |
| ------------------ | ---- | ----------- | --------------------------------------------------------------------------------- |
| 0x00 | 512 | uint16[256] | Color palette entries (each entry is 2 bytes 16bpp). If unused, entries are zero. |
| 0x200 | 2 | uint16 | CLUT packing X coordinate - already in 16 pixel steps |
| 0x202 | 2 | uint16 | CLUT packing Y coordinate |
| 0x204 | 2 | uint16 | Palette count (number of valid palette entries) |
| 0x206 | 2 | uint16 | Reserved (always 0) |
| Offset (per entry) | Size | Type | Description |
| ------------------ | ---- | ------ | ----------------------------------------------------- |
| 0x00 | 4 | int | **Clut Data Offset Placeholder** |
| 0x04 | 2 | uint16 | CLUT packing X coordinate - already in 16 pixel steps |
| 0x06 | 2 | uint16 | CLUT packing Y coordinate |
| 0x08 | 2 | uint16 | Palette count (number of valid palette entries) |
| 0x0A | 2 | uint16 | Reserved (always 0) |
---
@@ -71,23 +72,32 @@ For each exporter, a mesh data block is written at the offset specified in its d
#### **Triangle Data Layout (per triangle 52 bytes total):**
| Field | Size | Description |
| ----------------------------- | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Vertex Coordinates** | 3 vertices × 3 × 2 bytes = 18 bytes | For each vertex (v0, v1, v2): X, Y, Z coordinates (int16) |
| **Vertex Normal** | 3 × 2 bytes = 6 bytes | Normal vector for vertex v0 (int16: nx, ny, nz) |
| **Vertex Colors** | 3 vertices × (3 bytes color + 1 byte padding) = 12 bytes | For each vertex (v0, v1, v2): Red, Green, Blue (uint8) plus 1 byte padding |
| **Texture Coordinates (UVs)** | 3 vertices × 2 bytes = 6 bytes | For each vertex (v0, v1, v2): U and V coordinates (uint8), adjusted by texture packing factors |
| **UV Padding** | 2 bytes | Padding (uint16, set to zero) |
| **Texture Attributes** | 2 + 2 + 2 + 2 = 8 bytes | Contains: <br> • Texture page attributes (uint16 encoded from page X/Y, bit depth, dithering)<br> • Texture CLUT packing X (uint16)<br> • Texture CLUT packing Y (uint16)<br> • Reserved (uint16, set to zero) |
| Field | Size | Description |
| ----------------------------- | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| **Vertex Coordinates** | 3 vertices × 3 × 2 bytes = 18 bytes | For each vertex (v0, v1, v2): X, Y, Z coordinates (int16) |
| **Vertex Normal** | 3 × 2 bytes = 6 bytes | Normal vector for vertex v0 (int16: nx, ny, nz) |
| **Vertex Colors** | 3 vertices × (3 bytes color + 1 byte padding) = 12 bytes | For each vertex (v0, v1, v2): Red, Green, Blue (uint8) plus 1 byte padding |
| **Texture Coordinates (UVs)** | 3 vertices × 2 bytes = 6 bytes | For each vertex (v0, v1, v2): U and V coordinates (uint8), adjusted by texture packing factors |
| **UV Padding** | 2 bytes | Padding (uint16, set to zero) |
| **Texture Attributes** | 2 bytes | The TPage attribute for the given polygon |
| **Clut X** | 2 bytes | Clut position within VRAM (already predivided by 16) |
| **Clut Y** | 2 bytes | Clut position within VRAM |
| **Padding** | 2 bytes | |
*Triangles are written sequentially. Prior to writing each mesh data block, the file pointer is aligned to a 4-byte boundary.*
### 3.2 Atlas Data Blocks
For each atlas, a raw texture data block is written at the offset specified in its descriptor. Before writing, the file pointer is aligned to a 4-byte boundary.
For each atlas, a raw texture data block is written at the offset specified in its descriptor
- **Raw Texture Data:**
The atlas data is written pixel by pixel as returned by the pixel packing function. The total size equals
*(Atlas Width × Atlas Height)* The data is prepared for a DMA transfer to the VRAM.
### 3.3 Clut Data Blocks
For each clut, a raw pixel data block is written at the offset specified in its descriptor as an array of `uint16` colors already formatted for the VRAM.
---