Exemplo n.º 1
0
        private void SaveShadowDATONE(string datOneFileName)
        {
            byte[] bdtBytes    = VisibilityFunctions.ShadowVisibilityFileToArray(visibilityFunctions.ChunkList, bspRenderer.currentShadowFolderNamePrefix);
            byte[] splineBytes = shadowSplineEditor.ShadowSplinesToByteArray(bspRenderer.currentShadowFolderNamePrefix).ToArray();

            Archive shadowDATONE;

            if (File.Exists(datOneFileName))
            {
                byte[] fileContents = File.ReadAllBytes(datOneFileName);
                shadowDATONE = Archive.FromONEFile(ref fileContents);
            }
            else
            {
                shadowDATONE = new Archive(CommonRWVersions.Shadow050);
            }

            bool bdtFound = false;
            bool splFound = false;

            foreach (var file in shadowDATONE.Files)
            {
                if (Path.GetExtension(file.Name).ToLower() == ".bdt")
                {
                    file.CompressedData = Prs.Compress(ref bdtBytes);
                    bdtFound            = true;
                }
                else if (file.Name == "PATH.PTP")
                {
                    file.CompressedData = Prs.Compress(ref splineBytes);
                    splFound            = true;
                }
            }

            if (!bdtFound)
            {
                ArchiveFile file = new ArchiveFile((bspRenderer.currentShadowFolderNamePrefix + ".bdt").ToUpper(), bdtBytes);
                shadowDATONE.Files.Add(file);
            }
            if (!splFound)
            {
                ArchiveFile file = new ArchiveFile("PATH.PTP", splineBytes);
                shadowDATONE.Files.Add(file);
            }

            File.WriteAllBytes(datOneFileName, shadowDATONE.BuildShadowONEArchive(true).ToArray());
        }
