Ejemplo n.º 1
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>();
        }
Ejemplo n.º 2
0
 public ChunkHeader(ShockwaveReader input)
     : this(input.ReadReversedString(4))
 {
     Length = (IsVariableLength ?
               input.Read7BitEncodedInt() : input.ReadInt32());
     Offset = input.Position;
 }
Ejemplo n.º 3
0
        public XtraListChunk(ref ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            Remnants.Enqueue(input.ReadInt32());

            int xtraCount = input.ReadInt32();

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

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

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

                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);
            }
        }
Ejemplo n.º 4
0
        private void ReadInitialLoadSegment(ref ShockwaveReader input, AfterBurnerMapEntry[] entries, Dictionary <int, ChunkItem> chunks)
        {
            //First entry in the AfterBurnerMap must be ILS.
            AfterBurnerMapEntry ilsEntry = entries[0];

            input.Advance(ilsEntry.Offset);

            //TODO: this shouldn't be here
            ReadOnlySpan <byte> compressedData = input.ReadBytes(ilsEntry.Length);

            Span <byte> decompressedData = ilsEntry.DecompressedLength <= 1024 ?
                                           stackalloc byte[ilsEntry.DecompressedLength] : new byte[ilsEntry.DecompressedLength];

            ZLib.Decompress(compressedData, decompressedData);

            ShockwaveReader ilsReader = new ShockwaveReader(decompressedData, input.IsBigEndian);

            while (ilsReader.IsDataAvailable)
            {
                int id = ilsReader.Read7BitEncodedInt();

                AfterBurnerMapEntry entry = entries.FirstOrDefault(e => e.Id == id); //TODO: Chunk entries as dictionary
                if (entry == null)
                {
                    break;
                }

                chunks.Add(id, Read(ref ilsReader, entry.Header));
            }
        }
Ejemplo n.º 5
0
        public BitmapCastProperties(ref ShockwaveReader input)
        {
            int v27 = input.ReadUInt16();

            TotalWidth = v27 & 0x7FFF; //TODO: what does that last bit even do.. some sneaky flag?
            //DIRAPI checks if TotalWidth & 0x8000 == 0

            Rectangle      = input.ReadRect();
            AlphaThreshold = input.ReadByte();
            OLE            = input.ReadBytes(7).ToArray();

            RegistrationPoint = input.ReadPoint();

            Flags = (BitmapFlags)input.ReadByte();

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

            if (!input.IsDataAvailable)
            {
                return;
            }
            Palette = input.ReadInt32();

            //TODO: PaletteRef or something
            if (!IsSystemPalette)
            {
                Palette &= 0x7FFF;
            }
        }
 public LingoContextSection(ref ShockwaveReader input)
 {
     Unknown = input.ReadInt32();
     Id      = input.ReadInt32();
     Flags   = (LingoContextSectionFlags)input.ReadInt16();
     Link    = input.ReadInt16();
 }
Ejemplo n.º 7
0
        public ShockwaveFile(ShockwaveReader input)
            : this()
        {
            _input = input;

            Metadata = new FileMetadataChunk(input);
        }
Ejemplo n.º 8
0
        public ScriptContextChunk(ref ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            Remnants.Enqueue(input.ReadInt32());
            Remnants.Enqueue(input.ReadInt32());

            Sections = new List <ScriptContextSection>(input.ReadInt32());
            input.ReadInt32();

            short entryOffset = input.ReadInt16();

            input.ReadInt16();

            Remnants.Enqueue(input.ReadInt32()); //0
            Type = input.ReadInt32();            //TODO: Enum
            Remnants.Enqueue(input.ReadInt32());

            NameListChunkId = input.ReadInt32();

            ValidCount  = input.ReadInt16(); //validCount - tremor "length"
            Flags       = input.ReadInt16(); //TODO: 1, 5
            FreeChunkId = input.ReadInt16();

            input.Position = entryOffset;

            for (int i = 0; i < Sections.Capacity; i++)
            {
                Sections.Add(new ScriptContextSection(ref input));
            }
        }
