Преглед на файлове

Added TR binary file format template [skip ci]

Thomas Buck преди 10 години
родител
ревизия
7934d3d35f
променени са 2 файла, в които са добавени 445 реда и са изтрити 0 реда
  1. 2
    0
      ChangeLog.md
  2. 443
    0
      utils/tombraider.bfft

+ 2
- 0
ChangeLog.md Целия файл

@@ -4,6 +4,8 @@
4 4
 
5 5
     [ 20141016 ]
6 6
     * ImGuis Font can now be used if no other is available
7
+    * Added [Binspector](https://github.com/binspector/binspector) binary file format template
8
+      that can be used to parse and analyze TR1-TR3 level files.
7 9
 
8 10
     [ 20141015 ]
9 11
     * Added rudimentary command history support for Console

+ 443
- 0
utils/tombraider.bfft Целия файл

@@ -0,0 +1,443 @@
1
+/*
2
+ * tombraider.bfft - Tomb Raider 1 - 3 Level File Format Description
3
+ * 2014, Thomas Buck <xythobuz@xythobuz.de>
4
+ *
5
+ * Based on the TR Rosetta Stone (http://www.tnlc.com/eep/tr/TRosettaStone.html)
6
+ * Developed for Binspector (https://github.com/binspector/binspector)
7
+ */
8
+
9
+struct face4_t {
10
+    unsigned 16 little vertices[4];
11
+    unsigned 16 little texture;
12
+}
13
+
14
+struct face3_t {
15
+    unsigned 16 little vertices[3];
16
+    unsigned 16 little texture;
17
+}
18
+
19
+struct vertex_t {
20
+    signed 16 little x;
21
+    signed 16 little y;
22
+    signed 16 little z;
23
+
24
+    summary "X: ", x, " Y: ", y, " Z: ", z;
25
+}
26
+
27
+struct room_vertex_t {
28
+    vertex_t vertex;
29
+    signed 16 little lighting1;
30
+
31
+    if (TRversion > 1) {
32
+        unsigned 16 little attributes;
33
+        signed 16 little lighting2;
34
+    }
35
+}
36
+
37
+struct room_sprite_t {
38
+    signed 16 little vertex;
39
+    signed 16 little texture;
40
+}
41
+
42
+struct room_door_t {
43
+    unsigned 16 little adjoiningRoom;
44
+    vertex_t normal;
45
+    vertex_t vertices[4];
46
+
47
+    summary "To: ", adjoiningRoom;
48
+}
49
+
50
+struct room_sector_t {
51
+    unsigned 16 little floorDataIndex;
52
+    unsigned 16 little boxIndex;
53
+    unsigned 8 little roomBelow;
54
+    signed 8 little floor;
55
+    unsigned 8 little roomAbove;
56
+    signed 8 little ceiling;
57
+
58
+    summary "Be.: ", roomBelow, " Ab.: ", roomAbove;
59
+}
60
+
61
+struct room_light_t {
62
+    signed 32 little x;
63
+    signed 32 little y;
64
+    signed 32 little z;
65
+    unsigned 16 little intensity1;
66
+
67
+    if (TRversion > 1)
68
+        unsigned 16 little intensity2;
69
+
70
+    unsigned 32 little fade1;
71
+
72
+    if (TRversion > 1)
73
+        unsigned 32 little fade2;
74
+
75
+    summary "X: ", x, " Y: ", y, " Z: ", z;
76
+}
77
+
78
+struct room_mesh_t {
79
+    unsigned 32 little x;
80
+    unsigned 32 little y;
81
+    unsigned 32 little z;
82
+    unsigned 16 little rotation;
83
+    unsigned 16 little intensity1;
84
+    
85
+    if (TRversion > 1)
86
+        unsigned 16 little intensity2;
87
+
88
+    unsigned 16 little objectID;
89
+
90
+    summary "ID: ", objectID, " X: ", x, " Y: ", y, " Z: ", z;
91
+}
92
+
93
+struct room_t {
94
+    // Room Header
95
+    signed 32 little x;
96
+    signed 32 little z;
97
+    signed 32 little yBottom;
98
+    signed 32 little yTop;
99
+
100
+    unsigned 32 little numDataToFollow;
101
+
102
+    unsigned 16 little numVertices;
103
+    room_vertex_t vertices[numVertices];
104
+
105
+    unsigned 16 little numRectangles;
106
+    face4_t rectangles[numRectangles];
107
+
108
+    unsigned 16 little numTriangles;
109
+    face3_t triangles[numTriangles];
110
+
111
+    unsigned 16 little numSprites;
112
+    room_sprite_t sprites[numSprites];
113
+
114
+    unsigned 16 little numDoors;
115
+    room_door_t doors[numDoors];
116
+
117
+    unsigned 16 little numZSector;
118
+    unsigned 16 little numXSector;
119
+    room_sector_t sectorData[numZSector * numXSector];
120
+
121
+    signed 16 little intensity1;
122
+
123
+    if (TRversion > 1)
124
+        signed 16 little intensity2;
125
+
126
+    if (TRversion == 2)
127
+        signed 16 little lightMode;
128
+
129
+    unsigned 16 little numLights;
130
+    room_light_t lights[numLights];
131
+
132
+    unsigned 16 little numStaticMeshes;
133
+    room_mesh_t staticMeshes[numStaticMeshes];
134
+
135
+    signed 16 little alternateRoom;
136
+    unsigned 16 little flags;
137
+
138
+    if (TRversion == 3)
139
+        unsigned 24 little roomLightColor;
140
+
141
+    summary "X: ", x, " Ybot: ", yBottom, " Ytop: ", yTop, " Z: ", z;
142
+}
143
+
144
+struct animation_t {
145
+    unsigned 32 little frameOffset;
146
+    unsigned 8 little frameRate;
147
+    unsigned 8 little frameSize;
148
+    unsigned 16 little stateID;
149
+    skip unknown[8];
150
+    unsigned 16 little frameStart;
151
+    unsigned 16 little frameEnd;
152
+    unsigned 16 little nextAnimation;
153
+    unsigned 16 little nextFrame;
154
+    unsigned 16 little numStateChanges;
155
+    unsigned 16 little stateChangeOffset;
156
+    unsigned 16 little numAnimCommands;
157
+    unsigned 16 little animCommandOffset;
158
+
159
+    summary "State: ", stateID, " To: ", nextAnimation, "-", nextFrame;
160
+}
161
+
162
+struct state_change_t {
163
+    unsigned 16 little stateID;
164
+    unsigned 16 little numAnimDispatches;
165
+    unsigned 16 little animDispatchOffset;
166
+
167
+    summary "State: ", stateID;
168
+}
169
+
170
+struct anim_dispatch_t {
171
+    signed 16 little low;
172
+    signed 16 little high;
173
+    signed 16 little nextAnimation;
174
+    signed 16 little nextFrame;
175
+
176
+    summary low, "-", high, " To: ", nextAnimation, "-", nextFrame;
177
+}
178
+
179
+struct moveable_t {
180
+    unsigned 32 little objectID;
181
+    unsigned 16 little numMeshes;
182
+    unsigned 16 little startingMesh;
183
+    unsigned 32 little meshTree;
184
+    unsigned 32 little frameOffset;
185
+    unsigned 16 little animation;
186
+
187
+    summary "ID: ", objectID, " Anim: ", animation;
188
+}
189
+
190
+struct static_mesh_t {
191
+    unsigned 32 little objectID;
192
+    unsigned 16 little mesh;
193
+    vertex_t boundingBox[4];
194
+    unsigned 16 little flags;
195
+
196
+    summary "ID: ", objectID;
197
+}
198
+
199
+struct object_texture_vert_t {
200
+    unsigned 8 little xCoordinate;
201
+    unsigned 8 little xPixel;
202
+    unsigned 8 little yCoordinate;
203
+    unsigned 8 little yPixel;
204
+
205
+    summary xCoordinate, "-", yCoordinate, ", ", xPixel, "-", yPixel;
206
+}
207
+
208
+struct object_texture_t {
209
+    unsigned 16 little attribute;
210
+    unsigned 16 little tile;
211
+    object_texture_vert_t vertices[4];
212
+
213
+    summary "Tile: ", tile;
214
+}
215
+
216
+struct sprite_texture_t {
217
+    unsigned 16 little tile;
218
+    unsigned 8 little x;
219
+    unsigned 8 little y;
220
+    unsigned 16 little width;
221
+    unsigned 16 little height;
222
+    signed 16 little leftSide;
223
+    signed 16 little topSide;
224
+    signed 16 little rightSide;
225
+    signed 16 little bottomSide;
226
+
227
+    summary x, "-", y, ", ", width, "-", height;
228
+}
229
+
230
+struct sprite_sequence_t {
231
+    signed 32 little objectID;
232
+    signed 16 little negativeLength;
233
+    signed 16 little offset;
234
+
235
+    summary "ID: ", objectID;
236
+}
237
+
238
+struct camera_t {
239
+    signed 32 little x;
240
+    signed 32 little y;
241
+    signed 32 little z;
242
+    signed 16 little room;
243
+    unsigned 16 little unknown;
244
+
245
+    summary "X: ", x, " Y: ", y, " Z: ", z;
246
+}
247
+
248
+struct sound_source_t {
249
+    signed 32 little x;
250
+    signed 32 little y;
251
+    signed 32 little z;
252
+    unsigned 16 little soundID;
253
+    unsigned 16 little flags;
254
+
255
+    summary "X: ", x, " Y: ", y, " Z: ", z;
256
+}
257
+
258
+struct box_t {
259
+    if (TRversion > 1) {
260
+        unsigned 8 little zMin;
261
+        unsigned 8 little zMax;
262
+        unsigned 8 little xMin;
263
+        unsigned 8 little xMax;
264
+    } else {
265
+        signed 32 little zMin;
266
+        signed 32 little zMax;
267
+        signed 32 little xMin;
268
+        signed 32 little xMax;
269
+    }
270
+    signed 16 little trueFloor;
271
+    signed 16 little overlapIndex;
272
+
273
+    summary "X: ", xMin, "-", xMax, " Z: ", zMin, "-", zMax;
274
+}
275
+
276
+struct item_t {
277
+    signed 16 little objectID;
278
+    signed 16 little room;
279
+    signed 32 little x;
280
+    signed 32 little y;
281
+    signed 32 little z;
282
+    signed 16 little angle;
283
+    signed 16 little intensity1;
284
+
285
+    if (TRversion > 1)
286
+        signed 16 little intensity2;
287
+
288
+    unsigned 16 little flags;
289
+
290
+    summary "ID: ", objectID, " X: ", x, " Y: ", y, " Z: ", z;
291
+}
292
+
293
+struct cinematic_frame_t {
294
+    signed 16 little rotY;
295
+    signed 16 little rotZ;
296
+    signed 16 little rotZ2;
297
+    signed 16 little posZ;
298
+    signed 16 little posY;
299
+    signed 16 little posX;
300
+    signed 16 little unknown;
301
+    signed 16 little rotX;
302
+}
303
+
304
+struct sound_details_t {
305
+    signed 16 little sample;
306
+    signed 16 little volume;
307
+    signed 16 little unknown1;
308
+    signed 16 little unknown2;
309
+
310
+    summary sample, " - ", volume;
311
+}
312
+
313
+struct main {
314
+    unsigned 32 little version;
315
+
316
+    if (version == 0x20) {
317
+        notify "Tomb Raider 1 file detected...";
318
+        const TRversion = 1;
319
+    } else if (version == 0x2D) {
320
+        notify "Tomb Raider 2 file detected...";
321
+        const TRversion = 2;
322
+    } else if ((version == 0xFF080038) || (version == 0xFF180038)) {
323
+        notify "Tomb Raider 3 file detected...";
324
+        const TRversion = 3;
325
+    } else if ((version == 0xFFFFFFF0) || (version == 0x00345254)) {
326
+        die "Tomb Raider 4 file detected but not supported!";
327
+    } else {
328
+        die "Unknown version number found!";
329
+    }
330
+
331
+    if (TRversion > 1)
332
+        skip palettes[256 * 7];
333
+
334
+    unsigned 32 little numTextiles;
335
+    skip textiles[256 * 256 * numTextiles];
336
+
337
+    if (TRversion > 1)
338
+        skip textiles16[256 * 256 * numTextiles * 2];
339
+
340
+    unsigned 32 little unused;
341
+
342
+    unsigned 16 little numRooms;
343
+    room_t rooms[numRooms];
344
+
345
+    unsigned 32 little numFloorData;
346
+    skip floorData[numFloorData * 2];
347
+
348
+    unsigned 32 little numMeshData;
349
+    skip meshData[numMeshData * 2];
350
+    unsigned 32 little numMeshPointers;
351
+    unsigned 32 little meshPointers[numMeshPointers];
352
+
353
+    unsigned 32 little numAnimations;
354
+    animation_t animations[numAnimations];
355
+
356
+    unsigned 32 little numStateChanges;
357
+    state_change_t stateChanges[numStateChanges];
358
+
359
+    unsigned 32 little numAnimDispatches;
360
+    anim_dispatch_t animDispatches[numAnimDispatches];
361
+
362
+    unsigned 32 little numAnimCommands;
363
+    signed 16 little animCommands[numAnimCommands];
364
+
365
+    unsigned 32 little numMeshTrees;
366
+    signed 32 little meshTrees[numMeshTrees];
367
+
368
+    unsigned 32 little numFrames;
369
+    skip frames[numFrames * 2];
370
+
371
+    unsigned 32 little numMoveables;
372
+    moveable_t moveables[numMoveables];
373
+
374
+    unsigned 32 little numStaticMeshes;
375
+    static_mesh_t staticMeshes[numStaticMeshes];
376
+
377
+    if (TRversion < 3) {
378
+        unsigned 32 little numObjectTextures;
379
+        object_texture_t objectTextures[numObjectTextures];
380
+    }
381
+
382
+    unsigned 32 little numSpriteTextures;
383
+    sprite_texture_t spriteTextures[numSpriteTextures];
384
+
385
+    unsigned 32 little numSpriteSequences;
386
+    sprite_sequence_t spriteSequences[numSpriteSequences];
387
+
388
+    unsigned 32 little numCameras;
389
+    camera_t cameras[numCameras];
390
+
391
+    unsigned 32 little numSoundSources;
392
+    sound_source_t soundSources[numSoundSources];
393
+
394
+    unsigned 32 little numBoxes;
395
+    box_t boxes[numBoxes];
396
+
397
+    unsigned 32 little numOverlaps;
398
+    skip overlaps[numOverlaps * 2];
399
+
400
+    if (TRversion > 1)
401
+        skip zones[numBoxes * 10 * 2];
402
+    else
403
+        skip zones[numBoxes * 6 * 2];
404
+
405
+    unsigned 32 little numAnimatedTextures;
406
+    skip animatedTextures[numAnimatedTextures * 2];
407
+
408
+    if (TRversion == 3) {
409
+        unsigned 32 little numObjectTextures;
410
+        object_texture_t objectTextures[numObjectTextures];
411
+    }
412
+
413
+    unsigned 32 little numItems;
414
+    item_t items[numItems];
415
+
416
+    skip lightMap[32 * 256];
417
+
418
+    if (TRversion == 1)
419
+        skip palette[256 * 3];
420
+
421
+    unsigned 16 little numCinematicFrames;
422
+    cinematic_frame_t cinematicFrames[numCinematicFrames];
423
+
424
+    unsigned 16 little numDemoData;
425
+    skip demoData[numDemoData];
426
+
427
+    if (TRversion > 1)
428
+        skip soundMap[370 * 2];
429
+    else
430
+        skip soundMap[256 * 2];
431
+
432
+    unsigned 32 little numSoundDetails;
433
+    sound_details_t soundDetails[numSoundDetails];
434
+
435
+    if (TRversion == 1) {
436
+        unsigned 32 little numSamples;
437
+        skip samples[numSamples];
438
+    }
439
+
440
+    unsigned 32 little numSampleIndices;
441
+    skip sampleIndices[numSampleIndices * 4];
442
+}
443
+

Loading…
Отказ
Запис