};
static int definedactions = sizeof(actions)/sizeof(struct Action);
-ActionTAG* swf_GetActions(TAG*tag)
+ActionTAG* swf_ActionGet(TAG*tag)
{
U8 op = 1;
int length;
length = swf_GetU16(tag);
if(length) {
- int t;
data = malloc(length);
- for(t=0;t<length;t++)
- data[t] = swf_GetU8(tag);
+ swf_GetBlock(tag, data, length);
} else {
data = 0;
}
return tmp.next;
}
-void swf_SetActions(TAG*tag, ActionTAG*action)
+void swf_ActionFree(ActionTAG*action)
+{
+ while(action)
+ {
+ ActionTAG*tmp;
+ if(action->data && action->data != action->tmp)
+ free(action->data);
+ tmp = action;
+ action=action->next;
+ free(tmp);
+ }
+}
+
+void swf_ActionSet(TAG*tag, ActionTAG*action)
{
while(action)
{
currentatag = currentatag->next;
}
+ActionMarker action_setMarker()
+{
+ ActionMarker m;
+ m.atag = currentatag;
+ return m;
+}
+
+int inline ActionTagSize(ActionTAG*atag)
+{
+ return (atag->op&0x80)?3+(atag->len):1+0;
+}
+
+
#define ACTION_END 0x00
#define ACTION_NEXTFRAME 0x04
#define ACTION_PREVIOUSFRAME 0x05
#define ACTION_CALL 0x9e
#define ACTION_GOTOFRAME2 0x9f
+void action_fixjump(ActionMarker m1, ActionMarker m2)
+{
+ ActionTAG* a1 = m1.atag;
+ ActionTAG* a2 = m2.atag;
+ ActionTAG* a;
+ int len = 0;
+ int oplen = 0;
+ a = a1;
+
+ a = a->next; //first one is free
+ while(a && a!=a2)
+ {
+ len += ActionTagSize(a);
+ oplen ++;
+ a = a->next;
+ }
+ if(!a)
+ { len = 0;
+ oplen = 0;
+ a = a2;
+ while(a && a!=a1) {
+ len -= ActionTagSize(a);
+ oplen --;
+ a = a->next;
+ }
+ if(!a) {
+ fprintf(stderr, "action_fixjump: couldn't find second tag\n");
+ return;
+ }
+ len -= ActionTagSize(a);
+ oplen --;
+ }
+
+ if (a1->op == ACTION_IF || a1->op == ACTION_JUMP)
+ {
+ *(U16*)(a1->data) = len;
+ }
+ else if(a1->op == ACTION_WAITFORFRAME)
+ {
+ ((U8*)(a1->data))[2] = oplen;
+ }
+ else if(a1->op == ACTION_WAITFORFRAME2)
+ {
+ ((U8*)(a1->data))[0] = oplen;
+ }
+
+}
+
+
void action_NextFrame() {swf_AddActionTAG(ACTION_NEXTFRAME, 0, 0);}
void action_PreviousFrame() {swf_AddActionTAG(ACTION_PREVIOUSFRAME, 0, 0);}
void action_Play() {swf_AddActionTAG(ACTION_PLAY, 0, 0);}