Пример #1
0
        public void ApplyGameGenie()
        {
            if (!string.IsNullOrEmpty(GameGenie))
            {
                bool wasCompressed = DecompressPossible().Length > 0;
                if (wasCompressed)
                {
                    Decompress();
                }

                var codes    = GameGenie.Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
                var nesFiles = Directory.GetFiles(this.basePath, "*.nes", SearchOption.TopDirectoryOnly);
                foreach (var f in nesFiles)
                {
                    var nesFile = new NesFile(f);
                    foreach (var code in codes)
                    {
                        nesFile.PRG = GameGeniePatcherNes.Patch(nesFile.PRG, code.Trim());
                    }
                    nesFile.Save(f);
                }

                if (wasCompressed)
                {
                    Compress();
                }
            }
        }
Пример #2
0
 public void ApplyGameGenie()
 {
     if (!string.IsNullOrEmpty(GameGenie))
     {
         var codes   = GameGenie.Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
         var nesFile = new NesFile(NesPath);
         foreach (var code in codes)
         {
             nesFile.PRG = GameGeniePatcher.Patch(nesFile.PRG, code.Trim());
         }
         nesFile.Save(NesPath);
     }
 }
Пример #3
0
        public bool ApplyGameGenie(out byte[] gameFileData)
        {
            gameFileData = null;
            if (!string.IsNullOrEmpty(GameGenie))
            {
                var    codes        = GameGenie.Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
                string gameFilePath = GameFilePath;
                if (gameFilePath != null)
                {
                    gameFilePath = gameFilePath.ToLower();
                    byte[] data   = null;
                    int    offset = 0;
                    if (gameFilePath.Contains(".sfrom"))
                    {
                        data   = GameFileData;
                        offset = 48;
                    }
                    else if (gameFilePath.Contains(".sfc") || gameFilePath.Contains(".smc"))
                    {
                        data = GameFileData;
                        if ((data.Length % 1024) != 0)
                        {
                            offset = 512;
                        }
                        else
                        {
                            offset = 0;
                        }
                    }

                    if (data != null)
                    {
                        byte[] rawData = new byte[data.Length - offset];
                        Array.Copy(data, offset, rawData, 0, rawData.Length);

                        foreach (var code in codes)
                        {
                            rawData = GameGeniePatcherSnes.Patch(rawData, code);
                        }

                        Array.Copy(rawData, 0, data, offset, rawData.Length);
                        gameFileData = data;
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #4
0
 public void ApplyGameGenie()
 {
     if (!string.IsNullOrEmpty(GameGenie))
     {
         var codes    = GameGenie.Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
         var nesFiles = Directory.GetFiles(this.GamePath, "*.nes", SearchOption.TopDirectoryOnly);
         foreach (var f in nesFiles)
         {
             var nesFile = new NesFile(f);
             foreach (var code in codes)
             {
                 nesFile.PRG = GameGeniePatcherNes.Patch(nesFile.PRG, code.Trim());
             }
             nesFile.Save(f);
         }
     }
 }
Пример #5
0
        public void ApplyGameGenie()
        {
            if (!string.IsNullOrEmpty(GameGenie))
            {
                var codes    = GameGenie.Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
                var nesFiles = Directory.GetFiles(this.GamePath, "*.*", SearchOption.TopDirectoryOnly);
                foreach (var f in nesFiles)
                {
                    byte[] data;
                    var    ext = Path.GetExtension(f).ToLower();
                    int    offset;
                    if (ext == ".sfrom")
                    {
                        data   = File.ReadAllBytes(f);
                        offset = 48;
                    }
                    else if (ext == ".sfc" || ext == ".smc")
                    {
                        data = File.ReadAllBytes(f);
                        if ((data.Length % 1024) != 0)
                        {
                            offset = 512;
                        }
                        else
                        {
                            offset = 0;
                        }
                    }
                    else
                    {
                        continue;
                    }

                    var rawData = new byte[data.Length - offset];
                    Array.Copy(data, offset, rawData, 0, rawData.Length);

                    foreach (var code in codes)
                    {
                        rawData = GameGeniePatcherSnes.Patch(rawData, code);
                    }

                    Array.Copy(rawData, 0, data, offset, rawData.Length);
                    File.WriteAllBytes(f, data);
                }
            }
        }
Пример #6
0
 public bool ApplyGameGenie(out byte[] gameFileData)
 {
     gameFileData = null;
     if (!string.IsNullOrEmpty(GameGenie))
     {
         var    codes        = GameGenie.Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
         string gameFilePath = GameFilePath;
         if (gameFilePath != null)
         {
             byte[] data = GameFileData;
             if (data != null)
             {
                 var nesFile = new NesFile(data);
                 foreach (var code in codes)
                 {
                     nesFile.PRG = GameGeniePatcherNes.Patch(nesFile.PRG, code.Trim());
                 }
                 gameFileData = nesFile.GetRaw();
                 return(true);
             }
         }
     }
     return(false);
 }