-
Notifications
You must be signed in to change notification settings - Fork 5
/
NierA_PAK.bt
55 lines (47 loc) · 1.33 KB
/
NierA_PAK.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
/*
Container for HAP/XML scripts. HAP scripts control most of the quests.
*/
// everything is 4 byte aligned
LittleEndian();
typedef int bool;
struct HeaderEntry
{
uint32 type;
uint32 uncompressedSizeMaybe;
uint32 offset;
};
struct File(uint32 size, uint32 uncompressedSize, bool isCompressed)
{
uint32 unknown;
if (isCompressed) {
ubyte data[unknown];
local uint32 paddingEndSize = size - unknown - 4;
if (paddingEndSize > 0)
ubyte paddingEnd[paddingEndSize];
}
else {
local uint32 paddingEndSize = (4 - (uncompressedSize % 4)) % 4;
ubyte data[size - 4 - paddingEndSize];
if (paddingEndSize > 0)
ubyte paddingEnd[paddingEndSize];
}
};
local uint32 firstOffset = ReadUInt(0x8);
local uint32 entriesCount = (firstOffset - 0x4) / sizeof(HeaderEntry);
HeaderEntry headerEntries[entriesCount];
uint32 null;
local uint32 i;
local uint32 lastOffset = firstOffset;
local uint32 fileSizes[entriesCount];
local uint32 fileSize;
for (i = 1; i < entriesCount; i++)
{
fileSizes[i - 1] = headerEntries[i].offset - lastOffset;
lastOffset = headerEntries[i].offset;
}
fileSizes[entriesCount - 1] = FileSize() - lastOffset;
local bool isCompressed;
for (i = 0; i < entriesCount; i++) {
isCompressed = headerEntries[i].uncompressedSizeMaybe > fileSizes[i];
File file(fileSizes[i], headerEntries[i].uncompressedSizeMaybe, isCompressed);
}