예제 #1
0
        public TRK(Stream Data)
        {
            m_Reader = new FileReader(Data, false);
            string DataStr = "";
            string[] Elements;

            ASCIIEncoding Enc = new ASCIIEncoding();
            string MagicNumber = Enc.GetString(m_Reader.ReadBytes(4));

            if (!MagicNumber.Equals("2DKT", StringComparison.InvariantCultureIgnoreCase) && !MagicNumber.Equals("TKDT", StringComparison.InvariantCultureIgnoreCase))
                throw new HitException("Invalid TrackData header - TRK.cs");

            if (MagicNumber.Equals("2DKT", StringComparison.InvariantCultureIgnoreCase))
            {
                DataStr = Enc.GetString(m_Reader.ReadBytes((int)m_Reader.ReadUInt32()));
                Elements = DataStr.Split(',');
            }
            else
                Elements = Enc.GetString(m_Reader.ReadToEnd()).Split(',');

            m_Version = int.Parse(Elements[1], NumberStyles.Integer);
            TrackName = Elements[2];

            if (!Elements[3].Equals("", StringComparison.InvariantCultureIgnoreCase))
                SoundID = uint.Parse(Elements[3].Replace("0x", ""), NumberStyles.HexNumber);
            else
                SoundID = 0;

            if (Elements[5].Equals("\r\n", StringComparison.InvariantCultureIgnoreCase))
                return;

            if (!Elements[5].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Argument = (HITTrackArguments)Enum.Parse(typeof(HITTrackArguments), Elements[5]);

            if (!Elements[7].Equals("", StringComparison.InvariantCultureIgnoreCase))
                ControlGroup = (HITControlGroup)Enum.Parse(typeof(HITControlGroup), Elements[7]);

            if (!Elements[(m_Version != 2) ? 11 : 12].Equals("", StringComparison.InvariantCultureIgnoreCase))
                DuckingPriority = int.Parse(Elements[(m_Version != 2) ? 11 : 12], NumberStyles.Integer);

            if (!Elements[(m_Version != 2) ? 12 : 13].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Looped = (int.Parse(Elements[(m_Version != 2) ? 12 : 13], NumberStyles.Integer) != 0) ? true : false;

            if (!Elements[(m_Version != 2) ? 13 : 14].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Volume = int.Parse(Elements[(m_Version != 2) ? 13 : 14], NumberStyles.Integer);

            m_Reader.Close();
        }
예제 #2
0
        public ExportTable(Stream Data)
        {
            FileReader Reader = new FileReader(Data, false);

            int StartLocation = Data.BinaryContains(new byte[] { (byte)'E', (byte)'N', (byte)'T', (byte)'P' });
            Reader.Seek(StartLocation);

            while (true)
            {
                string EndTest = ASCIIEncoding.ASCII.GetString(Reader.ReadBytes(4));

                if (!EndTest.Equals("EENT", StringComparison.InvariantCultureIgnoreCase))
                {
                    Reader.Seek(Reader.Position - 4);
                    uint TrackID = Reader.ReadUInt32();
                    uint Address = Reader.ReadUInt32();
                    //TrackID, Address
                    m_SubRoutines.Add(TrackID, Address);
                }
                else
                {
                    break;
                }
            }
        }
예제 #3
0
        public Thumbnail(byte[] thumbnail,ThumbnailType type)
        {
            thumbType = type;
            Stream stream = new MemoryStream(thumbnail);
            FileReader reader = new FileReader(stream);
            reader.ReadBytes(4);//skip Tag 'THUM'

            width = (int)(reader.ReadUInt32());
            height = (int)(reader.ReadUInt32());

            byte[] readBytes = reader.ReadBytes(thumbnail.Length-12);
            pngBytes = new byte[readBytes.Length];
            readBytes.CopyTo(pngBytes, 0);

            stream.Close();
            reader.Close();
        }
예제 #4
0
        public OBJf(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Reader.ReadBytes(4); //Zero
            Reader.ReadBytes(4); //Version
            Reader.ReadBytes(4); //Magic

            uint Count = Reader.ReadUInt32();

            for (int i = 0; i < Count; i++)
            {
                OBJfFunctionPair FuncPair = new OBJfFunctionPair();
                FuncPair.ConditionFunction = Reader.ReadUShort();
                FuncPair.ActionFunction = Reader.ReadUShort();
                FunctionTable.Add(i, FuncPair);
            }

            Reader.Close();
            m_Data = null;
        }
예제 #5
0
        public Hit(Stream Data)
        {
            m_Reader = new FileReader(Data, false);

            ASCIIEncoding Enc = new ASCIIEncoding();
            string MagicNumber = Enc.GetString(m_Reader.ReadBytes(4));

            if (!MagicNumber.Equals("HIT!", StringComparison.InvariantCultureIgnoreCase))
                throw new HitException("MagicNumber was wrong - Hit.cs!");

            m_Reader.ReadUInt32(); //MajorVersion
            m_Reader.ReadUInt32(); //MinorVersion

            string Trax = Enc.GetString(m_Reader.ReadBytes(4));
            if (!Trax.Equals("TRAX", StringComparison.InvariantCultureIgnoreCase))
                throw new HitException("Invalid TRAX header - Hit.cs!");

            ExTable = new ExportTable(Data);
            m_Reader.Seek(0);
            InstructionData = m_Reader.ReadBytes((int)m_Reader.StreamLength);

            m_Reader.Close();
        }
예제 #6
0
        public PALT(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Reader.ReadUInt32(); //Version

            m_Colors = new Color[Reader.ReadUInt32()];
            Reader.ReadBytes(8); //Reserved

            for (int i = 0; i < m_Colors.Length; i++)
                m_Colors[i] = new Color(new Vector3(Reader.ReadByte(), Reader.ReadByte(), Reader.ReadByte()));

            Reader.Close();
            m_Data = null;
        }
예제 #7
0
        public Anim(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version

            ASCIIEncoding Enc = new ASCIIEncoding();
            Name = Enc.GetString(m_Reader.ReadBytes(m_Reader.ReadUShort()));
            Duration = m_Reader.ReadFloat();
            Distance = m_Reader.ReadFloat();
            IsMoving = (m_Reader.ReadByte() != 0) ? true : false;
            TranslationsCount = m_Reader.ReadUInt32();

            Translations = new float[TranslationsCount, 3];

            for(int i = 0; i < TranslationsCount; i++)
            {
                Translations[i, 0] = m_Reader.ReadFloat();
                Translations[i, 1] = m_Reader.ReadFloat();
                Translations[i, 2] = m_Reader.ReadFloat();
            }

            RotationsCount = m_Reader.ReadUInt32();

            Rotations = new float[RotationsCount, 4];

            for (int i = 0; i < RotationsCount; i++)
            {
                Rotations[i, 0] = m_Reader.ReadFloat();
                Rotations[i, 1] = m_Reader.ReadFloat();
                Rotations[i, 2] = m_Reader.ReadFloat();
                Rotations[i, 3] = m_Reader.ReadFloat();
            }

            MotionCount = m_Reader.ReadUInt32();

            for(int i = 0; i < MotionCount; i++)
                Motions.Add(new Motion(m_Reader));

            m_Reader.Close();
        }
예제 #8
0
        /// <summary>
        /// Loads an *.xa file, setting things up for decompression.
        /// Should always be called before DecompressFile().
        /// </summary>
        /// <param name="Data">The data of the *.xa file to process.</param>
        public void LoadFile(byte[] Data)
        {
            m_Reader = new FileReader(new MemoryStream(Data), false);

            m_ID = Convert.ToString(m_Reader.ReadBytes(4));
            m_DecompressedSize = m_Reader.ReadUInt32();
            m_Tag = m_Reader.ReadUShort();
            m_Channels = m_Reader.ReadUShort();
            m_SampleRate = m_Reader.ReadUInt32();
            m_AvgByteRate = m_Reader.ReadUInt32();
            m_Align = m_Reader.ReadUShort();
            m_Bits = m_Reader.ReadUShort();

            m_DecompressedStream = new MemoryStream((int)m_DecompressedSize);
            m_Writer = new BinaryWriter(m_DecompressedStream);
        }
예제 #9
0
        /// <summary>
        /// Loads a *.xa file, setting things up for decompression.
        /// Should always be called before DecompressFile().
        /// </summary>
        /// <param name="Path">The path to the *.xa file to load.</param>
        public void LoadFile(string Path)
        {
            m_Reader = new FileReader(File.Open(Path, FileMode.Open, FileAccess.Read, FileShare.Read), false);

            m_ID = Convert.ToString(m_Reader.ReadBytes(4));
            m_DecompressedSize = m_Reader.ReadUInt32();
            m_Tag = m_Reader.ReadUShort();
            m_Channels = m_Reader.ReadUShort();
            m_SampleRate = m_Reader.ReadUInt32();
            m_AvgByteRate = m_Reader.ReadUInt32();
            m_Align = m_Reader.ReadUShort();
            m_Bits = m_Reader.ReadUShort();

            m_DecompressedStream = new MemoryStream((int)m_DecompressedSize);
            m_Writer = new BinaryWriter(m_DecompressedStream);
        }