Emulation.Common - more misc cleanups throughout

This commit is contained in:
adelikat 2017-04-27 12:25:12 -05:00
parent 883d9d2207
commit 130f881ea0
7 changed files with 42 additions and 43 deletions

View File

@ -18,14 +18,14 @@ namespace BizHawk.Emulation.Common
{
ExecuteCallbacksAvailable = true;
Reads.CollectionChanged += OnCollectionChanged;
Writes.CollectionChanged += OnCollectionChanged;
Execs.CollectionChanged += OnCollectionChanged;
_reads.CollectionChanged += OnCollectionChanged;
_writes.CollectionChanged += OnCollectionChanged;
_execs.CollectionChanged += OnCollectionChanged;
}
private readonly ObservableCollection<IMemoryCallback> Reads = new ObservableCollection<IMemoryCallback>();
private readonly ObservableCollection<IMemoryCallback> Writes = new ObservableCollection<IMemoryCallback>();
private readonly ObservableCollection<IMemoryCallback> Execs = new ObservableCollection<IMemoryCallback>();
private readonly ObservableCollection<IMemoryCallback> _reads = new ObservableCollection<IMemoryCallback>();
private readonly ObservableCollection<IMemoryCallback> _writes = new ObservableCollection<IMemoryCallback>();
private readonly ObservableCollection<IMemoryCallback> _execs = new ObservableCollection<IMemoryCallback>();
private bool _empty = true;
@ -40,15 +40,15 @@ namespace BizHawk.Emulation.Common
switch (callback.Type)
{
case MemoryCallbackType.Execute:
Execs.Add(callback);
_execs.Add(callback);
_hasExecutes = true;
break;
case MemoryCallbackType.Read:
Reads.Add(callback);
_reads.Add(callback);
_hasReads = true;
break;
case MemoryCallbackType.Write:
Writes.Add(callback);
_writes.Add(callback);
_hasWrites = true;
break;
}
@ -76,7 +76,7 @@ namespace BizHawk.Emulation.Common
{
if (_hasReads)
{
Call(Reads, addr);
Call(_reads, addr);
}
}
@ -84,7 +84,7 @@ namespace BizHawk.Emulation.Common
{
if (_hasWrites)
{
Call(Writes, addr);
Call(_writes, addr);
}
}
@ -92,7 +92,7 @@ namespace BizHawk.Emulation.Common
{
if (_hasExecutes)
{
Call(Execs, addr);
Call(_execs, addr);
}
}
@ -104,30 +104,30 @@ namespace BizHawk.Emulation.Common
private void UpdateHasVariables()
{
_hasReads = Reads.Count > 0;
_hasWrites = Writes.Count > 0;
_hasExecutes = Execs.Count > 0;
_hasReads = _reads.Count > 0;
_hasWrites = _writes.Count > 0;
_hasExecutes = _execs.Count > 0;
}
private int RemoveInternal(Action action)
{
var readsToRemove = Reads.Where(imc => imc.Callback == action).ToList();
var writesToRemove = Writes.Where(imc => imc.Callback == action).ToList();
var execsToRemove = Execs.Where(imc => imc.Callback == action).ToList();
var readsToRemove = _reads.Where(imc => imc.Callback == action).ToList();
var writesToRemove = _writes.Where(imc => imc.Callback == action).ToList();
var execsToRemove = _execs.Where(imc => imc.Callback == action).ToList();
foreach (var read in readsToRemove)
{
Reads.Remove(read);
_reads.Remove(read);
}
foreach (var write in writesToRemove)
{
Writes.Remove(write);
_writes.Remove(write);
}
foreach (var exec in execsToRemove)
{
Execs.Remove(exec);
_execs.Remove(exec);
}
UpdateHasVariables();
@ -174,19 +174,19 @@ namespace BizHawk.Emulation.Common
public void Clear()
{
// Remove one-by-one to avoid NotifyCollectionChangedAction.Reset events.
for (int i = Reads.Count - 1; i >= 0; i--)
for (int i = _reads.Count - 1; i >= 0; i--)
{
Reads.RemoveAt(i);
_reads.RemoveAt(i);
}
for (int i = Reads.Count - 1; i >= 0; i--)
for (int i = _reads.Count - 1; i >= 0; i--)
{
Writes.RemoveAt(i);
_writes.RemoveAt(i);
}
for (int i = Reads.Count - 1; i >= 0; i--)
for (int i = _reads.Count - 1; i >= 0; i--)
{
Execs.RemoveAt(i);
_execs.RemoveAt(i);
}
if (!_empty)
@ -236,17 +236,17 @@ namespace BizHawk.Emulation.Common
public IEnumerator<IMemoryCallback> GetEnumerator()
{
foreach (var imc in Reads)
foreach (var imc in _reads)
{
yield return imc;
}
foreach (var imc in Writes)
foreach (var imc in _writes)
{
yield return imc;
}
foreach (var imc in Execs)
foreach (var imc in _execs)
{
yield return imc;
}
@ -254,17 +254,17 @@ namespace BizHawk.Emulation.Common
IEnumerator IEnumerable.GetEnumerator()
{
foreach (var imc in Reads)
foreach (var imc in _reads)
{
yield return imc;
}
foreach (var imc in Writes)
foreach (var imc in _writes)
{
yield return imc;
}
foreach (var imc in Execs)
foreach (var imc in _execs)
{
yield return imc;
}

View File

@ -12,8 +12,6 @@
Name = "Null Controller"
};
public bool this[string button] => false;
public bool IsPressed(string button)
{
return false;

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Common.Base_Implementations
public class SimpleSyncSoundProvider : ISoundProvider
{
private short[] _buffer = new short[0];
private int _nsamp = 0;
private int _nsamp;
public bool CanProvideAsync => false;

View File

@ -220,6 +220,7 @@ namespace BizHawk.Emulation.Common.BizInvoke
p.SetCustomAttribute(GetAttributeBuilder(a));
}
}
{
var p = delegateInvoke.DefineParameter(0, ParameterAttributes.Retval, baseMethod.ReturnParameter.Name);
foreach (var a in baseMethod.ReturnParameter.GetCustomAttributes(false))
@ -328,7 +329,6 @@ namespace BizHawk.Emulation.Common.BizInvoke
returnType,
paramTypes);
var il = method.GetILGenerator();
Label exc = new Label();
@ -466,6 +466,7 @@ namespace BizHawk.Emulation.Common.BizInvoke
{
throw new InvalidOperationException("Multidimensional arrays are not supported!");
}
if (type.Name.Contains('*'))
{
throw new InvalidOperationException("Only 0-based 1-dimensional arrays are supported!");

View File

@ -259,7 +259,7 @@ namespace BizHawk.Emulation.Common
// for sync
private short[] _outbuf2 = new short[16];
private int _outbuf2pos = 0;
private int _outbuf2pos;
// in buffer position in samples (not sample pairs)
private int _inbufpos;

View File

@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Common
// TODO: This should build itself from the Cores assembly, we don't want to maintain this
public class SystemLookup
{
private readonly List<SystemInfo> Systems = new List<SystemInfo>
private readonly List<SystemInfo> _systems = new List<SystemInfo>
{
new SystemInfo { SystemId = "A26", FullName = "Atari 2600" },
new SystemInfo { SystemId = "A78", FullName = "Atari 7800" },
@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Common
{
get
{
var system = Systems.FirstOrDefault(s => s.SystemId == systemId);
var system = _systems.FirstOrDefault(s => s.SystemId == systemId);
if (system != null)
{
@ -56,10 +56,10 @@ namespace BizHawk.Emulation.Common
{
if (VersionInfo.DeveloperBuild)
{
return Systems;
return _systems;
}
return Systems.Where(s => s.SystemId != "C64");
return _systems.Where(s => s.SystemId != "C64");
}
}

View File

@ -104,7 +104,7 @@ namespace BizHawk.Emulation.Common
}
// other data besides the core
public T ExtraData;
public readonly T ExtraData;
public TextStateFPtrs GetFunctionPointersSave()
{