public ScriptContextSection(ShockwaveReader input)
 {
     Unknown = input.ReadBigEndian <int>();
     Id      = input.ReadBigEndian <int>();
     Flags   = input.ReadBigEndian <short>(); // 4=Used
     Link    = input.ReadBigEndian <short>();
 }
Exemple #2
0
        public ScriptChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());

            input.ReadBigEndian <int>();
            input.ReadBigEndian <int>();

            input.ReadBigEndian <short>();
            ScriptNumber = input.ReadBigEndian <short>();

            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadInt32());           // -1
            Remnants.Enqueue(input.ReadInt32());           // 0
            Remnants.Enqueue(input.ReadInt32());
            Remnants.Enqueue(input.ReadInt32());           // 0

            BehaviourScript = input.ReadBigEndian <int>(); //enum, Behav=0, Global=2

            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <short>()); //scriptId

            Remnants.Enqueue(input.ReadInt16());

            Pool = new LingoValuePool(this, input);
        }
Exemple #3
0
        public CastListEntry(ShockwaveReader input)
        {
            Name     = input.ReadString();
            FilePath = input.ReadString();

            PreloadSettings = input.ReadBigEndian <short>();
            MemberMin       = input.ReadBigEndian <short>();
            MemberCount     = input.ReadBigEndian <short>();

            Id = input.ReadBigEndian <int>();
        }
Exemple #4
0
 public TextFormat(ShockwaveReader input)
 {
     Offset   = input.ReadBigEndian <int>();
     Height   = input.ReadBigEndian <short>();
     Ascent   = input.ReadBigEndian <short>();
     FontId   = input.ReadBigEndian <short>();
     Slant    = input.ReadBoolean();
     Padding  = input.ReadByte();
     FontSize = input.ReadBigEndian <short>();
     Color    = input.ReadColor();
 }
        public SpriteProperties(ShockwaveReader input)
        {
            StartFrame = input.ReadBigEndian <int>();
            EndFrame   = input.ReadBigEndian <int>();

            input.ReadBigEndian <int>();

            Channel = input.ReadBigEndian <int>();
            SpritePropertiesOffsetsOffset = input.ReadBigEndian <int>();

            input.Position += 28;
        }
Exemple #6
0
        public ShapeCastProperties(ShockwaveReader input)
        {
            Type      = (ShapeType)input.ReadBigEndian <short>();
            Rectangle = input.ReadRect();

            Pattern         = input.ReadBigEndian <short>();
            ForegroundColor = input.ReadByte();
            BackgroundColor = input.ReadByte();
            IsFilled        = input.ReadBoolean(); //TODO:
            LineSize        = input.ReadByte();    //-1
            LineDirection   = input.ReadByte();    //-5
        }
Exemple #7
0
        public TextCastProperties(ShockwaveReader input)
        {
            input.Position += 4;

            Alignment       = (TextAlignment)input.ReadBigEndian <short>();
            BackgroundColor = input.ReadColor();

            Font       = input.ReadBigEndian <short>();
            Rectangle  = input.ReadRect();
            LineHeight = input.ReadBigEndian <short>();

            input.Position += 4;
            ButtonType      = input.ReadBigEndian <short>();
        }
Exemple #8
0
        public StyledTextChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            input.ReadBigEndian <int>();
            int textLength = input.ReadBigEndian <int>();

            input.ReadBigEndian <int>();

            Text = Encoding.UTF8.GetString(input.ReadBytes(textLength)); //TODO:

            Formattings = new TextFormat[input.ReadBigEndian <short>()];
            for (int i = 0; i < Formattings.Length; i++)
            {
                Formattings[i] = new TextFormat(input);
            }
        }
Exemple #9
0
        public Frame(ShockwaveReader input)
        {
            long endOffset = input.Position + input.ReadBigEndian <short>();

            if ((endOffset - input.Position) < 0)
            {
                Debugger.Break(); //We at padding of the framez I guess
            }
            while ((endOffset - input.Position) > 0)
            {
                short  channelLength = input.ReadBigEndian <short>();
                ushort channelOffset = input.ReadBigEndian <ushort>();
                byte[] data          = input.ReadBytes(channelLength);

                Debug.WriteLine($"Channel??: {channelOffset / 48} To: {channelOffset} | Len: {channelLength} | Left: {(endOffset - input.Position)}");
            }
        }
