Browse Source

Commented level file format description [skip ci]

Thomas Buck 10 years ago
parent
commit
03e0fc9198
1 changed files with 84 additions and 0 deletions
  1. 84
    0
      utils/tombraider.bfft

+ 84
- 0
utils/tombraider.bfft View File

@@ -6,17 +6,36 @@
6 6
  * Developed for Binspector (https://github.com/binspector/binspector)
7 7
  */
8 8
 
9
+// ########## General data structures ##########
10
+
11
+// Rectangular faces
9 12
 struct face4_t {
13
+    // These are indices into the appropriate vertex list
10 14
     unsigned 16 little vertices[4];
15
+
16
+    /*
17
+     * Index into the object texture list (for textured objects)
18
+     * or into the 8 or 16bit palette (for colored object).
19
+     * When coloring is used, texture contains two indices:
20
+     *   (texture & 0x00FF) = index into 8bit palette
21
+     *   ((texture & 0xFF00) >> 8) = index into 16bit palette
22
+     */
11 23
     unsigned 16 little texture;
24
+
25
+    summary vertices[0], " - ", vertices[1], " - ", vertices[2], " - ", vertices[4];
12 26
 }
13 27
 
28
+// Triangular faces
14 29
 struct face3_t {
30
+    // See face4_t for a description of the elements
15 31
     unsigned 16 little vertices[3];
16 32
     unsigned 16 little texture;
33
+
34
+    summary vertices[0], " - ", vertices[1], " - ", vertices[2];
17 35
 }
18 36
 
19 37
 struct vertex_t {
38
+    // These coordinates are relative!
20 39
     signed 16 little x;
21 40
     signed 16 little y;
22 41
     signed 16 little z;
@@ -24,24 +43,62 @@ struct vertex_t {
24 43
     summary "X: ", x, " Y: ", y, " Z: ", z;
25 44
 }
26 45
 
46
+// ########## Room data structures ##########
47
+
27 48
 struct room_vertex_t {
49
+    /* 
50
+     * Position of this vertex, relative to the x/z coordinates
51
+     * of the room this vertex is a part of.
52
+     */
28 53
     vertex_t vertex;
54
+
55
+    /*
56
+     * Room lighting is internal vertex lighting, except for except
57
+     * for necessarily external sources like flares.
58
+     * Room ambient lights and point sources are ignored.
59
+     */
29 60
     signed 16 little lighting1;
30 61
 
62
+    // TR1 lacks these attributes
31 63
     if (TRversion > 1) {
64
+        /*
65
+         * A set of flags for special rendering effects:
66
+         *   0x8000 - Has something to do with water surfaces
67
+         *   0x4000 - Underwater lighting modulation and movement,
68
+         *            if viewed from above the water surface.
69
+         *   0x2000 - Water/Quicksand surface movement
70
+         *   0x0010 - Normal
71
+         */
32 72
         unsigned 16 little attributes;
73
+
74
+        // Almost always equal to lighting1
33 75
         signed 16 little lighting2;
34 76
     }
77
+
78
+    summary summaryof(vertex);
35 79
 }
36 80
 
37 81
 struct room_sprite_t {
82
+    // Index into the vertex list of the current room
38 83
     signed 16 little vertex;
84
+
85
+    // Index into the sprite texture list
39 86
     signed 16 little texture;
87
+
88
+    summary vertex, "-", texture;
40 89
 }
41 90
 
42 91
 struct room_door_t {
92
+    // Which room this portal leads to
43 93
     unsigned 16 little adjoiningRoom;
94
+
95
+    /*
96
+     * Which way the portal faces (points away from adjacent room,
97
+     * to be seen though it must point toward the viewpoint)
98
+     */
44 99
     vertex_t normal;
100
+
101
+    // The corners of this portal (right-hand rule applies wrt normal)
45 102
     vertex_t vertices[4];
46 103
 
47 104
     summary "To: ", adjoiningRoom;
@@ -141,6 +198,8 @@ struct room_t {
141 198
     summary "X: ", x, " Ybot: ", yBottom, " Ytop: ", yTop, " Z: ", z;
142 199
 }
143 200
 
201
+// ########## Actor data structures ##########
202
+
144 203
 struct animation_t {
145 204
     unsigned 32 little frameOffset;
146 205
     unsigned 8 little frameRate;
@@ -187,6 +246,8 @@ struct moveable_t {
187 246
     summary "ID: ", objectID, " Anim: ", animation;
188 247
 }
189 248
 
249
+// ########## Other data structures ##########
250
+
190 251
 struct static_mesh_t {
191 252
     unsigned 32 little objectID;
192 253
     unsigned 16 little mesh;
@@ -257,17 +318,29 @@ struct sound_source_t {
257 318
 
258 319
 struct box_t {
259 320
     if (TRversion > 1) {
321
+        /*
322
+         * In TR2 & TR3, these values are based on sectors,
323
+         * so they need to be scaled (* 1024 units)
324
+         */
260 325
         unsigned 8 little zMin;
261 326
         unsigned 8 little zMax;
262 327
         unsigned 8 little xMin;
263 328
         unsigned 8 little xMax;
264 329
     } else {
330
+        // In TR1 there is no scaling
265 331
         signed 32 little zMin;
266 332
         signed 32 little zMax;
267 333
         signed 32 little xMin;
268 334
         signed 32 little xMax;
269 335
     }
336
+
337
+    // Y value (no scaling)
270 338
     signed 16 little trueFloor;
339
+
340
+    /*
341
+     * Index into overlaps. The high bit is sometimes set,
342
+     * this occurs in front of swinging doors and the like
343
+     */
271 344
     signed 16 little overlapIndex;
272 345
 
273 346
     summary "X: ", xMin, "-", xMax, " Z: ", zMin, "-", zMax;
@@ -310,6 +383,8 @@ struct sound_details_t {
310 383
     summary sample, " - ", volume;
311 384
 }
312 385
 
386
+// ########## Main file layout ##########
387
+
313 388
 struct main {
314 389
     unsigned 32 little version;
315 390
 
@@ -328,12 +403,15 @@ struct main {
328 403
         die "Unknown version number found!";
329 404
     }
330 405
 
406
+    // TR2 & TR3 have their 8 & 16bit palettes here
331 407
     if (TRversion > 1)
332 408
         skip palettes[256 * 7];
333 409
 
410
+    // 8bit textures
334 411
     unsigned 32 little numTextiles;
335 412
     skip textiles[256 * 256 * numTextiles];
336 413
 
414
+    // TR1 does not have any 16bit textures
337 415
     if (TRversion > 1)
338 416
         skip textiles16[256 * 256 * numTextiles * 2];
339 417
 
@@ -374,6 +452,7 @@ struct main {
374 452
     unsigned 32 little numStaticMeshes;
375 453
     static_mesh_t staticMeshes[numStaticMeshes];
376 454
 
455
+    // TR1 & TR2 have their object textures placed here
377 456
     if (TRversion < 3) {
378 457
         unsigned 32 little numObjectTextures;
379 458
         object_texture_t objectTextures[numObjectTextures];
@@ -397,6 +476,7 @@ struct main {
397 476
     unsigned 32 little numOverlaps;
398 477
     skip overlaps[numOverlaps * 2];
399 478
 
479
+    // TR1 has 6 bytes per zone entry, TR2 & TR3 have 10
400 480
     if (TRversion > 1)
401 481
         skip zones[numBoxes * 10 * 2];
402 482
     else
@@ -405,6 +485,7 @@ struct main {
405 485
     unsigned 32 little numAnimatedTextures;
406 486
     skip animatedTextures[numAnimatedTextures * 2];
407 487
 
488
+    // TR3 has its object textures placed here
408 489
     if (TRversion == 3) {
409 490
         unsigned 32 little numObjectTextures;
410 491
         object_texture_t objectTextures[numObjectTextures];
@@ -415,6 +496,7 @@ struct main {
415 496
 
416 497
     skip lightMap[32 * 256];
417 498
 
499
+    // TR1 places its 8bit palette here
418 500
     if (TRversion == 1)
419 501
         skip palette[256 * 3];
420 502
 
@@ -424,6 +506,7 @@ struct main {
424 506
     unsigned 16 little numDemoData;
425 507
     skip demoData[numDemoData];
426 508
 
509
+    // TR1s sound map has 256 entries, TR2 & TR3 have 370
427 510
     if (TRversion > 1)
428 511
         skip soundMap[370 * 2];
429 512
     else
@@ -432,6 +515,7 @@ struct main {
432 515
     unsigned 32 little numSoundDetails;
433 516
     sound_details_t soundDetails[numSoundDetails];
434 517
 
518
+    // TR1 has the sample data embedded here (WAV files)
435 519
     if (TRversion == 1) {
436 520
         unsigned 32 little numSamples;
437 521
         skip samples[numSamples];

Loading…
Cancel
Save