From 377ab3b4ea884bcc23d56c1bc1d6f584b3870b29 Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 1 Jan 2014 03:19:08 +0000 Subject: [PATCH] Fix Hex Editor to show cheat value on frozen addresses, and some fix ups in misc bugs that also contributed to this problem. Note: hex editor still will show some dubious behavior when viewing in one byte size and having cheats in another, that kind of mess will have to be sorted out in another commit --- BizHawk.Client.Common/tools/Cheat.cs | 2 +- BizHawk.Client.Common/tools/CheatList.cs | 13 ++++++++----- BizHawk.Client.EmuHawk/MainForm.cs | 2 +- .../tools/HexEditor/HexEditor.cs | 14 +++++++++++++- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/BizHawk.Client.Common/tools/Cheat.cs b/BizHawk.Client.Common/tools/Cheat.cs index f982fc187d..b3c57f219b 100644 --- a/BizHawk.Client.Common/tools/Cheat.cs +++ b/BizHawk.Client.Common/tools/Cheat.cs @@ -87,7 +87,7 @@ namespace BizHawk.Client.Common public int? Value { - get { return _watch.Value; } + get { return IsSeparator ? (int?)null : _val; } } public bool? BigEndian diff --git a/BizHawk.Client.Common/tools/CheatList.cs b/BizHawk.Client.Common/tools/CheatList.cs index 083380af75..2eaf79746e 100644 --- a/BizHawk.Client.Common/tools/CheatList.cs +++ b/BizHawk.Client.Common/tools/CheatList.cs @@ -48,6 +48,14 @@ namespace BizHawk.Client.Common get { return _cheatList[index]; } } + public Cheat this[MemoryDomain domain, int address] + { + get + { + return _cheatList.FirstOrDefault(cheat => cheat.Domain == domain && cheat.Address == address); + } + } + public void Pulse() { _cheatList.ForEach(cheat => cheat.Pulse()); @@ -94,11 +102,6 @@ namespace BizHawk.Client.Common Changes = false; } - public void Update() - { - _cheatList.ForEach(x => x.Pulse()); - } - public void Add(Cheat cheat) { if (cheat.IsSeparator) diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index b9b8f391c7..c327fb53bd 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -2538,6 +2538,7 @@ namespace BizHawk.Client.EmuHawk // client input-related duties GlobalWin.OSD.ClearGUIText(); + Global.CheatList.Pulse(); if (!isTurboing) { GlobalWin.Tools.UpdateToolsBefore(); @@ -2588,7 +2589,6 @@ namespace BizHawk.Client.EmuHawk coreskipaudio = Global.ClientControls["Turbo"] && _currAviWriter == null; - Global.CheatList.Pulse(); Global.Emulator.FrameAdvance(!_throttle.skipnextframe || _currAviWriter != null, !coreskipaudio); GlobalWin.DisplayManager.NeedsToPaint = true; Global.CheatList.Pulse(); diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index a2fb967458..82f2908298 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -527,7 +527,7 @@ namespace BizHawk.Client.EmuHawk { if (_addr + k < _domain.Size) { - rowStr.Append(Remap(_domain.PeekByte(_addr + k))); + rowStr.Append(Remap(MakeByte(_addr + k))); } } @@ -537,8 +537,20 @@ namespace BizHawk.Client.EmuHawk return rowStr.ToString(); } + private byte MakeByte(int address) + { + return Global.CheatList.IsActive(_domain, address) + ? (byte) Global.CheatList[_domain, address].Value.Value + : _domain.PeekByte(address); + } + private int MakeValue(int address) { + if (Global.CheatList.IsActive(_domain, address)) + { + return Global.CheatList[_domain, address].Value.Value; + } + switch (_dataSize) { default: