Example #1
0
File: Main.cs Project: MetLob/tinke
        public sFolder Unpack(sFile file)
        {
            if (file.name == "archiveDBK.dsa")
                return Archive.Unpack_archiveDBK(pluginHost, file.path);

            return new sFolder();
        }
Example #2
0
File: Main.cs Project: MetLob/tinke
        public Control Show_Info(sFile file)
        {
            if (file.name.ToUpper().EndsWith(".BIN"))
                return new Bin(file.path, file.id, pluginHost, file.name).Get_Control();

            return new Control();
        }
Example #3
0
File: Main.cs Project: MetLob/tinke
        public Format Get_Format(sFile file, byte[] magic)
        {
            if (file.name.ToUpper() == "ROMFILE.BIN")
                return Format.Pack;

            return Format.Unknown;
        }
Example #4
0
File: Main.cs Project: MetLob/tinke
        public Format Get_Format(sFile file, byte[] magic)
        {
            if (gameCode == "YDNJ" && file.id == 0x1)
                return Format.Pack;

            return Format.Unknown;
        }
Example #5
0
        public Format Get_Format(sFile file, byte[] magic)
        {
            if (file.id >= 0x2F && file.id <= 0x93)
                return Format.Pack;

            return Format.Unknown;
        }
Example #6
0
File: Main.cs Project: MetLob/tinke
        public sFolder Unpack(sFile file)
        {
            if (file.name.ToUpper().EndsWith(".DPK"))
                return DPK.Unpack(file.path, pluginHost);

            return new sFolder();
        }
Example #7
0
        public Format Get_Format(sFile file, byte[] magic)
        {
            if (file.id == 0x461 || file.id == 0x462 || file.id == 0x45D || file.id == 0x45F)
                return Format.Pack;

            return Format.Unknown;
        }
Example #8
0
File: Main.cs Project: MetLob/tinke
        public sFolder Unpack(sFile file)
        {
            if (file.name.ToUpper().EndsWith(".PACK"))
                return PACK.Unpack(pluginHost, file.path);

            return new sFolder();
        }
Example #9
0
File: Main.cs Project: MetLob/tinke
        public string Pack(ref sFolder unpacked, sFile file)
        {
            string fileOut = pluginHost.Get_TempFile();
            PAC.Pack(file.path, fileOut, ref unpacked);

            return fileOut;
        }
Example #10
0
File: Main.cs Project: MetLob/tinke
        public Format Get_Format(sFile file, byte[] magic)
        {
            string ext = new String(Encoding.ASCII.GetChars(magic));

            if (ext == "sadl")
            {
                byte coding = pluginHost.Get_Bytes(file.path, (int)file.offset + 0x33, 1)[0];
                if ((coding & 0xF0) == 0x70 || (coding & 0xF0) == 0xB0)
                    return Format.Sound;
            }

            if (file.name.ToUpper().EndsWith(".ADX"))
            {
                if (magic[0] != 0x80 || magic[1] != 00)     // Constant
                    return Format.Unknown;

                byte[] checkBytes = pluginHost.Get_Bytes(file.path, (int)file.offset + 4, 0xF); // Version and encoding flags
                if (checkBytes[0] == 0x03 && (checkBytes[0xE] == 0x03 || checkBytes[0xE] == 0x04))
                {
                    byte[] offset = { magic[3], magic[2] };
                    byte[] copyright = pluginHost.Get_Bytes(file.path, (int)file.offset + BitConverter.ToUInt16(offset, 0) - 2, 6);

                    if (new String(Encoding.ASCII.GetChars(copyright)) == "(c)CRI")
                        return Format.Sound;
                }
            }

            return Format.Unknown;
        }
Example #11
0
File: Main.cs Project: MetLob/tinke
        public Format Get_Format(sFile file, byte[] magic)
        {
            if (file.name.EndsWith(".PACK"))
                return Format.Compressed;

            return Format.Unknown;
        }
