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(); } } }
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); } }
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); }
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); } } }
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); } } }
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); }