Memory callback system - simplify and remove now unused methods
This commit is contained in:
parent
558171d949
commit
40ac534f51
|
@ -186,14 +186,9 @@ namespace BizHawk.Emulation.Common
|
||||||
public int PlayerNumber(string buttonName)
|
public int PlayerNumber(string buttonName)
|
||||||
{
|
{
|
||||||
var match = PlayerRegex.Match(buttonName);
|
var match = PlayerRegex.Match(buttonName);
|
||||||
if (match.Success)
|
return match.Success
|
||||||
{
|
? int.Parse(match.Groups[1].Value)
|
||||||
return int.Parse(match.Groups[1].Value);
|
: 0;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Regex PlayerRegex = new Regex("^P(\\d+) ");
|
private static readonly Regex PlayerRegex = new Regex("^P(\\d+) ");
|
||||||
|
|
|
@ -33,9 +33,6 @@ namespace BizHawk.Emulation.Common
|
||||||
private readonly ObservableCollection<IMemoryCallback> _writes = new ObservableCollection<IMemoryCallback>();
|
private readonly ObservableCollection<IMemoryCallback> _writes = new ObservableCollection<IMemoryCallback>();
|
||||||
private readonly ObservableCollection<IMemoryCallback> _execs = new ObservableCollection<IMemoryCallback>();
|
private readonly ObservableCollection<IMemoryCallback> _execs = new ObservableCollection<IMemoryCallback>();
|
||||||
|
|
||||||
private bool _hasReads;
|
|
||||||
private bool _hasWrites;
|
|
||||||
private bool _hasExecutes;
|
|
||||||
private bool _hasAny;
|
private bool _hasAny;
|
||||||
|
|
||||||
public bool ExecuteCallbacksAvailable { get; }
|
public bool ExecuteCallbacksAvailable { get; }
|
||||||
|
@ -81,56 +78,41 @@ namespace BizHawk.Emulation.Common
|
||||||
|
|
||||||
public void CallMemoryCallbacks(uint addr, uint value, uint flags, string scope)
|
public void CallMemoryCallbacks(uint addr, uint value, uint flags, string scope)
|
||||||
{
|
{
|
||||||
if (!_hasAny) return;
|
if (!_hasAny)
|
||||||
|
|
||||||
if (_hasReads)
|
|
||||||
{
|
{
|
||||||
if((flags & (uint)MemoryCallbackFlags.AccessRead)!=0)
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HasReads)
|
||||||
|
{
|
||||||
|
if ((flags & (uint) MemoryCallbackFlags.AccessRead) != 0)
|
||||||
|
{
|
||||||
Call(_reads, addr, value, flags, scope);
|
Call(_reads, addr, value, flags, scope);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_hasWrites)
|
if (HasWrites)
|
||||||
{
|
{
|
||||||
if((flags & (uint)MemoryCallbackFlags.AccessWrite)!=0)
|
if ((flags & (uint) MemoryCallbackFlags.AccessWrite) != 0)
|
||||||
|
{
|
||||||
Call(_writes, addr, value, flags, scope);
|
Call(_writes, addr, value, flags, scope);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_hasExecutes)
|
if (HasExecutes)
|
||||||
{
|
{
|
||||||
if((flags & (uint)MemoryCallbackFlags.AccessExecute)!=0)
|
if ((flags & (uint) MemoryCallbackFlags.AccessExecute) != 0)
|
||||||
|
{
|
||||||
Call(_execs, addr, value, flags, scope);
|
Call(_execs, addr, value, flags, scope);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CallReads(uint addr, uint value, uint flags, string scope)
|
public bool HasReads { get; private set; }
|
||||||
{
|
|
||||||
if (_hasReads)
|
|
||||||
{
|
|
||||||
Call(_reads, addr, value, flags, scope);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CallWrites(uint addr, uint value, uint flags, string scope)
|
public bool HasWrites { get; private set; }
|
||||||
{
|
|
||||||
if (_hasWrites)
|
|
||||||
{
|
|
||||||
Call(_writes, addr, value, flags, scope);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CallExecutes(uint addr, uint value, uint flags, string scope)
|
public bool HasExecutes { get; private set; }
|
||||||
{
|
|
||||||
if (_hasExecutes)
|
|
||||||
{
|
|
||||||
Call(_execs, addr, value, flags, scope);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HasReads => _hasReads;
|
|
||||||
|
|
||||||
public bool HasWrites => _hasWrites;
|
|
||||||
|
|
||||||
public bool HasExecutes => _hasExecutes;
|
|
||||||
|
|
||||||
public bool HasReadsForScope(string scope)
|
public bool HasReadsForScope(string scope)
|
||||||
{
|
{
|
||||||
|
@ -149,16 +131,16 @@ namespace BizHawk.Emulation.Common
|
||||||
|
|
||||||
private bool UpdateHasVariables()
|
private bool UpdateHasVariables()
|
||||||
{
|
{
|
||||||
bool hadReads = _hasReads;
|
bool hadReads = HasReads;
|
||||||
bool hadWrites = _hasWrites;
|
bool hadWrites = HasWrites;
|
||||||
bool hadExecutes = _hasExecutes;
|
bool hadExecutes = HasExecutes;
|
||||||
|
|
||||||
_hasReads = _reads.Count > 0;
|
HasReads = _reads.Count > 0;
|
||||||
_hasWrites = _writes.Count > 0;
|
HasWrites = _writes.Count > 0;
|
||||||
_hasExecutes = _execs.Count > 0;
|
HasExecutes = _execs.Count > 0;
|
||||||
_hasAny = _hasReads || _hasWrites || _hasExecutes;
|
_hasAny = HasReads || HasWrites || HasExecutes;
|
||||||
|
|
||||||
return (_hasReads != hadReads || _hasWrites != hadWrites || _hasExecutes != hadExecutes);
|
return (HasReads != hadReads || HasWrites != hadWrites || HasExecutes != hadExecutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int RemoveInternal(MemoryCallbackDelegate action)
|
private int RemoveInternal(MemoryCallbackDelegate action)
|
||||||
|
|
Loading…
Reference in New Issue