-
Notifications
You must be signed in to change notification settings - Fork 5
/
gtchunk.bt
50 lines (45 loc) · 1.62 KB
/
gtchunk.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//------------------------------------------------
//--- 010 Editor Binary Template
//
// File: .gtchunk
// Authors: freakbyte, FallenAvatar, Arkii, Xsear
// Category: Firefall
// File Mask: *.gtchunk
// ID Bytes: ED 12 5B ED 12 5A ED 12 00 00 04 00
//------------------------------------------------
#include "_common_types.bt"
#include "_common_gtlayer.bt"
struct COMPRESSED_DATA(uint length) {
char magic[4];
byte data[length-4];
};
string CompressedHeaderDisplay(COMPRESSED_DATA &data)
{
if (data.magic == "DATA") {
return "DATA / Zlib/Deflate";
}
else if (data.magic == "DAT2") {
return "DAT2 / LZMA";
}
else {
return "UNKNOWN";
}
}
struct FILE {
// Root layer / Index
Layer root(NO_PARENT)<comment="index">;
// Compressed data
local int lod<hidden=true>;
local int subchunk<hidden=true>;
local uint baseOffset<hidden=true> = FTell();
for (lod = 0; lod < root.data.numLods; lod++) {
struct DATA {
FSeek(baseOffset + root.child[lod].data.dataOffset);
COMPRESSED_DATA data(root.child[lod].data.compressedSize)<read=CompressedHeaderDisplay, comment="LOD Shared Data">;
for(subchunk = 0; subchunk < (1 << 2 * root.child[lod].data.numSubChunks); subchunk++) {
FSeek(baseOffset + root.child[lod].child[subchunk].data.dataOffset);
COMPRESSED_DATA data(root.child[lod].child[subchunk].data.compressedSize)<read=CompressedHeaderDisplay, comment="SubChunk Data">;
};
} lod_data<comment="Compressed data for each LOD, referenced by index">;
};
} gtchunk;