Esempio n. 1
0
        public static void Unpack(string FileName, string OutFolder)
        {
            if (!Directory.Exists(OutFolder))
            {
                Directory.CreateDirectory(OutFolder);
            }

            using (FileStream Input = new FileStream(FileName, FileMode.Open))
            {
                BinaryReader Reader = new BinaryReader(Input);

                uint FilesCount = Reader.ReadUInt32();

                for (int Index = 0; Index < FilesCount; Index++)
                {
                    Input.Seek(4 + Index * 8, SeekOrigin.Begin);

                    uint FileAddr = Reader.ReadUInt32();
                    uint FileLen  = Reader.ReadUInt32();

                    Input.Seek(FileAddr, SeekOrigin.Begin);

                    byte[] Data = GalCompression.Decompress(Input);

                    string OutFileName = Path.Combine(OutFolder, string.Format("file_{0:d5}.tim", Index));

                    Console.WriteLine("{0:x8} -> {1}", FileAddr, OutFileName);

                    File.WriteAllBytes(OutFileName, Data);
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("GalTTT - Galerians TIM Texture Tool");
            Console.WriteLine("Made by gdkchan");
            Console.WriteLine("Version 1.1\n");
            Console.ResetColor();

            if (args.Length != 3 && args.Length != 2)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Usage:\n");
                Console.ResetColor();
                Console.WriteLine("galttt [command] gamefile.ext folder/file\n");
                Console.WriteLine("Accepted commands:\n");
                Console.WriteLine("-xcdb  Extract CDB archive to a folder");
                Console.WriteLine("-ccdb  Creates a CDB archive from a folder");
                Console.WriteLine("-xtim  Decompress texture TIM pack to a folder");
                Console.WriteLine("-ctim  Compress a textures TIM pack from a folder");
                Console.WriteLine("-dec   Decompress raw file");
                Console.WriteLine("-cmp   Compress raw file");
                Console.WriteLine("\nExamples:\n");
                Console.WriteLine("galttt -xcdb DISPLAY.CDB display");
                Console.WriteLine("galttt -xtim file_00042.bin tstex");
                Console.WriteLine("galttt -dec compressed.bin decompressed.tim");
                Console.WriteLine("galttt -cmp compressed.bin decompressed.tim");
            }
            else
            {
                bool InvalidCmd = false;

                switch (args[0].ToLower())
                {
                case "-xcdb": GalFilePackage.Unpack(args[1], args[2]); break;

                case "-ccdb": GalFilePackage.Pack(args[1], args[2]); break;

                case "-xtim": GalTexPack.Unpack(args[1], args[2]); break;

                case "-ctim": GalTexPack.Pack(args[1], args[2]); break;

                case "-dec":  GalCompression.Decompress(args[1], args[2]); break;

                case "-cmp":  GalCompression.Compress(args[2], args[1]); break;

                default: InvalidCmd = true; break;
                }

                if (InvalidCmd)
                {
                    Console.WriteLine("Invalid command!");
                }
                else
                {
                    Console.WriteLine("\nDone.");
                }
            }
        }
Esempio n. 3
0
        public static void Pack(string FileName, string InFolder)
        {
            string[] Files = Directory.GetFiles(InFolder);

            using (FileStream Output = new FileStream(FileName, FileMode.Create))
            {
                BinaryWriter Writer = new BinaryWriter(Output);

                Writer.Write(Files.Length);

                long DataPosition = 4 + Files.Length * 8;

                for (int Index = 0; Index < Files.Length; Index++)
                {
                    Console.WriteLine("{0} -> {1:x8}", Files[Index], DataPosition);

                    byte[] Data = File.ReadAllBytes(Files[Index]);

                    Output.Seek(DataPosition, SeekOrigin.Begin);

                    GalCompression.Compress(Data, Output);

                    while ((Output.Position & 3) != 0)
                    {
                        Output.WriteByte(0);
                    }

                    long OldPosition = DataPosition;

                    DataPosition = Output.Position;

                    Output.Seek(4 + Index * 8, SeekOrigin.Begin);

                    Writer.Write((uint)OldPosition);
                    Writer.Write((uint)(DataPosition - OldPosition));
                }
            }
        }