forked from PrimeDecomp/PrimeRemasterStructs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Common.bt
104 lines (89 loc) · 1.71 KB
/
Common.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef _COMMON
#define _COMMON
typedef uchar bool;
typedef struct
{
string text;
} CString <bgcolor=0xCDE6FF, read=StringRead>;
typedef struct
{
uint32 size;
if (size > 0) {
char text[size];
}
} CStringFixed <bgcolor=0xCDE6FF, read=StringReadFixed>;
string StringRead(CString &str)
{
if (exists(str.text)) {
return str.text;
}
return "<empty>";
}
string StringReadFixed(CStringFixed &str)
{
if (exists(str.text)) {
return str.text;
}
return "<empty>";
}
typedef char FourCC[4] <fgcolor=cLtGreen>;
FourCC FourCCInt(uint32 in)
{
FourCC fcc;
fcc[0] = (in >> 24) & 0xFF;
fcc[1] = (in >> 16) & 0xFF;
fcc[2] = (in >> 8) & 0xFF;
fcc[3] = (in >> 0) & 0xFF;
return fcc;
}
string FormatBytes(uint64 size)
{
byte order = 0;
while (size >= 1024 && order < 5)
{
order++;
size /= 1024;
}
string suffix;
switch (order)
{
case 0:
suffix = "";
break;
case 1:
suffix = " KiB";
break;
case 2:
suffix = " MiB";
break;
case 3:
suffix = " GiB";
break;
case 4:
suffix = " TiB";
break;
}
return Str("%d%s", size, suffix);
}
string SizeComment(uint64 size)
{
return Str("Size: %s (0x%X)", FormatBytes(size), size);
}
local GUID GUIDZero <hidden=true>;
// Struct wrapper for GUID
// Allows array usage
typedef struct {
GUID inner;
} CGuid <
read=(GUIDToString(inner)),
fgcolor=(cLtAqua)
>;
typedef enum <byte>
{
NONE = 0x0,
LZSS_8 = 0x1,
LZSS_16 = 0x2,
LZSS_32 = 0x3,
ZLIB = 0xD,
} CompressionType;
#endif// _COMMON