private static void unitTests() { foreach (string bcmfilename in Directory.EnumerateFiles(@"C:\Users\Eric\Desktop\BLECE\latest\", "*.bcm", SearchOption.AllDirectories)) { //Console.WriteLine(bcmfilename); string charname = bcmfilename.Substring(bcmfilename.Length - 7, 3); Console.Write(charname + "-BCM-"); var bcm = BCMFile.FromFilename(bcmfilename); var bac = BACFile.FromFilename(bcmfilename.Replace(".bcm", ".bac"), bcm); BCMFile.ToFilename("tmp." + charname + ".bcm", bcm); BACFile.ToFilename("tmp." + charname + ".bac", bac, bcm); byte[] original = File.ReadAllBytes(bcmfilename); byte[] output = File.ReadAllBytes("tmp." + charname + ".bcm"); if (original.Length != output.Length) { Console.WriteLine("--------------------------REBUILD FAIL:These arent even the same size?"); Console.WriteLine("original: {0} rebuild: {1} diff: {2}", original.Length, output.Length, original.Length - output.Length); continue; } //Console.WriteLine("Good, files are the same size"); bool good = true; for (int i = 0; i < original.Length; i++) { if (original[i] != output[i]) { Console.WriteLine("-----------------------REBUILD FAIL:Difference at {0:X}", i); good = false; break; } } if (good == true) { Console.WriteLine("----This files ok!"); } Console.Write(charname + "-BAC"); original = File.ReadAllBytes(bcmfilename.Replace(".bcm", ".bac")); output = File.ReadAllBytes("tmp." + charname + ".bac"); if (original.Length != output.Length) { Console.WriteLine("--------------------------REBUILD FAIL:These arent even the same size?"); continue; } //Console.WriteLine("Good, files are the same size"); good = true; for (int i = 0; i < original.Length; i++) { if (original[i] != output[i]) { Console.WriteLine("-----------------------REBUILD FAIL:Difference at {0:X}", i); good = false; break; } } if (good == true) { Console.WriteLine("----This files ok!"); } } }
private static void rainbow() { foreach (string bcmfilename in Directory.EnumerateFiles(@"C:\Users\Eric\Desktop\BLECE\latest\", "*.bcm", SearchOption.AllDirectories)) { //Console.WriteLine(bcmfilename); string charname = bcmfilename.Substring(bcmfilename.Length - 7, 3); Console.WriteLine(charname); var bcm = BCMFile.FromFilename(bcmfilename); var bac = BACFile.FromFilename(bcmfilename.Replace(".bcm", ".bac"), bcm); string targetbcm = @"C:\Program Files (x86)\Capcom\Super Street Fighter IV\dlc\03_character_free\battle\regulation\latest\" + Path.GetFileNameWithoutExtension(bcmfilename) + "\\" + Path.GetFileNameWithoutExtension(bcmfilename) + ".bcm"; string targetbac = targetbcm.Replace(".bcm", ".bac"); foreach (Charge charge in bcm.Charges) { charge.Frames = 2; } foreach (Script script in bac.Scripts) { if (script.Name == "NONE") { continue; } foreach (HitboxCommand hitbox in script.CommandLists[(int)CommandListType.HITBOX]) { //hitbox.Juggle = 1; hitbox.JugglePotential = 20; if (hitbox.Type == HitboxCommand.HitboxType.GRAB) { hitbox.Type = HitboxCommand.HitboxType.NORMAL; } if (hitbox.HitLevel == HitboxCommand.HitLevelType.AIR_ONLY) { hitbox.HitLevel = HitboxCommand.HitLevelType.MID; } } foreach (SpeedCommand speed in script.CommandLists[(int)CommandListType.SPEED]) { speed.Multiplier = (float)(speed.Multiplier * 1.7); } foreach (CancelCommand cancel in script.CommandLists[(int)CommandListType.CANCELS]) { if (cancel.Condition == CancelCommand.CancelConditions.ON_HIT) { cancel.Condition = CancelCommand.CancelConditions.START; } } } if (!Directory.Exists(Path.GetDirectoryName(targetbcm))) { Directory.CreateDirectory(Path.GetDirectoryName(targetbcm)); } BCMFile.ToFilename(targetbcm, bcm); BACFile.ToFilename(targetbac, bac, bcm); } }
/// <summary> /// The load BCM. /// </summary> /// <param name="character"> /// The character. /// </param> public static void LoadBCM(string character) { string path = string.Format("{0}\\patch\\battle\\regulation\\latest_ae\\{1}\\{1}.bcm", @"M:\SteamLibrary\SteamApps\common\Super Street Fighter IV - Arcade Edition", character); try { // This isn't case sensitive. bcm = BCMFile.FromFilename(path); bac = BACFile.FromFilename(path.Replace("bcm", "bac"), bcm); loadedCharacter = character.ToLower(); }catch {} }
private void ClickSave(object sender, RoutedEventArgs e) { /* * var sb = new SaveFileDialog(); * sb.InitialDirectory = System.IO.Path.GetDirectoryName(opened); * bool result = sb.ShowDialog(this); * if(result)*/ var result = MessageBox.Show("Are you sure you want to overwrite \"" + _opened + "\" ?", "Overwrite File", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { AELogger.Log("Saving BCM " + System.IO.Path.GetFileName(_opened)); BCMFile.ToFilename(_opened, App.OpenedFiles.BCMFile); AELogger.Log("Saved BCM, Saving BAC " + System.IO.Path.GetFileName(_opened)); BACFile.ToFilename(_opened.Replace(".bcm", ".bac"), App.OpenedFiles.BACFile, App.OpenedFiles.BCMFile); AELogger.Log("Saved BAC " + System.IO.Path.GetFileName(_opened)); } }
private void ClickSaveAs(object sender, RoutedEventArgs e) { var sb = new SaveFileDialog(); sb.InitialDirectory = System.IO.Path.GetDirectoryName(_opened); sb.Filter = "SF4AE BCM Files|*.bcm"; sb.AddExtension = true; sb.OverwritePrompt = true; bool result = (bool)sb.ShowDialog(this); if (result) { _opened = sb.FileName; AELogger.Log("Saving BCM " + System.IO.Path.GetFileName(_opened)); BCMFile.ToFilename(sb.FileName, App.OpenedFiles.BCMFile); AELogger.Log("Saved BCM, Saving BAC " + System.IO.Path.GetFileName(_opened)); BACFile.ToFilename(sb.FileName.Replace(".bcm", ".bac"), App.OpenedFiles.BACFile, App.OpenedFiles.BCMFile); AELogger.Log("Saved BAC " + System.IO.Path.GetFileName(_opened)); } }
private void RecentOpen(String file) { if (String.IsNullOrEmpty(file)) { return; } UserSettings.CurrentSettings.LastOpenedFile = file; AELogger.Log("Opening BCM " + System.IO.Path.GetFileName(_opened)); App.OpenedFiles.BCMFile = BCMFile.FromFilename(file); string bacfile = file.Replace(".bcm", ".bac"); AELogger.Log("Opened BCM, Opening BAC " + System.IO.Path.GetFileName(_opened)); App.OpenedFiles.BACFile = BACFile.FromFilename(bacfile, App.OpenedFiles.BCMFile); _opened = file; RainbowLib.ResourceManager.LoadCharacterData(System.IO.Path.GetFileNameWithoutExtension(_opened)); App.OpenedFiles.FilesOpened = true; AELogger.Log("Opened BAC " + System.IO.Path.GetFileName(_opened)); this.Title = "Editing " + Opened + " -Ono!"; }
private void ClickOpen(object sender, RoutedEventArgs e) { var sb = new OpenFileDialog { Filter = "SF4AE BCM Files|*.bcm" }; var result = sb.ShowDialog(this); if ((bool)result.Value) { UserSettings.CurrentSettings.LastOpenedFile = sb.FileName; AELogger.Log("Opening BCM " + System.IO.Path.GetFileName(_opened)); App.OpenedFiles.BCMFile = BCMFile.FromFilename(sb.FileName); string bacfile = sb.FileName.Replace(".bcm", ".bac"); AELogger.Log("Opened BCM, Opening BAC " + System.IO.Path.GetFileName(_opened)); App.OpenedFiles.BACFile = BACFile.FromFilename(bacfile, App.OpenedFiles.BCMFile); _opened = sb.FileName; RainbowLib.ResourceManager.LoadCharacterData(System.IO.Path.GetFileNameWithoutExtension(_opened)); App.OpenedFiles.FilesOpened = true; // yay recentFileList.InsertFile(sb.FileName); AELogger.Log("Opened BAC " + System.IO.Path.GetFileName(_opened)); this.Title = "Editing " + Opened + " -Ono!"; } }
private static void RunScript(string dir, string script, string charname) { var str = Path.GetFileNameWithoutExtension(script); var ms = new MemoryStream(); var sw = new StringWriter(); sw.WriteLine("//RainbowScript output for " + str + " on " + charname); Console.WriteLine("running " + str + " on " + charname); //var oldout = Console.Out; IronPythonHelper.SetOut(ms, sw); var bcm = BCMFile.FromFilename(dir + "/" + charname + "/" + charname + ".bcm"); var bac = BACFile.FromFilename(dir + "/" + charname + "/" + charname + ".bac", bcm); IronPythonHelper.Export("bcm", bcm); IronPythonHelper.Export("bac", bac); IronPythonHelper.Export("charName", charname); IronPythonHelper.RunFile(script); Directory.CreateDirectory("output/" + str + "/"); File.WriteAllText("output/" + str + "/" + charname + ".html", sw.ToString()); File.AppendAllText("output/" + str + ".html", sw.ToString()); //Console.SetOut(oldout); //Console.ReadLine(); }
public void ReadBCMData() { int off = 0x8; if (PlayerIndex == 1) { off = 0xC; } //06A7DF0 var InputBufferOffset = (int)Util.Memory.ReadInt((int)Util.Memory.ReadInt(0x400000 + 0x6A7DEC) + off); int BCM = (int)Util.Memory.ReadInt(InputBufferOffset + 0x8); if (BCM != bcm_off && BCM != 0) { //Gotta load BCM var tmpfile = File.Create(System.IO.Path.GetTempPath() + "/tmp.bcm", 0x9000); var tmparr = Util.Memory.ReadAOB(BCM, 0x9000); tmpfile.Write(tmparr, 0, tmparr.Length); tmpfile.Close(); bcm = BCMFile.FromFilename(System.IO.Path.GetTempPath() + "/tmp.bcm"); bcm_off = BCM; } //Not in a match if (BCM == 0) { return; } var chargeStatus = (int)Util.Memory.ReadInt(InputBufferOffset + 0x1594); ActiveCancelLists.Clear(); var InputBufferStart = (int)Util.Memory.ReadInt(0x400000 + 0x6A7DF0) + 0x48; var InputBufferCurrent = (int)Util.Memory.ReadInt(InputBufferStart + 0x400 * 0xC + 4); var InputBufferCurrentAlt = (int)Util.Memory.ReadInt(InputBufferStart - 0x1C) % 0x400; InputBufferCurrent = InputBufferCurrentAlt; var i = 0; while (i < 0x10) { var test = (int)Util.Memory.ReadInt(InputBufferOffset + 0x147C + i++ *0x10); if (test != -1) { if (bcm.CancelLists.Count > test) { ActiveCancelLists.Add(bcm.CancelLists[test].Name); } else { ActiveCancelLists.Add(test.ToString()); } } } //InputBuffer.Clear(); if (InputBuffer.Count == 0x400) { InputBuffer.RemoveAt(0x400 - 1); } var inputsToRead = 0x400 - InputBuffer.Count(); var InputBufferIndex = (int)Util.Memory.ReadInt(InputBufferOffset + 0x1414); var tmp = Util.Memory.ReadInt(InputBufferStart + 0xC * InputBufferCurrent); InputBuffer.Insert(0, (FighterState.Input)tmp); }