Ejemplo n.º 9
0
        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));
            }
        }
Ejemplo n.º 10
0
 public ScriptContextSection(ShockwaveReader input)
 {
     Unknown = input.ReadBigEndian <int>();
     Id      = input.ReadBigEndian <int>();
     Flags   = input.ReadBigEndian <short>(); // 4=Used
     Link    = input.ReadBigEndian <short>();
 }
Ejemplo n.º 11
0
        public ScriptChunk(ref ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            input.IsBigEndian = true;

            Remnants.Enqueue(input.ReadInt32());
            Remnants.Enqueue(input.ReadInt32());

            input.ReadInt32();
            input.ReadInt32();

            input.ReadInt16();
            ScriptNumber = input.ReadInt16();

            Remnants.Enqueue(input.ReadInt16());
            Remnants.Enqueue(input.ReadBEInt32()); // -1
            Remnants.Enqueue(input.ReadBEInt32()); // 0
            Remnants.Enqueue(input.ReadBEInt32());
            Remnants.Enqueue(input.ReadBEInt32()); // 0

            BehaviourScript = input.ReadInt32();   //enum, Behav=0, Global=2

            Remnants.Enqueue(input.ReadInt32());
            Remnants.Enqueue(input.ReadInt16()); //scriptId

            Remnants.Enqueue(input.ReadBEInt16());

            Pool = new LingoValuePool(this, ref input);
        }
Ejemplo n.º 12
0
        private ICastProperties ReadTypeProperties(ref ShockwaveReader input, int dataLength)
        {
            switch (Type)
            {
            case CastType.Bitmap:
            case CastType.OLE:
                return(new BitmapCastProperties(ref input));

            case CastType.Shape:
                return(new ShapeCastProperties(ref input));

            case CastType.Movie:
            case CastType.DigitalVideo:
                return(new VideoCastProperties(ref input));

            case CastType.Button:
            case CastType.Text:
                return(new TextCastProperties(ref input));

            case CastType.Script:
                return(new ScriptCastProperties(ref input));

            default:
                return(new UnknownCastProperties(ref input, dataLength));
            }
        }
Ejemplo n.º 13
0
        public LingoScriptChunk(ref ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            input.IsBigEndian = true;

            input.ReadInt32();
            input.ReadInt32();

            input.ReadInt32();
            input.ReadInt32();

            input.ReadInt16();
            ScriptNumber = input.ReadInt16();

            Remnants.Enqueue(input.ReadInt16());
            input.ReadBEInt32();
            input.ReadBEInt32();
            Remnants.Enqueue(input.ReadBEInt32());
            input.ReadBEInt32();

            Type = input.ReadInt32(); //TODO: enum, Behav=0, Global=2

            Remnants.Enqueue(input.ReadInt32());
            CastMemberRef = input.ReadInt16();     //scriptId

            Remnants.Enqueue(input.ReadBEInt16()); //factoryNameId?

            Pool = new LingoValuePool(this, ref input);
        }
Ejemplo n.º 14
0
 public ChunkEntry(ShockwaveReader input)
     : this(new ChunkHeader(input))
 {
     Offset  = input.ReadInt32();
     Flags   = (ChunkEntryFlags)input.ReadInt16();
     Unknown = input.ReadInt16();
     Link    = input.ReadInt32();
 }
Ejemplo n.º 15
0
        public FileVersionChunk(ref ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            var unknown  = input.ReadBytes(3); // likely varints?
            var unknown2 = input.ReadBytes(2);

            Version = input.ReadString(); //TOOD: => DirectorVersion
        }
Ejemplo n.º 16
0
        public ShockwaveFile(byte[] data)
            : this()
        {
            _input = data;

            var input = new ShockwaveReader(_input.Span);

            Metadata = new FileMetadataChunk(ref input);
        }
