forked from eXpl0it3r/bnkextr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bnkextr.hpp
483 lines (400 loc) · 8.83 KB
/
bnkextr.hpp
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
#include <cstring>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstdint>
#include <map>
#define ALIGN(value, align) value + ((align - (value % align)) % align)
struct Index;
struct Section;
#pragma pack(push, 1)
struct Index
{
std::uint32_t id;
std::uint32_t offset;
std::uint32_t size;
};
#pragma pack(pop)
#pragma pack(push, 1)
struct Section
{
char sign[4];
std::uint32_t size;
};
#pragma pack(pop)
#pragma pack(push, 1)
struct BankHeader
{
std::uint32_t version;
std::uint32_t id;
};
#pragma pack(pop)
#pragma pack(push, 1)
struct PCK_Header
{
std::uint32_t unkn2;
std::uint32_t languageLength;
std::uint32_t bnkTableLength;
std::uint32_t wemTableLength;
std::uint32_t unkn6;
};
#pragma pack(pop)
#pragma pack(push, 1)
struct stringData
{
std::uint32_t postHeaderOffset;
std::uint32_t index;
};
#pragma pack(pop)
#pragma pack(push, 1)
struct embeddedMedia
{
uint32_t ID;
uint32_t unkn;
uint32_t Length;
uint32_t Offset;
uint32_t language;
};
#pragma pack(pop)
enum class ObjectType : std::int8_t
{
Settings = 1,
Sound = 2,
EventAction = 3,
Event = 4,
RandomOrSequenceContainer = 5,
SwitchContainer = 6,
ActorMixer = 7,
AudioBus = 8,
BlendContainer = 9,
MusicSegment = 10,
MusicTrack = 11,
MusicSwitchContainer = 12,
MusicPlaylistContainer = 13,
Attenuation = 14,
DialogueEvent = 15,
MotionBus = 16,
MotionFx = 17,
Effect = 18,
Unknown = 19,
AuxiliaryBus = 20
};
std::string GetObjectTypeName(ObjectType Object)
{
switch (Object)
{
case ObjectType::Settings:
return "Settings";
break;
case ObjectType::Sound:
return "Sound";
break;
case ObjectType::EventAction:
return "EventAction";
break;
case ObjectType::Event:
return"Event";
break;
case ObjectType::RandomOrSequenceContainer:
return "RandomOrSequenceContainer";
break;
case ObjectType::SwitchContainer:
return "SwitchContainer";
break;
case ObjectType::ActorMixer:
return "ActorMixer";
break;
case ObjectType::AudioBus:
return "AudioBus";
break;
case ObjectType::BlendContainer:
return "BlendContainer";
break;
case ObjectType::MusicSegment:
return "MusicSegment";
break;
case ObjectType::MusicTrack:
return "MusicTrack";
break;
case ObjectType::MusicSwitchContainer:
return "MusicSwitchContainer";
break;
case ObjectType::MusicPlaylistContainer:
return "MusicPlaylistContainer";
break;
case ObjectType::Attenuation:
return "Attenuation";
break;
case ObjectType::DialogueEvent:
return "DialogueEvent";
break;
case ObjectType::MotionBus:
return "MotionBus";
break;
case ObjectType::MotionFx:
return "MotionFx";
break;
case ObjectType::Effect:
return "Effect";
break;
case ObjectType::Unknown:
return "Unknown";
break;
case ObjectType::AuxiliaryBus:
return "AuxiliaryBus";
break;
default:
return "Unknown";
break;
};
}
#pragma pack(push, 1)
struct Object
{
ObjectType type;
std::uint32_t size;
std::uint32_t id;
};
#pragma pack(pop)
struct EventObject
{
std::uint32_t action_count;
std::vector<std::uint32_t> action_ids;
};
enum class EventActionScope : std::int8_t
{
SwitchOrTrigger = 1,
Global = 2,
GameObject = 3,
State = 4,
All = 5,
AllExcept = 6
};
std::string GetEventActionName(EventActionScope Event)
{
switch (Event)
{
case EventActionScope::SwitchOrTrigger:
return "SwitchOrTrigger";
break;
case EventActionScope::Global:
return "Global";
break;
case EventActionScope::GameObject:
return "GameObject";
break;
case EventActionScope::State:
return "State";
break;
case EventActionScope::All:
return "All";
break;
case EventActionScope::AllExcept:
return "AllExcept";
break;
default:
return "Unknown";
break;
}
}
enum class EventActionType : std::int8_t
{
Stop = 1,
Pause = 2,
Resume = 3,
Play = 4,
Trigger = 5,
Mute = 6,
UnMute = 7,
SetVoicePitch = 8,
ResetVoicePitch = 9,
SetVoiceVolume = 10,
ResetVoiceVolume = 11,
SetBusVolume = 12,
ResetBusVolume = 13,
SetVoiceLowPassFilter = 14,
ResetVoiceLowPassFilter = 15,
EnableState = 16,
DisableState = 17,
SetState = 18,
SetGameParameter = 19,
ResetGameParameter = 20,
SetSwitch = 21,
ToggleBypass = 22,
ResetBypassEffect = 23,
Break = 24,
Seek = 25
};
std::string GetActionName(EventActionType Action)
{
switch (Action)
{
case EventActionType::Stop:
return "Stop";
break;
case EventActionType::Pause:
return "Pause";
break;
case EventActionType::Resume:
return "Resume";
break;
case EventActionType::Play:
return "Play";
break;
case EventActionType::Trigger:
return "Trigger";
break;
case EventActionType::Mute:
return "Mute";
break;
case EventActionType::UnMute:
return "UnMute";
break;
case EventActionType::SetVoicePitch:
return "SetVoicePitch";
break;
case EventActionType::ResetVoicePitch:
return "ResetVoicePitch";
break;
case EventActionType::SetVoiceVolume:
return "SetVoiceVolume";
break;
case EventActionType::ResetVoiceVolume:
return "ResetVoiceVolume";
break;
case EventActionType::SetBusVolume:
return "SetBusVolume";
break;
case EventActionType::ResetBusVolume:
return "ResetBusVolume";
break;
case EventActionType::SetVoiceLowPassFilter:
return "SetVoiceLowPassFilter";
break;
case EventActionType::ResetVoiceLowPassFilter:
return "ResetVoiceLowPassFilter";
break;
case EventActionType::EnableState:
return "EnableState";
break;
case EventActionType::DisableState:
return "DisableState";
break;
case EventActionType::SetState:
return "SetState";
break;
case EventActionType::SetGameParameter:
return "SetGameParameter";
break;
case EventActionType::ResetGameParameter:
return "ResetGameParameter";
break;
case EventActionType::SetSwitch:
return "SetSwitch";
break;
case EventActionType::ToggleBypass:
return "ToggleBypass";
break;
case EventActionType::ResetBypassEffect:
return "ResetBypassEffect";
break;
case EventActionType::Break:
return "Break";
break;
case EventActionType::Seek:
return "Seek";
break;
default:
return "Unknown";
break;
}
}
enum class EventActionParameterType : std::int8_t
{
Delay = 0x0E,
Play = 0x0F,
Probability = 0x10
};
std::string GetEventActionParameterName(EventActionParameterType Action)
{
switch (Action)
{
case EventActionParameterType::Delay:
return "Delay";
break;
case EventActionParameterType::Play:
return "Play";
break;
case EventActionParameterType::Probability:
return "Probability";
break;
default:
return "Unknown";
break;
}
}
enum class StorageType : std::int8_t
{
Embedded = 0,
Streamed = 1,
StreamedPrefetched = 2
};
std::string GetStorageTypeName(StorageType Type)
{
switch (Type)
{
case StorageType::Embedded:
return "Embedded";
break;
case StorageType::Streamed:
return "Streamed";
break;
case StorageType::StreamedPrefetched:
return "StreamedPrefetched";
break;
default:
return "Unknown";
break;
}
}
enum class SoundType : std::int8_t
{
SFX = 0,
Voice = 1
};
std::string GetSoundTypeName(SoundType Type)
{
switch (Type)
{
case SoundType::SFX:
return "SFX";
break;
case SoundType::Voice:
return "Voice";
break;
default:
return "Unknown";
break;
}
}
struct EventActionObject
{
EventActionScope scope;
EventActionType action_type;
std::uint32_t game_object_id;
std::uint8_t parameter_count;
std::vector<EventActionParameterType> parameters_types;
std::vector<std::int8_t> parameters;
};
struct Sound
{
std::uint32_t PluginID;
StorageType state;
std::uint32_t AudioID;
std::uint32_t SourceID;
SoundType SoundType;
std::uint32_t InMemoryMediaSize;
};