Example #12
0
        public static sFolder Decrypt(sFile item, int blockSize, IPluginHost pluginHost)
        {
            sFolder unpacked = new sFolder();
            unpacked.files = new List<sFile>();

            byte[] data = File.ReadAllBytes(item.path);
            int numBlocks = data.Length / blockSize;

            for (int i = 0; i < numBlocks; i++)
            {
                byte[] block = new byte[blockSize];
                Array.Copy(data, i * blockSize, block, 0, blockSize);
                Decrypt(ref block);
                Array.Copy(block, 0, data, i * blockSize, blockSize);
            }

            string fileout = pluginHost.Get_TempFile();
            File.WriteAllBytes(fileout, data);

            sFile newItem = new sFile();
            newItem.path = fileout;
            newItem.offset = 0;
            newItem.name = item.name;
            newItem.size = (uint)data.Length;
            unpacked.files.Add(newItem);

            return unpacked;
        }
Example #13
0
File: Arch.cs Project: MetLob/tinke
        public Format Get_Format(sFile file, byte[] magic)
        {
            if (Encoding.ASCII.GetString(magic) == MagicStamp)
                return Format.Pack;

            return Format.Unknown;
        }
Example #14
0
        public sFolder Unpack(sFile file)
        {
            if (file.id == 0x3F)
            {
                sFolder unpack = new sFolder();
                unpack.files = new List<sFile>();
                BinaryReader br = new BinaryReader(File.OpenRead(file.path));

                uint fat_size = br.ReadUInt32();
                uint num_files = fat_size / 4 - 1;  // Include a ptr to the fat section

                for (int i = 0; i < num_files; i++)
                {
                    sFile cfile = new sFile();
                    cfile.name = "File" + i.ToString() + ".bin";
                    cfile.path = file.path;

                    br.BaseStream.Position = 8 + i * 4;
                    cfile.offset = br.ReadUInt32();
                    br.BaseStream.Position = cfile.offset;
                    cfile.size = br.ReadUInt32();
                    cfile.offset += 4;

                    unpack.files.Add(cfile);
                }

                br.Close();
                br = null;

                return unpack;
            }

            return new sFolder();
        }
Example #15
0
File: Main.cs Project: MetLob/tinke
        public Format Get_Format(sFile file, byte[] magic)
        {
            if (file.name.ToUpper().EndsWith(".DPK"))
                return Format.Pack;

            return Format.Unknown;
        }
Example #16
0
File: Main.cs Project: MetLob/tinke
        public void Read(sFile file)
        {
            System.IO.BinaryReader br = new System.IO.BinaryReader(System.IO.File.OpenRead(file.path));
            string ext = new String(Encoding.ASCII.GetChars(br.ReadBytes(4)));
            br.Close();

            if (ext == "CG4 ")
            {
                CGx cgx = new CGx(file.path, file.id, false, file.name);
                pluginHost.Set_Palette(cgx.Palette);
                pluginHost.Set_Image(cgx);
            }
            else if (ext == "CG8 ")
            {
                CGx cgx = new CGx(file.path, file.id, true, file.name);
                pluginHost.Set_Palette(cgx.Palette);
                pluginHost.Set_Image(cgx);
            }
            else if (ext == "SC4 " || ext == "SC8 ")
            {
                SCx scx = new SCx(file.path, file.id, file.name);
                pluginHost.Set_Map(scx);
            }
            else if (ext == "CGT ")
            {
                CGT cgt = new CGT(file.path, file.id, file.name);
                pluginHost.Set_Palette(cgt.Palette);
                pluginHost.Set_Image(cgt);
            }
        }
Example #17
0
File: Main.cs Project: MetLob/tinke
        public string Pack(ref sFolder unpacked, sFile file)
        {
            if (file.name.ToUpper().EndsWith(".DPK"))
                return DPK.Pack(ref unpacked, file.path, file.id);

            return null;
        }
