forked from difcareer/010templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SWFTemplate.bt
executable file
·2205 lines (2051 loc) · 66.9 KB
/
SWFTemplate.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
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*************************************************************
* 010 Editor v3.0 Binary Template
*
* File: SWFTemplate.bt
* Author: Josh Zelonis <[email protected]>
* Revision: 1.2
* Purpose: Defines a template for parsing SWF files based on
* the file format specification for Flash 9. This is most
* compatible with Actionscript 1 and 2 as the Actionscript
* Byte Code has not been templated in.
* Changes: 1.1 - Updated email address
* 1.2 - Add code to check CWS file - TQN
*************************************************************/
/***************
* Action Tags *
***************/
local quad ActionTagEnd = 0;
local byte isCompressed = 0;
typedef struct {
ubyte Register;
string ParamName;
} REGISTERPARAM;
typedef struct {
string value;
} CONSTANTPOOL;
typedef struct {
string value;
} PARAMS;
typedef struct {
ubyte Type;
switch (Type) {
case 0:
string String;
break;
case 1:
float Float;
break;
case 4:
ubyte RegisterNumber;
break;
case 5:
ubyte Boolean;
break;
case 6:
double Double;
break;
case 7:
int Integer;
break;
case 8:
ubyte Constant8;
break;
case 9:
ushort Constant16;
break;
default:
Warning("Unexpected Value detected.");
}
} TYPECONST;
typedef struct {
local int i;
ubyte ActionCode;
if (ActionCode >=0x80) {
ushort Length;
ActionTagEnd = FTell() + Length;
}
switch (ActionCode) {
/************************
* SWF 3 Action Model *
************************/
case 0x81: /* ActionGotoFrame */
if (Length != 2) {
Warning("ActionGotoFrame: Length must be 2.");
}
ushort Frame;
break;
case 0x83: /* ActionGetURL */
string UrlString;
string TargetString;
break;
case 0x04: /* ActionNextFrame */
case 0x05: /* ActionPreviousFrame */
case 0x06: /* ActionPlay */
case 0x07: /* ActionStop */
case 0x08: /* ActionToggleQuality */
case 0x09: /* ActionStopSounds */
break;
case 0x8a: /* ActionWaitForFrame */
if (Length != 3) {
Warning("ActionWaitForFrame: Length must be 3.");
}
ushort Frame;
ubyte SkipCount;
break;
case 0x8b: /* ActionSetTarget */
string TargetName;
break;
case 0x8c: /* ActionGoToLabel */
string Label;
break;
/************************
* SWF 4 Action Model *
************************/
case 0x96: /* ActionPush */
do {
TYPECONST TypeConst;
} while (FTell() < ActionTagEnd);
break;
case 0x17: /* ActionPop */
case 0x0a: /* ActionAdd */
case 0x0b: /* ActionSubtract */
case 0x0c: /* ActionMultiply */
case 0x0d: /* ActionDivide */
case 0x0e: /* ActionEquals */
case 0x0f: /* ActionLess */
case 0x10: /* ActionAnd */
case 0x11: /* ActionOr */
case 0x12: /* ActionNot */
case 0x13: /* ActionStringEquals */
case 0x14: /* ActionStringLength */
case 0x21: /* ActionStringAdd */
case 0x15: /* ActionStringExtract */
case 0x29: /* ActionStringLess */
case 0x31: /* ActionMBStringLength */
case 0x35: /* ActionMBStringExtract */
case 0x18: /* ActionToInteger */
case 0x32: /* ActionCharToAscii */
case 0x33: /* ActionAsciiToChar */
case 0x36: /* ActionMBCharToAscii */
case 0x37: /* ActionMBAsciiToChar */
break;
case 0x99: /* ActionJump */
short BranchOffset;
break;
case 0x9d: /* ActionIf */
short BranchOffset;
break;
case 0x9e: /* ActionCall */
case 0x1c: /* ActionGetVariable */
case 0x1d: /* ActionSetVariable */
break;
case 0x9a: /* ActionGetURL2 */
ubyte SendVarsMethod : 2;
ubyte Reserved : 4;
ubyte LoadTargetFlag : 1;
ubyte LoadVariablesFlag : 1;
break;
case 0x9f: /* ActionGotoFrame2 */
ubyte Reserved : 6;
ubyte SceneBiasFlag : 1;
ubyte PlayFlag : 1;
if (SceneBiasFlag == 1) {
ushort SceneBias;
}
break;
case 0x20: /* ActionSetTarget2 */
case 0x22: /* ActionGetProperty */
case 0x23: /* ActionSetProperty */
case 0x24: /* ActionCloneSprite */
case 0x25: /* ActionRemoveSprite */
case 0x27: /* ActionStartDrag */
case 0x28: /* ActionEndDrag */
break;
case 0x8d: /* ActionWaitForFrame2 */
ubyte SkipCount;
break;
case 0x26: /* ActionTrace */
case 0x34: /* ActionGetTime */
case 0x30: /* ActionRandomNumber */
break;
/************************
* SWF 5 Action Model *
************************/
case 0x3d: /* ActionCallFunction */
case 0x52: /* ActionCallMethod */
break;
case 0x88: /* ActionConstantPool */
ushort Count;
for (i=0; i<Count; i++) {
CONSTANTPOOL Constant;
}
break;
case 0x9b: /* ActionDefineFunction */
string FunctionName;
ushort NumParams;
for (i=0; i<NumParams; i++) {
PARAMS Param;
}
ushort codeSize;
break;
case 0x3c: /* ActionDefineLocal */
case 0x41: /* ActionDefineLocal2 */
case 0x3a: /* ActionDelete */
case 0x3b: /* ActionDelete2 */
case 0x46: /* ActionEnumerate */
case 0x49: /* ActionEquals2 */
case 0x4e: /* ActionGetMember */
case 0x42: /* ActionInitArray */
case 0x43: /* ActionInitObject */
case 0x53: /* ActionNewMethod */
case 0x40: /* ActionNewObject */
case 0x4f: /* ActionSetMember */
case 0x45: /* ActionTargetPath */
break;
case 0x94: /* ActionWith */
ushort Size;
break;
case 0x4a: /* ActionToNumber */
case 0x4b: /* ActionToString */
case 0x44: /* ActionTypeOf */
case 0x47: /* ActionAdd2 */
case 0x48: /* ActionLess2 */
case 0x3f: /* ActionModulo */
case 0x60: /* ActionBitAnd */
case 0x63: /* ActionBitLShift */
case 0x61: /* ActionBitOr */
case 0x64: /* ActionBitRShift */
case 0x65: /* ActionBitURShift */
case 0x62: /* ActionBitXor */
case 0x51: /* ActionDecrement */
case 0x50: /* ActionIncrement */
case 0x4c: /* ActionPushDuplicate */
case 0x3e: /* ActionReturn */
case 0x4d: /* ActionStackSwap */
break;
case 0x87: /* ActionStoreRegister */
ubyte RegisterNumber;
break;
/************************
* SWF 6 Action Model *
************************/
case 0x55: /* ActionEnumerate2 */
case 0x66: /* ActionStrictEquals */
case 0x67: /* ActionGreater */
case 0x68: /* ActionStringGreater */
break;
/************************
* SWF 7 Action Model *
************************/
case 0x8e: /* ActionDefineFunction2 */
string FunctionName;
ushort NumParams;
ubyte RegisterCount;
ubyte PreloadParentFlag : 1;
ubyte PreloadRootFlag : 1;
ubyte SuppressSuperFlag : 1;
ubyte PreloadSuperFlag : 1;
ubyte SuppressArgumentsFlag : 1;
ubyte PreloadArgumentsFlag : 1;
ubyte SuppressThisFlag : 1;
ubyte PreloadThisFlag : 1;
ubyte Reserved : 7;
ubyte PreloadGlobalFlag : 1;
for (i=0; i<NumParams; i++) {
REGISTERPARAM Parameter;
}
ushort codeSize;
break;
case 0x69: /* ActionExtends */
case 0x2b: /* ActionCastOp */
case 0x2c: /* ActionImplementsOp */
break;
case 0x8f: /* ActionTry */
ubyte Reserved : 5;
ubyte CatchInRegisterFlag : 1;
ubyte FinallyBlockFlag : 1;
ubyte CatchBlockFlag : 1;
ushort TrySize;
ushort CatchSize;
ushort FinallySize;
if (CatchInRegisterFlag == 0) {
string CatchName;
}
else {
ubyte CatchRegister;
}
if (TrySize) ubyte TryBody[TrySize];
if (CatchSize) ubyte CatchBody[CatchSize];
if (FinallySize) ubyte FinallyBody[FinallySize];
break;
case 0x2a: /* ActionThrow */
break;
/************************
* SWF 9 Action Model *
************************/
default: /* Undefined Behavior */
if (ActionCode>=0x80) {
ubyte Padding[ActionTagEnd - FTell()];
}
break;
}
/*****************************************
* This is a fixup for files that aren't
* parsing correctly. This may be due to
* my code, obfuscation techniques or
* other unknown circumstances.
*****************************************/
if (ActionCode>=0x80) {
if (ActionTagEnd>FTell()) {
ubyte Padding[ActionTagEnd-FTell()];
Printf("WARNING: ActionTag padded to 0x%LXh\n", FTell());
}
else if (ActionTagEnd<FTell()-1) {
Printf("WARNING: ActionTag overrun to 0x%LXh, expected end at 0x%LXh\n", FTell(), ActionTagEnd);
}
}
} ACTIONRECORD <read=GetActionType>;
string GetActionType(ACTIONRECORD &ActionTag)
{
string action;
ubyte ActionType = ActionTag.ActionCode;
switch (ActionType)
{
case 0x81: return "ActionGotoFrame";
case 0x83: return "ActionGetURL";
case 0x04: return "ActionNextFrame";
case 0x05: return "ActionPreviousFrame";
case 0x06: return "ActionPlay";
case 0x07: return "ActionStop";
case 0x08: return "ActionToggleQuality";
case 0x09: return "ActionStopSounds";
case 0x8a: return "ActionWaitForFrame";
case 0x8b: return "ActionSetTarget";
case 0x8c: return "ActionGoToLabel";
case 0x96: return "ActionPush";
case 0x17: return "ActionPop";
case 0x0a: return "ActionAdd";
case 0x0b: return "ActionSubtract";
case 0x0c: return "ActionMultiply";
case 0x0d: return "ActionDivide";
case 0x0e: return "ActionEquals";
case 0x0f: return "ActionLess";
case 0x10: return "ActionAnd";
case 0x11: return "ActionOr";
case 0x12: return "ActionNot";
case 0x13: return "ActionStringEquals";
case 0x14: return "ActionStringLength";
case 0x21: return "ActionStringAdd";
case 0x15: return "ActionStringExtract";
case 0x29: return "ActionStringLess";
case 0x31: return "ActionMBStringLength";
case 0x35: return "ActionMBStringExtract";
case 0x18: return "ActionToInteger";
case 0x32: return "ActionCharToAscii";
case 0x33: return "ActionAsciiToChar";
case 0x36: return "ActionMBCharToAscii";
case 0x37: return "ActionMBAsciiToChar";
case 0x99: return "ActionJump";
case 0x9d: return "ActionIf";
case 0x9e: return "ActionCall";
case 0x1c: return "ActionGetVariable";
case 0x1d: return "ActionSetVariable";
case 0x9a: return "ActionGetURL2";
case 0x9f: return "ActionGotoFrame2";
case 0x20: return "ActionSetTarget2";
case 0x22: return "ActionGetProperty";
case 0x23: return "ActionSetProperty";
case 0x24: return "ActionCloneSprite";
case 0x25: return "ActionRemoveSprite";
case 0x27: return "ActionStartDrag";
case 0x28: return "ActionEndDrag";
case 0x8d: return "ActionWaitForFrame2";
case 0x26: return "ActionTrace";
case 0x34: return "ActionGetTime";
case 0x30: return "ActionRandomNumber";
case 0x3d: return "ActionCallFunction";
case 0x52: return "ActionCallMethod";
case 0x88: return "ActionConstantPool";
case 0x9b: return "ActionDefineFunction";
case 0x3c: return "ActionDefineLocal";
case 0x41: return "ActionDefineLocal2";
case 0x3a: return "ActionDelete";
case 0x3b: return "ActionDelete2";
case 0x46: return "ActionEnumerate";
case 0x49: return "ActionEquals2";
case 0x4e: return "ActionGetMember";
case 0x42: return "ActionInitArray";
case 0x43: return "ActionInitObject";
case 0x53: return "ActionNewMethod";
case 0x40: return "ActionNewObject";
case 0x4f: return "ActionSetMember";
case 0x45: return "ActionTargetPath";
case 0x94: return "ActionWith";
case 0x4a: return "ActionToNumber";
case 0x4b: return "ActionToString";
case 0x44: return "ActionTypeOf";
case 0x47: return "ActionAdd2";
case 0x48: return "ActionLess2";
case 0x3f: return "ActionModulo";
case 0x60: return "ActionBitAnd";
case 0x63: return "ActionBitLShift";
case 0x61: return "ActionBitOr";
case 0x64: return "ActionBitRShift";
case 0x65: return "ActionBitURShift";
case 0x62: return "ActionBitXor";
case 0x51: return "ActionDecrement";
case 0x50: return "ActionIncrement";
case 0x4c: return "ActionPushDuplicate";
case 0x3e: return "ActionReturn";
case 0x4d: return "ActionStackSwap";
case 0x87: return "ActionStoreRegister";
case 0x55: return "ActionEnumerate2";
case 0x66: return "ActionStrictEquals";
case 0x67: return "ActionGreater";
case 0x68: return "ActionStringGreater";
case 0x8e: return "ActionDefineFunction2";
case 0x69: return "ActionExtends";
case 0x2b: return "ActionCastOp";
case 0x2c: return "ActionImplementsOp";
case 0x8f: return "ActionTry";
case 0x2a: return "ActionThrow";
case 0x00: return "END";
default: SPrintf(action, "%02Xh", ActionType);
}
return action;
}
/**************
* Data Types *
**************/
local quad SWFTagEnd;
local ushort CurrentTag;
typedef struct {
byte value;
} SI8;
typedef struct {
short value;
} SI16;
typedef struct {
int value;
} SI32;
typedef struct {
ubyte value;
} UI8;
typedef struct {
ushort value;
} UI16;
typedef struct {
uint value;
} UI32;
typedef struct {
quad value;
} UI64;
typedef struct {
int whole : 16;
int decimal : 16;
} FIXED;
typedef struct {
short whole : 8;
short decimal : 8;
} FIXED8;
typedef struct {
ushort sign : 1;
ushort exponent : 5;
ushort mantissa : 10;
} FLOAT16;
typedef struct {
BigEndian();
local int i=0;
do {
byte next : 1;
byte value : 7;
i++;
} while (i<5 & next);
} EncodedU32;
typedef struct {
do {
char character;
} while (character != 0x00);
} STRING;
typedef struct {
ubyte LanguageCode;
} LANGCODE;
typedef struct {
ubyte Red;
ubyte Green;
ubyte Blue;
} RGB;
typedef struct {
ubyte Red;
ubyte Green;
ubyte Blue;
ubyte Alpha;
} RGBA;
typedef struct {
ubyte Alpha;
ubyte Red;
ubyte Green;
ubyte Blue;
} ARGB;
/***********************************************
* The min values in this are going to look
* wrong because there isn't any pretty way
* for 010 to print an Nbits-bit signed number.
* The key is that the max values match expected
* values and because there isn't any variation
* on how the numbers are being calculated and
* no bit padding, we can assume these are
* correct.
***********************************************/
typedef struct {
ubyte Nbits : 5;
BitfieldDisablePadding();
int Xmin : Nbits;
int Xmax : Nbits;
int Ymin : Nbits;
int Ymax : Nbits;
BitfieldEnablePadding();
} RECT;
typedef struct {
BitfieldEnablePadding();
BitfieldLeftToRight();
ubyte HasScale : 1;
if (HasScale) {
ubyte NScaleBits : 5;
BitfieldDisablePadding();
int ScaleX : NScaleBits;
int ScaleY : NScaleBits;
}
ubyte HasRotate : 1;
if (HasRotate) {
ubyte NRotateBits : 5;
BitfieldDisablePadding();
int RotateSkew0 : NRotateBits;
int RotateSkew1 : NRotateBits;
}
ubyte NTranslateBits : 5;
BitfieldDisablePadding();
int TranslateX : NTranslateBits;
int TranslateY : NTranslateBits;
BitfieldEnablePadding();
} MATRIX;
typedef struct {
ushort Tag;
string Name;
} ASSETS;
typedef struct {
EncodedU32 Offset;
string Name;
} OFFSETANDNAME;
typedef struct {
BitfieldEnablePadding();
ubyte HasAddTerms : 1;
ubyte HasMultTerms : 1;
ubyte Nbits : 4;
BitfieldDisablePadding();
if (HasMultTerms) {
short RedMultTerm : Nbits;
short GreenMultTerm : Nbits;
short BlueMultTerm : Nbits;
}
if (HasAddTerms) {
short RedAddTerm : Nbits;
short GreenAddTerm : Nbits;
short BlueAddTerm : Nbits;
}
BitfieldEnablePadding();
} CXFORM;
typedef struct {
BitfieldEnablePadding();
ubyte HasAddTerms : 1;
ubyte HasMultTerms : 1;
ubyte Nbits : 4;
BitfieldDisablePadding();
if (HasMultTerms) {
short RedMultTerm : Nbits;
short GreenMultTerm : Nbits;
short BlueMultTerm : Nbits;
short AlphaMultTerm : Nbits;
}
if (HasAddTerms) {
short RedAddTerm : Nbits;
short GreenAddTerm : Nbits;
short BlueAddTerm : Nbits;
short AlphaAddTerm : Nbits;
}
BitfieldEnablePadding();
} CXFORMWITHALPHA;
typedef struct {
ushort ClipEventKeyUp : 1;
ushort ClipEventKeyDown : 1;
ushort ClipEventMouseUp : 1;
ushort ClipEventMouseDown : 1;
ushort ClipEventMouseMove : 1;
ushort ClipEventUnload : 1;
ushort ClipEventEnterFrame : 1;
ushort ClipEventLoad : 1;
ushort ClipEventDragOver : 1;
ushort ClipEventRollOut : 1;
ushort ClipEventRollOver : 1;
ushort ClipEventReleaseOutside : 1;
ushort ClipEventRelease : 1;
ushort ClipEventPress : 1;
ushort ClipEventInitialize : 1;
ushort ClipEventData : 1;
if (File.Header.Version >= 6) {
ushort Reserved : 5;
ushort ClipEventConstruct : 1;
ushort ClipEventKeyPress : 1;
ushort ClipEventDragout : 1;
ushort Reserved : 8;
}
} CLIPEVENTFLAGS;
typedef struct {
CLIPEVENTFLAGS EventFlags;
uint ActionRecordSize;
if ((File.Header.Version>5) && EventFlags.ClipEventKeyPress) {
ubyte KeyCode;
}
do {
ACTIONRECORD Action;
} while (Action.ActionCode!=0x00);
} CLIPACTIONRECORD;
typedef struct {
local uint clips;
ushort Reserved;
CLIPEVENTFLAGS AllEventFlags;
do {
CLIPACTIONRECORD ClipActionRecord;
} while ((SWFTagEnd-FTell())>9); /* min bytes in CLIPACTIONRECORD */
if (File.Header.Version>5) {
uint ClipActionEndFlag;
}
else {
ushort ClipActionEndFlag;
}
} CLIPACTIONS;
typedef struct {
float Matrix[20];
} COLORMATRIXFILTER;
typedef struct {
ubyte MatrixX;
ubyte MatrixY;
float Divisor;
float Bias;
float Matrix[MatrixX * MatrixY];
RGBA DefaultColor;
ubyte Reserved : 6;
ubyte Clamp : 1;
ubyte PreserveAlpha : 1;
} CONVOLUTIONFILTER;
typedef struct {
FIXED BlurX;
FIXED BlurY;
ubyte Passes : 5;
ubyte Reserved : 3;
} BLURFILTER;
typedef struct {
RGBA DropShadowColor;
FIXED BlurX;
FIXED BlurY;
FIXED Angle;
FIXED Distance;
FIXED8 Strength;
ubyte InnerShadow : 1;
ubyte Knockout : 1;
ubyte CompositeSource : 1;
ubyte Passes : 5;
} DROPSHADOWFILTER;
typedef struct {
RGBA GlowColor;
FIXED BlurX;
FIXED BlurY;
FIXED8 Strength;
ubyte InnerShadow : 1;
ubyte Knockout : 1;
ubyte CompositeSource : 1;
ubyte Passes : 5;
} GLOWFILTER;
typedef struct {
RGBA ShadowColor;
RGBA HighlightColor;
FIXED BlurX;
FIXED BlurY;
FIXED Angle;
FIXED Distance;
FIXED8 Strength;
ubyte InnerShadow : 1;
ubyte Knockout : 1;
ubyte CompositeSource : 1;
ubyte OnTop : 1;
ubyte Passes : 4;
} BEVELFILTER;
typedef struct {
ubyte Ratio;
if ((CurrentTag == 2) /* DefineShape */
|| (CurrentTag == 22)) { /* DefineShape2 */
RGB Color;
}
else { /* DefineShape3 */
RGBA Color;
}
} GRADRECORD;
typedef struct {
local short i;
ubyte SpreadMode : 2;
ubyte InterpolationMode : 2;
ubyte NumGradients : 4;
for (i=0; i<NumGradients; i++) {
GRADRECORD GradientRecord;
}
} GRADIENT;
typedef struct {
local short i;
ubyte SpreadMode : 2;
ubyte InterpolationMode : 2;
ubyte NumGradients : 4;
for (i=0; i<NumGradients; i++) {
GRADRECORD GradientRecord;
}
FIXED8 FocalPoint;
} FOCALGRADIENT;
typedef struct {
ubyte NumColors;
RGBA GradientColors[NumColors];
ubyte GradientRatio[NumColors];
FIXED BlurX;
FIXED BlurY;
FIXED Angle;
FIXED Distance;
FIXED8 Strength;
ubyte InnerShadow : 1;
ubyte Knockout : 1;
ubyte CompositeSource : 1;
ubyte OnTop : 1;
ubyte Passes : 4;
} GRADIENTGLOWFILTER;
typedef struct {
ubyte NumColors;
RGBA GradientColors[NumColors];
ubyte GradientRatio[NumColors];
FIXED BlurX;
FIXED BlurY;
FIXED Angle;
FIXED Distance;
FIXED8 Strength;
ubyte InnerShadow : 1;
ubyte Knockout : 1;
ubyte CompositeSource : 1;
ubyte OnTop : 1;
ubyte Passes : 4;
} GRADIENTBEVELFILTER;
typedef struct {
ushort FilterId;
switch (FilterId) {
case 0:
DROPSHADOWFILTER DropShadowFilter;
break;
case 1:
BLURFILTER BlurFilter;
break;
case 2:
GLOWFILTER GlowFilter;
break;
case 3:
BEVELFILTER BevelFilter;
break;
case 4:
GRADIENTGLOWFILTER GradientGlowFilter;
break;
case 5:
CONVOLUTIONFILTER ConvolutionFilter;
break;
case 6:
COLORMATRIXFILTER ColorMatrixFilter;
break;
case 7:
GRADIENTBEVELFILTER GradientBevelFilter;
break;
}
} FILTER;
typedef struct {
local ushort i;
ubyte NumberOfFilters;
for (i=0; i<NumberOfFilters; i++) {
FILTER Filter;
}
} FILTERLIST;
typedef struct {
ubyte FillStyleType;
switch (FillStyleType) {
case 0x00:
if ((CurrentTag == 2) /* DefineShape */
|| (CurrentTag == 22)) { /* DefineShape2 */
RGB Color;
}
else { /* DefineShape3 */
RGBA Color;
}
break;
case 0x10:
case 0x12:
MATRIX GradientMatrix;
GRADIENT Gradient;
break;
case 0x13:
FOCALGRADIENT Gradient;
break;
case 0x40:
case 0x41:
case 0x42:
case 0x43:
ushort BitmapId;
MATRIX BitmapMatrix;
break;
default:
break;
}
} FILLSTYLE;
typedef struct {
local ushort i;
ubyte FillStyleCount;
if (FillStyleCount == 0xff) {
UI16 FillStyleCountExtended;
for (i=0; i<FillStyleCount; i++) {
FILLSTYLE FillStyle;
}
}
else {
for (i=0; i<FillStyleCount; i++) {
FILLSTYLE FillStyle;
}
}
} FILLSTYLEARRAY;
typedef struct {
ushort Width;
if ((CurrentTag == 2) /* DefineShape */
|| (CurrentTag == 22)) { /* DefineShape2 */
RGB Color;
}
else { /* DefineShape3 */
RGBA Color;
}
} LINESTYLE;
typedef struct {
ushort Width;
ubyte StartCapStyle : 2;
ubyte JoinStyle : 2;
ubyte HasFillFlag : 1;
ubyte NoHScaleFlag : 1;
ubyte NoVScaleFlag : 1;
ubyte PixelHintingFlag : 1;
ubyte Reserved : 5;
ubyte NoClose : 1;
ubyte EndCapStyle : 2;
if (JoinStyle == 2) {
ushort MiterLimitFactor;
}
if (HasFillFlag) {
FILLSTYLE FillType;
}
else {
RGBA Color;
}
} LINESTYLE2;
typedef struct {
local ushort i;
BitfieldDisablePadding();
ubyte LineStyleCount;
if (LineStyleCount == 0xff) {
UI16 LineStyleCountExtended;
for (i=0; i<LineStyleCountExtended; i++) {
if ((CurrentTag == 2) /* DefineShape */
|| (CurrentTag == 22) /* DefineShape2 */
|| (CurrentTag == 32)) { /* DefineShape3 */
LINESTYLE LineStyle;
}
else if (CurrentTag == 83) { /* DefineShape4 */
LINESTYLE2 LineStyle;
}
}
}
else {
for (i=0; i<LineStyleCount; i++) {
if ((CurrentTag == 2) /* DefineShape */
|| (CurrentTag == 22) /* DefineShape2 */
|| (CurrentTag == 32)) { /* DefineShape3 */
LINESTYLE LineStyle;
}
else if (CurrentTag == 83) { /* DefineShape4 */
LINESTYLE2 LineStyle;
}
}
}
BitfieldEnablePadding();
} LINESTYLEARRAY;
typedef struct {
BitfieldDisablePadding();
ubyte TypeFlag : 1;
if (TypeFlag) {
ubyte StraightFlag : 1;
if (StraightFlag) { /* StraightEdgeRecord */
ubyte NumBits : 4;
ubyte GeneralLineFlag : 1;
if (GeneralLineFlag) {
int DeltaX : NumBits+2;
int DeltaY : NumBits+2;
}
else {
ubyte VertLineFlag : 1;
if (VertLineFlag) {
int DeltaY : NumBits+2;
}
else {
int DeltaX : NumBits+2;
}
}
}
else { /* CurvedEdgeRecord */
ubyte NumBits : 4;
int ControlDeltaX : NumBits+2;
int ControlDeltaY : NumBits+2;
int AnchorDeltaX : NumBits+2;
int AnchorDeltaY : NumBits+2;
}
}
else { /* StyleChangeRecord & EndShapeRecord */
ubyte StateNewStyles : 1;
ubyte StateLineStyle : 1;
ubyte StateFillStyle1 : 1;
ubyte StateFillStyle0 : 1;
ubyte StateMoveTo : 1;
if (StateMoveTo) {
ubyte MoveBits : 5;
int MoveDeltaX : MoveBits;
int MoveDeltaY : MoveBits;
}
if (StateFillStyle0) {