示例#1
0
        private static void WriteFileHeader(BinderFile file, BinaryWriterEx bw, int index, Binder.Format format)
        {
            bw.WriteByte((byte)file.Flags);
            bw.WriteByte(0);
            bw.WriteByte(0);
            bw.WriteByte(0);

            bw.ReserveInt32($"CompressedSize{index}");
            bw.ReserveUInt32($"FileData{index}");

            if (Binder.HasID(format))
            {
                bw.WriteInt32(file.ID);
            }

            if (Binder.HasName(format))
            {
                bw.ReserveUInt32($"FileName{index}");
            }

            if (Binder.HasUncompressedSize(format))
            {
                bw.WriteInt32(file.Bytes.Length);
            }
        }
示例#2
0
 internal void WriteHeader(BinaryWriterEx bw, byte format2D, int i)
 {
     if ((format2D & 0x7F) < 4)
     {
         bw.WriteUInt32((uint)ID);
         bw.ReserveUInt32($"RowOffset{i}");
         bw.ReserveUInt32($"NameOffset{i}");
     }
     else
     {
         bw.WriteInt64(ID);
         bw.ReserveInt64($"RowOffset{i}");
         bw.ReserveInt64($"NameOffset{i}");
     }
 }
示例#3
0
                public static void Write(BinaryWriterEx bw, File file, int index, byte format)
                {
                    bw.WriteByte(file.Flags);
                    bw.WriteByte(0);
                    bw.WriteByte(0);
                    bw.WriteByte(0);

                    bw.WriteInt32(-1);
                    bw.ReserveInt64($"FileSize{index}");
                    if (format == 0x2E || format == 0x3E || format == 0x74)
                    {
                        bw.WriteInt64(file.Bytes.LongLength);
                    }

                    if (format == 0x3E)
                    {
                        bw.ReserveUInt64($"FileOffset{index}");
                    }
                    else
                    {
                        bw.ReserveUInt32($"FileOffset{index}");
                    }

                    if (format == 0x2E || format == 0x3E || format == 0x74)
                    {
                        bw.WriteInt32(file.ID);
                    }

                    bw.ReserveInt32($"FileName{index}");
                }
 internal void WriteHeader(BinaryWriterEx bw, int index)
 {
     bw.WriteInt32(0);
     bw.WriteInt32(Count);
     bw.ReserveUInt32($"EntriesOffset{index}");
     bw.WriteInt32(0);
 }
示例#5
0
文件: NVA.cs 项目: swordworld/dstools
        internal override void Write(BinaryWriterEx bw)
        {
            var connectorPoints     = new ConnectorPointSection();
            var connectorConditions = new ConnectorConditionSection();

            foreach (Connector connector in Connectors)
            {
                connector.GivePointsAndConds(connectorPoints, connectorConditions);
            }

            bw.BigEndian = false;
            bw.WriteASCII("NVMA");
            bw.WriteUInt32((uint)Version);
            bw.ReserveUInt32("FileSize");
            bw.WriteInt32(Version == NVAVersion.OldBloodborne ? 8 : 9);

            Navmeshes.Write(bw, 0);
            Entries1.Write(bw, 1);
            Entries2.Write(bw, 2);
            new Section3().Write(bw, 3);
            Connectors.Write(bw, 4);
            connectorPoints.Write(bw, 5);
            connectorConditions.Write(bw, 6);
            Entries7.Write(bw, 7);
            if (Version != NVAVersion.OldBloodborne)
            {
                Entries8.Write(bw, 8);
            }

            bw.FillUInt32("FileSize", (uint)bw.Position);
        }
示例#6
0
 internal void WriteHeader(BinaryWriterEx bw, PARAM parent, int i)
 {
     if (parent.Format2D.HasFlag(FormatFlags1.LongDataOffset))
     {
         bw.WriteInt32(ID);
         bw.WriteInt32(0);
         bw.ReserveInt64($"RowOffset{i}");
         bw.ReserveInt64($"NameOffset{i}");
     }
     else
     {
         bw.WriteInt32(ID);
         bw.ReserveUInt32($"RowOffset{i}");
         bw.ReserveUInt32($"NameOffset{i}");
     }
 }
