|
@@ -83,26 +83,24 @@ typedef enum {
|
83
|
83
|
TR_VERSION_5
|
84
|
84
|
} tr2_version_type;
|
85
|
85
|
|
86
|
|
-
|
87
|
86
|
typedef enum {
|
88
|
87
|
TR_FREAD_NORMAL = 0,
|
89
|
88
|
TR_FREAD_COMPRESSED
|
90
|
89
|
} tr_fread_mode_t;
|
91
|
90
|
|
92
|
|
-
|
93
|
91
|
typedef enum {
|
94
|
|
- tombraiderLight_typeDirectional = 1,
|
95
|
|
- tombraiderLight_typeSpot = 2,
|
96
|
|
- tombraiderLight_typePoint = 3
|
|
92
|
+ tombraiderLight_typeDirectional = 1,
|
|
93
|
+ tombraiderLight_typeSpot = 2,
|
|
94
|
+ tombraiderLight_typePoint = 3
|
97
|
95
|
} tombraiderLightType;
|
98
|
96
|
|
99
|
97
|
typedef enum {
|
100
|
|
- tombraiderLight_useCutoff = 1,
|
101
|
|
- tombraiderLight_useAttenuation = 2
|
|
98
|
+ tombraiderLight_useCutoff = 1,
|
|
99
|
+ tombraiderLight_useAttenuation = 2
|
102
|
100
|
} tombraiderLightFlags;
|
103
|
101
|
|
104
|
102
|
typedef enum {
|
105
|
|
- tombraiderRoom_underWater = 1
|
|
103
|
+ tombraiderRoom_underWater = 1
|
106
|
104
|
} tombraiderRoomFlags;
|
107
|
105
|
|
108
|
106
|
typedef enum {
|
|
@@ -110,12 +108,11 @@ typedef enum {
|
110
|
108
|
} tombraiderSectorFlags;
|
111
|
109
|
|
112
|
110
|
typedef enum {
|
113
|
|
- tombraiderFace_Alpha = 1,
|
114
|
|
- tombraiderFace_Colored = 2,
|
115
|
|
- tombraiderFace_PartialAlpha = 4
|
|
111
|
+ tombraiderFace_Alpha = (1 << 0),
|
|
112
|
+ tombraiderFace_Colored = (1 << 1),
|
|
113
|
+ tombraiderFace_PartialAlpha = (1 << 2)
|
116
|
114
|
} tombraiderFace_Flags;
|
117
|
115
|
|
118
|
|
-
|
119
|
116
|
#define TR_SOUND_FOOTSTEP0 1
|
120
|
117
|
#define TR_SOUND_F_PISTOL 12
|
121
|
118
|
|
|
@@ -167,7 +164,6 @@ typedef struct {
|
167
|
164
|
unsigned char b; //!< Blue part
|
168
|
165
|
} __attribute__ ((packed)) tr2_colour_t;
|
169
|
166
|
|
170
|
|
-
|
171
|
167
|
/*!
|
172
|
168
|
* \brief Basic vertex structure.
|
173
|
169
|
*
|
|
@@ -212,8 +208,9 @@ typedef struct {
|
212
|
208
|
*/
|
213
|
209
|
} __attribute__ ((packed)) tr4_quad_t;
|
214
|
210
|
|
215
|
|
-/*--------------------------------------------------------------
|
216
|
|
- * A triangular face definition.
|
|
211
|
+/*!
|
|
212
|
+ * \brief A triangular face definition.
|
|
213
|
+ *
|
217
|
214
|
* Three vertices (the values are indices into the
|
218
|
215
|
* appropriate vertex list) and a texture (an index into the
|
219
|
216
|
* texture list) or colour (index into palette).
|
|
@@ -221,111 +218,97 @@ typedef struct {
|
221
|
218
|
* In the case of a colour, (Texture & 0xff) is the index
|
222
|
219
|
* into the 8-bit palette, while (Texture >> 8) is
|
223
|
220
|
* the index into the 16-bit palette.
|
224
|
|
- --------------------------------------------------------------*/
|
225
|
|
-typedef struct tr2_tri_s /* was tr2_face3 */
|
226
|
|
-{
|
227
|
|
- unsigned short vertices[3];
|
228
|
|
- unsigned short texture;
|
229
|
|
-} __attribute__ ((packed)) tr2_tri_t;
|
|
221
|
+ */
|
|
222
|
+typedef struct {
|
|
223
|
+ unsigned short vertices[3];
|
|
224
|
+ unsigned short texture;
|
|
225
|
+} __attribute__ ((packed)) tr2_tri_t; // was tr2_face3
|
230
|
226
|
|
231
|
|
-typedef struct tr4_tri_s
|
232
|
|
-{
|
233
|
|
- unsigned short vertices[3]; // The 3 vertices of a tri
|
234
|
|
- unsigned short texture; // Object-texture index
|
235
|
|
- unsigned short lighting; // transparency flag & strength of
|
236
|
|
- // the hilight
|
237
|
|
-} __attribute__ ((packed)) tr4_tri_t;
|
|
227
|
+typedef struct {
|
|
228
|
+ unsigned short vertices[3]; //!< The 3 vertices of a tri
|
|
229
|
+ unsigned short texture; //!< Object-texture index
|
|
230
|
+ unsigned short lighting; //!< Transparency flag & strength of the highlight
|
|
231
|
+} __attribute__ ((packed)) tr4_tri_t;
|
238
|
232
|
|
239
|
|
-/*--------------------------------------------------------------
|
240
|
|
- * An 8-bit texture tile (65536 bytes).
|
|
233
|
+/*!
|
|
234
|
+ * \brief An 8-bit texture tile (65536 bytes).
|
241
|
235
|
*
|
242
|
236
|
* Each byte represents a pixel whose colour
|
243
|
237
|
* is in the 8-bit palette.
|
244
|
|
- --------------------------------------------------------------*/
|
245
|
|
-typedef struct tr2_textile8_s
|
246
|
|
-{
|
247
|
|
- unsigned char tile[256 * 256];
|
248
|
|
-} __attribute__ ((packed)) tr2_textile8_t;
|
249
|
|
-
|
|
238
|
+ */
|
|
239
|
+typedef struct {
|
|
240
|
+ unsigned char tile[256 * 256];
|
|
241
|
+} __attribute__ ((packed)) tr2_textile8_t;
|
250
|
242
|
|
251
|
|
-/*--------------------------------------------------------------
|
252
|
|
- * A 16-bit texture tile (131072 bytes).
|
|
243
|
+/*!
|
|
244
|
+ * \brief A 16-bit texture tile (131072 bytes).
|
253
|
245
|
*
|
254
|
246
|
* Each word represents a pixel
|
255
|
247
|
* whose colour is of the form ARGB, MSB-to-LSB:
|
256
|
248
|
*
|
257
|
|
- * 1-bit transparency (0: transparent, 1: opaque)
|
258
|
|
- * 5-bit red channel
|
259
|
|
- * 5-bit green channel
|
260
|
|
- * 5-bit blue channel
|
261
|
|
- --------------------------------------------------------------*/
|
262
|
|
-typedef struct tr2_textile16_s
|
263
|
|
-{
|
264
|
|
- unsigned short tile[256 * 256];
|
265
|
|
-} __attribute__ ((packed)) tr2_textile16_t;
|
266
|
|
-
|
267
|
|
-
|
268
|
|
-/* --------------------------------------------------------------
|
269
|
|
- * 32bit textiles
|
270
|
|
- * BGRA with 4bytes each channel
|
271
|
|
- --------------------------------------------------------------*/
|
272
|
|
-typedef struct tr2_textile32_s
|
273
|
|
-{
|
274
|
|
- unsigned int tile[256 * 256];
|
275
|
|
-} __attribute__ ((packed)) tr2_textile32_t;
|
|
249
|
+ * * 1-bit transparency (0: transparent, 1: opaque)
|
|
250
|
+ * * 5-bit red channel
|
|
251
|
+ * * 5-bit green channel
|
|
252
|
+ * * 5-bit blue channel
|
|
253
|
+ */
|
|
254
|
+typedef struct {
|
|
255
|
+ unsigned short tile[256 * 256];
|
|
256
|
+} __attribute__ ((packed)) tr2_textile16_t;
|
276
|
257
|
|
|
258
|
+/*!
|
|
259
|
+ * \brief A 32-bit texture tile (262144 bytes).
|
|
260
|
+ *
|
|
261
|
+ * BGRA with 4bytes each channel.
|
|
262
|
+ */
|
|
263
|
+typedef struct {
|
|
264
|
+ unsigned int tile[256 * 256];
|
|
265
|
+} __attribute__ ((packed)) tr2_textile32_t;
|
277
|
266
|
|
278
|
|
-/*--------------------------------------------------------------
|
279
|
|
- * The "header" of a room.
|
280
|
|
- * + X/Z indicate the base position of the room
|
281
|
|
- * mesh in world coordinates.
|
282
|
|
- * + YLowest and yHighest indicate the lowest and
|
283
|
|
- * + Highest points in this room
|
284
|
|
- * (even though their actual values appear to
|
285
|
|
- * be reversed, since a "high" point will have a
|
286
|
|
- * smaller value than a "low" point).
|
|
267
|
+/*!
|
|
268
|
+ * \brief The "header" of a room.
|
|
269
|
+ *
|
|
270
|
+ * X/Z indicate the base position of the room mesh in world coordinates.
|
|
271
|
+ *
|
|
272
|
+ * yLowest and yHighest indicate the lowest and highest points in this room
|
|
273
|
+ * (even though their actual values appear to be reversed, since a "high"
|
|
274
|
+ * point will have a smaller value than a "low" point).
|
287
|
275
|
*
|
288
|
276
|
* When positioning objects/items, as well as the room meshes
|
289
|
277
|
* themselves, y is always 0-relative (not room-relative).
|
290
|
|
- --------------------------------------------------------------*/
|
291
|
|
-typedef struct tr2_room_info_s
|
292
|
|
-{
|
293
|
|
- int x; // X-offset of room (world coordinates)
|
294
|
|
- int z; // Z-offset of room (world coordinates)
|
295
|
|
- int y_bottom; // Y-offset of lowest point in room (world coordinates)
|
296
|
|
- // (actually highest value)
|
297
|
|
- int y_top; // Y-offset of highest point in room (world coordinates)
|
298
|
|
- // (actually lowest value)
|
299
|
|
-} __attribute__ ((packed)) tr2_room_info_t;
|
300
|
|
-
|
|
278
|
+ */
|
|
279
|
+typedef struct {
|
|
280
|
+ int x; //!< X-offset of room (world coordinates)
|
|
281
|
+ int z; //!< Z-offset of room (world coordinates)
|
|
282
|
+ int y_bottom; //!< Y-offset of lowest point in room (world coordinates, actually highest value)
|
|
283
|
+ int y_top; //!< Y-offset of highest point in room (world coordinates, actually lowest value)
|
|
284
|
+} __attribute__ ((packed)) tr2_room_info_t;
|
301
|
285
|
|
302
|
|
-/*--------------------------------------------------------------
|
303
|
|
- * Portal structure.
|
|
286
|
+/*!
|
|
287
|
+ * \brief Portal structure.
|
|
288
|
+ *
|
304
|
289
|
* This defines every viable exit from a given "room".
|
305
|
290
|
*
|
306
|
291
|
* Note that "rooms" are really just areas. They aren't
|
307
|
292
|
* necessarily enclosed. The door structure below defines
|
308
|
293
|
* areas of egress, not the actual moveable mesh,
|
309
|
294
|
* texture, and action (if any).
|
310
|
|
- --------------------------------------------------------------*/
|
311
|
|
-typedef struct tr2_room_portal_s
|
312
|
|
-{
|
313
|
|
- unsigned short adjoining_room; // Which room this "door" leads to
|
314
|
|
- tr2_vertex_t normal; // Which way the "door" faces
|
315
|
|
- tr2_vertex_t vertices[4]; // The corners of the "door"
|
316
|
|
-} __attribute__ ((packed)) tr2_room_portal_t;
|
317
|
|
-
|
|
295
|
+ */
|
|
296
|
+typedef struct {
|
|
297
|
+ unsigned short adjoining_room; //!< Which room this "door" leads to
|
|
298
|
+ tr2_vertex_t normal; //!< Which way the "door" faces
|
|
299
|
+ tr2_vertex_t vertices[4]; //!< The corners of the "door"
|
|
300
|
+} __attribute__ ((packed)) tr2_room_portal_t;
|
318
|
301
|
|
319
|
|
-/*--------------------------------------------------------------
|
320
|
|
- * Room sector structure.
|
|
302
|
+/*!
|
|
303
|
+ * \brief Room sector structure.
|
321
|
304
|
*
|
322
|
|
- * Sectors are 1024 * 1024 (world coordinates). Floor and
|
|
305
|
+ * Sectors are 1024 * 1024 (world coordinates). Floor and
|
323
|
306
|
* Ceiling are signed number of 256 units of height
|
324
|
307
|
* (relative to 0), e.g. Floor 0x04 corresponds to
|
325
|
308
|
* Y = 1024 in world coordinates.
|
326
|
309
|
*
|
327
|
310
|
* Note: this implies that, while X and Z can be quite large,
|
328
|
|
- * Y is constrained to -32768..32512. Floor/Ceiling value of
|
|
311
|
+ * Y is constrained to -32768..32512. Floor/Ceiling value of
|
329
|
312
|
* 0x81 indicates impenetrable wall.
|
330
|
313
|
*
|
331
|
314
|
* Floor values are used by the game engine to determine what
|
|
@@ -346,79 +329,70 @@ typedef struct tr2_room_portal_s
|
346
|
329
|
* ceiling is a collisional portal to that room, while if
|
347
|
330
|
* RoomBelow is not "none", then the floor is a collisional
|
348
|
331
|
* portal to that room.
|
349
|
|
- --------------------------------------------------------------*/
|
350
|
|
-typedef struct tr2_room_sector_s
|
351
|
|
-{
|
352
|
|
- unsigned short fd_index; // Index into FloorData[]
|
353
|
|
- unsigned short box_index; // Index into Boxes[]/Zones[] ( -1 if none )
|
354
|
|
- unsigned char room_below; // The number of the room below this one
|
355
|
|
- // ( -1 or 255 if none )
|
356
|
|
- char floor; // Absolute height of floor
|
357
|
|
- // ( Multiply by 256 for world coordinates )
|
358
|
|
- unsigned char room_above; // The number of the room above this one
|
359
|
|
- // ( -1 or 255 if none )
|
360
|
|
- char ceiling; // Absolute height of ceiling
|
361
|
|
- // ( Multiply by 256 for world coordinates )
|
362
|
|
-} __attribute__ ((packed)) tr2_room_sector_t;
|
363
|
|
-
|
|
332
|
+ */
|
|
333
|
+typedef struct {
|
|
334
|
+ unsigned short fd_index; //!< Index into FloorData[]
|
|
335
|
+ unsigned short box_index; //!< Index into Boxes[]/Zones[] (-1 if none)
|
|
336
|
+ unsigned char room_below; //!< The number of the room below this one (-1 or 255 if none)
|
|
337
|
+ char floor; //!< Absolute height of floor (Multiply by 256 for world coordinates)
|
|
338
|
+ unsigned char room_above; //!< The number of the room above this one (-1 or 255 if none)
|
|
339
|
+ char ceiling; //!< Absolute height of ceiling (multiply by 256 for world coordinates)
|
|
340
|
+} __attribute__ ((packed)) tr2_room_sector_t;
|
364
|
341
|
|
365
|
|
-/*--------------------------------------------------------------
|
366
|
|
- * Room lighting structure.
|
|
342
|
+/*!
|
|
343
|
+ * \brief Room lighting structure.
|
|
344
|
+ *
|
367
|
345
|
* X/Y/Z are in world coordinates.
|
|
346
|
+ *
|
368
|
347
|
* Lighting values seem to range from 0..8192.
|
369
|
|
- --------------------------------------------------------------*/
|
370
|
|
-typedef struct tr2_room_light_s
|
371
|
|
-{
|
372
|
|
- int x;
|
373
|
|
- int y;
|
374
|
|
- int z;
|
375
|
|
- unsigned short intensity1;
|
376
|
|
- unsigned short intensity2;
|
377
|
|
- unsigned int fade1;
|
378
|
|
- unsigned int fade2;
|
379
|
|
-} __attribute__ ((packed)) tr2_room_light_t;
|
380
|
|
-
|
381
|
|
-typedef struct tr4_room_light_s
|
382
|
|
-{
|
383
|
|
- int xPosition; // world coords
|
384
|
|
- int yPosition; // world coords
|
385
|
|
- int zPosition; // world coords
|
386
|
|
- tr2_colour_t color; // three bytes rgb values
|
387
|
|
- unsigned char lightType; // same as D3D (i.e. 2 is for spotlight)
|
388
|
|
- unsigned char unknown; // always 0xff?
|
389
|
|
- unsigned char intensity;
|
390
|
|
- float in;
|
|
348
|
+ */
|
|
349
|
+typedef struct {
|
|
350
|
+ int x;
|
|
351
|
+ int y;
|
|
352
|
+ int z;
|
|
353
|
+ unsigned short intensity1;
|
|
354
|
+ unsigned short intensity2;
|
|
355
|
+ unsigned int fade1;
|
|
356
|
+ unsigned int fade2;
|
|
357
|
+} __attribute__ ((packed)) tr2_room_light_t;
|
|
358
|
+
|
|
359
|
+typedef struct {
|
|
360
|
+ int xPosition; //!< World coords
|
|
361
|
+ int yPosition; //!< World coords
|
|
362
|
+ int zPosition; //!< World coords
|
|
363
|
+ tr2_colour_t color; //!< Three bytes rgb values
|
|
364
|
+ unsigned char lightType; //!< Same as D3D (i.e. 2 is for spotlight)
|
|
365
|
+ unsigned char unknown; //!< Always 0xff?
|
|
366
|
+ unsigned char intensity;
|
|
367
|
+ float in;
|
391
|
368
|
float out;
|
392
|
369
|
float length;
|
393
|
370
|
float cutoff;
|
394
|
|
- float xDir, yDir, zDir; // direction?
|
395
|
|
-
|
396
|
|
-} __attribute__ ((packed)) tr4_room_light_t;
|
397
|
|
-
|
|
371
|
+ float xDir, yDir, zDir; //!< Direction?
|
|
372
|
+} __attribute__ ((packed)) tr4_room_light_t;
|
398
|
373
|
|
399
|
|
-/*--------------------------------------------------------------
|
400
|
|
- * Room vertex structure.
|
|
374
|
+/*!
|
|
375
|
+ * \brief Room vertex structure.
|
|
376
|
+ *
|
401
|
377
|
* This defines the vertices within a room.
|
402
|
|
- --------------------------------------------------------------*/
|
403
|
|
-typedef struct tr2_vertex_room_s
|
404
|
|
-{
|
405
|
|
- tr2_vertex_t vertex;
|
406
|
|
- // Following 3 entries
|
407
|
|
- short lighting1; // Values range from 0 to 32767,
|
408
|
|
- // 0 = total darkness. (TR3)
|
409
|
|
- // I think the values ranged from
|
410
|
|
- // 0 to 8192 in TR1/2, 0=total brightness
|
411
|
|
-
|
412
|
|
- unsigned short attributes; // 0x8000 Something to do with water surface
|
413
|
|
- // 0x4000 Under water lighting modulation
|
414
|
|
- // and movement if viewed from
|
415
|
|
- // above water surface
|
416
|
|
- // 0x2000 Water/quicksand surface movement
|
417
|
|
- // 0x1fef Nothing?
|
418
|
|
- // 0x0010 Everything?
|
419
|
|
-
|
420
|
|
- short lighting2; // Seems to be the same as lighting1
|
421
|
|
-} __attribute__ ((packed)) tr2_vertex_room_t;
|
|
378
|
+ */
|
|
379
|
+typedef struct {
|
|
380
|
+ tr2_vertex_t vertex;
|
|
381
|
+ short lighting1; //!< Values range from 0 to 32767 in TR3, 0=dark.
|
|
382
|
+ /*!< I think the values ranged from 0 to 8192
|
|
383
|
+ * in TR1/2, 0=bright. */
|
|
384
|
+ unsigned short attributes; /*!<
|
|
385
|
+ * * 0x8000 Something to do with water surface
|
|
386
|
+ * * 0x4000 Under water lighting modulation
|
|
387
|
+ * and movement if viewed from
|
|
388
|
+ * above water surface
|
|
389
|
+ * * 0x2000 Water/quicksand surface movement
|
|
390
|
+ * * 0x1fef Nothing?
|
|
391
|
+ * * 0x0010 Everything?
|
|
392
|
+ */
|
|
393
|
+
|
|
394
|
+ short lighting2; //!< Seems to be the same as lighting1
|
|
395
|
+} __attribute__ ((packed)) tr2_vertex_room_t;
|
422
|
396
|
|
423
|
397
|
|
424
|
398
|
/*--------------------------------------------------------------
|