Exemple #10
0
        public XtraListChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            Remnants.Enqueue(input.ReadBigEndian <int>());

            int xtraCount = input.ReadBigEndian <int>();

            for (int i = 0; i < xtraCount; i++)
            {
                long xtraEndOffset = input.Position + input.ReadBigEndian <int>() + 4;

                int  unk2 = input.ReadBigEndian <int>();
                int  unk3 = input.ReadBigEndian <int>(); //Flags or just booleans?
                Guid guid = new Guid(input.ReadBytes(16));

                int[] offsets = new int[input.ReadBigEndian <short>() + 1];
                for (int j = 0; j < offsets.Length; j++)
                {
                    offsets[j] = input.ReadBigEndian <int>();
                }

                do
                {
                    byte unk4 = input.ReadByte(); // 1 when kind = URL
                    byte kind = input.ReadByte(); // 2 -> Name | 0 -> URL, 5 -> File, x32 ?!? no idea

                    string str = input.ReadString();
                    input.ReadByte();
                }while (input.Position != xtraEndOffset);
            }
        }
Exemple #11
0
 public CastAssociationTableChunk(ShockwaveReader input, ChunkHeader header)
     : base(header)
 {
     Members = new int[(int)header.Length / sizeof(int)];
     for (int i = 0; i < Members.Length; i++)
     {
         Members[i] = input.ReadBigEndian <int>();
     }
 }
        public CommonMemberProperties(ShockwaveReader input)
        {
            int[] propertyOffsets = new int[input.ReadBigEndian <short>() + 1];
            for (int i = 0; i < propertyOffsets.Length; i++)
            {
                propertyOffsets[i] = input.ReadBigEndian <int>();
            }

            for (int i = 0; i < propertyOffsets.Length - 1; i++)
            {
                int length = propertyOffsets[i + 1] - propertyOffsets[i];
                if (length < 1)
                {
                    continue;
                }

                ReadProperty(input, i, length);
            }
        }
Exemple #13
0
        public void ReadValue(ShockwaveReader input, long dataOffset)
        {
            if (Kind != LiteralKind.Integer)
            {
                input.Position = dataOffset + Offset;

                int length = input.ReadBigEndian <int>();
                Value = Kind switch
                {
                    LiteralKind.String => input.ReadString(length),
                    LiteralKind.Float => input.ReadBigEndian <long>(),
                    LiteralKind.CompiledJavascript => input.ReadBytes(length)
                };
            }
            else
            {
                Value = Offset;
            }
        }
Exemple #14
0
        public CastMemberPropertiesChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            Type = (CastType)input.ReadBigEndian <int>();
            input.ReadBigEndian <int>();
            int dataLength = input.ReadBigEndian <int>();

            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());

            Common     = new CommonMemberProperties(input);
            Properties = ReadTypeProperties(input, dataLength);
        }
Exemple #15
0
        public FileInfoChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            int bitfieldLen = input.ReadBigEndian <int>();

            BitField = input.ReadBytes(bitfieldLen);

            Offsets = new List <int>(input.ReadBigEndian <short>());

            input.ReadByte();

            for (short i = 0; i < Offsets.Capacity; i++)
            {
                Offsets.Add(input.ReadBigEndian <int>());
            }

            input.ReadByte();
            CreatedBy = input.ReadString();
            input.ReadByte();
            ModifiedBy = input.ReadString();
            input.ReadByte();
            FilePath = input.ReadString();
        }
        public ScoreReferenceChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            input.ReadBigEndian <int>();
            input.ReadBigEndian <int>();

            int entryCount = input.ReadBigEndian <int>();
            int validCount = input.ReadBigEndian <int>();

            input.ReadBigEndian <short>();
            input.ReadBigEndian <short>();

            Remnants.Enqueue(input.ReadBigEndian <int>());

            Entries = new Dictionary <short, int>(entryCount);
            for (int i = 0; i < entryCount; i++)
            {
                Entries.Add(input.ReadBigEndian <short>(), input.ReadBigEndian <int>());
            }
        }
Exemple #17
0
        public BitmapCastProperties(ChunkHeader header, ShockwaveReader input)
        {
            bool IsDataAvailable()
            => input.Position < header.Offset + header.Length;

            TotalWidth = input.ReadBigEndian <ushort>() & 0x7FFF;

            Rectangle      = input.ReadRect();
            AlphaThreshold = input.ReadByte();
            OLE            = input.ReadBytes(7); //TODO:

            short regX = input.ReadBigEndian <short>();
            short regY = input.ReadBigEndian <short>();

            RegistrationPoint = new Point(regX, regY);

            Flags = (BitmapFlags)input.ReadByte();

            if (!IsDataAvailable())
            {
                return;
            }
            BitDepth = input.ReadByte();

            if (!IsDataAvailable())
            {
                return;
            }
            Palette = input.ReadBigEndian <int>();

            //TODO: PaletteRef or something
            if (!IsSystemPalette)
            {
                Palette &= 0x7FFF;
            }
        }
        public VideoCastProperties(ShockwaveReader input)
        {
            Type            = input.ReadString((int)input.ReadBigEndian <uint>());
            input.Position += 10;

            byte videoFlags = input.ReadByte();

            Streaming = ((videoFlags & 1) == 1);

            videoFlags    = input.ReadByte();
            HasSound      = ((videoFlags & 1) == 1);
            PausedAtStart = ((videoFlags & 2) == 2);

            Flags           = (VideoCastFlags)input.ReadByte();
            input.Position += 3;
            Framerate       = input.ReadByte();
            input.Position += 32;
            Rectangle       = input.ReadRect();
        }