示例#7
0
        internal void WriteBinder4FileHeader(BinaryWriterEx bw, Format format, bool bitBigEndian, int index)
        {
            WriteFileFlags(bw, bitBigEndian, format, Flags);
            bw.WriteByte(0);
            bw.WriteByte(0);
            bw.WriteByte(0);
            bw.WriteInt32(-1);

            bw.ReserveInt64($"FileCompressedSize{index}");

            if (HasCompression(format))
            {
                bw.ReserveInt64($"FileUncompressedSize{index}");
            }

            if (HasLongOffsets(format))
            {
                bw.ReserveInt64($"FileDataOffset{index}");
            }
            else
            {
                bw.ReserveUInt32($"FileDataOffset{index}");
            }

            if (HasIDs(format))
            {
                bw.WriteInt32(ID);
            }

            if (HasNames(format))
            {
                bw.ReserveInt32($"FileNameOffset{index}");
            }
        }
示例#8
0
            public static Block Write(BinaryWriterEx bw, int type, int version, byte marker)
            {
                bw.WriteInt32(0);
                long start = bw.Position + 4;

                bw.ReserveUInt32($"Block{start:X}");
                bw.WriteInt32(type);
                bw.WriteInt32(version);
                WriteMarker(bw, marker);
                return(new Block(start, 0, type, version, marker));
            }
 internal void Write(BinaryWriterEx bw, bool longFormat, int index)
 {
     bw.WriteInt32(ID);
     if (longFormat)
     {
         bw.WriteBoolean(BattleInterrupt);
         bw.WriteBoolean(LogicInterrupt);
         bw.WriteInt16(0);
         bw.ReserveInt64($"NameOffset{index}");
         bw.ReserveInt64($"LogicInterruptNameOffset{index}");
     }
     else
     {
         bw.ReserveUInt32($"NameOffset{index}");
         bw.ReserveUInt32($"LogicInterruptNameOffset{index}");
         bw.WriteBoolean(BattleInterrupt);
         bw.WriteBoolean(LogicInterrupt);
         bw.WriteInt16(0);
     }
 }
            internal void Write(BinaryWriterEx bw)
            {
                bw.WriteInt16((short)Members1.Count);
                bw.WriteInt16((short)Members2.Count);
                bw.ReserveUInt32("SekiroUnkOffset1");
                bw.ReserveUInt32("SekiroUnkOffset2");
                bw.WriteInt32(0);
                bw.WriteInt32(0);
                bw.WriteInt32(0);
                bw.WriteInt32(0);
                bw.WriteInt32(0);

                bw.FillUInt32("SekiroUnkOffset1", (uint)bw.Position);
                foreach (Member member in Members1)
                {
                    member.Write(bw);
                }

                bw.FillUInt32("SekiroUnkOffset2", (uint)bw.Position);
                foreach (Member member in Members2)
                {
                    member.Write(bw);
                }
            }