Ejemplo n.º 17
0
        public void Populate(ShockwaveReader input, long scriptChunkOffset)
        {
            input.Position = scriptChunkOffset + _codeOffset;
            input.Read(Body.Code, 0, Body.Code.Length);

            input.PopulateVList(scriptChunkOffset + _argumentsOffset, Arguments, input.ReadBigEndian <short>);
            input.PopulateVList(scriptChunkOffset + _localsOffset, Locals, input.ReadBigEndian <short>);
            input.PopulateVList(scriptChunkOffset + _lineOffset, new List <byte>(), input.ReadByte);
        }
Ejemplo n.º 18
0
 public CastAssociationTableChunk(ref ShockwaveReader input, ChunkHeader header)
     : base(header)
 {
     Members = new int[header.Length / sizeof(int)];
     for (int i = 0; i < Members.Length; i++)
     {
         Members[i] = input.ReadInt32();
     }
 }
Ejemplo n.º 19
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>();
     }
 }
Ejemplo n.º 20
0
        public void Populate(ref ShockwaveReader input, int scriptChunkOffset)
        {
            input.Advance(scriptChunkOffset + _codeOffset);
            input.ReadBytes(Body.Code);

            //input.PopulateVList(scriptChunkOffset + _argumentsOffset, Arguments, input.ReadInt16);
            //input.PopulateVList(scriptChunkOffset + _localsOffset, Locals, input.ReadInt16);
            //input.PopulateVList(scriptChunkOffset + _lineOffset, new List<byte>(), input.ReadByte);
        }
Ejemplo n.º 21
0
 public PaletteChunk(ShockwaveReader input, ChunkHeader header)
     : base(header)
 {
     Colors = new Color[header.Length / 6];
     for (int i = 0; i < Colors.Length; i++)
     {
         Colors[i] = input.ReadColor();
     }
 }
Ejemplo n.º 22
0
 public InitialMapChunk(ref ShockwaveReader input, ChunkHeader header)
     : base(header)
 {
     MemoryMapOffsets = new int[input.ReadBEInt32()];
     for (int i = 0; i < MemoryMapOffsets.Length; i++)
     {
         MemoryMapOffsets[i] = input.ReadBEInt32();
     }
     Version = (DirectorVersion)input.ReadBEInt32();
 }
Ejemplo n.º 23
0
        public ChunkEntry(ref ShockwaveReader input, int id)
            : this(new ChunkHeader(ref input))
        {
            Id = id;

            Offset  = input.ReadBEInt32();
            Flags   = (ChunkEntryFlags)input.ReadBEInt16();
            Unknown = input.ReadBEInt16();
            Link    = input.ReadBEInt32();
        }
Ejemplo n.º 24
0
        public DeflateShockwaveReader CreateDeflateReader(ref ShockwaveReader input)
        {
            input.Advance(2); //Skip ZLib header

            int dataLeft = Header.Length - input.Position;

            byte[] compressedData = input.ReadBytes(dataLeft).ToArray();

            return(new DeflateShockwaveReader(compressedData, input.IsBigEndian));
        }
