Client-side cheats system added, works on all cores with working PokeByte()

This commit is contained in:
beirich 2011-08-03 03:00:19 +00:00
parent 6f379cee76
commit a1c562259d
5 changed files with 62 additions and 11 deletions

View File

@ -319,6 +319,7 @@
<Compile Include="tools\Cheats.Designer.cs">
<DependentUpon>Cheats.cs</DependentUpon>
</Compile>
<Compile Include="tools\MemoryPulse.cs" />
<Compile Include="tools\VirtualPad.cs">
<SubType>Component</SubType>
</Compile>

View File

@ -12,6 +12,7 @@ using BizHawk.Emulation.Consoles.TurboGrafx;
using BizHawk.Emulation.Consoles.Calculator;
using BizHawk.Emulation.Consoles.Gameboy;
using BizHawk.Emulation.Consoles.Nintendo;
using BizHawk.MultiClient.tools;
namespace BizHawk.MultiClient
{
@ -1486,7 +1487,9 @@ namespace BizHawk.MultiClient
//}
//=======================================
MemoryPulse.Pulse();
Global.Emulator.FrameAdvance(!throttle.skipnextframe);
MemoryPulse.Pulse();
//=======================================
if (CurrAviWriter != null)
@ -1938,9 +1941,10 @@ namespace BizHawk.MultiClient
private void CloseROM()
{
CloseGame();
CloseGame();
Global.Emulator = new NullEmulator();
Global.Game = new NullGame();
MemoryPulse.Clear();
RamSearch1.Restart();
RamWatch1.Restart();
HexEditor1.Restart();

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizHawk.MultiClient.tools;
namespace BizHawk.MultiClient
{
@ -44,13 +41,13 @@ namespace BizHawk.MultiClient
public void Enable()
{
enabled = true;
//domain.SetFreeze(address, new MemoryDomain.FreezeData(MemoryDomain.FreezeData.Flag.Frozen, value));
MemoryPulse.Add(domain, address, value);
}
public void Disable()
{
enabled = false;
//domain.ClearFreeze(address);
MemoryPulse.Remove(domain, address);
}
public bool IsEnabled()

View File

@ -157,10 +157,6 @@ namespace BizHawk.MultiClient
default:
break;
case "GB":
case "SMS":
case "SG":
case "GG":
case "PCE":
AddCheatGroup.Enabled = false;
CheatListView.Enabled = false;
MessageLabel.Text = Global.Emulator.SystemId + " not supported.";

View File

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
namespace BizHawk.MultiClient.tools
{
public static class MemoryPulse
{
public class MemoryPulseEntry
{
public int address;
public byte value;
public MemoryDomain domain;
}
private static List<MemoryPulseEntry> entries = new List<MemoryPulseEntry>();
public static void Pulse()
{
foreach (var entry in entries)
{
entry.domain.PokeByte(entry.address, entry.value);
}
}
public static void Add(MemoryDomain domain, int address, byte value)
{
entries.RemoveAll(o => o.domain == domain && o.address == address);
var entry = new MemoryPulseEntry {address = address, value = value, domain = domain};
entries.Add(entry);
}
public static MemoryPulseEntry Query(MemoryDomain domain, int address)
{
return entries.Find(o => o.domain == domain && o.address == address);
}
public static void Remove(MemoryDomain domain, int address)
{
entries.RemoveAll(o => o.domain == domain && o.address == address);
}
public static IList<MemoryPulseEntry> GetEntries()
{
return entries.AsReadOnly();
}
public static void Clear()
{
entries.Clear();
}
}
}