示例#11
0
        private void Write(BinaryWriterEx bhdWriter, BinaryWriterEx bdtWriter)
        {
            bhdWriter.WriteASCII("BHF3");
            bhdWriter.WriteFixStr(BHDTimestamp, 8);
            bhdWriter.WriteByte((byte)Format);
            bhdWriter.WriteByte(0);
            bhdWriter.WriteByte(0);
            bhdWriter.WriteByte(0);
            bhdWriter.BigEndian = Binder.ForceBigEndian(Format);

            bhdWriter.WriteInt32(Files.Count);
            bhdWriter.WriteInt32(0);
            bhdWriter.WriteInt32(0);
            bhdWriter.WriteInt32(0);

            bdtWriter.WriteASCII("BDF3");
            bdtWriter.WriteFixStr(BDTTimestamp, 8);
            bdtWriter.WriteInt32(0);

            for (int i = 0; i < Files.Count; i++)
            {
                BinderFile file = Files[i];
                bhdWriter.WriteByte(0x40);
                bhdWriter.WriteByte(0);
                bhdWriter.WriteByte(0);
                bhdWriter.WriteByte(0);

                bhdWriter.WriteInt32(file.Bytes.Length);
                bhdWriter.WriteUInt32((uint)bdtWriter.Position);
                bhdWriter.WriteInt32(i);
                bhdWriter.ReserveUInt32($"FileName{i}");

                if (Binder.HasUncompressedSize(Format))
                {
                    bhdWriter.WriteInt32(file.Bytes.Length);
                }

                bdtWriter.WriteBytes(file.Bytes);
                bdtWriter.Pad(0x10);
            }

            for (int i = 0; i < Files.Count; i++)
            {
                BinderFile file = Files[i];
                bhdWriter.FillUInt32($"FileName{i}", (uint)bhdWriter.Position);
                bhdWriter.WriteShiftJIS(file.Name, true);
            }
        }
 public void WriteHeader(BinaryWriterEx bw, HKX.HKXVariation variation)
 {
     bw.WriteFixStr(SectionTag, 19);
     bw.WriteByte(0xFF);
     bw.ReserveUInt32("absoffset" + SectionID);
     bw.ReserveUInt32("locoffset" + SectionID);
     bw.ReserveUInt32("globoffset" + SectionID);
     bw.ReserveUInt32("virtoffset" + SectionID);
     bw.ReserveUInt32("expoffset" + SectionID);
     bw.ReserveUInt32("impoffset" + SectionID);
     bw.ReserveUInt32("endoffset" + SectionID);
     if (variation == HKX.HKXVariation.HKXBloodBorne || variation == HKX.HKXVariation.HKXDS3)
     {
         bw.WriteUInt32(0xFFFFFFFF);
         bw.WriteUInt32(0xFFFFFFFF);
         bw.WriteUInt32(0xFFFFFFFF);
         bw.WriteUInt32(0xFFFFFFFF);
     }
 }
示例#13
0
        /// <summary>
        /// Serializes file data to a stream.
        /// </summary>
        protected override void Write(BinaryWriterEx bw)
        {
            bw.BigEndian = BigEndian;
            for (int i = 0; i < Globals.Count; i++)
            {
                if (LongFormat)
                {
                    bw.ReserveInt64($"Offset{i}");
                }
                else
                {
                    bw.ReserveUInt32($"Offset{i}");
                }
            }

            if (LongFormat)
            {
                bw.WriteInt64(0);
            }
            else
            {
                bw.WriteUInt32(0);
            }

            for (int i = 0; i < Globals.Count; i++)
            {
                if (LongFormat)
                {
                    bw.FillInt64($"Offset{i}", bw.Position);
                    bw.WriteUTF16(Globals[i], true);
                }
                else
                {
                    bw.FillUInt32($"Offset{i}", (uint)bw.Position);
                    bw.WriteShiftJIS(Globals[i], true);
                }
            }
            bw.Pad(0x10);
        }
示例#14
0
        internal override void Write(BinaryWriterEx bw)
        {
            if (layout == null)
            {
                throw new InvalidOperationException("Params cannot be written without a layout.");
            }

            Rows.Sort((r1, r2) => r1.ID.CompareTo(r2.ID));

            bw.BigEndian = BigEndian;
            void WriteFormat()
            {
                bw.WriteByte((byte)(BigEndian ? 0xFF : 0x00));
                bw.WriteByte(Format2D);
                bw.WriteByte(Format2E);
                bw.WriteByte(Format2F);
            }

            // DeS, DS1
            if ((Format2D & 0x7F) < 3)
            {
                bw.ReserveUInt32("StringsOffset");
                bw.ReserveUInt16("DataStart");
                bw.WriteInt16(Unk06);
                bw.WriteInt16(Unk08);
                bw.WriteUInt16((ushort)Rows.Count);
                bw.WriteFixStr(ID, 0x20, 0x20);
                WriteFormat();
            }
            // DS2
            else if ((Format2D & 0x7F) == 3)
            {
                bw.ReserveUInt32("StringsOffset");
                bw.WriteInt16(0);
                bw.WriteInt16(Unk06);
                bw.WriteInt16(Unk08);
                bw.WriteUInt16((ushort)Rows.Count);
                bw.WriteFixStr(ID, 0x20, 0x20);
                WriteFormat();
                bw.ReserveUInt32("DataStart");
                bw.WriteInt32(0);
                bw.WriteInt32(0);
                bw.WriteInt32(0);
            }
            // SotFS, BB
            else if ((Format2D & 0x7F) == 4)
            {
                bw.ReserveUInt32("StringsOffset");
                bw.WriteInt16(0);
                bw.WriteInt16(Unk06);
                bw.WriteInt16(Unk08);
                bw.WriteUInt16((ushort)Rows.Count);
                bw.WriteFixStr(ID, 0x20, 0x00);
                WriteFormat();
                bw.ReserveInt64("DataStart");
                bw.WriteInt64(0);
            }
            // DS3, SDT
            else
            {
                bw.ReserveUInt32("StringsOffset");
                bw.WriteInt16(0);
                bw.WriteInt16(Unk06);
                bw.WriteInt16(Unk08);
                bw.WriteUInt16((ushort)Rows.Count);
                bw.WriteInt32(0);
                bw.ReserveInt64("IDOffset");
                bw.WritePattern(0x14, 0x00);
                WriteFormat();
                bw.ReserveInt64("DataStart");
                bw.WriteInt64(0);
            }

            for (int i = 0; i < Rows.Count; i++)
            {
                Rows[i].WriteHeader(bw, Format2D, i);
            }

            if ((Format2D & 0x7F) < 3)
            {
                bw.FillUInt16("DataStart", (ushort)bw.Position);
            }
            else if ((Format2D & 0x7F) == 3)
            {
                bw.FillUInt32("DataStart", (uint)bw.Position);
            }
            else
            {
                bw.FillInt64("DataStart", bw.Position);
            }

            for (int i = 0; i < Rows.Count; i++)
            {
                Rows[i].WriteCells(bw, Format2D, i, layout);
            }

            bw.FillUInt32("StringsOffset", (uint)bw.Position);

            if ((Format2D & 0x7F) > 4)
            {
                bw.FillInt64("IDOffset", bw.Position);
                bw.WriteASCII(ID, true);
            }

            for (int i = 0; i < Rows.Count; i++)
            {
                Rows[i].WriteName(bw, Format2D, i);
            }
        }
示例#15
0
            internal void WriteHeader(BinaryWriterEx bw, int index, TPFPlatform platform, byte flag2)
            {
                if (platform == TPFPlatform.PC)
                {
                    DDS dds = new DDS(Bytes);
                    if (dds.dwCaps2.HasFlag(DDS.DDSCAPS2.CUBEMAP))
                    {
                        Type = TexType.Cubemap;
                    }
                    else if (dds.dwCaps2.HasFlag(DDS.DDSCAPS2.VOLUME))
                    {
                        Type = TexType.Volume;
                    }
                    else
                    {
                        Type = TexType.Texture;
                    }
                    Mipmaps = (byte)dds.dwMipMapCount;
                }

                bw.ReserveUInt32($"FileData{index}");
                bw.ReserveInt32($"FileSize{index}");

                bw.WriteByte(Format);
                bw.WriteByte((byte)Type);
                bw.WriteByte(Mipmaps);
                bw.WriteByte(Flags1);

                if (platform != TPFPlatform.PC)
                {
                    bw.WriteInt16(Header.Width);
                    bw.WriteInt16(Header.Height);

                    if (platform == TPFPlatform.Xbox360)
                    {
                        bw.WriteInt32(0);
                    }
                    else if (platform == TPFPlatform.PS3)
                    {
                        bw.WriteInt32(Header.Unk1);
                        if (flag2 != 0)
                        {
                            bw.WriteInt32(Header.Unk2);
                        }
                    }
                    else if (platform == TPFPlatform.PS4 || platform == TPFPlatform.Xbone)
                    {
                        bw.WriteInt32(Header.TextureCount);
                        bw.WriteInt32(Header.Unk2);
                    }
                }

                bw.ReserveUInt32($"FileName{index}");
                bw.WriteInt32(FloatStruct == null ? 0 : 1);

                if (platform == TPFPlatform.PS4 || platform == TPFPlatform.Xbone)
                {
                    bw.WriteInt32(Header.DXGIFormat);
                }

                if (FloatStruct != null)
                {
                    FloatStruct.Write(bw);
                }
            }
示例#16
0
        /// <summary>
        /// Serializes file data to a stream.
        /// </summary>
        protected override void Write(BinaryWriterEx bw)
        {
            if (AppliedParamdef == null)
            {
                throw new InvalidOperationException("Params cannot be written without applying a paramdef.");
            }

            bw.BigEndian = BigEndian;
            void WriteFormat()
            {
                bw.WriteByte((byte)(BigEndian ? 0xFF : 0x00));
                bw.WriteByte(Format2D);
                bw.WriteByte(Format2E);
                bw.WriteByte(Format2F);
            }

            // DeS, DS1
            if ((Format2D & 0x7F) < 3)
            {
                bw.ReserveUInt32("StringsOffset");
                bw.ReserveUInt16("DataStart");
                bw.WriteInt16(Unk06);
                bw.WriteInt16(Unk08);
                bw.WriteUInt16((ushort)Rows.Count);
                bw.WriteFixStr(ParamType, 0x20, (byte)((Format2D & 0x7F) < 2 ? 0x20 : 0x00));
                WriteFormat();
            }
            // DS2
            else if ((Format2D & 0x7F) == 3)
            {
                bw.ReserveUInt32("StringsOffset");
                bw.WriteInt16(0);
                bw.WriteInt16(Unk06);
                bw.WriteInt16(Unk08);
                bw.WriteUInt16((ushort)Rows.Count);
                bw.WriteFixStr(ParamType, 0x20, 0x20);
                WriteFormat();
                bw.ReserveUInt32("DataStart");
                bw.WriteInt32(0);
                bw.WriteInt32(0);
                bw.WriteInt32(0);
            }
            // SotFS, BB
            else if ((Format2D & 0x7F) == 4)
            {
                bw.ReserveUInt32("StringsOffset");
                bw.WriteInt16(0);
                bw.WriteInt16(Unk06);
                bw.WriteInt16(Unk08);
                bw.WriteUInt16((ushort)Rows.Count);
                bw.WriteFixStr(ParamType, 0x20, 0x00);
                WriteFormat();
                bw.ReserveInt64("DataStart");
                bw.WriteInt64(0);
            }
            // DS3, SDT
            else
            {
                bw.ReserveUInt32("StringsOffset");
                bw.WriteInt16(0);
                bw.WriteInt16(Unk06);
                bw.WriteInt16(Unk08);
                bw.WriteUInt16((ushort)Rows.Count);
                bw.WriteInt32(0);
                bw.ReserveInt64("IDOffset");
                bw.WritePattern(0x14, 0x00);
                WriteFormat();
                bw.ReserveInt64("DataStart");
                bw.WriteInt64(0);
            }

            for (int i = 0; i < Rows.Count; i++)
            {
                Rows[i].WriteHeader(bw, Format2D, i);
            }

            if ((Format2D & 0x7F) < 2)
            {
                bw.WritePattern(0x20, 0x00);
            }
            if ((Format2D & 0x7F) < 3)
            {
                bw.FillUInt16("DataStart", (ushort)bw.Position);
            }
            else if ((Format2D & 0x7F) == 3)
            {
                bw.FillUInt32("DataStart", (uint)bw.Position);
            }
            else
            {
                bw.FillInt64("DataStart", bw.Position);
            }

            for (int i = 0; i < Rows.Count; i++)
            {
                Rows[i].WriteCells(bw, Format2D, i);
            }

            bw.FillUInt32("StringsOffset", (uint)bw.Position);

            if ((Format2D & 0x7F) > 4)
            {
                bw.FillInt64("IDOffset", bw.Position);
                bw.WriteASCII(ParamType, true);
            }

            for (int i = 0; i < Rows.Count; i++)
            {
                Rows[i].WriteName(bw, Format2D, Format2E, i);
            }
            // DeS and BB sometimes (but not always) include some useless padding here
        }