Example #18
0
File: Main.cs Project: MetLob/tinke
        public Format Get_Format(sFile file, byte[] magic)
        {
            string ext = new string(Encoding.ASCII.GetChars(magic));
            uint exti = BitConverter.ToUInt32(magic, 0);

            if (file.id == 0x1D9 || file.id == 0x1DA)
                return Format.FullImage;
            else if (ext == "LINK")
                return Format.Pack;
            else if (exti == 0x0040E3C4 || exti == 0x0040E3BC)
                return Format.Pack;
            else if (bigImages.Contains(file.id))
                return Format.Tile;
            else if (bigImages.Contains(file.id - 1))
                return Format.System;
            else if (file.id == 0x20F || file.id == 0x230 || file.id == 0x231)
                return Format.FullImage;
            else if (file.id == 0x210 || file.id == 0x232 || file.id == 0x233)
                return Format.System;

            if (file.id == 0xE6 || file.id == 0xE9)
                return Format.Tile;
            else if (file.id == 0xE7 || file.id == 0xEA)
                return Format.Palette;

            return Format.Unknown;
        }
Example #19
0
        /// <summary>
        /// Get a "sFolder" variable with all files and folders from the main folder path.
        /// </summary>
        /// <param name="folderPath">Folder to read</param>
        /// <param name="currFolder">Empty folder</param>
        /// <returns></returns>
        public static sFolder Recursive_GetDirectories(string folderPath, sFolder currFolder)
        {
            foreach (string file in Directory.GetFiles(folderPath))
            {
                sFile newFile = new sFile();
                newFile.name = Path.GetFileName(file);
                newFile.offset = 0x00;
                newFile.path = file;
                newFile.size = (uint)new FileInfo(file).Length;

                if (!(currFolder.files is List<sFile>))
                    currFolder.files = new List<sFile>();
                currFolder.files.Add(newFile);
            }

            foreach (string folder in Directory.GetDirectories(folderPath))
            {
                sFolder newFolder = new sFolder();
                newFolder.name = new DirectoryInfo(folder).Name;
                newFolder = Recursive_GetDirectories(folder, newFolder);

                if (!(currFolder.folders is List<sFolder>))
                    currFolder.folders = new List<sFolder>();
                currFolder.folders.Add(newFolder);
            }

            return currFolder;
        }
Example #20
0
File: Main.cs Project: MetLob/tinke
        public Format Get_Format(sFile file, byte[] magic)
        {
            if (file.name == "RESOURCE.NXARC")
                return Format.Pack;

            return Format.Unknown;
        }
Example #21
0
        public sFolder Unpack(sFile file)
        {
            // There are only one type of pack file
            BinaryReader br = new BinaryReader(File.OpenRead(file.path));
            sFolder unpack = new sFolder();
            unpack.files = new List<sFile>();

            uint num_files = (br.ReadUInt32() / 8) - 1; // The last entry indicate the end of file
            br.BaseStream.Position = 0;

            for (int i = 0; i < num_files; i++)
            {
                sFile newFile = new sFile();
                newFile.name = file.name + '_' + i.ToString() + ".bin";
                newFile.offset = br.ReadUInt32();
                newFile.path = file.path;

                uint size = br.ReadUInt32();
                if ((size >> 31) == 1)  // The file it's compressed with LZ11
                {
                    uint next_offset = br.ReadUInt32();
                    newFile.size = next_offset - newFile.offset;
                    br.BaseStream.Position -= 4;
                }
                else
                    newFile.size = size;

                unpack.files.Add(newFile);
            }

            br.Close();
            return unpack;
        }
Example #22
0
File: Main.cs Project: MetLob/tinke
        public sFolder Unpack(sFile file)
        {
            if (file.name.ToUpper().EndsWith("RESOURCE.NXARC"))
                return PACK.Unpack(file.path, file.name);

            return new sFolder();
        }
Example #23
0
File: Main.cs Project: MetLob/tinke
        public sFolder Unpack(sFile file)
        {
            if (gameCode == "YDNJ" && file.id == 0x01)
                return Packs.Unpack_data(file);

            return new sFolder();
        }
