add a CanPoke() extension method for memory domains, checks for a null or not implemented Poke Poke delegate, use it to disable Poke on Ram Search and Ram Watch, still todo - hex editor and lua

This commit is contained in:
adelikat 2015-01-25 14:37:37 +00:00
parent d200c1be38
commit 7ed8704555
5 changed files with 44 additions and 5 deletions

View File

@ -1173,10 +1173,13 @@ namespace BizHawk.Client.EmuHawk
RemoveMenuItem.Enabled =
AddToRamWatchMenuItem.Enabled =
PokeAddressMenuItem.Enabled =
FreezeAddressMenuItem.Enabled =
SelectedIndices.Any();
PokeAddressMenuItem.Enabled =
SelectedIndices.Any() &&
SelectedWatches.All(w => w.Domain.CanPoke());
UndoMenuItem.Enabled =
ClearUndoMenuItem.Enabled =
_searches.CanUndo;
@ -1379,13 +1382,15 @@ namespace BizHawk.Client.EmuHawk
RemoveContextMenuItem.Visible =
AddToRamWatchContextMenuItem.Visible =
PokeContextMenuItem.Visible =
FreezeContextMenuItem.Visible =
ContextMenuSeparator2.Visible =
ViewInHexEditorContextMenuItem.Visible =
SelectedIndices.Any();
PokeContextMenuItem.Enabled =
SelectedIndices.Any() &&
SelectedWatches.All(w => w.Domain.CanPoke());
UnfreezeAllContextMenuItem.Visible = Global.CheatList.ActiveCount > 0;
ContextMenuSeparator3.Visible = SelectedIndices.Any() || (Global.CheatList.ActiveCount > 0);

View File

@ -687,10 +687,13 @@ namespace BizHawk.Client.EmuHawk
RemoveWatchMenuItem.Enabled =
MoveUpMenuItem.Enabled =
MoveDownMenuItem.Enabled =
PokeAddressMenuItem.Enabled =
FreezeAddressMenuItem.Enabled =
SelectedIndices.Any();
PokeAddressMenuItem.Enabled =
SelectedIndices.Any() &&
SelectedWatches.All(w => w.Domain.CanPoke());
PauseMenuItem.Text = _paused ? "Unpause" : "Pause";
}
@ -1008,6 +1011,10 @@ namespace BizHawk.Client.EmuHawk
Separator6.Visible =
indexes.Count > 0;
PokeContextMenuItem.Enabled =
SelectedIndices.Any() &&
SelectedWatches.All(w => w.Domain.CanPoke());
var allCheats = _watches.All(x => Global.CheatList.IsActive(x.Domain, x.Address ?? 0));
if (allCheats)

View File

@ -52,7 +52,13 @@ namespace BizHawk.Emulation.Common
delegate(long addr, byte val)
{
if (writable)
{
data[addr] = val;
}
else
{
throw new NotImplementedException();
}
}
);
}

View File

@ -163,6 +163,27 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
return (IDisassemblable)core.ServiceProvider.GetService<IDisassemblable>();
}
public static bool CanPoke(this MemoryDomain d)
{
if (d.PokeByte == null)
{
return false;
}
try
{
d.PokeByte(0, d.PeekByte(0));
}
catch (NotImplementedException)
{
return false;
}
return true;
}
// TODO: a better place for these
public static bool IsImplemented(this MethodInfo info)
{

View File

@ -228,7 +228,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public MemoryDomain GetDiskPeeker()
{
return new MemoryDomain("FDS SIDE", diskdrive.NumBytes, MemoryDomain.Endian.Little, diskdrive.PeekData, null); // silent poke fail TODO: don't pass null! Throw a not implemented exception, handle this exception in ram tools
return new MemoryDomain("FDS SIDE", diskdrive.NumBytes, MemoryDomain.Endian.Little, diskdrive.PeekData, null);
}
void SetIRQ()