Exemplo n.º 2
0
        private void SaveFile()
        {
            ByteConverter.BigEndian = bigEndian;
            uint        addr     = (uint)((scenes.Count + 1) * Scene.Size) + 0x817AFE60u;
            List <byte> fc       = new List <byte>();
            Encoding    encoding = useSJIS ? jpenc : euenc;

            foreach (Scene scene in scenes)
            {
                fc.AddRange(ByteConverter.GetBytes(scene.SceneNumber));
                fc.AddRange(ByteConverter.GetBytes(addr));
                fc.AddRange(ByteConverter.GetBytes(scene.Messages.Count));
                addr += (uint)(scene.Messages.Count * Message.Size);
            }
            fc.AddRange(Enumerable.Repeat(byte.MaxValue, 4));
            fc.AddRange(Enumerable.Repeat(byte.MinValue, 8));
            System.Diagnostics.Debug.Assert(fc.Count == (scenes.Count + 1) * Scene.Size);
            foreach (Scene scene in scenes)
            {
                foreach (Message msg in scene.Messages)
                {
                    fc.AddRange(ByteConverter.GetBytes(msg.Character));
                    fc.AddRange(ByteConverter.GetBytes(addr));
                    addr += (uint)(encoding.GetByteCount(msg.Text) + 1);
                }
            }
            foreach (Scene scene in scenes)
            {
                foreach (Message msg in scene.Messages)
                {
                    fc.AddRange(encoding.GetBytes(msg.Text));
                    fc.Add(0);
                }
            }
            if (Path.GetExtension(filename).Equals(".prs", StringComparison.OrdinalIgnoreCase))
            {
                Prs.Compress(fc.ToArray(), filename);
            }
            else
            {
                File.WriteAllBytes(filename, fc.ToArray());
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Replaces the compressed contents of an individual archive file with another file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void replaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Pick file.
            CommonOpenFileDialog fileDialog = new CommonOpenFileDialog
            {
                Title            = "Select the file to replace the current file contents with.",
                InitialDirectory = _lastOpenedDirectory
            };

            // Replace the file
            if (fileDialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                byte[] newFile = File.ReadAllBytes(fileDialog.FileName);
                ArchiveFile.CompressedData = Prs.Compress(ref newFile);
                if (!Properties.Settings.Default.OpenAtCurrentFile)
                {
                    _lastOpenedDirectory = Path.GetDirectoryName(fileDialog.FileName);
                }
            }
        }
Exemplo n.º 4
0
        /*
         *  Process each file in a DragDrop operation.
         */
        private void btn_CompressDragDrop_DragDrop(object sender, DragEventArgs e)
        {
            // Get files dropped onto button and process them.
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            int             searchBufferSize = (int)nud_SearchBufferSize.Value;
            ParallelOptions options          = new ParallelOptions()
            {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            };

            Parallel.ForEach(files, file =>
            {
                byte[] decompressedFile = File.ReadAllBytes(file);
                byte[] compressedFile   = Prs.Compress(ref decompressedFile, searchBufferSize);

                string fileName = Path.GetFileName(file);
                File.WriteAllBytes($"{TempDirectoryName}\\{fileName}", compressedFile);
            });

            // Open directory
            Process.Start(TempDirectoryName);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Compresses the file (if necessary), retrieving the compressed data corresponding to this file.
 /// </summary>
 /// <param name="bufferSize">Size of the compressor search buffer, between 0 - 8191.</param>
 public byte[] GetCompressedData(int bufferSize = 255)
 {
     return(IsDataCompressed ? Data : Prs.Compress(Data, bufferSize));
 }
Exemplo n.º 6
0
        private static List <MaterialBuildInfo> BuildProceduralMaterials(string baseDirectory, List <Assimp.Material> aiMaterials, string texturePakPath)
        {
            var textureArchive       = new GvmArchive();
            var textureArchiveStream = new MemoryStream();
            var textureArchiveWriter = ( GvmArchiveWriter )textureArchive.Create(textureArchiveStream);
            var textureIdLookup      = new Dictionary <string, int>(StringComparer.InvariantCultureIgnoreCase);

            if (texturePakPath != null && File.Exists(texturePakPath))
            {
                var extension  = Path.GetExtension(texturePakPath);
                var fileStream = ( Stream )File.OpenRead(texturePakPath);
                if (extension.Equals(".prs", StringComparison.InvariantCultureIgnoreCase))
                {
                    try
                    {
                        var decompressedFileStream = new MemoryStream();
                        Prs.Decompress(fileStream, decompressedFileStream);
                        fileStream.Dispose();
                        fileStream = decompressedFileStream;
                    }
                    catch (Exception)
                    {
                        // Not compressed
                    }

                    fileStream.Position = 0;
                }

                var existingTextureArchive       = new GvmArchive();
                var existingTextureArchiveReader = ( GvmArchiveReader )existingTextureArchive.Open(fileStream);
                for (var i = 0; i < existingTextureArchiveReader.Entries.Count; i++)
                {
                    var entry = existingTextureArchiveReader.Entries[i];

                    // Make copy of entry stream
                    var entryStreamCopy = new MemoryStream();
                    entry.Open().CopyTo(entryStreamCopy);
                    entryStreamCopy.Position = 0;

                    var texture = new VrSharp.GvrTexture.GvrTexture(entryStreamCopy);
                    Console.WriteLine(texture.GlobalIndex);
                    entryStreamCopy.Position = 0;

                    // Clean entry name from the added extension
                    var entryName = Path.ChangeExtension(entry.Name, null);

                    textureArchiveWriter.CreateEntry(entryStreamCopy, entryName);
                    textureIdLookup[entryName] = i;
                }
            }

            var materials = new List <MaterialBuildInfo>();

            foreach (var aiMaterial in aiMaterials)
            {
                var textureName = Path.GetFileNameWithoutExtension(aiMaterial.TextureDiffuse.FilePath).ToLowerInvariant();
                if (!textureIdLookup.TryGetValue(textureName, out var textureId))
                {
                    textureId = textureIdLookup[textureName] = textureIdLookup.Count;
                    var texturePath = Path.GetFullPath(Path.Combine(baseDirectory, aiMaterial.TextureDiffuse.FilePath));
                    if (File.Exists(texturePath))
                    {
                        // Convert texture
                        var texture = new GvrTexture {
                            GlobalIndex = ( uint )(1 + textureId)
                        };

                        var textureStream = new MemoryStream();
                        var textureBitmap = new Bitmap(texturePath);
                        texture.Write(textureBitmap, textureStream);
                        textureStream.Position = 0;

                        // Add it
                        textureArchiveWriter.CreateEntry(textureStream, textureName);
                    }
                }

                var material = new MaterialBuildInfo
                {
                    Ambient          = AssimpHelper.FromAssimp(aiMaterial.ColorAmbient),
                    Diffuse          = AssimpHelper.FromAssimp(aiMaterial.ColorDiffuse),
                    Specular         = AssimpHelper.FromAssimp(aiMaterial.ColorSpecular),
                    ClampU           = aiMaterial.TextureDiffuse.WrapModeU == Assimp.TextureWrapMode.Clamp,
                    ClampV           = aiMaterial.TextureDiffuse.WrapModeV == Assimp.TextureWrapMode.Clamp,
                    FlipU            = aiMaterial.TextureDiffuse.WrapModeU == Assimp.TextureWrapMode.Mirror,
                    FlipV            = aiMaterial.TextureDiffuse.WrapModeV == Assimp.TextureWrapMode.Mirror,
                    DestinationAlpha = DstAlphaOp.InverseDst,
                    Exponent         = 0,
                    FilterMode       = FilterMode.Trilinear,
                    MipMapDAdjust    = MipMapDAdjust.D050,
                    SourceAlpha      = SrcAlphaOp.Src,
                    SuperSample      = false,
                    TextureId        = (short)textureId,
                };

                materials.Add(material);
            }

            // Write texture archive to file
            textureArchiveWriter.Flush();
            textureArchiveStream.Position = 0;

            if (texturePakPath != null)
            {
                // Compress it.
                var textureArchivePrsStream = new MemoryStream();
                Prs.Compress(textureArchiveStream, textureArchivePrsStream);

                // Save compressed file.
                textureArchivePrsStream.Position = 0;
                using (var outFile = File.Create(texturePakPath))
                    textureArchivePrsStream.CopyTo(outFile);
            }

            return(materials);
        }
Exemplo n.º 7
0
 public byte[] Compress(int windowSize) => Prs.Compress(FileData, windowSize);
Exemplo n.º 8
0
 public void GlobalSetup()
 {
     // Executed once per each WindowSize
     FileDataCompressed = Prs.Compress(FileData, WindowSize);
 }
Exemplo n.º 9
0
 public FileBenchmark(byte[] fileData)
 {
     FileData           = fileData;
     FileDataCompressed = Prs.Compress(FileData, 0x1FFF);
 }
Exemplo n.º 10
0
 public void Compress(byte[] file)
 {
     byte[] compressed   = Prs.Compress(file, 0x1FFF);
     byte[] decompressed = Prs.Decompress(compressed);
     Assert.Equal(file, decompressed);
 }
Exemplo n.º 11
0
 /// <summary>
 /// 压缩文件
 /// </summary>
 /// <param name="compFile"></param>
 /// <returns></returns>
 public override byte[] Compress(string file)
 {
     return(Prs.Compress(file));
 }
Exemplo n.º 12
0
 public ArchiveFile(string name, byte[] uncompressedData)
 {
     Name                = name;
     CompressedData      = Prs.Compress(ref uncompressedData);
     RwVersion.RwVersion = (uint)CommonRWVersions.Heroes;
 }
Exemplo n.º 13
0
        public static void SaveShadowVisibilityFile(IEnumerable <Chunk> chunkList, string levelName, string visibilityONEpath)
        {
            BinaryWriter BLKFileWriter = new BinaryWriter(new MemoryStream());

            foreach (char c in levelName)
            {
                BLKFileWriter.Write((byte)c);
            }

            BLKFileWriter.BaseStream.Position = 0x40;

            BLKFileWriter.Write(chunkList.Count());
            foreach (Chunk i in chunkList)
            {
                BLKFileWriter.Write(i.number);
                BLKFileWriter.Write(i.Min.X);
                BLKFileWriter.Write(i.Min.Y);
                BLKFileWriter.Write(i.Min.Z);
                BLKFileWriter.Write(i.Max.X);
                BLKFileWriter.Write(i.Max.Y);
                BLKFileWriter.Write(i.Max.Z);
                BLKFileWriter.Write(80);
            }

            Archive shadowDATONE;

            if (File.Exists(visibilityONEpath))
            {
                byte[] fileContents = File.ReadAllBytes(visibilityONEpath);
                shadowDATONE = Archive.FromONEFile(ref fileContents);
            }
            else
            {
                shadowDATONE = new Archive(CommonRWVersions.Shadow050);
            }

            bool found = false;

            foreach (var file in shadowDATONE.Files)
            {
                if (Path.GetExtension(file.Name).ToLower() == ".bdt")
                {
                    byte[] bytes = (BLKFileWriter.BaseStream as MemoryStream).ToArray();
                    file.CompressedData = Prs.Compress(ref bytes);
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                byte[]      bytes = (BLKFileWriter.BaseStream as MemoryStream).ToArray();
                ArchiveFile file  = new ArchiveFile((levelName + ".bdt").ToUpper(), bytes);
                shadowDATONE.Files.Add(file);
            }


            List <byte> fileBytes = shadowDATONE.BuildShadowONEArchive(true);

            File.WriteAllBytes(visibilityONEpath, fileBytes.ToArray());

            BLKFileWriter.Close();
        }
Exemplo n.º 14
0
 static void Main(string[] args)
 {
     if (args.Length == 0)
     {
         Console.Write("Filename: ");
         args = new string[] { Console.ReadLine().Trim('"') };
     }
     foreach (string filename in args)
     {
         byte[] fc;
         if (Path.GetExtension(filename).Equals(".prs", StringComparison.OrdinalIgnoreCase))
         {
             fc = Prs.Decompress(filename);
         }
         else
         {
             fc = File.ReadAllBytes(filename);
         }
         string       path = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(filename)), Path.GetFileNameWithoutExtension(filename));
         EventIniData ini  = IniSerializer.Deserialize <EventIniData>(Path.Combine(path, Path.ChangeExtension(Path.GetFileName(filename), ".ini")));
         uint         key;
         if (fc[0] == 0x81)
         {
             ByteConverter.BigEndian = true;
             key = 0x8125FE60;
         }
         else
         {
             ByteConverter.BigEndian = false;
             key = 0xC600000;
         }
         List <byte> modelbytes           = new List <byte>(fc);
         Dictionary <string, uint> labels = new Dictionary <string, uint>();
         foreach (string file in ini.Files.Where(a => HelperFunctions.FileHash(Path.Combine(path, a.Key)) != a.Value).Select(a => a.Key))
         {
             modelbytes.AddRange(new ModelFile(Path.Combine(path, file)).Model.GetBytes((uint)(key + modelbytes.Count), false, labels, out uint address));
         }
         fc = modelbytes.ToArray();
         int ptr = fc.GetPointer(0x20, key);
         if (ptr != 0)
         {
             for (int i = 0; i < (ini.Game == Game.SA2B ? 18 : 16); i++)
             {
                 UpgradeInfo info = ini.Upgrades[i];
                 if (info.RootNode != null)
                 {
                     if (labels.ContainsKey(info.RootNode))
                     {
                         ByteConverter.GetBytes(labels[info.RootNode]).CopyTo(fc, ptr);
                     }
                     if (labels.ContainsKey(info.AttachNode1))
                     {
                         ByteConverter.GetBytes(labels[info.AttachNode1]).CopyTo(fc, ptr + 4);
                     }
                     if (labels.ContainsKey(info.Model1))
                     {
                         ByteConverter.GetBytes(labels[info.Model1]).CopyTo(fc, ptr + 8);
                     }
                     if (info.AttachNode2 != null && labels.ContainsKey(info.AttachNode2))
                     {
                         ByteConverter.GetBytes(labels[info.AttachNode2]).CopyTo(fc, ptr + 12);
                     }
                     if (info.Model2 != null && labels.ContainsKey(info.Model2))
                     {
                         ByteConverter.GetBytes(labels[info.Model2]).CopyTo(fc, ptr + 16);
                     }
                 }
                 ptr += 0x14;
             }
         }
         int gcnt = ByteConverter.ToInt32(fc, 8);
         ptr = fc.GetPointer(0, key);
         if (ptr != 0)
         {
             for (int gn = 0; gn <= gcnt; gn++)
             {
                 GroupInfo info = ini.Groups[gn];
                 int       ptr2 = fc.GetPointer(ptr, key);
                 int       ecnt = Math.Min(ByteConverter.ToInt32(fc, ptr + 4), info.Entities?.Count ?? 0);
                 if (ptr2 != 0)
                 {
                     for (int en = 0; en < ecnt; en++)
                     {
                         if (labels.ContainsKey(info.Entities[en]))
                         {
                             ByteConverter.GetBytes(labels[info.Entities[en]]).CopyTo(fc, ptr2);
                         }
                         ptr2 += ini.Game == Game.SA2B ? 0x2C : 0x20;
                     }
                 }
                 ptr2 = fc.GetPointer(ptr + 0x18, key);
                 if (ptr2 != 0 && info.Big != null && labels.ContainsKey(info.Big))
                 {
                     ByteConverter.GetBytes(labels[info.Big]).CopyTo(fc, ptr2);
                 }
                 ptr += 0x20;
             }
         }
         ptr = fc.GetPointer(0x18, key);
         if (ptr != 0)
         {
             for (int i = 0; i < 18; i++)
             {
                 if (ini.MechParts.ContainsKey(i) && labels.ContainsKey(ini.MechParts[i]))
                 {
                     ByteConverter.GetBytes(labels[ini.MechParts[i]]).CopyTo(fc, ptr);
                 }
                 ptr += 4;
             }
         }
         ptr = fc.GetPointer(0x1C, key);
         if (ptr != 0 && ini.TailsTails != null && labels.ContainsKey(ini.TailsTails))
         {
             ByteConverter.GetBytes(labels[ini.TailsTails]).CopyTo(fc, ptr);
         }
         if (Path.GetExtension(filename).Equals(".prs", StringComparison.OrdinalIgnoreCase))
         {
             Prs.Compress(fc, filename);
         }
         else
         {
             File.WriteAllBytes(filename, fc);
         }
     }
 }
Exemplo n.º 15
0
        public static void Build(string filename)
        {
            nodenames.Clear();
            modelfiles.Clear();
            motionfiles.Clear();

            byte[] fc;
            if (Path.GetExtension(filename).Equals(".prs", StringComparison.OrdinalIgnoreCase))
            {
                fc = Prs.Decompress(filename);
            }
            else
            {
                fc = File.ReadAllBytes(filename);
            }
            string           path = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(filename)), Path.GetFileNameWithoutExtension(filename));
            JsonSerializer   js   = new JsonSerializer();
            MiniEventIniData ini;

            using (TextReader tr = File.OpenText(Path.Combine(path, Path.ChangeExtension(Path.GetFileName(filename), ".json"))))
                using (JsonTextReader jtr = new JsonTextReader(tr))
                    ini = js.Deserialize <MiniEventIniData>(jtr);
            uint key;

            if (fc[4] == 0x81)
            {
                ByteConverter.BigEndian = true;
                key = 0x816DFE60;
            }
            else
            {
                ByteConverter.BigEndian = false;
                key = 0xCB00000;
            }
            List <byte> modelbytes           = new List <byte>(fc);
            Dictionary <string, uint> labels = new Dictionary <string, uint>();

            foreach (string file in ini.Files.Where(a => a.Key.EndsWith(".sa2mdl", StringComparison.OrdinalIgnoreCase) && HelperFunctions.FileHash(Path.Combine(path, a.Key)) != a.Value).Select(a => a.Key))
            {
                modelbytes.AddRange(new ModelFile(Path.Combine(path, file)).Model.GetBytes((uint)(key + modelbytes.Count), false, labels, new List <uint>(), out uint _));
            }
            foreach (string file in ini.Files.Where(a => a.Key.EndsWith(".saanim", StringComparison.OrdinalIgnoreCase) && HelperFunctions.FileHash(Path.Combine(path, a.Key)) != a.Value).Select(a => a.Key))
            {
                modelbytes.AddRange(NJS_MOTION.Load(Path.Combine(path, file)).GetBytes((uint)(key + modelbytes.Count), labels, out uint _));
            }
            fc = modelbytes.ToArray();
            int ptr = fc.GetPointer(8, key);

            if (ptr != 0)
            {
                MiniEventChars info = ini.Sonic[0];
                if (labels.ContainsKeySafer(info.BodyAnims))
                {
                    ByteConverter.GetBytes(labels[info.BodyAnims]).CopyTo(fc, ptr);
                }
                if (info.HeadPart != null)
                {
                    if (labels.ContainsKeySafer(info.HeadPart))
                    {
                        ByteConverter.GetBytes(labels[info.HeadPart]).CopyTo(fc, ptr + 4);
                    }
                    if (labels.ContainsKeySafer(info.HeadAnims))
                    {
                        ByteConverter.GetBytes(labels[info.HeadAnims]).CopyTo(fc, ptr + 8);
                    }
                    if (labels.ContainsKeySafer(info.HeadShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.HeadShapeMotions]).CopyTo(fc, ptr + 0xC);
                    }
                    if (labels.ContainsKeySafer(info.MouthPart))
                    {
                        ByteConverter.GetBytes(labels[info.MouthPart]).CopyTo(fc, ptr + 0x10);
                    }
                    if (labels.ContainsKeySafer(info.MouthAnims))
                    {
                        ByteConverter.GetBytes(labels[info.MouthAnims]).CopyTo(fc, ptr + 0x14);
                    }
                    if (labels.ContainsKeySafer(info.MouthShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.MouthShapeMotions]).CopyTo(fc, ptr + 0x18);
                    }
                    if (labels.ContainsKeySafer(info.LHandPart))
                    {
                        ByteConverter.GetBytes(labels[info.LHandPart]).CopyTo(fc, ptr + 0x1C);
                    }
                    if (labels.ContainsKeySafer(info.LHandAnims))
                    {
                        ByteConverter.GetBytes(labels[info.LHandAnims]).CopyTo(fc, ptr + 0x20);
                    }
                    if (labels.ContainsKeySafer(info.LHandShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.LHandShapeMotions]).CopyTo(fc, ptr + 0x24);
                    }
                    if (labels.ContainsKeySafer(info.RHandPart))
                    {
                        ByteConverter.GetBytes(labels[info.RHandPart]).CopyTo(fc, ptr + 0x28);
                    }
                    if (labels.ContainsKeySafer(info.RHandAnims))
                    {
                        ByteConverter.GetBytes(labels[info.RHandAnims]).CopyTo(fc, ptr + 0x2C);
                    }
                    if (labels.ContainsKeySafer(info.RHandShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.RHandShapeMotions]).CopyTo(fc, ptr + 0x30);
                    }
                }
            }
            ptr = fc.GetPointer(0xC, key);
            if (ptr != 0)
            {
                MiniEventChars info = ini.Shadow[0];
                if (labels.ContainsKeySafer(info.BodyAnims))
                {
                    ByteConverter.GetBytes(labels[info.BodyAnims]).CopyTo(fc, ptr);
                }
                if (info.HeadPart != null)
                {
                    if (labels.ContainsKeySafer(info.HeadPart))
                    {
                        ByteConverter.GetBytes(labels[info.HeadPart]).CopyTo(fc, ptr + 4);
                    }
                    if (labels.ContainsKeySafer(info.HeadAnims))
                    {
                        ByteConverter.GetBytes(labels[info.HeadAnims]).CopyTo(fc, ptr + 8);
                    }
                    if (labels.ContainsKeySafer(info.HeadShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.HeadShapeMotions]).CopyTo(fc, ptr + 0xC);
                    }
                    if (labels.ContainsKeySafer(info.MouthPart))
                    {
                        ByteConverter.GetBytes(labels[info.MouthPart]).CopyTo(fc, ptr + 0x10);
                    }
                    if (labels.ContainsKeySafer(info.MouthAnims))
                    {
                        ByteConverter.GetBytes(labels[info.MouthAnims]).CopyTo(fc, ptr + 0x14);
                    }
                    if (labels.ContainsKeySafer(info.MouthShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.MouthShapeMotions]).CopyTo(fc, ptr + 0x18);
                    }
                    if (labels.ContainsKeySafer(info.LHandPart))
                    {
                        ByteConverter.GetBytes(labels[info.LHandPart]).CopyTo(fc, ptr + 0x1C);
                    }
                    if (labels.ContainsKeySafer(info.LHandAnims))
                    {
                        ByteConverter.GetBytes(labels[info.LHandAnims]).CopyTo(fc, ptr + 0x20);
                    }
                    if (labels.ContainsKeySafer(info.LHandShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.LHandShapeMotions]).CopyTo(fc, ptr + 0x24);
                    }
                    if (labels.ContainsKeySafer(info.RHandPart))
                    {
                        ByteConverter.GetBytes(labels[info.RHandPart]).CopyTo(fc, ptr + 0x28);
                    }
                    if (labels.ContainsKeySafer(info.RHandAnims))
                    {
                        ByteConverter.GetBytes(labels[info.RHandAnims]).CopyTo(fc, ptr + 0x2C);
                    }
                    if (labels.ContainsKeySafer(info.RHandShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.RHandShapeMotions]).CopyTo(fc, ptr + 0x30);
                    }
                }
            }
            ptr = fc.GetPointer(0x18, key);
            if (ptr != 0)
            {
                MiniEventChars info = ini.Knuckles[0];
                if (labels.ContainsKeySafer(info.BodyAnims))
                {
                    ByteConverter.GetBytes(labels[info.BodyAnims]).CopyTo(fc, ptr);
                }
                if (info.HeadPart != null)
                {
                    if (labels.ContainsKeySafer(info.HeadPart))
                    {
                        ByteConverter.GetBytes(labels[info.HeadPart]).CopyTo(fc, ptr + 4);
                    }
                    if (labels.ContainsKeySafer(info.HeadAnims))
                    {
                        ByteConverter.GetBytes(labels[info.HeadAnims]).CopyTo(fc, ptr + 8);
                    }
                    if (labels.ContainsKeySafer(info.HeadShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.HeadShapeMotions]).CopyTo(fc, ptr + 0xC);
                    }
                    if (labels.ContainsKeySafer(info.MouthPart))
                    {
                        ByteConverter.GetBytes(labels[info.MouthPart]).CopyTo(fc, ptr + 0x10);
                    }
                    if (labels.ContainsKeySafer(info.MouthAnims))
                    {
                        ByteConverter.GetBytes(labels[info.MouthAnims]).CopyTo(fc, ptr + 0x14);
                    }
                    if (labels.ContainsKeySafer(info.MouthShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.MouthShapeMotions]).CopyTo(fc, ptr + 0x18);
                    }
                    if (labels.ContainsKeySafer(info.LHandPart))
                    {
                        ByteConverter.GetBytes(labels[info.LHandPart]).CopyTo(fc, ptr + 0x1C);
                    }
                    if (labels.ContainsKeySafer(info.LHandAnims))
                    {
                        ByteConverter.GetBytes(labels[info.LHandAnims]).CopyTo(fc, ptr + 0x20);
                    }
                    if (labels.ContainsKeySafer(info.LHandShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.LHandShapeMotions]).CopyTo(fc, ptr + 0x24);
                    }
                    if (labels.ContainsKeySafer(info.RHandPart))
                    {
                        ByteConverter.GetBytes(labels[info.RHandPart]).CopyTo(fc, ptr + 0x28);
                    }
                    if (labels.ContainsKeySafer(info.RHandAnims))
                    {
                        ByteConverter.GetBytes(labels[info.RHandAnims]).CopyTo(fc, ptr + 0x2C);
                    }
                    if (labels.ContainsKeySafer(info.RHandShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.RHandShapeMotions]).CopyTo(fc, ptr + 0x30);
                    }
                }
            }
            ptr = fc.GetPointer(0x1C, key);
            if (ptr != 0)
            {
                MiniEventChars info = ini.Rouge[0];
                if (labels.ContainsKeySafer(info.BodyAnims))
                {
                    ByteConverter.GetBytes(labels[info.BodyAnims]).CopyTo(fc, ptr);
                }
                if (info.HeadPart != null)
                {
                    if (labels.ContainsKeySafer(info.HeadPart))
                    {
                        ByteConverter.GetBytes(labels[info.HeadPart]).CopyTo(fc, ptr + 4);
                    }
                    if (labels.ContainsKeySafer(info.HeadAnims))
                    {
                        ByteConverter.GetBytes(labels[info.HeadAnims]).CopyTo(fc, ptr + 8);
                    }
                    if (labels.ContainsKeySafer(info.HeadShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.HeadShapeMotions]).CopyTo(fc, ptr + 0xC);
                    }
                    if (labels.ContainsKeySafer(info.MouthPart))
                    {
                        ByteConverter.GetBytes(labels[info.MouthPart]).CopyTo(fc, ptr + 0x10);
                    }
                    if (labels.ContainsKeySafer(info.MouthAnims))
                    {
                        ByteConverter.GetBytes(labels[info.MouthAnims]).CopyTo(fc, ptr + 0x14);
                    }
                    if (labels.ContainsKeySafer(info.MouthShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.MouthShapeMotions]).CopyTo(fc, ptr + 0x18);
                    }
                    if (labels.ContainsKeySafer(info.LHandPart))
                    {
                        ByteConverter.GetBytes(labels[info.LHandPart]).CopyTo(fc, ptr + 0x1C);
                    }
                    if (labels.ContainsKeySafer(info.LHandAnims))
                    {
                        ByteConverter.GetBytes(labels[info.LHandAnims]).CopyTo(fc, ptr + 0x20);
                    }
                    if (labels.ContainsKeySafer(info.LHandShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.LHandShapeMotions]).CopyTo(fc, ptr + 0x24);
                    }
                    if (labels.ContainsKeySafer(info.RHandPart))
                    {
                        ByteConverter.GetBytes(labels[info.RHandPart]).CopyTo(fc, ptr + 0x28);
                    }
                    if (labels.ContainsKeySafer(info.RHandAnims))
                    {
                        ByteConverter.GetBytes(labels[info.RHandAnims]).CopyTo(fc, ptr + 0x2C);
                    }
                    if (labels.ContainsKeySafer(info.RHandShapeMotions))
                    {
                        ByteConverter.GetBytes(labels[info.RHandShapeMotions]).CopyTo(fc, ptr + 0x30);
                    }
                }
            }
            ptr = fc.GetPointer(0x24, key);
            if (ptr != 0 && labels.ContainsKeySafer(ini.MechEggmanBodyAnims))
            {
                ByteConverter.GetBytes(labels[ini.MechEggmanBodyAnims]).CopyTo(fc, ptr);
            }
            ptr = fc.GetPointer(4, key);
            if (ptr != 0 && labels.ContainsKeySafer(ini.Camera))
            {
                ByteConverter.GetBytes(labels[ini.Camera]).CopyTo(fc, 4);
                //ByteConverter.GetBytes(ini.CamFrames).CopyTo(fc, ptr + 4);
                ByteConverter.GetBytes(labels[ini.Camera]).CopyTo(fc, ptr + 0x10);
            }
            if (Path.GetExtension(filename).Equals(".prs", StringComparison.OrdinalIgnoreCase))
            {
                Prs.Compress(fc, filename);
            }
            else
            {
                File.WriteAllBytes(filename, fc);
            }
        }