Ejemplo n.º 1
0
        public void DeserializeExtraData(BinaryReader reader)
        {
            uint stringLength = reader.ReadUInt32();

            if (stringLength > 0)
            {
                SoundDataFilePath = Encoding.UTF8.GetString(reader.ReadBytesStrict(stringLength));
            }

            LanguageBits = reader.ReadUInt16();
            DataLength   = reader.ReadByte();

            // Yes, they really did this manually
            SoundFormat = new WaveResource();
            SoundFormat.DecodeFlags(reader.ReadByte());
            SoundFormat.FrameSize      = reader.ReadUInt16();
            SoundFormat.Encoding       = (EWaveDataEncoding)reader.ReadByte();
            SoundFormat.ChannelCount   = reader.ReadByte();
            SoundFormat.SampleRate     = reader.ReadInt32();
            SoundFormat.BitsPerSample  = reader.ReadUInt16();
            SoundFormat.BitsPerSecond  = reader.ReadUInt32();
            SoundFormat.BlockAlignment = reader.ReadUInt16();
            SoundFormat.FormatTag      = reader.ReadUInt16();

            UnknownData = new byte[22][];
            uint currentLanguageBit = 1;

            for (uint i = 1; i < 22; i++)
            {
                if ((GetLanguageSpecificFlags((ELanguage)i) & 2) == 0)
                {
                    continue;
                }

                if ((currentLanguageBit & LanguageBits) != 0)
                {
                    UnknownData[i] = reader.ReadBytesStrict(DataLength);
                }

                currentLanguageBit = BitOperations.RotateLeft(currentLanguageBit, 1);
            }
        }
Ejemplo n.º 2
0
        public void DeserializeExtraData(BinaryReader reader)
        {
            uint stringLength = reader.ReadUInt32();

            if (stringLength > 0)
            {
                SoundDataFilePath = Encoding.UTF8.GetString(reader.ReadBytesStrict(stringLength));
            }

            ushort languageBits = reader.ReadUInt16();
            byte   dataLength   = reader.ReadByte();

            // Yes, they really did this manually
            SoundFormat = new WaveResource();
            SoundFormat.DecodeFlags(reader.ReadByte());
            SoundFormat.FrameSize      = reader.ReadUInt16();
            SoundFormat.Encoding       = (EWaveDataEncoding)reader.ReadByte();
            SoundFormat.ChannelCount   = reader.ReadByte();
            SoundFormat.SampleRate     = reader.ReadInt32();
            SoundFormat.BitsPerSample  = reader.ReadUInt16();
            SoundFormat.BitsPerSecond  = reader.ReadUInt32();
            SoundFormat.BlockAlignment = reader.ReadUInt16();
            SoundFormat.FormatTag      = reader.ReadUInt16();

            uint currentLanguageBit = 1;

            for (uint i = 1; i < 22; i++)
            {
                if ((GetLanguageSpecificFlags((ELanguage)i) & 2) == 0)
                {
                    continue;
                }

                if ((currentLanguageBit & languageBits) != 0)
                {
                    var unknownData = reader.ReadBytesStrict(dataLength);
                }

                // Bit rotate left
                currentLanguageBit = (currentLanguageBit << 1) | (currentLanguageBit >> 31);
            }
        }