-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNBNK-Recursive.bt
690 lines (647 loc) · 17.7 KB
/
NBNK-Recursive.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
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
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
//------------------------------------------------
//--- 010 Editor v9.0.2 Binary Template
//
// File:
// Authors: Deathcream, Silvris
// Version:
// Purpose:
// Category:
// File Mask:
// ID Bytes:
// History: 1.1
// -Rewrote the majority of the template to be recursive
//------------------------------------------------
local int i <hidden=true>;
local int j <hidden=true>;
local int Bool1Length <hidden=true>;
local int Bool2Length <hidden=true>;
local int HIRC10Count1;
local int value <hidden=true>; //Hidden so they don't appear in the variables
local int wemcnt <hidden=true>; //Re-enable if you wanna check (hidden=false)
typedef struct{
long blockID;
uint sectionLength;
}BlockHeader;
typedef struct{
value = (Header.sectionLength/4)-2;
int32 unkn1;
uint nbnkID;
int32 data[value];
}BKHD;
typedef struct{
uint32 WemId; //ID?
uint32 phoffs; //Post Header offset
uint32 size; //Byte size of wem
}WemHead;
typedef struct{
wemcnt = Header.sectionLength/12;
WemHead wemh[wemcnt];
}DIDX;
typedef struct{
byte wemByte;
}WemByte;
struct WemData{
WemByte wemData[MainBlock[1].DIDXBlock.wemh[i].size]<optimize=false>;
};
struct DATA{
for(i=0;i<wemcnt;i++){
FSeek(MainBlock[0].Header.sectionLength+MainBlock[1].Header.sectionLength+MainBlock[1].DIDXBlock.wemh[i].phoffs+24);
WemData Wem<optimize=false>;
};
};
typedef struct{
byte datum;
}UnknData;
typedef struct{
byte blockID;
uint sectionLength;
}HIRCBlockHeader;
typedef struct{
uint objectID;
byte settingsCount;
byte settingsType[settingsCount];
float settingsValue[settingsCount];
}HIRC1;
typedef struct(int count){
for(i=0;i<count;i++){
byte dimension;
};
for(i=0;i<count;i++){
if(dimension == 0){
float unkn1;
float unkn2;
};
if(dimension == 1){
float unkn1;
float unkn2;
float unkn3;
};
if(dimension == 2){
float unkn1;
float unkn2;
};
};
}HIRCPosition;
typedef struct{
byte unknType;
int32 unknHash;
}HIRCExtendHeader;
typedef struct(int count){
int32 unkn0;
float unkn1;
int32 unkn2;
for(i=0;i<count-1;i++){
float unkn3;
float unkn4;
int32 unkn5;
};
}HIRCExtendType2Segment;
typedef struct(int type){
HIRCExtendType2Segment segment(type);
}HIRCExtendTypeSegment;
typedef struct{
uint32 unknID0;
byte unknFlag0;
byte unknFlag1;
byte unknFlag2;
uint32 unknID1;
}HIRCExtendTail;
typedef struct{
HIRCExtendHeader header;
byte unknType0;
short segmentType0;
HIRCExtendTypeSegment segment0(segmentType0);
}HIRCExtend;
typedef struct{
byte unkn1;
uint unknID;
byte unkn2;
}HIRCExtend2;
typedef struct{
//byte unknStartData[70];
short unknSD0;
int unknSD1;
int unknSD2;
int unknSD3;
float unknSD4;
int unknSD5;
float unknSD6;
int unknSD7;
float unknSD8;
int unknSD9;
float unknSD10;
int unknSD11[7];
//byte unknCount2;
//uint unknID1;
}HIRCStructM7;
typedef struct{
short unknSD0;
short unknSD1;
int unknSD2;
byte unknSD3;
short unknSD4;
int unknSD5;
byte unknSD7;
byte unknSD8;
byte unknSD9;
int unknSD10;
float unknSD11;
int unknSD12;
float unknSD13;
float unknSD14;
int unknSD15;
float unknSD16;
float unknSD17;
int unknSD18;
float unknSD19;
float unknSD20;
int unknSD21;
float unknSD22;
float unknSD23;
int unknSD24;
float unknSD25;
float unknSD26;
int unknSD27;
}HIRCStructM0;
typedef struct{
uint unknID;
byte unkn2;
for (i=0;i<unkn2;i++) {
HIRCExtend2 extend;
};
byte unkn3;
for (i=0;i<unkn3;i++) {
HIRCExtend extended;
};
}HIRCSoundStructEnd;
typedef struct{
byte unkn1;
byte effectCount;
if(effectCount > 0){
byte flag;
for(i=0;i<effectCount;i++){
byte index;
uint effectObject;
byte zero1;
byte zero2;
};
};
byte bool1;
uint outputBus;
uint parentBus;
byte bool2;
byte additionalParameters;
for(i=0;i<additionalParameters;i++){
byte parameterType;
};
for(i=0;i<additionalParameters;i++){
if(parameterType[i] == 7) uint loopCount;
else float parameterValue;
};
byte positioningBool;
if(positioningBool>0){
HIRCPosition Positioning(positioningBool);
};
byte unknStart;
if(unknStart == 0){
HIRCStructM0 unknRegion;
}
else{
if(unknStart == -7){
HIRCStructM7 unknRegion;
}
else if(unknStart == -39){
byte unknCount2;
uint unknID1;
}
else if(unknStart == -64){;
}
else{
Printf("unknStart not on list [0,-7,-39,-64]");
};
};
byte unknCount;
if(unknCount == 10){
uint unknID1;
uint unkn3;
short unkn4;
};
byte bool3;
byte bool4;
byte bool5;
byte bool6;
byte bool7;
byte bool8;
if(ReadByte() == 1||ReadByte() == 2||ReadByte()==3)uint bool9;
else byte bool9;
if(bool9==1||bool9==3){
float unknFloat;
};
if(bool9==2){
float unknFloat;
byte unkn1;
short unkn2;
if(unkn2){
uint unkn1;
for(i=0;i<bool9;i++){
uint unkn2;
};
if(bool9>1){
byte unkn3;
};
};
};
byte bool10;
short bool11;
short bool13;
if(bool10) {
if(bool13){
HIRCSoundStructEnd footer;
};
}
else{
for(j=0;j<bool13;j++){
HIRCSoundStructEnd footer;
};
};
}HIRCSoundStruct;
typedef struct{
uint objectID;
short unkn1;
short unkn2;
byte spacing;
if(unkn2 == 101){
uint unkn19ID;
uint unkn2;
uint unkn3;
}
else{
uint wemID;
uint byteLength;
}
byte unkn3;
HIRCSoundStruct SoundData;
}HIRC2;
typedef struct{
uint objectID;
byte actionScope;
byte actionType;
uint affectedID;
byte zero;
byte additionalParameters;
for(i=0;i<additionalParameters;i++){
byte parameterType;
};
for(i=0;i<additionalParameters;i++){
if(parameterType[i] == 16) uint probability;
else uint unkn;
};
byte zero2;
if(actionType == 1){
byte unkn;
uint unkn2;
};
if(actionType == 4){
byte unkn;
uint NBNKID;
};
if(actionType == 10){
byte unknD[2];
float unkn2[4];
};
if(actionType == 11){
byte unknE[18];
};
if(actionType == 13){
byte unknF[18];
};
if(actionType == 14){
byte unknA[2];
float unkn2[4];
};
if(actionType == 15){
byte unknB[2];
float unknC[4];
};
if(actionType == 19){
byte unknG[19];
};
if(actionType == 18){
uint StateGroupID;
uint StateID;
};
if(actionType == 25){
uint SwitchGroupID;
uint SwitchID;
};
}HIRC3;
typedef struct{
uint objectID<name="Object ID">;
uint actionCount<name="Action Count">;
uint actionID[actionCount]<name="Action IDs">;
}HIRC4;
typedef struct{
uint objectID;
HIRCSoundStruct SoundStructure;
uint unknCount;
short unkn1;
float unkn2;
uint unkn3;
uint unkn4;
uint unkn5;
byte byte1;
byte byte2;
uint count1;
for(i=0;i<count1;i++){
uint id;
};
short count2;
for(i=0;i<count2;i++){
uint unkn10;
uint fiftyThousand;
};
}HIRC5;
typedef struct{
uint switchID;
uint unknIndex;
local int structStart = FTell();
uint unknID[unknIndex];
}HIRC6A;
typedef struct{
uint unknID;
short unkn1;
uint unkn2;
uint unkn3;
}HIRC6B;
typedef struct{
uint objectID;
HIRCSoundStruct soundStruct;
byte null0;
uint WWSWID;
uint null;
byte null;
uint randomCount;
uint randomIDs[randomCount];
uint switchCount;
for(i=0;i<switchCount;i++){
HIRC6A switches;
};
uint unknCount;
for(i=0;i<unknCount;i++){
HIRC6B unknStructs;
};
}HIRC6;
typedef struct{
uint unknParameter;
double unknDouble;
uint stringLength;
if (stringLength > 0){
string unknString;
};
}HIRC10A;
typedef struct{
uint objectID;
byte unkn;
HIRCSoundStruct SoundStructure;
uint childCount;
for (i=0;i<childCount;i++){
uint childID;
};
double unkn2;
uint unkn4[2];
float unkn5;
byte unkn6a;
byte unkn6b[6];
double loopTime1<bgcolor=0x0000FF>;
uint unknCount;
HIRC10A UnknDoubles[unknCount-1]<optimize=false>;
char loopHash[4];//HÖ»[
double loopTime2<bgcolor=0xFF0000>;
uint zero;
}HIRC10;
typedef struct{
uint objectID;
byte unknA;
uint headerCount;
for(i=0;i<headerCount;i++){
short unkn1;
short unkn2;
byte unkn3;
uint wemID;
byte unknByte;
uint unknValue;
};
uint unknCount;
for(i=0;i<unknCount;i++){
uint unknA;
uint wemID2;
double startingPointNegative<bgcolor=0xb67b96>;
double startingPointPositive<bgcolor=0xad6b89>;
double remainderOfSong<bgcolor=0xa45a7c>;
double songTotalLength<bgcolor=0x93516f>;
};
uint unknB;
uint unknC;
for(j=0;j<unknC;j++){
uint unknF;
uint unknG;
uint unknH;
for(i=0;i<unknH;i++){
float unknI;
float unknJ;
uint unknK;
};
};
HIRCSoundStruct SoundStructure;
byte unknD;
uint unknE;
}HIRC11;
typedef struct{
local int unknHLen = 0;
local int effectLen = 0;
uint objectID;
byte unknA;
uint headerCount;
for(i=0;i<headerCount;i++){
short unkn1;
short unkn2;
byte unkn3;
uint wemID;
byte unknByte;
uint unknValue;
};
uint unknCount;
for(i=0;i<unknCount;i++){
uint unknA;
uint wemID2;
double startingPointNegative<bgcolor=0xb67b96>;
double startingPointPositive<bgcolor=0xad6b89>;
double remainderOfSong<bgcolor=0xa45a7c>;
double songTotalLength<bgcolor=0x93516f>;
};
uint unknB;
uint unknC;
for(j=0;j<unknC;j++){
uint unknF;
uint unknG;
uint unknH;
unknHLen += 12;
for(i=0;i<unknH;i++){
float unknI;
float unknJ;
uint unknK;
unknHLen += 12;
};
};
byte unkn1;
byte effectCount;
if(effectCount > 0){
byte flag;
for(i=0;i<effectCount;i++){
byte index;
uint effectObject;
byte zero1;
byte zero2;
};
effectLen = 1 + (effectCount*7);
};
byte bool1;
uint outputBus;
uint parentBus;
byte unkns[StructHeader.sectionLength-13-(headerCount*14)-(unknCount*40)-19-(effectLen)-(unknHLen)];
}HIRC11S;
typedef struct{
uint objectID;
}HIRC14;
typedef struct{
uint objectID;
uint actorMixerID;
float unkns[3];
byte unknByte1;
if (unknBytes != 0){
byte unknowns[15];
};
float unknFloat;
uint unknID2;
byte unknCount;
for (i=0;i<unknCount;i++){
short unkn1; //might be flags of some sort
uint unknID;
byte unknByte;
};
byte unkns1[13];
}HIRC20;
struct HIRCParseBlock;
typedef struct{
HIRCBlockHeader StructHeader<bgcolor=0xFF00FF,name="Header">;
local int i;
if (StructHeader.blockID == 1) HIRC1 settings<optimize = false, bgcolor=0x0000FF, name="Settings">;
else if (StructHeader.blockID == 2) HIRC2 soundsfxvoice<optimize = false, bgcolor=0x0000FF, name="Sound SFX/Sound Voice">;
else if (StructHeader.blockID == 3) HIRC3 eventaction<optimize = false, bgcolor=0xCFB3FF, name="Event Action">;
else if (StructHeader.blockID == 4) HIRC4 event<optimize = false, bgcolor=0xD3FFB3, name="Event">;
else if (StructHeader.blockID == 5) HIRC5 rngsequencecontainer<optimize = false, bgcolor=0xB3D8FF, name="Random/Sequence Container">;
else if (StructHeader.blockID == 6) HIRC6 switchcontainer<optimize = false, bgcolor=0xEAFFB3, name="Switch Container">;
else if (StructHeader.blockID == 7) for(i=0;i<(StructHeader.sectionLength);i++)UnknData actormixer<optimize = false, bgcolor=0xFFCAB3, name="Actor-Mixer">;
else if (StructHeader.blockID == 8) for(i=0;i<(StructHeader.sectionLength);i++)UnknData audiobus<optimize = false, bgcolor=0xFFBAB3, name="Audio Bus">;
else if (StructHeader.blockID == 9) for(i=0;i<(StructHeader.sectionLength);i++)UnknData blendcontainer<optimize = false, bgcolor=0xFFB3DA, name="Blend Container">;
else if (StructHeader.blockID == 10) HIRC10 musicsegment<optimize = false, bgcolor=0x33FFBD, name="Music Segment">;
else if (StructHeader.blockID == 11) HIRC11S musictrack<optimize = false, bgcolor=0xB3FFD0, name="Music Track">;
else if (StructHeader.blockID == 12) for(i=0;i<(StructHeader.sectionLength);i++)UnknData mswitchcontainer<optimize = false, bgcolor=0xB3FFB3, name="Music Switch Container">;
else if (StructHeader.blockID == 13) for(i=0;i<(StructHeader.sectionLength);i++)UnknData playlistcontainer<optimize = false, bgcolor=0xFF4040, name="Music Playlist Container">;
else if (StructHeader.blockID == 14) for(i=0;i<(StructHeader.sectionLength);i++)UnknData attenuation<optimize = false, bgcolor=0x40C2FF, name="Attenuation">;
else if (StructHeader.blockID == 15) for(i=0;i<(StructHeader.sectionLength);i++)UnknData dialogueevent<optimize = false, bgcolor=0x85FF40, name="Dialogue Event">;
else if (StructHeader.blockID == 16) for(i=0;i<(StructHeader.sectionLength);i++)UnknData motionbus<optimize = false, bgcolor=0xFFDF40, name="Motion Bus">;
else if (StructHeader.blockID == 17) for(i=0;i<(StructHeader.sectionLength);i++)UnknData motionfx<optimize = false, bgcolor=0xFF9F40, name="Motion FX">;
else if (StructHeader.blockID == 18) for(i=0;i<(StructHeader.sectionLength);i++)UnknData effect<optimize = false, bgcolor=0x7440FF, name="Effect">;
else if (StructHeader.blockID == 19) for(i=0;i<(StructHeader.sectionLength);i++)UnknData unkntype19<optimize = false, bgcolor=0x40FF9A, name="Unknown Type 19">;
else if (StructHeader.blockID == 20) for(i=0;i<(StructHeader.sectionLength);i++)UnknData auxiliarybus<optimize = false, bgcolor=0x407AFF, name="Auxiliary Bus">;
else for(i=0;i<(StructHeader.sectionLength);i++)UnknData Data<optimize = false,bgcolor=0x000000, name="unkBlock">; // sType
}HIRCParseBlock;
typedef struct{
uint structCount;
HIRCParseBlock HIRCData[structCount]<optimize=false,name="Object Data">;
}HIRC;
typedef struct{
uint unknValues;
uint stringLength;
string unknAddon;
}INITString;
typedef struct{
uint stringCount;
for (i=0;i<stringCount;i++){
INITString String;
};
}INIT;
typedef struct{
float volumeThreshold;
uint16 maxVoiceInstances;
uint stateGroupCount;
for (i=0;i<stateGroupCount;i++){
uint stateGroupID;
uint defaultTransitionTime;
uint customTransitionCount;
for (j=0;j<customTransitionCount;j++){
uint stateIDFrom;
uint stateIDTo;
uint transitionTime;
};
};
uint switchGroupCount;
for (i=0;i<switchGroupCount;i++){
uint switchGroupID;
uint gameParameterID;
byte unknownByte;
uint pointCount;
for (j=0;j<pointCount;j++){
float gameParameterValue;
uint SwitchIDatValue;
uint curveShape;
};
};
uint gameParameterCount;
for (i=0;i<gameParameterCount;i++){
uint gameParameterID;
float defaultValue;
uint unknCount;
float unkn3;
float unkn1;
byte unkn2;
};
byte spacer[8];
}STMG;
typedef struct{
for (i=0;i<6;i++){
uint bigNum;
uint zero1;
uint zero2;
uint val1;
if (val1 == 9){
float float1a;
float float1b;
float float1c;
};
float float1;
float float2;
uint four2;
};
}ENVS;
typedef struct{
uint stringLength;
string exportPlatform;
}PLAT;
struct ParseableBlock;
struct ParseableBlock{
BlockHeader Header<bgcolor=0xFFFF00>;
Printf("%08x - %d\n",Header.blockID,Header.sectionLength);
local int i;
if (Header.blockID == 1145588546) BKHD BKHDBlock<optimize = false, bgcolor=0x0000FF, name="Bank Header">;
else if (Header.blockID == 1480870212) DIDX DIDXBlock<optimize = false, bgcolor=0xFF0000, name="Data Index">;
else if (Header.blockID == 1096040772) DATA DATABlock<optimize = false, bgcolor=0x00FF00, name="Wem Data">; //there is a more detailed structure for this, but it's a lot of effort to get it to work with the recursion, and its well documented elsewhere, look through vgmstream's source code
else if (Header.blockID == 1129466184) HIRC HIRCBlock<optimize = false, bgcolor=0x123456, name="WWise Objects">;
else if (Header.blockID == 1414090313) INIT INITBlock<optimize = false, bgcolor=0x567890, name="Initialization">;
else if (Header.blockID == 1196250195) STMG STMGBlock<optimize = false, bgcolor=0x987654, name="State Management">;
else if (Header.blockID == 1398165061) ENVS ENVSBlock<optimize = false, bgcolor=0x489863, name="Environment Settings">;
else if (Header.blockID == 1413565520) PLAT PLATBlock<optimize = false, bgcolor=0xF0F0F0, name="Platform of Export">;
else for(i=0;i<(Header.sectionLength);i++)UnknData Data<optimize = false,bgcolor=0x000000, name="unkBlock">; // sType
};
while(FTell()< FileSize()) ParseableBlock MainBlock;