コード例 #1
0
        public byte[] Serialize()
        {
            List <byte> Serialized = new List <byte>((int)Header.Filesize);

            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(Header.Identify)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(Header.Filesize)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(Header.Lines)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(Header.Unknown)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(Header.TextStart)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(Header.Empty)));

            foreach (ChatFileLine Line in Lines)
            {
                Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian((uint)Line.NamePointer)));
                Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian((uint)Line.ENG)));
                Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian((uint)Line.ENG)));
                Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(Line.Unknown)));
            }

            byte ByteNull = 0x00;

            foreach (ChatFileLine Line in Lines)
            {
                Serialized.AddRange(TextUtils.StringToBytesShiftJis(Line.SName));
                Serialized.Add(ByteNull);
                Serialized.AddRange(TextUtils.StringToBytesShiftJis(Line.SENG));
                Serialized.Add(ByteNull);
            }

            return(Serialized.ToArray());
        }
コード例 #2
0
ファイル: FontInfo.cs プロジェクト: asker1982/HyoutaTools
        public FontInfo(byte[] File, int Offset)
        {
            CharacterLengths = new int[0x220];

            for (int i = 0; i < 0x220; i++)
            {
                CharacterLengths[i] = EndianUtils.SwapEndian(BitConverter.ToInt32(File, Offset + i * 4));
            }

            BuildCharacterMap();
        }
コード例 #3
0
ファイル: FontInfo.cs プロジェクト: asker1982/HyoutaTools
        public void WriteCharacterLengths(String Filename, int Offset)
        {
            byte[] File = System.IO.File.ReadAllBytes(Filename);

            for (int i = 0; i < CharacterLengths.Length; i++)
            {
                int    c = EndianUtils.SwapEndian(CharacterLengths[i]);
                byte[] b = BitConverter.GetBytes(c);
                b.CopyTo(File, Offset + i * 4);
            }

            System.IO.File.WriteAllBytes(Filename, File);
        }
コード例 #4
0
        private void Initialize(byte[] file)
        {
            this.File             = file;
            CreditInfoStartOffset = EndianUtils.SwapEndian(BitConverter.ToUInt32(file, 0x24));
            CreditInfoCount       = EndianUtils.SwapEndian(BitConverter.ToUInt32(file, (int)CreditInfoStartOffset));
            CreditInfoCount       = 2995;       // PS3 // not accurate in file...?
            //CreditInfoCount = 0x1ACE8 / 40; // 360

            items = new List <CreditsInfoSingle>((int)CreditInfoCount);
            for (int i = 0; i < CreditInfoCount; ++i)
            {
                items.Add(new CreditsInfoSingle(this, (int)CreditInfoStartOffset + 4 + i * 40, file));
            }
        }
コード例 #5
0
ファイル: SDB.cs プロジェクト: asker1982/HyoutaTools
        public void Write(System.IO.Stream stream)
        {
            stream.WriteUInt32(Type.ToEndian(Endian));

            bool ToZ = Type != 0x08;

            if (ToZ)
            {
                stream.WriteUInt32(EndianUtils.ToEndian(0x0Cu, Endian));
            }

            stream.WriteUInt32(((uint)TextList.Count).ToEndian(Endian));

            if (ToZ)
            {
                stream.WriteUInt32(((uint)OtherData.Count).ToEndian(Endian));
                foreach (uint d in OtherData)
                {
                    stream.WriteUInt32(d.ToEndian(Endian));
                }
                stream.WriteUInt32((uint)(TextList.Count * 8 + 4));
            }

            uint pointerLocation = (uint)stream.Position;

            for (int i = 0; i < TextList.Count; ++i)
            {
                // reserve space for pointers
                stream.WriteUInt32(0);
                stream.WriteUInt32(0);
            }

            foreach (SDBEntry e in TextList)
            {
                for (int i = 0; i < 2; ++i)
                {
                    if (ToZ)
                    {
                        stream.WriteAlign(2);
                    }
                    uint pos = (uint)stream.Position;
                    stream.Position = pointerLocation;
                    stream.WriteUInt32((pos - pointerLocation).ToEndian(Endian));
                    stream.Position  = pos;
                    pointerLocation += 4;
                    stream.WriteUTF8Nullterm(i == 0 ? e.IDString : e.Text);
                }
            }
        }
コード例 #6
0
        public byte[] Serialize()
        {
            List <byte> Serialized = new List <byte>(0x20);

            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(Magic)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(CodeStart)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(CodeLength)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(TextStart)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(EntryCodeStart)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(EntryPointerEnd)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(TextLength)));
            Serialized.AddRange(System.BitConverter.GetBytes(EndianUtils.SwapEndian(SectorSize)));

            return(Serialized.ToArray());
        }
コード例 #7
0
        public TownMapInfo(byte[] File, int TilesLocationJPN, int TilesLocationENG, int InfoLocation)
        {
            Filename = TextUtils.GetTextAscii(File, InfoLocation);

            this.InfoLocation = InfoLocation;

            TileAmountJPN = EndianUtils.SwapEndian(BitConverter.ToInt32(File, InfoLocation + 0xA4));
            TileAmountENG = EndianUtils.SwapEndian(BitConverter.ToInt32(File, InfoLocation + 0xA8));

            TownMapTilesJPN = new TownMapTile[TileAmountJPN];
            TownMapTilesENG = new TownMapTile[TileAmountENG];

            for (int i = 0; i < TileAmountJPN; i++)
            {
                TownMapTilesJPN[i] = new TownMapTile(File, TilesLocationJPN + (i * 0x20));
            }
            for (int i = 0; i < TileAmountENG; i++)
            {
                TownMapTilesENG[i] = new TownMapTile(File, TilesLocationENG + (i * 0x20));
            }
        }