예제 #1
0
 private void AddScope(DefineFunction2 scope, SwfReader r)
 {
     AddScope(scope.ActionContainer, r);
 }
예제 #2
0
 internal ActionRecords(SwfReader r, uint tagLen) : this(r, tagLen, false)
 {
 }
예제 #3
0
        internal ActionRecords(SwfReader r, uint tagLen, bool isInitTag)
        {
            this.IsInitActions = isInitTag;
            if (isInitTag)
            {
                InitTarget = r.GetUI16();
            }

            CodeSize = tagLen;
            uint codeEnd = r.Position + tagLen;             // clip events dont have an end tag

            AddScope(this, r);
            AddLineNumber(r.Position);

            ActionKind actionCode = (ActionKind)0xFF;
            bool       hitEnd     = false;

            while (r.Position < codeEnd && !hitEnd)             //(actionCode != ActionKind.End))
            {
                if (r.Position >= curBounds)
                {
                    RemoveScope();
                }
                actionCode = (ActionKind)r.GetByte();
                uint len = 0;
                if (((byte)actionCode & 0x80) > 0)
                {
                    len = r.GetUI16();
                }
                AddLineNumber(r.Position + len);

                switch (actionCode)
                {
                case ActionKind.Add:
                    curStatements.Add(new Add());
                    break;

                case ActionKind.Add2:
                    curStatements.Add(new Add2());
                    break;

                case ActionKind.And:
                    curStatements.Add(new And());
                    break;

                case ActionKind.AsciiToChar:
                    curStatements.Add(new AsciiToChar());
                    break;

                case ActionKind.BitAnd:
                    curStatements.Add(new BitAnd());
                    break;

                case ActionKind.BitLShift:
                    curStatements.Add(new BitLShift());
                    break;

                case ActionKind.BitOr:
                    curStatements.Add(new BitOr());
                    break;

                case ActionKind.BitRShift:
                    curStatements.Add(new BitRShift());
                    break;

                case ActionKind.BitURShift:
                    curStatements.Add(new BitURShift());
                    break;

                case ActionKind.BitXor:
                    curStatements.Add(new BitXor());
                    break;

                case ActionKind.Call:
                    curStatements.Add(new Call());
                    break;

                case ActionKind.CallFunction:
                    curStatements.Add(new CallFunction());
                    break;

                case ActionKind.CallMethod:
                    curStatements.Add(new CallMethod());
                    break;

                case ActionKind.CastOp:
                    curStatements.Add(new CastOp());
                    break;

                case ActionKind.CharToAscii:
                    curStatements.Add(new CharToAscii());
                    break;

                case ActionKind.CloneSprite:
                    curStatements.Add(new CloneSprite());
                    break;

                case ActionKind.ConstantPool:
                    ConstantPool cp = new ConstantPool(r);                             // todo: will need stack for cp
                    CurrentConstantPool = cp;
                    curStatements.Add(cp);
                    break;

                case ActionKind.Decrement:
                    curStatements.Add(new Decrement());
                    break;

                case ActionKind.DefineFunction:
                    DefineFunction df = new DefineFunction(r, CurrentConstantPool);
                    curStatements.Add(df);
                    AddScope(df, r);
                    AddLineLabel((uint)(r.Position + df.CodeSize));
                    break;

                case ActionKind.DefineFunction2:
                    DefineFunction2 df2 = new DefineFunction2(r, CurrentConstantPool);
                    curStatements.Add(df2);
                    AddScope(df2, r);
                    AddLineLabel((uint)(r.Position + df2.ActionContainer.CodeSize));
                    break;

                case ActionKind.DefineLocal:
                    curStatements.Add(new DefineLocal());
                    break;

                case ActionKind.DefineLocal2:
                    curStatements.Add(new DefineLocal2());
                    break;

                case ActionKind.Delete:
                    curStatements.Add(new Delete());
                    break;

                case ActionKind.Delete2:
                    curStatements.Add(new Delete2());
                    break;

                case ActionKind.Divide:
                    curStatements.Add(new Divide());
                    break;

                case ActionKind.End:
                    curStatements.Add(new End());
                    hitEnd = true;
                    break;

                case ActionKind.EndDrag:
                    curStatements.Add(new EndDrag());
                    break;

                case ActionKind.Enumerate:
                    curStatements.Add(new Enumerate());
                    break;

                case ActionKind.Enumerate2:
                    curStatements.Add(new Enumerate2());
                    break;

                case ActionKind.Equals:
                    curStatements.Add(new Equals());
                    break;

                case ActionKind.Equals2:
                    curStatements.Add(new Equals2());
                    break;

                case ActionKind.Extends:
                    curStatements.Add(new Extends());
                    break;

                case ActionKind.GetMember:
                    curStatements.Add(new GetMember());
                    break;

                case ActionKind.GetProperty:
                    curStatements.Add(new GetProperty());
                    break;

                case ActionKind.GetTime:
                    curStatements.Add(new GetTime());
                    break;

                case ActionKind.GetURL:
                    curStatements.Add(new GetURL(r));
                    break;

                case ActionKind.GetURL2:
                    curStatements.Add(new GetURL2(r));
                    break;

                case ActionKind.GetVariable:
                    curStatements.Add(new GetVariable());
                    break;

                case ActionKind.GoToLabel:
                    curStatements.Add(new GoToLabel(r));
                    break;

                case ActionKind.GotoFrame:
                    curStatements.Add(new GotoFrame(r));
                    break;

                case ActionKind.GotoFrame2:
                    curStatements.Add(new GotoFrame2(r));
                    break;

                case ActionKind.Greater:
                    curStatements.Add(new Greater());
                    break;

                case ActionKind.If:
                    If ifTag = new If(r);
                    curStatements.Add(ifTag);
                    AddLineLabel((uint)(r.Position + ifTag.BranchOffset));
                    break;

                case ActionKind.ImplementsOp:
                    curStatements.Add(new ImplementsOp());
                    break;

                case ActionKind.Increment:
                    curStatements.Add(new Increment());
                    break;

                case ActionKind.InitArray:
                    curStatements.Add(new InitArray());
                    break;

                case ActionKind.InitObject:
                    curStatements.Add(new InitObject());
                    break;

                case ActionKind.InstanceOf:
                    curStatements.Add(new InstanceOf());
                    break;

                case ActionKind.Jump:
                    Jump jump = new Jump(r);
                    curStatements.Add(jump);
                    AddLineLabel((uint)(r.Position + jump.BranchOffset));
                    break;

                case ActionKind.Less:
                    curStatements.Add(new Less());
                    break;

                case ActionKind.Less2:
                    curStatements.Add(new Less2());
                    break;

                case ActionKind.MBAsciiToChar:
                    curStatements.Add(new MBAsciiToChar());
                    break;

                case ActionKind.MBCharToAscii:
                    curStatements.Add(new MBCharToAscii());
                    break;

                case ActionKind.MBStringExtract:
                    curStatements.Add(new MBStringExtract());
                    break;

                case ActionKind.MBStringLength:
                    curStatements.Add(new MBStringLength());
                    break;

                case ActionKind.Modulo:
                    curStatements.Add(new Modulo());
                    break;

                case ActionKind.Multiply:
                    curStatements.Add(new Multiply());
                    break;

                case ActionKind.NewMethod:
                    curStatements.Add(new NewMethod());
                    break;

                case ActionKind.NewObject:
                    curStatements.Add(new NewObject());
                    break;

                case ActionKind.NextFrame:
                    curStatements.Add(new NextFrame());
                    break;

                case ActionKind.Not:
                    curStatements.Add(new Not());
                    break;

                case ActionKind.Or:
                    curStatements.Add(new Or());
                    break;

                case ActionKind.Play:
                    curStatements.Add(new Play());
                    break;

                case ActionKind.Pop:
                    curStatements.Add(new Pop());
                    break;

                case ActionKind.PreviousFrame:
                    curStatements.Add(new PreviousFrame());
                    break;

                case ActionKind.Push:
                    curStatements.Add(new Push(r, len + r.Position));
                    break;

                case ActionKind.PushDuplicate:
                    curStatements.Add(new PushDuplicate());
                    break;

                case ActionKind.RandomNumber:
                    curStatements.Add(new RandomNumber());
                    break;

                case ActionKind.RemoveSprite:
                    curStatements.Add(new RemoveSprite());
                    break;

                case ActionKind.Return:
                    curStatements.Add(new Return());
                    break;

                case ActionKind.SetMember:
                    curStatements.Add(new SetMember());
                    break;

                case ActionKind.SetProperty:
                    curStatements.Add(new SetProperty());
                    break;

                case ActionKind.SetTarget:
                    curStatements.Add(new SetTarget(r));
                    break;

                case ActionKind.SetTarget2:
                    curStatements.Add(new SetTarget2());
                    break;

                case ActionKind.SetVariable:
                    curStatements.Add(new SetVariable());
                    break;

                case ActionKind.StackSwap:
                    curStatements.Add(new StackSwap());
                    break;

                case ActionKind.StartDrag:
                    curStatements.Add(new StartDrag());
                    break;

                case ActionKind.Stop:
                    curStatements.Add(new Stop());
                    break;

                case ActionKind.StopSounds:
                    curStatements.Add(new StopSounds());
                    break;

                case ActionKind.StoreRegister:
                    curStatements.Add(new StoreRegister(r));
                    break;

                case ActionKind.StrictEquals:
                    curStatements.Add(new StrictEquals());
                    break;

                case ActionKind.StringAdd:
                    curStatements.Add(new StringAdd());
                    break;

                case ActionKind.StringEquals:
                    curStatements.Add(new StringEquals());
                    break;

                case ActionKind.StringExtract:
                    curStatements.Add(new StringExtract());
                    break;

                case ActionKind.StringGreater:
                    curStatements.Add(new StringGreater());
                    break;

                case ActionKind.StringLength:
                    curStatements.Add(new StringLength());
                    break;

                case ActionKind.StringLess:
                    curStatements.Add(new StringLess());
                    break;

                case ActionKind.Subtract:
                    curStatements.Add(new Subtract());
                    break;

                case ActionKind.TargetPath:
                    curStatements.Add(new TargetPath());
                    break;

                case ActionKind.Throw:
                    //					curStatements.Add(new Throw(r));
                    break;

                case ActionKind.ToInteger:
                    curStatements.Add(new ToInteger());
                    break;

                case ActionKind.ToNumber:
                    curStatements.Add(new ToNumber());
                    break;

                case ActionKind.ToString:
                    curStatements.Add(new ToString());
                    break;

                case ActionKind.ToggleQuality:
                    curStatements.Add(new ToggleQuality());
                    break;

                case ActionKind.Trace:
                    curStatements.Add(new Trace());
                    break;

                case ActionKind.Try:
                    //					curStatements.Add(new Try(r));
                    break;

                case ActionKind.TypeOf:
                    curStatements.Add(new TypeOf());
                    break;

                case ActionKind.WaitForFrame:
                    curStatements.Add(new WaitForFrame(r));
                    break;

                case ActionKind.WaitForFrame2:
                    curStatements.Add(new WaitForFrame2(r));
                    break;

                case ActionKind.With:
                    //					curStatements.Add(new With(r));
                    break;
                }
            }
            GenerateLabels();
        }
