IMemoryCallbackSystem - add a flag to indicate whether execute callbacks are available, in lua and the debugger, take this flag into account, also improve some availability checking in Lua memory callbacks. Flag N64 as not having execute callbacks available

This commit is contained in:
adelikat 2015-01-25 22:14:58 +00:00
parent 0d54298f02
commit 8246de14aa
9 changed files with 72 additions and 8 deletions

View File

@ -17,6 +17,9 @@ namespace BizHawk.Client.Common
[OptionalService]
public IDebuggable DebuggableCore { get; set; }
[RequiredService]
public IEmulator Emulator { get; set; }
private readonly LuaFunctionList _luaFunctions = new LuaFunctionList();
public EventLuaLibrary(Lua lua)
@ -132,7 +135,12 @@ namespace BizHawk.Client.Common
private void LogMemoryCallbacksNotImplemented()
{
Log(string.Format("{0} does not implement memory callbacks"));
Log(string.Format("{0} does not implement memory callbacks", Emulator.Attributes().CoreName));
}
private void LogMemoryExecuteCallbacksNotImplemented()
{
Log(string.Format("{0} does not implement memory execute callbacks", Emulator.Attributes().CoreName));
}
#endregion
@ -212,7 +220,8 @@ namespace BizHawk.Client.Common
{
try
{
if (DebuggableCore != null)
if (DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable() &&
DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable)
{
var nlf = new NamedLuaFunction(luaf, "OnMemoryExecute", LogOutputCallback, CurrentThread, name);
_luaFunctions.Add(nlf);
@ -224,11 +233,11 @@ namespace BizHawk.Client.Common
}
catch(NotImplementedException)
{
LogMemoryCallbacksNotImplemented();
LogMemoryExecuteCallbacksNotImplemented();
return Guid.Empty.ToString();
}
LogMemoryCallbacksNotImplemented();
LogMemoryExecuteCallbacksNotImplemented();
return Guid.Empty.ToString();
}
@ -240,7 +249,7 @@ namespace BizHawk.Client.Common
{
try
{
if (DebuggableCore != null)
if (DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable())
{
var nlf = new NamedLuaFunction(luaf, "OnMemoryRead", LogOutputCallback, CurrentThread, name);
_luaFunctions.Add(nlf);
@ -268,7 +277,7 @@ namespace BizHawk.Client.Common
{
try
{
if (DebuggableCore != null)
if (DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable())
{
var nlf = new NamedLuaFunction(luaf, "OnMemoryWrite", LogOutputCallback, CurrentThread, name);
_luaFunctions.Add(nlf);

View File

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AddButton = new System.Windows.Forms.Button();
this.BreakpointTypeGroupbox = new System.Windows.Forms.GroupBox();
this.ExecuteRadio = new System.Windows.Forms.RadioButton();
@ -35,6 +36,7 @@
this.ReadRadio = new System.Windows.Forms.RadioButton();
this.AddressBox = new BizHawk.Client.EmuHawk.HexTextBox();
this.label1 = new System.Windows.Forms.Label();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.BreakpointTypeGroupbox.SuspendLayout();
this.SuspendLayout();
//
@ -144,5 +146,6 @@
private System.Windows.Forms.RadioButton ReadRadio;
private HexTextBox AddressBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolTip toolTip1;
}
}

View File

@ -18,6 +18,17 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent();
}
public void DisableExecuteOption()
{
if (ExecuteRadio.Checked)
{
ReadRadio.Checked = true;
}
ExecuteRadio.Enabled = false;
}
public MemoryCallbackType BreakType
{
get

View File

@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -150,6 +150,11 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
MaxAddressSize = Global.Emulator.AsMemoryDomains().SystemBus.Size - 1
};
if (!MCS.ExecuteCallbacksAvailable)
{
b.DisableExecuteOption();
}
if (b.ShowHawkDialog() == DialogResult.OK)
{
Breakpoints.Add(Core, b.Address, b.BreakType);

View File

@ -8,6 +8,11 @@ namespace BizHawk.Emulation.Common
{
public class MemoryCallbackSystem : IMemoryCallbackSystem
{
public MemoryCallbackSystem()
{
ExecuteCallbacksAvailable = true;
}
private readonly List<IMemoryCallback> Reads = new List<IMemoryCallback>();
private readonly List<IMemoryCallback> Writes = new List<IMemoryCallback>();
private readonly List<IMemoryCallback> Execs = new List<IMemoryCallback>();
@ -18,6 +23,8 @@ namespace BizHawk.Emulation.Common
private bool _hasWrites = false;
private bool _hasExecutes = false;
public bool ExecuteCallbacksAvailable { get; set; }
public void Add(IMemoryCallback callback)
{
switch (callback.Type)

View File

@ -136,7 +136,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
{
try
{
var tracer = debuggable.MemoryCallbacks;
var callbacks = debuggable.MemoryCallbacks;
return true;
}
catch (NotImplementedException)
@ -148,6 +148,24 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
return false;
}
public static bool MemoryCallbacksAvailable(this IDebuggable core)
{
if (core == null)
{
return false;
}
try
{
var callbacks = core.MemoryCallbacks;
return true;
}
catch (NotImplementedException)
{
return false;
}
}
public static bool CanDisassemble(this IEmulator core)
{
if (core == null)

View File

@ -11,6 +11,11 @@ namespace BizHawk.Emulation.Common
* These functions must return very quickly if the list is empty. Very very quickly.
*/
/// <summary>
/// Specifies whether or not Execute callbacks are available for this this implementation
/// </summary>
bool ExecuteCallbacksAvailable { get; }
/// <summary>
/// Returns whether or not there are currently any read hooks
/// </summary>

View File

@ -54,7 +54,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
{
ServiceProvider = new BasicServiceProvider(this);
InputCallbacks = new InputCallbackSystem();
MemoryCallbacks = new MemoryCallbackSystem();
MemoryCallbacks = new MemoryCallbackSystem
{
ExecuteCallbacksAvailable = false
};
int SaveType = 0;
if (game.OptionValue("SaveType") == "EEPROM_16K")