Ejemplo n.º 25
0
        public static ChunkItem Read(ref ShockwaveReader input, ChunkHeader header)
        {
            ReadOnlySpan <byte> chunkSpan  = input.ReadBytes(header.Length);
            ShockwaveReader     chunkInput = new ShockwaveReader(chunkSpan, input.IsBigEndian);

            return(header.Kind switch
            {
                ChunkKind.RIFX => new FileMetadataChunk(ref chunkInput, header),

                ChunkKind.Fver => new FileVersionChunk(ref chunkInput, header),
                ChunkKind.Fcdr => new FileCompressionTypesChunk(ref chunkInput, header),
                ChunkKind.ABMP => new AfterburnerMapChunk(ref chunkInput, header),
                ChunkKind.FGEI => new FileGzipEmbeddedImageChunk(header),

                ChunkKind.imap => new InitialMapChunk(ref chunkInput, header),
                ChunkKind.mmap => new MemoryMapChunk(ref chunkInput, header),
                ChunkKind.KEYPtr => new AssociationTableChunk(ref chunkInput, header),

                ChunkKind.VWCF => new ConfigChunk(ref chunkInput, header),
                ChunkKind.DRCF => new ConfigChunk(ref chunkInput, header),

                //ChunkKind.VWSC => new ScoreChunk(ref chunkInput, header),
                ChunkKind.VWLB => new ScoreLabelChunk(ref chunkInput, header),
                ChunkKind.VWFI => new FileInfoChunk(ref chunkInput, header),

                ChunkKind.Lnam => new LingoNameChunk(ref chunkInput, header),
                ChunkKind.Lscr => new LingoScriptChunk(ref chunkInput, header),
                ChunkKind.Lctx => new LingoContextChunk(ref chunkInput, header), //TODO: StackHeight and other differences.
                ChunkKind.LctX => new LingoContextChunk(ref chunkInput, header),

                ChunkKind.CASPtr => new CastAssociationTableChunk(ref chunkInput, header),
                ChunkKind.CASt => new CastMemberPropertiesChunk(ref chunkInput, header),
                ChunkKind.MCsL => new MovieCastListChunk(ref chunkInput, header),

                //ChunkKind.Cinf => new CastInfoChunk(ref chunkInput, header),
                ChunkKind.SCRF => new ScoreReferenceChunk(ref chunkInput, header),
                ChunkKind.Sord => new SortOrderChunk(ref chunkInput, header),
                ChunkKind.CLUT => new PaletteChunk(ref chunkInput, header),
                ChunkKind.STXT => new StyledTextChunk(ref chunkInput, header),

                //ChunkKind.cupt => new CuePointsChunk(ref chunkInput, header),
                ChunkKind.snd => new SoundDataChunk(ref chunkInput, header),

                //ChunkKind.XTRl => new XtraListChunk(ref chunkInput, header),
                //ChunkKind.Fmap => new CastFontMapChunk(ref chunkInput, header),

                //ChunkKind.PUBL => new PublishSettingsChunk(ref chunkInput, header),
                ChunkKind.GRID => new GridChunk(ref chunkInput, header),
                ChunkKind.FCOL => new FavoriteColorsChunk(ref chunkInput, header),

                ChunkKind.FXmp => new FontMapChunk(ref chunkInput, header),
                ChunkKind.BITD => new BitmapDataChunk(ref chunkInput, header),

                _ => new UnknownChunk(ref chunkInput, header),
            });
Ejemplo n.º 26
0
        public CastListEntry(ref ShockwaveReader input)
        {
            Name     = input.ReadString();
            FilePath = input.ReadString();

            PreloadSettings = input.ReadInt16();
            MemberMin       = input.ReadInt16();
            MemberCount     = input.ReadInt16();

            Id = input.ReadInt32();
        }
Ejemplo n.º 27
0
        public FavoriteColorsChunk(ref ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            Remnants.Enqueue(input.ReadInt32()); //1
            Remnants.Enqueue(input.ReadInt32()); //1

            for (int i = 0; i < Colors.Length; i++)
            {
                Colors[i] = Color.FromArgb(input.ReadByte(), input.ReadByte(), input.ReadByte());
            }
        }
Ejemplo n.º 28
0
 public static ChunkItem Read(ref ShockwaveReader input, AfterBurnerMapEntry entry)
 {
     if (entry.IsCompressed)
     {
         return(input.ReadCompressedChunk(entry));
     }
     else
     {
         return(Read(ref input, entry.Header));
     }
 }
Ejemplo n.º 29
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>();
        }
Ejemplo n.º 30
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();
 }