Example #1
0
        /// <summary>
        /// Read file.
        /// </summary>
        /// <param name="br">The reader.</param>
        public void Read(BinaryDataReader br)
        {
            var s = SoundArchiveReader.ReadSoundArchive(FilePath);

            Streams           = s.Streams;
            WaveSoundDatas    = s.WaveSoundDatas;
            Sequences         = s.Sequences;
            SoundSets         = s.SoundSets;
            Banks             = s.Banks;
            WaveArchives      = s.WaveArchives;
            Groups            = s.Groups;
            Players           = s.Players;
            Files             = s.Files;
            MaxSequences      = s.MaxSequences;
            MaxSequenceTracks = s.MaxSequenceTracks;
            MaxStreamSounds   = s.MaxStreamSounds;
            MaxStreamTracks   = s.MaxStreamTracks;
            MaxStreamChannels = s.MaxStreamChannels;
            MaxWaveSounds     = s.MaxWaveSounds;
            MaxWaveTracks     = s.MaxWaveTracks;
            StreamBufferTimes = s.StreamBufferTimes;
            Options           = s.Options;
            WriteMode         = s.WriteMode;
            Version           = s.Version;
            CreateStrings     = s.CreateStrings;
        }
Example #2
0
        /// <summary>
        /// Open file.
        /// </summary>
        /// <param name="br">The reader.</param>
        /// <param name="writeMode">Write mode.</param>
        /// <param name="version">Version.</param>
        public void OpenFile(BinaryDataReader br, out WriteMode writeMode, out FileWriter.Version version)
        {
            //Set up variables.
            blockOffsets         = new List <int>();
            fileStartPos         = br.Position;
            sizedReferenceTables = new Dictionary <string, ReferenceStructures.SizedReferenceTableInfo>();
            referenceTables      = new Dictionary <string, ReferenceStructures.ReferenceTableInfo>();
            references           = new Dictionary <string, ReferenceStructures.ReferenceInfo>();
            sizedReferences      = new Dictionary <string, ReferenceStructures.SizedReferenceInfo>();
            structurePositions   = new Stack <long>();

            //Get F or C.
            char identifier = br.ReadChar();

            //Skip rest of magic.
            br.Position += 3;

            //Get byte order.
            br.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
            bool bigEndian = true;

            if (br.ReadUInt16() == ByteOrder.LittleEndian)
            {
                //Little endian.
                bigEndian    = false;
                br.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
            }

            //Get header size.
            UInt16 headerSize = br.ReadUInt16();

            //Get version.
            version = new FileWriter.Version(br.ReadUInt32(), identifier);

            //Get size.
            fileSize = br.ReadUInt32();

            //Number of blocks and padding.
            UInt16 numBlocks = br.ReadUInt16();

            br.ReadUInt16();

            //Read offsets.
            for (int i = 0; i < numBlocks; i++)
            {
                br.ReadUInt32();
                blockOffsets.Add(br.ReadInt32());
                br.ReadUInt32();
            }

            //If the format is an F type.
            bool FFiles = identifier == 'F';

            //Determine the write mode.
            writeMode = WriteMode.Cafe;
            if (FFiles && !bigEndian)
            {
                writeMode = WriteMode.NX;
            }
            if (!FFiles && !bigEndian)
            {
                writeMode = WriteMode.CTR;
            }
            if (!FFiles && bigEndian)
            {
                writeMode = WriteMode.C_BE;
            }

            //Set the position.
            br.Position = fileStartPos + headerSize;
        }