Alien Trilogy BND: Difference between revisions
imported>LexSafonov No edit summary |
imported>LexSafonov No edit summary |
||
| Line 60: | Line 60: | ||
=== | === Sprite Section Specifications === | ||
Revision as of 15:00, 24 May 2021
Back to index | Edit this page
BND
- Format Type : File container
- Extensions: bnd and b16 for 16-bit sprites
- Platforms: PC/PS1/Sega Saturn
- Endian Order : Little Endian/Big Endian
Format Description
A container file that can store sprites, textures, models, palette, texture mesh for models. Each file is divided into "sections" that have "names". The problem with this format is that one and the same file is used for different types of data, and different types of data are specified just by "sections" within the file itself. There are the following "section names":
- F000(#1,2,3....) F? - Frame, this section is used for sprites. Most sprites have compression, do not have information about frame sizes (hardcoded into the game engine in animation structures)
- T000(#1,2,3....) T? - Texture, in this section there are standard "descriptions" of images - size, color, no compression, resources can be ripped out with tools such as XWE, TiledGGD.
- M000(#1,2,3....) M? - Model, section contains models. Contains a list of vertices and quads. The peculiarity with quads is apparently due to the fact that the game was originally developed for the Sega Saturn console, which supports them in hardware better than polygon
- BX00(#1,2,3....) - Texture mesh, usually located next to the texture section and has the same numbering. Contains a "list" of quads for texturing.
- CX00(#1,2,3....) - urrently unencrypted section
- C000(#1,2,3....) - C? - Color, specific section, only available in b16 file variations. Contains a 16-bit palette.
Format Specifications
This is a generic "template" for a file. As mentioned above, the rest of the data is determined by the game by the "names / identifiers" of the sections within the file itself.
// Alien Trilogy // BND(B16) file format size comment ----------------------------------------------------------------------------- 0x04 46 4F 52 4D FORM 0x04 - file data size in bytes, BIG-ENDIAN 0x04 - number of sections in a file, text(string?) 0x04 - format \ section identifier(F000\T000\M000....) 0x0... - data, for each section have its own structure
F000(#1,2,3....) Sprite Section
This section contains sprites of enemies and weapons.
These files contain such sections:
Enemyes:
BURSTER.BND(B16) COLONIST.BND(B16)
DOG.BND(B16) DOGCEIL.BND(B16)
EGGS.BND(B16) FINGERS.BND(B16)
GUARD.BND(B16) HANDLER.BND(B16)
HUGGER.BND(B16) QUEEN.BND(B16)
SOLDIERSYNTH.BND(B16) WAR.BND(B16)
WARCEIL.BND(B16)
Wepons:
MM9.BND(B16) PULSE.BND(B16)
SHOTGUN.BND(B16)FLAME.BND(B16)
SMART.BND(B16)
Does not contain image size information. All sizing information is contained in the game engine in animation structures. Most of the sprites in the PC version of the game are compressed by the LZW algorithm, which works the other way around. Those. - the principle of "sliding window" is applied and subsequent pixels are built from the previous ones. The .B16 format uses in addition a section C000 with a 16-bit palette of 2 bytes per color.
Sprite Section Specifications
// Alien Trilogy
// Model Section format(combine in Container Format)
=== Sprite decompression function ===
One section can contain several sprites, some of which may not be compressed. Take this into account when using the function.
<div class="toccolours mw-collapsible" id="mw-customcollapsible-myDivision" style="width:800px; overflow:auto;">
<pre>
void PicDecoder(uint8_t *p, uint8_t *u) {
int32_t i, offs, size;
i = 0;
while (1) {
while (1) {
i >>= 1;
if (!(i & 0xFF00)) {
i = 0xFF00 | *p;
p++;
}
if (i & 1) { break; }
*u = *p;
u++;
p++;
}
if (*p >= 96) {
offs = *p - 256;
size = 3;
p++;
} else {
size = (*p & 0xF0) >> 4;
offs = (*p & 0x0F) << 8;
p++;
offs |= *p;
p++;
if (!offs) { break; }
offs = -offs;
if (size == 5) {
size = *p + 9;
p++;
} else {
size = size + 4;
}
}
while (--size) {
*u = u[offs];
u++;
}
}
}
M000(#1,2,3....) Models Section
This section contains models. Models have vertices and quads in their composition. The nuance with quads, apparently, is due to the fact that the game was originally developed for the Sega Saturn, where quads work better in hardware than polygons. Vertex coordinates have integer values! Many models have a textured mesh
These files contain such sections:
PICKMOD.BND - pickup models
OPTOBJ.BND - menu option models
OBJ3D.BND - other models
Model Section Specifications
// Alien Trilogy // Model Section format(combine in Container Format) Size Comment ----------------------------------------------------------------------------- 0x04 46 4F 52 4D FORM 0x04 - File data size in bytes, BIG-ENDIAN 0x04 - Number of sections in a file, text(string?) 0x04 - Format \ section identifier M000...(Char "M" + 3 bytes model number) 0x04 - Model data size in bytes, BIG-ENDIAN 0x04 4F 42 4A 31 OBJ1 0x08 00 00 00 00 00 00 00 00 Unknown value? 0x04 - The number of quads in the model. LITTLE-ENDIAN 0x04 - The number of vertices in the model? 0x14*N - Quads in turn (see format below) 0x08*N - Vertices in turn (see format below) - Quad format: Size Comment ------------------------------------------------------------------------------------------------------------------------- 0x04 - First point index. LITTLE-ENDIAN 0x04 - Second point index. LITTLE-ENDIAN 0x04 - Third point index. LITTLE-ENDIAN 0x04 - Fourth point index. Maybe -1 (0xFFFFFFFF), then this is a triangle and the third point must be duplicated. 0x02 - Quad texture index 0x02 - Some parameter. Maybe 11, then the texture should be flipped along Y (?). Maybe 128. no one knows why. - Vertices format: Size Comment ------------------------------------------------------------------------------------------------------------------------- 0x02 - X coordinate (signed, LITTLE-ENDIAN, short) 0x02 - Y coordinate (signed, LITTLE-ENDIAN, short) 0x02 - Z coordinate (signed, LITTLE-ENDIAN, short) 0x02 - Unknown value, always zero. Apparently serves to make the data multiples of 4