From 17fe836926debb796d786640e5e0aedb50f11faf Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 27 Apr 2017 08:24:21 -0500 Subject: [PATCH] Emulation.Common - misc cleanups in Base Implementations --- .../BasicServiceProvider.cs | 15 +- .../CallbackBasedTraceBuffer.cs | 12 +- .../Base Implementations/CodeDataLog.cs | 18 +-- .../ControllerDefinition.cs | 8 +- .../InputCallbackSystem.cs | 3 +- .../Base Implementations/NullEmulator.cs | 144 +++++++++++------- .../Base Implementations/NullSound.cs | 4 +- .../Base Implementations/TraceBuffer.cs | 2 +- .../Consoles/Sega/gpgx64/GPGX.ITraceable.cs | 2 +- 9 files changed, 120 insertions(+), 88 deletions(-) diff --git a/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs b/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs index 56a90e1004..3e3414dac7 100644 --- a/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs +++ b/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs @@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Common /// public class BasicServiceProvider : IEmulatorServiceProvider { - private readonly Dictionary Services = new Dictionary(); + private readonly Dictionary _services = new Dictionary(); public BasicServiceProvider(IEmulator core) { @@ -31,14 +31,14 @@ namespace BizHawk.Emulation.Common foreach (Type service in services) { - Services.Add(service, core); + _services.Add(service, core); } // add the actual instantiated type and any types in the hierarchy // except for object because that would be dumb (or would it?) while (coreType != typeof(object)) { - Services.Add(coreType, core); + _services.Add(coreType, core); coreType = coreType.BaseType; } } @@ -46,6 +46,7 @@ namespace BizHawk.Emulation.Common /// /// the core can call this to register an additional service /// + /// The to register public void Register(T provider) where T : IEmulatorService { @@ -54,7 +55,7 @@ namespace BizHawk.Emulation.Common throw new ArgumentNullException(nameof(provider)); } - Services[typeof(T)] = provider; + _services[typeof(T)] = provider; } public T GetService() @@ -66,7 +67,7 @@ namespace BizHawk.Emulation.Common public object GetService(Type t) { object service; - if (Services.TryGetValue(t, out service)) + if (_services.TryGetValue(t, out service)) { return service; } @@ -82,14 +83,14 @@ namespace BizHawk.Emulation.Common public bool HasService(Type t) { - return Services.ContainsKey(t); + return _services.ContainsKey(t); } public IEnumerable AvailableServices { get { - return Services.Select(d => d.Key); + return _services.Select(d => d.Key); } } } diff --git a/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs b/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs index 580c1cce46..f87e4bcb73 100644 --- a/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs +++ b/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs @@ -6,8 +6,8 @@ using BizHawk.Emulation.Common.IEmulatorExtensions; namespace BizHawk.Emulation.Common { /// - /// An implementation of ITraceable that is implementation using only methods - /// from IDebuggable, IMemoryDomains, and IDisassemblable + /// An implementation of that is implementation using only methods + /// from , , and /// Useful for ported cores that have these hooks but no trace logging hook, /// This allows for a traceable implementation without the need for additional API /// Note that this technique will always be significantly slower than a direct implementation @@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Common /// public abstract class CallbackBasedTraceBuffer : ITraceable { - public CallbackBasedTraceBuffer(IDebuggable debuggableCore, IMemoryDomains memoryDomains, IDisassemblable disassembler) + protected CallbackBasedTraceBuffer(IDebuggable debuggableCore, IMemoryDomains memoryDomains, IDisassemblable disassembler) { if (!debuggableCore.MemoryCallbacksAvailable()) { @@ -46,7 +46,7 @@ namespace BizHawk.Emulation.Common protected readonly List Buffer = new List(); - public abstract void TraceFromCallback(); + protected abstract void TraceFromCallback(); private ITraceSink _sink; @@ -59,7 +59,7 @@ namespace BizHawk.Emulation.Common public ITraceSink Sink { - get + private get { return _sink; } @@ -76,7 +76,7 @@ namespace BizHawk.Emulation.Common } } - public string Header { get; set; } + public string Header { get; protected set; } public class TracingMemoryCallback : IMemoryCallback { diff --git a/BizHawk.Emulation.Common/Base Implementations/CodeDataLog.cs b/BizHawk.Emulation.Common/Base Implementations/CodeDataLog.cs index 260c48b3e0..626354c7b7 100644 --- a/BizHawk.Emulation.Common/Base Implementations/CodeDataLog.cs +++ b/BizHawk.Emulation.Common/Base Implementations/CodeDataLog.cs @@ -22,14 +22,14 @@ namespace BizHawk.Emulation.Common /// public void Pin() { - if (Pins.Count != 0) + if (_pins.Count != 0) { throw new InvalidOperationException("incremental astrological examination"); } foreach (var kvp in this) { - Pins[kvp.Key] = GCHandle.Alloc(kvp.Value, GCHandleType.Pinned); + _pins[kvp.Key] = GCHandle.Alloc(kvp.Value, GCHandleType.Pinned); } } @@ -38,12 +38,12 @@ namespace BizHawk.Emulation.Common /// public void Unpin() { - foreach (var pin in Pins.Values) + foreach (var pin in _pins.Values) { pin.Free(); } - Pins.Clear(); + _pins.Clear(); } /// @@ -51,13 +51,13 @@ namespace BizHawk.Emulation.Common /// public IntPtr GetPin(string key) { - return Pins[key].AddrOfPinnedObject(); + return _pins[key].AddrOfPinnedObject(); } /// /// Pinned managed arrays /// - private readonly Dictionary Pins = new Dictionary(); + private readonly Dictionary _pins = new Dictionary(); /// /// Whether the CDL is tracking a block with the given name @@ -146,10 +146,10 @@ namespace BizHawk.Emulation.Common public void Save(Stream s) { - _Save(s, true); + SaveInternal(s, true); } - private Dictionary _Save(Stream s, bool forReal) + private Dictionary SaveInternal(Stream s, bool forReal) { var ret = new Dictionary(); var w = new BinaryWriter(s); @@ -184,7 +184,7 @@ namespace BizHawk.Emulation.Common public Dictionary GetBlockMap() { - return _Save(new MemoryStream(), false); + return SaveInternal(new MemoryStream(), false); } public void Load(Stream s) diff --git a/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs b/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs index 57a3bb9cd1..13cd1fa98b 100644 --- a/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs +++ b/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs @@ -86,7 +86,7 @@ namespace BizHawk.Emulation.Common float range = (float)constraint.Params[2]; double xval = floatButtons[xaxis]; double yval = floatButtons[yaxis]; - double length = Math.Sqrt(xval * xval + yval * yval); + double length = Math.Sqrt((xval * xval) + (yval * yval)); if (length > range) { double ratio = range / length; @@ -154,7 +154,7 @@ namespace BizHawk.Emulation.Common } /// - /// Puts the controls in a logical order such as by controller number, + /// Gets a list of controls put in a logical order such as by controller number, /// This is a default implementation that should work most of the time /// public virtual IEnumerable> ControlsOrdered @@ -170,9 +170,9 @@ namespace BizHawk.Emulation.Common ret[i] = new List(); } - for (int i = 0; i < list.Count; i++) + foreach (string btn in list) { - ret[PlayerNumber(list[i])].Add(list[i]); + ret[PlayerNumber(btn)].Add(btn); } return ret; diff --git a/BizHawk.Emulation.Common/Base Implementations/InputCallbackSystem.cs b/BizHawk.Emulation.Common/Base Implementations/InputCallbackSystem.cs index 9109004a4e..21e6383c18 100644 --- a/BizHawk.Emulation.Common/Base Implementations/InputCallbackSystem.cs +++ b/BizHawk.Emulation.Common/Base Implementations/InputCallbackSystem.cs @@ -19,6 +19,7 @@ namespace BizHawk.Emulation.Common } } + // TODO: these just happen to be all the add/remove methods the client uses, to be thorough the others should be overriden as well public void RemoveAll(IEnumerable actions) { var hadAny = this.Any(); @@ -53,8 +54,6 @@ namespace BizHawk.Emulation.Common return result; } - // TODO: these just happen to be all the add/remove methods the client uses, to be thorough the others should be overriden as well - public delegate void ActiveChangedEventHandler(); public event ActiveChangedEventHandler ActiveChanged; diff --git a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs index 5e3d869375..c60916bd12 100644 --- a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs +++ b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs @@ -200,7 +200,7 @@ namespace BizHawk.Emulation.Common private bool _frameBufferClear = true; - private bool _xmas; + private readonly bool _xmas; private readonly Pleg _pleg; private NullEmulatorSettings _settings; @@ -227,88 +227,104 @@ namespace BizHawk.Emulation.Common internal class Bell { // ms ima adpcm - private const string dataz = "H4sICHbdkVQCAGJlbGxzb3V0LnJhdwDtWOdz+nQYz8BZsqmrkJBAXS1JgNZZZqueo4XW8Upt63jpqPOd486X7vf6c7zxzlHQO19pgeqdq4VA62yBBOpqIQvqKknEP8PT50VeJt/k+cwAOPD//D//z390IHx4cQH/z79lQBxgVFuJECSHdxqAznFRFu1ut/wgMS2oe4ogRYBpf7er+OvaOWGNqaa2dDDKDioBfx2Elg5lAGIxI41+JRPTfHvV7m5oF/ohnPR93CQJLkobvyq+zVUj7LjXAQckbxEb2AZQDgTvYvYkpmH9fBeANfR9k7koBfxa4RiKHefflXE9AuCmKE2eSv9gRjjhY+hPDZxjAiPNQTOKXJfV7F4sR/+eaPo1gH3bCNzMdNt3PKdDs5ETY6Q11l4Meqt8beEUZ7m8tZTr6pzfEOVZpvtVgQOusSF/5xUwgBPAvQPjL0WAE+bN/rdlEHeoYHzDqQPXCZDv9zEJv9DXEhuO2lv4ZtXBK0IhqrJSCv3otITeuJWvIJUodp3QZN5z+otgorayrTvQVOJcWhuUtbsJHBALJ0qquqiL67hK1i8L91b2DUx4L+jnPgZtrMBNJaXQht5M/sZOjVXA8HscfJdK6MhrYukhFfk9VPQNXy9cDo61mHMSBcxca5DoOKoBBne25rrrRGah0KkARiItenSiiI8m3huuYV9Z0kg7Wr/3xMDJswwWQFrcXzqoszejHxvpbvlWv4wUE7mIlvwxU/aXsnUPl2gA2z/I3GgqMLZO2LB9m6AgCv+6aMw62FGO6wa0Rwbm4DSkL1aTGlCeRWH74RMJZ0x+58lcqhwxFre5BvUlTICCWrtAxk5fAs88TbTcaft0qz2Wj+xNWx6kbYP8qLLgkM8vS+n6UpErkyMwCiZaSKz7mS0yH/r67vbtJqPcqcRrsc1knu/h+Xib/CIs6zfBmL68M1lK5WAHjq9Hv2LlwOF0kzxxITgBokQzYf7pmn8pfORxw5Of8nriDUGNVkS0j//qscixY3on/r64nlJd3j5de0D2N1eaHAIz0oONwAlsjft2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ycMQkwfwNoPjsGACAAAA=="; private static readonly int[] AdaptationTable = { 230, 230, 230, 230, 307, 409, 512, 614, 768, 614, 512, 409, 307, 230, 230, 230 }; private static readonly int[] AdaptCoeff1 = { 256, 512, 0, 192, 240, 460, 392 }; private static readonly int[] AdaptCoeff2 = { 0, -256, 0, 64, 0, -208, -232 }; - private byte[] data; + private readonly byte[] _data; public Bell() { var gz = new System.IO.Compression.GZipStream( - new MemoryStream(Convert.FromBase64String(dataz), false), + new MemoryStream(Convert.FromBase64String(Dataz), false), System.IO.Compression.CompressionMode.Decompress); var ms = new MemoryStream(); gz.CopyTo(ms); - data = ms.ToArray(); + _data = ms.ToArray(); for (int i = 0; i < 3800; i++) // compenstate for sample start point { Next(); } } - private int blockpredictor; - private int sample1; - private int sample2; - private int delta; + private int _blockpredictor; + private int _sample1; + private int _sample2; + private int _delta; - private int idx = 0; - private bool top = false; + private int _idx = 0; + private bool _top = false; - private int samplectr = 0; - private const int sampleloop = 15360; + private int _samplectr = 0; + private const int Sampleloop = 15360; public short Next() { int ret; - if ((idx & 0x3ff) == 0) // start block + if ((_idx & 0x3ff) == 0) // start block { - blockpredictor = data[idx] % 7; - delta = (short)(data[idx + 1] | data[idx + 2] << 8); - sample1 = (short)(data[idx + 3] | data[idx + 4] << 8); - sample2 = (short)(data[idx + 5] | data[idx + 6] << 8); + _blockpredictor = _data[_idx] % 7; + _delta = (short)(_data[_idx + 1] | _data[_idx + 2] << 8); + _sample1 = (short)(_data[_idx + 3] | _data[_idx + 4] << 8); + _sample2 = (short)(_data[_idx + 5] | _data[_idx + 6] << 8); - ret = sample2; - idx++; + ret = _sample2; + _idx++; } - else if ((idx & 0x3ff) == 1) + else if ((_idx & 0x3ff) == 1) { - ret = sample1; - top = true; - idx += 6; + ret = _sample1; + _top = true; + _idx += 6; } else { - int nibble = data[idx]; - if (top) + int nibble = _data[_idx]; + if (_top) + { nibble >>= 4; + } else - idx++; - top ^= true; + { + _idx++; + } + + _top ^= true; nibble <<= 28; nibble >>= 28; - int predictor = sample1 * AdaptCoeff1[blockpredictor] + sample2 * AdaptCoeff2[blockpredictor]; + int predictor = (_sample1 * AdaptCoeff1[_blockpredictor]) + (_sample2 * AdaptCoeff2[_blockpredictor]); predictor >>= 8; - predictor += nibble * delta; - if (predictor >= 32767) predictor = 32767; - if (predictor <= -32768) predictor = -32768; + predictor += nibble * _delta; + if (predictor >= 32767) + { + predictor = 32767; + } + + if (predictor <= -32768) + { + predictor = -32768; + } + ret = predictor; - sample2 = sample1; - sample1 = predictor; - delta = AdaptationTable[nibble & 15] * delta; - delta >>= 8; - if (delta < 16) delta = 16; + _sample2 = _sample1; + _sample1 = predictor; + _delta = AdaptationTable[nibble & 15] * _delta; + _delta >>= 8; + if (_delta < 16) + { + _delta = 16; + } } - samplectr++; - if (samplectr == sampleloop) + _samplectr++; + if (_samplectr == Sampleloop) { - samplectr = 0; - idx = 0; + _samplectr = 0; + _idx = 0; } return (short)ret; @@ -317,18 +333,18 @@ namespace BizHawk.Emulation.Common internal class Pleg { - private const string data = "H4sICI/2sVICAG91dDMudHh0AOxazdLbIAy8d6bvgkFImFsvufb936Yt3YyKvjBY5UvS6XDSxOZndyULy9H3ylLD1y8/baxHs/Lb5rNG2IT7zVKq9Msmrmf7Tb/st3qcP4ff7rdhb7itw04eXrVzsYWOTuXTt7yzl/OXvYHtDWwN+0cQi0IcqzJnxtchy9lDbo5rVODAAJvbdXWk1PiQooBiMBQPnxcOnYbhfkoCSgGUMmLxbgsoCSgdoCSgFEApwxZQArZ0uryWTp227DUBxVzDpbXLNUhlAVIGJELsZ6hb+kzACdePGqFqxPiE8QnjEualCcUZtb+mRKAUP0tlfyxHQAiIZUEsJ6gZYVXtTlVOiGWBmhk29qoS+zIQ6zQvJZ3rUHFtSwm9I++q5WJUS1At90mNAywhA/CqausZIPaPG/Jtgwhq6ug3qU5GdZMRMg+OmNR7IxfjjQwbDLXD5Q09Yta9QcfqKQfkz4Aw3fptrP0xNVfsCVu++j1S55KPJem01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5KIxvq6iMxb/HxV7CmpLPV6i6vhrGZdRHp5Us/SEPEwmD5eaXQEzycN5kIfZ5GHjDS7LediftAaxH/DN0r5riPWOLXld3xiI/unqWhgqnbCHieGzU8v9/YJK2wWrSqxHA0404bv+7yjpy1G7HwGBFAoiOIJw9PsABHVVHhBc+G8UJyAAYwv1lJASaZZAiPFbzCN6Pq7zKPq+pUWdtuy7oo9qp2YCNe59xGwe0RmWco1CWaDAfeKUA95KfXmA6+qlWKOpwieUZlTW/0NNSqH9DoAcAfmosUuYx2d5wf+MpP4ZYYbqAdBpoP5x73ExrRFHXwuKpSa+Z0R0mo+aFqsygKRrj9SerYqrZu1V3CRuqRbougPdId0qxLlfR6Psgam9PBxhT+wd+71zcKmeg05bVBWQboBkIF7Zq8xWxdXJ2iuZfILTSuil/SxIqSxDu+bX+RHOYjIxwUZTQIgeKoOuQ2Ac993tbsTdjbi7EXc34u5G3N2IuxtxdyPubsTdjbi7EXc34u5G3N2IuxtxdyPubsTdjbi7EXc34o927dAGAACEgeB27D8SEoVBleRmqGg+ORqRRqQRaUQakUakEWlEGjG1rmlEGpFGpBFpRBqRRqQRaUQakUakEWlEGpFGpBFpRBqRRqQRaUQakUakEWlEGpFGpBFpRBqRRqQRaUQakUb86OhoRBqRRqQRk+qaRqQRaUQakUakEWlEGpFGpBFvGnFXiHMetSzUwqZz46p5AAA="; private readonly List SinMen = new List(); private readonly List Lines = new List(); private readonly Bell Bell = new Bell(); - private int LineIDX = 0; - private int deadtime = 0; + private int _lineIdx = 0; + private int _deadtime = 0; public Pleg() { var gz = new System.IO.Compression.GZipStream( - new MemoryStream(Convert.FromBase64String(data), false), + new MemoryStream(Convert.FromBase64String(Data), false), System.IO.Compression.CompressionMode.Decompress); var tr = new StreamReader(gz); string line; @@ -377,17 +393,28 @@ namespace BizHawk.Emulation.Common } } - if (ret > 32767) ret = 32767; - if (ret < -32767) ret = -32767; + if (ret > 32767) + { + ret = 32767; + } + + if (ret < -32767) + { + ret = -32767; + } + return (short)ret; } private string FetchNext() { - string ret = Lines[LineIDX]; - LineIDX++; - if (LineIDX == Lines.Count) - LineIDX = 0; + string ret = Lines[_lineIdx]; + _lineIdx++; + if (_lineIdx == Lines.Count) + { + _lineIdx = 0; + } + return ret; } @@ -396,27 +423,32 @@ namespace BizHawk.Emulation.Common int idx = 0; while (idx < dest.Length) { - if (deadtime > 0) + if (_deadtime > 0) { short n = Next(); n += Bell.Next(); dest[idx++] = n; dest[idx++] = n; - deadtime--; + _deadtime--; } else { string[] s = FetchNext().Split(':'); char c = s[0][0]; if (c == 'A') - deadtime = int.Parse(s[1]) * 40; + { + _deadtime = int.Parse(s[1]) * 40; + } else if (c == 'O') + { On(int.Parse(s[2]), int.Parse(s[1])); + } else if (c == 'F') + { Off(int.Parse(s[2]), int.Parse(s[1])); + } } } - } } @@ -433,7 +465,7 @@ namespace BizHawk.Emulation.Common public bool Done => amp < 2.0; - static double GetFreq(int note) + private static double GetFreq(int note) { return Math.Pow(2.0, note / 12.0) * 13.0; } diff --git a/BizHawk.Emulation.Common/Base Implementations/NullSound.cs b/BizHawk.Emulation.Common/Base Implementations/NullSound.cs index 41bdf78286..27afd57ecc 100644 --- a/BizHawk.Emulation.Common/Base Implementations/NullSound.cs +++ b/BizHawk.Emulation.Common/Base Implementations/NullSound.cs @@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Common { private readonly long _spfNumerator; private readonly long _spfDenominator; - private long _remainder = 0; + private long _remainder; private short[] _buff = new short[0]; private NullSound() @@ -32,7 +32,7 @@ namespace BizHawk.Emulation.Common /// /// Initializes a new instance of the class - /// that exactly matches a given framerate when in sync mode + /// that exactly matches a given frame rate when in sync mode /// public NullSound(long fpsNum, long fpsDen) { diff --git a/BizHawk.Emulation.Common/Base Implementations/TraceBuffer.cs b/BizHawk.Emulation.Common/Base Implementations/TraceBuffer.cs index 80b53f5a76..75d64f56c9 100644 --- a/BizHawk.Emulation.Common/Base Implementations/TraceBuffer.cs +++ b/BizHawk.Emulation.Common/Base Implementations/TraceBuffer.cs @@ -13,7 +13,7 @@ public string Header { get; set; } - public ITraceSink Sink { get; set; } + public ITraceSink Sink { private get; set; } public bool Enabled => Sink != null; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs index 38b177adcc..c9d8abf61e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs @@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx64 Header = "M68K: PC, machine code, mnemonic, operands, registers (D0-D7, A0-A7, SR, USP), flags (XNZVC)"; } - public override void TraceFromCallback() + protected override void TraceFromCallback() { var regs = DebuggableCore.GetCpuFlagsAndRegisters(); uint pc = (uint)regs["M68K PC"].Value;