3 Math and matrix functions, misc tools
5 Extension module for the rfxswf library.
6 Part of the swftools package.
8 Copyright (c) 2000, 2001 Rainer Böhme <rfxswf@reflex-studio.de>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
24 // Matrix & Math tools for SWF files
27 SFIXED RFXSWF_SP(SFIXED a1,SFIXED a2,SFIXED b1,SFIXED b2)
29 a = (S64)a1*(S64)b1+(S64)a2*(S64)b2;
30 return (SFIXED)(a>>16);
32 SFIXED RFXSWF_QFIX(int zaehler,int nenner) // bildet Quotient von zwei INTs in SFIXED
33 { S64 z = zaehler<<16;
34 S64 a = z/(S64)nenner;
39 MATRIX * swf_MatrixJoin(MATRIX * d,MATRIX * s1,MATRIX * s2)
42 if (!s1) return (s2)?(MATRIX *)memcpy(d,s2,sizeof(MATRIX)):NULL;
43 if (!s2) return (MATRIX *)memcpy(d,s1,sizeof(MATRIX));
45 d->tx = s1->tx + s2->tx;
46 d->ty = s1->ty + s2->ty;
48 d->sx = RFXSWF_SP(s1->sx,s1->r1,s2->sx,s2->r0);
49 d->sy = RFXSWF_SP(s1->r0,s1->sy,s2->r1,s2->sy);
50 d->r0 = RFXSWF_SP(s1->r0,s1->sy,s2->sx,s2->r0);
51 d->r1 = RFXSWF_SP(s1->sx,s1->r1,s2->r1,s2->sy);
58 MATRIX * swf_MatrixMapTriangle(MATRIX * m,int dx,int dy,int x0,int y0,
59 int x1,int y1,int x2,int y2)
66 if ((!dx)||(!dy)) return NULL; // check DIV by zero
70 m->sx = RFXSWF_QFIX(dx1,dx);
71 m->sy = RFXSWF_QFIX(dy2,dy);
72 m->r0 = RFXSWF_QFIX(dy1,dx);
73 m->r1 = RFXSWF_QFIX(dx2,dy);
78 void swf_SetDefineID(TAG * tag, U16 newid)
80 int oldlen = tag->len;
82 swf_SetU16(tag, newid); /* set defining ID */
86 U16 swf_GetDefineID(TAG * t)
91 oldTagPos = swf_GetTagPos(t);
94 switch (swf_GetTagID(t))
95 { case ST_DEFINESHAPE:
98 case ST_DEFINEMORPHSHAPE:
99 case ST_DEFINEEDITTEXT:
101 case ST_DEFINEBITSJPEG2:
102 case ST_DEFINEBITSJPEG3:
103 case ST_DEFINEBITSLOSSLESS:
104 case ST_DEFINEBITSLOSSLESS2:
105 case ST_DEFINEBUTTON:
106 case ST_DEFINEBUTTON2:
107 case ST_DEFINEBUTTONCXFORM: //pseudodefine
108 case ST_DEFINEBUTTONSOUND: //pseudodefine
111 case ST_DEFINEFONTINFO: //pseudodefine
112 case ST_DEFINEFONTINFO2: //pseudodefine
116 case ST_DEFINESPRITE:
118 case ST_DEFINEVIDEOSTREAM:
119 case ST_GLYPHNAMES: //pseudodefine
120 case ST_VIDEOFRAME: //pseudodefine
121 case ST_NAMECHARACTER: //pseudodefine
122 case ST_DOINITACTION: //pseudodefine
126 fprintf(stderr, "rfxswf: Error: tag %d (%s) has no id\n", t->id, swf_TagGetName(t));
129 swf_SetTagPos(t,oldTagPos);
134 SRECT swf_GetDefineBBox(TAG * t)
139 memset(&b1, 0, sizeof(b1));
141 oldTagPos = swf_GetTagPos(t);
146 switch (swf_GetTagID(t))
147 { case ST_DEFINESHAPE:
148 case ST_DEFINESHAPE2:
149 case ST_DEFINESHAPE3:
150 case ST_DEFINEEDITTEXT:
153 case ST_DEFINEVIDEOSTREAM:
157 case ST_DEFINEMORPHSHAPE:
161 swf_ExpandRect2(&b1, &b2);
163 case ST_DEFINEBITSLOSSLESS:
164 case ST_DEFINEBITSLOSSLESS2:
166 case ST_DEFINEBITSJPEG2:
167 case ST_DEFINEBITSJPEG3:
172 swf_SetTagPos(t,oldTagPos);
177 U16 swf_GetPlaceID(TAG * t)
182 oldTagPos = swf_GetTagPos(t);
185 switch (swf_GetTagID(t))
186 { case ST_PLACEOBJECT:
187 case ST_REMOVEOBJECT:
188 case ST_FREECHARACTER:
193 case ST_PLACEOBJECT2:
194 { U8 flags = swf_GetU8(t);
195 U16 d = swf_GetU16(t);
196 id = (flags&PF_CHAR)?swf_GetU16(t):id;
201 swf_SetTagPos(t,oldTagPos);
206 static int swf_definingtagids[] =
219 ST_DEFINEBITSLOSSLESS,
220 ST_DEFINEBITSLOSSLESS2,
226 ST_DEFINEVIDEOSTREAM,
230 // tags which may be used inside a sprite definition
231 static int swf_spritetagids[] =
236 ST_REMOVEOBJECT2, //?
247 static int swf_pseudodefiningtagids[] =
251 ST_DEFINEBUTTONCXFORM,
252 ST_DEFINEBUTTONSOUND,
260 U8 swf_isAllowedSpriteTag(TAG * tag)
264 while(swf_spritetagids[t]>=0)
266 if(swf_spritetagids[t] == id)
273 U8 swf_isDefiningTag(TAG * tag)
277 while(swf_definingtagids[t]>=0)
279 if(swf_definingtagids[t] == id)
286 U8 swf_isPseudoDefiningTag(TAG * tag)
290 while(swf_pseudodefiningtagids[t]>=0)
292 if(swf_pseudodefiningtagids[t] == id)
299 int swf_GetDepth(TAG * t)
303 oldTagPos = swf_GetTagPos(t);
306 switch (swf_GetTagID(t))
307 { case ST_PLACEOBJECT:
308 case ST_REMOVEOBJECT:
310 depth = swf_GetU16(t);
312 case ST_REMOVEOBJECT2:
313 depth = swf_GetU16(t);
315 case ST_PLACEOBJECT2:
316 { U8 flags = swf_GetU8(t);
317 depth = swf_GetU16(t);
321 depth = swf_GetU16(t);
324 swf_SetTagPos(t,oldTagPos);
328 void swf_SetDepth(TAG * t, U16 depth)
330 switch (swf_GetTagID(t))
331 { case ST_PLACEOBJECT:
332 case ST_REMOVEOBJECT:
333 PUT16(t->data, depth);
335 case ST_REMOVEOBJECT2:
336 PUT16(t->data, depth);
338 case ST_PLACEOBJECT2:
339 PUT16(&t->data[1], depth);
342 PUT16(t->data, depth);
345 fprintf(stderr, "rfxswf: Error: tag %d has no depth\n", t->id);
349 char* swf_GetName(TAG * t)
355 oldTagPos = swf_GetTagPos(t);
357 switch(swf_GetTagID(t))
360 name = &t->data[swf_GetTagPos(t)];
362 case ST_PLACEOBJECT2: {
363 U8 flags = swf_GetU8(t);
364 swf_GetU16(t); //depth;
368 swf_GetMatrix(t, &m);
370 swf_GetCXForm(t, &c, 1);
373 if(flags&PF_CLIPACTION)
376 swf_ResetReadBits(t);
377 name = &t->data[swf_GetTagPos(t)];
382 swf_SetTagPos(t,oldTagPos);
386 /* used in enumerateUsedIDs */
387 void swf_GetMorphGradient(TAG * tag, GRADIENT * gradient1, GRADIENT * gradient2)
397 gradient2->num = swf_GetU8(tag);
398 for(t=0;t<gradient1->num;t++)
403 gradient1->ratios[t] = swf_GetU8(tag);
404 swf_GetRGBA(tag, &gradient1->rgba[t]);
405 gradient2->ratios[t] = swf_GetU8(tag);
406 swf_GetRGBA(tag, &gradient2->rgba[t]);
410 #define DEBUG_ENUMERATE if(0)
412 static void enumerateUsedIDs_styles(TAG * tag, void (*callback)(TAG*, int, void*), void*callback_data, int num, int morph)
416 count = swf_GetU8(tag);
417 if(count == 0xff && num>1) // defineshape2,3 only
418 count = swf_GetU16(tag);
424 swf_ResetReadBits(tag);
425 type = swf_GetU8(tag); //type
428 {swf_GetRGBA(tag, NULL);if(morph) swf_GetRGBA(tag, NULL);}
430 {swf_GetRGB(tag, NULL);if(morph) swf_GetRGB(tag, NULL);}
432 else if(type == 0x10 || type == 0x12)
434 swf_ResetReadBits(tag);
435 swf_GetMatrix(tag, NULL);
437 swf_GetMatrix(tag, NULL);
438 swf_ResetReadBits(tag);
440 swf_GetMorphGradient(tag, NULL, NULL);
442 swf_GetGradient(tag, NULL, /*alpha*/ num>=3?1:0);
444 else if(type == 0x40 || type == 0x41)
446 swf_ResetReadBits(tag);
448 if(tag->data[tag->pos] != 0xff ||
449 tag->data[tag->pos+1] != 0xff)
450 (callback)(tag, tag->pos, callback_data);
453 swf_ResetReadBits(tag);
454 swf_GetMatrix(tag, NULL);
456 swf_GetMatrix(tag, NULL);
459 fprintf(stderr, "rfxswf:swftools.c Unknown fillstyle:0x%02x\n",type);
462 swf_ResetReadBits(tag);
463 count = swf_GetU8(tag); // line style array
465 count = swf_GetU16(tag);
472 {swf_GetRGBA(tag, NULL);if(morph) swf_GetRGBA(tag, NULL);}
474 {swf_GetRGB(tag, NULL);if(morph) swf_GetRGB(tag, NULL);}
478 void enumerateUsedIDs(TAG * tag, int base, void (*callback)(TAG*, int, void*), void*callback_data)
481 swf_ResetReadBits(tag);
485 case ST_DEFINEBUTTONCXFORM: {
487 callback(tag, tag->pos + base, callback_data);
490 callback(tag, tag->pos + base, callback_data);
491 swf_GetU16(tag); //sound id
492 flags = swf_GetU8(tag);
494 swf_GetU32(tag); // in point
496 swf_GetU32(tag); // out points
498 swf_GetU16(tag); // loop count
501 int npoints = swf_GetU8(tag);
503 for(s=0;s<npoints;s++)
512 case ST_DEFINEBUTTONSOUND:
513 callback(tag, tag->pos + base, callback_data); //button id
516 case ST_EXPORTASSETS: {
517 int num = swf_GetU16(tag);
520 callback(tag, tag->pos + base, callback_data); //button id
521 swf_GetU16(tag); //id
522 while(swf_GetU8(tag)); //name
526 case ST_FREECHARACTER: /* unusual tags, which all start with an ID */
527 case ST_NAMECHARACTER:
528 case ST_GENERATORTEXT:
529 callback(tag, tag->pos + base, callback_data);
532 callback(tag, tag->pos + base, callback_data);
534 case ST_PLACEOBJECT2:
535 // only if placeflaghascharacter
536 if(!(tag->data[0]&2))
538 callback(tag, 3 + base, callback_data);
540 case ST_REMOVEOBJECT:
541 callback(tag, tag->pos + base, callback_data);
544 callback(tag, tag->pos + base, callback_data);
546 case ST_DEFINESPRITE: {
548 break; // sprite is expanded
550 swf_GetU16(tag); // id
551 swf_GetU16(tag); // framenum
554 U16 flags = swf_GetU16(tag);
557 TAG *tag2 = swf_InsertTag(NULL, id);
560 len = swf_GetU32(tag);
563 tag2->len = tag2->memsize = len;
564 tag2->data = rfx_alloc(len);
565 memcpy(tag2->data, &tag->data[tag->pos], len);
566 /* I never saw recursive sprites, but they are (theoretically)
567 possible, so better add base here again */
568 enumerateUsedIDs(tag2, tag->pos + base, callback, callback_data);
570 swf_GetBlock(tag, NULL, len);
574 case ST_DEFINEBUTTON2: // has some font ids in the button records
577 case ST_DEFINEBUTTON: {
578 swf_GetU16(tag); //button id
582 swf_GetU8(tag); //flag
583 offset = swf_GetU16(tag); //offset
588 if(!swf_GetU8(tag)) //flags
590 callback(tag, tag->pos + base, callback_data);
591 swf_GetU16(tag); //char
592 swf_GetU16(tag); //layer
593 swf_ResetReadBits(tag);
594 swf_GetMatrix(tag, NULL);
596 swf_ResetReadBits(tag);
597 swf_GetCXForm(tag, NULL, 1);
603 case ST_DEFINEEDITTEXT: {
605 swf_GetU16(tag); //id
606 swf_GetRect(tag, NULL); //bounding box
607 swf_ResetReadBits(tag);
608 flags1 = swf_GetU8(tag);
609 flags2 = swf_GetU8(tag);
611 callback(tag, tag->pos + base, callback_data);
616 case ST_DEFINETEXT: {
617 int glyphbits, advancebits;
619 id = swf_GetU16(tag); //id
620 swf_GetRect(tag, NULL); //bounding box
621 swf_ResetReadBits(tag);
622 swf_GetMatrix(tag, NULL); //matrix
623 swf_ResetReadBits(tag);
624 glyphbits = swf_GetU8(tag); //glyphbits
625 advancebits = swf_GetU8(tag); //advancebits
628 swf_ResetReadBits(tag);
629 flags = swf_GetBits(tag, 8);
631 if(flags & 128) // text style record
633 swf_ResetReadBits(tag);
634 if(flags & 8) { // hasfont
635 callback(tag, tag->pos + base, callback_data);
636 id = swf_GetU16(tag);
638 if(flags & 4) { // hascolor
639 if(num==1) swf_GetRGB(tag, NULL);
640 else swf_GetRGBA(tag, NULL);
642 if(flags & 2) { //has x offset
643 swf_ResetReadBits(tag);
646 if(flags & 1) { //has y offset
647 swf_ResetReadBits(tag);
650 if(flags & 8) { //has height
651 swf_ResetReadBits(tag);
654 } else { // glyph record
656 swf_ResetReadBits(tag);
657 for(t=0;t<flags;t++) {
658 swf_GetBits(tag, glyphbits);
659 swf_GetBits(tag, advancebits);
666 case ST_DEFINEFONTINFO:
667 case ST_DEFINEFONTINFO2:
669 callback(tag, tag->pos + base, callback_data);
671 case ST_DEFINEVIDEOSTREAM:
674 case ST_DOINITACTION:
675 callback(tag, tag->pos + base, callback_data);
678 case ST_DEFINEMORPHSHAPE:
679 case ST_DEFINESHAPE3:
681 case ST_DEFINESHAPE2:
683 case ST_DEFINESHAPE: {
689 if(tag->id == ST_DEFINEMORPHSHAPE) {
694 id = swf_GetU16(tag); // id;
695 swf_GetRect(tag, NULL); // bounds
697 swf_ResetReadBits(tag);
698 swf_GetRect(tag, NULL); // bounds2
699 swf_GetU32(tag); //offset to endedges
702 DEBUG_ENUMERATE printf("Tag:%d Name:%s ID:%d\n", tag->id, swf_TagGetName(tag), id);
704 enumerateUsedIDs_styles(tag, callback, callback_data, num, morph);
705 DEBUG_ENUMERATE printf("-------\n");
706 while(--numshapes>=0) /* morph shapes define two shapes */
708 DEBUG_ENUMERATE printf("shape:%d\n", numshapes);
709 fillbits = swf_GetBits(tag, 4);
710 linebits = swf_GetBits(tag, 4);
711 DEBUG_ENUMERATE printf("%d %d\n", fillbits, linebits);
712 swf_ResetReadBits(tag);
715 flags = swf_GetBits(tag, 1);
716 if(!flags) { //style change
717 flags = swf_GetBits(tag, 5);
721 int n = swf_GetBits(tag, 5);
723 x = swf_GetBits(tag, n); //x
724 y = swf_GetBits(tag, n); //y
725 DEBUG_ENUMERATE printf("move %f %f\n",x/20.0,y/20.0);
727 if(flags&2) { //fill0
729 fill0 = swf_GetBits(tag, fillbits);
730 DEBUG_ENUMERATE printf("fill0 %d\n", fill0);
732 if(flags&4) { //fill1
734 fill1 = swf_GetBits(tag, fillbits);
735 DEBUG_ENUMERATE printf("fill1 %d\n", fill1);
737 if(flags&8) { //linestyle
739 line = swf_GetBits(tag, linebits);
740 DEBUG_ENUMERATE printf("linestyle %d\n",line);
743 DEBUG_ENUMERATE printf("more fillstyles\n");
744 enumerateUsedIDs_styles(tag, callback, callback_data, num, 0);
745 fillbits = swf_GetBits(tag, 4);
746 linebits = swf_GetBits(tag, 4);
749 flags = swf_GetBits(tag, 1);
750 if(flags) { //straight edge
751 int n = swf_GetBits(tag, 4) + 2;
752 if(swf_GetBits(tag, 1)) { //line flag
754 x = swf_GetSBits(tag, n); //delta x
755 y = swf_GetSBits(tag, n); //delta y
756 DEBUG_ENUMERATE printf("line %f %f\n",x/20.0,y/20.0);
758 int v=swf_GetBits(tag, 1);
760 d = swf_GetSBits(tag, n); //vert/horz
761 DEBUG_ENUMERATE printf("%s %f\n",v?"vertical":"horizontal", d/20.0);
763 } else { //curved edge
764 int n = swf_GetBits(tag, 4) + 2;
766 x1 = swf_GetSBits(tag, n);
767 y1 = swf_GetSBits(tag, n);
768 x2 = swf_GetSBits(tag, n);
769 y2 = swf_GetSBits(tag, n);
770 DEBUG_ENUMERATE printf("curve %f %f %f %f\n", x1/20.0, y1/20.0, x2/20.0, y2/20.0);
782 void callbackCount(TAG * t,int pos, void*ptr)
785 DEBUG_ENUMERATE printf("callback(%d) %d\n", pos, *(U16*)&t->data[pos]);
788 void callbackFillin(TAG * t,int pos, void*ptr)
792 DEBUG_ENUMERATE printf("callback(%d) %d\n", pos, *(U16*)&t->data[pos]);
795 int swf_GetNumUsedIDs(TAG * t)
798 enumerateUsedIDs(t, 0, callbackCount, &num);
802 void swf_GetUsedIDs(TAG * t, int * positions)
804 int * ptr = positions;
805 enumerateUsedIDs(t, 0, callbackFillin, &ptr);
808 void swf_Relocate (SWF*swf, char*bitmap)
812 memset(slaveids, -1, sizeof(slaveids));
820 if(swf_isDefiningTag(tag))
825 id = swf_GetDefineID(tag); //own id
827 if(!bitmap[id]) { //free
832 for (t=1;t<65536;t++)
842 slaveids[id] = newid;
844 swf_SetDefineID(tag, newid);
847 num = swf_GetNumUsedIDs(tag);
849 ptr = rfx_alloc(sizeof(int)*num);
850 swf_GetUsedIDs(tag, ptr);
853 int id = GET16(&tag->data[ptr[t]]);
855 fprintf(stderr, "swf_Relocate: Mapping id never encountered before: %d\n", id);
859 PUT16(&tag->data[ptr[t]], id);
866 void swf_RelocateDepth(SWF*swf, char*bitmap)
871 for(nr=65535;nr>=0;nr--) {
875 // now nr is the highest used depth. So we start
876 // assigning depths at nr+1
881 /* TODO * clip depths
884 int depth = swf_GetDepth(tag);
886 int newdepth = depth+nr;
888 fprintf(stderr, "Couldn't relocate depths: too large values\n");
891 swf_SetDepth(tag, newdepth);
897 U8 swf_isShapeTag(TAG*tag)
899 if(tag->id == ST_DEFINESHAPE ||
900 tag->id == ST_DEFINESHAPE2 ||
901 tag->id == ST_DEFINESHAPE3)
906 U8 swf_isImageTag(TAG*tag)
908 if(tag->id == ST_DEFINEBITSJPEG ||
909 tag->id == ST_DEFINEBITSJPEG2 ||
910 tag->id == ST_DEFINEBITSJPEG3 ||
911 tag->id == ST_DEFINEBITSLOSSLESS ||
912 tag->id == ST_DEFINEBITSLOSSLESS2)
917 TAG* swf_Concatenate (TAG*list1,TAG*list2)
919 TAG*tag=0,*lasttag=0;
921 char depthmap[65536];
923 memset(bitmap, 0, sizeof(bitmap));
924 memset(depthmap, 0, sizeof(depthmap));
925 memset(&swf1, 0, sizeof(swf1));
926 memset(&swf2, 0, sizeof(swf2));
928 swf1.firstTag = list1;
930 swf2.firstTag = list2;
935 if(!swf_isDefiningTag(tag)) {
936 int id = swf_GetDefineID(tag);
939 if(tag->id == ST_PLACEOBJECT ||
940 tag->id == ST_PLACEOBJECT2) {
941 int depth = swf_GetDepth(tag);
944 if(tag->id == ST_REMOVEOBJECT ||
945 tag->id == ST_REMOVEOBJECT2) {
946 int depth = swf_GetDepth(tag);
952 swf_Relocate(&swf2, bitmap);
953 swf_RelocateDepth(&swf2, depthmap);
954 lasttag->next = swf2.firstTag;
955 swf2.firstTag->prev = lasttag;
957 return swf1.firstTag;
960 static int tagHash(TAG*tag)
963 unsigned int a = 0x6b973e5a;
964 /* start at pos 2, as 0 and 1 are the id */
965 for(t=2;t<tag->len;t++) {
968 a += tag->data[t]*0xefbc35a5*b*(t+1);
970 return a&0x7fffffff; //always return positive number
973 void swf_Optimize(SWF*swf)
975 const int hash_size = 131072;
976 char* dontremap = rfx_calloc(sizeof(char)*65536);
977 U16* remap = rfx_alloc(sizeof(U16)*65536);
978 TAG* id2tag = rfx_calloc(sizeof(TAG*)*65536);
979 TAG** hashmap = rfx_calloc(sizeof(TAG*)*hash_size);
982 for(t=0;t<65536;t++) {
990 /* make sure we don't remap to this tag,
991 as it might have different "helper tags"
992 FIXME: a better way would be to compare
993 the helper tags, too.
995 if(swf_isPseudoDefiningTag(tag) &&
996 tag->id != ST_NAMECHARACTER) {
997 dontremap[swf_GetDefineID(tag)] = 1;
1001 tag = swf->firstTag;
1005 TAG*next = tag->next;
1008 int num = swf_GetNumUsedIDs(tag);
1009 int*positions = rfx_alloc(sizeof(int)*num);
1011 swf_GetUsedIDs(tag, positions);
1012 for(t=0;t<num;t++) {
1013 int id = GET16(&tag->data[positions[t]]);
1015 PUT16(&tag->data[positions[t]], id);
1017 rfx_free(positions);
1020 /* now look for previous tags with the same
1022 if(swf_isDefiningTag(tag)) {
1024 int id = swf_GetDefineID(tag);
1025 int hash = tagHash(tag);
1028 while((tag2 = hashmap[hash%hash_size])) {
1029 if(tag2 != (TAG*)(-1) && tag->len == tag2->len) {
1031 /* start at pos 2, as 0 and 1 are the id */
1032 for(t=2;t<tag->len;t++) {
1033 if(tag->data[t] != tag2->data[t])
1041 /* we found two identical tags- remap one
1043 remap[id] = swf_GetDefineID(tag2);
1049 while(hashmap[hash%hash_size]) hash++;
1050 hashmap[hash%hash_size] = tag;
1053 if(tag == swf->firstTag)
1054 swf->firstTag = next;
1057 } else if(swf_isPseudoDefiningTag(tag)) {
1058 int id = swf_GetDefineID(tag);
1060 /* if this tag was remapped, we don't
1061 need the helper tag anymore. Discard
1064 if(tag == swf->firstTag)
1065 swf->firstTag = next;
1072 rfx_free(dontremap);