New Cheat system - various fixes to actually make it work

This commit is contained in:
adelikat 2013-10-06 18:44:51 +00:00
parent a76dcd62b7
commit 719b705f6d
9 changed files with 50 additions and 64 deletions

View File

@ -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;
}
}

View File

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

View File

@ -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<char, int> GameGenieTable = new Dictionary<char, int>();
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();
}
}

View File

@ -31,6 +31,14 @@ namespace BizHawk.MultiClient
get { return _cheatList[index]; }
}
public void Pulse()
{
foreach(var cheat in _cheatList)
{
cheat.Pulse();
}
}
/// <summary>
/// Looks for a .cht file that matches the ROM loaded based on the default filename for a given ROM
/// </summary>
@ -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);
}
}

View File

@ -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

View File

@ -186,6 +186,7 @@ namespace BizHawk.MultiClient
ToggleGameGenieButton();
CheatEditor.SetAddEvent(AddCheat);
CheatEditor.SetEditEvent(EditCheat);
UpdateValues();
}
protected override void OnClosing(CancelEventArgs e)

View File

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

View File

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

View File

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