public override void Read(string file) { // It's compressed pluginHost.Decompress(file); string dec_file; sFolder dec_folder = pluginHost.Get_Files(); if (dec_folder.files is List <sFile> ) { dec_file = dec_folder.files[0].path; } else { string tempFile = Path.GetTempFileName(); Byte[] compressFile = new Byte[(new FileInfo(file).Length) - 0x08]; Array.Copy(File.ReadAllBytes(file), 0x08, compressFile, 0, compressFile.Length);; File.WriteAllBytes(tempFile, compressFile); pluginHost.Decompress(tempFile); dec_file = pluginHost.Get_Files().files[0].path; } BinaryReader br = new BinaryReader(File.OpenRead(dec_file)); NTFS[] map = new NTFS[br.BaseStream.Length / 2]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); } br.Close(); Set_Map(map, false, 0x100, 0x100); pluginHost.Set_Map(this); }
public override void Read(string file) { // Decompressed the file pluginHost.Decompress(file); string dec_file; sFolder dec_folder = pluginHost.Get_Files(); if (dec_folder.files is List <sFile> ) { dec_file = dec_folder.files[0].path; } else { string tempFile = Path.GetTempFileName(); Byte[] compressFile = new Byte[(new FileInfo(file).Length) - 0x08]; Array.Copy(File.ReadAllBytes(file), 0x08, compressFile, 0, compressFile.Length);; File.WriteAllBytes(tempFile, compressFile); pluginHost.Decompress(tempFile); dec_file = pluginHost.Get_Files().files[0].path; } BinaryReader br = new BinaryReader(File.OpenRead(dec_file)); ColorFormat depth = (br.BaseStream.Length > 0x20) ? ColorFormat.colors256 : ColorFormat.colors16; Color[][] colors = new Color[1][]; colors[0] = Actions.BGR555ToColor(br.ReadBytes((int)br.BaseStream.Length)); br.Close(); Set_Palette(colors, depth, false); pluginHost.Set_Palette(this); }
public override void Read(string file) { // It's compressed pluginHost.Decompress(file); string dec_file; sFolder dec_folder = pluginHost.Get_Files(); if (dec_folder.files is List <sFile> ) { dec_file = dec_folder.files[0].path; } else { string tempFile = Path.GetTempFileName(); Byte[] compressFile = new Byte[(new FileInfo(file).Length) - 0x08]; Array.Copy(File.ReadAllBytes(file), 0x08, compressFile, 0, compressFile.Length);; File.WriteAllBytes(tempFile, compressFile); pluginHost.Decompress(tempFile); dec_file = pluginHost.Get_Files().files[0].path; } BinaryReader br = new BinaryReader(File.OpenRead(dec_file)); Byte[] tiles = br.ReadBytes((int)br.BaseStream.Length); br.Close(); Set_Tiles(tiles, 0x100, tiles.Length / 0x100, ColorFormat.colors16, TileForm.Horizontal, false); pluginHost.Set_Image(this); }
public Control Show_Info() { // Los archivos tienen compresión LZ77, descomprimimos primero. string temp = archivo + "nn"; Byte[] compressFile = new Byte[(new FileInfo(archivo).Length) - 4]; Array.Copy(File.ReadAllBytes(archivo), 4, compressFile, 0, compressFile.Length);; File.WriteAllBytes(temp, compressFile); pluginHost.Decompress(temp); archivo = pluginHost.Get_Files().files[0].path; File.Delete(temp); InfoAni control = new InfoAni(); if (archivo.EndsWith(".arcnn")) { control = new InfoAni(Obtener_Todo(), pluginHost); } else if (archivo.EndsWith(".arjnn")) { control = new InfoAni(Obtener_ARJ(), pluginHost); } File.Delete(archivo); return(control); }
public static sFolder Read(string file, int id, IPluginHost pluginHost) { pluginHost.Decompress(file); string dec_file = pluginHost.Get_Files().files[0].path; BinaryReader br = new BinaryReader(File.OpenRead(dec_file)); sFolder decompressed = new sFolder(); sPCK2 pck2 = new sPCK2(); pck2.file_id = id; // Read the header pck2.header.header_size = br.ReadUInt32(); pck2.header.file_size = br.ReadUInt32(); pck2.header.id = br.ReadChars(4); pck2.header.unknown = br.ReadUInt32(); // Read all files decompressed.files = new List <sFile>(); br.BaseStream.Position = pck2.header.header_size; while (br.BaseStream.Position != br.BaseStream.Length) { long pos = br.BaseStream.Position; sPCK2.File newFile = new sPCK2.File(); newFile.header_size = br.ReadUInt32(); newFile.size = br.ReadUInt32(); newFile.unknown = br.ReadUInt32(); newFile.data_size = br.ReadUInt32(); newFile.name = ""; char c = br.ReadChar(); while (c != '\x0') { newFile.name += c; c = br.ReadChar(); } br.BaseStream.Position = pos + newFile.header_size; newFile.data = br.ReadBytes((int)newFile.data_size); br.BaseStream.Position = pos + newFile.size; // Save the new file sFile savedFile = new sFile(); savedFile.name = newFile.name; savedFile.offset = 0x00; savedFile.size = newFile.data_size; savedFile.path = Path.GetTempPath() + Path.DirectorySeparatorChar + newFile.name; File.WriteAllBytes(savedFile.path, newFile.data); decompressed.files.Add(savedFile); } br.Close(); return(decompressed); }
public static sFolder Read(string file, int id, IPluginHost pluginHost) { pluginHost.Decompress(file); string dec_file = pluginHost.Get_Files().files[0].path; BinaryReader br = new BinaryReader(File.OpenRead(dec_file)); sFolder decompressed = new sFolder(); sPCK2 pck2 = new sPCK2(); pck2.file_id = id; // Read the header pck2.header.header_size = br.ReadUInt32(); pck2.header.file_size = br.ReadUInt32(); pck2.header.id = br.ReadChars(4); pck2.header.unknown = br.ReadUInt32(); // Read all files decompressed.files = new List<sFile>(); br.BaseStream.Position = pck2.header.header_size; while (br.BaseStream.Position != br.BaseStream.Length) { long pos = br.BaseStream.Position; sPCK2.File newFile = new sPCK2.File(); newFile.header_size = br.ReadUInt32(); newFile.size = br.ReadUInt32(); newFile.unknown = br.ReadUInt32(); newFile.data_size = br.ReadUInt32(); newFile.name = ""; char c = br.ReadChar(); while (c != '\x0') { newFile.name += c; c = br.ReadChar(); } br.BaseStream.Position = pos + newFile.header_size; newFile.data = br.ReadBytes((int)newFile.data_size); br.BaseStream.Position = pos + newFile.size; // Save the new file sFile savedFile = new sFile(); savedFile.name = newFile.name; savedFile.offset = 0x00; savedFile.size = newFile.data_size; savedFile.path = Path.GetTempPath() + Path.DirectorySeparatorChar + newFile.name; File.WriteAllBytes(savedFile.path, newFile.data); decompressed.files.Add(savedFile); } br.Close(); return decompressed; }
public static sFolder Unpack(sFile file, IPluginHost pluginHost) { string filename = Path.GetFileNameWithoutExtension(file.name); BinaryReader br = new BinaryReader(File.OpenRead(file.path)); string decodedPath = file.path; byte b = br.ReadByte(); br.Close(); if (b == 0x10) { pluginHost.Decompress(file.path); decodedPath = pluginHost.Get_Files().files[0].path; } br = new BinaryReader(File.OpenRead(decodedPath)); sFolder unpacked = new sFolder(); unpacked.files = new List <sFile>(); uint numFiles = br.ReadUInt32(); for (int i = 0; i < numFiles; i++) { br.BaseStream.Position = 4 + i * 8; sFile newFile = new sFile(); newFile.path = decodedPath; newFile.name = filename + "_" + i.ToString(); newFile.offset = br.ReadUInt32(); newFile.size = br.ReadUInt32(); if (IsPack(br.BaseStream, newFile.offset, newFile.size)) { newFile.name += ".pack"; } else { newFile.name += ".bin"; } unpacked.files.Add(newFile); } br.Close(); br = null; return(unpacked); }
public override void Read(string fileIn) { // The file is compressed string temp = pluginHost.Get_TempFolder() + Path.DirectorySeparatorChar + Path.GetRandomFileName(); Byte[] compressFile = new Byte[(new FileInfo(fileIn).Length) - 4]; Array.Copy(File.ReadAllBytes(fileIn), 4, compressFile, 0, compressFile.Length);; File.WriteAllBytes(temp, compressFile); pluginHost.Decompress(temp); // Get the decompressed file fileIn = pluginHost.Get_Files().files[0].path; File.Delete(temp); Get_Image(fileIn); }
public static sFile Decompress(string file, IPluginHost pluginHost) { sFile decompressed; string parent_name = Path.GetFileNameWithoutExtension(file).Substring(12); string temp = parent_name + ".resc"; Byte[] compressFile = new Byte[(new FileInfo(file).Length) - 0x10]; Array.Copy(File.ReadAllBytes(file), 0x10, compressFile, 0, compressFile.Length); ; File.WriteAllBytes(temp, compressFile); pluginHost.Decompress(temp); decompressed = pluginHost.Get_Files().files[0]; File.Delete(temp); return decompressed; }
public static sFile Decompress(string file, IPluginHost pluginHost) { sFile decompressed; string parent_name = Path.GetFileNameWithoutExtension(file).Substring(12); string temp = parent_name + ".resc"; Byte[] compressFile = new Byte[(new FileInfo(file).Length) - 0x10]; Array.Copy(File.ReadAllBytes(file), 0x10, compressFile, 0, compressFile.Length);; File.WriteAllBytes(temp, compressFile); pluginHost.Decompress(temp); decompressed = pluginHost.Get_Files().files[0]; File.Delete(temp); return(decompressed); }
public static sFolder Unpack(sFile file, IPluginHost pluginHost) { string filename = Path.GetFileNameWithoutExtension(file.name); BinaryReader br = new BinaryReader(File.OpenRead(file.path)); string decodedPath = file.path; byte b = br.ReadByte(); br.Close(); if (b == 0x10) { pluginHost.Decompress(file.path); decodedPath = pluginHost.Get_Files().files[0].path; } br = new BinaryReader(File.OpenRead(decodedPath)); sFolder unpacked = new sFolder(); unpacked.files = new List<sFile>(); uint numFiles = br.ReadUInt32(); for (int i = 0; i < numFiles; i++) { br.BaseStream.Position = 4 + i * 8; sFile newFile = new sFile(); newFile.path = decodedPath; newFile.name = filename + "_" + i.ToString(); newFile.offset = br.ReadUInt32(); newFile.size = br.ReadUInt32(); if (IsPack(br.BaseStream, newFile.offset, newFile.size)) newFile.name += ".pack"; else newFile.name += ".bin"; unpacked.files.Add(newFile); } br.Close(); br = null; return unpacked; }
void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); char[] type = br.ReadChars(4); if (new String(type) != "TMAP") { br.Close(); br = null; throw new FormatException("Invalid header!"); } uint imgs_layer = br.ReadUInt32(); // Number of images per layer tile_width = br.ReadUInt32(); // Number of horizontal images tile_height = br.ReadUInt32(); // Number of vertical images // Layer 1: background // Layer 2: layer 1 (it's printed after print the NPC and player, it's over the player) // Layer 3: layer 2 // Layer 4: Collision tiles = new Bitmap[4][]; for (int l = 0; l < 4; l++) { // For each layer get al the files tiles[l] = new Bitmap[imgs_layer]; for (int i = 0; i < imgs_layer; i++) { // Read FAT br.BaseStream.Position = 0x10 + l * imgs_layer * 8 + i * 8; uint offset = br.ReadUInt32(); uint size = br.ReadUInt32(); if (offset == 0x00 || size == 0x00) { continue; } // Read file br.BaseStream.Position = offset; byte[] data = br.ReadBytes((int)size); string tempFile = null; if (data[0] == 0x11 || data[0] == 0x30) // Decompress it, LZ11 for BTX0 and RLE for BMP { pluginHost.Decompress(data); sFolder f = pluginHost.Get_Files(); if (!(f.files is List <sFile>) || f.files.Count != 1) // Check if the decompression fails { Console.WriteLine("Problem decompressing file -> l: {0}, i: {1}", l.ToString(), i.ToString()); continue; } tempFile = f.files[0].path; // Check if the decomprsesion fails data = File.ReadAllBytes(tempFile); if (data[0] == 0x11 || data[0] == 0x30) { continue; } } else { tempFile = pluginHost.Get_TempFile(); File.WriteAllBytes(tempFile, data); } // Get image string header = new string(Encoding.ASCII.GetChars(data, 0, 4)); if (header == "BTX0") { // Call to the 3D plugin to get a bitmap from the texture string[] param = { tempFile, "_3DModels.Main", "", "BTX0" }; pluginHost.Call_Plugin(param, -1, 0); if (pluginHost.Get_Object() is Bitmap[]) { tiles[l][i] = ((Bitmap[])pluginHost.Get_Object())[0]; pluginHost.Set_Object(null); } else { Console.WriteLine("Problem getting bitmap image -> l: {0}, i: {1}", l.ToString(), i.ToString()); } } else if (header.StartsWith("BM")) // BMP file { try { tiles[l][i] = (Bitmap)Image.FromFile(tempFile); } catch { } } else { Console.WriteLine("Unknown file -> l: {0}, i: {1}", l.ToString(), i.ToString()); } } } br.Close(); br = null; }
public override void Read(string file) { // It's compressed pluginHost.Decompress(file); string dec_file; sFolder dec_folder = pluginHost.Get_Files(); if (dec_folder.files is List <sFile> ) { dec_file = dec_folder.files[0].path; } else { string tempFile = Path.GetTempFileName(); Byte[] compressFile = new Byte[(new FileInfo(file).Length) - 0x08]; Array.Copy(File.ReadAllBytes(file), 0x08, compressFile, 0, compressFile.Length);; File.WriteAllBytes(tempFile, compressFile); pluginHost.Decompress(tempFile); dec_file = pluginHost.Get_Files().files[0].path; } BinaryReader br = new BinaryReader(File.OpenRead(dec_file)); // Bank info Ekona.Images.Bank[] banks = new Ekona.Images.Bank[br.ReadUInt32()]; uint num_cells = br.ReadUInt32(); uint unknown1 = br.ReadUInt32(); for (int i = 0; i < banks.Length; i++) { uint unk = br.ReadUInt16(); banks[i].oams = new OAM[br.ReadUInt16()]; } // Read cell information for (int i = 0; i < banks.Length; i++) { for (int j = 0; j < banks[i].oams.Length; j++) { banks[i].oams[j].obj1.xOffset = br.ReadInt16(); banks[i].oams[j].obj0.yOffset = br.ReadInt16(); uint size_b = br.ReadUInt32(); byte b1 = (byte)(size_b & 0x03); byte b2 = (byte)((size_b & 0x0C) >> 2); System.Drawing.Size size = Actions.Get_OAMSize(b1, b2); banks[i].oams[j].width = (ushort)size.Width; banks[i].oams[j].height = (ushort)size.Height; banks[i].oams[j].obj2.tileOffset = br.ReadUInt32(); banks[i].oams[j].obj2.index_palette = 0; banks[i].oams[j].num_cell = (ushort)j; } } Set_Banks(banks, 2, false); pluginHost.Set_Sprite(this); // Palette PaletteBase palette; int palette_length = (int)(br.BaseStream.Length - br.BaseStream.Position); Color[][] colors = new Color[1][]; colors[0] = Actions.BGR555ToColor(br.ReadBytes(palette_length)); br.Close(); palette = new RawPalette(colors, false, (palette_length > 0x20) ? ColorFormat.colors256 : ColorFormat.colors16); pluginHost.Set_Palette(palette); }