implemented sprite folding/unfolding.
authorkramm <kramm>
Sun, 21 Jul 2002 13:58:16 +0000 (13:58 +0000)
committerkramm <kramm>
Sun, 21 Jul 2002 13:58:16 +0000 (13:58 +0000)
lib/rfxswf.c
lib/rfxswf.h

index 9b96235..7824dee 100644 (file)
@@ -744,6 +744,51 @@ int swf_DefineSprite_GetRealSize(TAG * t)
   return len;
 }
 
+void swf_UnFoldSprite(TAG * t)
+{
+  U16 id,tmp;
+  U32 len;
+  TAG*next = t;
+  U16 spriteid,spriteframes;
+  if(t->id!=ST_DEFINESPRITE)
+    return;
+  if(t->len<=4) // not folded
+    return;
+
+  swf_SetTagPos(t,0);
+
+  spriteid = swf_GetU16(t); //id
+  spriteframes = swf_GetU16(t); //frames
+
+  tmp = swf_GetU16(t);
+  len = tmp&0x3f;
+  id  = tmp>>6;
+  while(id)
+  {
+    TAG*it = 0;
+    if (len==0x3f)
+       len = swf_GetU32(t);
+    it = swf_InsertTag(next, id);
+    next = it;
+    it->len = len;
+    it->id  = id;
+    if (it->len)
+    { it->data = (U8*)malloc(t->len);
+      it->memsize = it->len;
+      swf_GetBlock(t, it->data, it->len);
+    }
+    tmp = swf_GetU16(t);
+    len = tmp&0x3f;
+    id  = tmp>>6;
+  }
+  
+  free(t->data); t->data = 0;
+  t->memsize = t->len = t->pos = 0;
+
+  swf_SetU16(t, spriteid);
+  swf_SetU16(t, spriteframes);
+}
+
 void swf_FoldSprite(TAG * t)
 {
   TAG*sprtag=t,*tmp;
@@ -809,6 +854,17 @@ void swf_FoldAll(SWF*swf)
     }
 }
 
+void swf_UnFoldAll(SWF*swf)
+{
+    TAG*tag = swf->firstTag;
+    while(tag) {
+        TAG*next = swf_NextTag(tag);
+       if(tag->id == ST_DEFINESPRITE)
+           swf_UnFoldSprite(tag);
+       tag = next;
+    }
+}
+
 // Movie Functions
 
 int swf_ReadSWF2(struct reader_t*reader, SWF * swf)   // Reads SWF to memory (malloc'ed), returns length or <0 if fails
index ff15257..861e378 100644 (file)
@@ -158,7 +158,9 @@ int  swf_ReadHeader(struct reader_t*reader, SWF * swf);   // Reads SWF Header vi
 // folding/unfolding:
 
 void swf_FoldAll(SWF*swf);
+void swf_UnFoldAll(SWF*swf);
 void swf_FoldSprite(TAG*tag);
+void swf_UnFoldSprite(TAG*tag);
 
 // basic routines:
     
@@ -766,7 +768,7 @@ void action_fixjump(ActionMarker m1, ActionMarker m2);
 
 // swfobject.c
 
-// The following routines only use placeobject2:
+// The following 3 routines only use placeobject2:
 
 int swf_ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name);
 int swf_ObjectPlaceClip(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name, U16 clipaction);