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
  * Developed for Binspector (https://github.com/binspector/binspector)
6
  * Developed for Binspector (https://github.com/binspector/binspector)
7
  */
7
  */
8
 
8
 
9
+// ########## General data structures ##########
10
+
11
+// Rectangular faces
9
 struct face4_t {
12
 struct face4_t {
13
+    // These are indices into the appropriate vertex list
10
     unsigned 16 little vertices[4];
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
     unsigned 16 little texture;
23
     unsigned 16 little texture;
24
+
25
+    summary vertices[0], " - ", vertices[1], " - ", vertices[2], " - ", vertices[4];
12
 }
26
 }
13
 
27
 
28
+// Triangular faces
14
 struct face3_t {
29
 struct face3_t {
30
+    // See face4_t for a description of the elements
15
     unsigned 16 little vertices[3];
31
     unsigned 16 little vertices[3];
16
     unsigned 16 little texture;
32
     unsigned 16 little texture;
33
+
34
+    summary vertices[0], " - ", vertices[1], " - ", vertices[2];
17
 }
35
 }
18
 
36
 
19
 struct vertex_t {
37
 struct vertex_t {
38
+    // These coordinates are relative!
20
     signed 16 little x;
39
     signed 16 little x;
21
     signed 16 little y;
40
     signed 16 little y;
22
     signed 16 little z;
41
     signed 16 little z;
24
     summary "X: ", x, " Y: ", y, " Z: ", z;
43
     summary "X: ", x, " Y: ", y, " Z: ", z;
25
 }
44
 }
26
 
45
 
46
+// ########## Room data structures ##########
47
+
27
 struct room_vertex_t {
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
     vertex_t vertex;
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
     signed 16 little lighting1;
60
     signed 16 little lighting1;
30
 
61
 
62
+    // TR1 lacks these attributes
31
     if (TRversion > 1) {
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
         unsigned 16 little attributes;
72
         unsigned 16 little attributes;
73
+
74
+        // Almost always equal to lighting1
33
         signed 16 little lighting2;
75
         signed 16 little lighting2;
34
     }
76
     }
77
+
78
+    summary summaryof(vertex);
35
 }
79
 }
36
 
80
 
37
 struct room_sprite_t {
81
 struct room_sprite_t {
82
+    // Index into the vertex list of the current room
38
     signed 16 little vertex;
83
     signed 16 little vertex;
84
+
85
+    // Index into the sprite texture list
39
     signed 16 little texture;
86
     signed 16 little texture;
87
+
88
+    summary vertex, "-", texture;
40
 }
89
 }
41
 
90
 
42
 struct room_door_t {
91
 struct room_door_t {
92
+    // Which room this portal leads to
43
     unsigned 16 little adjoiningRoom;
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
     vertex_t normal;
99
     vertex_t normal;
100
+
101
+    // The corners of this portal (right-hand rule applies wrt normal)
45
     vertex_t vertices[4];
102
     vertex_t vertices[4];
46
 
103
 
47
     summary "To: ", adjoiningRoom;
104
     summary "To: ", adjoiningRoom;
141
     summary "X: ", x, " Ybot: ", yBottom, " Ytop: ", yTop, " Z: ", z;
198
     summary "X: ", x, " Ybot: ", yBottom, " Ytop: ", yTop, " Z: ", z;
142
 }
199
 }
143
 
200
 
201
+// ########## Actor data structures ##########
202
+
144
 struct animation_t {
203
 struct animation_t {
145
     unsigned 32 little frameOffset;
204
     unsigned 32 little frameOffset;
146
     unsigned 8 little frameRate;
205
     unsigned 8 little frameRate;
187
     summary "ID: ", objectID, " Anim: ", animation;
246
     summary "ID: ", objectID, " Anim: ", animation;
188
 }
247
 }
189
 
248
 
