2011-08-07 01:16:55 +00:00
|
|
|
|
using BizHawk.MultiClient;
|
2012-09-01 14:13:36 +00:00
|
|
|
|
using BizHawk.Emulation.Consoles.Nintendo;
|
2011-03-16 03:56:22 +00:00
|
|
|
|
|
|
|
|
|
namespace BizHawk.MultiClient
|
|
|
|
|
{
|
2011-06-19 23:39:25 +00:00
|
|
|
|
public class Cheat
|
|
|
|
|
{
|
|
|
|
|
public string name { get; set; }
|
|
|
|
|
public int address { get; set; }
|
|
|
|
|
public byte value { get; set; }
|
2012-08-31 11:59:14 +00:00
|
|
|
|
public byte? compare { get; set; }
|
2011-06-19 23:39:25 +00:00
|
|
|
|
public MemoryDomain domain { get; set; }
|
|
|
|
|
private bool enabled;
|
|
|
|
|
|
|
|
|
|
public Cheat()
|
|
|
|
|
{
|
|
|
|
|
name = "";
|
|
|
|
|
address = 0;
|
|
|
|
|
value = 0;
|
2012-08-31 11:59:14 +00:00
|
|
|
|
compare = null;
|
2011-06-19 23:39:25 +00:00
|
|
|
|
enabled = false;
|
|
|
|
|
domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Cheat(Cheat c)
|
|
|
|
|
{
|
|
|
|
|
name = c.name;
|
|
|
|
|
address = c.address;
|
|
|
|
|
value = c.value;
|
|
|
|
|
enabled = c.enabled;
|
|
|
|
|
domain = c.domain;
|
2012-08-31 11:59:14 +00:00
|
|
|
|
compare = c.compare;
|
2011-08-06 19:49:21 +00:00
|
|
|
|
if (enabled)
|
|
|
|
|
MemoryPulse.Add(domain, address, value);
|
|
|
|
|
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 11:59:14 +00:00
|
|
|
|
public Cheat(string cname, int addr, byte val, bool e, MemoryDomain d, byte? comp = null)
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
|
|
|
|
name = cname;
|
|
|
|
|
address = addr;
|
|
|
|
|
value = val;
|
|
|
|
|
enabled = e;
|
|
|
|
|
domain = d;
|
2012-08-31 11:59:14 +00:00
|
|
|
|
compare = comp;
|
2011-08-06 19:49:21 +00:00
|
|
|
|
if (enabled)
|
2012-08-31 11:59:14 +00:00
|
|
|
|
{
|
|
|
|
|
MemoryPulse.Add(domain, address, value, compare);
|
|
|
|
|
}
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Enable()
|
|
|
|
|
{
|
|
|
|
|
enabled = true;
|
2012-09-01 14:13:36 +00:00
|
|
|
|
if (Global.Emulator is NES)
|
|
|
|
|
{
|
|
|
|
|
(Global.Emulator as NES).ApplyGameGenie(address, value, compare);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MemoryPulse.Add(domain, address, value, compare);
|
|
|
|
|
}
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Disable()
|
|
|
|
|
{
|
|
|
|
|
enabled = false;
|
2012-09-01 14:35:12 +00:00
|
|
|
|
DisposeOfCheat();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DisposeOfCheat()
|
|
|
|
|
{
|
|
|
|
|
if (Global.Emulator is NES)
|
|
|
|
|
{
|
|
|
|
|
(Global.Emulator as NES).RemoveGameGenie(address);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MemoryPulse.Remove(domain, address);
|
|
|
|
|
}
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsEnabled()
|
|
|
|
|
{
|
|
|
|
|
return enabled;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-07 01:16:55 +00:00
|
|
|
|
~Cheat()
|
|
|
|
|
{
|
2012-09-01 14:35:12 +00:00
|
|
|
|
DisposeOfCheat();
|
2011-08-07 01:16:55 +00:00
|
|
|
|
}
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
2011-03-16 03:56:22 +00:00
|
|
|
|
}
|