3 Actionscript generation and parsing routines
5 Extension module for the rfxswf library.
6 Part of the swftools package.
8 Copyright (c) 2001 Matthias Kramm <kramm@quiss.org>
10 This file is distributed under the GPL, see file COPYING for details
14 #include "../rfxswf.h"
29 C: constant pool header (byte)
30 c: constant pool entry (string)
31 s: skip (byte) (number of actions)
32 m: method (byte) swf_GetUrl2:(0=none, 1=get, 2=post)/GotoFrame2:(1=play)
33 b: branch (word) (number of bytes)
34 p (push): type(byte), type=0:string, type=1:double
35 {: define function (name (string), num (word), params (num strings), codesize (word)
40 {3,"GotoFrame", 0x81, "f"},
41 {4,"GotoFrame2", 0x9f, "m"}, // -1 (/Movieclip:3)
42 {3,"GetUrl", 0x83, "ul"},
43 {4,"GetUrl2", 0x9a, "m"}, //-2
44 {3,"NextFrame", 0x04, ""},
45 {3,"PreviousFrame", 0x05, ""},
48 {3,"ToggleQuality", 0x08, ""},
49 {3,"StopSounds", 0x09, ""},
50 {3,"WaitForFrame", 0x8a, "fs"},
51 {4,"WaitForFrame2", 0x8d, "s"}, // -1
52 {3,"SetTarget", 0x8b, "t"},
53 {4,"SetTarget2", 0x20, ""}, //-1
54 {3,"GotoLabel", 0x8c, "l"},
55 {4,"Add", 0x0a, ""}, // -2, +1
56 {4,"Multiply", 0x0c, ""}, // -2, +1
57 {4,"Divide", 0x0d, ""}, // -2, +1
58 {4,"Subtract", 0x0b, ""}, // -2, +1
59 {4,"Less", 0x0f, ""}, // -2, +1
60 {4,"Equals", 0x0e, ""}, // -2, +1
61 {4,"And", 0x10, ""}, // -2, +1
62 {4,"Or", 0x11, ""}, // -2, +1
63 {4,"Not", 0x12, ""}, // -1, +1
64 {4,"StringAdd", 0x21, ""}, // -2,+1
65 {4,"StringLength", 0x14, ""}, // -1, +1
66 {4,"MBStringLength", 0x31, ""}, // -1, +1
67 {4,"StringEquals", 0x13, ""}, // -2, +1
68 {4,"StringLess", 0x29, ""}, //-2, +1
69 {4,"StringExtract", 0x15, ""}, // -3, +1
70 {4,"MBStringExtract", 0x35, ""}, //-3 +1
71 {4,"Push", 0x96, "p"}, // +1
72 {4,"Pop", 0x17, ""}, // -1
73 {4,"ToInteger", 0x18, ""}, // -1, +1
74 {4,"CharToAscii", 0x32, ""}, // -1, +1
75 {4,"AsciiToChar", 0x33, ""}, // -1, +1
76 {4,"MBCharToAscii", 0x36, ""}, // -1, +1
77 {4,"MBAsciiToChar", 0x37, ""}, // -1, +1
78 {4,"Jump", 0x99, "b"},
79 {4,"If", 0x9d, "b"}, // -1
80 {4,"Call", 0x9e, ""}, //-1 (frame label/number) (high bit is wrong.)
81 {4,"GetVariable", 0x1c,""}, // -1, +1
82 {4,"SetVariable", 0x1d,""}, // -2
83 {4,"GetProperty", 0x22,""}, //-2, +1
84 {4,"SetProperty", 0x23, ""}, // -3
85 {4,"RemoveSprite", 0x25, ""}, //-1
86 {4,"StartDrag", 0x27, ""}, // -2, -1, (-4)
87 {4,"EndDrag", 0x28, ""},
88 {4,"CloneSprite", 0x24, ""}, // -3
89 {4,"Trace", 0x26, ""}, //-1
90 {4,"GetTime", 0x34, ""}, //+1
91 {4,"RandomNumber", 0x30, ""}, //-1,+1
92 {5,"Modulo", 0x3f,""},
93 {5,"BitAnd", 0x60,""},
94 {5,"BitLShift", 0x63,""},
96 {5,"BitRShift", 0x64,""},
97 {5,"BitURShift", 0x65,""},
98 {5,"BitXor", 0x62,""},//66?
99 {5,"Decrement", 0x51,""},
100 {5,"Increment", 0x50,""},
101 {5,"PushDuplicate", 0x4c,""},
102 {5,"StackSwap", 0x4d,""}, //?
103 {5,"StoreRegister", 0x87,"r"},
104 {5,"CallFunction", 0x3d,""},
105 {5,"DefineFunction", 0x9b, "{"},
106 {5,"Return", 0x3e,""},
107 {5,"GetMember", 0x4e,""},
108 {5,"SetMember", 0x4f,""},
109 {5,"CallMethod", 0x52,""},
110 {5,"Constantpool", 0x88, "Cc"},
111 {5,"DefineLocal", 0x3c,""},
112 {5,"DefineLocal2", 0x41,""},
113 {5,"Makehash", 0x43, ""}, //??
114 {5,"Delete", 0x3a,""}, //?
115 {5,"Delete2", 0x3b,""},
116 {5,"Enumerate", 0x46,""},
117 {5,"Equals2", 0x49,""},
118 {5,"InitArray", 0x42,""}, // InitObject?
119 {5,"NewMethod", 0x53,""}, //?
120 {5,"NewObject", 0x40,""},
121 {5,"TargetPath", 0x45,""}, //?
122 {5,"With", 0x94, "o"},
123 {5,"ToNumber", 0x4a,""}, //?
124 {5,"ToString", 0x4b,""}, //?
125 {5,"TypeOf", 0x44,""},
129 static int definedactions = sizeof(actions)/sizeof(struct Action);
131 ActionTAG* swf_GetActions(TAG*tag)
136 ActionTAG*action = &tmp;
140 action->next = (ActionTAG*)malloc(sizeof(ActionTAG));
141 action->next->prev = action;
142 action->next->next = 0;
143 action = action->next;
149 length = swf_GetU16(tag);
153 data = malloc(length);
154 for(t=0;t<length;t++)
155 data[t] = swf_GetU8(tag);
160 action->len = length;
162 action->parent = tag;
167 void swf_SetActions(TAG*tag, ActionTAG*action)
171 swf_SetU8(tag, action->op);
173 swf_SetU16(tag, action->len);
175 swf_SetBlock(tag, action->data, action->len);
177 action = action->next;
181 int OpAdvance(char c, char*data)
188 return strlen(data)+1;
190 return strlen(data)+1;
192 return strlen(data)+1;
194 return strlen(data)+1;
206 return 1+strlen(data)+1; //string
207 } else if (type == 1) {
209 } else if (type == 2) {
211 } else if (type == 4) {
212 return 1+1; //register
213 } else if (type == 5) {
215 } else if (type == 6) {
217 } else if (type == 7) {
219 } else if (type == 8) {
228 /* TODO: this should be in swfdump.c */
229 void swf_DumpActions(ActionTAG*atag, char*prefix)
239 for(t=0;t<definedactions;t++)
240 if(actions[t].op == atag->op)
243 if(t==definedactions) {
244 printf("%s (%5d bytes) action: %02x\n", prefix, atag->len, atag->op);
248 printf("%s (%5d bytes) action: %s", prefix, atag->len, actions[t].name);
249 cp = actions[t].flags;
251 if(atag->len) //TODO: check for consistency: should we have a length?
257 printf(" %d", *(U16*)data); //FIXME: le/be
260 printf(" URL:\"%s\"", data);
263 printf(" Target:\"%s\"", data);
266 printf(" Label:\"%s\"", data);
269 printf(" String:\"%s\"", data);
273 printf("(%d entries)", poollen);
276 printf(" +%d", *data);
279 //m: method (byte) url:(0=none, 1=get, 2=datat)/gf2:(1=play)
280 printf(" %d", *data);
283 printf(" %d", *(U16*)data);
289 printf(" String:\"%s\"", value);
290 } else if (type == 1) {
291 printf(" Float:%f", *(float*)value);
292 } else if (type == 2) {
294 } else if (type == 4) {
295 printf(" register:%d", *value);
296 } else if (type == 5) {
297 printf(" bool:%s", *value?"true":"false");
298 } else if (type == 6) {
299 printf(" float:%f", *(double*)value);
300 } else if (type == 7) {
301 printf(" int:%d", *(int*)value);
302 } else if (type == 8) {
303 printf(" Lookup:%d", *value);
305 printf(" UNKNOWN[%02x]",type);
309 data += OpAdvance(*cp, data);
310 if((*cp!='c' || !poollen) &&
311 (*cp!='p' || !(data<&atag->data[atag->len])))
317 if(data < atag->data + atag->len)
319 int nl = ((atag->data+atag->len)-data);
321 printf(" (remainder of %d bytes:\"", nl);
324 printf("\\%d",data[t]);
326 printf("%c", data[t]);
335 static const char TYPE_URL = 1;
336 static const char TYPE_TARGET = 2;
337 static const char TYPE_STRING = 4;
339 int swf_ActionEnumerate(ActionTAG*atag, char*(*callback)(char*), int type)
348 for(t=0;t<definedactions;t++)
349 if(actions[t].op == atag->op)
352 if(t==definedactions) {
358 cp = actions[t].flags;
364 U8 * replacement = 0;
370 replacelen = strlen(data);
372 replacement = callback(data); // may be null
378 replacelen = strlen(data);
380 replacement = callback(data); // may be null
386 replacelen = strlen(data);
388 replacement = callback(data); // may be null
398 char*value = &data[1];
399 if(datatype == 0) { //string
402 replacelen = strlen(value);
404 replacement = callback(value); // may be null
406 } else if (datatype == 8) { //lookup
410 data += OpAdvance(*cp, data);
411 if(*cp!='c' || !poollen)
418 int newlen = strlen(replacement);
419 char * newdata = malloc(atag->len - replacelen + newlen);
420 int rpos = replacepos - atag->data;
421 memcpy(newdata, atag->data, rpos);
422 memcpy(&newdata[rpos], replacement, newlen);
423 memcpy(&newdata[rpos+newlen], &replacepos[replacelen],
424 &data[atag->len] - &replacepos[replacelen]);
426 atag->data = newdata;
427 data = &atag->data[rpos+newlen+1];
437 void swf_ActionEnumerateTargets(ActionTAG*atag, char*(*callback)(char*))
439 swf_ActionEnumerate(atag, callback, TYPE_TARGET);
441 void swf_ActionEnumerateStrings(ActionTAG*atag, char*(*callback)(char*))
443 swf_ActionEnumerate(atag, callback, TYPE_STRING);
445 void swf_ActionEnumerateURLs(ActionTAG*atag, char*(*callback)(char*))
447 swf_ActionEnumerate(atag, callback, TYPE_URL);
450 static ActionTAG * currentatag;
452 ActionTAG* swf_ActionStart()
454 currentatag = (ActionTAG*)malloc(sizeof(ActionTAG));
455 currentatag->prev = 0;
456 currentatag->parent = 0;
457 currentatag->data = 0;
458 currentatag->len = 0;
464 currentatag->prev->next = 0;
468 void swf_AddActionTAG(U8 op, U8*data, U16 len)
470 currentatag->next = (ActionTAG*)malloc(sizeof(ActionTAG));
471 currentatag->next->prev = currentatag;
472 currentatag->parent = 0;
473 currentatag->data = data;
474 currentatag->len = len;
475 currentatag->op = op;
476 currentatag = currentatag->next;
479 #define ACTION_END 0x00
480 #define ACTION_NEXTFRAME 0x04
481 #define ACTION_PREVIOUSFRAME 0x05
482 #define ACTION_PLAY 0x06
483 #define ACTION_STOP 0x07
484 #define ACTION_TOGGLEQUALITY 0x08
485 #define ACTION_STOPSOUNDS 0x09
486 #define ACTION_ADD 0x0a
487 #define ACTION_SUBTRACT 0x0b
488 #define ACTION_MULTIPLY 0x0c
489 #define ACTION_DIVIDE 0x0d
490 #define ACTION_EQUALS 0x0e
491 #define ACTION_LESS 0x0f
492 #define ACTION_AND 0x10
493 #define ACTION_OR 0x11
494 #define ACTION_NOT 0x12
495 #define ACTION_STRINGEQUALS 0x13
496 #define ACTION_STRINGLENGTH 0x14
497 #define ACTION_STRINGEXTRACT 0x15
498 #define ACTION_POP 0x17
499 #define ACTION_TOINTEGER 0x18
500 #define ACTION_GETVARIABLE 0x1c
501 #define ACTION_SETVARIABLE 0x1d
502 #define ACTION_SETTARGET2 0x20
503 #define ACTION_STRINGADD 0x21
504 #define ACTION_GETPROPERTY 0x22
505 #define ACTION_SETPROPERTY 0x23
506 #define ACTION_CLONESPRITE 0x24
507 #define ACTION_REMOVESPRITE 0x25
508 #define ACTION_TRACE 0x26
509 #define ACTION_STARTDRAG 0x27
510 #define ACTION_ENDDRAG 0x28
511 #define ACTION_STRINGLESS 0x29
512 #define ACTION_RANDOMNUMBER 0x30
513 #define ACTION_MBSTRINGLENGTH 0x31
514 #define ACTION_CHARTOASCII 0x32
515 #define ACTION_ASCIITOCHAR 0x33
516 #define ACTION_GETTIME 0x34
517 #define ACTION_MBSTRINGEXTRACT 0x35
518 #define ACTION_MBCHARTOASCII 0x36
519 #define ACTION_MBASCIITOCHAR 0x37
520 #define ACTION_DELETE 0x3a
521 #define ACTION_DELETE2 0x3b
522 #define ACTION_DEFINELOCAL 0x3c
523 #define ACTION_CALLFUNCTION 0x3d
524 #define ACTION_RETURN 0x3e
525 #define ACTION_MODULO 0x3f
526 #define ACTION_NEWOBJECT 0x40
527 #define ACTION_DEFINELOCAL2 0x41
528 #define ACTION_INITARRAY 0x42
529 #define ACTION_MAKEHASH 0x43
530 #define ACTION_TYPEOF 0x44
531 #define ACTION_TARGETPATH 0x45
532 #define ACTION_ENUMERATE 0x46
533 #define ACTION_ADD2 0x47
534 #define ACTION_LESS2 0x48
535 #define ACTION_EQUALS2 0x49
536 #define ACTION_TONUMBER 0x4a
537 #define ACTION_TOSTRING 0x4b
538 #define ACTION_PUSHDUPLICATE 0x4c
539 #define ACTION_STACKSWAP 0x4d
540 #define ACTION_GETMEMBER 0x4e
541 #define ACTION_SETMEMBER 0x4f
542 #define ACTION_INCREMENT 0x50
543 #define ACTION_DECREMENT 0x51
544 #define ACTION_CALLMETHOD 0x52
545 #define ACTION_NEWMETHOD 0x53
546 #define ACTION_BITAND 0x60
547 #define ACTION_BITOR 0x61
548 #define ACTION_BITXOR 0x62
549 #define ACTION_BITLSHIFT 0x63
550 #define ACTION_BITRSHIFT 0x64
551 #define ACTION_BITURSHIFT 0x65
552 #define ACTION_GOTOFRAME 0x81
553 #define ACTION_GETURL 0x83
554 #define ACTION_STOREREGISTER 0x87
555 #define ACTION_CONSTANTPOOL 0x88
556 #define ACTION_WAITFORFRAME 0x8a
557 #define ACTION_SETTARGET 0x8b
558 #define ACTION_GOTOLABEL 0x8c
559 #define ACTION_WAITFORFRAME2 0x8d
560 #define ACTION_WITH 0x94
561 #define ACTION_PUSH 0x96
562 #define ACTION_JUMP 0x99
563 #define ACTION_GETURL2 0x9a
564 #define ACTION_DEFINEFUNCTION 0x9b
565 #define ACTION_IF 0x9d
566 #define ACTION_CALL 0x9e
567 #define ACTION_GOTOFRAME2 0x9f
569 void action_NextFrame() {swf_AddActionTAG(ACTION_NEXTFRAME, 0, 0);}
570 void action_PreviousFrame() {swf_AddActionTAG(ACTION_PREVIOUSFRAME, 0, 0);}
571 void action_Play() {swf_AddActionTAG(ACTION_PLAY, 0, 0);}
572 void action_Stop() {swf_AddActionTAG(ACTION_STOP, 0, 0);}
573 void action_ToggleQuality() {swf_AddActionTAG(ACTION_TOGGLEQUALITY, 0, 0);}
574 void action_StopSounds() {swf_AddActionTAG(ACTION_STOPSOUNDS, 0, 0);}
575 void action_Add() {swf_AddActionTAG(ACTION_ADD, 0, 0);}
576 void action_Subtract() {swf_AddActionTAG(ACTION_SUBTRACT, 0, 0);}
577 void action_Multiply() {swf_AddActionTAG(ACTION_MULTIPLY, 0, 0);}
578 void action_Divide() {swf_AddActionTAG(ACTION_DIVIDE, 0, 0);}
579 void action_Equals() {swf_AddActionTAG(ACTION_EQUALS, 0, 0);}
580 void action_Less() {swf_AddActionTAG(ACTION_LESS, 0, 0);}
581 void action_And() {swf_AddActionTAG(ACTION_AND, 0, 0);}
582 void action_Or() {swf_AddActionTAG(ACTION_OR, 0, 0);}
583 void action_Not() {swf_AddActionTAG(ACTION_NOT, 0, 0);}
584 void action_StringEquals() {swf_AddActionTAG(ACTION_STRINGEQUALS, 0, 0);}
585 void action_StringLength() {swf_AddActionTAG(ACTION_STRINGLENGTH, 0, 0);}
586 void action_StringExtract() {swf_AddActionTAG(ACTION_STRINGEXTRACT, 0, 0);}
587 void action_Pop() {swf_AddActionTAG(ACTION_POP, 0, 0);}
588 void action_ToInteger() {swf_AddActionTAG(ACTION_TOINTEGER, 0, 0);}
589 void action_GetVariable() {swf_AddActionTAG(ACTION_GETVARIABLE, 0, 0);}
590 void action_SetVariable() {swf_AddActionTAG(ACTION_SETVARIABLE, 0, 0);}
591 void action_SetTarget2() {swf_AddActionTAG(ACTION_SETTARGET2, 0, 0);}
592 void action_StringAdd() {swf_AddActionTAG(ACTION_STRINGADD, 0, 0);}
593 void action_GetProperty() {swf_AddActionTAG(ACTION_GETPROPERTY, 0, 0);}
594 void action_SetProperty() {swf_AddActionTAG(ACTION_SETPROPERTY, 0, 0);}
595 void action_CloneSprite() {swf_AddActionTAG(ACTION_CLONESPRITE, 0, 0);}
596 void action_RemoveSprite() {swf_AddActionTAG(ACTION_REMOVESPRITE, 0, 0);}
597 void action_Trace() {swf_AddActionTAG(ACTION_TRACE, 0, 0);}
598 void action_StartDrag() {swf_AddActionTAG(ACTION_STARTDRAG, 0, 0);}
599 void action_EndDrag() {swf_AddActionTAG(ACTION_ENDDRAG, 0, 0);}
600 void action_StringLess() {swf_AddActionTAG(ACTION_STRINGLESS, 0, 0);}
601 void action_RandomNumber() {swf_AddActionTAG(ACTION_RANDOMNUMBER, 0, 0);}
602 void action_MBStringLength() {swf_AddActionTAG(ACTION_MBSTRINGLENGTH, 0, 0);}
603 void action_CharToAscii() {swf_AddActionTAG(ACTION_CHARTOASCII, 0, 0);}
604 void action_AsciiToChar() {swf_AddActionTAG(ACTION_ASCIITOCHAR, 0, 0);}
605 void action_GetTime() {swf_AddActionTAG(ACTION_GETTIME, 0, 0);}
606 void action_MBStringExtract() {swf_AddActionTAG(ACTION_MBSTRINGEXTRACT, 0, 0);}
607 void action_MBCharToAscii() {swf_AddActionTAG(ACTION_MBCHARTOASCII, 0, 0);}
608 void action_MBAsciiToChar() {swf_AddActionTAG(ACTION_MBASCIITOCHAR, 0, 0);}
609 void action_Delete() {swf_AddActionTAG(ACTION_DELETE, 0, 0);}
610 void action_Delete2() {swf_AddActionTAG(ACTION_DELETE2, 0, 0);}
611 void action_DefineLocal() {swf_AddActionTAG(ACTION_DEFINELOCAL, 0, 0);}
612 void action_CallFunction() {swf_AddActionTAG(ACTION_CALLFUNCTION, 0, 0);}
613 void action_Return() {swf_AddActionTAG(ACTION_RETURN, 0, 0);}
614 void action_Modulo() {swf_AddActionTAG(ACTION_MODULO, 0, 0);}
615 void action_NewObject() {swf_AddActionTAG(ACTION_NEWOBJECT, 0, 0);}
616 void action_DefineLocal2() {swf_AddActionTAG(ACTION_DEFINELOCAL2, 0, 0);}
617 void action_InitArray() {swf_AddActionTAG(ACTION_INITARRAY, 0, 0);}
618 void action_Makehash() {swf_AddActionTAG(ACTION_MAKEHASH, 0, 0);}
619 void action_TypeOf() {swf_AddActionTAG(ACTION_TYPEOF, 0, 0);}
620 void action_TargetPath() {swf_AddActionTAG(ACTION_TARGETPATH, 0, 0);}
621 void action_Enumerate() {swf_AddActionTAG(ACTION_ENUMERATE, 0, 0);}
622 void action_Add2() {swf_AddActionTAG(ACTION_ADD2, 0, 0);}
623 void action_Less2() {swf_AddActionTAG(ACTION_LESS2, 0, 0);}
624 void action_Equals2() {swf_AddActionTAG(ACTION_EQUALS2, 0, 0);}
625 void action_ToNumber() {swf_AddActionTAG(ACTION_TONUMBER, 0, 0);}
626 void action_ToString() {swf_AddActionTAG(ACTION_TOSTRING, 0, 0);}
627 void action_PushDuplicate() {swf_AddActionTAG(ACTION_PUSHDUPLICATE, 0, 0);}
628 void action_StackSwap() {swf_AddActionTAG(ACTION_STACKSWAP, 0, 0);}
629 void action_GetMember() {swf_AddActionTAG(ACTION_GETMEMBER, 0, 0);}
630 void action_SetMember() {swf_AddActionTAG(ACTION_SETMEMBER, 0, 0);}
631 void action_Increment() {swf_AddActionTAG(ACTION_INCREMENT, 0, 0);}
632 void action_Decrement() {swf_AddActionTAG(ACTION_DECREMENT, 0, 0);}
633 void action_CallMethod() {swf_AddActionTAG(ACTION_CALLMETHOD, 0, 0);}
634 void action_NewMethod() {swf_AddActionTAG(ACTION_NEWMETHOD, 0, 0);}
635 void action_BitAnd() {swf_AddActionTAG(ACTION_BITAND, 0, 0);}
636 void action_BitOr() {swf_AddActionTAG(ACTION_BITOR, 0, 0);}
637 void action_BitXor() {swf_AddActionTAG(ACTION_BITXOR, 0, 0);}
638 void action_BitLShift() {swf_AddActionTAG(ACTION_BITLSHIFT, 0, 0);}
639 void action_BitRShift() {swf_AddActionTAG(ACTION_BITRSHIFT, 0, 0);}
640 void action_BitURShift() {swf_AddActionTAG(ACTION_BITURSHIFT, 0, 0);}
641 void action_Call() {swf_AddActionTAG(ACTION_CALL, 0, 0);}
642 void action_End() {swf_AddActionTAG(ACTION_END, 0, 0);}
643 void action_GotoFrame(U16 frame)
645 *(U16*)currentatag->tmp = frame;
646 swf_AddActionTAG(ACTION_GOTOFRAME, (U8*)currentatag->tmp, 2);
648 void action_Jump(U16 branch)
650 *(U16*)currentatag->tmp = branch;
651 swf_AddActionTAG(ACTION_JUMP, (U8*)currentatag->tmp, 2);
653 void action_If(U16 branch)
655 *(U16*)currentatag->tmp = branch;
656 swf_AddActionTAG(ACTION_IF, (U8*)currentatag->tmp, 2);
658 void action_StoreRegister(U8 reg)
660 *(U8*)currentatag->tmp = reg;
661 swf_AddActionTAG(ACTION_STOREREGISTER, (U8*)currentatag->tmp, 1);
663 void action_GotoFrame2(U8 method)
665 *(U8*)currentatag->tmp = method;
666 swf_AddActionTAG(ACTION_GOTOFRAME2, (U8*)currentatag->tmp, 1);
668 void action_GetUrl2(U8 method)
670 *(U8*)currentatag->tmp = method;
671 swf_AddActionTAG(ACTION_GETURL2, (U8*)currentatag->tmp, 1);
673 void action_WaitForFrame2(U8 skip)
675 *(U8*)currentatag->tmp = skip;
676 swf_AddActionTAG(ACTION_WAITFORFRAME2, (U8*)currentatag->tmp, 1);
678 void action_WaitForFrame(U16 frame, U8 skip)
680 *(U16*)currentatag->tmp = frame;
681 *(U8*)¤tatag->tmp[2] = skip;
682 swf_AddActionTAG(ACTION_WAITFORFRAME, (U8*)currentatag->tmp, 3);
684 void action_SetTarget(char* target)
686 char*ptr = strdup(target);
687 swf_AddActionTAG(ACTION_SETTARGET, (U8*)ptr, strlen(ptr)+1);
689 void action_PushNULL()
691 *(U8*)currentatag->tmp = 2; //NULL
692 swf_AddActionTAG(ACTION_PUSH, (U8*)currentatag->tmp, 1);
694 void action_PushBoolean(char c)
696 *(U8*)currentatag->tmp = 5; //bool
697 *(U8*)¤tatag->tmp[1] = c;
698 swf_AddActionTAG(ACTION_PUSH, (U8*)currentatag->tmp, 2);
700 void action_PushRegister(U8 reg)
702 *(U8*)currentatag->tmp = 4; //register
703 *(U8*)¤tatag->tmp[1] = reg;
704 swf_AddActionTAG(ACTION_PUSH, (U8*)currentatag->tmp, 2);
706 void action_PushLookup(U8 index)
708 *(U8*)currentatag->tmp = 8; //lookup
709 *(U8*)¤tatag->tmp[1] = index;
710 swf_AddActionTAG(ACTION_PUSH, (U8*)currentatag->tmp, 2);
712 void action_PushString(char*str)
715 char*ptr = (char*)malloc(l+2);
716 ptr[0] = 0; // string
717 strcpy(&ptr[1], str);
718 swf_AddActionTAG(ACTION_PUSH, (U8*)ptr, l+2);
720 void action_PushFloat(float f)
722 char*ptr = (char*)malloc(5);
724 *(float*)&ptr[1] = f;
725 swf_AddActionTAG(ACTION_PUSH, (U8*)ptr, 5);
727 void action_PushDouble(double d)
729 char*ptr = (char*)malloc(9);
731 *(double*)&ptr[1] = d;
732 swf_AddActionTAG(ACTION_PUSH, (U8*)ptr, 9);
734 void action_PushInt(int i)
736 *(U8*)currentatag->tmp = 7; //int
737 *(U8*)¤tatag->tmp[1] = i;
738 swf_AddActionTAG(ACTION_PUSH, (U8*)currentatag->tmp, 5);
740 void action_GotoLabel(char* label)
742 char*ptr = strdup(label);
743 swf_AddActionTAG(ACTION_GOTOLABEL, (U8*)ptr, strlen(ptr));
745 void action_GetUrl(char* url, char* label)
748 int l2= strlen(label);
749 char*ptr = malloc(l1+l2+2);
751 strcpy(&ptr[l1+1], label);
752 swf_AddActionTAG(ACTION_GETURL, ptr, l1+l2+2);
755 void action_DefineFunction(U8*data, int len) {}
756 void action_Constantpool(char* constantpool) {}
757 void action_With(char*object) {}