Exemple #19
0
        public SortOrderChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());

            Entries = new List <int>(input.ReadBigEndian <int>());

            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());

            for (int i = 0; i < Entries.Capacity; i++)
            {
                Entries.Add(input.ReadBigEndian <int>());
            }
        }
Exemple #20
0
        public NameTableChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());
            input.ReadBigEndian <int>();
            input.ReadBigEndian <int>();

            short nameOffset = input.ReadBigEndian <short>();

            Names = new List <string>(input.ReadBigEndian <short>());

            input.Position = Header.Offset + nameOffset;
            for (int i = 0; i < Names.Capacity; i++)
            {
                Names.Add(input.ReadString());
            }
        }
Exemple #21
0
        public MovieCastListChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            Remnants.Enqueue(input.ReadBigEndian <int>());
            Entries = new List <CastListEntry>(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <short>());

            Unknowns = new int[input.ReadBigEndian <int>()];
            for (int i = 0; i < Unknowns.Length; i++)
            {
                Unknowns[i] = input.ReadBigEndian <int>();
            }

            input.ReadBigEndian <int>();
            for (int i = 0; i < Entries.Capacity; i++)
            {
                Entries.Add(new CastListEntry(input));
            }
        }
Exemple #22
0
        public ScoreChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            int totalLength = input.ReadBigEndian <int>();
            int headerType  = input.ReadBigEndian <int>(); //-3

            int spritePropertiesOffsetThingy = input.ReadBigEndian <int>();

            int[] spritePropertyOffsets = new int[input.ReadBigEndian <int>() + 1];

            int notationOffset           = input.ReadBigEndian <int>() * 4 + 12 + spritePropertiesOffsetThingy;
            int lastSpritePropertyOffset = input.ReadBigEndian <int>();

            for (int i = 0; i < spritePropertyOffsets.Length; i++)
            {
                spritePropertyOffsets[i] = input.ReadBigEndian <int>();
            }

            Debug.Assert(input.Position == (Header.Offset + notationOffset), "What");

            int frameEndOffset = input.ReadBigEndian <int>();

            Remnants.Enqueue(input.ReadBigEndian <int>());

            Frames = new Frame[input.ReadBigEndian <int>()];
            short framesType = input.ReadBigEndian <short>(); //13, 14

            short channelLength  = input.ReadBigEndian <short>();
            short lastChannelMax = input.ReadBigEndian <short>(); //1006
            short lastChannel    = input.ReadBigEndian <short>();

            for (int i = 0; i < Frames.Length; i++)
            {
                Frames[i] = new Frame(input);
            }

            int[] spritePropertyOffsetIndices = new int[input.ReadBigEndian <int>()];
            for (int i = 0; i < spritePropertyOffsetIndices.Length; i++)
            {
                spritePropertyOffsetIndices[i] = input.ReadBigEndian <int>();
            }

            SpriteProperties[] spriteProperties = new SpriteProperties[spritePropertyOffsetIndices.Length];
            for (int i = 0; i < spritePropertyOffsetIndices.Length; i++)
            {
                int spritePropertyOffset = spritePropertyOffsets[spritePropertyOffsetIndices[i]];

                input.Position      = Header.Offset + notationOffset + spritePropertyOffset;
                spriteProperties[i] = new SpriteProperties(input);
            }
        }