예제 #4
0
        //internal ClipActions ClipActions;

        internal PlaceObject3Tag(SwfReader r)
        {
            tagType = TagType.PlaceObject3;

            HasClipActions    = r.GetBit();
            HasClipDepth      = r.GetBit();
            HasName           = r.GetBit();
            HasRatio          = r.GetBit();
            HasColorTransform = r.GetBit();
            HasMatrix         = r.GetBit();
            HasCharacter      = r.GetBit();
            Move = r.GetBit();

            r.GetBits(5);             // reserved
            PlaceFlagHasCacheAsBitmap = r.GetBit();
            PlaceFlagHasBlendMode     = r.GetBit();
            PlaceFlagHasFilterList    = r.GetBit();

            Depth = r.GetUI16();

            if (HasCharacter)
            {
                Character = r.GetUI16();
            }
            if (HasMatrix)
            {
                Matrix = new Matrix(r);
            }
            if (HasColorTransform)
            {
                ColorTransform = new ColorTransform(r, true);
            }
            if (HasRatio)
            {
                Ratio = r.GetUI16();
            }
            if (HasName)
            {
                Name = r.GetString();
            }
            if (HasClipDepth)
            {
                ClipDepth = r.GetUI16();
            }

            if (PlaceFlagHasFilterList)
            {
                uint filterCount = (uint)r.GetByte();
                FilterList = new List <IFilter>();
                for (int i = 0; i < filterCount; i++)
                {
                    FilterKind kind = (FilterKind)r.GetByte();
                    switch (kind)
                    {
                    case FilterKind.Bevel:
                        FilterList.Add(new FilterBevel(r));
                        break;

                    case FilterKind.Blur:
                        FilterList.Add(new FilterBlur(r));
                        break;

                    case FilterKind.ColorMatrix:
                        FilterList.Add(new FilterColorMatrix(r));
                        break;

                    case FilterKind.Convolution:
                        FilterList.Add(new FilterConvolution(r));
                        break;

                    case FilterKind.DropShadow:
                        FilterList.Add(new FilterDropShadow(r));
                        break;

                    case FilterKind.Glow:
                        FilterList.Add(new FilterGlow(r));
                        break;

                    case FilterKind.GradientBevel:
                        FilterList.Add(new FilterGradientBevel(r));
                        break;

                    case FilterKind.GradientGlow:
                        FilterList.Add(new FilterGradientGlow(r));
                        break;

                    default:
                        // unsupported filter
                        break;
                    }
                }
            }
            if (PlaceFlagHasBlendMode)
            {
                BlendMode = (BlendMode)r.GetByte();
            }


            if (HasClipActions)
            {
                //ClipActions = new ClipActions();
            }
        }
예제 #5
0
 internal ShowFrame(SwfReader r)
     : base(TagType.ShowFrame)
 {
 }
예제 #6
0
        internal DefineBitsLosslessTag(SwfReader r, uint curTagLen, bool hasAlpha)
            : base(TagType.DefineBitsLossless)
        {
            TagLen   = curTagLen;
            HasAlpha = hasAlpha;
            if (hasAlpha)
            {
                tagType = TagType.DefineBitsLossless2;
            }

            CharacterId  = r.GetUI16();
            BitmapFormat = (BitmapFormat)r.GetByte();

            this.Width  = r.GetUI16();
            this.Height = r.GetUI16();

            if (BitmapFormat == BitmapFormat.Colormapped8Bit) // 8-bit colormapped image
            {
                this.ColorCount = (uint)r.GetByte() + 1;

                this.isIndexedColors = true;
                uint colorBytes = hasAlpha ? (uint)4 : (uint)3;
                uint padWidth   = this.Width + (4 - (this.Width % 4));

                // temp for debugging
                uint pos = r.Position;
                OrgBitmapData = r.GetBytes(curTagLen - 8);
                r.Position    = pos;
                // end temp

                uint   unzippedSize = (this.ColorCount * colorBytes) + (padWidth * this.Height);
                byte[] mapData      = r.DecompressZLIB(curTagLen - 8, unzippedSize);

                uint index = 0;
                this.ColorTable = new RGBA[this.ColorCount];
                for (int i = 0; i < this.ColorCount; i++)
                {
                    if (hasAlpha)
                    {
                        this.ColorTable[i] = new RGBA(mapData[index], mapData[index + 1], mapData[index + 2], mapData[index + 3]);
                    }
                    else
                    {
                        this.ColorTable[i] = new RGBA(mapData[index], mapData[index + 1], mapData[index + 2]);
                    }
                    index += colorBytes;
                }
                this.ColorData = new uint[this.Width * this.Height];
                index          = 0;
                int offset = (int)(this.ColorCount * colorBytes);
                for (int i = 0; i < padWidth * this.Height; i++)
                {
                    if ((i % padWidth) < this.Width)                    // exclude padding
                    {
                        this.ColorData[index++] = mapData[i + offset];
                    }
                }
            }
            else if (BitmapFormat == BitmapFormat.RGB15Bit) // RGBx555
            {
                // todo: find a test file for rgb555
                uint colorBytes = 2;
                uint padWidth   = this.Width * colorBytes;
                padWidth += (4 - padWidth) % 4;

                // temp for debugging
                uint pos = r.Position;
                OrgBitmapData = r.GetBytes(curTagLen - 7);
                r.Position    = pos;
                // end temp

                uint   unzippedSize = (padWidth * this.Height) * colorBytes;
                byte[] mapData      = r.DecompressZLIB(curTagLen - 7, unzippedSize);

                int index = 0;
                this.BitmapData = new RGBA[this.Width * this.Height];
                for (uint i = 0; i < unzippedSize; i += colorBytes)
                {
                    if ((i % padWidth) < (this.Width * colorBytes))                     // exclude padding
                    {
                        byte b0 = mapData[i];
                        byte b1 = mapData[i + 1];
                        byte rd = (byte)((b0 & 0x7C) << 1);
                        byte gr = (byte)(((b0 & 0x03) << 6) | ((b1 & 0xE0) >> 2));
                        byte bl = (byte)((b1 & 0x1F) << 3);
                        this.BitmapData[index++] = new RGBA(rd, gr, bl);
                    }
                }
            }
            else if (BitmapFormat == BitmapFormat.RGB24Bit) // RGB 24
            {
                // temp for debugging
                uint pos = r.Position;
                OrgBitmapData = r.GetBytes(curTagLen - 7);
                r.Position    = pos;
                // end temp

                uint   colorBytes   = 4;             // 4 bytes will always be byte aligned
                uint   unzippedSize = (this.Width * this.Height) * colorBytes;
                byte[] mapData      = r.DecompressZLIB(curTagLen - 7, unzippedSize);

                int index = 0;
                this.BitmapData = new RGBA[this.Width * this.Height];
                for (uint i = 0; i < unzippedSize; i += colorBytes)
                {
                    if (hasAlpha)
                    {
                        this.BitmapData[index++] = new RGBA(mapData[i + 1], mapData[i + 2], mapData[i + 3], mapData[i]);
                    }
                    else
                    {
                        this.BitmapData[index++] = new RGBA(mapData[i + 1], mapData[i + 2], mapData[i + 3]);
                    }
                }
            }
        }
예제 #7
0
 internal FileAttributesTag(SwfReader r)
     : base(TagType.FileAttributes)
 {
     this._flags = r.GetUI32();
 }
예제 #8
0
 internal PrimitiveUndefined(SwfReader r)
 {
 }
예제 #9
0
 internal ClipActionRecord(SwfReader r) : this(r, true)
 {
 }
예제 #10
0
 internal ScriptLimitsTag(SwfReader r)
     : base(TagType.ScriptLimits)
 {
     ScriptRecursionLimit = r.GetInt16();
     ScriptTimeLimit      = r.GetInt16();
 }
예제 #11
0
 internal Mp3Frame(SwfReader r)
 {
     //r.GetBytes();
 }
예제 #12
0
 internal DefineButtonCxform(SwfReader r)
     : base(TagType.DefineButtonCxform)
 {
     ButtonId             = r.GetUI16();
     ButtonColorTransform = new ColorTransform(r, false);
 }
예제 #13
0
 internal BackgroundColorTag(SwfReader r)
     : base(TagType.BackgroundColor)
 {
     this.Color = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), 0xFF);
 }
예제 #14
0
 internal WaitForFrame(SwfReader r)
 {
     Frame     = r.GetUI16();
     SkipCount = (uint)r.GetByte();
 }
