• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PredatorCZ / RevilLib / 175

19 Nov 2025 10:16PM UTC coverage: 10.614% (-0.5%) from 11.16%
175

push

github

PredatorCZ
add more mtf texture support

0 of 139 new or added lines in 2 files covered. (0.0%)

639 existing lines in 6 files now uncovered.

757 of 7132 relevant lines covered (10.61%)

6360.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/tex.hpp
1
/*  Revil Format Library
2
    Copyright(C) 2020-2025 Lukas Cone
3

4
    This program is free software : you can redistribute it and / or modify
5
    it under the terms of the GNU General Public License as published by
6
    the Free Software Foundation, either version 3 of the License, or
7
    (at your option) any later version.
8

9
    This program is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
12
    GNU General Public License for more details.
13

14
    You should have received a copy of the GNU General Public License
15
    along with this program.If not, see <https://www.gnu.org/licenses/>.
16
*/
17

18
#pragma once
19
#include "revil/platform.hpp"
20
#include "revil/settings.hpp"
21
#include "spike/io/bincore_fwd.hpp"
22
#include "spike/type/bitfield.hpp"
23
#include "spike/type/vectors.hpp"
24
#include <functional>
25

26
namespace revil {
27

28
enum class TextureType : uint8 {
29
  None,
30
  ColorPixel,
31
  General,
32
  Cubemap,
33
  Volume,
34
};
35

36
enum class TextureTypeV2 {
37
  General = 2,
38
  Volume = 3,
39
  Cubemap = 6,
40
};
41

42
enum class GeneralTextureType {
43
  None,
44
  IllumMap,  // IM
45
  ColorMap,  // BM, LM, or SRGB??
46
  NormalMap, // NM XGXA
47
};
48

49
enum class CubemapTextureType {
50
  Eye, // LP PC, some struct dump
51
  Classic,
52
};
53

54
enum class TEXFormat : uint32 {
55
  DXT1 = CompileFourCC("DXT1"),
56
  DXT2 = CompileFourCC("DXT2"),
57
  DXT3 = CompileFourCC("DXT3"),
58
  DXT5 = CompileFourCC("DXT5"),
59
  RGBA8_PACKED = 0x15,
60
  RG8_SNORM = 0x3c,
61

62
  /*360
63
  405274959
64
  405275014
65
  438305106
66
  438305107
67
  438305108
68
  438305137
69
  438305147
70
  438305148*/
71
};
72
// 9 14 55
73
enum class TEXFormatV2 : uint8 {
74
  RGBA16F = 0x2,
75
  R8 = 0x7,
76
  RGBA8_LP4 = 0x9,
77
  RGB10A2 = 0xE, // vertex field (VTF)
78
  BC1 = 0x13,
79
  BC1A = 0x14,
80
  BC2 = 0x15,
81
  BC2_PA = 0x16, // alpha premult?
82
  BC3 = 0x17,
83
  BC3_PA = 0x18,                        // alpha premult?
84
  COMPRESSED_GRAYSCALE = 0x19,          // BC4, BC1
85
  COMPRESSED_NORMAL_MAP = 0x1e,         // BC1
86
  COMPRESSED_DERIVED_NORMAL_MAP = 0x1f, // BC3, BC5, BC5S
87
  BC3_LM = 0x20,                        // alpha premult?
88
  BC3_CM = 0x23,                        // ddon defaultcube only, alpha premult?
89
  BC3_PM = 0x25,                        // rgb NM, alpha HM
90
  RGBA8 = 0x27,
91
  RGBA8_PA = 0x28,   // alpha premult?
92
  BC3_YUV = 0x2A,    // red Y, green A, blue U, alpha V
93
  BC3_YUV_PA = 0x2B, // alpha premult?
94
  BC3_EFF = 0x2F,    // effect related (DD)
95
  BC7 = 0x30,
96
  BC7_PA = 0x37, // premult aplha or srgb
97
};
98

99
enum class TEXFormat3DS : uint8 {
100
  RGBA4 = 1,
101
  RGBA8 = 3,
102
  R5G6B5 = 4,
103
  R8 = 5,
104
  RG4 = 6,
105
  IA8 = 7,
106
  ETC1 = 0xB,
107
  ETC1A4 = 0xC,
108
  A4 = 0xE,
109
  L4 = 0xF,
110
  AL4 = 0x10,
111
  RGB8 = 0x11,
112
};
113

114
static constexpr uint32 TEXID = CompileFourCC("TEX");
115
static constexpr uint32 TEXSID = CompileFourCC("TEX ");
116
static constexpr uint32 XETID = CompileFourCC("\0XET");
117

NEW
118
struct TEXx70 {
×
119
  using TextureType = BitMemberDecl<0, 4>;
120
  using TextureSubtype = BitMemberDecl<1, 4>;
121
  using TextureLayout = BitFieldType<uint16, TextureType, TextureSubtype>;
122
  uint32 id = TEXID;
123
  uint16 version;
124
  TextureLayout type;
125
  uint8 numMips;
126
  uint8 numFaces = 1; // 6 for cubemap
127
  uint16 null = 0;
128
  uint16 width;
129
  uint16 height;
130
  uint32 arraySize = 0;
131
  TEXFormat fourcc;
132
  Vector4 colorCorrection{1.f, 1.f, 1.f, 0};
133

NEW
134
  void SwapEndian(bool way) {
×
NEW
135
    FByteswapper(id);
×
NEW
136
    FByteswapper(version);
×
NEW
137
    FByteswapper(type, way);
×
NEW
138
    FByteswapper(width);
×
NEW
139
    FByteswapper(height);
×
NEW
140
    FByteswapper(arraySize);
×
NEW
141
    FByteswapper(fourcc);
×
NEW
142
    FByteswapper(colorCorrection);
×
143
  }
144
};
145

NEW
146
struct TEXx66 {
×
147
  using TextureType = BitMemberDecl<0, 4>;
148
  using TextureSubtype = BitMemberDecl<1, 4>;
149
  using TextureLayout = BitFieldType<uint16, TextureType, TextureSubtype>;
150
  uint32 id = TEXID;
151
  uint16 version;
152
  TextureLayout type;
153
  uint8 numMips;
154
  uint8 numFaces = 1;
155
  uint16 width;
156
  uint16 height;
157
  uint16 arraySize;
158
  TEXFormat fourcc;
159
  Vector4 colorCorrection{1.f, 1.f, 1.f, 0};
160

NEW
161
  void SwapEndian(bool way) {
×
NEW
162
    FByteswapper(id);
×
NEW
163
    FByteswapper(version);
×
NEW
164
    FByteswapper(type, way);
×
NEW
165
    FByteswapper(width);
×
NEW
166
    FByteswapper(height);
×
NEW
167
    FByteswapper(arraySize);
×
NEW
168
    FByteswapper(fourcc);
×
NEW
169
    FByteswapper(colorCorrection);
×
170
  }
171
};
172

173
struct TEXx56 {
174
  enum class TextureLayout : uint8 { General, Illum, Corrected = 4 };
175

176
  uint32 id;
177
  uint8 version;
178
  TextureType type;
179
  TextureLayout layout;
180
  uint8 numMips;
181
  uint32 width;
182
  uint32 height;
183
  uint32 arraySize;
184
  TEXFormat fourcc;
185

NEW
186
  void SwapEndian() {
×
NEW
187
    FByteswapper(id);
×
NEW
188
    FByteswapper(width);
×
NEW
189
    FByteswapper(height);
×
NEW
190
    FByteswapper(arraySize);
×
NEW
191
    FByteswapper(fourcc);
×
192
  }
193
};
194

195
struct TEXx87 {
196
  using TextureType = BitMemberDecl<0, 4>;
197
  using NumMips = BitMemberDecl<1, 5>;
198
  using NumFaces = BitMemberDecl<2, 8>;
199
  using Width = BitMemberDecl<3, 13>;
200
  using Tier0 = BitFieldType<uint32, TextureType, NumMips, NumFaces, Width>;
201
  using Height = BitMemberDecl<0, 13>;
202
  using Depth = BitMemberDecl<1, 13>;
203
  using Null = BitMemberDecl<2, 6>;
204
  using Tier1 = BitFieldType<uint32, Height, Depth, Null>;
205

206
  uint32 id;
207
  uint16 version;
208
  uint16 null;
209
  Tier0 tier0;
210
  Tier1 tier1;
211
  TEXFormatV2 format;
212

NEW
213
  void SwapEndian(bool way) {
×
NEW
214
    FByteswapper(id);
×
NEW
215
    FByteswapper(version);
×
NEW
216
    FByteswapper(tier0, way);
×
217
    FByteswapper(tier1, way);
218
  }
219
};
220

221
struct TEXx9D {
222
  using Version = BitMemberDecl<0, 8>;
223
  using Unk00 = BitMemberDecl<1, 6>;
224
  using Unk01 = BitMemberDecl<2, 14>;
225
  using TextureType = BitMemberDecl<3, 4>;
226
  using Tier0 = BitFieldType<uint32, Version, Unk00, Unk01, TextureType>;
227

228
  using NumMips = BitMemberDecl<0, 6>;
229
  using Width = BitMemberDecl<1, 13>;
230
  using Height = BitMemberDecl<2, 13>;
231
  using Tier1 = BitFieldType<uint32, NumMips, Width, Height>;
232

233
  uint32 id;
234
  Tier0 tier0;
235
  Tier1 tier1;
236
  uint8 numFaces;
237
  TEXFormatV2 format;
238
  uint16 depth;
239

NEW
240
  void SwapEndian(bool) {
×
NEW
241
    FByteswapper(id);
×
NEW
242
    FByteswapper(tier0.value);
×
NEW
243
    FByteswapper(tier1.value);
×
NEW
244
    FByteswapper(reinterpret_cast<uint32 &>(numFaces));
×
245
  }
246
};
247

248
enum class TEXFormatAndr : uint8 {
249
  RGBA8 = 0x1,
250
  R5G6B5 = 0x6,
251
  RGBA4 = 0x7,
252
  ETC1 = 0xA,
253
  BC3 = 0xC,
254
  PVRTC4 = 0xD,
255
};
256

257
enum class TEXTypeAndr : uint32 {
258
  Common,       // GSM, ID, CMM, fallback?
259
  BaseMap,      // BM
260
  MaskMap,      // MM
261
  AlphaMap = 5, // AM
262
  Cubemap,      // CM
263
  LP4,          // event slides?
264
  Nuki,         // NUKI, extract in jp
265
};
266

267
struct TEXx09 {
268
  uint32 id;
269
  uint16 version;
270
  TEXFormatAndr format;
271
  uint8 unk00;
272
  uint32 unk01 : 4;
273
  TEXTypeAndr type : 28;
274

275
  uint32 width : 13;
276
  uint32 height : 13;
277
  uint32 numMips : 4;
278
  uint32 unk0 : 1;
279
  uint32 unk1 : 1;
280

281
  uint32 dataOffset;
282
  uint32 pvrVariantOffset;
283
  uint32 unkVariantOffset;
284

285
  uint32 dataSize;
286
  uint32 pvrSize;
287
  uint32 unkSize;
288
};
289

290
using TextureVersion =
291
    std::function<bool(uint32 version, BinReaderRef_e rd, Platform platform)>;
292
void RE_EXTERN LoadDetectTex(BinReaderRef_e rd, Platform platform,
293
                             TextureVersion loadFunc);
294

295
} // namespace revil
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc