00001 #ifndef _SCRIPT_H_ 00002 #define _SCRIPT_H_ 00003 00004 // SWF file parser. 00005 // 00007 00009 // Input script object definition. 00011 00012 // An input script object. This object represents a script created from 00013 // an external file that is meant to be inserted into an output script. 00014 struct CInputScript : public Dict 00015 { 00016 int level; 00017 struct CInputScript *next; 00018 00019 Program *program; // Current parsed program 00020 00021 // Memory fences 00022 int outOfMemory; 00023 00024 //Flash info 00025 long frameRate; 00026 long frameCount; 00027 Rect frameRect; 00028 00029 // Pointer to file contents buffer. 00030 U8 *m_fileBuf; 00031 00032 // File state information. 00033 U32 m_filePos; 00034 U32 m_fileSize; 00035 U32 m_actualSize; 00036 U32 m_fileStart; 00037 U16 m_fileVersion; 00038 00039 int needHeader; 00040 00041 // Bit Handling 00042 S32 m_bitPos; 00043 U32 m_bitBuf; 00044 00045 // Tag parsing information. 00046 U32 m_tagStart; 00047 U32 m_tagEnd; 00048 U32 m_tagLen; 00049 00050 // Parsing information. 00051 S32 m_nFillBits; 00052 S32 m_nLineBits; 00053 S32 m_nGlyphBits; 00054 S32 m_nAdvanceBits; 00055 00056 // Set to true if we wish to dump all contents long form 00057 U32 m_dumpAll; 00058 00059 // if set to true will dump image guts (i.e. jpeg, zlib, etc. data) 00060 U32 m_dumpGuts; 00061 00062 // Handle to output file. 00063 FILE *m_outputFile; 00064 00065 // Constructor/destructor. 00066 CInputScript(int level = 0); 00067 ~CInputScript(); 00068 00069 // Tag scanning methods. 00070 U16 GetTag(void); 00071 U8 GetByte(void); 00072 U16 GetWord(void); 00073 U32 GetDWord(void); 00074 void GetRect(Rect *r); 00075 void GetMatrix(Matrix *matrix); 00076 00077 void GetCxform(Cxform *cxform, BOOL hasAlpha); 00078 char *GetString(void); 00079 00080 // Routines for reading arbitrary sized bit fields from the stream. 00081 // Always call start bits before gettings bits and do not intermix 00082 // these calls with GetByte, etc... 00083 void InitBits(); 00084 S32 GetSBits(S32 n); 00085 U32 GetBits(S32 n); 00086 00087 // Tag subcomponent parsing methods 00088 void ParseFillStyle(long getAlpha = 0); 00089 void ParseLineStyle(long getAlpha = 0); 00090 int ParseShapeRecord(long getAlpha = 0); 00091 ButtonRecord * ParseButtonRecord(long getCxform = 0); 00092 ActionRecord * ParseActionRecord(); 00093 TextRecord * ParseTextRecord(int hasAlpha = 0); 00094 void ParseShapeData(int getAlpha, int getStyles); 00095 00096 // Parsing methods. 00097 void ParseEnd(); // 00: stagEnd 00098 void ParseShowFrame(U32 frame, U32 offset); // 01: stagShowFrame 00099 void ParseDefineShape(int level); // 02: stagDefineShape 00100 void ParseFreeCharacter(); // 03: stagFreeCharacter 00101 void ParsePlaceObject(); // 04: stagPlaceObject 00102 void ParseRemoveObject(); // 05: stagRemoveObject 00103 void ParseDefineBits(); // 06: stagDefineBits 00104 void ParseDefineButton(); //x 07: stagDefineButton 00105 void ParseJPEGTables(); // 08: stagJPEGTables 00106 void ParseSetBackgroundColor(); // 09: stagSetBackgroundColor 00107 void ParseDefineFont(); //x 10: stagDefineFont 00108 void ParseDefineText(int hasAplha); //x 11: stagDefineText 33: stagDefineText2 00109 void ParseDoAction(); // 12: stagDoAction 00110 void ParseDefineFontInfo(); //x 13: stagDefineFontInfo 00111 void ParseDefineSound(); // 14: stagDefineSound 00112 void ParseStartSound(); // 15: stagStartSound 00113 void ParseStopSound(); // 16: stagStopSound 00114 void ParseDefineButtonSound(); // 17: stagDefineButtonSound 00115 void ParseSoundStreamHead(); // 18: stagSoundStreamHead 00116 void ParseSoundStreamBlock(); // 19: stagSoundStreamBlock 00117 void ParseDefineBitsLossless(int level); // 20: stagDefineBitsLossless 36: stagDefineBitsLossless2 00118 void ParseDefineBitsJPEG2(); // 21: stagDefineBitsJPEG2 00119 void ParseDefineButtonCxform(); // 23: stagDefineButtonCxform 00120 void ParseProtect(); // 24: stagProtect 00121 void ParsePlaceObject2(); // 26: stagPlaceObject2 00122 void ParseRemoveObject2(); // 28: stagRemoveObject2 00123 void ParseDefineButton2(); //x 34: stagDefineButton2 00124 void ParseDefineBitsJPEG3(); // 35: stagDefineBitsJPEG3 00125 void ParseDefineMouseTarget(); // 38: stagDefineMouseTarget 00126 void ParseDefineSprite(); //x 39: stagDefineSprite 00127 void ParseNameCharacter(); // 40: stagNameCharacter 00128 void ParseFrameLabel(); // 43: stagFrameLabel 00129 void ParseSoundStreamHead2(); // 45: stagSoundStreamHead2 00130 void ParseDefineMorphShape(); //x 46: stagDefineMorphShape 00131 void ParseDefineFont2(); //x 48: stagDefineFont2 00132 void ParseUnknown(long,long); 00133 00134 void ParseTags(int *); 00135 int ParseData(FlashMovie *movie, char * data, long size); 00136 void S_DumpImageGuts(); 00137 00138 #ifdef DUMP 00139 long save(char *filenam); 00140 #endif 00141 }; 00142 00143 00144 #endif /* _SCRIPT_H_ */
1.4.2