예제 #15
0
 internal UnsupportedDefinitionTag(SwfReader r, uint tagType, string msg)
     : base(tagType)
 {
     this.Message = msg;
 }
예제 #16
0
 internal PrimitiveFloat(SwfReader r)
 {
     FloatValue = r.GetFixedNBits(32);
 }
예제 #17
0
 internal PrimitiveInteger(SwfReader r)
 {
     IntegerValue = r.GetInt32();
 }
예제 #18
0
파일: Push.cs 프로젝트: Screeder/GameFiles
        internal Push(SwfReader r, uint maxLen)
        {
            PrimitiveType type;

            while (r.Position < maxLen)
            {
                type = (PrimitiveType)(r.GetByte());
                switch (type)
                {
                case PrimitiveType.String:
                {
                    Values.Add(new PrimitiveString(r));
                    break;
                }

                case PrimitiveType.Float:
                {
                    Values.Add(new PrimitiveFloat(r));
                    break;
                }

                case PrimitiveType.Null:
                {
                    Values.Add(new PrimitiveNull(r));
                    break;
                }

                case PrimitiveType.Register:
                {
                    Values.Add(new PrimitiveRegister(r));
                    break;
                }

                case PrimitiveType.Boolean:
                {
                    Values.Add(new PrimitiveBoolean(r));
                    break;
                }

                case PrimitiveType.Double:
                {
                    Values.Add(new PrimitiveDouble(r));
                    break;
                }

                case PrimitiveType.Integer:
                {
                    Values.Add(new PrimitiveInteger(r));
                    break;
                }

                case PrimitiveType.Constant8:
                {
                    Values.Add(new PrimitiveConstant8(r));
                    break;
                }

                case PrimitiveType.Constant16:
                {
                    Values.Add(new PrimitiveConstant16(r));
                    break;
                }

                case PrimitiveType.Undefined:
                {
                    Values.Add(new PrimitiveUndefined(r));
                    break;
                }
                }
            }
        }
예제 #19
0
        //internal List<GlyphShape> GlyphShapeTable;

        internal DefineFontTag(SwfReader r)
            : base(TagType.DefineFont)
        {
        }
예제 #20
0
 internal RemoveObject2Tag(SwfReader r)
     : base(TagType.RemoveObject2)
 {
     this.Depth = r.GetUI16();
 }