This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
BHF3.bt
85 lines (69 loc) · 2.38 KB
/
BHF3.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//------------------------------------------------
//--- 010 Editor v9.0.2 Binary Template
//
// File: BHF3.bt
// Authors: TKGP
// Version:
// Purpose: Header file for split file archives before DS2
// Category: Dantelion
// File Mask: *.*bhd
// ID Bytes: 42 48 46 33
// History:
//------------------------------------------------
#include "Util.bt"
//------------------------------------------------
typedef struct {
char magic[4]; Assert(magic == "BHF3");
char version[8];
ubyte rawFormat <format=hex>;
byte bigEndian; Assert(bigEndian == 0 || bigEndian == 1);
byte unk0E; Assert(unk0E == 0 || unk0E == 1);
byte unk0F <hidden=true>; Assert(unk0F == 0);
local ubyte format <format=binary> = bigEndian ? rawFormat : ReverseBits(rawFormat);
if (bigEndian || (format & 0b00000001))
BigEndian();
else
LittleEndian();
int fileCount;
int unk14 <hidden=true>; Assert(unk14 == 0);
int unk18 <hidden=true>; Assert(unk18 == 0);
int unk1C <hidden=true>; Assert(unk1C == 0);
} Header <bgcolor=cLtRed>;
typedef struct {
ubyte rawFlags <format=hex>;
byte unk01 <hidden=true>; Assert(unk01 == 0);
byte unk02 <hidden=true>; Assert(unk02 == 0);
byte unk03 <hidden=true>; Assert(unk03 == 0);
local ubyte flags <format=binary> = header.bigEndian ? rawFlags : ReverseBits(rawFlags);
int compressedSize <format=hex>;
uint dataOffset <format=hex>;
if (header.format & 0b00000010)
int id;
if (header.format & 0b00000100)
int nameOffset;
if (header.format & 0b00100000)
int uncompressedSize <format=hex>;
if (exists(nameOffset)) {
local quad pos <hidden=true> = FTell();
FSeek(nameOffset);
string name <bgcolor=cGreen>;
FSeek(pos);
}
} File <read=ReadFile, bgcolor=cLtGreen, optimize=false>;
string ReadFile(File& file) {
string str;
if (exists(file.id) && exists(file.name))
SPrintf(str, "@%8Xh %10i %s", file.dataOffset, file.id, file.name);
else if (exists(file.id))
SPrintf(str, "%10i", file.id);
else if (exists(file.name))
SPrintf(str, "%s", file.name);
else
SPrintf(str, "@%8Xh", file.dataOffset);
return str;
}
//------------------------------------------------
Header header;
if (header.fileCount > 0) {
struct { File files[header.fileCount]; } files <open=true>;
}