forked from jilleb/mqb-soundaktor
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFL_xx__x.odx.FD_2DATA.BIN.bt
748 lines (689 loc) · 26.7 KB
/
FL_xx__x.odx.FD_2DATA.BIN.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
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
//------------------------------------------------
//--- 010 Editor v12.0 Binary Template
//
// File: FL_xx__x.odx.FD_2DATA.BIN
// Authors: Jille, Dark
// Version: 0.9.9
// Purpose: Parse the contents of the MQB soundaktor firmware
// Category:
// File Mask:
// ID Bytes:
// History: 0.1 - Initial version
// 0.2 - Additional field descriptions taken from MxCar sheet
// 0.3.1 - 10 out of 12 tables mapped
// 0.3.2 - Gain table key
// 0.4 - Parsed and visualized all the tables found at this moment
// 0.5 - Transposed some tables to be viewed in the right way
// 0.6 - Added Lib_Sig (whatever it may be.. noise signature?)
// 0.7 - template code cleanup, started GEN2.5 parsing
// 0.8 - Checksum mechanism included
// 0.9 - GEN2 finished, GEN2.5 work in progress
// 0.9.1 - several more table params for GEN2.5
// 0.9.8 - parsed and printed everything except SUM_DATA and MX_PROFILE
// 0.9.9 - MX_Profile parsed
// 1.0 - more GEN2.5 Car / MX Profile options parsed
//------------------------------------------------
// legend:
// yellow/aqua = uncertain
// red = checksum
// green = confirmed
// gray = seemingly irrelevant
// blue = special
// LOCAL VARIABLES
local int i = 0;
local int j = 0;
local float x = 0;
local int factor = 0;
local string format = "";
local int start = 0x02;
local int end = 0xE000;
local string output = "";
local int GEN25 = (FileSize() == 0x18000 ? 1 : 0);
if (GEN25) {
end = 0x18000;
}
string getFilterProperties(int filterSetting) {
switch (filterSetting) {
case 0x00: return "No";
case 0x01: return "50Hz/6dB";
case 0x02: return "100Hz/6dB";
case 0x03: return "150Hz/6dB";
case 0x04: return "200Hz/6dB";
case 0x05: return "250Hz/6dB";
case 0x06: return "300Hz/6dB";
case 0x07: return "350Hz/6dB";
case 0x08: return "400Hz/6dB";
case 0x09: return "450Hz/6dB";
case 0x0A: return "50Hz/12dB";
case 0x0B: return "100Hz/12dB";
case 0x0C: return "150Hz/12dB";
case 0x0D: return "200Hz/12dB";
case 0x0E: return "250Hz/12dB";
case 0x0F: return "300Hz/12dB";
case 0x10: return "350Hz/12dB";
case 0x11: return "400Hz/12dB";
case 0x12: return "450Hz/12dB";
default: return "Unknown";
}
}
string getSampleRate(int sampleRate) {
switch (sampleRate) {
case 0: return "512";
case 1: return "1024";
case 2: return "2048";
case 3: return "4096";
case 4: return "8192";
case 5: return "16384";
case 6: return "32768";
default:return "Unknown";
}
}
int getIntegerSampleRate(int sampleRate) {
switch (sampleRate) {
case 0: return 512;
case 1: return 1024;
case 2: return 2048;
case 3: return 4096;
case 4: return 8192;
case 5: return 16384;
case 6: return 32768;
default:return 0;
}
}
string getSumEffect(int effectNumber) {
switch(effectNumber) {
case 0: return "Bypass";
case 1: return "Tiefpass";
case 2: return "Hochpass";
case 3: return "Bandpass";
case 4: return "Notch";
case 5: return "Peak";
case 6: return "LowShelf";
case 7: return "HighShelf";
default:return "Unknown";
}
}
// START PARSING
LittleEndian();
ushort file_checksum <bgcolor=cRed>; //some kind of checksum?
byte unknown_2 <bgcolor=cDkYellow>;
byte Gain_table_flag <bgcolor=cYellow>;
ushort DEFAULTS_Profiles <bgcolor=cDkAqua>;
if (!GEN25) {
ushort DEFAULTS_Effects <bgcolor=cAqua>;
} else {
local int DEFAULTS_Effects = 16;
}
ushort DEFAULTS_RevsFunctions <bgcolor=cDkAqua>; // engine revolutions / LIB_n_Gain
ushort DEFAULTS_AccelFunctions <bgcolor=cAqua>; // acceleration / G-meter / LIB_m_Gain
ushort DEFAULTS_SpeedFunctions <bgcolor=cDkAqua>; // speed / LIB_v_Gain
if (GEN25) {
ushort DEFAULTS_PedalFunctions <bgcolor=cAqua>; // pedal / LIB_p_Gain
ushort DEFAULTS_Samples_count <bgcolor=cYellow>;
ushort unknown_9 <bgcolor=cDkYellow>;
ushort unknown_10 <bgcolor=cYellow>;
ushort unknown_11 <bgcolor=cDkYellow>;
ushort unknown_12 <bgcolor=cYellow>;
} else {
ushort DEFAULTS_Revolutions_length <bgcolor=cYellow>;
ushort DEFAULTS_Acceleration_length <bgcolor=cDkYellow>;
ushort DEFAULTS_Speed_length <bgcolor=cYellow>;
ushort DEFAULTS_Acceleration_Table_size <bgcolor=cDkYellow>; // size of LIB_m_Gain table in bytes, 512
ushort DEFAULTS_Revolutions_Table_size <bgcolor=cYellow>; // size of LIB_n_Gain table in bytes, 8192
}
ushort DEFAULTS_Profiles_2 <bgcolor=cDkAqua>;
if (!GEN25) {
ushort DEFAULTS_Effects_2 <bgcolor=cAqua>;
}
ushort DEFAULTS_RevsFunctions_2 <bgcolor=cDkAqua>;
ushort DEFAULTS_AccelFunctions_2 <bgcolor=cAqua>;
ushort DEFAULTS_SpeedFunctions_2 <bgcolor=cDkAqua>;
if (GEN25) {
ushort DEFAULTS_PedalFunctions_2 <bgcolor=cAqua>;
ushort DEFAULTS_Samples_count_2 <bgcolor=cYellow>;
ushort DEFAULTS_Sample_Rate <bgcolor=cDkYellow, read=getSampleRate>;
ushort unknown_14 <bgcolor=cYellow>;
ushort unknown_15 <bgcolor=cDkYellow>;
ushort unknown_16 <bgcolor=cYellow>;
ushort unknown_17 <bgcolor=cDkYellow>;
ushort unknown_18 <bgcolor=cYellow>;
} else {
// the following 2 values are linked to SampleRate
// Depending on the value there, the values here are different.
ushort DEFAULTS_Samples_count <bgcolor=cYellow>; // LIB_Sig
ushort DEFAULTS_Sample_length <bgcolor=cDkYellow>; // LIB_Sig
ushort DEFAULTS_Damping_factor <bgcolor=cYellow>; // Range 0-65535
}
// Offset where the filename starts.
FSeek(62);
ushort source_filename_checksum <bgcolor=cRed>;// CRC16-CCITT
char source_filename[64] <bgcolor=cDkGreen>;
ushort Profiles <bgcolor=cDkAqua>;
ushort RevsFunctions <bgcolor=cAqua>;
ushort AccelFunctions <bgcolor=cDkAqua>;
ushort SpeedFunctions <bgcolor=cAqua>;
if (!GEN25) {
ushort Samples_count <bgcolor=cDkAqua>;
ushort Sample_Rate <bgcolor=cAqua, read=getSampleRate>;
ushort Damping_factor <bgcolor=cDkAqua>; // 0 <= DF <= 1 Quantization 0-65535
// they refer to it as initial speed value in GEN2 ???? (always set to 0!)
ushort InitialSpeedValue <bgcolor=cAqua>; // should be 0 in most cases, some electric cars have reversed value of 32768
} else {
ushort PedalFunctions <bgcolor=cDkAqua>;
ushort Samples_count <bgcolor=cAqua>;
ushort Sample_Rate <bgcolor=cDkAqua, read=getSampleRate>;
ushort unknown_22 <bgcolor=cAqua>;
ushort unknown_23 <bgcolor=cDkAqua>;
ushort unknown_24 <bgcolor=cAqua>;
ushort unknown_25 <bgcolor=cDkAqua>;
ushort unknown_26 <bgcolor=cAqua>;
ushort unknown_27 <bgcolor=cDkAqua>;
ushort unknown_28 <bgcolor=cAqua>;
ushort unknown_29 <bgcolor=cDkAqua>;
ushort unknown_30 <bgcolor=cAqua>;
}
Printf("%s \n\n", source_filename);
if (!GEN25) {
Printf("GEN2 firmware\n\n");
struct {
ubyte Engine_code <bgcolor=cDkGreen>;
char VIN_mask[17] <bgcolor=cGreen>;
ubyte Charisma_01_Switch_Relapse_Clamp15 <bgcolor=cDkGreen>;
ubyte Charisma_02_Switch_Gearbox <bgcolor=cGreen>;
ubyte Charisma_03_Default_driving_profile <bgcolor=cDkGreen>;
ubyte Charisma_04_Reverse_driving_profile <bgcolor=cGreen>;
ubyte Charisma_05_Comfort_driving_profile <bgcolor=cDkGreen>;
ubyte Charisma_06_Normal_driving_profile <bgcolor=cGreen>;
ubyte Charisma_07_Sport_driving_profile <bgcolor=cDkGreen>;
ubyte Charisma_08_Offroad_driving_profile <bgcolor=cGreen>;
ubyte Charisma_09_Eco_driving_profile <bgcolor=cDkGreen>;
ubyte Charisma_10_Race_driving_profile <bgcolor=cGreen>;
ubyte Charisma_11_GTE_driving_profile <bgcolor=cDkGreen>;
ubyte HighPass_filter <bgcolor=cGreen, read=getFilterProperties>;
ubyte Reserved_for_future_use_2 <bgcolor=cDkYellow>;
ubyte PHEV_button_led_bits <bgcolor=cYellow>; // 335 only
} Car[Profiles];
// Engine codes
// 06 - high-perf 2.0l diesel engine? CUNA / CUPA / CUBA 190hp+
// 07 - mid-perf DFGA (could cover DFE also, maybe CRL too) Kodiaq 150hp 2.0l diesel
// 0C - CEPA / CZGB 2.5l I5 engine
// 17 - DAZA 2.5l 340+hp
// 29 - MLB-version of high-perf 2.0l
// 2B - CJX 2.0l 220+hp GTI, S3, SQ2, etc
// 2A - CJS 1.8 Leon FR 170+hp
// 42 - CJE / CPK / CPR 1.8 Leon FR
// 45 - something between CJX and higher-perf 2.5l engines, maybe overtuned CJX from Clubsport models? 260-280hp
// 32 - Passat PHEV / Tiguan PHEV, 2.0l maybe?
// 13 - CUK 1.4TSI GTE, Bora / Lavida / Golf
// 14 - old-school A4 diesels 2.0l / 2.7l / 3.0l
// 2D - A6 diesel ?
// 48 - CWGD / DLZA V6 3.0l 350hp S4
// 49 - DECA / DKMB V6 2.9l 450hp RS4 / RS5
// 5A - ???
// 3F - ANY
// D5 - S3 8Y
// E4 - S3 8Y
// D8 - Urus V8
struct { // ST_Gain
ushort value[DEFAULTS_Effects];
} Gain_Effect[Profiles] <bgcolor=cDkGreen, optimize=true>;
struct { // ST_Phase
ushort value[DEFAULTS_Effects];
} Phase_Effect[Profiles] <bgcolor=cGreen, optimize=true>;
struct { // ST_Pitch_Shift
ushort value[DEFAULTS_Effects];
} Pitch_Shift_Effect[Profiles] <bgcolor=cDkGreen, optimize=true>;
struct { // ST_Delay
ushort value[DEFAULTS_Effects];
} Delay_Effect[Profiles] <bgcolor=cGreen, optimize=true>;
struct {
byte value[DEFAULTS_Effects];
} Effects_to_Accel[Profiles] <bgcolor=cDkGreen, optimize=true>;
struct {
byte value[DEFAULTS_Effects];
} Effects_to_Revs[Profiles] <bgcolor=cGreen, optimize=true>;
struct {
byte value[DEFAULTS_Effects];
} Effects_to_Speed[Profiles] <bgcolor=cDkGreen, optimize=true>;
// general table to apply effects on the final sound of every car profile
if (Gain_table_flag > 0) {
// this gain table appears only in newer firmware: 5F 0003+, 8S, 8W
// but 5F 0001, 0002, 8K firmwares dont have it
struct {
byte value[DEFAULTS_Effects];
} Effects_to_Profiles[Profiles] <bgcolor=cGreen, optimize=true>;
}
struct { // MX_Sig
ushort gain[Profiles];
ushort clip[Profiles];
} Effects_to_Samples <bgcolor=cDkGreen>;
ushort Acceleration_Scale[DEFAULTS_Acceleration_length] <bgcolor=cGreen>; // values in [-0.3 - 0.98] range (5F 0003 fw) / [-0.4 - 1.00] range (565 AGA fw)
ushort Revolutions_Scale[DEFAULTS_Revolutions_length] <bgcolor=cDkGreen>; // values in [500 - 8150] (rpm) range quanified by 16256
ushort Speed_Scale[DEFAULTS_Speed_length] <bgcolor=cGreen>; // values in [0 - 326.39] (km/h) range
struct { // LIB_m_Gain
ushort value[DEFAULTS_Acceleration_length];
} Acceleration[AccelFunctions] <bgcolor=cDkGreen, optimize=true>;
struct { // LIB_n_Gain
ushort value[DEFAULTS_Revolutions_length];
} Revolutions[RevsFunctions] <bgcolor=cGreen, optimize=true>;
struct { // LIB_v_Gain
ushort value[DEFAULTS_Speed_length];
} Speed[SpeedFunctions] <bgcolor=cDkGreen, optimize=true>;
struct { // LIB_Sig
short value[getIntegerSampleRate(Sample_Rate)];
} Samples[Samples_count] <bgcolor=cDkAqua, optimize=true>;
// Print a report to output
Printf("ID\tEngine\tVIN\t\tRelapseKl15\tGearbox\tDefault\tReverse\tComfort(1)\tNormal(2)\tSport(3)\tOffroad(4)\tEco(5)\tRace(6)\tHybrid(8)\tHighPassFtr\tRFU2\tRFU3\t\n");
for( i = 0; i < Profiles; i++ ) {
Printf("%i\t%02X\t%s\t%i\t%i\t%i\t%i\t%i\t%i\t%i\t%i\t%i\t%i\t%i\t%s\t%i\t%i\n",
i+1,
Car[i].Engine_code,
Car[i].VIN_mask,
Car[i].Charisma_01_Switch_Relapse_Clamp15,
Car[i].Charisma_02_Switch_Gearbox,
Car[i].Charisma_03_Default_driving_profile + 1,// these all need +1 for some reason, unless it's 255
Car[i].Charisma_04_Reverse_driving_profile + 1,
Car[i].Charisma_05_Comfort_driving_profile + 1,
Car[i].Charisma_06_Normal_driving_profile + 1,
Car[i].Charisma_07_Sport_driving_profile + 1,
Car[i].Charisma_08_Offroad_driving_profile + 1,
Car[i].Charisma_09_Eco_driving_profile + 1,
Car[i].Charisma_10_Race_driving_profile + 1,
Car[i].Charisma_11_GTE_driving_profile + 1,
getFilterProperties(Car[i].HighPass_filter),
Car[i].Reserved_for_future_use_2,
Car[i].PHEV_button_led_bits
);
}
} else if (GEN25) {
Printf("GEN2.5 firmware\n\n");
local int DEFAULTS_Acceleration_length = 32;
local int DEFAULTS_Revolutions_length = 256;
local int DEFAULTS_Speed_length = 32;
local int DEFAULTS_Pedal_length = 32;
FSeek(160);
struct {
ubyte Power_kW <bgcolor=cGreen>;
ubyte unknown_2 <bgcolor=cDkYellow>; // car Class / Group
ubyte Engine_code <bgcolor=cDkGreen>;
char VIN_mask[17] <bgcolor=cGreen>;
char Transmission <bgcolor=cDkGreen>;
// A - Auto
// H - Hybrid ???
char BodyType <bgcolor=cGreen>;
// G - ???
// O - Cabrio / Open Roof
char Drivetrain <bgcolor=cDkGreen>;
// V - All-wheel drive ???
// H - Hybrid
char FPA_installed <bgcolor=cGreen>;
ubyte unknown_25 <bgcolor=cDkYellow>;
ubyte MX_ID <bgcolor=cYellow>; // Priority ???
} Car[Profiles];
// local int MXP_y = 32;
// local int MXP_x = 12;
local int SUM_x = 14; // 19
if (Gain_table_flag == 3) {
SUM_x = 19;
}
// struct {
// ubyte unknown[MXP_x];
// }
ubyte MX_Profile[384] <bgcolor=cDkAqua, optimize=true>;
struct {
ushort value[SUM_x]; // there is NO parameter with such a value and sometimes it is 19 !!!!
} SUM_data[Profiles] <bgcolor=cAqua, optimize=true>;
struct {
ushort value[DEFAULTS_Effects];
} Gain_Effect[Profiles] <bgcolor=cDkGreen, optimize=true>;
struct {
ushort value[DEFAULTS_Effects];
} Pitch_Shift_Effect[Profiles] <bgcolor=cGreen, optimize=true>;
struct {
ushort value[DEFAULTS_Effects];
} Phase_Effect[Profiles] <bgcolor=cDkGreen, optimize=true>;
struct {
ushort value[DEFAULTS_Effects];
} Delay_Effect[Profiles] <bgcolor=cGreen, optimize=true>;
struct {
ubyte value[DEFAULTS_Effects];
} Effects_to_Revs[Profiles] <bgcolor=cDkGreen, optimize=true>;
ushort Revolutions_Scale[DEFAULTS_Revolutions_length] <bgcolor=cGreen>; // values in [500 - 8150] (rpm) range quanified by 16256
struct { // LIB_n_Gain
ushort value[DEFAULTS_Revolutions_length];
} Revolutions[RevsFunctions] <bgcolor=cDkGreen, optimize=true>;
struct {
ubyte value[DEFAULTS_Effects];
} Effects_to_Accel[Profiles] <bgcolor=cGreen, optimize=true>;
ushort Acceleration_Scale[DEFAULTS_Acceleration_length] <bgcolor=cDkGreen>; // values in [-0.5 - 1.00] range, acceleration
struct { // LIB_m_Gain
ushort value[DEFAULTS_Acceleration_length];
} Acceleration[AccelFunctions] <bgcolor=cGreen, optimize=true>;
struct {
ubyte value[DEFAULTS_Effects];
} Effects_to_Speed[Profiles] <bgcolor=cDkGreen, optimize=true>;
ushort Speed_Scale[DEFAULTS_Speed_length] <bgcolor=cGreen>; // values in [0 - 326.39] (km/h) range
struct { // LIB_v_Gain
ushort value[DEFAULTS_Speed_length];
} Speed[SpeedFunctions] <bgcolor=cDkGreen, optimize=true>;
struct {
ubyte value[DEFAULTS_Effects];
} Effects_to_Pedal[Profiles] <bgcolor=cGreen, optimize=true>;
ushort Pedal_Scale[DEFAULTS_Pedal_length] <bgcolor=cDkGreen>;
struct { // LIB_p_Gain
ushort value[DEFAULTS_Pedal_length];
} Pedal[PedalFunctions] <bgcolor=cGreen, optimize=true>;
struct { // MX_Sig
ubyte value[DEFAULTS_Effects];
} Effects_to_Samples[Profiles] <bgcolor=cDkGreen, optimize=true>;
struct { // LIB_Sig
short value[getIntegerSampleRate(Sample_Rate)];
} Samples[Samples_count] <bgcolor=cDkAqua, optimize=true>;
// Print a report to output
Printf("CAR\n");
Printf("ID\tPower kW\tunknown_2\tEngine\tVIN\t\tTransmissn\tBody Type\tDrivetrain\tFPA Flag\tunknown_25\tMX ID\n");
for( i = 0; i < Profiles; i++ ) {
Printf("%i\t%i\t%i\t%02X\t%s\t%s\t%s\t%s\t%s\t%i\t%i\n",
i + 1,
Car[i].Power_kW == 63 ? 0 : Car[i].Power_kW,
Car[i].unknown_2,
Car[i].Engine_code,
Car[i].VIN_mask,
Car[i].Transmission,
Car[i].BodyType,
Car[i].Drivetrain,
(Car[i].FPA_installed == 'J' ? "Yes" : Car[i].FPA_installed == 'N' ? "No" : "Any"),
Car[i].unknown_25,
Car[i].MX_ID
);
}
}
// FUNCTIONS
void PrintHeader( char name[] ) {
Printf("\n%s\n", name);
if (!GEN25) {
Printf("BOOST\t\t\tHYBRID\t\t\tEFFICIENCY\n");
Printf("Normal\tSport\tEco\tNormal\tSport\tEco\tNormal\tSport\n");
}
}
ubyte get2HalfByte(ubyte source) {
return source >> 4;
}
ubyte get1HalfByte(ubyte source) {
return source & 0x0F;
}
// SHORT spreadsheets 8x12(16)
if (GEN25) {
// WORK IN PROGRESS
// WORK IN PROGRESS
// WORK IN PROGRESS
local int schema_type_byte_position = (Gain_table_flag == 3 ? 4 : 2);
local int original_line_length = schema_type_byte_position + 4;
local int current_line_length = original_line_length;
local int line_counter = 0;
local int profile = 0;
j = 0;
i = 0;
Printf("\nMX_Profile\n");
Printf("ID\t byte_1\t");
if (schema_type_byte_position == 4) {
Printf(" byte_2\t");
Printf(" byte_3\t");
}
Printf("Schemas\t");
Printf(" Comfort(1)\t Normal(2)\t Sport(3)\t Offroad(4)\t Eco(5)\t Race(6)\t Hybrid(8)\t \t");
Printf(" Comfort(1)\t Normal(2)\t Sport(3)\t Offroad(4)\t Eco(5)\t Race(6)\t Hybrid(8)\t ");
Printf("\n");
do {
if (j == 0) {
Printf("%i\t", line_counter+1);
}
j++;
if (j == schema_type_byte_position && MX_Profile[i] > 0) {
current_line_length +=4;
}
if ( j == schema_type_byte_position ) {
profile = get1HalfByte(MX_Profile[i]);
// if (profile > 127) {
// profile = 255 - profile;
// Printf("-");
// }
if (profile == 0) {
Printf("0 B\t");
} else if (profile == 1) {
Printf("1 M\t");
} else if (profile == 2) {
Printf("2 H\t");
} else if (profile == 3) {
Printf("3 HM\t");
} else if (profile == 4) {
Printf("4 C\t");
} else if (profile == 5) {
Printf("5 CM\t");
} else if (profile == 6) {
Printf("6 CH\t");
} else if (profile == 7) {
Printf("7 CHM\t");
} else if (profile == 8) {
Printf("8 BK\t");
} else {
Printf("%i unkwn\t", profile);
}
} else {
if ( j < schema_type_byte_position ) {
Printf("( %02i %02i ) \t", get1HalfByte(MX_Profile[i]), get2HalfByte(MX_Profile[i]) );
} else {
if ( j == schema_type_byte_position + 1 ||
j == schema_type_byte_position + 5 ||
j == schema_type_byte_position + 9
) {
Printf("[ ");
}
if ( j == schema_type_byte_position + 4 ||
j == schema_type_byte_position + 8 ||
j == schema_type_byte_position + 12
) {
Printf("%i\t]\t", get1HalfByte(MX_Profile[i]) + 1); // skip 8th unused half-byte
} else {
Printf("%i\t %i\t ", get1HalfByte(MX_Profile[i]) + 1, get2HalfByte(MX_Profile[i]) + 1);
}
}
}
if (j == current_line_length) {
Printf("\n");
line_counter++;
j = 0;
current_line_length = original_line_length;
}
i++;
} while (line_counter < 8);
Printf("%i bytes length\n", i);
/*
// WORK IN PROGRESS
// WORK IN PROGRESS
// WORK IN PROGRESS
Printf("\nSUM_data\n");
for ( j = 0; j < SUM_x; j++ ) {
for( i = 0; i < Profiles; i++ ) {
if (j == SUM_x-3) {
x = (float) SUM_data[i].value[j] / 65536;
Printf("%.2g\t", x);
} else if (j == SUM_x-2) {
x = (float) SUM_data[i].value[j] / 2048 * 16;
Printf("%.2g\t", x);
} else if (j == SUM_x-1) {
x = (float) SUM_data[i].value[j] / 2048 * 8;
Printf("%.2g\t", x);
} else {
x = (float) SUM_data[i].value[j] ;
Printf("%g\t", x);
}
}
Printf("\n");
};
// WORK IN PROGRESS
// WORK IN PROGRESS
// WORK IN PROGRESS
*/
}
PrintHeader("Gain_Effect (ST/TS_Gain)");
for ( j = 0; j < DEFAULTS_Effects; j++ ) {
for( i = 0; i < Profiles; i++ ) {
if (GEN25) {
x = (float) Gain_Effect[i].value[j] / (0xffff / 4);
Printf("%.3g\t", x);
} else {
// there is definitelly a rounding issue exists
// trying to compensate it with 1.0058 multiplier
x = (float) Gain_Effect[i].value[j] * 1.0058 / 16;
Printf("%.4g°\t", x);
}
}
Printf("\n");
};
PrintHeader("Phase_Effect (ST/TS_Phase)");
for ( j = 0; j < DEFAULTS_Effects; j++ ) {
for( i = 0; i < Profiles; i++ ) {
x = (float) Phase_Effect[i].value[j];
if (GEN25) {
x = (float) Phase_Effect[i].value[j] / (0xFFFF / (2 * 3.14159265359)); // 2Pi / 65536
}
Printf("%.3g\t", x);
}
Printf("\n");
};
PrintHeader("Pitch_Shift_Effect (ST/TS_Pitch-Shift)");
for ( j = 0; j < DEFAULTS_Effects; j++ ) {
for( i = 0; i < Profiles; i++ ) {
x = (float) Pitch_Shift_Effect[i].value[j] / 0xffff;
if (GEN25) {
x *= 1.4265; // FMax value
}
Printf("%.3g\t", x);
}
Printf("\n");
};
PrintHeader("Delay_Effect (ST/TS_Delay)");
for ( j = 0; j < DEFAULTS_Effects; j++ ) {
for( i = 0; i < Profiles; i++ ) {
x = (float) Delay_Effect[i].value[j] / 0xffff;
if (GEN25) {
x *= 0.01024; // 0.005 / 65536
}
Printf("%.2g\t", x);
}
Printf("\n");
};
// BYTE spreadsheets 8x12(16)
PrintHeader("Effects_to_Accel (MX_m_Gain)");
for ( j = 0; j < DEFAULTS_Effects; j++ ) {
for( i = 0; i < Profiles; i++ ) {
Printf("%i\t", Effects_to_Accel[i].value[j] + 1); // not sure do we need this +1
}
Printf("\n");
};
PrintHeader("Effects_to_Revs (MX_n_Gain)");
for ( j = 0; j < DEFAULTS_Effects; j++ ) {
for( i = 0; i < Profiles; i++ ) {
Printf("%i\t", Effects_to_Revs[i].value[j] + 1); // not sure do we need this +1
}
Printf("\n");
};
PrintHeader("Effects_to_Speed (MX_v_Gain)");
for ( j = 0; j < DEFAULTS_Effects; j++ ) {
for( i = 0; i < Profiles; i++ ) {
Printf("%i\t", Effects_to_Speed[i].value[j] + 1); // not sure do we need this +1
}
Printf("\n");
};
if (GEN25) {
PrintHeader("Effects_to_Pedal (MX_p_Gain)");
for ( j = 0; j < DEFAULTS_Effects; j++ ) {
for( i = 0; i < Profiles; i++ ) {
Printf("%i\t", Effects_to_Pedal[i].value[j] + 1); // not sure do we need this +1
}
Printf("\n");
};
PrintHeader("Effects_to_Samples (MX_Sig)");
for ( j = 0; j < DEFAULTS_Effects; j++ ) {
for( i = 0; i < Profiles; i++ ) {
Printf("%i\t", Effects_to_Samples[i].value[j] + 1); // not sure do we need this +1
}
Printf("\n");
};
} else {
if (Gain_table_flag > 0) {
PrintHeader("Effects_to_Profiles");
for ( j = 0; j < DEFAULTS_Effects; j++ ) {
for( i = 0; i < Profiles; i++ ) {
Printf("%i\t", Effects_to_Profiles[i].value[j] + 1); // not sure do we need this +1
}
Printf("\n");
};
}
PrintHeader("Effects_to_Samples (MX_Sig)");
for ( j = 0; j < 8; j++ ) {
Printf("%.3g\t", (float) Effects_to_Samples.gain[j] / 0xffff * 2); // 0 < X < 1 // Q:65536
}
Printf("GAIN");
Printf("\n");
for ( j = 0; j < 8; j++ ) {
Printf("%.3g\t", (float) Effects_to_Samples.clip[j] / 0xffff * 512); // 0 < X < 8 // Q:65536
}
Printf("CLIP");
Printf("\n");
}
Printf("\nAcceleration (LIB_m_Gain)\nHEADER\tDATA\n");
for( i = 0; i < DEFAULTS_Acceleration_length; i++ ) {
Printf("%.2f", (float) Acceleration_Scale[i] / 32768 - 1);
for( j = 0; j < AccelFunctions; j++ ) {
Printf("\t%.4f", (float) Acceleration[j].value[i] / 0xffff);
}
Printf("\n");
}
Printf("\nRevolutions (LIB_n_Gain)\nHEADER\tDATA\n");
for( i = 0; i < DEFAULTS_Revolutions_length; i++ ) {
Printf("%i", (float) Revolutions_Scale[i] / 4);
for( j = 0; j < 16; j++ ) {
Printf("\t%.4f", (float) Revolutions[j].value[i] / 0xffff);
}
Printf("\n");
}
Printf("\nSpeed (LIB_v_Gain)\nHEADER\tDATA\n");
for( i = 0; i < DEFAULTS_Speed_length; i++ ) {
// real scale for this header column is the percentage [0 - 100%] from 326.39 value
// multipliying it to 3.2639 shows absolute speed
// (VW e-UP! is limited to 150kmh)
Printf("%.2f", (float) Speed_Scale[i] / 326.39 * 3.2639);
for( j = 0; j < SpeedFunctions; j++ ) {
Printf("\t%.4f", (float) Speed[j].value[i] / 0xffff);
}
Printf("\n");
}
if (GEN25) {
Printf("\nPedal (LIB_p_Gain)\nHEADER\tDATA\n");
for( i = 0; i < DEFAULTS_Pedal_length; i++ ) {
Printf("%.2f", (float) Pedal_Scale[i] / 0xffff);
for( j = 0; j < PedalFunctions; j++ ) {
Printf("\t%.4f", (float) Pedal[j].value[i] / 0xffff);
}
Printf("\n");
}
}
/*
Printf("\nSamples (LIB_Sig) %i length x %i\nHEADER\tDATA\n", getIntegerSampleRate(Sample_Rate), Samples_count);
for( i = 0; i < getIntegerSampleRate(Sample_Rate); i++ ) {
for( j = 0; j < Samples_count; j++ ) {
Printf("%i\t", (float) Samples[j].value[i]);
}
Printf("\n");
}
*/
local int checksum = -1;
for (j = start;j < end; j += 2) {
checksum = checksum + ReadUShort(j);
}
checksum = (checksum & 0xffff) ^ 0xffff;
local int name_checksum = Checksum(CHECKSUM_CRCCCITT, 64, 64, -1, -1); // algo, size, length, poly, init
Printf("\nFILE CHECKSUM: %.04X", SwapBytes(checksum) >> 16 & 0x0000ffff);
Printf("\nNAME CHECKSUM: %.04X", SwapBytes(name_checksum) >> 16 & 0x0000ffff);