Exemple #23
0
        public LingoHandler(ScriptChunk script, ShockwaveReader input)
            : this(script)
        {
            NameIndex             = input.ReadBigEndian <short>();
            HandlerVectorPosition = input.ReadBigEndian <short>();

            Body        = new LingoHandlerBody(this, input);
            _codeOffset = input.ReadBigEndian <int>();

            Arguments.Capacity = input.ReadBigEndian <short>();
            _argumentsOffset   = input.ReadBigEndian <int>();

            Locals.Capacity = input.ReadBigEndian <short>();
            _localsOffset   = input.ReadBigEndian <int>();

            short unk1Length = input.ReadBigEndian <short>();
            int   unk1Offset = input.ReadBigEndian <int>();

            int unk2Length = input.ReadBigEndian <int>();
            int unk2Offset = input.ReadBigEndian <short>();

            BytesPerLine.Capacity = input.ReadBigEndian <short>();
            _lineOffset           = input.ReadBigEndian <int>();

            Body.StackHeight = input.ReadBigEndian <int>();
        }
        private void ReadProperty(ShockwaveReader input, int index, int length)
        {
            switch (index)
            {
            case 0:
                ScriptText = input.ReadString(length);
                break;

            case 1:
                Name = input.ReadString();
                break;

            case 2:
                FilePath = input.ReadString(length);
                break;

            case 3:
                FileName = input.ReadString(length);
                break;

            case 4:
                FileType = input.ReadString(length);
                break;

            case 9:
                XtraGUID = new Guid(input.ReadBytes(length));
                break;

            case 10:
                XtraName = input.ReadNullString();
                break;

            case 11:     //TODO:
                break;

            case 12:
                RegistrationPoints = new int[length / 4];
                for (int i = 0; i < RegistrationPoints.Length; i++)
                {
                    RegistrationPoints[i] = input.ReadBigEndian <int>();
                }
                break;

            case 16:
                ClipboardFormat = input.ReadString(length);
                break;

            case 17:
                CreationDate = input.ReadBigEndian <int>() * 1000;
                break;

            case 18:
                ModifiedDate = input.ReadBigEndian <int>() * 1000;
                break;

            case 19:
                ModifiedBy = input.ReadNullString();
                break;

            case 20:
                Comments = input.ReadString(length);
                break;

            case 21:
                byte[] imageFlags = input.ReadBytes(length);     //4

                ImageCompression = imageFlags[0] >> 4;
                ImageQuality     = imageFlags[1];
                break;

            case 7:
            default:
                byte[] unknown = input.ReadBytes(length);
                break;
            }
        }
Exemple #25
0
 public LingoHandlerBody(LingoHandler handler, ShockwaveReader input)
     : this(handler)
 {
     Code = new byte[input.ReadBigEndian <int>()];
 }
Exemple #26
0
 public ScriptCastProperties(ShockwaveReader input)
 {
     ScriptNumber = input.ReadBigEndian <short>();
 }
Exemple #27
0
 public LingoLiteral(ShockwaveReader input)
 {
     Kind   = (LiteralKind)input.ReadBigEndian <int>();
     Offset = input.ReadBigEndian <int>();
 }
Exemple #28
0
        public ConfigChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            input.ReadBigEndian <short>();
            Version = (DirectorVersion)input.ReadBigEndian <ushort>();

            StageRectangle = input.ReadRect();

            MinMember = input.ReadBigEndian <short>(); //Obsolete
            MaxMember = input.ReadBigEndian <short>(); //Obsolete

            Tempo = input.ReadByte();
            Remnants.Enqueue(input.ReadByte());

            byte g = input.ReadByte();
            byte b = input.ReadByte();

            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadBigEndian <short>());

            //https://www.youtube.com/watch?v=sA_eCl4Txzs
            byte r = input.ReadByte();

            StageBackgroundColor = Color.FromArgb(r, g, b);

            Remnants.Enqueue(input.ReadByte());
            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadByte()); //-2 when version < 0x551
            Remnants.Enqueue(input.ReadByte());
            Remnants.Enqueue(input.ReadBigEndian <int>());

            MovieVersion = (DirectorVersion)input.ReadBigEndian <short>();
            Remnants.Enqueue(input.ReadBigEndian <short>());//16?
            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadByte());
            Remnants.Enqueue(input.ReadByte());
            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadBigEndian <short>());

            RandomNumber = input.ReadBigEndian <short>();

            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());
            OldDefaultPalette = input.ReadBigEndian <short>();
            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadBigEndian <int>());
            DefaultPalette = input.ReadBigEndian <int>(); //TODO:
            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadBigEndian <short>());
            DownloadFramesBeforePlaying = input.ReadBigEndian <int>(); //90
            //Zeros
            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadBigEndian <short>());
            Remnants.Enqueue(input.ReadBigEndian <short>());
        }
        public ScriptContextChunk(ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            Remnants.Enqueue(input.ReadBigEndian <int>());
            Remnants.Enqueue(input.ReadBigEndian <int>());

            int entryCount = input.ReadBigEndian <int>();

            input.ReadBigEndian <int>();

            short entryOffset = input.ReadBigEndian <short>(); //TODO: Research

            input.ReadBigEndian <short>();

            Remnants.Enqueue(input.ReadBigEndian <int>()); //0
            Type = input.ReadBigEndian <int>();            //TODO: Enum
            Remnants.Enqueue(input.ReadBigEndian <int>());

            NameListChunkId = input.ReadBigEndian <int>();

            Remnants.Enqueue(input.ReadBigEndian <short>()); //validCount
            Remnants.Enqueue(input.ReadBytes(2));            //flags, short?
            Remnants.Enqueue(input.ReadBigEndian <short>()); //freePtr

            input.Position = Header.Offset + entryOffset;

            Sections = new List <ScriptContextSection>(entryCount);
            for (int i = 0; i < entryCount; i++)
            {
                Sections.Add(new ScriptContextSection(input));
            }
        }