Esempio n. 1
0
        private static void ShowTeaFile(string file)
        {
            if (!File.Exists(file))
                return;

            byte[] buffer;
            using (FileStream fs = File.OpenRead(file))
            {
                buffer = new byte[fs.Length];
                fs.Read(buffer, 0, (int)fs.Length);
            }

            String output = Path.GetFileName(file) + " len=" + buffer.Length;
            Console.WriteLine(output);
            if (Writer != null)
                Writer.WriteLine(output);

            TEA tea = new TEA();
            int bufIdx = 0;
            Array.Copy(buffer, tea.comments, tea.comments.Length);
            bufIdx += tea.comments.Length;
            tea.i1 = BitConverter.ToInt32(buffer, bufIdx);
            bufIdx += sizeof(int);
            bufIdx += tea.unk1.Length;
            tea.i2 = BitConverter.ToInt32(buffer, bufIdx);
            bufIdx += sizeof(int);
            bufIdx += tea.unk2.Length;
            Array.Copy(buffer, bufIdx, tea.id, 0, tea.id.Length);
            bufIdx += tea.id.Length;
            tea.i3 = BitConverter.ToInt32(buffer, bufIdx);
            bufIdx += sizeof(int);
            tea.f1 = BitConverter.ToSingle(buffer, bufIdx);
            bufIdx += sizeof(float);
            tea.f2 = BitConverter.ToSingle(buffer, bufIdx);
            bufIdx += sizeof(float);
            tea.f3 = BitConverter.ToSingle(buffer, bufIdx);
            bufIdx += sizeof(float);

            output = "i" + tea.i1 + " i" + tea.i2 +
                String.Format(" ID: {0:X2}-{1:X2}-{2:X2}-{3:X2}", tea.id[0], tea.id[1], tea.id[2], tea.id[3]) +
                " i" + tea.i3 + " " + tea.f1 + " " + tea.f2 + " " + tea.f3;
            Console.WriteLine(output);
            if (Writer != null)
                Writer.WriteLine(output);

            SubTEA sub = new SubTEA();
            bufIdx = ShowSubTea(sub, buffer, bufIdx);

            output = "Stopped at x" + bufIdx.ToString("X4") + " rest " + (buffer.Length - bufIdx) + " bytes";
            Console.WriteLine(output);
            if (Writer != null)
                Writer.WriteLine(output);
        }
Esempio n. 2
0
        private static void ShowTeaFile(string file)
        {
            if (!File.Exists(file))
            {
                return;
            }

            byte[] buffer;
            using (FileStream fs = File.OpenRead(file))
            {
                buffer = new byte[fs.Length];
                fs.Read(buffer, 0, (int)fs.Length);
            }

            String output = Path.GetFileName(file) + " len=" + buffer.Length;

            Console.WriteLine(output);
            if (Writer != null)
            {
                Writer.WriteLine(output);
            }

            TEA tea    = new TEA();
            int bufIdx = 0;

            Array.Copy(buffer, tea.comments, tea.comments.Length);
            bufIdx += tea.comments.Length;
            tea.i1  = BitConverter.ToInt32(buffer, bufIdx);
            bufIdx += sizeof(int);
            bufIdx += tea.unk1.Length;
            tea.i2  = BitConverter.ToInt32(buffer, bufIdx);
            bufIdx += sizeof(int);
            bufIdx += tea.unk2.Length;
            Array.Copy(buffer, bufIdx, tea.id, 0, tea.id.Length);
            bufIdx += tea.id.Length;
            tea.i3  = BitConverter.ToInt32(buffer, bufIdx);
            bufIdx += sizeof(int);
            tea.f1  = BitConverter.ToSingle(buffer, bufIdx);
            bufIdx += sizeof(float);
            tea.f2  = BitConverter.ToSingle(buffer, bufIdx);
            bufIdx += sizeof(float);
            tea.f3  = BitConverter.ToSingle(buffer, bufIdx);
            bufIdx += sizeof(float);

            output = "i" + tea.i1 + " i" + tea.i2 +
                     String.Format(" ID: {0:X2}-{1:X2}-{2:X2}-{3:X2}", tea.id[0], tea.id[1], tea.id[2], tea.id[3]) +
                     " i" + tea.i3 + " " + tea.f1 + " " + tea.f2 + " " + tea.f3;
            Console.WriteLine(output);
            if (Writer != null)
            {
                Writer.WriteLine(output);
            }

            SubTEA sub = new SubTEA();

            bufIdx = ShowSubTea(sub, buffer, bufIdx);

            output = "Stopped at x" + bufIdx.ToString("X4") + " rest " + (buffer.Length - bufIdx) + " bytes";
            Console.WriteLine(output);
            if (Writer != null)
            {
                Writer.WriteLine(output);
            }
        }