public static void Pack(string fileIn, string fileOut, ref sFolder unpacked) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); br.BaseStream.Position = 0x08; uint block_size = br.ReadUInt32(); br.Close(); BinaryWriter bw = new BinaryWriter(File.OpenWrite(fileOut)); bw.Write(new char[] { 'L', 'I', 'N', 'K' }); bw.Write(unpacked.files.Count); bw.Write(block_size); bw.Write(0x00); unpacked.files.Sort(SortFiles); uint offset = block_size; List <byte> buffer = new List <byte>(); for (int i = 0; i < unpacked.files.Count; i++) { br = new BinaryReader(File.OpenRead(unpacked.files[i].path)); br.BaseStream.Position = unpacked.files[i].offset; buffer.AddRange(br.ReadBytes((int)unpacked.files[i].size)); while (buffer.Count % block_size != 0) { buffer.Add(0x00); } br.Close(); bw.Write(offset / block_size); bw.Write(unpacked.files[i].size); sFile upFile = unpacked.files[i]; upFile.offset = offset; upFile.path = fileOut; unpacked.files[i] = upFile; offset += unpacked.files[i].size; if (offset % block_size != 0) // Padding { offset += (block_size - (offset % block_size)); } } byte[] rem = new byte[0]; if (bw.BaseStream.Position % block_size != 0) { rem = new byte[block_size - (bw.BaseStream.Position % block_size)]; } bw.Write(rem); bw.Flush(); bw.Write(buffer.ToArray()); bw.Flush(); bw.Close(); }
public TMAP(sFile cfile, IPluginHost pluginHost) { this.id = cfile.id; this.fileName = Path.GetFileNameWithoutExtension(cfile.name); this.pluginHost = pluginHost; Read(cfile.path); }
public String Pack(sFile file, ref sFolder unpacked) { Unpack(file); String fileout = pluginHost.Get_TempFile(); Save_NARC(fileout, ref unpacked, file.path); return(fileout); }
public string Pack(ref sFolder unpacked, sFile file) { string fileOut = pluginHost.Get_TempFile(); PAC.Pack(file.path, fileOut, ref unpacked); return(fileOut); }
public TMAPcontrol(sFile cfile, IPluginHost pluginHost) { InitializeComponent(); this.pluginHost = pluginHost; tmap = new TMAP(cfile, pluginHost); numLayer_ValueChanged(null, null); }
public VisorHexBasic(sFile gameFile) { this.file = File.OpenRead(gameFile.path); this.size = gameFile.size; this.offset = gameFile.offset; Initialize(); }
public static sFolder Unpack(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); sFolder unpacked = new sFolder(); unpacked.files = new List <sFile>(); char[] type = br.ReadChars(4); uint num_files = br.ReadUInt32(); uint block_size = br.ReadUInt32(); uint padding = br.ReadUInt32(); for (int i = 0; i < num_files; i++) { sFile newFile = new sFile(); newFile.name = "File" + i.ToString(); newFile.offset = br.ReadUInt32() * block_size; newFile.size = br.ReadUInt32(); if (newFile.size == 0) { newFile.size = block_size; } newFile.path = file; if (num_files == 6) { if (i == 0) { newFile.name += ".nanr"; } else if (i == 1) { newFile.name += ".ncgr"; // Tile form -> Lineal } else if (i == 2) { newFile.name += ".ncer"; } else if (i == 3) { newFile.name += ".ncgr"; // Tile form -> Horizontal } else if (i == 4) { newFile.name += ".nclr"; } else if (i == 5) { newFile.name += ".nscr"; } } unpacked.files.Add(newFile); } br.Close(); return(unpacked); }
public static void Pack(string file, string original, ref sFolder unpacked, IPluginHost pluginHost) { BinaryWriter bw = new BinaryWriter(File.OpenWrite(file)); BinaryReader br = new BinaryReader(File.OpenRead(original)); // Copy header bw.Write(br.ReadBytes(0x50)); // Write file info uint offset = 0x800; for (int i = 0; i < unpacked.files.Count; i++) { bw.Write(br.ReadBytes(0x08)); bw.Write(unpacked.files[i].size); br.BaseStream.Position += 4; bw.Write(offset); br.BaseStream.Position += 4; offset += unpacked.files[i].size; if (offset % 0x800 != 0) { offset += 0x800 - (offset % 0x800); } } br.Close(); // Write files bw.Write(new byte[0x800 - bw.BaseStream.Position]); for (int i = 0; i < unpacked.files.Count; i++) { sFile cfile = unpacked.files[i]; uint startOffset = (uint)bw.BaseStream.Position; // Write info BinaryReader brfile = new BinaryReader(File.OpenRead(cfile.path)); brfile.BaseStream.Position = cfile.offset; bw.Write(brfile.ReadBytes((int)cfile.size)); brfile.Close(); // Write padding while (bw.BaseStream.Position % 0x800 != 0) { bw.Write((byte)0); } // Update file info cfile.offset = startOffset; cfile.path = file; unpacked.files[i] = cfile; } // Update file size bw.BaseStream.Position = 0x08; bw.Write((uint)bw.BaseStream.Length); bw.Close(); }
private void btnAddOffset_Click(object sender, EventArgs e) { if (fat.files == null) { fat.files = new List <sFile>(); } sFile newFile = new sFile(); newFile.path = file; newFile.name = "File " + (fat.files.Count - 1).ToString(); newFile.offset = (uint)(numOffset.Value * numericOffsetMult.Value); if (numSize.Value == 0) { newFile.size = (uint)(new FileInfo(file).Length - newFile.offset); } else { newFile.size = (uint)numSize.Value; } // Get the extension BinaryReader br = new BinaryReader(File.OpenRead(file)); br.BaseStream.Position = newFile.offset; char[] ext; if (newFile.size < 4) { ext = Encoding.ASCII.GetChars(br.ReadBytes((int)newFile.size)); } else { ext = Encoding.ASCII.GetChars(br.ReadBytes(4)); } String extS = "."; for (int s = 0; s < ext.Length; s++) { if (Char.IsLetterOrDigit(ext[s]) || ext[s] == 0x20) { extS += ext[s]; } } if (extS != "." && extS.Length == 5 && newFile.size >= 4) { newFile.name += extS; } else { newFile.name += ".bin"; } fat.files.Add(newFile); listBoxFiles.Items.Add(newFile.name); }
public Format Get_Format(sFile file, byte[] magic) { if (file.name == "RESOURCE.NXARC") { return(Format.Pack); } return(Format.Unknown); }
public System.Windows.Forms.Control Show_Info(sFile file) { if (this.IsImage(file.id)) { return(this.ShowImage(file)); } return(new TextEditor(this.pluginHost, file)); }
public Format Get_Format(sFile file, byte[] magic) { if (file.name.ToUpper() == "ROMFILE.BIN") { return(Format.Pack); } return(Format.Unknown); }
public Format Get_Format(sFile file, byte[] magic) { if (magic[0] == 0x08) { return(Format.Compressed); } return(Format.Unknown); }
public sFolder Unpack(sFile file) { if (file.name.ToUpper().EndsWith(".DPK")) { return(DPK.Unpack(file.path, pluginHost)); } return(new sFolder()); }
public sFolder Unpack(sFile file) { if (file.id >= 0x9E && file.id <= 0xD8 && file.id != 0xBA) { return(Unpack(file.path, file.name)); } return(new sFolder()); }
public Format Get_Format(sFile file, byte[] magic) { if (file.name.EndsWith(".PACK")) { return(Format.Compressed); } return(Format.Unknown); }
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); }
public sFolder Unpack(sFile file) { if (file.name.ToUpper().EndsWith(".PACK")) { return(PACK.Unpack(pluginHost, file.path)); } return(new sFolder()); }
public void Read(sFile file) { //// BMP images //string fileOut = pluginHost.Get_TempFolder() + Path.DirectorySeparatorChar + file.name + ".png"; //System.Drawing.Image img = System.Drawing.Image.FromFile(file.path); //img.Save(fileOut, System.Drawing.Imaging.ImageFormat.Png); //img.Dispose(); //img = null; }
public sFolder Unpack(sFile file) { if (file.id == 0x01) { return(HETALIA.Pack.DATA.Unpack(file)); } return(new sFolder()); }
public Format Get_Format(sFile file, byte[] magic) { if (Encoding.ASCII.GetString(magic) == MagicStamp) { return(Format.Pack); } return(Format.Unknown); }
public sFolder Unpack(sFile file) { if (gameCode == "YDNJ" && file.id == 0x01) { return(Packs.Unpack_data(file)); } return(new sFolder()); }
public Format Get_Format(sFile file, byte[] magic) { if (gameCode == "YDNJ" && file.id == 0x1) { return(Format.Pack); } return(Format.Unknown); }
public sFolder Unpack(sFile file) { if (file.name.ToUpper().EndsWith(".ARC")) { return(ARC.Unpack(file.path, pluginHost, gameCode)); } return(new sFolder()); }
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); }
public sFolder Unpack(sFile file) { if (file.name.ToUpper().EndsWith("RESOURCE.NXARC")) { return(PACK.Unpack(file.path, file.name)); } return(new sFolder()); }
public Format Get_Format(sFile file, byte[] magic) { if (file.id >= 0x2F && file.id <= 0x93) { return(Format.Pack); } return(Format.Unknown); }
public Format Get_Format(sFile file, byte[] magic) { if (file.name.ToUpper().EndsWith(".DPK")) { return(Format.Pack); } return(Format.Unknown); }
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); }
public Format Get_Format(sFile file, byte[] magic) { if (file.name.EndsWith(".pack") || IsPack(file.id)) { return(Format.Pack); } return(Format.Unknown); }