+
+void swf_SetPlaceObject(TAG * t,SWFPLACEOBJECT* obj)
+{
+ U8 flags;
+ if (!t) return ;
+ if(t->id == ST_PLACEOBJECT) {
+ swf_SetU16(t, obj->id);
+ swf_SetU16(t, obj->depth);
+ swf_SetMatrix(t, &obj->matrix);
+ swf_SetCXForm(t, &obj->cxform, 0);
+ } else {
+ int m = !isUnitMatrix(&obj->matrix);
+ int cx = !isUnitCXForm(&obj->cxform);
+
+ flags = (obj->id?PF_CHAR:0)|(m?PF_MATRIX:0)|(cx?PF_CXFORM:0)|(obj->ratio?PF_RATIO:0)|
+ (obj->name?PF_NAME:0)|(obj->move?PF_MOVE:0)|
+ (obj->clipdepth?PF_CLIPACTION:0);
+
+ swf_SetU8(t,flags);
+ swf_SetU16(t,obj->depth);
+ if (flags&PF_CHAR) swf_SetU16(t,obj->id);
+ if (flags&PF_MATRIX) swf_SetMatrix(t,&obj->matrix);
+ if (flags&PF_CXFORM) swf_SetCXForm(t,&obj->cxform,1);
+ if (flags&PF_RATIO) swf_SetU16(t,obj->ratio);
+
+ /* ??? The spec states that name comes first? */
+ if (flags&PF_CLIPACTION) swf_SetU16(t,obj->clipdepth);
+ if (flags&PF_NAME) swf_SetString(t,obj->name);
+ if (flags&PF_ACTIONEVENT) {
+ // ...
+ }
+ }
+}
+
+void swf_GetPlaceObject(TAG * tag,SWFPLACEOBJECT* obj)
+{
+ U8 flags;
+ if(!tag) {
+ memset(obj, 0, sizeof(SWFPLACEOBJECT));
+ swf_GetMatrix(0, &obj->matrix);
+ swf_GetCXForm(0, &obj->cxform, 1);
+ //obj->internal = PF_CHAR|PF_MATRIX|PF_CXFORM;
+ return;
+ }
+ swf_SetTagPos(tag, 0);
+
+ if(tag->id == ST_PLACEOBJECT) {
+ obj->id = swf_GetU16(tag);
+ obj->depth = swf_GetU16(tag);
+ swf_GetMatrix(tag, &obj->matrix);
+ swf_GetCXForm(tag, &obj->cxform, 0);
+ //obj->internal = PF_CHAR|PF_MATRIX|PF_CXFORM;
+ } else if(tag->id == ST_PLACEOBJECT2) {
+ flags = swf_GetU8(tag);
+ memset(obj,0,sizeof(SWFPLACEOBJECT));
+
+ swf_GetMatrix(0,&obj->matrix);
+ swf_GetCXForm(0,&obj->cxform,1);
+
+ obj->depth = swf_GetU16(tag);
+ //obj->internal = flags;
+ if(flags&1) obj->move = 1;
+ if(flags&2) obj->id = swf_GetU16(tag);
+ if(flags&4) swf_GetMatrix(tag, &obj->matrix);
+ if(flags&8) swf_GetCXForm(tag, &obj->cxform,1);
+ if(flags&16) obj->ratio = swf_GetU16(tag);
+ /* if you modify the order of these operations, also
+ modify it in ../src/swfcombine.c */
+ if(flags&64)
+ obj->clipdepth = swf_GetU16(tag); //clip
+ if(flags&32) {
+ int l,t;
+ U8*data;
+ swf_ResetReadBits(tag);
+ l = strlen(&tag->data[tag->pos]);
+ t = 0;
+ data = rfx_alloc(l+1);
+ obj->name = data;
+ while((data[t++] = swf_GetU8(tag)));
+ }
+
+ /* Actionscript ignored (for now) */
+ obj->actions = 0;
+ } else {
+ fprintf(stderr, "rfxswf: Bad Tag: %d not a placeobject\n", tag->id);
+ }
+}
+
+void swf_PlaceObjectFree(SWFPLACEOBJECT* obj)
+{
+ if(obj->name)
+ rfx_free(obj->name);
+}
+