1 #ifndef _TR_TYPES_H_
2 #define _TR_TYPES_H_
3 
4 #include <stdint.h>
5 
6 /// \brief RGBA colour using bitu8. For palette etc.
7 typedef struct tr2_colour_s
8 {
9     uint8_t r;        ///< \brief the red component.
10     uint8_t g;        ///< \brief the green component.
11     uint8_t b;        ///< \brief the blue component.
12     uint8_t a;        ///< \brief the alpha component.
13 } tr2_colour_t;
14 
15 /// \brief RGBA colour using float. For single colours.
16 typedef struct tr5_colour_s
17 {
18     float r;        ///< \brief the red component.
19     float g;        ///< \brief the green component.
20     float b;        ///< \brief the blue component.
21     float a;        ///< \brief the alpha component.
22 } tr5_colour_t;
23 
24 /// \brief A vertex with x, y and z coordinates.
25 typedef struct tr5_vertex_s
26 {
27     float x;
28     float y;
29     float z;
30 } tr5_vertex_t;
31 
32 /// \brief Definition for a triangle.
33 typedef struct tr4_face3_s
34 {
35     uint16_t vertices[3];    ///< index into the appropriate list of vertices.
36     uint16_t texture;        /**< \brief object-texture index or colour index.
37                                * If the triangle is textured, then this is an index into the object-texture list.
38                                * If it's not textured, then the low 8 bit contain the index into the 256 colour palette
39                                * and from TR2 on the high 8 bit contain the index into the 16 bit palette.
40                                */
41     uint16_t lighting;       /**< \brief transparency flag & strength of the hilight (TR4-TR5).
42                                * bit0 if set, then alpha channel = intensity (see attribute in tr2_object_texture).<br>
43                                * bit1-7 is the strength of the hilight.
44                                */
45 } tr4_face3_t;
46 
47 /// \brief Definition for a rectangle.
48 typedef struct tr4_face4_s
49 {
50     uint16_t vertices[4];    ///< index into the appropriate list of vertices.
51     uint16_t texture;        /**< \brief object-texture index or colour index.
52                                * If the rectangle is textured, then this is an index into the object-texture list.
53                                * If it's not textured, then the low 8 bit contain the index into the 256 colour palette
54                                * and from TR2 on the high 8 bit contain the index into the 16 bit palette.
55                                */
56     uint16_t lighting;       /**< \brief transparency flag & strength of the hilight (TR4-TR5).
57                                *
58                                * In TR4, objects can exhibit some kind of light reflection when seen from some particular angles.
59                                * - bit0 if set, then alpha channel = intensity (see attribute in tr2_object_texture).
60                                * - bit1-7 is the strength of the hilight.
61                                */
62 } tr4_face4_t;
63 
64 /** \brief 8-bit texture.
65   *
66   * Each pixel is an index into the colour palette.
67   */
68 typedef struct tr_textile8_s
69 {
70     uint8_t pixels[256][256];
71 } tr_textile8_t;
72 
73 /** \brief 16-bit texture.
74   *
75   * Each pixel is a colour with the following format.<br>
76   * - 1-bit transparency (0 ::= transparent, 1 ::= opaque) (0x8000)
77   * - 5-bit red channel (0x7c00)
78   * - 5-bit green channel (0x03e0)
79   * - 5-bit blue channel (0x001f)
80   */
81 typedef struct tr2_textile16_s
82 {
83     uint16_t pixels[256][256];
84 } tr2_textile16_t;
85 
86 /** \brief 32-bit texture.
87   *
88   * Each pixel is an ABGR value.
89   */
90 typedef struct tr4_textile32_s
91 {
92     uint32_t pixels[256][256];
93 } tr4_textile32_t;
94 
95 /** \brief Room portal.
96   */
97 typedef struct tr_room_portal_s
98 {
99     uint16_t adjoining_room;     ///< \brief which room this portal leads to.
100     tr5_vertex_t normal;         /**< \brief which way the portal faces.
101                                    * the normal points away from the adjacent room.
102                                    * to be seen through, it must point toward the viewpoint.
103                                    */
104     tr5_vertex_t vertices[4];    /**< \brief the corners of this portal.
105                                    * the right-hand rule applies with respect to the normal.
106                                    * if the right-hand-rule is not followed, the portal will
107                                    * contain visual artifacts instead of a viewport to
108                                    * AdjoiningRoom.
109                                    */
110 } tr_room_portal_t;
111 
112 /** \brief Room sector.
113   */
114 typedef struct tr_room_sector_s
115 {
116     uint16_t fd_index;     // Index into FloorData[]
117     uint16_t box_index;    // Index into Boxes[]/Zones[] (-1 if none)
118     uint8_t room_below;    // The number of the room below this one (-1 or 255 if none)
119     int8_t floor;          // Absolute height of floor (multiply by 256 for world coordinates)
120     uint8_t room_above;    // The number of the room above this one (-1 or 255 if none)
121     int8_t ceiling;        // Absolute height of ceiling (multiply by 256 for world coordinates)
122 } tr_room_sector_t;
123 
124 /** \brief Room light.
125   */
126 typedef struct tr5_room_light_s
127 {
128     tr5_vertex_t pos;           // world coords
129     tr2_colour_t color;         // three bytes rgb values
130     float intensity;            // Calculated intensity
131     uint16_t intensity1;        // Light intensity
132     uint16_t intensity2;        // Almost always equal to Intensity1 [absent from TR1 data files]
133     uint32_t fade1;             // Falloff value 1
134     uint32_t fade2;             // Falloff value 2 [absent from TR1 data files]
135     uint8_t light_type;         // same as D3D (i.e. 2 is for spotlight)
136     uint8_t unknown;            // always 0xff?
137     float r_inner;
138     float r_outer;
139     float length;
140     float cutoff;
141     tr5_vertex_t dir;           // direction
142     tr5_vertex_t pos2;          // world coords
143     tr5_vertex_t dir2;          // direction
144 } tr5_room_light_t;
145 
146 /** \brief Room sprite.
147   */
148 typedef struct tr_room_sprite_s
149 {
150     int16_t vertex;                 // offset into vertex list
151     int16_t texture;                // offset into sprite texture list
152 } tr_room_sprite_t;
153 
154 /** \brief Room layer (TR5).
155   */
156 typedef struct tr5_room_layer_s
157 {
158     uint16_t num_vertices;          // number of vertices in this layer (4 bytes)
159     uint16_t unknown_l1;
160     uint16_t unknown_l2;
161     uint16_t num_rectangles;        // number of rectangles in this layer (2 bytes)
162     uint16_t num_triangles;         // number of triangles in this layer (2 bytes)
163     uint16_t unknown_l3;
164     uint16_t unknown_l4;
165     //  The following 6 floats (4 bytes each) define the bounding box for the layer
166     float bounding_box_x1;
167     float bounding_box_y1;
168     float bounding_box_z1;
169     float bounding_box_x2;
170     float bounding_box_y2;
171     float bounding_box_z2;
172     int16_t unknown_l6a;
173     int16_t unknown_l6b;
174     int16_t unknown_l7a;
175     int16_t unknown_l7b;
176     int16_t unknown_l8a;
177     int16_t unknown_l8b;
178 } tr5_room_layer_t;
179 
180 /** \brief Room vertex.
181   */
182 typedef struct tr5_room_vertex_s
183 {
184     tr5_vertex_t vertex;    // where this vertex lies (relative to tr2_room_info::x/z)
185     int16_t lighting1;
186     uint16_t attributes;    // A set of flags for special rendering effects [absent from TR1 data files]
187     // 0x8000 something to do with water surface
188     // 0x4000 under water lighting modulation and
189     // movement if viewed from above water surface
190     // 0x2000 water/quicksand surface movement
191     // 0x0010 "normal"
192     int16_t lighting2;      // Almost always equal to Lighting1 [absent from TR1 data files]
193     // TR5 -->
194     tr5_vertex_t normal;
195     tr5_colour_t colour;    // vertex color ARGB format (4 bytes)
196 } tr5_room_vertex_t;
197 
198 /** \brief Room staticmesh.
199   */
200 typedef struct tr2_room_staticmesh_s
201 {
202     tr5_vertex_t pos;       // world coords
203     float rotation;         // high two bits (0xC000) indicate steps of
204     // 90 degrees (e.g. (Rotation >> 14) * 90)
205     int16_t intensity1;     // Constant lighting; -1 means use mesh lighting
206     int16_t intensity2;     // Like Intensity 1, and almost always the same value [absent from TR1 data files]
207     uint16_t object_id;     // which StaticMesh item to draw
208     tr5_colour_t tint;      // extracted from intensity
209 } tr2_room_staticmesh_t;
210 
211 /** \brief Room.
212   */
213 typedef struct tr5_room_s
214 {
215     tr5_vertex_t offset;            ///< \brief offset of room (world coordinates).
216     float y_bottom;                 ///< \brief indicates lowest point in room.
217     float y_top;                    ///< \brief indicates highest point in room.
218     uint32_t num_layers;            // number of layers (pieces) this room (4 bytes)
219     tr5_room_layer_t *layers;       // [NumStaticMeshes]list of static meshes
220     uint32_t num_vertices;          // number of vertices in the following list
221     tr5_room_vertex_t *vertices;    // [NumVertices] list of vertices (relative coordinates)
222     uint32_t num_rectangles;        // number of textured rectangles
223     tr4_face4_t *rectangles;        // [NumRectangles] list of textured rectangles
224     uint32_t num_triangles;         // number of textured triangles
225     tr4_face3_t *triangles;         // [NumTriangles] list of textured triangles
226     uint32_t num_sprites;           // number of sprites
227     tr_room_sprite_t *sprites;      // [NumSprites] list of sprites
228     uint16_t num_portals;           // number of visibility portals to other rooms
229     tr_room_portal_t *portals;      // [NumPortals] list of visibility portals
230     uint16_t num_zsectors;          // "width" of sector list
231     uint16_t num_xsectors;          // "height" of sector list
232     tr_room_sector_t *sector_list;  // [NumXsectors * NumZsectors] list of sectors
233     // in this room
234     int16_t intensity1;             // This and the next one only affect externally-lit objects
235     int16_t intensity2;             // Almost always the same value as AmbientIntensity1 [absent from TR1 data files]
236     int16_t light_mode;             // (present only in TR2: 0 is normal, 1 is flickering(?), 2 and 3 are uncertain)
237     uint16_t num_lights;            // number of point lights in this room
238     tr5_room_light_t *lights;       // [NumLights] list of point lights
239     uint16_t num_static_meshes;     // number of static meshes
240     tr2_room_staticmesh_t *static_meshes;    // [NumStaticMeshes]list of static meshes
241     int16_t alternate_room;         // number of the room that this room can alternate
242     int8_t  alternate_group;        // number of group which is used to switch alternate rooms
243     // with (e.g. empty/filled with water is implemented as an empty room that alternates with a full room)
244 
245         uint16_t flags;
246     // Flag bits:
247     // 0x0001 - room is filled with water,
248     // 0x0020 - Lara's ponytail gets blown by the wind;
249     // TR1 has only the water flag and the extra unknown flag 0x0100.
250     // TR3 most likely has flags for "is raining", "is snowing", "water is cold", and "is
251     // filled by quicksand", among others.
252 
253         uint8_t water_scheme;
254     // Water scheme is used with various room options, for example, R and M room flags in TRLE.
255     // Also, it specifies lighting scheme, when 0x4000 vertex attribute is set.
256 
257     uint8_t reverb_info;
258 
259     // Reverb info is used in TR3-5 and contains index that specifies reverb type.
260     // 0 - Outside, 1 - Small room, 2 - Medium room, 3 - Large room, 4 - Pipe.
261 
262     tr5_colour_t light_colour;    // Present in TR4 and TR5 only
263 
264     // TR5 only:
265 
266     float room_x;
267     float room_z;
268     float room_y_bottom;
269     float room_y_top;
270 
271     uint32_t unknown_r1;
272     uint32_t unknown_r2;
273     uint32_t unknown_r3;
274     uint16_t unknown_r4a;
275     uint16_t unknown_r4b;
276     uint32_t unknown_r5;
277     uint32_t unknown_r6;
278 } tr5_room_t;
279 
280 /** \brief Mesh.
281   */
282 typedef struct tr4_mesh_s
283 {
284     tr5_vertex_t centre;                // This is usually close to the mesh's centroid, and appears to be the center of a sphere used for collision testing.
285     int16_t collision_size;             // This appears to be the radius of that aforementioned collisional sphere.
286     uint8_t flags;                      // Known flags (&1)
287     uint8_t dummy;                      // Unused
288     int16_t num_vertices;               // number of vertices in this mesh
289     uint32_t vertices_count;
290     tr5_vertex_t *vertices;             //[NumVertices]; // list of vertices (relative coordinates)
291     int16_t num_normals;                // If positive, number of normals in this mesh.
292     // If negative, number of vertex lighting elements (* (-1))
293     int16_t num_lights;                 // Engine internal for above
294     tr5_vertex_t *normals;              //[NumNormals]; // list of normals (if NumNormals is positive)
295     int16_t *lights;                    //[-NumNormals]; // list of light values (if NumNormals is negative)
296     int16_t num_textured_rectangles;    // number of textured rectangles in this mesh
297     tr4_face4_t *textured_rectangles;   //[NumTexturedRectangles]; // list of textured rectangles
298     int16_t num_textured_triangles;      // number of textured triangles in this mesh
299     tr4_face3_t *textured_triangles;    //[NumTexturedTriangles]; // list of textured triangles
300     // the rest is not present in TR4
301     int16_t num_coloured_rectangles;    // number of coloured rectangles in this mesh
302     tr4_face4_t *coloured_rectangles;   //[NumColouredRectangles]; // list of coloured rectangles
303     int16_t num_coloured_triangles;     // number of coloured triangles in this mesh
304     tr4_face3_t *coloured_triangles;    //[NumColouredTriangles]; // list of coloured triangles
305 } tr4_mesh_t;
306 
307 /** \brief Staticmesh.
308   */
309 typedef struct tr_staticmesh_s
310 {                    // 32 bytes
311     uint32_t object_id;             // Object Identifier (matched in Items[])
312     uint16_t mesh;                  // mesh (offset into MeshPointers[])
313     tr5_vertex_t visibility_box[2];
314     tr5_vertex_t collision_box[2];
315     uint16_t flags;                 // Meaning uncertain; it is usually 2, and is 3 for objects Lara can travel through,
316     // like TR2's skeletons and underwater vegetation
317 } tr_staticmesh_t;
318 
319 /** \brief MeshTree.
320   *
321   * MeshTree[] is actually groups of four bit32s. The first one is a
322   * "flags" word;
323   *    bit 1 (0x0002) indicates "put the parent mesh on the mesh stack";
324   *    bit 0 (0x0001) indicates "take the top mesh off of the mesh stack and use as the parent mesh"
325   * when set, otherwise "use the previous mesh are the parent mesh".
326   * When both are present, the bit-0 operation is always done before the bit-1 operation; in effect, read the stack but do not change it.
327   * The next three bit32s are X, Y, Z offsets of the mesh's origin from the parent mesh's origin.
328   */
329 typedef struct tr_meshtree_s
330 {        // 4 bytes
331     uint32_t flags;
332     tr5_vertex_t offset;
333 } tr_meshtree_t;
334 
335 /** \brief Frame.
336   *
337   * Frames indicates how composite meshes are positioned and rotated.
338   * They work in conjunction with Animations[] and Bone2[].
339   *
340   * A given frame has the following format:
341   *    short BB1x, BB1y, BB1z           // bounding box (low)
342   *    short BB2x, BB2y, BB2z           // bounding box (high)
343   *    short OffsetX, OffsetY, OffsetZ  // starting offset for this moveable
344   *    (TR1 ONLY: short NumValues       // number of angle sets to follow)
345   *    (TR2/3: NumValues is implicitly NumMeshes (from moveable))
346   *
347   * What follows next is a list of angle sets.  In TR2/3, an angle set can
348   * specify either one or three axes of rotation.  If either of the high two
349   * bits (0xc000) of the first angle unsigned short are set, it's one axis:
350   *  only one  unsigned short,
351   *  low 10 bits (0x03ff),
352   *  scale is 0x100 == 90 degrees;
353   * the high two  bits are interpreted as follows:
354   *  0x4000 == X only, 0x8000 == Y only,
355   *  0xC000 == Z only.
356   *
357   * If neither of the high bits are set, it's a three-axis rotation.  The next
358   * 10 bits (0x3ff0) are the X rotation, the next 10 (including the following
359   * unsigned short) (0x000f, 0xfc00) are the Y rotation,
360   * the next 10 (0x03ff) are the Z rotation, same scale as
361   * before (0x100 == 90 degrees).
362   *
363   * Rotations are performed in Y, X, Z order.
364   * TR1 ONLY: All angle sets are two words and interpreted like the two-word
365   * sets in TR2/3, EXCEPT that the word order is reversed.
366   *
367   */
368 /*typedef struct tr_frame_s
369 {
370     tr5_vertex_t bbox_low;
371     tr5_vertex_t bbox_high;
372     tr5_vertex_t offset;
373     tr5_vertex_array_t rotations;
374     int32_t byte_offset;
375 } tr_frame_t;
376 typedef prtl::array < tr_frame_t > tr_frame_array_t;*/
377 
378 /** \brief Moveable.
379   */
380 typedef struct tr_moveable_s
381 {                // 18 bytes
382     uint32_t object_id;         // Item Identifier (matched in Items[])
383     uint16_t num_meshes;        // number of meshes in this object
384     uint16_t starting_mesh;     // stating mesh (offset into MeshPointers[])
385     uint32_t mesh_tree_index;   // offset into MeshTree[]
386     uint32_t frame_offset;      // byte offset into Frames[] (divide by 2 for Frames[i])
387     uint32_t frame_index;
388     uint16_t animation_index;   // offset into Animations[]
389 } tr_moveable_t;
390 
391 /** \brief Item.
392   */
393 typedef struct tr2_item_s
394 {           // 24 bytes [TR1: 22 bytes]
395     int16_t object_id;     // Object Identifier (matched in Moveables[], or SpriteSequences[], as appropriate)
396     int16_t room;          // which room contains this item
397     tr5_vertex_t pos;      // world coords
398     float rotation;        // ((0xc000 >> 14) * 90) degrees
399     int16_t intensity1;    // (constant lighting; -1 means use mesh lighting)
400     int16_t intensity2;    // Like Intensity1, and almost always with the same value. [absent from TR1 data files]
401     int16_t ocb;           // Object code bit - used for altering entity behaviour. Only in TR4-5.
402     uint16_t flags;        // 0x0100 indicates "initially invisible", 0x3e00 is Activation Mask
403     // 0x3e00 indicates "open" or "activated";  these can be XORed with
404     // related FloorData::FDlist fields (e.g. for switches)
405 } tr2_item_t;
406 
407 /** \brief Sprite texture.
408   */
409 typedef struct tr_sprite_texture_s
410 {               // 16 bytes
411     uint16_t        tile;
412     int16_t         x0;        // tex coords
413     int16_t         y0;        //
414     int16_t         x1;        //
415     int16_t         y1;        //
416 
417     int16_t         left_side;
418     int16_t         top_side;
419     int16_t         right_side;
420     int16_t         bottom_side;
421 } tr_sprite_texture_t;
422 
423 /** \brief Sprite sequence.
424   */
425 typedef struct tr_sprite_sequence_s
426 {           // 8 bytes
427     int32_t object_id;     // Item identifier (matched in Items[])
428     int16_t length;        // negative of "how many sprites are in this sequence"
429     int16_t offset;        // where (in sprite texture list) this sequence starts
430 } tr_sprite_sequence_t;
431 
432 /** \brief Animation.
433   *
434   * This describes each individual animation; these may be looped by specifying
435   * the next animation to be itself. In TR2 and TR3, one must be careful when
436   * parsing frames using the FrameSize value as the size of each frame, since
437   * an animation's frame range may extend into the next animation's frame range,
438   * and that may have a different FrameSize value.
439   */
440 typedef struct tr_animation_s
441 {                // 32 bytes TR1/2/3 40 bytes TR4
442     uint32_t frame_offset;      // byte offset into Frames[] (divide by 2 for Frames[i])
443     uint8_t frame_rate;         // Engine ticks per frame
444     uint8_t frame_size;         // number of bit16's in Frames[] used by this animation
445     uint16_t state_id;
446 
447     float   speed;
448     float   accel;
449 
450     float   speed_lateral;      // new in TR4 -->
451     float   accel_lateral;      // lateral speed and acceleration.
452 
453     uint16_t frame_start;           // first frame in this animation
454     uint16_t frame_end;             // last frame in this animation (numframes = (End - Start) + 1)
455     uint16_t next_animation;
456     uint16_t next_frame;
457 
458     uint16_t num_state_changes;
459     uint16_t state_change_offset;   // offset into StateChanges[]
460     uint16_t num_anim_commands;     // How many of them to use.
461     uint16_t anim_command;          // offset into AnimCommand[]
462 } tr_animation_t;
463 
464 /** \brief Mesh Tree.
465   *
466   * Each one contains the flag (0x0001 = POP, 0x0002 = PUSH, 0x0003 = POP + PUSH)
467   * and mesh offset (x, y, z)
468   */
469 typedef struct tr_mesh_thee_tag_s
470 {               // 16 bytes
471     uint32_t    flag_data;
472     float       dx;
473     float       dy;
474     float       dz;
475 } tr_mesh_thee_tag_t;
476 
477 /** \brief State Change.
478   *
479   * Each one contains the state to change to and which animation dispatches
480   * to use; there may be more than one, with each separate one covering a different
481   * range of frames.
482   */
483 typedef struct tr_state_change_s
484 {                        // 6 bytes
485     uint16_t state_id;
486     uint16_t num_anim_dispatches;       // number of ranges (seems to always be 1..5)
487     uint16_t anim_dispatch;             // Offset into AnimDispatches[]
488 } tr_state_change_t;
489 
490 /** \brief Animation Dispatch.
491   *
492   * This specifies the next animation and frame to use; these are associated
493   * with some range of frames. This makes possible such specificity as one
494   * animation for left foot forward and another animation for right foot forward.
495   */
496 typedef struct tr_anim_dispatch_s
497 {                // 8 bytes
498     int16_t low;                // Lowest frame that uses this range
499     int16_t high;               // Highest frame (+1?) that uses this range
500     int16_t next_animation;     // Animation to dispatch to
501     int16_t next_frame;         // Frame offset to dispatch to
502 } tr_anim_dispatch_t;
503 
504 /** \brief Animation Command.
505   *
506   * These are various commands associated with each animation; they are
507   * called "Bone1" in some documentation. They are varying numbers of bit16's
508   * packed into an array; the first of each set is the opcode, which determines
509   * how operand bit16's follow it. Some of them refer to the whole animation
510   * (jump and grab points, etc.), while others of them are associated with
511   * specific frames (sound, bubbles, etc.).
512   */
513 //typedef struct {        // 2 bytes
514 //    int16_t value;
515 //} tr_anim_command_t;
516 
517 /** \brief Box.
518   */
519 typedef struct tr_box_s
520 {            // 8 bytes [TR1: 20 bytes] In TR1, the first four are bit32's instead of bitu8's, and are not scaled.
521     uint32_t zmin;          // sectors (* 1024 units)
522     uint32_t zmax;
523     uint32_t xmin;
524     uint32_t xmax;
525     int16_t true_floor;     // Y value (no scaling)
526     uint16_t overlap_index; // index into Overlaps[]. The high bit is sometimes set;
527     // occurs in front of swinging doors and the like.
528 } tr_box_t;
529 
530 /** \brief Zone.
531   */
532 typedef struct tr2_zone_s
533 {
534     int16_t GroundZone1_Normal;
535     int16_t GroundZone2_Normal;
536     int16_t GroundZone3_Normal;
537     int16_t GroundZone4_Normal;
538     int16_t FlyZone_Normal;
539     int16_t GroundZone1_Alternate;
540     int16_t GroundZone2_Alternate;
541     int16_t GroundZone3_Alternate;
542     int16_t GroundZone4_Alternate;
543     int16_t FlyZone_Alternate;
544 } tr2_zone_t;
545 
546 /** \brief SoundSource.
547   *
548   * This structure contains the details of continuous-sound sources. Although
549   * a SoundSource object has a position, it has no room membership; the sound
550   * seems to propagate omnidirectionally for about 10 horizontal-grid sizes
551   * without regard for the presence of walls.
552   */
553 typedef struct tr_sound_source_s
554 {
555     int32_t x;              // absolute X position of sound source (world coordinates)
556     int32_t y;              // absolute Y position of sound source (world coordinates)
557     int32_t z;              // absolute Z position of sound source (world coordinates)
558     uint16_t sound_id;      // internal sound index
559     uint16_t flags;         // 0x40, 0x80, or 0xc0
560 } tr_sound_source_t;
561 
562 /** \brief SoundDetails.
563  *
564  * SoundDetails (also called SampleInfos in native TR sources) are properties
565  * for each sound index from SoundMap. It contains all crucial information
566  * that is needed to play certain sample, except offset to raw wave buffer,
567  * which is unnecessary, as it is managed internally by DirectSound.
568  */
569 
570 typedef struct tr_sound_details_s
571 {                         // 8 bytes
572     uint16_t sample;                     // Index into SampleIndices -- NOT USED IN TR4-5!!!
573     uint16_t volume;                     // Global sample value
574     uint16_t sound_range;                // Sound range
575     uint16_t chance;                     // Chance to play
576     int16_t pitch;                       // Pitch shift
577     uint8_t num_samples_and_flags_1;     // Bits 0-1: Looped flag, bits 2-5: num samples, bits 6-7: UNUSED
578     uint8_t flags_2;                     // Bit 4: UNKNOWN, bit 5: Randomize pitch, bit 6: randomize volume
579                                          // All other bits in flags_2 are unused.
580 } tr_sound_details_t;
581 
582 
583 /** \brief Object Texture Vertex.
584   *
585   * It specifies a vertex location in textile coordinates.
586   * The Xpixel and Ypixel are the actual coordinates of the vertex's pixel.
587   * The Xcoordinate and Ycoordinate values depend on where the other vertices
588   * are in the object texture. And if the object texture is used to specify
589   * a triangle, then the fourth vertex's values will all be zero.
590   */
591 typedef struct tr4_object_texture_vert_s
592 {            // 4 bytes
593     int8_t xcoordinate;     // 1 if Xpixel is the low value, -1 if Xpixel is the high value in the object texture
594     uint8_t xpixel;
595     int8_t ycoordinate;     // 1 if Ypixel is the low value, -1 if Ypixel is the high value in the object texture
596     uint8_t ypixel;
597 } tr4_object_texture_vert_t;
598 
599 /** \brief Object Texture.
600   *
601   * These, thee contents of ObjectTextures[], are used for specifying texture
602   * mapping for the world geometry and for mesh objects.
603   */
604 typedef struct tr4_object_texture_s
605 {                    // 38 bytes TR4 - 20 in TR1/2/3
606     uint16_t transparency_flags;    // 0 means that a texture is all-opaque, and that transparency
607     // information is ignored.
608     // 1 means that transparency information is used. In 8-bit colour,
609     // index 0 is the transparent colour, while in 16-bit colour, the
610     // top bit (0x8000) is the alpha channel (1 = opaque, 0 = transparent).
611     // 2 (only in TR3) means that the opacity (alpha) is equal to the intensity;
612     // the brighter the colour, the more opaque it is. The intensity is probably calculated
613     // as the maximum of the individual color values.
614     uint16_t tile_and_flag;                     // index into textile list
615     uint16_t flags;                             // TR4
616     tr4_object_texture_vert_t vertices[4];      // the four corners of the texture
617     uint32_t unknown1;                          // TR4
618     uint32_t unknown2;                          // TR4
619     uint32_t x_size;                            // TR4
620     uint32_t y_size;                            // TR4
621 } tr4_object_texture_t;
622 
623 /** \brief Animated Textures.
624   */
625 typedef struct tr_animated_textures_s
626 {
627     //int16_t num_texture_ids;    // Actually, this is the number of texture ID's - 1.
628     int16_t  texture_ids_count;
629     int16_t *texture_ids;       //[NumTextureIDs + 1]; // offsets into ObjectTextures[], in animation order.
630 } tr_animated_textures_t;       //[NumAnimatedTextures];
631 
632 /** \brief Camera.
633   */
634 typedef struct tr_camera_s
635 {
636     int32_t x;
637     int32_t y;
638     int32_t z;
639     int16_t room;
640     uint16_t unknown1;    // correlates to Boxes[]? Zones[]?
641 } tr_camera_t;
642 
643 /** \brief Extra Camera.
644   */
645 typedef struct tr4_flyby_camera_s
646 {
647     int32_t pos_x;
648     int32_t pos_y;
649     int32_t pos_z;
650     int32_t target_x;
651     int32_t target_y;
652     int32_t target_z;
653     uint8_t sequence;
654     uint8_t index;
655 
656     uint16_t fov;
657     uint16_t roll;
658     uint16_t timer;
659     uint16_t speed;
660     uint16_t flags;
661 
662     int32_t room_id;
663 } tr4_flyby_camera_t;
664 
665 /** \brief AI Object.
666   */
667 typedef struct tr4_ai_object_s
668 {
669     uint16_t object_id;    // the objectID from the AI object (AI_FOLLOW is 402)
670     uint16_t room;
671     int32_t x;
672     int32_t y;
673     int32_t z;
674     uint16_t ocb;
675     uint16_t flags;        // The trigger flags (button 1-5, first button has value 2)
676     int32_t angle;
677 } tr4_ai_object_t;
678 
679 /** \brief Cinematic Frame.
680   */
681 typedef struct tr_cinematic_frame_s
682 {
683     //Camera look at position
684     int16_t targetx;
685     int16_t targety;
686     int16_t targetz;
687     //Camera position
688     int16_t posx;
689     int16_t posy;
690     int16_t posz;
691     int16_t fov;
692     int16_t roll;
693 } tr_cinematic_frame_t;
694 
695 /** \brief Lightmap.
696   */
697 typedef struct tr_lightmap_s
698 {
699     uint8_t map[32 * 256];
700 } tr_lightmap_t;
701 
702 /** \brief Palette.
703   */
704 typedef struct tr2_palette_s
705 {
706     tr2_colour_t colour[256];
707 } tr2_palette_t;
708 
709 #endif // _TR_TYPES_H_
710