Example #24
0
File: DATA.cs Project: MetLob/tinke
        public static sFolder Unpack(sFile file)
        {
            BinaryReader br = new BinaryReader(File.OpenRead(file.path));
            sFolder unpack = new sFolder();
            unpack.files = new List<sFile>();

            br.BaseStream.Position = 0x10;  // Header

            const int num_files = 0x1246;
            for (int i = 0; i < num_files; i++)
            {
                sFile newFile = new sFile();
                newFile.name = "File_" + i.ToString() + '.';
                newFile.size = br.ReadUInt32();
                newFile.offset = br.ReadUInt32();
                newFile.path = file.path;

                long currPos = br.BaseStream.Position;
                br.BaseStream.Position = newFile.offset;
                string ext = new String(br.ReadChars(3));
                if (ext != "IMY" && ext != "MAP")
                    ext = "BIN";
                newFile.name += ext;
                br.BaseStream.Position = currPos;

                unpack.files.Add(newFile);
            }

            br.Close();
            return unpack;
        }
Example #25
0
File: Main.cs Project: MetLob/tinke
        public Format Get_Format(sFile file, byte[] magic)
        {
            if (file.name.ToUpper().EndsWith(".BIN"))
                return Format.FullImage;

            return Format.Unknown;
        }
Example #26
0
File: WMAP.cs Project: MetLob/tinke
        static uint HEADER = 0x50414d57; // "WMAP"

        #endregion Fields

        #region Methods

        public static sFolder Unpack(string fileIn, string name)
        {
            name = Path.GetFileNameWithoutExtension(name);

            BinaryReader br = new BinaryReader(File.OpenRead(fileIn));
            sFolder unpack = new sFolder();
            unpack.files = new List<sFile>();

            if (br.ReadUInt32() != HEADER)
            {
                br.Close();
                br = null;
                throw new FormatException("Invalid header!");
            }

            uint num_files = br.ReadUInt32();
            br.ReadUInt32();    // Unknown 1
            br.ReadUInt32();    // Unknown 2

            for (int i = 0; i < num_files; i++)
            {
                sFile cfile = new sFile();
                cfile.name = name + '_' + i.ToString() + ".bin";
                cfile.offset = br.ReadUInt32();
                cfile.size = br.ReadUInt32();
                cfile.path = fileIn;
                unpack.files.Add(cfile);
            }

            br.Close();
            br = null;
            return unpack;
        }
Example #27
0
File: Main.cs Project: MetLob/tinke
 public void Read(sFile file)
 {
     if (file.id >= 0x13EF && file.id <= 0x1500)
         new SIR0_Sprite(pluginHost, file.path, file.id, file.name);
     //if (file.name.EndsWith(".at6p"))
     //    new SIR0_Image(pluginHost, file.path, file.id, file.name);
 }
Example #28
0
File: Main.cs Project: MetLob/tinke
        public Format Get_Format(sFile file, byte[] magic)
        {
            string ext = Encoding.ASCII.GetString(magic);

            if (file.id == this.GetPackId(PackTypes.FileData) ||
                file.id == this.GetPackId(PackTypes.ProjectTable))
            {
                return Format.Pack;
            }

            if (file.id == this.GetPackId(PackTypes.ProjectData))
            {
                return Format.System;
            }

            if (ext == "SCRN")
            {
                return Format.FullImage;
            }

            if (ext == "CELL")
            {
                return Format.Cell;
            }

            if (file.name.EndsWith(".inl"))
            {
                return Format.Text;
            }

            return Format.Unknown;
        }
Example #29
0
 public TextEditor(IPluginHost pluginHost, sFile file)
     : this()
 {
     this.pluginHost = pluginHost;
     this.id = file.id;
     this.txtText.Text = File.ReadAllText(file.path);
 }
Example #30
0
File: Main.cs Project: MetLob/tinke
        public Format Get_Format(sFile file, byte[] magic)
        {
            if (file.name == "archiveDBK.dsa")
                return Format.Pack;

            return Format.Unknown;
        }