示例#17
0
        /// <summary>
        /// Serializes file data to a stream.
        /// </summary>
        protected override void Write(BinaryWriterEx bw)
        {
            if (AppliedParamdef == null)
            {
                throw new InvalidOperationException("Params cannot be written without applying a paramdef.");
            }

            bw.BigEndian = BigEndian;

            bw.ReserveUInt32("StringsOffset");
            if (Format2D.HasFlag(FormatFlags1.Flag01) && Format2D.HasFlag(FormatFlags1.IntDataOffset) || Format2D.HasFlag(FormatFlags1.LongDataOffset))
            {
                bw.WriteInt16(0);
            }
            else
            {
                bw.ReserveUInt16("DataStart");
            }
            bw.WriteInt16(Unk06);
            bw.WriteInt16(ParamdefDataVersion);
            bw.WriteUInt16((ushort)Rows.Count);
            if (Format2D.HasFlag(FormatFlags1.OffsetParamType))
            {
                bw.WriteInt32(0);
                bw.ReserveInt64("ParamTypeOffset");
                bw.WritePattern(0x14, 0x00);
            }
            else
            {
                // This padding heuristic isn't completely accurate, not that it matters
                bw.WriteFixStr(ParamType, 0x20, (byte)(Format2D.HasFlag(FormatFlags1.Flag01) ? 0x20 : 0x00));
            }
            bw.WriteByte((byte)(BigEndian ? 0xFF : 0x00));
            bw.WriteByte((byte)Format2D);
            bw.WriteByte((byte)Format2E);
            bw.WriteByte(ParamdefFormatVersion);
            if (Format2D.HasFlag(FormatFlags1.Flag01) && Format2D.HasFlag(FormatFlags1.IntDataOffset))
            {
                bw.ReserveUInt32("DataStart");
                bw.WriteInt32(0);
                bw.WriteInt32(0);
                bw.WriteInt32(0);
            }
            else if (Format2D.HasFlag(FormatFlags1.LongDataOffset))
            {
                bw.ReserveInt64("DataStart");
                bw.WriteInt64(0);
            }

            for (int i = 0; i < Rows.Count; i++)
            {
                Rows[i].WriteHeader(bw, this, i);
            }

            // This is probably pretty stupid
            if (Format2D == FormatFlags1.Flag01)
            {
                bw.WritePattern(0x20, 0x00);
            }

            if (Format2D.HasFlag(FormatFlags1.Flag01) && Format2D.HasFlag(FormatFlags1.IntDataOffset))
            {
                bw.FillUInt32("DataStart", (uint)bw.Position);
            }
            else if (Format2D.HasFlag(FormatFlags1.LongDataOffset))
            {
                bw.FillInt64("DataStart", bw.Position);
            }
            else
            {
                bw.FillUInt16("DataStart", (ushort)bw.Position);
            }

            for (int i = 0; i < Rows.Count; i++)
            {
                Rows[i].WriteCells(bw, this, i);
            }

            bw.FillUInt32("StringsOffset", (uint)bw.Position);

            if (Format2D.HasFlag(FormatFlags1.OffsetParamType))
            {
                bw.FillInt64("ParamTypeOffset", bw.Position);
                bw.WriteASCII(ParamType, true);
            }

            for (int i = 0; i < Rows.Count; i++)
            {
                Rows[i].WriteName(bw, this, i);
            }
            // DeS and BB sometimes (but not always) include some useless padding here
        }