diff --git a/BizHawk.MultiClient/MainForm.Designer.cs b/BizHawk.MultiClient/MainForm.Designer.cs index 091c318237..ab87135a2d 100644 --- a/BizHawk.MultiClient/MainForm.Designer.cs +++ b/BizHawk.MultiClient/MainForm.Designer.cs @@ -342,7 +342,6 @@ this.cmiScreenshotClipboard = new System.Windows.Forms.ToolStripMenuItem(); this.cmiCloseRom = new System.Windows.Forms.ToolStripMenuItem(); this.cmiShowMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.newCheatsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.StatusSlot0.SuspendLayout(); this.contextMenuStrip1.SuspendLayout(); @@ -1809,8 +1808,7 @@ this.luaConsoleToolStripMenuItem, this.cheatsToolStripMenuItem, this.toolStripSeparator29, - this.createDualGBXMLToolStripMenuItem, - this.newCheatsToolStripMenuItem}); + this.createDualGBXMLToolStripMenuItem}); this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; this.toolsToolStripMenuItem.Size = new System.Drawing.Size(48, 19); this.toolsToolStripMenuItem.Text = "&Tools"; @@ -2979,12 +2977,6 @@ this.cmiShowMenu.Text = "Show Menu"; this.cmiShowMenu.Click += new System.EventHandler(this.showMenuToolStripMenuItem_Click); // - // newCheatsToolStripMenuItem - // - this.newCheatsToolStripMenuItem.Name = "newCheatsToolStripMenuItem"; - this.newCheatsToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.newCheatsToolStripMenuItem.Text = "New Cheats"; - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 14F); @@ -3339,7 +3331,6 @@ private System.Windows.Forms.ToolStripMenuItem rewindToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem firmwaresToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem loadTIFileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem newCheatsToolStripMenuItem; } } diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index d6a6e61f10..571de6bb13 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -2243,10 +2243,10 @@ namespace BizHawk.MultiClient coreskipaudio = Global.ClientControls["MaxTurbo"] && CurrAviWriter == null; //======================================= - MemoryPulse.Pulse(); + Global.CheatList.Pulse(); Global.Emulator.FrameAdvance(!throttle.skipnextframe || CurrAviWriter != null, !coreskipaudio); Global.DisplayManager.NeedsToPaint = true; - MemoryPulse.Pulse(); + Global.CheatList.Pulse(); //======================================= if (!PauseAVI) @@ -2873,6 +2873,7 @@ namespace BizHawk.MultiClient if (!_cheats.IsHandleCreated || _cheats.IsDisposed) { + _cheats = new NewCheatForm(); _cheats.Show(); } else @@ -3196,7 +3197,7 @@ namespace BizHawk.MultiClient SyncCoreCommInputSignals(); Global.Emulator = new NullEmulator(Global.CoreComm); Global.Game = GameInfo.GetNullGame(); - MemoryPulse.Clear(); + RewireSound(); ResetRewindBuffer(); RamSearch1.Restart(); diff --git a/BizHawk.MultiClient/NEStools/NESGameGenie.cs b/BizHawk.MultiClient/NEStools/NESGameGenie.cs index d9953c12b3..2776e2b83b 100644 --- a/BizHawk.MultiClient/NEStools/NESGameGenie.cs +++ b/BizHawk.MultiClient/NEStools/NESGameGenie.cs @@ -9,9 +9,9 @@ namespace BizHawk.MultiClient { public partial class NESGameGenie : Form { - public int? _address = null; - public int? _value = null; - public int? _compare = null; + private int? _address = null; + private int? _value = null; + private int? _compare = null; private readonly Dictionary GameGenieTable = new Dictionary(); public int? Address { get { return _address; } } @@ -363,7 +363,7 @@ namespace BizHawk.MultiClient AddressBox.ToRawInt(), Watch.WatchSize.Byte, Watch.DisplayType.Hex, - String.Empty, + GameGenieCode.Text, false); int? compare = null; @@ -372,7 +372,13 @@ namespace BizHawk.MultiClient compare = CompareBox.ToRawInt(); } - Global.CheatList.Add(new Cheat(watch, compare, enabled: true)); + Global.CheatList.Add(new Cheat( + watch, + ValueBox.ToRawInt(), + compare, + enabled: true)); + + Global.MainForm.Cheats_UpdateValues(); } } diff --git a/BizHawk.MultiClient/tools/Cheats/CheatList.cs b/BizHawk.MultiClient/tools/Cheats/CheatList.cs index 198eca43b3..d925eb53b0 100644 --- a/BizHawk.MultiClient/tools/Cheats/CheatList.cs +++ b/BizHawk.MultiClient/tools/Cheats/CheatList.cs @@ -31,6 +31,14 @@ namespace BizHawk.MultiClient get { return _cheatList[index]; } } + public void Pulse() + { + foreach(var cheat in _cheatList) + { + cheat.Pulse(); + } + } + /// /// Looks for a .cht file that matches the ROM loaded based on the default filename for a given ROM /// @@ -156,37 +164,6 @@ namespace BizHawk.MultiClient return false; } - public void Freeze(MemoryDomain domain, int address, Watch.WatchSize size, int value, bool? bigendian = null) - { - var exists = _cheatList.Any(x => x.Domain == domain && x.Address == address && x.Size == size); - if (!exists) - { - bool endian = false; - if (bigendian.HasValue) - { - endian = bigendian.Value; - } - else - { - switch (domain.Endian) - { - default: - case Endian.Unknown: - case Endian.Little: - bigendian = false; - break; - case Endian.Big: - bigendian = true; - break; - } - } - - Watch w = Watch.GenerateWatch(domain, address, size, Watch.DisplayType.Unsigned, String.Empty, endian); - _cheatList.Add(new Cheat(w, compare: null, enabled: true)); - Global.MainForm.UpdateCheatStatus(); - } - } - public void SaveOnClose() { if (Global.Config.CheatsAutoSaveOnClose) @@ -311,7 +288,7 @@ namespace BizHawk.MultiClient BIGENDIAN ); - Cheat c = new Cheat(w, COMPARE, Global.Config.DisableCheatsOnLoad ? false : ENABLED); + Cheat c = new Cheat(w, VALUE, COMPARE, Global.Config.DisableCheatsOnLoad ? false : ENABLED); _cheatList.Add(c); } } diff --git a/BizHawk.MultiClient/tools/Cheats/NewCheat.cs b/BizHawk.MultiClient/tools/Cheats/NewCheat.cs index d1bde29340..46d6c4b097 100644 --- a/BizHawk.MultiClient/tools/Cheats/NewCheat.cs +++ b/BizHawk.MultiClient/tools/Cheats/NewCheat.cs @@ -9,15 +9,14 @@ namespace BizHawk.MultiClient { #region Constructors - public Cheat(Watch watch, int? compare = null, bool enabled = true) + public Cheat(Watch watch, int value, int? compare = null, bool enabled = true) { _enabled = enabled; _watch = watch; _compare = compare; - if (!_watch.IsSeparator) - { - _val = _watch.Value.Value; - } + _val = value; + + Pulse(); } public Cheat(Cheat cheat) @@ -39,12 +38,15 @@ namespace BizHawk.MultiClient cheat.BigEndian.Value ); _compare = cheat.Compare; + _val = cheat.Value.Value; + + Pulse(); } } public static Cheat Separator { - get { return new Cheat(SeparatorWatch.Instance, null, false); } + get { return new Cheat(SeparatorWatch.Instance, 0, null, false); } } #endregion @@ -83,10 +85,7 @@ namespace BizHawk.MultiClient public MemoryDomain Domain { - get - { - return _watch.Domain; - } + get { return _watch.Domain; } } public Watch.WatchSize Size diff --git a/BizHawk.MultiClient/tools/Cheats/NewCheatForm.cs b/BizHawk.MultiClient/tools/Cheats/NewCheatForm.cs index 9a358ed7a0..6fb523c33e 100644 --- a/BizHawk.MultiClient/tools/Cheats/NewCheatForm.cs +++ b/BizHawk.MultiClient/tools/Cheats/NewCheatForm.cs @@ -186,6 +186,7 @@ namespace BizHawk.MultiClient ToggleGameGenieButton(); CheatEditor.SetAddEvent(AddCheat); CheatEditor.SetEditEvent(EditCheat); + UpdateValues(); } protected override void OnClosing(CancelEventArgs e) diff --git a/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs b/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs index 42061cb162..64066e6b79 100644 --- a/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs +++ b/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs @@ -903,7 +903,11 @@ namespace BizHawk.MultiClient String.Empty, BigEndian); - Global.CheatList.Add(new Cheat(watch, compare: null, enabled: true)); + Global.CheatList.Add(new Cheat( + watch, + watch.Value.Value, + compare: null, + enabled: true)); MemoryViewerBox.Refresh(); UpdateRelatedDialogs(); diff --git a/BizHawk.MultiClient/tools/Lua/LuaImplementation.cs b/BizHawk.MultiClient/tools/Lua/LuaImplementation.cs index e86c8c7292..1dc192cfb4 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaImplementation.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaImplementation.cs @@ -3018,7 +3018,11 @@ namespace BizHawk.MultiClient code, false); - Global.CheatList.Add(new Cheat(watch, gg._compare, enabled: true)); + Global.CheatList.Add(new Cheat( + watch, + gg.Value.Value, + gg.Compare, + enabled: true)); } } } @@ -3031,7 +3035,7 @@ namespace BizHawk.MultiClient gg.DecodeGameGenieCode(code); if (gg.Address.HasValue && gg.Value.HasValue) { - var cheats = Global.CheatList.Where(x => x.Address == gg._address); + var cheats = Global.CheatList.Where(x => x.Address == gg.Address); Global.CheatList.RemoveRange(cheats); } } diff --git a/BizHawk.MultiClient/tools/ToolHelpers.cs b/BizHawk.MultiClient/tools/ToolHelpers.cs index 7c9c7f8300..a6ed51b7ad 100644 --- a/BizHawk.MultiClient/tools/ToolHelpers.cs +++ b/BizHawk.MultiClient/tools/ToolHelpers.cs @@ -70,7 +70,10 @@ namespace BizHawk.MultiClient { foreach(var watch in watches) { - Cheat cheat = new Cheat(watch, compare: null, enabled: true); + if (!watch.IsSeparator) + { + Cheat cheat = new Cheat(watch, watch.Value.Value, compare: null, enabled: true); + } } Global.MainForm.UpdateCheatStatus();