Both sides previous revisionPrevious revisionNext revision | Previous revision |
trs:file_formats [2017/02/04 16:34] – ↷ Links adapted because of a move operation stohrendorf | trs:file_formats [2021/04/29 21:53] (current) – [TR1 Level Format] zdimension |
---|
| {{indexmenu_n>9}} |
| |
====== Entire Level File Formats ====== | ====== Entire Level File Formats ====== |
| |
<code cpp> | <code cpp> |
uint32_t Version; // version (4 bytes) | uint32_t Version; // version (4 bytes) |
uint32_t NumTextiles; // number of texture tiles (4 bytes) | uint32_t NumImages; // number of texture images (4 bytes) |
tr_textile8 Textile8[NumTextiles]; // 8-bit (palettized) textiles (NumTextiles * 65536 bytes) | tr_image8 Images8[NumImages]; // 8-bit (palettized) images (NumImages * 65536 bytes) |
uint32_t Unused; // 32-bit unused value (4 bytes) | uint32_t Unused; // supposed to be the level number but TOM2PC didn't allow changing it, always 0 (4 bytes) |
uint16_t NumRooms; // number of rooms (2 bytes) | uint16_t NumRooms; // number of rooms (2 bytes) |
tr_room Rooms[NumRooms]; // room list (variable length) | tr_room Rooms[NumRooms]; // room list (variable length) |
tr_colour Palette[256]; // 8-bit palette (768 bytes) | tr_colour Palette[256]; // 8-bit palette (768 bytes) |
tr_colour4 Palette16[256]; // (1024 bytes) | tr_colour4 Palette16[256]; // (1024 bytes) |
uint32_t NumTextiles; // number of texture tiles (4 bytes) | uint32_t NumImages; // number of texture images (4 bytes) |
tr_textile8 Textile8[NumTextiles]; // 8-bit (palettized) textiles (NumTextiles * 65536 bytes) | tr_teximage8 Images8[NumImages]; // 8-bit (palettized) images (NumImages * 65536 bytes) |
tr_textile16 Textile16[NumTextiles]; // 16-bit (ARGB) textiles (NumTextiles * 131072 bytes) | tr_teximage16 Images16[NumImages]; // 16-bit (ARGB) images (NumImages * 131072 bytes) |
uint32_t Unused; // 32-bit unused value (4 bytes) | uint32_t Unused; // supposed to be the level number but TOM2PC didn't allow changing it, always 0 (4 bytes) |
uint16_t NumRooms; // number of rooms (2 bytes) | uint16_t NumRooms; // number of rooms (2 bytes) |
tr2_room Rooms[NumRooms]; // room list (variable length) | tr2_room Rooms[NumRooms]; // room list (variable length) |
tr_colour Palette[256]; // 8-bit palette (768 bytes) | tr_colour Palette[256]; // 8-bit palette (768 bytes) |
tr_colour4 Palette16[256]; // (1024 bytes) | tr_colour4 Palette16[256]; // (1024 bytes) |
uint32_t NumTextiles; // number of texture tiles (4 bytes) | uint32_t NumImages; // number of texture images (4 bytes) |
tr_textile8 Textile8[NumTextiles]; // 8-bit (palettized) textiles (NumTextiles * 65536 bytes) | tr_image8 Images8[NumImages]; // 8-bit (palettized) images (NumImages * 65536 bytes) |
tr_textile16 Textile16[NumTextiles]; // 16-bit (ARGB) textiles (NumTextiles * 131072 bytes) (absent from TR1) | tr_image16 Images16[NumImages]; // 16-bit (ARGB) images (NumImages * 131072 bytes) (absent from TR1) |
uint32_t Unused; // 32-bit unused value (4 bytes) | // "VICT.TR2" stops here, nothing after |
| uint32_t Unused; // supposed to be the level number but TOM2PC didn't allow changing it, always 0 (4 bytes) |
uint16_t NumRooms; // number of rooms (2 bytes) | uint16_t NumRooms; // number of rooms (2 bytes) |
tr3_room Rooms[NumRooms]; // room list (variable length) | tr3_room Rooms[NumRooms]; // room list (variable length) |
<code cpp> | <code cpp> |
uint32_t Version; // version (4 bytes) | uint32_t Version; // version (4 bytes) |
uint16_t NumRoomTextiles; // number of non bumped room tiles (2 bytes) | uint16_t NumRoomImages; // number of non.bumpmapped room images (2 bytes) |
uint16_t NumObjTextiles; // number of object tiles (2 bytes) | uint16_t NumObjImages; // number of object images (2 bytes) |
uint16_t NumBumpTextiles; // number of bumped room tiles (2 bytes) | uint16_t NumBumpmaps; // number of bump-mapped room images (2 bytes) |
uint32_t Textile32_UncompSize; // uncompressed size (in bytes) of the 32-bit textures chunk (4 bytes) | uint32_t Image32_UncompSize; // uncompressed size (in bytes) of the 32-bit textures chunk (4 bytes) |
uint32_t Textile32_CompSize; // compressed size (in bytes) of the 32-bit textures chunk (4 bytes) | uint32_t Image32_CompSize; // compressed size (in bytes) of the 32-bit textures chunk (4 bytes) |
uint8_t Textile32_Compressed[Textile32_CompSize]; // zlib-compressed 32-bit textures chunk (Textile32_CompSize bytes) | uint8_t Image32_Compressed[Image32_CompSize]; // zlib-compressed 32-bit textures chunk (Image32_CompSize bytes) |
{ | { |
tr4_textile32 Textile32[NumRoomTextiles + NumObjTextiles + NumBumpTextiles]; | tr4_image32 Image32[NumRoomImages + NumObjImages + NumBumpmaps]; |
} | } |
uint32_t Textile16_UncompSize; // uncompressed size (in bytes) of the 16-bit textures chunk (4 bytes) | uint32_t Image16_UncompSize; // uncompressed size (in bytes) of the 16-bit textures chunk (4 bytes) |
uint32_t Textile16_CompSize; // compressed size (in bytes) of the 16-bit textures chunk (4 bytes) | uint32_t Image16_CompSize; // compressed size (in bytes) of the 16-bit textures chunk (4 bytes) |
uint8_t Textile16_Compressed[Textile32_CompSize]; // zlib-compressed 16-bit textures chunk (Textile16_CompSize bytes) | uint8_t Image16_Compressed[Image32_CompSize]; // zlib-compressed 16-bit textures chunk (Image16_CompSize bytes) |
{ | { |
tr_textile16 Textile16[NumRoomTextiles + NumObjTextiles + NumBumpTextiles]; | tr_image16 Image16[NumRoomImages + NumObjImages + NumBumpmaps]; |
} | } |
uint32_t Textile32Misc_UncompSize; // uncompressed size (in bytes) of the 32-bit misc textures chunk (4 bytes), should always be 524288 | uint32_t Image32Misc_UncompSize; // uncompressed size (in bytes) of the 32-bit misc textures chunk (4 bytes), should always be 524288 |
uint32_t Textile32Misc_CompSize; // compressed size (in bytes) of the 32-bit misc textures chunk (4 bytes) | uint32_t Image32Misc_CompSize; // compressed size (in bytes) of the 32-bit misc textures chunk (4 bytes) |
uint8_t Textile32Misc_Compressed[Textile32Misc_CompSize]; // zlib-compressed 32-bit misc textures chunk (Textile32Misc_CompSize bytes) | uint8_t Image32Misc_Compressed[Image32Misc_CompSize]; // zlib-compressed 32-bit misc textures chunk (Image32Misc_CompSize bytes) |
{ | { |
tr4_textile32 Textile32Misc[2]; | tr4_image32 Image32Misc[2]; |
} | } |
uint32_t LevelData_UncompSize; // uncompressed size (in bytes) of the level data chunk (4 bytes) | uint32_t LevelData_UncompSize; // uncompressed size (in bytes) of the level data chunk (4 bytes) |
uint8_t LevelData_Compressed[LevelData_CompSize]; // zlib-compressed level data chunk (LevelData_CompSize bytes) | uint8_t LevelData_Compressed[LevelData_CompSize]; // zlib-compressed level data chunk (LevelData_CompSize bytes) |
{ | { |
uint32_t Unused; // 32-bit unused value, always 0 (4 bytes) | uint32_t Unused; // supposed to be the level number but TOM2PC didn't allow changing it, always 0 (4 bytes) |
uint16_t NumRooms; // number of rooms (2 bytes) | uint16_t NumRooms; // number of rooms (2 bytes) |
tr4_room Rooms[NumRooms]; // room list (variable length) | tr4_room Rooms[NumRooms]; // room list (variable length) |
uint16_t AnimatedTextures[NumAnimatedTextures]; // animated texture data (NumAnimatedTextures * 2 bytes) | uint16_t AnimatedTextures[NumAnimatedTextures]; // animated texture data (NumAnimatedTextures * 2 bytes) |
uint8_t AnimatedTexturesUVCount; | uint8_t AnimatedTexturesUVCount; |
| uint8_t TEX[3]; // T E X (0x54, 0x45, 0x58) |
uint32_t NumObjectTextures; // number of object textures to follow (4 bytes) (after AnimatedTextures in TR3) | uint32_t NumObjectTextures; // number of object textures to follow (4 bytes) (after AnimatedTextures in TR3) |
tr4_object_texture ObjectTextures[NumObjectTextures]; // object texture list (NumObjectTextures * 38 bytes) | tr4_object_texture ObjectTextures[NumObjectTextures]; // object texture list (NumObjectTextures * 38 bytes) |
uint32_t NumSampleIndices; // number of sample indices to follow (4 bytes) + | uint32_t NumSampleIndices; // number of sample indices to follow (4 bytes) + |
uint32_t SampleIndices[NumSampleIndices]; // sample indices (NumSampleIndices * 4 bytes) | uint32_t SampleIndices[NumSampleIndices]; // sample indices (NumSampleIndices * 4 bytes) |
| uint8_t Separator[6]; // 6 0x00 bytes |
} | } |
uint32_t NumSamples; // number of sound samples (4 bytes) | uint32_t NumSamples; // number of sound samples (4 bytes) |
<code cpp> | <code cpp> |
uint32_t Version; // version (4 bytes) | uint32_t Version; // version (4 bytes) |
uint16_t NumRoomTextiles; // number of non bumped room tiles (2 bytes) | uint16_t NumRoomImages; // number of non-bumpmapped room images (2 bytes) |
uint16_t NumObjTextiles; // number of object tiles (2 bytes) | uint16_t NumObjImages; // number of object images (2 bytes) |
uint16_t NumBumpTextiles; // number of bumped room tiles (2 bytes) | uint16_t NumBumpmaps; // number of bumpmaps (2 bytes) |
uint32_t Textile32_UncompSize; // uncompressed size (in bytes) of the 32-bit textures chunk (4 bytes) | uint32_t Image32_UncompSize; // uncompressed size (in bytes) of the 32-bit textures chunk (4 bytes) |
uint32_t Textile32_CompSize; // compressed size (in bytes) of the 32-bit textures chunk (4 bytes) | uint32_t Image32_CompSize; // compressed size (in bytes) of the 32-bit textures chunk (4 bytes) |
uint8_t Textile32_Compressed[Textile32_CompSize]; // zlib-compressed 32-bit textures chunk (Textile32_CompSize bytes) | uint8_t Image32_Compressed[Image32_CompSize]; // zlib-compressed 32-bit textures chunk (Image32_CompSize bytes) |
{ | { |
tr4_textile32 Textile32[NumRoomTextiles + NumObjTextiles + NumBumpTextiles]; | tr4_image32 Image32[NumRoomImages + NumObjImages + NumBumpmaps]; |
} | } |
uint32_t Textile16_UncompSize; // uncompressed size (in bytes) of the 16-bit textures chunk (4 bytes) | uint32_t Image16_UncompSize; // uncompressed size (in bytes) of the 16-bit textures chunk (4 bytes) |
uint32_t Textile16_CompSize; // compressed size (in bytes) of the 16-bit textures chunk (4 bytes) | uint32_t Image16_CompSize; // compressed size (in bytes) of the 16-bit textures chunk (4 bytes) |
uint8_t Textile16_Compressed[Textile32_CompSize]; // zlib-compressed 16-bit textures chunk (Textile16_CompSize bytes) | uint8_t Image16_Compressed[Image32_CompSize]; // zlib-compressed 16-bit textures chunk (Image16_CompSize bytes) |
{ | { |
tr_textile16 Textile16[NumRoomTextiles + NumObjTextiles + NumBumpTextiles]; | tr_image16 Image16[NumRoomImages + NumObjImages + NumBumpmaps]; |
} | } |
uint32_t Textile32Misc_UncompSize; // uncompressed size (in bytes) of the 32-bit misc textures chunk (4 bytes), should always be 786432 | uint32_t Image32Misc_UncompSize; // uncompressed size (in bytes) of the 32-bit misc textures chunk (4 bytes), should always be 786432 |
uint32_t Textile32Misc_CompSize; // compressed size (in bytes) of the 32-bit misc textures chunk (4 bytes) | uint32_t Image32Misc_CompSize; // compressed size (in bytes) of the 32-bit misc textures chunk (4 bytes) |
uint8_t Textile32Misc_Compressed[Textile32Misc_CompSize]; // zlib-compressed 32-bit misc textures chunk (Textile32Misc_CompSize bytes) | uint8_t Image32Misc_Compressed[Image32Misc_CompSize]; // zlib-compressed 32-bit misc textures chunk (Image32Misc_CompSize bytes) |
{ | { |
tr4_textile32 Textile32Misc[3]; | tr4_image32 Image32Misc[3]; |
} | } |
uint16_t LaraType; | uint16_t LaraType; |
uint32_t LevelData_CompSize; // compressed size (in bytes) of the level data chunk, equal to LevelData_UncompSize (4 bytes) | uint32_t LevelData_CompSize; // compressed size (in bytes) of the level data chunk, equal to LevelData_UncompSize (4 bytes) |
// NOT COMPRESSED | // NOT COMPRESSED |
uint32_t Unused; // 32-bit unused value, always 0 (4 bytes) | uint32_t LevelNumber; // supposed to be the level number but TOM2PC didn't allow changing it, always 0 (4 bytes) |
uint16_t NumRooms; // number of rooms (2 bytes) | uint16_t NumRooms; // number of rooms (2 bytes) |
tr5_room Rooms[NumRooms]; // room list (variable length) | tr5_room Rooms[NumRooms]; // room list (variable length) |
tr4_sample Samples[NumSamples]; // sound samples (this is the last part, so you can simply read until EOF) | tr4_sample Samples[NumSamples]; // sound samples (this is the last part, so you can simply read until EOF) |
</code> | </code> |
| {{anchor:LaraType}} |
''%%LaraType%%'': | ''%%LaraType%%'': |
| |
* **4** — Divesuit | * **4** — Divesuit |
* **6** — Invisible | * **6** — Invisible |
| * |
| {{anchor:WeatherType}} |
''%%WeatherType%%'': | ''%%WeatherType%%'': |
| |
* In TR1, [[trs:room_geometry#tr2_room_vertex|[tr2_room_vertex]]] has after its [[trs:fundamentals#tr_vertex|[tr_vertex]]] struct only the first light intensity, and not the attributes or the second intensity. | * In TR1, [[trs:room_geometry#tr2_room_vertex|[tr2_room_vertex]]] has after its [[trs:fundamentals#tr_vertex|[tr_vertex]]] struct only the first light intensity, and not the attributes or the second intensity. |
* In TR1, after SectorData, there is only the first light intensity, and not the second one or the lighting mode. | * In TR1, after SectorData, there is only the first light intensity, and not the second one or the lighting mode. |
* In TR1, tr2_room_light has only one of: | * In TR1, [[trs:room_geometry#tr2_room_light|[tr2_room_light]]] has only one of: |
* ''%%uint16_t%%'' Diffuse1/2 | * ''%%uint16_t%%'' Diffuse1/2 |
* ''%%uint32_t%%'' Unknown1/2 | * ''%%uint32_t%%'' Unknown1/2 |
* In TR1, tr_room_staticmesh does not have two light intensities, but only one. | * In TR1, [[trs:room_geometry#tr_room_staticmesh|[tr_room_staticmesh]]] does not have two light intensities, but only one. |
* “Boxes” objects are rectangles whose four horizontal-coordinate values are ''%%uint8_t%%''s in TR2 and ''%%int32_t%%'''s in TR1. | * “Boxes” objects are rectangles whose four horizontal-coordinate values are ''%%uint8_t%%''s in TR2 and ''%%int32_t%%'''s in TR1. |
* “Zones” objects have 10 ''%%int16_t%%''s in TR2, but 6 ''%%int16_t%%''s in TR1 | * “Zones” objects have 10 ''%%int16_t%%''s in TR2, but 6 ''%%int16_t%%''s in TR1 |
* There are no more 8-bit textures. | * There are no more 8-bit textures. |
* There are now 32-bit textures. | * There are now 32-bit textures. |
* Texture tiles are now divided into three parts: //non-bumped room texture tiles//, //model texture tiles// and //bumped room texture tiles//. | * Texture atlases are now divided into three parts: //non-bumpmapped room texture atlases//, //model texture atlases// and //bumpmapped room texture atlases//. |
* Level file divided in several chunks, with each chunk compressed using //zlib//: | * Level file divided in several chunks, with each chunk compressed using //zlib//: |
* Chunk 1: 32-bit texture tiles. | * Chunk 1: 32-bit texture atlases. |
* Chunk 2: 16-bit texture tiles. | * Chunk 2: 16-bit texture atlases. |
* Chunk 3: 32-bit //sky and font graphics//. | * Chunk 3: 32-bit //sky and font graphics//. |
* Chunk 4: Level data. | * Chunk 4: Level data. |
===== Changes in TR4 vs. TR5 ===== | ===== Changes in TR4 vs. TR5 ===== |
| |
* There is no more //bumped room texture tiles// block. | * There is no more //bump-mapped room texture atlases// block. |
* There are now two extra ''%%uint16_t%%'' values after last texture block specifying //Lara type// and //weather type//. Weather type may be either //0// (no weather), //1// (raining) or //2// (snowing). | * There are now two extra ''%%uint16_t%%'' values after last texture block specifying [[trs:file_formats#LaraType|Lara type]] and [[trs:file_formats#WeatherType|weather type]]. |
* Also, it is followed by 28 bytes zero padding. | * Also, it is followed by 28 bytes zero padding. |
* //uncompressed size// and //compressed size// ''%%uint32_t%%'' values for //Level data// block are equal (reason below). | * //Uncompressed size// and //compressed size// ''%%uint32_t%%'' values for //Level data// block are equal (reason below). |
* //Level data// block is not compressed. | * //Level data// block is not compressed. |
* [[trs:room_geometry#tr5_room|[tr5_room]]] struct is used instead of [[trs:room_geometry#tr4_room|[tr4_room]]]. | * [[trs:room_geometry#tr5_room|[tr5_room]]] struct is used instead of [[trs:room_geometry#tr4_room|[tr4_room]]]. |
* The TR2 “Wall” demo, and maybe also its “Venice” demo, has its LightMap (8K) moved to between the SpriteSequences and the Cameras. It also has its SampleIndices content replaced by the soundfiles, though the associated number of them remains unchanged (the number of indices becomes the number of samples). | * The TR2 “Wall” demo, and maybe also its “Venice” demo, has its LightMap (8K) moved to between the SpriteSequences and the Cameras. It also has its SampleIndices content replaced by the soundfiles, though the associated number of them remains unchanged (the number of indices becomes the number of samples). |
* That demo also has its own version of ''%%TOMBPC.DAT%%'', called ''%%DEMOPC.DAT%%'', which appears to have the exact same format as ''%%TOMBPC.DAT%%''. | * That demo also has its own version of ''%%TOMBPC.DAT%%'', called ''%%DEMOPC.DAT%%'', which appears to have the exact same format as ''%%TOMBPC.DAT%%''. |
* The ''%%Version%%'' field of TR4 levels is ''%%0x00345254`%%''(''%%TR4\0%%'') for normal game and ''%%0x63345254%%'' (''%%TR4c%%'') for demo. | * The ''%%Version%%'' field of TR4 levels is ''%%0x00345254%%'' ("''%%TR4\0%%''") for normal game and ''%%0x63345254%%'' ("''%%TR4c%%''") for demo. |
| |
No rearrangements are known for the TR3 demos. | No rearrangements are known for the TR3 demos. |
| |
| |