Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string TPLToBCLIM(string path)
- {
- string newname = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(path) + ".bclim";
- byte[] data = File.ReadAllBytes(path);
- byte[] tpldata = new byte[data.Length - 0x100];
- Array.Copy(data, 0x100, tpldata, 0, tpldata.Length);
- byte[] climfooter = { (byte)0x43, (byte)0x4C, (byte)0x49, (byte)0x4D, (byte)0xFF, (byte)0xFE, (byte)0x14, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02, (byte)0x02, (byte)0x28, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x69, (byte)0x6D, (byte)0x61, (byte)0x67, (byte)0x10, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x40, (byte)0x00, (byte)0x00 };
- byte format = data[data[BitConverter.ToUInt16(data, 0x8)] + 4];
- byte[] formats = new byte[] { 0x2, 0x3, 0x2, 0x3, 0x5, 0x8, 0x9 }; // Formats 0-6, 8, 9, E documented.
- if (format < formats.Length)
- {
- climfooter[0x20] = formats[format];
- }
- else if (format == 0x8 || format == 0x9)
- climfooter[0x20] = 0x8;
- else if (format == 0xE)
- climfooter[0x20] = 0xA;
- else
- {
- throw new ArgumentException("Unknown TPL Format: " + format.ToString("X"));
- }
- Array.Copy(data, BitConverter.ToUInt32(data, 0x1C) + 4, climfooter, 0x1C, 4);
- Array.Copy(BitConverter.GetBytes(tpldata.Length), 0, climfooter, 0x24, 4);
- Array.Copy(BitConverter.GetBytes(tpldata.Length + 0x28), 0, climfooter, 0x0C, 4);
- File.WriteAllBytes(newname, tpldata.Concat(climfooter).ToArray());
- return newname;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement