using System; using System.Collections.Generic; namespace BizHawk.Emulation.Common { /// /// This is a property of , and defines the means by which a client /// gets and sets memory callbacks in the core. A memory callback should fire any time memory is /// read/written/executed by the core, and depends on the type specified by the callback /// /// 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. */ /// /// Gets a value indicating whether or not Execute callbacks are available for this this implementation /// bool ExecuteCallbacksAvailable { get; } /// /// Gets a value indicating whether or not there are currently any read hooks /// bool HasReads { get; } /// /// Gets a value indicating whether or not there are currently any write hooks /// bool HasWrites { get; } /// /// Gets a value indicating whether or not there are currently any execute hooks /// bool HasExecutes { get; } /// /// Gets a value indicating whether or not there are currently any read hooks /// bool HasReadsForScope(string scope); /// /// Gets a value indicating whether or not there are currently any write hooks /// bool HasWritesForScope(string scope); /// /// Gets a value indicating whether or not there are currently any execute hooks /// bool HasExecutesForScope(string scope); /// /// 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 /// /// Thrown when the property of the is not in the void Add(IMemoryCallback callback); /// /// Executes all Read callbacks for the given address and domain /// /// The address to check for callbacks /// The scope that the address pertains to. Must be a value in void CallReads(uint addr, string scope); /// /// Executes all Write callbacks for the given address and domain /// /// The address to check for callbacks /// The scope that the address pertains to. Must be a value in void CallWrites(uint addr, string scope); /// /// Executes all Execute callbacks for the given address and domain /// /// The address to check for callbacks /// The scope that the address pertains to. Must be a value in void CallExecutes(uint addr, string scope); /// /// 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(); /// /// A list of available "scopes" (memory domains, cpus, etc) that a the property of the can have /// Passing a into the method that is not in this list will result in an /// string[] AvailableScopes { get; } } /// /// This service defines a memory callback used by an IMemoryCallbackSystem implementation /// /// public interface IMemoryCallback { MemoryCallbackType Type { get; } string Name { get; } Action Callback { get; } uint? Address { get; } uint? AddressMask { get; } string Scope { get; } } public enum MemoryCallbackType { Read, Write, Execute } }