249
+// ########## Other data structures ##########
250
+
190
 struct static_mesh_t {
251
 struct static_mesh_t {
191
     unsigned 32 little objectID;
252
     unsigned 32 little objectID;
192
     unsigned 16 little mesh;
253
     unsigned 16 little mesh;
257
 
318
 
258
 struct box_t {
319
 struct box_t {
259
     if (TRversion > 1) {
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
         unsigned 8 little zMin;
325
         unsigned 8 little zMin;
261
         unsigned 8 little zMax;
326
         unsigned 8 little zMax;
262
         unsigned 8 little xMin;
327
         unsigned 8 little xMin;
263
         unsigned 8 little xMax;
328
         unsigned 8 little xMax;
264
     } else {
329
     } else {
330
+        // In TR1 there is no scaling
265
         signed 32 little zMin;
331
         signed 32 little zMin;
266
         signed 32 little zMax;
332
         signed 32 little zMax;
267
         signed 32 little xMin;
333
         signed 32 little xMin;
268
         signed 32 little xMax;
334
         signed 32 little xMax;
269
     }
335
     }
336
+
337
+    // Y value (no scaling)
270
     signed 16 little trueFloor;
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
     signed 16 little overlapIndex;
344
     signed 16 little overlapIndex;
272
 
345
 
273
     summary "X: ", xMin, "-", xMax, " Z: ", zMin, "-", zMax;
346
     summary "X: ", xMin, "-", xMax, " Z: ", zMin, "-", zMax;
310
     summary sample, " - ", volume;
383
     summary sample, " - ", volume;
311
 }
384
 }
312
 
385
 
386
+// ########## Main file layout ##########
387
+
313
 struct main {
388
 struct main {
314
     unsigned 32 little version;
389
     unsigned 32 little version;
315
 
390
 
328
         die "Unknown version number found!";
403
         die "Unknown version number found!";
329
     }
404
     }
330
 
405
 
406
+    // TR2 & TR3 have their 8 & 16bit palettes here
331
     if (TRversion > 1)
407
     if (TRversion > 1)
332
         skip palettes[256 * 7];
408
         skip palettes[256 * 7];
333
 
409
 
410
+    // 8bit textures
334
     unsigned 32 little numTextiles;
411
     unsigned 32 little numTextiles;
335
     skip textiles[256 * 256 * numTextiles];
412
     skip textiles[256 * 256 * numTextiles];
336
 
413
 
414
+    // TR1 does not have any 16bit textures
337
     if (TRversion > 1)
415
     if (TRversion > 1)
338
         skip textiles16[256 * 256 * numTextiles * 2];
416
         skip textiles16[256 * 256 * numTextiles * 2];
339
 
417
 
374
     unsigned 32 little numStaticMeshes;
452
     unsigned 32 little numStaticMeshes;
375
     static_mesh_t staticMeshes[numStaticMeshes];
453
     static_mesh_t staticMeshes[numStaticMeshes];
376
 
454
 
455
+    // TR1 & TR2 have their object textures placed here
377
     if (TRversion < 3) {
456
     if (TRversion < 3) {
378
         unsigned 32 little numObjectTextures;
457
         unsigned 32 little numObjectTextures;
379
         object_texture_t objectTextures[numObjectTextures];
458
         object_texture_t objectTextures[numObjectTextures];
397
     unsigned 32 little numOverlaps;
476
     unsigned 32 little numOverlaps;
398
     skip overlaps[numOverlaps * 2];
477
     skip overlaps[numOverlaps * 2];
399
 
478
 
479
+    // TR1 has 6 bytes per zone entry, TR2 & TR3 have 10
400
     if (TRversion > 1)
480
     if (TRversion > 1)
401
         skip zones[numBoxes * 10 * 2];
481
         skip zones[numBoxes * 10 * 2];
402
     else
482
     else
405
     unsigned 32 little numAnimatedTextures;
485
     unsigned 32 little numAnimatedTextures;
406
     skip animatedTextures[numAnimatedTextures * 2];
486
     skip animatedTextures[numAnimatedTextures * 2];
407
 
487
 
488
+    // TR3 has its object textures placed here
408
     if (TRversion == 3) {
489
     if (TRversion == 3) {
409
         unsigned 32 little numObjectTextures;
490
         unsigned 32 little numObjectTextures;
410
         object_texture_t objectTextures[numObjectTextures];
491
         object_texture_t objectTextures[numObjectTextures];
415
 
496
 
416
     skip lightMap[32 * 256];
497
     skip lightMap[32 * 256];
417
 
498
 
499
+    // TR1 places its 8bit palette here
418
     if (TRversion == 1)
500
     if (TRversion == 1)
419
         skip palette[256 * 3];
501
         skip palette[256 * 3];
420
 
502
 
424
     unsigned 16 little numDemoData;
506
     unsigned 16 little numDemoData;
425
     skip demoData[numDemoData];
507
     skip demoData[numDemoData];
426
 
508
 
509
+    // TR1s sound map has 256 entries, TR2 & TR3 have 370
427
     if (TRversion > 1)
510
     if (TRversion > 1)
428
         skip soundMap[370 * 2];
511
         skip soundMap[370 * 2];
429
     else
512
     else
432
     unsigned 32 little numSoundDetails;
515
     unsigned 32 little numSoundDetails;
433
     sound_details_t soundDetails[numSoundDetails];
516
     sound_details_t soundDetails[numSoundDetails];
434
 
517
 
518
+    // TR1 has the sample data embedded here (WAV files)
435
     if (TRversion == 1) {
519
     if (TRversion == 1) {
436
         unsigned 32 little numSamples;
520
         unsigned 32 little numSamples;
437
         skip samples[numSamples];
521
         skip samples[numSamples];

Loading…
Cancel
Save