using System; using System.Collections.Generic; namespace BizHawk.Emulation.Common { public interface IMemoryCallbackSystem : IEnumerable { /* * DANGER: * Many cores will blindly call CallReads(), CallWrites(), CallExecutes() on every rwx no matter what. * These functions must return very quickly if the list is empty. Very very quickly. */ /// /// Returns whether or not there are currently any read hooks /// bool HasReads { get; } /// /// Returns whether or not there are currently any write hooks /// bool HasWrites { get; } /// /// Returns whether or not there are currently any execute hooks /// bool HasExecutes { get; } /// /// Adds a callback for the given type to the given address /// If no address is specified the callback will be hooked to all addresses /// Note: an execute callback can not be added without an address, else an InvalidOperationException will occur /// void Add(IMemoryCallback callback); /// /// Executes all Read callbacks for the given addr /// void CallReads(uint addr); /// /// Executes all Write callbacks for the given addr /// void CallWrites(uint addr); /// /// Executes all Execute callbacks for the given addr /// void CallExecutes(uint addr); /// /// Removes the given callback from the list /// void Remove(Action action); /// /// Removes the given callbacks from the list /// void RemoveAll(IEnumerable actions); /// /// Removes all read,write, and execute callbacks /// void Clear(); } public interface IMemoryCallback { MemoryCallbackType Type { get; } string Name { get; } Action Callback { get; } uint? Address { get; } } public enum MemoryCallbackType { Read, Write, Execute } }