Client.Common cleanups
This commit is contained in:
parent
85f78b358d
commit
70baf9d306
|
@ -48,12 +48,12 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_buttons.Any(x => x.Value))
|
||||
if (_buttons.Any(b => b.Value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return _floatButtons.Any(x => x.Value != 0);
|
||||
return _floatButtons.Any(b => b.Value != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace BizHawk.Client.Common
|
|||
public static void SyncCoreCommInputSignals(CoreComm target)
|
||||
{
|
||||
string superhack = null;
|
||||
if (target.CoreFileProvider != null && target.CoreFileProvider is CoreFileProvider)
|
||||
if (target.CoreFileProvider is CoreFileProvider)
|
||||
{
|
||||
superhack = ((CoreFileProvider)target.CoreFileProvider).SubfileDirectory;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
|
@ -267,19 +268,21 @@ namespace BizHawk.Client.Common
|
|||
fixed (byte* srcp = src)
|
||||
fixed (int* dstp = dst)
|
||||
{
|
||||
using (new BizHawk.Common.SimpleTime("Blit"))
|
||||
Blit(new BMP
|
||||
{
|
||||
Data = (int*)srcp,
|
||||
Width = in_w,
|
||||
Height = in_h
|
||||
},
|
||||
new BMP
|
||||
{
|
||||
Data = dstp,
|
||||
Width = v.BufferWidth,
|
||||
Height = v.BufferHeight,
|
||||
});
|
||||
using (new SimpleTime("Blit"))
|
||||
{
|
||||
Blit(new BMP
|
||||
{
|
||||
Data = (int*)srcp,
|
||||
Width = in_w,
|
||||
Height = in_h
|
||||
},
|
||||
new BMP
|
||||
{
|
||||
Data = dstp,
|
||||
Width = v.BufferWidth,
|
||||
Height = v.BufferHeight,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -311,19 +314,21 @@ namespace BizHawk.Client.Common
|
|||
fixed (int* srcp = src)
|
||||
fixed (byte* dstp = dst)
|
||||
{
|
||||
using (new BizHawk.Common.SimpleTime("Blit"))
|
||||
Blit(new BMP
|
||||
{
|
||||
Data = srcp,
|
||||
Width = v.BufferWidth,
|
||||
Height = v.BufferHeight
|
||||
},
|
||||
new BMP
|
||||
{
|
||||
Data = (int*)dstp,
|
||||
Width = w,
|
||||
Height = h,
|
||||
});
|
||||
using (new SimpleTime("Blit"))
|
||||
{
|
||||
Blit(new BMP
|
||||
{
|
||||
Data = srcp,
|
||||
Width = v.BufferWidth,
|
||||
Height = v.BufferHeight
|
||||
},
|
||||
new BMP
|
||||
{
|
||||
Data = (int*)dstp,
|
||||
Width = w,
|
||||
Height = h,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
s.Write(dst, 0, dst.Length);
|
||||
|
|
|
@ -355,8 +355,7 @@ namespace BizHawk.Client.Common
|
|||
string discPath = e.Path;
|
||||
|
||||
//--- load the disc in a context which will let us abort if it's going to take too long
|
||||
var discMountJob = new DiscMountJob { IN_FromPath = discPath };
|
||||
discMountJob.IN_SlowLoadAbortThreshold = 8;
|
||||
var discMountJob = new DiscMountJob { IN_FromPath = discPath, IN_SlowLoadAbortThreshold = 8 };
|
||||
discMountJob.Run();
|
||||
disc = discMountJob.OUT_Disc;
|
||||
|
||||
|
|
|
@ -339,8 +339,7 @@ namespace BizHawk.Client.Common
|
|||
this.path = path;
|
||||
this.compressionlevel = compressionlevel;
|
||||
|
||||
svc = new SevenZip.SevenZipCompressor();
|
||||
svc.ArchiveFormat = SevenZip.OutArchiveFormat.Zip;
|
||||
svc = new SevenZip.SevenZipCompressor { ArchiveFormat = SevenZip.OutArchiveFormat.Zip };
|
||||
|
||||
switch (compressionlevel)
|
||||
{
|
||||
|
|
|
@ -23,15 +23,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void WriteItem(string name, Action<Stream> callback)
|
||||
{
|
||||
var e = new ZipEntry(name);
|
||||
if (_level == 0)
|
||||
var e = new ZipEntry(name)
|
||||
{
|
||||
e.CompressionMethod = CompressionMethod.Stored;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.CompressionMethod = CompressionMethod.Deflated;
|
||||
}
|
||||
CompressionMethod = _level == 0 ? CompressionMethod.Stored : CompressionMethod.Deflated
|
||||
};
|
||||
|
||||
_zipOutputStream.PutNextEntry(e);
|
||||
callback(_zipOutputStream);
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
return Bindings.FirstOrDefault(x => x.DisplayName == index) ?? new Binding();
|
||||
return Bindings.FirstOrDefault(b => b.DisplayName == index) ?? new Binding();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ namespace BizHawk.Client.Common
|
|||
// Add missing entries
|
||||
foreach (Binding defaultBinding in DefaultValues)
|
||||
{
|
||||
var binding = Bindings.FirstOrDefault(x => x.DisplayName == defaultBinding.DisplayName);
|
||||
var binding = Bindings.FirstOrDefault(b => b.DisplayName == defaultBinding.DisplayName);
|
||||
if (binding == null)
|
||||
{
|
||||
Bindings.Add(defaultBinding);
|
||||
|
@ -96,7 +96,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
List<Binding> entriesToRemove = (from entry in Bindings let binding = DefaultValues.FirstOrDefault(x => x.DisplayName == entry.DisplayName) where binding == null select entry).ToList();
|
||||
List<Binding> entriesToRemove = (from entry in Bindings let binding = DefaultValues.FirstOrDefault(b => b.DisplayName == entry.DisplayName) where binding == null select entry).ToList();
|
||||
|
||||
// Remove entries that no longer exist in defaults
|
||||
foreach (Binding entry in entriesToRemove)
|
||||
|
@ -105,7 +105,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
static List<Binding> s_DefaultValues;
|
||||
private static List<Binding> s_DefaultValues;
|
||||
|
||||
public static List<Binding> DefaultValues
|
||||
{
|
||||
|
|
|
@ -7,11 +7,11 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public class PathEntry
|
||||
{
|
||||
public string SystemDisplayName;
|
||||
public string Type;
|
||||
public string Path;
|
||||
public string System;
|
||||
public int Ordinal;
|
||||
public string SystemDisplayName { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string System { get; set; }
|
||||
public int Ordinal { get; set; }
|
||||
|
||||
public bool HasSystem(string systemID)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
return Paths.FirstOrDefault(x => x.HasSystem(system) && x.Type == type) ?? TryGetDebugPath(system, type);
|
||||
return Paths.FirstOrDefault(p => p.HasSystem(system) && p.Type == type) ?? TryGetDebugPath(system, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ namespace BizHawk.Client.Common
|
|||
// Add missing entries
|
||||
foreach (PathEntry defaultpath in DefaultValues)
|
||||
{
|
||||
var path = Paths.FirstOrDefault(x => x.System == defaultpath.System && x.Type == defaultpath.Type);
|
||||
var path = Paths.FirstOrDefault(p => p.System == defaultpath.System && p.Type == defaultpath.Type);
|
||||
if (path == null)
|
||||
{
|
||||
Paths.Add(defaultpath);
|
||||
|
@ -106,7 +106,7 @@ namespace BizHawk.Client.Common
|
|||
// Remove entries that no longer exist in defaults
|
||||
foreach (PathEntry pathEntry in Paths)
|
||||
{
|
||||
var path = DefaultValues.FirstOrDefault(x => x.System == pathEntry.System && x.Type == pathEntry.Type);
|
||||
var path = DefaultValues.FirstOrDefault(p => p.System == pathEntry.System && p.Type == pathEntry.Type);
|
||||
if (path == null)
|
||||
{
|
||||
entriesToRemove.Add(pathEntry);
|
||||
|
@ -119,10 +119,10 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
// Add missing displaynames
|
||||
var missingDisplayPaths = Paths.Where(x => x.SystemDisplayName == null).ToList();
|
||||
var missingDisplayPaths = Paths.Where(p => p.SystemDisplayName == null).ToList();
|
||||
foreach (PathEntry path in missingDisplayPaths)
|
||||
{
|
||||
path.SystemDisplayName = DefaultValues.FirstOrDefault(x => x.System == path.System).SystemDisplayName;
|
||||
path.SystemDisplayName = DefaultValues.First(p => p.System == path.System).SystemDisplayName;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,9 +89,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
catch (NotImplementedException)
|
||||
{
|
||||
Log(string.Format(
|
||||
"Error: {0} does not yet implement disassemble()",
|
||||
Emulator.Attributes().CoreName));
|
||||
Log($"Error: {Emulator.Attributes().CoreName} does not yet implement disassemble()");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -178,9 +176,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
catch (NotImplementedException)
|
||||
{
|
||||
Log(string.Format(
|
||||
"Error: {0} does not yet implement totalexecutedcycles()",
|
||||
Emulator.Attributes().CoreName));
|
||||
Log($"Error: {Emulator.Attributes().CoreName} does not yet implement totalexecutedcycles()");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -238,7 +234,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
Log(string.Format("Can not set lag information, {0} does not implement IInputPollable", Emulator.Attributes().CoreName));
|
||||
Log($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -135,13 +135,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private bool N64CoreTypeDynarec()
|
||||
{
|
||||
if (Emulator is N64)
|
||||
if ((Emulator as N64)?.GetSyncSettings().Core == N64SyncSettings.CoreType.Dynarec)
|
||||
{
|
||||
if ((Emulator as N64).GetSyncSettings().Core == N64SyncSettings.CoreType.Dynarec)
|
||||
{
|
||||
Log("N64 Error: Memory callbacks are not implemented for Dynamic Recompiler core type\nUse Interpreter or Pure Interpreter\n");
|
||||
return true;
|
||||
}
|
||||
Log("N64 Error: Memory callbacks are not implemented for Dynamic Recompiler core type\nUse Interpreter or Pure Interpreter\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -204,7 +201,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private void LogNotImplemented()
|
||||
{
|
||||
Log(string.Format("Error: {0} does not yet implement input polling callbacks"));
|
||||
Log($"Error: {Emulator.Attributes().CoreName} does not yet implement input polling callbacks");
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
|
|
|
@ -174,7 +174,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
var decoder = new NESGameGenieDecoder(code);
|
||||
Global.CheatList.RemoveRange(
|
||||
Global.CheatList.Where(x => x.Address == decoder.Address));
|
||||
Global.CheatList.Where(c => c.Address == decoder.Address));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ __Types and notation__
|
|||
** A standard Lua table
|
||||
");
|
||||
|
||||
foreach (var library in this.Select(x => new { Name = x.Library, Description = x.LibraryDescription }).Distinct())
|
||||
foreach (var library in this.Select(lf => new { Name = lf.Library, Description = lf.LibraryDescription }).Distinct())
|
||||
{
|
||||
sb
|
||||
.AppendFormat("%%TAB {0}%%", library.Name)
|
||||
|
@ -54,7 +54,7 @@ __Types and notation__
|
|||
.AppendLine();
|
||||
}
|
||||
|
||||
foreach (var func in this.Where(x => x.Library == library.Name))
|
||||
foreach (var func in this.Where(lf => lf.Library == library.Name))
|
||||
{
|
||||
sb
|
||||
.AppendFormat("__{0}.{1}__%%%", func.Library, func.Name)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
CurrentDirectory = System.IO.Path.GetDirectoryName(path);
|
||||
}
|
||||
|
||||
public LuaFile(bool isSeparator)
|
||||
private LuaFile(bool isSeparator)
|
||||
{
|
||||
IsSeparator = isSeparator;
|
||||
Name = "";
|
||||
|
@ -28,11 +28,13 @@
|
|||
State = RunState.Disabled;
|
||||
}
|
||||
|
||||
public static LuaFile SeparatorInstance => new LuaFile(true);
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string Path { get; }
|
||||
public bool Enabled => State != RunState.Disabled;
|
||||
public bool Paused => State == RunState.Paused;
|
||||
public bool IsSeparator { get; set; }
|
||||
public bool IsSeparator { get; }
|
||||
public LuaInterface.Lua Thread { get; set; }
|
||||
public bool FrameWaiting { get; set; }
|
||||
public string CurrentDirectory { get; set; }
|
||||
|
@ -44,8 +46,6 @@
|
|||
|
||||
public RunState State { get; set; }
|
||||
|
||||
public static LuaFile SeparatorInstance => new LuaFile(true);
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
State = RunState.Disabled;
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void StopAllScripts()
|
||||
{
|
||||
ForEach(x => x.State = LuaFile.RunState.Disabled);
|
||||
ForEach(lf => lf.State = LuaFile.RunState.Disabled);
|
||||
}
|
||||
|
||||
public new void Clear()
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
return this.FirstOrDefault(x => x.Guid.ToString() == guid);
|
||||
return this.FirstOrDefault(nlf => nlf.Guid.ToString() == guid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,13 +34,13 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (Global.Emulator.InputCallbacksAvailable())
|
||||
{
|
||||
Global.Emulator.AsInputPollable().InputCallbacks.RemoveAll(this.Select(x => x.Callback));
|
||||
Global.Emulator.AsInputPollable().InputCallbacks.RemoveAll(this.Select(w => w.Callback));
|
||||
}
|
||||
|
||||
if (Global.Emulator.MemoryCallbacksAvailable())
|
||||
{
|
||||
var memoryCallbacks = Global.Emulator.AsDebuggable().MemoryCallbacks;
|
||||
memoryCallbacks.RemoveAll(this.Select(x => x.Callback));
|
||||
memoryCallbacks.RemoveAll(this.Select(w => w.Callback));
|
||||
}
|
||||
|
||||
Clear();
|
||||
|
|
|
@ -10,24 +10,25 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public abstract class LuaLibraryBase
|
||||
{
|
||||
public LuaLibraryBase(Lua lua)
|
||||
protected LuaLibraryBase(Lua lua)
|
||||
{
|
||||
Lua = lua;
|
||||
}
|
||||
|
||||
public LuaLibraryBase(Lua lua, Action<string> logOutputCallback)
|
||||
protected LuaLibraryBase(Lua lua, Action<string> logOutputCallback)
|
||||
: this(lua)
|
||||
{
|
||||
LogOutputCallback = logOutputCallback;
|
||||
}
|
||||
|
||||
public abstract string Name { get; }
|
||||
public Action<string> LogOutputCallback { get; set; }
|
||||
public Lua Lua { get; set; }
|
||||
protected static Lua CurrentThread { get; private set; }
|
||||
|
||||
public static Lua CurrentThread { get; private set; }
|
||||
static Thread CurrentHostThread;
|
||||
static object ThreadMutex = new object();
|
||||
private static Thread CurrentHostThread;
|
||||
private static readonly object ThreadMutex = new object();
|
||||
|
||||
public abstract string Name { get; }
|
||||
public Action<string> LogOutputCallback { protected get; set; }
|
||||
protected Lua Lua { get; }
|
||||
|
||||
public static void ClearCurrentThread()
|
||||
{
|
||||
|
@ -52,31 +53,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
protected void Log(object message)
|
||||
{
|
||||
LogOutputCallback?.Invoke(message.ToString());
|
||||
}
|
||||
|
||||
public virtual void LuaRegister(Type callingLibrary, LuaDocumentation docs = null)
|
||||
{
|
||||
Lua.NewTable(Name);
|
||||
|
||||
var luaAttr = typeof(LuaMethodAttributes);
|
||||
|
||||
var methods = GetType()
|
||||
.GetMethods()
|
||||
.Where(m => m.GetCustomAttributes(luaAttr, false).Any());
|
||||
|
||||
foreach (var method in methods)
|
||||
{
|
||||
var luaMethodAttr = method.GetCustomAttributes(luaAttr, false).First() as LuaMethodAttributes;
|
||||
var luaName = Name + "." + luaMethodAttr.Name;
|
||||
Lua.RegisterFunction(luaName, this, method);
|
||||
|
||||
docs?.Add(new LibraryFunction(Name, callingLibrary.Description(), method));
|
||||
}
|
||||
}
|
||||
|
||||
protected static int LuaInt(object luaArg)
|
||||
{
|
||||
return (int)(double)luaArg;
|
||||
|
@ -94,8 +70,7 @@ namespace BizHawk.Client.Common
|
|||
return null;
|
||||
}
|
||||
|
||||
double tryNum = double.NaN;
|
||||
|
||||
double tryNum;
|
||||
var result = double.TryParse(color.ToString(), out tryNum);
|
||||
|
||||
if (result)
|
||||
|
@ -111,5 +86,30 @@ namespace BizHawk.Client.Common
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void Log(object message)
|
||||
{
|
||||
LogOutputCallback?.Invoke(message.ToString());
|
||||
}
|
||||
|
||||
public void LuaRegister(Type callingLibrary, LuaDocumentation docs = null)
|
||||
{
|
||||
Lua.NewTable(Name);
|
||||
|
||||
var luaAttr = typeof(LuaMethodAttributes);
|
||||
|
||||
var methods = GetType()
|
||||
.GetMethods()
|
||||
.Where(m => m.GetCustomAttributes(luaAttr, false).Any());
|
||||
|
||||
foreach (var method in methods)
|
||||
{
|
||||
var luaMethodAttr = (LuaMethodAttributes)method.GetCustomAttributes(luaAttr, false).First();
|
||||
var luaName = Name + "." + luaMethodAttr.Name;
|
||||
Lua.RegisterFunction(luaName, this, method);
|
||||
|
||||
docs?.Add(new LibraryFunction(Name, callingLibrary.Description(), method));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,11 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the queued movie
|
||||
/// When initializing a movie, it will be stored here until Rom processes have been completed, then it will be moved to the Movie property
|
||||
/// If an existing movie is still active, it will remain in the Movie property while the new movie is queued
|
||||
/// </summary>
|
||||
public IMovie QueuedMovie { get; set; }
|
||||
public IMovie QueuedMovie { get; private set; }
|
||||
|
||||
// This wrapper but the logic could change, don't make the client code understand these details
|
||||
public bool MovieIsQueued => QueuedMovie != null;
|
||||
|
@ -95,7 +96,7 @@ namespace BizHawk.Client.Common
|
|||
MessageCallback?.Invoke(message);
|
||||
}
|
||||
|
||||
public void LatchMultitrackPlayerInput(IController playerSource, MultitrackRewiringControllerAdapter rewiredSource)
|
||||
private void LatchMultitrackPlayerInput(IController playerSource, MultitrackRewiringControllerAdapter rewiredSource)
|
||||
{
|
||||
if (MultiTrack.IsActive)
|
||||
{
|
||||
|
@ -435,7 +436,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
// Movie Load Refactor TODO: a better name
|
||||
/// <summary>
|
||||
/// Sets the Movie property with the QueuedMovie, clears the queued movie, and starts the new movie
|
||||
/// </summary>
|
||||
|
|
|
@ -10,75 +10,75 @@ namespace BizHawk.Client.Common
|
|||
// are we collecting them anywhere else? for avi-writing code perhaps?
|
||||
|
||||
// just some constants, according to specs
|
||||
private static readonly double PAL_CARRIER = 15625 * 283.75 + 25; // 4.43361875 MHz
|
||||
private static readonly double NTSC_CARRIER = 4500000 * 227.5 / 286; // 3.579545454... MHz
|
||||
private static readonly double PAL_N_CARRIER = 15625 * 229.25 + 25; // 3.58205625 MHz
|
||||
private static readonly double PALCarrier = (15625 * 283.75) + 25; // 4.43361875 MHz
|
||||
private static readonly double NTSCCarrier = 4500000 * 227.5 / 286; // 3.579545454... MHz
|
||||
private static readonly double PALNCarrier = (15625 * 229.25) + 25; // 3.58205625 MHz
|
||||
|
||||
private static readonly Dictionary<string, double> _rates = new Dictionary<string, double>
|
||||
{
|
||||
{ "NES", 60.098813897440515532 }, // discussion here: http://forums.nesdev.com/viewtopic.php?t=492 ; a rational expression would be (19687500 / 11) / ((341*262-0.529780.5)/3) -> (118125000 / 1965513) -> 60.098813897440515529533511098629 (so our chosen number is very close)
|
||||
{ "NES_PAL", 50.006977968268290849 },
|
||||
{ "FDS", 60.098813897440515532 },
|
||||
{ "FDS_PAL", 50.006977968268290849 },
|
||||
{ "SNES", (double)21477272 / (4 * 341 * 262) }, // 60.098475521
|
||||
{ "SNES_PAL", (double)21281370 / (4 * 341 * 312) }, // 50.0069789082
|
||||
{ "SGB", (double)21477272 / (4 * 341 * 262) }, // 60.098475521
|
||||
{ "SGB_PAL", (double)21281370 / (4 * 341 * 312) }, // 50.0069789082
|
||||
{ "PCE", (7159090.90909090 / 455 / 263) }, // 59.8261054535
|
||||
{ "PCECD", (7159090.90909090 / 455 / 263) }, // 59.8261054535
|
||||
{ "SMS", (3579545 / 262.0 / 228.0) }, // 59.9227434043
|
||||
{ "SMS_PAL", (3546893 / 313.0 / 228.0) }, // 49.7014320946
|
||||
{ "GG", (3579545 / 262.0 / 228.0) }, // 59.9227434043
|
||||
{ "GG_PAL", (3546893 / 313.0 / 228.0) }, // 49.7014320946
|
||||
{ "SG", (3579545 / 262.0 / 228.0) }, // 59.9227434043
|
||||
{ "SG_PAL", (3546893 / 313.0 / 228.0) }, // 49.7014320946
|
||||
{ "NGP", (6144000.0 / (515 * 198)) }, // 60.2530155928
|
||||
{ "VBOY", (20000000.0 / (259 * 384 * 4)) }, // 50.2734877735
|
||||
{ "Lynx", 16000000.0 / (16 * 105 * 159) }, // 59.89817310572028
|
||||
{ "WSWAN", (3072000.0 / (159 * 256)) }, // 75.4716981132
|
||||
{ "GB", 262144.0 / 4389.0 }, // 59.7275005696
|
||||
{ "GBC", 262144.0 / 4389.0 }, // 59.7275005696
|
||||
{ "GBA", 262144.0 / 4389.0 }, // 59.7275005696
|
||||
{ "GEN", 53693175 / (3420.0 * 262) },
|
||||
{ "GEN_PAL", 53203424 / (3420.0 * 313) },
|
||||
private static readonly Dictionary<string, double> Rates = new Dictionary<string, double>
|
||||
{
|
||||
["NES"] = 60.098813897440515532, // discussion here: http://forums.nesdev.com/viewtopic.php?t=492 ; a rational expression would be (19687500 / 11) / ((341*262-0.529780.5)/3) -> (118125000 / 1965513) -> 60.098813897440515529533511098629 (so our chosen number is very close)
|
||||
["NES_PAL"] = 50.006977968268290849,
|
||||
["FDS"] = 60.098813897440515532,
|
||||
["FDS_PAL"] = 50.006977968268290849,
|
||||
["SNES"] = (double)21477272 / (4 * 341 * 262), // 60.098475521
|
||||
["SNES_PAL"] = (double)21281370 / (4 * 341 * 312), // 50.0069789082
|
||||
["SGB"] = (double)21477272 / (4 * 341 * 262), // 60.098475521
|
||||
["SGB_PAL"] = (double)21281370 / (4 * 341 * 312), // 50.0069789082
|
||||
["PCE"] = (7159090.90909090 / 455 / 263), // 59.8261054535
|
||||
["PCECD"] = (7159090.90909090 / 455 / 263), // 59.8261054535
|
||||
["SMS"] = (3579545 / 262.0 / 228.0), // 59.9227434043
|
||||
["SMS_PAL"] = (3546893 / 313.0 / 228.0), // 49.7014320946
|
||||
["GG"] = (3579545 / 262.0 / 228.0), // 59.9227434043
|
||||
["GG_PAL"] = (3546893 / 313.0 / 228.0), // 49.7014320946
|
||||
["SG"] = (3579545 / 262.0 / 228.0), // 59.9227434043
|
||||
["SG_PAL"] = (3546893 / 313.0 / 228.0), // 49.7014320946
|
||||
["NGP"] = (6144000.0 / (515 * 198)), // 60.2530155928
|
||||
["VBOY"] = (20000000.0 / (259 * 384 * 4)), // 50.2734877735
|
||||
["Lynx"] = 16000000.0 / (16 * 105 * 159), // 59.89817310572028
|
||||
["WSWAN"] = (3072000.0 / (159 * 256)), // 75.4716981132
|
||||
["GB"] = 262144.0 / 4389.0, // 59.7275005696
|
||||
["GBC"] = 262144.0 / 4389.0, // 59.7275005696
|
||||
["GBA"] = 262144.0 / 4389.0, // 59.7275005696
|
||||
["GEN"] = 53693175 / (3420.0 * 262),
|
||||
["GEN_PAL"] = 53203424 / (3420.0 * 313),
|
||||
|
||||
// while the number of scanlines per frame is software controlled and variable, we
|
||||
// enforce exactly 262 (NTSC) 312 (PAL) per reference time frame
|
||||
{ "A26", 315000000.0 / 88.0 / 262.0 / 228.0 }, // 59.922751013550531429197560173856
|
||||
// this pal clock ref is exact
|
||||
{ "A26_PAL", 3546895.0 / 312.0 / 228.0 }, // 49.860759671614934772829509671615
|
||||
// while the number of scanlines per frame is software controlled and variable, we
|
||||
// enforce exactly 262 (NTSC) 312 (PAL) per reference time frame
|
||||
["A26"] = 315000000.0 / 88.0 / 262.0 / 228.0, // 59.922751013550531429197560173856
|
||||
// this pal clock ref is exact
|
||||
["A26_PAL"] = 3546895.0 / 312.0 / 228.0, // 49.860759671614934772829509671615
|
||||
|
||||
{ "A78", 59.9227510135505 },
|
||||
{ "Coleco", 59.9227510135505 },
|
||||
["A78"] = 59.9227510135505,
|
||||
["Coleco"] = 59.9227510135505,
|
||||
|
||||
// according to http://problemkaputt.de/psx-spx.htm
|
||||
{ "PSX", 44100.0 * 768 * 11 / 7 / 263 / 3413 }, // 59.292862562
|
||||
{ "PSX_PAL", 44100.0 * 768 * 11 / 7 / 314 / 3406 }, // 49.7645593576
|
||||
// according to http://problemkaputt.de/psx-spx.htm
|
||||
["PSX"] = 44100.0 * 768 * 11 / 7 / 263 / 3413, // 59.292862562
|
||||
["PSX_PAL"] = 44100.0 * 768 * 11 / 7 / 314 / 3406, // 49.7645593576
|
||||
|
||||
{ "C64_PAL", PAL_CARRIER * 2 / 9 / 312 / 63 },
|
||||
{ "C64_NTSC", NTSC_CARRIER * 2 / 7 / 263 / 65 },
|
||||
{ "C64_NTSC_OLD", NTSC_CARRIER * 2 / 7 / 262 / 64 },
|
||||
{ "C64_DREAN", PAL_N_CARRIER * 2 / 7 / 312 / 65 },
|
||||
{ "INTV", 59.92 }
|
||||
["C64_PAL"] = PALCarrier * 2 / 9 / 312 / 63,
|
||||
["C64_NTSC"] = NTSCCarrier * 2 / 7 / 263 / 65,
|
||||
["C64_NTSC_OLD"] = NTSCCarrier * 2 / 7 / 262 / 64,
|
||||
["C64_DREAN"] = PALNCarrier * 2 / 7 / 312 / 65,
|
||||
["INTV"] = 59.92
|
||||
|
||||
// according to ryphecha, using
|
||||
// clocks[2] = { 53.693182e06, 53.203425e06 }; //ntsc console, pal console
|
||||
// lpf[2][2] = { { 263, 262.5 }, { 314, 312.5 } }; //ntsc,pal; noninterlaced, interlaced
|
||||
// cpl[2] = { 3412.5, 3405 }; //ntsc mode, pal mode
|
||||
// PAL PS1: 0, PAL Mode: 0, Interlaced: 0 --- 59.826106 (53.693182e06/(263*3412.5))
|
||||
// PAL PS1: 0, PAL Mode: 0, Interlaced: 1 --- 59.940060 (53.693182e06/(262.5*3412.5))
|
||||
// PAL PS1: 1, PAL Mode: 1, Interlaced: 0 --- 49.761427 (53.203425e06/(314*3405))
|
||||
// PAL PS1: 1, PAL Mode: 1, Interlaced: 1 --- 50.000282(53.203425e06/(312.5*3405))
|
||||
};
|
||||
// according to ryphecha, using
|
||||
// clocks[2] = { 53.693182e06, 53.203425e06 }; //ntsc console, pal console
|
||||
// lpf[2][2] = { { 263, 262.5 }, { 314, 312.5 } }; //ntsc,pal; noninterlaced, interlaced
|
||||
// cpl[2] = { 3412.5, 3405 }; //ntsc mode, pal mode
|
||||
// PAL PS1: 0, PAL Mode: 0, Interlaced: 0 --- 59.826106 (53.693182e06/(263*3412.5))
|
||||
// PAL PS1: 0, PAL Mode: 0, Interlaced: 1 --- 59.940060 (53.693182e06/(262.5*3412.5))
|
||||
// PAL PS1: 1, PAL Mode: 1, Interlaced: 0 --- 49.761427 (53.203425e06/(314*3405))
|
||||
// PAL PS1: 1, PAL Mode: 1, Interlaced: 1 --- 50.000282(53.203425e06/(312.5*3405))
|
||||
};
|
||||
|
||||
public double this[string systemId, bool pal]
|
||||
{
|
||||
get
|
||||
{
|
||||
var key = systemId + (pal ? "_PAL" : "");
|
||||
if (_rates.ContainsKey(key))
|
||||
if (Rates.ContainsKey(key))
|
||||
{
|
||||
return _rates[key];
|
||||
return Rates[key];
|
||||
}
|
||||
|
||||
return 60.0;
|
||||
|
|
|
@ -93,12 +93,8 @@ namespace BizHawk.Client.Common
|
|||
foreach (var button in playerSource.Definition.BoolButtons)
|
||||
{
|
||||
var bnp = ButtonNameParser.Parse(button);
|
||||
if (bnp == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bnp.PlayerNum != playerNum)
|
||||
if (bnp?.PlayerNum != playerNum)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -110,12 +106,8 @@ namespace BizHawk.Client.Common
|
|||
foreach (var button in Definition.FloatControls)
|
||||
{
|
||||
var bnp = ButtonNameParser.Parse(button);
|
||||
if (bnp == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bnp.PlayerNum != playerNum)
|
||||
if (bnp?.PlayerNum != playerNum)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -143,7 +135,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// latches sticky buttons from Global.AutofireStickyXORAdapter
|
||||
/// latches sticky buttons from <see cref="Global.AutofireStickyXORAdapter"/>
|
||||
/// </summary>
|
||||
public void LatchSticky()
|
||||
{
|
||||
|
@ -162,7 +154,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
var def = Global.Emulator.ControllerDefinition;
|
||||
var trimmed = mnemonic.Replace("|", "");
|
||||
var buttons = Definition.ControlsOrdered.SelectMany(x => x).ToList();
|
||||
var buttons = Definition.ControlsOrdered.SelectMany(c => c).ToList();
|
||||
var iterator = 0;
|
||||
|
||||
foreach (var key in buttons)
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace BizHawk.Client.Common
|
|||
/// A dumb-ish IStringLog with storage on disk with no provision for recovering lost space, except upon Clear()
|
||||
/// The purpose here is to avoid having too complicated buggy logic or a dependency on sqlite or such.
|
||||
/// It should be faster than those alternatives, but wasteful of disk space.
|
||||
/// It should also be easier to add new IList<string>-like methods than dealing with a database
|
||||
/// It should also be easier to add new IList<string>-like methods than dealing with a database
|
||||
/// </summary>
|
||||
internal class StreamStringLog : IStringLog
|
||||
{
|
||||
|
@ -132,6 +132,7 @@ namespace BizHawk.Client.Common
|
|||
stream.Position = Offsets[index];
|
||||
return br.ReadString();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
stream.Position = stream.Length;
|
||||
|
@ -179,8 +180,10 @@ namespace BizHawk.Client.Common
|
|||
index = log.Count;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void System.Collections.IEnumerator.Reset() { index = -1; }
|
||||
|
||||
public void Dispose() { }
|
||||
|
|
|
@ -33,12 +33,8 @@ namespace BizHawk.Client.Common
|
|||
foreach (var button in playerSource.Definition.BoolButtons)
|
||||
{
|
||||
var bnp = ButtonNameParser.Parse(button);
|
||||
if (bnp == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bnp.PlayerNum != playerNum)
|
||||
if (bnp?.PlayerNum != playerNum)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -144,8 +144,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
|||
}
|
||||
}
|
||||
|
||||
var tas = new TasMovie(newFilename, true);
|
||||
tas.BinarySavestate = savestate;
|
||||
var tas = new TasMovie(newFilename, true) { BinarySavestate = savestate };
|
||||
tas.ClearLagLog();
|
||||
|
||||
var entries = old.GetLogEntries();
|
||||
|
@ -220,8 +219,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
|||
}
|
||||
}
|
||||
|
||||
var tas = new TasMovie(newFilename, true);
|
||||
tas.SaveRam = saveRam;
|
||||
var tas = new TasMovie(newFilename, true) { SaveRam = saveRam };
|
||||
tas.TasStateManager.Clear();
|
||||
tas.ClearLagLog();
|
||||
|
||||
|
|
|
@ -181,6 +181,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return Convert.FromBase64String(blob.Substring(7));
|
||||
|
|
|
@ -347,7 +347,6 @@ namespace BizHawk.Client.Common
|
|||
string rightXRaw = new string(br.ReadChars(4)).Trim();
|
||||
string rightYRaw = new string(br.ReadChars(4)).Trim();
|
||||
|
||||
|
||||
Tuple<string, float> leftX = new Tuple<string, float>("P1 LStick X", float.Parse(leftXRaw));
|
||||
Tuple<string, float> leftY = new Tuple<string, float>("P1 LStick Y", float.Parse(leftYRaw));
|
||||
Tuple<string, float> rightX = new Tuple<string, float>("P1 RStick X", float.Parse(rightXRaw));
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
internal class StateManagerState : IDisposable
|
||||
{
|
||||
private static long _stateId = 0;
|
||||
private static long _stateId;
|
||||
private readonly TasStateManager _manager;
|
||||
private readonly long _id;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public partial class TasMovie
|
||||
{
|
||||
public TasMovieChangeLog ChangeLog;
|
||||
public TasMovieChangeLog ChangeLog { get; set; }
|
||||
|
||||
public override void RecordFrame(int frame, IController source)
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ namespace BizHawk.Client.Common
|
|||
bool endBatch = ChangeLog.BeginNewBatch("Remove Multiple Frames", true);
|
||||
ChangeLog.AddGeneralUndo(invalidateAfter, InputLogLength - 1);
|
||||
|
||||
foreach (var frame in frames.OrderByDescending(x => x)) // Removin them in reverse order allows us to remove by index;
|
||||
foreach (var frame in frames.OrderByDescending(f => f)) // Removing them in reverse order allows us to remove by index;
|
||||
{
|
||||
if (frame < _log.Count)
|
||||
{
|
||||
|
|
|
@ -230,7 +230,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (BranchStates.Any() && Settings.EraseBranchStatesFirst)
|
||||
{
|
||||
var kvp = BranchStates.Count() > 1 ? BranchStates.ElementAt(1) : BranchStates.ElementAt(0);
|
||||
var kvp = BranchStates.Count > 1 ? BranchStates.ElementAt(1) : BranchStates.ElementAt(0);
|
||||
shouldRemove.X = kvp.Key;
|
||||
shouldRemove.Y = kvp.Value.Keys[0];
|
||||
|
||||
|
@ -497,7 +497,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
List<KeyValuePair<int, StateManagerState>> statesToRemove =
|
||||
States.Where(x => x.Key >= frame).ToList();
|
||||
States.Where(s => s.Key >= frame).ToList();
|
||||
|
||||
anyInvalidated = statesToRemove.Any();
|
||||
|
||||
|
@ -873,7 +873,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
// Loop through branch states for the given frame.
|
||||
SortedList<int, StateManagerState> stateList = BranchStates[frame];
|
||||
for (int i = 0; i < stateList.Count(); i++)
|
||||
for (int i = 0; i < stateList.Count; i++)
|
||||
{
|
||||
// Don't check the branch containing the state to match.
|
||||
if (i == _movie.BranchIndexByHash(branchHash))
|
||||
|
@ -930,8 +930,8 @@ namespace BizHawk.Client.Common
|
|||
BranchStates[kvp.Key] = stateList;
|
||||
}
|
||||
|
||||
stateList.Add(branchHash, kvp.Value);
|
||||
// We aren't creating any new states, just adding a reference to an already-existing one; so Used doesn't need to be updated.
|
||||
stateList.Add(branchHash, kvp.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,11 +100,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void Clear()
|
||||
{
|
||||
if (_rewindBuffer != null)
|
||||
{
|
||||
_rewindBuffer.Clear();
|
||||
}
|
||||
|
||||
_rewindBuffer?.Clear();
|
||||
_lastState = new byte[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,14 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public class StreamBlobDatabase : IDisposable
|
||||
{
|
||||
private StreamBlobDatabaseBufferManager _mBufferManage;
|
||||
private readonly StreamBlobDatabaseBufferManager _mBufferManage;
|
||||
private readonly LinkedList<ListItem> _mBookmarks = new LinkedList<ListItem>();
|
||||
private readonly long _mCapacity;
|
||||
|
||||
private byte[] _mAllocatedBuffer;
|
||||
private Stream _mStream;
|
||||
private LinkedList<ListItem> _mBookmarks = new LinkedList<ListItem>();
|
||||
private LinkedListNode<ListItem> _mHead, _mTail;
|
||||
private long _mCapacity, _mSize;
|
||||
private long _mSize;
|
||||
|
||||
public StreamBlobDatabase(bool onDisk, long capacity, StreamBlobDatabaseBufferManager mBufferManage)
|
||||
{
|
||||
|
@ -42,22 +44,22 @@ namespace BizHawk.Client.Common
|
|||
/// <summary>
|
||||
/// Gets the amount of the buffer that's used
|
||||
/// </summary>
|
||||
public long Size { get { return _mSize; } }
|
||||
public long Size => _mSize;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current fullness ratio (Size/Capacity). Note that this wont reach 100% due to the buffer size not being a multiple of a fixed savestate size.
|
||||
/// </summary>
|
||||
public float FullnessRatio { get { return (float)((double)Size / (double)_mCapacity); } }
|
||||
public float FullnessRatio => (float)((double)Size / (double)_mCapacity);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of frames stored here
|
||||
/// </summary>
|
||||
public int Count { get { return _mBookmarks.Count; } }
|
||||
public int Count => _mBookmarks.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the underlying stream to
|
||||
/// </summary>
|
||||
public Stream Stream { get { return _mStream; } }
|
||||
public Stream Stream => _mStream;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
@ -79,7 +81,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The push and pop semantics are for historical reasons and not resemblence to normal definitions
|
||||
/// The push and pop semantics are for historical reasons and not resemblance to normal definitions
|
||||
/// </summary>
|
||||
public void Push(ArraySegment<byte> seg)
|
||||
{
|
||||
|
@ -91,7 +93,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The push and pop semantics are for historical reasons and not resemblence to normal definitions
|
||||
/// The push and pop semantics are for historical reasons and not resemblance to normal definitions
|
||||
/// </summary>
|
||||
public MemoryStream PopMemoryStream()
|
||||
{
|
||||
|
@ -276,14 +278,11 @@ namespace BizHawk.Client.Common
|
|||
Length = length;
|
||||
}
|
||||
|
||||
public int Timestamp { get; private set; }
|
||||
public long Index { get; private set; }
|
||||
public int Length { get; private set; }
|
||||
public int Timestamp { get; }
|
||||
public long Index { get; }
|
||||
public int Length { get; }
|
||||
|
||||
public long EndExclusive
|
||||
{
|
||||
get { return Index + Length; }
|
||||
}
|
||||
public long EndExclusive => Index + Length;
|
||||
}
|
||||
|
||||
private static byte[] test_BufferManage(byte[] inbuf, ref long size, bool allocate)
|
||||
|
@ -306,7 +305,7 @@ namespace BizHawk.Client.Common
|
|||
return null;
|
||||
}
|
||||
|
||||
static byte[] test_rewindFellationBuf;
|
||||
private static byte[] test_rewindFellationBuf;
|
||||
|
||||
private static void test(string[] args)
|
||||
{
|
||||
|
|
|
@ -25,12 +25,12 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public int CheatCount
|
||||
{
|
||||
get { return _cheatList.Count(x => !x.IsSeparator); }
|
||||
get { return _cheatList.Count(c => !c.IsSeparator); }
|
||||
}
|
||||
|
||||
public int ActiveCount
|
||||
{
|
||||
get { return _cheatList.Count(x => x.Enabled); }
|
||||
get { return _cheatList.Count(c => c.Enabled); }
|
||||
}
|
||||
|
||||
public bool Changes
|
||||
|
@ -124,7 +124,7 @@ namespace BizHawk.Client.Common
|
|||
cheat.Changed += CheatChanged;
|
||||
if (Contains(cheat))
|
||||
{
|
||||
_cheatList.Remove(Global.CheatList.FirstOrDefault(x => x.Domain == cheat.Domain && x.Address == cheat.Address));
|
||||
_cheatList.Remove(Global.CheatList.FirstOrDefault(c => c.Domain == cheat.Domain && c.Address == cheat.Address));
|
||||
}
|
||||
|
||||
_cheatList.Add(cheat);
|
||||
|
@ -140,16 +140,16 @@ namespace BizHawk.Client.Common
|
|||
Changes = true;
|
||||
}
|
||||
|
||||
public void Insert(int index, Cheat c)
|
||||
public void Insert(int index, Cheat cheat)
|
||||
{
|
||||
c.Changed += CheatChanged;
|
||||
if (_cheatList.Any(x => x.Domain == c.Domain && x.Address == c.Address))
|
||||
cheat.Changed += CheatChanged;
|
||||
if (_cheatList.Any(c => c.Domain == cheat.Domain && c.Address == cheat.Address))
|
||||
{
|
||||
_cheatList.First(x => x.Domain == c.Domain && x.Address == c.Address).Enable();
|
||||
_cheatList.First(c => c.Domain == cheat.Domain && c.Address == cheat.Address).Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cheatList.Insert(index, c);
|
||||
_cheatList.Insert(index, cheat);
|
||||
}
|
||||
|
||||
Changes = true;
|
||||
|
@ -169,9 +169,9 @@ namespace BizHawk.Client.Common
|
|||
return true;
|
||||
}
|
||||
|
||||
public bool Remove(Cheat c)
|
||||
public bool Remove(Cheat cheat)
|
||||
{
|
||||
var result = _cheatList.Remove(c);
|
||||
var result = _cheatList.Remove(cheat);
|
||||
if (result)
|
||||
{
|
||||
Changes = true;
|
||||
|
@ -516,15 +516,15 @@ namespace BizHawk.Client.Common
|
|||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderByDescending(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderByDescending(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -533,15 +533,15 @@ namespace BizHawk.Client.Common
|
|||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderByDescending(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Name)
|
||||
.OrderByDescending(c => c.Address ?? 0)
|
||||
.ThenBy(c => c.Name)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Name)
|
||||
.OrderBy(c => c.Address ?? 0)
|
||||
.ThenBy(c => c.Name)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -550,17 +550,17 @@ namespace BizHawk.Client.Common
|
|||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderByDescending(x => x.Value ?? 0)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderByDescending(c => c.Value ?? 0)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderBy(x => x.Value ?? 0)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderBy(c => c.Value ?? 0)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -569,17 +569,17 @@ namespace BizHawk.Client.Common
|
|||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderByDescending(x => x.Compare ?? 0)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderByDescending(c => c.Compare ?? 0)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderBy(x => x.Compare ?? 0)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderBy(c => c.Compare ?? 0)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -588,17 +588,17 @@ namespace BizHawk.Client.Common
|
|||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderByDescending(x => x.Enabled)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderByDescending(c => c.Enabled)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderBy(x => x.Enabled)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderBy(c => c.Enabled)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -607,17 +607,17 @@ namespace BizHawk.Client.Common
|
|||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderByDescending(x => x.Domain)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderByDescending(c => c.Domain)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderBy(x => x.Domain)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderBy(c => c.Domain)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -626,17 +626,17 @@ namespace BizHawk.Client.Common
|
|||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderByDescending(x => ((int)x.Size))
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderByDescending(c => ((int)c.Size))
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderBy(x => ((int)x.Size))
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderBy(c => ((int)c.Size))
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -645,17 +645,17 @@ namespace BizHawk.Client.Common
|
|||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderByDescending(x => x.BigEndian)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderByDescending(c => c.BigEndian)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderBy(x => x.BigEndian)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderBy(c => c.BigEndian)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -664,17 +664,17 @@ namespace BizHawk.Client.Common
|
|||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderByDescending(x => x.Type)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderByDescending(c => c.Type)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderBy(x => x.Type)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderBy(c => c.Type)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -683,17 +683,17 @@ namespace BizHawk.Client.Common
|
|||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderByDescending(x => x.ComparisonType)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderByDescending(c => c.ComparisonType)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
.OrderBy(x => x.ComparisonType)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.OrderBy(c => c.ComparisonType)
|
||||
.ThenBy(c => c.Name)
|
||||
.ThenBy(c => c.Address ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -722,15 +722,15 @@ namespace BizHawk.Client.Common
|
|||
public Cheat Cheat { get; private set; }
|
||||
}
|
||||
|
||||
public const string NAME = "NamesColumn";
|
||||
public const string ADDRESS = "AddressColumn";
|
||||
public const string VALUE = "ValueColumn";
|
||||
public const string COMPARE = "CompareColumn";
|
||||
public const string ON = "OnColumn";
|
||||
public const string DOMAIN = "DomainColumn";
|
||||
public const string SIZE = "SizeColumn";
|
||||
public const string ENDIAN = "EndianColumn";
|
||||
public const string TYPE = "DisplayTypeColumn";
|
||||
private const string NAME = "NamesColumn";
|
||||
private const string ADDRESS = "AddressColumn";
|
||||
private const string VALUE = "ValueColumn";
|
||||
private const string COMPARE = "CompareColumn";
|
||||
private const string ON = "OnColumn";
|
||||
private const string DOMAIN = "DomainColumn";
|
||||
private const string SIZE = "SizeColumn";
|
||||
private const string ENDIAN = "EndianColumn";
|
||||
private const string TYPE = "DisplayTypeColumn";
|
||||
private const string COMPARISONTYPE = "ComparisonTypeColumn";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ using BizHawk.Common;
|
|||
using BizHawk.Common.CollectionExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
// ReSharper disable PossibleInvalidCastExceptionInForeachLoop
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class RamSearchEngine
|
||||
|
@ -34,14 +35,16 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public RamSearchEngine(Settings settings, IMemoryDomains memoryDomains)
|
||||
{
|
||||
_settings = new Settings(memoryDomains);
|
||||
_settings.Mode = settings.Mode;
|
||||
_settings.Domain = settings.Domain;
|
||||
_settings.Size = settings.Size;
|
||||
_settings.CheckMisAligned = settings.CheckMisAligned;
|
||||
_settings.Type = settings.Type;
|
||||
_settings.BigEndian = settings.BigEndian;
|
||||
_settings.PreviousType = settings.PreviousType;
|
||||
_settings = new Settings(memoryDomains)
|
||||
{
|
||||
Mode = settings.Mode,
|
||||
Domain = settings.Domain,
|
||||
Size = settings.Size,
|
||||
CheckMisAligned = settings.CheckMisAligned,
|
||||
Type = settings.Type,
|
||||
BigEndian = settings.BigEndian,
|
||||
PreviousType = settings.PreviousType
|
||||
};
|
||||
}
|
||||
|
||||
public RamSearchEngine(Settings settings, IMemoryDomains memoryDomains, Compare compareTo, long? compareValue, int? differentBy)
|
||||
|
@ -153,9 +156,8 @@ namespace BizHawk.Client.Common
|
|||
_watchList[index].Previous,
|
||||
(_watchList[index] as IMiniWatchDetails).ChangeCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Watch.GenerateWatch(
|
||||
|
||||
return Watch.GenerateWatch(
|
||||
_settings.Domain,
|
||||
_watchList[index].Address,
|
||||
_settings.Size,
|
||||
|
@ -163,9 +165,7 @@ namespace BizHawk.Client.Common
|
|||
_settings.BigEndian,
|
||||
"",
|
||||
0,
|
||||
_watchList[index].Previous,
|
||||
0);
|
||||
}
|
||||
_watchList[index].Previous);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,11 +212,11 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (_isSorted)
|
||||
{
|
||||
listOfOne = Enumerable.Repeat(_watchList.BinarySearch(x => x.Address, address), 1);
|
||||
listOfOne = Enumerable.Repeat(_watchList.BinarySearch(w => w.Address, address), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
listOfOne = Enumerable.Repeat(_watchList.FirstOrDefault(x => x.Address == address), 1);
|
||||
listOfOne = Enumerable.Repeat(_watchList.FirstOrDefault(w => w.Address == address), 1);
|
||||
}
|
||||
|
||||
switch (_compareTo)
|
||||
|
@ -235,19 +235,13 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return _watchList.Count; }
|
||||
}
|
||||
public int Count => _watchList.Count;
|
||||
|
||||
public Settings.SearchMode Mode { get { return _settings.Mode; } }
|
||||
public Settings.SearchMode Mode => _settings.Mode;
|
||||
|
||||
public MemoryDomain Domain
|
||||
{
|
||||
get { return _settings.Domain; }
|
||||
}
|
||||
public MemoryDomain Domain => _settings.Domain;
|
||||
|
||||
public Compare CompareTo
|
||||
public Compare CompareTo
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -294,10 +288,6 @@ namespace BizHawk.Client.Common
|
|||
watch.Update(_settings.PreviousType, _settings.Domain, _settings.BigEndian);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetType(DisplayType type)
|
||||
|
@ -325,7 +315,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void SetPreviousToCurrent()
|
||||
{
|
||||
_watchList.ForEach(x => x.SetPreviousToCurrent(_settings.Domain, _settings.BigEndian));
|
||||
_watchList.ForEach(w => w.SetPreviousToCurrent(_settings.Domain, _settings.BigEndian));
|
||||
}
|
||||
|
||||
public void ClearChangeCounts()
|
||||
|
@ -350,8 +340,8 @@ namespace BizHawk.Client.Common
|
|||
_history.AddState(_watchList);
|
||||
}
|
||||
|
||||
var addresses = watches.Select(x => x.Address);
|
||||
var removeList = _watchList.Where(x => addresses.Contains(x.Address)).ToList();
|
||||
var addresses = watches.Select(w => w.Address);
|
||||
var removeList = _watchList.Where(w => addresses.Contains(w.Address)).ToList();
|
||||
_watchList = _watchList.Except(removeList).ToList();
|
||||
}
|
||||
|
||||
|
@ -438,35 +428,25 @@ namespace BizHawk.Client.Common
|
|||
case WatchList.ADDRESS:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList.OrderByDescending(x => x.Address).ToList();
|
||||
_watchList = _watchList.OrderByDescending(w => w.Address).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList.OrderBy(x => x.Address).ToList();
|
||||
_watchList = _watchList.OrderBy(w => w.Address).ToList();
|
||||
_isSorted = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case WatchList.VALUE:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList.OrderByDescending(x => GetValue(x.Address)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList.OrderBy(x => GetValue(x.Address)).ToList();
|
||||
}
|
||||
_watchList = reverse
|
||||
? _watchList.OrderByDescending(w => GetValue(w.Address)).ToList()
|
||||
: _watchList.OrderBy(w => GetValue(w.Address)).ToList();
|
||||
|
||||
break;
|
||||
case WatchList.PREV:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList.OrderByDescending(x => x.Previous).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList.OrderBy(x => x.Previous).ToList();
|
||||
}
|
||||
_watchList = reverse
|
||||
? _watchList.OrderByDescending(w => w.Previous).ToList()
|
||||
: _watchList.OrderBy(w => w.Previous).ToList();
|
||||
|
||||
break;
|
||||
case WatchList.CHANGES:
|
||||
|
@ -476,28 +456,23 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
_watchList = _watchList
|
||||
.Cast<IMiniWatchDetails>()
|
||||
.OrderByDescending(x => x.ChangeCount)
|
||||
.OrderByDescending(w => w.ChangeCount)
|
||||
.Cast<IMiniWatch>().ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.Cast<IMiniWatchDetails>()
|
||||
.OrderBy(x => x.ChangeCount)
|
||||
.OrderBy(w => w.ChangeCount)
|
||||
.Cast<IMiniWatch>().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case WatchList.DIFF:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList.OrderByDescending(x => (GetValue(x.Address) - x.Previous)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList.OrderBy(x => (GetValue(x.Address) - x.Previous)).ToList();
|
||||
}
|
||||
_watchList = reverse
|
||||
? _watchList.OrderByDescending(w => (GetValue(w.Address) - w.Previous)).ToList()
|
||||
: _watchList.OrderBy(w => GetValue(w.Address) - w.Previous).ToList();
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -556,56 +531,57 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
default:
|
||||
case ComparisonOperator.Equal:
|
||||
return watchList.Where(x => GetValue(x.Address) == x.Previous);
|
||||
return watchList.Where(w => GetValue(w.Address) == w.Previous);
|
||||
case ComparisonOperator.NotEqual:
|
||||
return watchList.Where(x => GetValue(x.Address) != x.Previous);
|
||||
return watchList.Where(w => GetValue(w.Address) != w.Previous);
|
||||
|
||||
case ComparisonOperator.GreaterThan:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => ToFloat(GetValue(x.Address)) > ToFloat(x.Previous));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) > ToFloat(w.Previous));
|
||||
}
|
||||
|
||||
return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) > SignExtendAsNeeded(x.Previous));
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) > SignExtendAsNeeded(w.Previous));
|
||||
|
||||
case ComparisonOperator.GreaterThanEqual:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => ToFloat(GetValue(x.Address)) >= ToFloat(x.Previous));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) >= ToFloat(w.Previous));
|
||||
}
|
||||
|
||||
return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) >= SignExtendAsNeeded(x.Previous));
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) >= SignExtendAsNeeded(w.Previous));
|
||||
|
||||
case ComparisonOperator.LessThan:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => ToFloat(GetValue(x.Address)) < ToFloat(x.Previous));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) < ToFloat(w.Previous));
|
||||
}
|
||||
|
||||
return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) < SignExtendAsNeeded(x.Previous));
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) < SignExtendAsNeeded(w.Previous));
|
||||
|
||||
case ComparisonOperator.LessThanEqual:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => ToFloat(GetValue(x.Address)) <= ToFloat(x.Previous));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) <= ToFloat(w.Previous));
|
||||
}
|
||||
|
||||
return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) <= SignExtendAsNeeded(x.Previous));
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) <= SignExtendAsNeeded(w.Previous));
|
||||
|
||||
case ComparisonOperator.DifferentBy:
|
||||
if (_differentBy.HasValue)
|
||||
{
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => (ToFloat(GetValue(x.Address)) + _differentBy.Value == ToFloat(x.Previous))
|
||||
|| (ToFloat(GetValue(x.Address)) - _differentBy.Value == ToFloat(x.Previous)));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) + _differentBy.Value == ToFloat(w.Previous)
|
||||
|| ToFloat(GetValue(w.Address)) - _differentBy.Value == ToFloat(w.Previous));
|
||||
}
|
||||
|
||||
return watchList.Where(x =>
|
||||
return watchList.Where(w =>
|
||||
{
|
||||
long val = SignExtendAsNeeded(GetValue(x.Address));
|
||||
long prev = SignExtendAsNeeded(x.Previous);
|
||||
return (val + _differentBy.Value == prev) || (val - _differentBy.Value == prev);
|
||||
long val = SignExtendAsNeeded(GetValue(w.Address));
|
||||
long prev = SignExtendAsNeeded(w.Previous);
|
||||
return val + _differentBy.Value == prev
|
||||
|| val - _differentBy.Value == prev;
|
||||
});
|
||||
}
|
||||
else
|
||||
|
@ -625,58 +601,58 @@ namespace BizHawk.Client.Common
|
|||
case ComparisonOperator.Equal:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => ToFloat(GetValue(x.Address)) == ToFloat(_compareValue.Value));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) == ToFloat(_compareValue.Value));
|
||||
}
|
||||
|
||||
return watchList.Where(x => GetValue(x.Address) == _compareValue.Value);
|
||||
return watchList.Where(w => GetValue(w.Address) == _compareValue.Value);
|
||||
case ComparisonOperator.NotEqual:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => ToFloat(GetValue(x.Address)) != ToFloat(_compareValue.Value));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) != ToFloat(_compareValue.Value));
|
||||
}
|
||||
|
||||
return watchList.Where(x => GetValue(x.Address) != _compareValue.Value);
|
||||
return watchList.Where(w => GetValue(w.Address) != _compareValue.Value);
|
||||
|
||||
case ComparisonOperator.GreaterThan:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => ToFloat(GetValue(x.Address)) > ToFloat(_compareValue.Value));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) > ToFloat(_compareValue.Value));
|
||||
}
|
||||
|
||||
return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) > _compareValue.Value);
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) > _compareValue.Value);
|
||||
case ComparisonOperator.GreaterThanEqual:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => ToFloat(GetValue(x.Address)) >= ToFloat(_compareValue.Value));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) >= ToFloat(_compareValue.Value));
|
||||
}
|
||||
|
||||
return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) >= _compareValue.Value);
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) >= _compareValue.Value);
|
||||
case ComparisonOperator.LessThan:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => ToFloat(GetValue(x.Address)) < ToFloat(_compareValue.Value));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) < ToFloat(_compareValue.Value));
|
||||
}
|
||||
|
||||
return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) < _compareValue.Value);
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) < _compareValue.Value);
|
||||
case ComparisonOperator.LessThanEqual:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => ToFloat(GetValue(x.Address)) <= ToFloat(_compareValue.Value));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) <= ToFloat(_compareValue.Value));
|
||||
}
|
||||
|
||||
return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) <= _compareValue.Value);
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) <= _compareValue.Value);
|
||||
case ComparisonOperator.DifferentBy:
|
||||
if (_differentBy.HasValue)
|
||||
{
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => (ToFloat(GetValue(x.Address)) + _differentBy.Value == _compareValue.Value) ||
|
||||
(ToFloat(GetValue(x.Address)) - _differentBy.Value == _compareValue.Value));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) + _differentBy.Value == _compareValue.Value
|
||||
|| ToFloat(GetValue(w.Address)) - _differentBy.Value == _compareValue.Value);
|
||||
}
|
||||
|
||||
return watchList.Where(x
|
||||
=> (SignExtendAsNeeded(GetValue(x.Address)) + _differentBy.Value == _compareValue.Value)
|
||||
|| (SignExtendAsNeeded(GetValue(x.Address)) - _differentBy.Value == _compareValue.Value));
|
||||
return watchList.Where(w
|
||||
=> SignExtendAsNeeded(GetValue(w.Address)) + _differentBy.Value == _compareValue.Value
|
||||
|| SignExtendAsNeeded(GetValue(w.Address)) - _differentBy.Value == _compareValue.Value);
|
||||
}
|
||||
|
||||
throw new InvalidOperationException();
|
||||
|
@ -694,21 +670,22 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
default:
|
||||
case ComparisonOperator.Equal:
|
||||
return watchList.Where(x => x.Address == _compareValue.Value);
|
||||
return watchList.Where(w => w.Address == _compareValue.Value);
|
||||
case ComparisonOperator.NotEqual:
|
||||
return watchList.Where(x => x.Address != _compareValue.Value);
|
||||
return watchList.Where(w => w.Address != _compareValue.Value);
|
||||
case ComparisonOperator.GreaterThan:
|
||||
return watchList.Where(x => x.Address > _compareValue.Value);
|
||||
return watchList.Where(w => w.Address > _compareValue.Value);
|
||||
case ComparisonOperator.GreaterThanEqual:
|
||||
return watchList.Where(x => x.Address >= _compareValue.Value);
|
||||
return watchList.Where(w => w.Address >= _compareValue.Value);
|
||||
case ComparisonOperator.LessThan:
|
||||
return watchList.Where(x => x.Address < _compareValue.Value);
|
||||
return watchList.Where(w => w.Address < _compareValue.Value);
|
||||
case ComparisonOperator.LessThanEqual:
|
||||
return watchList.Where(x => x.Address <= _compareValue.Value);
|
||||
return watchList.Where(w => w.Address <= _compareValue.Value);
|
||||
case ComparisonOperator.DifferentBy:
|
||||
if (_differentBy.HasValue)
|
||||
{
|
||||
return watchList.Where(x => (x.Address + _differentBy.Value == _compareValue.Value) || (x.Address - _differentBy.Value == _compareValue.Value));
|
||||
return watchList.Where(w => w.Address + _differentBy.Value == _compareValue.Value
|
||||
|| w.Address - _differentBy.Value == _compareValue.Value);
|
||||
}
|
||||
|
||||
throw new InvalidOperationException();
|
||||
|
@ -728,39 +705,40 @@ namespace BizHawk.Client.Common
|
|||
case ComparisonOperator.Equal:
|
||||
return watchList
|
||||
.Cast<IMiniWatchDetails>()
|
||||
.Where(x => x.ChangeCount == _compareValue.Value)
|
||||
.Where(w => w.ChangeCount == _compareValue.Value)
|
||||
.Cast<IMiniWatch>();
|
||||
case ComparisonOperator.NotEqual:
|
||||
return watchList
|
||||
.Cast<IMiniWatchDetails>()
|
||||
.Where(x => x.ChangeCount != _compareValue.Value)
|
||||
.Where(w => w.ChangeCount != _compareValue.Value)
|
||||
.Cast<IMiniWatch>();
|
||||
case ComparisonOperator.GreaterThan:
|
||||
return watchList
|
||||
.Cast<IMiniWatchDetails>()
|
||||
.Where(x => x.ChangeCount > _compareValue.Value)
|
||||
.Where(w => w.ChangeCount > _compareValue.Value)
|
||||
.Cast<IMiniWatch>();
|
||||
case ComparisonOperator.GreaterThanEqual:
|
||||
return watchList
|
||||
.Cast<IMiniWatchDetails>()
|
||||
.Where(x => x.ChangeCount >= _compareValue.Value)
|
||||
.Where(w => w.ChangeCount >= _compareValue.Value)
|
||||
.Cast<IMiniWatch>();
|
||||
case ComparisonOperator.LessThan:
|
||||
return watchList
|
||||
.Cast<IMiniWatchDetails>()
|
||||
.Where(x => x.ChangeCount < _compareValue.Value)
|
||||
.Where(w => w.ChangeCount < _compareValue.Value)
|
||||
.Cast<IMiniWatch>();
|
||||
case ComparisonOperator.LessThanEqual:
|
||||
return watchList
|
||||
.Cast<IMiniWatchDetails>()
|
||||
.Where(x => x.ChangeCount <= _compareValue.Value)
|
||||
.Where(w => w.ChangeCount <= _compareValue.Value)
|
||||
.Cast<IMiniWatch>();
|
||||
case ComparisonOperator.DifferentBy:
|
||||
if (_differentBy.HasValue)
|
||||
{
|
||||
return watchList
|
||||
.Cast<IMiniWatchDetails>()
|
||||
.Where(x => (x.ChangeCount + _differentBy.Value == _compareValue.Value) || (x.ChangeCount - _differentBy.Value == _compareValue.Value))
|
||||
.Where(w => w.ChangeCount + _differentBy.Value == _compareValue.Value
|
||||
|| w.ChangeCount - _differentBy.Value == _compareValue.Value)
|
||||
.Cast<IMiniWatch>();
|
||||
}
|
||||
|
||||
|
@ -781,57 +759,57 @@ namespace BizHawk.Client.Common
|
|||
case ComparisonOperator.Equal:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => (ToFloat(GetValue(x.Address)) - ToFloat(x.Previous)) == _compareValue.Value);
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) - ToFloat(w.Previous) == _compareValue.Value);
|
||||
}
|
||||
|
||||
return watchList.Where(x => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous)) == _compareValue.Value);
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) == _compareValue.Value);
|
||||
case ComparisonOperator.NotEqual:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous) != _compareValue.Value);
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) - w.Previous != _compareValue.Value);
|
||||
}
|
||||
|
||||
return watchList.Where(x => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous)) != _compareValue.Value);
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) != _compareValue.Value);
|
||||
case ComparisonOperator.GreaterThan:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous) > _compareValue.Value);
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) - w.Previous > _compareValue.Value);
|
||||
}
|
||||
|
||||
return watchList.Where(x => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous)) > _compareValue.Value);
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) > _compareValue.Value);
|
||||
case ComparisonOperator.GreaterThanEqual:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous) >= _compareValue.Value);
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) - w.Previous >= _compareValue.Value);
|
||||
}
|
||||
|
||||
return watchList.Where(x => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous)) >= _compareValue.Value);
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) >= _compareValue.Value);
|
||||
case ComparisonOperator.LessThan:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous) < _compareValue.Value);
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) - w.Previous < _compareValue.Value);
|
||||
}
|
||||
|
||||
return watchList.Where(x => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous)) < _compareValue.Value);
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) < _compareValue.Value);
|
||||
case ComparisonOperator.LessThanEqual:
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous) <= _compareValue.Value);
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) - w.Previous <= _compareValue.Value);
|
||||
}
|
||||
|
||||
return watchList.Where(x => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous)) <= _compareValue.Value);
|
||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) <= _compareValue.Value);
|
||||
case ComparisonOperator.DifferentBy:
|
||||
if (_differentBy.HasValue)
|
||||
{
|
||||
if (_settings.Type == DisplayType.Float)
|
||||
{
|
||||
return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous + _differentBy.Value == _compareValue) ||
|
||||
(ToFloat(GetValue(x.Address)) - x.Previous - _differentBy.Value == x.Previous));
|
||||
return watchList.Where(w => ToFloat(GetValue(w.Address)) - w.Previous + _differentBy.Value == _compareValue
|
||||
|| ToFloat(GetValue(w.Address)) - w.Previous - _differentBy.Value == w.Previous);
|
||||
}
|
||||
|
||||
return watchList.Where(x
|
||||
=> (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous) + _differentBy.Value == _compareValue)
|
||||
|| (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous) - _differentBy.Value == _compareValue));
|
||||
return watchList.Where(w
|
||||
=> SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) + _differentBy.Value == _compareValue
|
||||
|| SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) - _differentBy.Value == _compareValue);
|
||||
}
|
||||
|
||||
throw new InvalidOperationException();
|
||||
|
@ -906,7 +884,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
#region Classes
|
||||
|
||||
public interface IMiniWatch
|
||||
private interface IMiniWatch
|
||||
{
|
||||
long Address { get; }
|
||||
long Previous { get; } // do not store sign extended variables in here.
|
||||
|
@ -923,7 +901,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private sealed class MiniByteWatch : IMiniWatch
|
||||
{
|
||||
public long Address { get; private set; }
|
||||
public long Address { get; }
|
||||
private byte _previous;
|
||||
|
||||
public MiniByteWatch(MemoryDomain domain, long addr)
|
||||
|
@ -942,7 +920,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private sealed class MiniWordWatch : IMiniWatch
|
||||
{
|
||||
public long Address { get; private set; }
|
||||
public long Address { get; }
|
||||
private ushort _previous;
|
||||
|
||||
public MiniWordWatch(MemoryDomain domain, long addr, bool bigEndian)
|
||||
|
@ -951,10 +929,7 @@ namespace BizHawk.Client.Common
|
|||
_previous = domain.PeekUshort(Address % domain.Size, bigEndian);
|
||||
}
|
||||
|
||||
public long Previous
|
||||
{
|
||||
get { return _previous; }
|
||||
}
|
||||
public long Previous => _previous;
|
||||
|
||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
|
||||
{
|
||||
|
@ -962,7 +937,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public sealed class MiniDWordWatch : IMiniWatch
|
||||
private sealed class MiniDWordWatch : IMiniWatch
|
||||
{
|
||||
public long Address { get; }
|
||||
private uint _previous;
|
||||
|
@ -1096,7 +1071,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public sealed class MiniDWordWatchDetailed : IMiniWatch, IMiniWatchDetails
|
||||
private sealed class MiniDWordWatchDetailed : IMiniWatch, IMiniWatchDetails
|
||||
{
|
||||
public long Address { get; }
|
||||
|
||||
|
|
|
@ -8,8 +8,7 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public sealed partial class WatchList
|
||||
{
|
||||
private class WatchEqualityComparer
|
||||
: IEqualityComparer<Watch>
|
||||
private class WatchEqualityComparer : IEqualityComparer<Watch>
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines if two <see cref="Watch"/> are equals
|
||||
|
@ -25,23 +24,21 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (ReferenceEquals(y, null))
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ReferenceEquals(y, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (ReferenceEquals(x, y))
|
||||
}
|
||||
|
||||
if (ReferenceEquals(x, y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Emin_002Ejs/@EntryIndexedValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Emin_002Ejs/@EntryIndexRemoved">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=24A0AA3C_002DB25F_002D4197_002DB23D_002D476D6462DBA0_002Fd_003A7z/@EntryIndexedValue">ExplicitlyExcluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CanBeReplacedWithTryCastAndCheckForNull/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantCaseLabel/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantExtendsListEntry/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SpecifyACultureInStringConversionExplicitly/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
|
@ -26,6 +27,7 @@
|
|||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1122/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1126/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1200/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1204/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1309/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1402/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1502/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
|
@ -57,6 +59,7 @@
|
|||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GBC/@EntryIndexedValue">GBC</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GG/@EntryIndexedValue">GG</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GL/@EntryIndexedValue">GL</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=II/@EntryIndexedValue">II</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IO/@EntryIndexedValue">IO</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IPS/@EntryIndexedValue">IPS</s:String>
|
||||
|
|
Loading…
Reference in New Issue