diff --git a/BizHawk.Client.Common/BinarySaveStates.cs b/BizHawk.Client.Common/BinarySaveStates.cs
index 9ef4aa1023..f00d2f85b1 100644
--- a/BizHawk.Client.Common/BinarySaveStates.cs
+++ b/BizHawk.Client.Common/BinarySaveStates.cs
@@ -325,8 +325,7 @@ namespace BizHawk.Client.Common
public BinaryStateSaver(string path, bool notamovie = true) // notamovie is hack, really should have separate something
{
- _zip = new IonicZipWriter(path, notamovie ? Global.Config.SaveStateCompressionLevelNormal
- : Global.Config.MovieCompressionLevel);
+ _zip = new IonicZipWriter(path, notamovie ? Global.Config.SaveStateCompressionLevelNormal : Global.Config.MovieCompressionLevel);
////_zip = new SharpZipWriter(path, Global.Config.SaveStateCompressionLevelNormal);
////_zip = new SevenZipWriter(path, Global.Config.SaveStateCompressionLevelNormal);
diff --git a/BizHawk.Client.Common/CoreFileProvider.cs b/BizHawk.Client.Common/CoreFileProvider.cs
index 401db2c33b..39555e81cf 100644
--- a/BizHawk.Client.Common/CoreFileProvider.cs
+++ b/BizHawk.Client.Common/CoreFileProvider.cs
@@ -32,7 +32,6 @@ namespace BizHawk.Client.Common
return PathManager.SaveRamPath(Global.Game);
}
-
public string GetRetroSaveRAMDirectory()
{
return PathManager.RetroSaveRAMDirectory(Global.Game);
diff --git a/BizHawk.Client.Common/Global.cs b/BizHawk.Client.Common/Global.cs
index d06700502f..5484bbbc4f 100644
--- a/BizHawk.Client.Common/Global.cs
+++ b/BizHawk.Client.Common/Global.cs
@@ -1,9 +1,10 @@
-using BizHawk.Emulation.Common;
+using System.Collections.Generic;
+
+using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Emulation.Cores.Sega.MasterSystem;
-using System.Collections.Generic;
-
+// ReSharper disable StyleCop.SA1401
namespace BizHawk.Client.Common
{
public static class Global
@@ -23,7 +24,7 @@ namespace BizHawk.Client.Common
public static bool DisableSecondaryThrottling;
///
- /// The maximum number of millseconds the sound output buffer can go below full before causing a noticable sound interruption.
+ /// The maximum number of milliseconds the sound output buffer can go below full before causing a noticeable sound interruption.
///
public static int SoundMaxBufferDeficitMs;
diff --git a/BizHawk.Client.Common/RomGame.cs b/BizHawk.Client.Common/RomGame.cs
index 17edf7ae09..b6326fa858 100644
--- a/BizHawk.Client.Common/RomGame.cs
+++ b/BizHawk.Client.Common/RomGame.cs
@@ -158,7 +158,6 @@ namespace BizHawk.Client.Common
// output[i + 3] = source[i];
// output[i + 1] = source[i + 2];
// output[i + 2] = source[i + 1];
-
byte temp = pSource[i];
pSource[i] = source[i + 3];
pSource[i + 3] = temp;
@@ -192,7 +191,10 @@ namespace BizHawk.Client.Common
}
}
}
- catch (Exception) { } // No need for errors in patching to propagate.
+ catch (Exception)
+ {
+ // No need for errors in patching to propagate.
+ }
}
}
}
diff --git a/BizHawk.Client.Common/SavestateManager.cs b/BizHawk.Client.Common/SavestateManager.cs
index 53b7e1329f..24a0783c46 100644
--- a/BizHawk.Client.Common/SavestateManager.cs
+++ b/BizHawk.Client.Common/SavestateManager.cs
@@ -124,7 +124,9 @@ namespace BizHawk.Client.Common
buff[i] = j;
}
}
- catch (EndOfStreamException) { }
+ catch (EndOfStreamException)
+ {
+ }
}
}
diff --git a/BizHawk.Client.Common/SevenZipWriter.cs b/BizHawk.Client.Common/SevenZipWriter.cs
index 4eabfa05fe..3cfb544666 100644
--- a/BizHawk.Client.Common/SevenZipWriter.cs
+++ b/BizHawk.Client.Common/SevenZipWriter.cs
@@ -308,11 +308,11 @@ namespace BizHawk.Client.Common
}
}
- SevenZip.SevenZipCompressor svc;
+ private SevenZip.SevenZipCompressor svc;
- bool first = true;
- string path;
- int compressionlevel;
+ private bool first = true;
+ private string path;
+ private int compressionlevel;
public SevenZipWriter(string path, int compressionlevel)
{
@@ -325,16 +325,28 @@ namespace BizHawk.Client.Common
switch (compressionlevel)
{
default:
- case 0: svc.CompressionLevel = SevenZip.CompressionLevel.None; break;
+ case 0:
+ svc.CompressionLevel = SevenZip.CompressionLevel.None;
+ break;
case 1:
- case 2: svc.CompressionLevel = SevenZip.CompressionLevel.Fast; break;
+ case 2:
+ svc.CompressionLevel = SevenZip.CompressionLevel.Fast;
+ break;
case 3:
- case 4: svc.CompressionLevel = SevenZip.CompressionLevel.Low; break;
+ case 4:
+ svc.CompressionLevel = SevenZip.CompressionLevel.Low;
+ break;
case 5:
- case 6: svc.CompressionLevel = SevenZip.CompressionLevel.Normal; break;
+ case 6:
+ svc.CompressionLevel = SevenZip.CompressionLevel.Normal;
+ break;
case 7:
- case 8: svc.CompressionLevel = SevenZip.CompressionLevel.High; break;
- case 9: svc.CompressionLevel = SevenZip.CompressionLevel.Ultra; break;
+ case 8:
+ svc.CompressionLevel = SevenZip.CompressionLevel.High;
+ break;
+ case 9:
+ svc.CompressionLevel = SevenZip.CompressionLevel.Ultra;
+ break;
}
}
diff --git a/BizHawk.Client.Common/SystemInfo.cs b/BizHawk.Client.Common/SystemInfo.cs
index 836d7a396a..5039adcdc3 100644
--- a/BizHawk.Client.Common/SystemInfo.cs
+++ b/BizHawk.Client.Common/SystemInfo.cs
@@ -21,7 +21,7 @@ namespace BizHawk.Client.Common
#region cTor(s)
///
- /// Initialize a new instance of
+ /// Initializes a new instance of the class
///
/// A that specify how the system name is displayed
/// A that specify what core is used
@@ -45,17 +45,17 @@ namespace BizHawk.Client.Common
///
/// Gets the instance for Apple II
- ///
public static SystemInfo Libretro { get; } = new SystemInfo("Libretro", CoreSystem.Libretro, 1);
///
/// Gets the instance for Apple II
- ///
public static SystemInfo AppleII { get; } = new SystemInfo("Apple II", CoreSystem.AppleII, 1);
///
/// Gets the instance for Atari 2600
- ///
public static SystemInfo Atari2600 { get; } = new SystemInfo("Atari 2600", CoreSystem.Atari2600, 1);
///
@@ -184,7 +184,7 @@ namespace BizHawk.Client.Common
/// Get a by its
///
/// you're looking for
- /// Mathing
+ ///
public static SystemInfo FindByCoreSystem(CoreSystem system)
{
return _allSystemInfos.Find(s => s.System == system);
@@ -193,7 +193,7 @@ namespace BizHawk.Client.Common
///
/// Determine if this is equal to specified
///
- /// to comapre to
+ /// to compare to
/// True if object is equal to this instance; otherwise, false
public override bool Equals(object obj)
{
@@ -218,7 +218,6 @@ namespace BizHawk.Client.Common
/// Returns a representation of current
/// In fact, return the same as DisplayName property
///
- ///
public override string ToString()
{
return DisplayName;
@@ -258,7 +257,7 @@ namespace BizHawk.Client.Common
public JoypadButton AvailableButtons { get; }
///
- /// Gets the sytem name as
+ /// Gets the system name as
///
public string DisplayName { get; }
diff --git a/BizHawk.Client.Common/config/ConfigService.cs b/BizHawk.Client.Common/config/ConfigService.cs
index b8ddccca82..da6302ac1f 100644
--- a/BizHawk.Client.Common/config/ConfigService.cs
+++ b/BizHawk.Client.Common/config/ConfigService.cs
@@ -10,7 +10,7 @@ namespace BizHawk.Client.Common
{
public static class ConfigService
{
- private static JsonSerializer Serializer;
+ private static readonly JsonSerializer Serializer;
static ConfigService()
{
diff --git a/BizHawk.Client.Common/config/ToolDialogSettings.cs b/BizHawk.Client.Common/config/ToolDialogSettings.cs
index fcd2eee0bb..81da1f8d66 100644
--- a/BizHawk.Client.Common/config/ToolDialogSettings.cs
+++ b/BizHawk.Client.Common/config/ToolDialogSettings.cs
@@ -44,7 +44,6 @@ namespace BizHawk.Client.Common
{
_wndx = value;
}
-
}
}
@@ -62,12 +61,11 @@ namespace BizHawk.Client.Common
{
_wndy = value;
}
-
}
}
///
- /// Represents the top left corner coordinate, if Wndx and Wndy form a valid point
+ /// Gets a value that represents the top left corner coordinate, if Wndx and Wndy form a valid point
/// Throws an InvalidOperationException if Wndx or Wndy is null
/// It is expected to check for this before using this property
///
diff --git a/BizHawk.Client.Common/inputAdapters/AutoPattern.cs b/BizHawk.Client.Common/inputAdapters/AutoPattern.cs
index f924142b1f..4547ea66ba 100644
--- a/BizHawk.Client.Common/inputAdapters/AutoPattern.cs
+++ b/BizHawk.Client.Common/inputAdapters/AutoPattern.cs
@@ -7,9 +7,6 @@
public readonly int Loop = 0;
private int _index = 0;
- ///
- /// Autohold.
- ///
public AutoPatternBool()
{
Pattern = new[] { true };
diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs
index 07581c8b33..7e37ae5708 100644
--- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs
+++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs
@@ -184,7 +184,10 @@ namespace BizHawk.Client.Common
}
}
}
- catch { /*Eat it*/ }
+ catch
+ {
+ /*Eat it*/
+ }
}
}
}
diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs
index c3dd95aa3a..23ca2e0561 100644
--- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs
+++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs
@@ -15,13 +15,11 @@ namespace BizHawk.Client.Common
public MemoryLuaLibrary(Lua lua)
: base(lua)
{
-
}
public MemoryLuaLibrary(Lua lua, Action logOutputCallback)
: base(lua, logOutputCallback)
{
-
}
public override string Name => "memory";
@@ -41,12 +39,10 @@ namespace BizHawk.Client.Common
return _currentMemoryDomain;
}
- else
- {
- var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains";
- Log(error);
- throw new NotImplementedException(error);
- }
+
+ var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains";
+ Log(error);
+ throw new NotImplementedException(error);
}
}
diff --git a/BizHawk.Client.Common/movie/MovieSession.cs b/BizHawk.Client.Common/movie/MovieSession.cs
index 417a626f9d..d01aa32c15 100644
--- a/BizHawk.Client.Common/movie/MovieSession.cs
+++ b/BizHawk.Client.Common/movie/MovieSession.cs
@@ -28,12 +28,9 @@ namespace BizHawk.Client.Common
public IMovie QueuedMovie { get; set; }
// This wrapper but the logic could change, don't make the client code understand these details
- public bool MovieIsQueued
- {
- get { return QueuedMovie != null; }
- }
+ public bool MovieIsQueued => QueuedMovie != null;
- public MultitrackRecorder MultiTrack { get; private set; }
+ public MultitrackRecorder MultiTrack { get; }
public IMovieController MovieControllerAdapter { get; set; }
public IMovie Movie { get; set; }
@@ -54,7 +51,6 @@ namespace BizHawk.Client.Common
///
/// Simply shortens the verbosity necessary otherwise
///
- ///
public ILogEntryGenerator LogGeneratorInstance()
{
return Movie.LogGeneratorInstance();
diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs
index c08377f218..d39dd7b42d 100644
--- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs
+++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs
@@ -2,6 +2,7 @@
using System.IO;
using BizHawk.Common;
+using BizHawk.Common.IOExtensions;
namespace BizHawk.Client.Common
{
@@ -23,10 +24,10 @@ namespace BizHawk.Client.Common
backupName = backupName.Insert(Filename.LastIndexOf("."), $".{DateTime.Now:yyyy-MM-dd HH.mm.ss}");
backupName = Path.Combine(Global.Config.PathEntries["Global", "Movie backups"].Path, Path.GetFileName(backupName));
- var directory_info = new FileInfo(backupName).Directory;
- if (directory_info != null)
+ var directoryInfo = new FileInfo(backupName).Directory;
+ if (directoryInfo != null)
{
- Directory.CreateDirectory(directory_info.FullName);
+ Directory.CreateDirectory(directoryInfo.FullName);
}
Write(backupName, backup: true);
@@ -109,7 +110,7 @@ namespace BizHawk.Client.Common
bl.GetLump(BinaryStateLump.Input, true, delegate(TextReader tr)
{
- var errorMessage = "";
+ string errorMessage;
IsCountingRerecords = false;
ExtractInputLog(tr, out errorMessage);
IsCountingRerecords = true;
@@ -131,10 +132,11 @@ namespace BizHawk.Client.Common
{
SavestateFramebuffer = new int[length / sizeof(int)];
for (int i = 0; i < SavestateFramebuffer.Length; i++)
+ {
SavestateFramebuffer[i] = br.ReadInt32();
+ }
});
}
-
else if (StartsFromSaveRam)
{
bl.GetLump(BinaryStateLump.MovieSaveRam, false,
@@ -191,8 +193,7 @@ namespace BizHawk.Client.Common
if (SavestateFramebuffer != null)
{
- bs.PutLump(BinaryStateLump.Framebuffer,
- (BinaryWriter bw) => BizHawk.Common.IOExtensions.IOExtensions.Write(bw, SavestateFramebuffer));
+ bs.PutLump(BinaryStateLump.Framebuffer, (BinaryWriter bw) => bw.Write(SavestateFramebuffer));
}
}
else if (StartsFromSaveRam)
diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs
index 3e91e42774..1ba5b2f72f 100644
--- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs
+++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs
@@ -314,10 +314,10 @@ namespace BizHawk.Client.Common
///
/// Takes a log entry from a line in an input log,
- /// If the log key differs from the system's, it will be coverted
+ /// If the log key differs from the system's, it will be converted
///
/// a log entry line of text from the input log
- /// a log entry line of text from the input log
+ /// a key used to describe the mnemonic values and positions in the log
private string ConvertLogEntryFromFile(string line, string logKey)
{
var adapter = new Bk2LogEntryGenerator(logKey).MovieControllerAdapter;
diff --git a/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs b/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs
index f6b70a7e7e..b2d5e72dd7 100644
--- a/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs
+++ b/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs
@@ -484,7 +484,7 @@ namespace BizHawk.Client.Common
foreach (string name in BkmMnemonicConstants.ANALOGS[ControlType].Keys)
{
- Force("P" + player + " " + name, Int32.Parse(mnemonic.Substring(srcindex + start, 4)));
+ Force("P" + player + " " + name, int.Parse(mnemonic.Substring(srcindex + start, 4)));
start += 5;
}
}
diff --git a/BizHawk.Client.Common/movie/bkm/BkmMovie.ModeApi.cs b/BizHawk.Client.Common/movie/bkm/BkmMovie.ModeApi.cs
index 1dc77d9141..437ea64e68 100644
--- a/BizHawk.Client.Common/movie/bkm/BkmMovie.ModeApi.cs
+++ b/BizHawk.Client.Common/movie/bkm/BkmMovie.ModeApi.cs
@@ -4,7 +4,10 @@ namespace BizHawk.Client.Common
{
public partial class BkmMovie
{
- private enum Moviemode { Inactive, Play, Record, Finished }
+ private enum Moviemode
+ {
+ Inactive, Play, Record, Finished
+ }
private Moviemode _mode = Moviemode.Inactive;
diff --git a/BizHawk.Client.Common/movie/import/Fm2Import.cs b/BizHawk.Client.Common/movie/import/Fm2Import.cs
index 6fd2b2bae9..e344fa0b90 100644
--- a/BizHawk.Client.Common/movie/import/Fm2Import.cs
+++ b/BizHawk.Client.Common/movie/import/Fm2Import.cs
@@ -28,7 +28,8 @@ namespace BizHawk.Client.Common
{
continue;
}
- else if (line[0] == '|')
+
+ if (line[0] == '|')
{
// TODO: import a frame of input
// TODO: report any errors importing this frame and bail out if so
@@ -44,8 +45,7 @@ namespace BizHawk.Client.Common
}
else if (line.ToLower().StartsWith("emuversion"))
{
- Result.Movie.Comments.Add(
- string.Format("{0} {1} version {2}", EMULATIONORIGIN, emulator, ParseHeader(line, "emuVersion")));
+ Result.Movie.Comments.Add($"{EMULATIONORIGIN} {emulator} version {ParseHeader(line, "emuVersion")}");
}
else if (line.ToLower().StartsWith("version"))
{
diff --git a/BizHawk.Client.Common/movie/import/PJMImport.cs b/BizHawk.Client.Common/movie/import/PJMImport.cs
index a28ba75ef1..389404781f 100644
--- a/BizHawk.Client.Common/movie/import/PJMImport.cs
+++ b/BizHawk.Client.Common/movie/import/PJMImport.cs
@@ -1,9 +1,10 @@
-using BizHawk.Emulation.Cores.Sony.PSX;
-using System;
+using System;
using System.IO;
using Newtonsoft.Json;
+using BizHawk.Emulation.Cores.Sony.PSX;
+
namespace BizHawk.Client.Common
{
[ImportExtension(".pjm")]
@@ -435,8 +436,8 @@ namespace BizHawk.Client.Common
protected class MiscHeaderInfo
{
public bool binaryFormat = true;
- public UInt32 controllerDataOffset;
- public UInt32 frameCount;
+ public uint controllerDataOffset;
+ public uint frameCount;
public OctoshockDll.ePeripheralType player1Type;
public OctoshockDll.ePeripheralType player2Type;
diff --git a/BizHawk.Client.Common/movie/import/PXMImport.cs b/BizHawk.Client.Common/movie/import/PXMImport.cs
index 8c3fee251b..0844e71639 100644
--- a/BizHawk.Client.Common/movie/import/PXMImport.cs
+++ b/BizHawk.Client.Common/movie/import/PXMImport.cs
@@ -1,6 +1,6 @@
using System.IO;
-namespace BizHawk.Client.Common.movie.import
+namespace BizHawk.Client.Common.Movie.Import
{
// PXM files are directly compatible with binary-format PJM files, with the only
// difference being fewer flags implemented in the header, hence just calling the
diff --git a/BizHawk.Client.Common/movie/interfaces/ILogEntryGenerator.cs b/BizHawk.Client.Common/movie/interfaces/ILogEntryGenerator.cs
index a934c5a075..897dd79281 100644
--- a/BizHawk.Client.Common/movie/interfaces/ILogEntryGenerator.cs
+++ b/BizHawk.Client.Common/movie/interfaces/ILogEntryGenerator.cs
@@ -7,34 +7,32 @@ namespace BizHawk.Client.Common
///
/// Sets the controller source used to generate an input log entry
///
- ///
void SetSource(IController source);
///
/// Generates an input log entry for the current state of Source
///
- ///
string GenerateLogEntry();
///
- /// Generates a display friendly verion of the input log entry
+ /// Generates a display friendly version of the input log entry
///
- ///
string GenerateInputDisplay();
///
- /// Returns whether or not the current controller state is "empty"
+ /// Gets a value indicating whether or not the current controller state is "empty"
///
bool IsEmpty { get; }
///
- /// Returns an input log entry that is considered empty. (booleans will be false, floats will be 0)
+ /// Gets an input log entry that is considered empty. (booleans will be false, floats will be 0)
///
string EmptyEntry { get; }
///
- /// Returns a movie controller adapter in the same state
+ /// Gets a movie controller adapter in the same state as the log entry
///
+ ///
IMovieController MovieControllerAdapter { get; }
}
}
diff --git a/BizHawk.Client.Common/movie/interfaces/IMovie.cs b/BizHawk.Client.Common/movie/interfaces/IMovie.cs
index 4da742a75a..4ef25bd4e6 100644
--- a/BizHawk.Client.Common/movie/interfaces/IMovie.cs
+++ b/BizHawk.Client.Common/movie/interfaces/IMovie.cs
@@ -35,12 +35,12 @@ namespace BizHawk.Client.Common
int InputLogLength { get; }
///
- /// Returns the file extension for this implementation
+ /// Gets the file extension for the current implementation
///
string PreferredExtension { get; }
///
- /// Sync Settings from the Core
+ /// Gets or sets the Sync Settings from the Core
///
string SyncSettingsJson { get; set; }
@@ -74,7 +74,7 @@ namespace BizHawk.Client.Common
bool PreLoadHeaderAndLength(HawkFile hawkFile);
///
- /// Returns header key value pairs stored in the movie file
+ /// Gets the header key value pairs stored in the movie file
///
IDictionary HeaderEntries { get; }
@@ -107,11 +107,11 @@ namespace BizHawk.Client.Common
void Save();
///
- /// Extracts the current input log from the user.
+ /// Extracts the current input log from the user.
/// This is provided as the means for putting the input log into savestates,
/// for the purpose of out of order savestate loading (known as "bullet-proof rerecording")
///
- /// returns a string represntation of the input log in its current state
+ /// returns a string representation of the input log in its current state
string GetInputLog();
///
@@ -123,7 +123,6 @@ namespace BizHawk.Client.Common
/// Gets one frame from the input log.
///
/// The frame to get.
- ///
string GetInputLogEntry(int frame);
///
@@ -140,7 +139,6 @@ namespace BizHawk.Client.Common
///
/// The reader containing the contents of the input log
/// Returns an error message, if any
- ///
bool ExtractInputLog(TextReader reader, out string errorMessage);
#endregion
@@ -209,7 +207,7 @@ namespace BizHawk.Client.Common
///
/// Instructs the movie to remove all input from its input log after frame,
- /// AFter truncating, frame will be the last frame of input in the movie's input log
+ /// After truncating, frame will be the last frame of input in the movie's input log
///
/// The frame at which to truncate
void Truncate(int frame);
diff --git a/BizHawk.Client.Common/movie/tasproj/TasBranch.cs b/BizHawk.Client.Common/movie/tasproj/TasBranch.cs
index 13faf2d0f8..2eae586ab0 100644
--- a/BizHawk.Client.Common/movie/tasproj/TasBranch.cs
+++ b/BizHawk.Client.Common/movie/tasproj/TasBranch.cs
@@ -132,7 +132,7 @@ namespace BizHawk.Client.Common
var header = (dynamic)JsonConvert.DeserializeObject(tr.ReadLine());
b.Frame = (int)header.Frame;
- var timestamp = (dynamic)header.TimeStamp;
+ var timestamp = header.TimeStamp;
if (timestamp != null)
{
@@ -143,7 +143,7 @@ namespace BizHawk.Client.Common
b.TimeStamp = DateTime.Now;
}
- var identifier = (dynamic)header.UniqueIdentifier;
+ var identifier = header.UniqueIdentifier;
if (identifier != null)
{
b.UniqueIdentifier = (Guid)identifier;
@@ -168,7 +168,9 @@ namespace BizHawk.Client.Common
b.InputLog = StringLogUtil.MakeStringLog();
string line;
while ((line = tr.ReadLine()) != null)
+ {
b.InputLog.Add(line);
+ }
});
bl.GetLump(nframebuffer, true, delegate(Stream s, long length)
diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs
index 8c50291970..d2844c9278 100644
--- a/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs
+++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs
@@ -19,12 +19,12 @@ namespace BizHawk.Client.Common
base.RecordFrame(frame, source);
- LagLog.RemoveFrom(frame);
- LagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame;
+ _lagLog.RemoveFrom(frame);
+ _lagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame;
if (IsRecording)
{
- StateManager.Invalidate(frame + 1);
+ _stateManager.Invalidate(frame + 1);
}
if (frame != 0)
@@ -45,8 +45,8 @@ namespace BizHawk.Client.Common
base.Truncate(frame);
- LagLog.RemoveFrom(frame);
- StateManager.Invalidate(frame);
+ _lagLog.RemoveFrom(frame);
+ _stateManager.Invalidate(frame);
Markers.TruncateAt(frame);
ChangeLog.SetGeneralRedo();
@@ -70,7 +70,7 @@ namespace BizHawk.Client.Common
{
ChangeLog.AddGeneralUndo(frame, frame, "Set Frame At: " + frame);
- base.SetFrameAt(frame, source);
+ SetFrameAt(frame, source);
InvalidateAfter(frame);
ChangeLog.SetGeneralRedo();
@@ -163,6 +163,7 @@ namespace BizHawk.Client.Common
}
}
}
+
ChangeLog.IsRecording = wasRecording;
}
}
@@ -367,7 +368,6 @@ namespace BizHawk.Client.Common
ChangeLog.IsRecording = wasRecording;
}
-
Changes = true;
InvalidateAfter(frame - 1);
@@ -534,7 +534,9 @@ namespace BizHawk.Client.Common
_log[frame + i] = lg.GenerateLogEntry();
if (changed == -1 && old != val)
+ {
changed = frame + i;
+ }
}
if (changed != -1)
@@ -550,16 +552,17 @@ namespace BizHawk.Client.Common
public void RemoveLagHistory(int frame)
{
- LagLog.RemoveHistoryAt(frame);
+ _lagLog.RemoveHistoryAt(frame);
}
+
public void InsertLagHistory(int frame, bool isLag)
{
- LagLog.InsertHistoryAt(frame, isLag);
+ _lagLog.InsertHistoryAt(frame, isLag);
}
public void SetLag(int frame, bool? value)
{
- LagLog[frame] = value;
+ _lagLog[frame] = value;
}
#endregion
diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs
index 498ece9dd2..4ce8e66170 100644
--- a/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs
+++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs
@@ -9,20 +9,28 @@ namespace BizHawk.Client.Common
private readonly List> History;
public List Names;
public int UndoIndex = -1;
- int _maxSteps = 100;
+ private int _maxSteps = 100;
public int MaxSteps
{
- get { return _maxSteps; }
+ get
+ {
+ return _maxSteps;
+ }
+
set
{
_maxSteps = value;
if (History.Count > value)
{
if (History.Count <= value)
+ {
ClearLog();
+ }
else
+ {
ClearLog(History.Count - value);
+ }
}
}
}
@@ -48,16 +56,22 @@ namespace BizHawk.Client.Common
public void ClearLog(int upTo = -1)
{
if (upTo == -1)
+ {
upTo = History.Count;
+ }
History.RemoveRange(0, upTo);
Names.RemoveRange(0, upTo);
UndoIndex -= upTo;
if (UndoIndex < -1)
+ {
UndoIndex = -1;
+ }
if (History.Count == 0)
+ {
RecordingBatch = false;
+ }
}
private void TruncateLog(int from)
@@ -66,7 +80,9 @@ namespace BizHawk.Client.Common
Names.RemoveRange(from, Names.Count - from);
if (UndoIndex < History.Count - 1)
+ {
UndoIndex = History.Count - 1;
+ }
if (RecordingBatch)
{
@@ -79,26 +95,34 @@ namespace BizHawk.Client.Common
/// All changes made between calling Begin and End will be one Undo.
/// If already recording in a batch, calls EndBatch.
///
+ /// The name of the batch
/// If set and a batch is in progress, a new batch will not be created.
/// Returns true if a new batch was started; otherwise false.
public bool BeginNewBatch(string name = "", bool keepOldBatch = false)
{
if (!IsRecording)
+ {
return false;
+ }
bool ret = true;
if (RecordingBatch)
{
if (keepOldBatch)
+ {
ret = false;
+ }
else
+ {
EndBatch();
+ }
}
if (ret)
{
ret = AddMovieAction(name);
}
+
RecordingBatch = true;
return ret;
@@ -111,7 +135,9 @@ namespace BizHawk.Client.Common
public void EndBatch()
{
if (!IsRecording || !RecordingBatch)
+ {
return;
+ }
RecordingBatch = false;
List last = History.Last();
@@ -122,7 +148,9 @@ namespace BizHawk.Client.Common
UndoIndex--;
}
else
+ {
last.Capacity = last.Count;
+ }
}
///
@@ -132,11 +160,16 @@ namespace BizHawk.Client.Common
public int Undo()
{
if (UndoIndex == -1)
+ {
return Movie.InputLogLength;
+ }
List batch = History[UndoIndex];
for (int i = batch.Count - 1; i >= 0; i--)
+ {
batch[i].Undo(Movie);
+ }
+
UndoIndex--;
RecordingBatch = false;
@@ -156,12 +189,16 @@ namespace BizHawk.Client.Common
public int Redo()
{
if (UndoIndex == History.Count - 1)
+ {
return Movie.InputLogLength;
+ }
UndoIndex++;
List batch = History[UndoIndex];
- for (int i = 0; i < batch.Count; i++)
- batch[i].Redo(Movie);
+ foreach (IMovieAction b in batch)
+ {
+ b.Redo(Movie);
+ }
RecordingBatch = false;
@@ -268,7 +305,7 @@ namespace BizHawk.Client.Common
}
// TODO: These probably aren't the best way to handle undo/redo.
- private int lastGeneral;
+ private int _lastGeneral;
public void AddGeneralUndo(int first, int last, string name = "", bool force = false)
{
@@ -276,7 +313,7 @@ namespace BizHawk.Client.Common
{
AddMovieAction(name);
History.Last().Add(new MovieAction(first, last, Movie));
- lastGeneral = History.Last().Count - 1;
+ _lastGeneral = History.Last().Count - 1;
}
}
@@ -284,7 +321,7 @@ namespace BizHawk.Client.Common
{
if (IsRecording || force)
{
- (History.Last()[lastGeneral] as MovieAction).SetRedoLog(Movie);
+ (History.Last()[_lastGeneral] as MovieAction).SetRedoLog(Movie);
}
}
@@ -311,9 +348,13 @@ namespace BizHawk.Client.Common
if (IsRecording || force)
{
if (oldPosition == -1)
+ {
name = "Set Marker at frame " + newMarker.Frame;
+ }
else
+ {
name = "Remove Marker at frame " + oldPosition;
+ }
AddMovieAction(name);
History.Last().Add(new MovieActionMarker(newMarker, oldPosition, old_message));
@@ -348,37 +389,37 @@ namespace BizHawk.Client.Common
public int FirstFrame { get; }
public int LastFrame { get; }
- private int undoLength;
- private int redoLength;
+ private readonly int _undoLength;
+ private int _redoLength;
private int length => LastFrame - FirstFrame + 1;
- private List oldLog;
- private List newLog;
- private bool bindMarkers;
+ private readonly List _oldLog;
+ private List _newLog;
+ private readonly bool _bindMarkers;
public MovieAction(int firstFrame, int lastFrame, TasMovie movie)
{
FirstFrame = firstFrame;
LastFrame = lastFrame;
- oldLog = new List(length);
- undoLength = Math.Min(LastFrame + 1, movie.InputLogLength) - FirstFrame;
+ _oldLog = new List(length);
+ _undoLength = Math.Min(LastFrame + 1, movie.InputLogLength) - FirstFrame;
- for (int i = 0; i < undoLength; i++)
+ for (int i = 0; i < _undoLength; i++)
{
- oldLog.Add(movie.GetLogEntries()[FirstFrame + i]);
+ _oldLog.Add(movie.GetLogEntries()[FirstFrame + i]);
}
- bindMarkers = movie.BindMarkersToInput;
+ _bindMarkers = movie.BindMarkersToInput;
}
public void SetRedoLog(TasMovie movie)
{
- redoLength = Math.Min(LastFrame + 1, movie.InputLogLength) - FirstFrame;
- newLog = new List();
- for (int i = 0; i < redoLength; i++)
+ _redoLength = Math.Min(LastFrame + 1, movie.InputLogLength) - FirstFrame;
+ _newLog = new List();
+ for (int i = 0; i < _redoLength; i++)
{
- newLog.Add(movie.GetLogEntries()[FirstFrame + i]);
+ _newLog.Add(movie.GetLogEntries()[FirstFrame + i]);
}
}
@@ -387,18 +428,25 @@ namespace BizHawk.Client.Common
bool wasRecording = movie.ChangeLog.IsRecording;
bool wasBinding = movie.BindMarkersToInput;
movie.ChangeLog.IsRecording = false;
- movie.BindMarkersToInput = bindMarkers;
+ movie.BindMarkersToInput = _bindMarkers;
- if (redoLength != length)
- movie.InsertEmptyFrame(FirstFrame, length - redoLength, true);
- if (undoLength != length)
- movie.RemoveFrames(FirstFrame, movie.InputLogLength - undoLength, true);
+ if (_redoLength != length)
+ {
+ movie.InsertEmptyFrame(FirstFrame, length - _redoLength, true);
+ }
- for (int i = 0; i < undoLength; i++)
- movie.SetFrame(FirstFrame + i, oldLog[i]);
+ if (_undoLength != length)
+ {
+ movie.RemoveFrames(FirstFrame, movie.InputLogLength - _undoLength, true);
+ }
+
+ for (int i = 0; i < _undoLength; i++)
+ {
+ movie.SetFrame(FirstFrame + i, _oldLog[i]);
+ }
movie.ChangeLog.IsRecording = wasRecording;
- movie.BindMarkersToInput = bindMarkers;
+ movie.BindMarkersToInput = _bindMarkers;
}
public void Redo(TasMovie movie)
@@ -406,18 +454,24 @@ namespace BizHawk.Client.Common
bool wasRecording = movie.ChangeLog.IsRecording;
bool wasBinding = movie.BindMarkersToInput;
movie.ChangeLog.IsRecording = false;
- movie.BindMarkersToInput = bindMarkers;
+ movie.BindMarkersToInput = _bindMarkers;
- if (undoLength != length)
- movie.InsertEmptyFrame(FirstFrame, length - undoLength);
- if (redoLength != length)
- movie.RemoveFrames(FirstFrame, movie.InputLogLength - redoLength);
+ if (_undoLength != length)
+ {
+ movie.InsertEmptyFrame(FirstFrame, length - _undoLength);
+ }
+ if (_redoLength != length)
+ {
+ movie.RemoveFrames(FirstFrame, movie.InputLogLength - _redoLength);
+ }
- for (int i = 0; i < redoLength; i++)
- movie.SetFrame(FirstFrame + i, newLog[i]);
+ for (int i = 0; i < _redoLength; i++)
+ {
+ movie.SetFrame(FirstFrame + i, _newLog[i]);
+ }
movie.ChangeLog.IsRecording = wasRecording;
- movie.BindMarkersToInput = bindMarkers;
+ movie.BindMarkersToInput = _bindMarkers;
}
}
@@ -426,8 +480,8 @@ namespace BizHawk.Client.Common
public int FirstFrame { get; }
public int LastFrame { get; }
- private string oldMessage;
- private string newMessage;
+ private readonly string _oldMessage;
+ private readonly string _newMessage;
public MovieActionMarker(TasMovieMarker marker, int oldPosition = -1, string old_message = "")
{
@@ -435,69 +489,77 @@ namespace BizHawk.Client.Common
if (marker == null)
{
LastFrame = -1;
- oldMessage = old_message;
+ _oldMessage = old_message;
}
else
{
LastFrame = marker.Frame;
- if (old_message == "")
- oldMessage = marker.Message;
- else
- oldMessage = old_message;
- newMessage = marker.Message;
+ _oldMessage = old_message == "" ? marker.Message : old_message;
+ _newMessage = marker.Message;
}
}
public void Undo(TasMovie movie)
{
if (FirstFrame == -1) // Action: Place marker
+ {
movie.Markers.Remove(movie.Markers.Get(LastFrame), true);
+ }
else if (LastFrame == -1) // Action: Remove marker
- movie.Markers.Add(FirstFrame, oldMessage, true);
+ {
+ movie.Markers.Add(FirstFrame, _oldMessage, true);
+ }
else // Action: Move/rename marker
{
movie.Markers.Move(LastFrame, FirstFrame, true);
- movie.Markers.Get(LastFrame).Message = oldMessage;
+ movie.Markers.Get(LastFrame).Message = _oldMessage;
}
}
public void Redo(TasMovie movie)
{
if (FirstFrame == -1) // Action: Place marker
- movie.Markers.Add(LastFrame, oldMessage, true);
+ {
+ movie.Markers.Add(LastFrame, _oldMessage, true);
+ }
else if (LastFrame == -1) // Action: Remove marker
+ {
movie.Markers.Remove(movie.Markers.Get(FirstFrame), true);
+ }
else // Action: Move/rename marker
{
movie.Markers.Move(FirstFrame, LastFrame, true);
- movie.Markers.Get(LastFrame).Message = newMessage;
+ movie.Markers.Get(LastFrame).Message = _newMessage;
}
}
}
public class MovieActionFrameEdit : IMovieAction
{
- public int FirstFrame { get; private set; }
- public int LastFrame { get { return FirstFrame; } }
- private float oldState, newState;
- private string buttonName;
- private bool isFloat = false;
+ public int FirstFrame { get; }
+ public int LastFrame => FirstFrame;
+
+ private readonly float _oldState;
+ private readonly float _newState;
+
+ private readonly string _buttonName;
+ private readonly bool _isFloat;
public MovieActionFrameEdit(int frame, string button, bool oldS, bool newS)
{
- oldState = oldS ? 1 : 0;
- newState = newS ? 1 : 0;
+ _oldState = oldS ? 1 : 0;
+ _newState = newS ? 1 : 0;
FirstFrame = frame;
- buttonName = button;
+ _buttonName = button;
}
public MovieActionFrameEdit(int frame, string button, float oldS, float newS)
{
- oldState = oldS;
- newState = newS;
+ _oldState = oldS;
+ _newState = newS;
FirstFrame = frame;
- buttonName = button;
- isFloat = true;
+ _buttonName = button;
+ _isFloat = true;
}
public void Undo(TasMovie movie)
@@ -505,10 +567,14 @@ namespace BizHawk.Client.Common
bool wasRecording = movie.ChangeLog.IsRecording;
movie.ChangeLog.IsRecording = false;
- if (isFloat)
- movie.SetFloatState(FirstFrame, buttonName, oldState);
+ if (_isFloat)
+ {
+ movie.SetFloatState(FirstFrame, _buttonName, _oldState);
+ }
else
- movie.SetBoolState(FirstFrame, buttonName, oldState == 1);
+ {
+ movie.SetBoolState(FirstFrame, _buttonName, _oldState == 1);
+ }
movie.ChangeLog.IsRecording = wasRecording;
}
@@ -518,10 +584,14 @@ namespace BizHawk.Client.Common
bool wasRecording = movie.ChangeLog.IsRecording;
movie.ChangeLog.IsRecording = false;
- if (isFloat)
- movie.SetFloatState(FirstFrame, buttonName, newState);
+ if (_isFloat)
+ {
+ movie.SetFloatState(FirstFrame, _buttonName, _newState);
+ }
else
- movie.SetBoolState(FirstFrame, buttonName, newState == 1);
+ {
+ movie.SetBoolState(FirstFrame, _buttonName, _newState == 1);
+ }
movie.ChangeLog.IsRecording = wasRecording;
}
@@ -529,36 +599,40 @@ namespace BizHawk.Client.Common
public class MovieActionPaint : IMovieAction
{
- public int FirstFrame { get; private set; }
- public int LastFrame { get; private set; }
- private List oldState;
- private float newState;
- private string buttonName;
- private bool isFloat = false;
+ public int FirstFrame { get; }
+ public int LastFrame { get; }
+ private readonly List _oldState;
+ private readonly float _newState;
+ private readonly string _buttonName;
+ private readonly bool _isFloat = false;
public MovieActionPaint(int startFrame, int endFrame, string button, bool newS, TasMovie movie)
{
- newState = newS ? 1 : 0;
+ _newState = newS ? 1 : 0;
FirstFrame = startFrame;
LastFrame = endFrame;
- buttonName = button;
- oldState = new List(endFrame - startFrame + 1);
+ _buttonName = button;
+ _oldState = new List(endFrame - startFrame + 1);
for (int i = 0; i < endFrame - startFrame + 1; i++)
- oldState.Add(movie.BoolIsPressed(startFrame + i, button) ? 1 : 0);
+ {
+ _oldState.Add(movie.BoolIsPressed(startFrame + i, button) ? 1 : 0);
+ }
}
public MovieActionPaint(int startFrame, int endFrame, string button, float newS, TasMovie movie)
{
- newState = newS;
+ _newState = newS;
FirstFrame = startFrame;
LastFrame = endFrame;
- buttonName = button;
- isFloat = true;
- oldState = new List(endFrame - startFrame + 1);
+ _buttonName = button;
+ _isFloat = true;
+ _oldState = new List(endFrame - startFrame + 1);
for (int i = 0; i < endFrame - startFrame + 1; i++)
- oldState.Add(movie.BoolIsPressed(startFrame + i, button) ? 1 : 0);
+ {
+ _oldState.Add(movie.BoolIsPressed(startFrame + i, button) ? 1 : 0);
+ }
}
public void Undo(TasMovie movie)
@@ -566,15 +640,19 @@ namespace BizHawk.Client.Common
bool wasRecording = movie.ChangeLog.IsRecording;
movie.ChangeLog.IsRecording = false;
- if (isFloat)
+ if (_isFloat)
{
- for (int i = 0; i < oldState.Count; i++)
- movie.SetFloatState(FirstFrame + i, buttonName, oldState[i]);
+ for (int i = 0; i < _oldState.Count; i++)
+ {
+ movie.SetFloatState(FirstFrame + i, _buttonName, _oldState[i]);
+ }
}
else
{
- for (int i = 0; i < oldState.Count; i++)
- movie.SetBoolState(FirstFrame + i, buttonName, oldState[i] == 1);
+ for (int i = 0; i < _oldState.Count; i++)
+ {
+ movie.SetBoolState(FirstFrame + i, _buttonName, _oldState[i] == 1);
+ }
}
movie.ChangeLog.IsRecording = wasRecording;
@@ -585,10 +663,14 @@ namespace BizHawk.Client.Common
bool wasRecording = movie.ChangeLog.IsRecording;
movie.ChangeLog.IsRecording = false;
- if (isFloat)
- movie.SetFloatStates(FirstFrame, LastFrame - FirstFrame + 1, buttonName, newState);
+ if (_isFloat)
+ {
+ movie.SetFloatStates(FirstFrame, LastFrame - FirstFrame + 1, _buttonName, _newState);
+ }
else
- movie.SetBoolStates(FirstFrame, LastFrame - FirstFrame + 1, buttonName, newState == 1);
+ {
+ movie.SetBoolStates(FirstFrame, LastFrame - FirstFrame + 1, _buttonName, _newState == 1);
+ }
movie.ChangeLog.IsRecording = wasRecording;
}
@@ -596,20 +678,20 @@ namespace BizHawk.Client.Common
public class MovieActionBindInput : IMovieAction
{
- public int FirstFrame { get; private set; }
- public int LastFrame { get; private set; }
+ public int FirstFrame { get; }
+ public int LastFrame { get; }
- private string log;
- private bool delete;
+ private readonly string _log;
+ private readonly bool _delete;
- private bool bindMarkers;
+ private readonly bool _bindMarkers;
public MovieActionBindInput(TasMovie movie, int frame, bool isDelete)
{
FirstFrame = LastFrame = frame;
- log = movie.GetInputLogEntry(frame);
- delete = isDelete;
- bindMarkers = movie.BindMarkersToInput;
+ _log = movie.GetInputLogEntry(frame);
+ _delete = isDelete;
+ _bindMarkers = movie.BindMarkersToInput;
}
public void Undo(TasMovie movie)
@@ -617,11 +699,11 @@ namespace BizHawk.Client.Common
bool wasRecording = movie.ChangeLog.IsRecording;
bool wasBinding = movie.BindMarkersToInput;
movie.ChangeLog.IsRecording = false;
- movie.BindMarkersToInput = bindMarkers;
+ movie.BindMarkersToInput = _bindMarkers;
- if (delete) // Insert
+ if (_delete) // Insert
{
- movie.InsertInput(FirstFrame, log);
+ movie.InsertInput(FirstFrame, _log);
movie.InsertLagHistory(FirstFrame + 1, true);
}
else // Delete
@@ -631,7 +713,7 @@ namespace BizHawk.Client.Common
}
movie.ChangeLog.IsRecording = wasRecording;
- movie.BindMarkersToInput = bindMarkers;
+ movie.BindMarkersToInput = _bindMarkers;
}
public void Redo(TasMovie movie)
@@ -639,21 +721,21 @@ namespace BizHawk.Client.Common
bool wasRecording = movie.ChangeLog.IsRecording;
bool wasBinding = movie.BindMarkersToInput;
movie.ChangeLog.IsRecording = false;
- movie.BindMarkersToInput = bindMarkers;
+ movie.BindMarkersToInput = _bindMarkers;
- if (delete)
+ if (_delete)
{
movie.RemoveFrame(FirstFrame);
movie.RemoveLagHistory(FirstFrame + 1);
}
else
{
- movie.InsertInput(FirstFrame, log);
+ movie.InsertInput(FirstFrame, _log);
movie.InsertLagHistory(FirstFrame + 1, true);
}
movie.ChangeLog.IsRecording = wasRecording;
- movie.BindMarkersToInput = bindMarkers;
+ movie.BindMarkersToInput = _bindMarkers;
}
}
diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs
index a03428de30..b5449946d6 100644
--- a/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs
+++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs
@@ -27,9 +27,9 @@ namespace BizHawk.Client.Common
bs.PutLump(BinaryStateLump.Input, tw => WriteInputLog(tw));
// TasProj extras
- bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(StateManager.Settings.ToString()));
+ bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(_stateManager.Settings.ToString()));
- bs.PutLump(BinaryStateLump.LagLog, (BinaryWriter bw) => LagLog.Save(bw));
+ bs.PutLump(BinaryStateLump.LagLog, (BinaryWriter bw) => _lagLog.Save(bw));
bs.PutLump(BinaryStateLump.Markers, tw => tw.WriteLine(Markers.ToString()));
if (StartsFromSavestate)
@@ -62,17 +62,17 @@ namespace BizHawk.Client.Common
if (Branches.Any())
{
Branches.Save(bs);
- if (StateManager.Settings.BranchStatesInTasproj)
+ if (_stateManager.Settings.BranchStatesInTasproj)
{
- bs.PutLump(BinaryStateLump.BranchStateHistory, (BinaryWriter bw) => StateManager.SaveBranchStates(bw));
+ bs.PutLump(BinaryStateLump.BranchStateHistory, (BinaryWriter bw) => _stateManager.SaveBranchStates(bw));
}
}
bs.PutLump(BinaryStateLump.Session, tw => tw.WriteLine(Session.ToString()));
- if (StateManager.Settings.SaveStateHistory)
+ if (_stateManager.Settings.SaveStateHistory)
{
- bs.PutLump(BinaryStateLump.StateHistory, (BinaryWriter bw) => StateManager.Save(bw));
+ bs.PutLump(BinaryStateLump.StateHistory, (BinaryWriter bw) => _stateManager.Save(bw));
}
}
@@ -183,12 +183,12 @@ namespace BizHawk.Client.Common
// TasMovie enhanced information
bl.GetLump(BinaryStateLump.LagLog, false, delegate(BinaryReader br, long length)
{
- LagLog.Load(br);
+ _lagLog.Load(br);
});
bl.GetLump(BinaryStateLump.StateHistorySettings, false, delegate(TextReader tr)
{
- StateManager.Settings.PopulateFromString(tr.ReadToEnd());
+ _stateManager.Settings.PopulateFromString(tr.ReadToEnd());
});
bl.GetLump(BinaryStateLump.Markers, false, delegate(TextReader tr)
@@ -243,11 +243,11 @@ namespace BizHawk.Client.Common
});
Branches.Load(bl, this);
- if (StateManager.Settings.BranchStatesInTasproj)
+ if (_stateManager.Settings.BranchStatesInTasproj)
{
bl.GetLump(BinaryStateLump.BranchStateHistory, false, delegate(BinaryReader br, long length)
{
- StateManager.LoadBranchStates(br);
+ _stateManager.LoadBranchStates(br);
});
}
@@ -258,17 +258,17 @@ namespace BizHawk.Client.Common
if (!preload)
{
- if (StateManager.Settings.SaveStateHistory)
+ if (_stateManager.Settings.SaveStateHistory)
{
bl.GetLump(BinaryStateLump.StateHistory, false, delegate(BinaryReader br, long length)
{
- StateManager.Load(br);
+ _stateManager.Load(br);
});
}
// Movie should always have a state at frame 0.
if (!StartsFromSavestate && Global.Emulator.Frame == 0)
- StateManager.Capture();
+ _stateManager.Capture();
}
}
@@ -278,8 +278,8 @@ namespace BizHawk.Client.Common
private void ClearTasprojExtras()
{
- LagLog.Clear();
- StateManager.Clear();
+ _lagLog.Clear();
+ _stateManager.Clear();
Markers.Clear();
ChangeLog.ClearLog();
}
diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs
index 205f2c7e7a..735fe22449 100644
--- a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs
+++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs
@@ -12,37 +12,45 @@ namespace BizHawk.Client.Common
{
public sealed partial class TasMovie : Bk2Movie, INotifyPropertyChanged
{
+ private readonly Bk2MnemonicConstants _mnemonics = new Bk2MnemonicConstants();
+ private readonly TasStateManager _stateManager;
+ private readonly TasLagLog _lagLog = new TasLagLog();
+ private readonly Dictionary _inputStateCache = new Dictionary();
+
+ private BackgroundWorker _progressReportWorker;
+
public new const string Extension = "tasproj";
public const string DefaultProjectName = "default";
- public BackgroundWorker _progressReportWorker = null;
- public bool LastPositionStable = true;
- public string NewBranchText = "";
+
+ public bool LastPositionStable { get; set; } = true;
+ public string NewBranchText { get; set; } = "";
+
public readonly IStringLog VerificationLog = StringLogUtil.MakeStringLog(); // For movies that do not begin with power-on, this is the input required to get into the initial state
public readonly TasBranchCollection Branches = new TasBranchCollection();
public readonly TasSession Session;
- private readonly Bk2MnemonicConstants Mnemonics = new Bk2MnemonicConstants();
- private readonly TasStateManager StateManager;
- private readonly TasLagLog LagLog = new TasLagLog();
- private readonly Dictionary InputStateCache = new Dictionary();
- public TasLagLog TasLagLog { get { return LagLog; } }
- public IStringLog InputLog { get { return _log; } }
- public TasMovieMarkerList Markers { get; set; }
+
+ public TasLagLog TasLagLog => _lagLog;
+
+ public IStringLog InputLog => _log;
+
+ public TasMovieMarkerList Markers { get; private set; }
+
public bool BindMarkersToInput { get; set; }
public bool UseInputCache { get; set; }
public int CurrentBranch { get; set; }
public int BranchCount => Branches.Count;
- public int LastValidFrame => LagLog.LastValidFrame;
+ public int LastValidFrame => _lagLog.LastValidFrame;
public override string PreferredExtension => Extension;
- public TasStateManager TasStateManager => StateManager;
+ public TasStateManager TasStateManager => _stateManager;
public TasMovieRecord this[int index] => new TasMovieRecord
{
// State = StateManager[index],
- HasState = StateManager.HasState(index),
+ HasState = _stateManager.HasState(index),
LogEntry = GetInputLogEntry(index),
- Lagged = LagLog[index + 1],
- WasLagged = LagLog.History(index + 1)
+ Lagged = _lagLog[index + 1],
+ WasLagged = _lagLog.History(index + 1)
};
public TasMovie(string path, bool startsFromSavestate = false, BackgroundWorker progressReportWorker = null)
@@ -56,7 +64,7 @@ namespace BizHawk.Client.Common
}
ChangeLog = new TasMovieChangeLog(this);
- StateManager = new TasStateManager(this);
+ _stateManager = new TasStateManager(this);
Session = new TasSession(this);
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0 Tasproj v1.0";
Markers = new TasMovieMarkerList(this);
@@ -75,7 +83,7 @@ namespace BizHawk.Client.Common
}
ChangeLog = new TasMovieChangeLog(this);
- StateManager = new TasStateManager(this);
+ _stateManager = new TasStateManager(this);
Session = new TasSession(this);
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0 Tasproj v1.0";
Markers = new TasMovieMarkerList(this);
@@ -145,8 +153,8 @@ namespace BizHawk.Client.Common
/// The last frame that can be valid.
private void InvalidateAfter(int frame)
{
- var anyInvalidated = LagLog.RemoveFrom(frame);
- StateManager.Invalidate(frame + 1);
+ var anyInvalidated = _lagLog.RemoveFrom(frame);
+ _stateManager.Invalidate(frame + 1);
Changes = true; // TODO check if this actually removed anything before flagging changes
if (anyInvalidated && Global.MovieSession.Movie.IsCountingRerecords)
@@ -161,16 +169,16 @@ namespace BizHawk.Client.Common
///
public string DisplayValue(int frame, string buttonName)
{
- if (UseInputCache && InputStateCache.ContainsKey(frame))
+ if (UseInputCache && _inputStateCache.ContainsKey(frame))
{
- return CreateDisplayValueForButton(InputStateCache[frame], buttonName);
+ return CreateDisplayValueForButton(_inputStateCache[frame], buttonName);
}
var adapter = GetInputState(frame);
if (UseInputCache)
{
- InputStateCache.Add(frame, adapter);
+ _inputStateCache.Add(frame, adapter);
}
return CreateDisplayValueForButton(adapter, buttonName);
@@ -178,7 +186,7 @@ namespace BizHawk.Client.Common
public void FlushInputCache()
{
- InputStateCache.Clear();
+ _inputStateCache.Clear();
}
public string CreateDisplayValueForButton(IController adapter, string buttonName)
@@ -186,7 +194,7 @@ namespace BizHawk.Client.Common
if (adapter.Definition.BoolButtons.Contains(buttonName))
{
return adapter.IsPressed(buttonName)
- ? Mnemonics[buttonName].ToString()
+ ? _mnemonics[buttonName].ToString()
: "";
}
@@ -212,9 +220,9 @@ namespace BizHawk.Client.Common
public void ClearGreenzone()
{
- if (StateManager.Any())
+ if (_stateManager.Any())
{
- StateManager.ClearStateHistory();
+ _stateManager.ClearStateHistory();
Changes = true;
}
}
@@ -227,17 +235,17 @@ namespace BizHawk.Client.Common
LastPositionStable = false;
}
- LagLog[Global.Emulator.Frame] = Global.Emulator.AsInputPollable().IsLagFrame;
+ _lagLog[Global.Emulator.Frame] = Global.Emulator.AsInputPollable().IsLagFrame;
- if (!StateManager.HasState(Global.Emulator.Frame))
+ if (!_stateManager.HasState(Global.Emulator.Frame))
{
- StateManager.Capture();
+ _stateManager.Capture();
}
}
public void ClearLagLog()
{
- LagLog.Clear();
+ _lagLog.Clear();
}
public void DeleteLogBefore(int frame)
@@ -426,7 +434,7 @@ namespace BizHawk.Client.Common
if (TimelineBranchFrame.HasValue)
{
- LagLog.RemoveFrom(TimelineBranchFrame.Value);
+ _lagLog.RemoveFrom(TimelineBranchFrame.Value);
TasStateManager.Invalidate(TimelineBranchFrame.Value);
}
@@ -512,16 +520,16 @@ namespace BizHawk.Client.Common
// but if there's none, or only *after* divergent point, don't invalidate the entire movie anymore
if (divergentPoint.HasValue)
{
- StateManager.Invalidate(divergentPoint.Value);
- LagLog.FromLagLog(branch.LagLog); // don't truncate LagLog if the branch's one is shorter, but input is the same
+ _stateManager.Invalidate(divergentPoint.Value);
+ _lagLog.FromLagLog(branch.LagLog); // don't truncate LagLog if the branch's one is shorter, but input is the same
}
else
{
- StateManager.Invalidate(branch.InputLog.Count);
+ _stateManager.Invalidate(branch.InputLog.Count);
}
- StateManager.LoadBranch(Branches.IndexOf(branch));
- StateManager.SetState(branch.Frame, branch.CoreData);
+ _stateManager.LoadBranch(Branches.IndexOf(branch));
+ _stateManager.SetState(branch.Frame, branch.CoreData);
////ChangeLog = branch.ChangeLog;
if (BindMarkersToInput) // pretty critical not to erase them
diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs b/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs
index 044ddeea54..a854076f72 100644
--- a/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs
+++ b/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs
@@ -19,7 +19,7 @@ namespace BizHawk.Client.Common
}
///
- /// Parses a Marker from a line of text
+ /// Initializes a new instance of the class from a line of text
///
public TasMovieMarker(string line)
{
diff --git a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs
index 94971dd6c1..22ffc820aa 100644
--- a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs
+++ b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs
@@ -666,7 +666,9 @@ namespace BizHawk.Client.Common
////Used += len;
}
}
- catch (EndOfStreamException) { }
+ catch (EndOfStreamException)
+ {
+ }
}
public void SaveBranchStates(BinaryWriter bw)
@@ -707,7 +709,10 @@ namespace BizHawk.Client.Common
c--;
}
}
- catch (EndOfStreamException) { } // Bad!
+ catch (EndOfStreamException)
+ {
+ // Bad!
+ }
}
diff --git a/BizHawk.Client.Common/movie/tasproj/TasStateManagerSettings.cs b/BizHawk.Client.Common/movie/tasproj/TasStateManagerSettings.cs
index d0f39ed204..e834d62666 100644
--- a/BizHawk.Client.Common/movie/tasproj/TasStateManagerSettings.cs
+++ b/BizHawk.Client.Common/movie/tasproj/TasStateManagerSettings.cs
@@ -32,45 +32,45 @@ namespace BizHawk.Client.Common
///
[DisplayName("Save History")]
[Description("Whether or not to use savestate history")]
- public bool SaveStateHistory { get { return DiskSaveCapacitymb != 0; } }
+ public bool SaveStateHistory => DiskSaveCapacitymb != 0;
///
- /// The size limit to use when saving the tas project to disk.
+ /// Gets or sets the size limit to use when saving the TAS project to disk.
///
[DisplayName("Save Capacity (in megabytes)")]
[Description("The size limit to use when saving the tas project to disk.")]
public int DiskSaveCapacitymb { get; set; }
///
- /// The total amount of memory to devote to state history in megabytes
+ /// Gets or sets the total amount of memory to devote to state history in megabytes
///
[DisplayName("Capacity (in megabytes)")]
[Description("The size limit of the state history buffer. When this limit is reached it will start moving to disk.")]
public int Capacitymb { get; set; }
///
- /// The total amount of disk space to devote to state history in megabytes
+ /// Gets or sets the total amount of disk space to devote to state history in megabytes
///
[DisplayName("Disk Capacity (in megabytes)")]
[Description("The size limit of the state history buffer on the disk. When this limit is reached it will start removing previous savestates")]
public int DiskCapacitymb { get; set; }
///
- /// The amount of states to skip during project saving
+ /// Gets or sets the amount of states to skip during project saving
///
[DisplayName("State interval for .tasproj")]
[Description("The actual state gap in frames is calculated as Nth power on 2")]
public int StateGap { get; set; }
///
- /// Put branch states to .tasproj
+ /// Gets or sets a value indicating whether or not to save branch states into the movie file
///
[DisplayName("Put branch states to .tasproj")]
[Description("Put branch states to .tasproj")]
public bool BranchStatesInTasproj { get; set; }
///
- /// Erase branch states before greenzone states when capacity is met
+ /// Gets or sets a value indicating whether or not to erase branch states before greenzone states when capacity is met
///
[DisplayName("Erase branch states first")]
[Description("Erase branch states before greenzone states when capacity is met")]
@@ -116,33 +116,20 @@ namespace BizHawk.Client.Common
if (!int.TryParse(lines[0], out refCapacity))
{
- if (bool.Parse(lines[0]))
- DiskSaveCapacitymb = Capacitymb;
- else
- DiskSaveCapacitymb = 0;
+ DiskSaveCapacitymb = bool.Parse(lines[0]) ? Capacitymb : 0;
}
else
+ {
DiskSaveCapacitymb = refCapacity;
+ }
- if (lines.Length > 2)
- DiskCapacitymb = int.Parse(lines[2]);
- else
- DiskCapacitymb = 512;
+ DiskCapacitymb = lines.Length > 2 ? int.Parse(lines[2]) : 512;
- if (lines.Length > 3)
- BranchStatesInTasproj = bool.Parse(lines[3]);
- else
- BranchStatesInTasproj = false;
+ BranchStatesInTasproj = lines.Length > 3 && bool.Parse(lines[3]);
- if (lines.Length > 4)
- EraseBranchStatesFirst = bool.Parse(lines[4]);
- else
- EraseBranchStatesFirst = true;
+ EraseBranchStatesFirst = lines.Length <= 4 || bool.Parse(lines[4]);
- if (lines.Length > 5)
- StateGap = int.Parse(lines[5]);
- else
- StateGap = 4;
+ StateGap = lines.Length > 5 ? int.Parse(lines[5]) : 4;
}
catch (Exception) // TODO: this is bad
{
diff --git a/BizHawk.Client.Common/tools/Cheat.cs b/BizHawk.Client.Common/tools/Cheat.cs
index 4bc76388a0..c3fe344e9d 100644
--- a/BizHawk.Client.Common/tools/Cheat.cs
+++ b/BizHawk.Client.Common/tools/Cheat.cs
@@ -16,11 +16,10 @@ namespace BizHawk.Client.Common
}
private readonly Watch _watch;
+ private readonly COMPARISONTYPE _comparisonType;
private int? _compare;
private int _val;
private bool _enabled;
- private readonly COMPARISONTYPE _comparisonType;
-
public Cheat(Watch watch, int value, int? compare = null, bool enabled = true, COMPARISONTYPE comparisonType = COMPARISONTYPE.NONE)
{
diff --git a/BizHawk.Client.Common/tools/CheatList.cs b/BizHawk.Client.Common/tools/CheatList.cs
index d4615721e0..e924fb6f42 100644
--- a/BizHawk.Client.Common/tools/CheatList.cs
+++ b/BizHawk.Client.Common/tools/CheatList.cs
@@ -283,6 +283,7 @@ namespace BizHawk.Client.Common
/// Returns the value of a given cheat, or a partial value of a multi-byte cheat
/// Note that address + size MUST NOT exceed the range of the cheat or undefined behavior will occur
///
+ /// The to apply cheats to
/// The starting address for which you will get the number of bytes
/// The number of bytes of the cheat to return
/// The value, or null if it can't resolve the address with a given cheat
diff --git a/BizHawk.Client.Common/tools/Watch/Watch.cs b/BizHawk.Client.Common/tools/Watch/Watch.cs
index 045793b64d..37d4f7cf20 100644
--- a/BizHawk.Client.Common/tools/Watch/Watch.cs
+++ b/BizHawk.Client.Common/tools/Watch/Watch.cs
@@ -1,790 +1,790 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Diagnostics;
-
-using BizHawk.Common.NumberExtensions;
-using BizHawk.Emulation.Common;
-
-namespace BizHawk.Client.Common
-{
- ///
- /// This class holds a watch i.e. something inside a identified by an address
- /// with a specific size (8, 16 or 32bits).
- /// This is an abstract class
- ///
- [DebuggerDisplay("Note={Notes}, Value={ValueString}")]
- public abstract class Watch
- : IEquatable,
- IEquatable,
- IComparable
- {
- private MemoryDomain _domain;
- private DisplayType _type;
-
- ///
- /// Initializes a new instance of the class
- ///
- /// where you want to track
- /// The address you want to track
- /// A (byte, word, double word)
- /// How you you want to display the value See
- /// Specify the endianess. true for big endian
- /// A custom note about the
- /// Occurs when a is incompatible with the
- protected Watch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian, string note)
- {
- if (IsDiplayTypeAvailable(type))
- {
- _domain = domain;
- Address = address;
- Size = size;
- _type = type;
- BigEndian = bigEndian;
- Notes = note;
- }
- else
- {
- throw new ArgumentException($"DisplayType {type} is invalid for this type of Watch", nameof(type));
- }
- }
-
- #region Methods
-
- #region Static
-
- ///
- /// Generate sa from a given string
- /// String is tab separate
- ///
- /// Entire string, tab separated for each value Order is:
- ///
- /// -
- /// 0x00
- /// Address in hexadecimal
- ///
- /// -
- /// b,w or d
- /// The , byte, word or double word
- /// s, u, h, b, 1, 2, 3, f
- /// The signed, unsigned,etc...
- ///
- /// -
- /// 0 or 1
- /// Big endian or not
- ///
- /// -
- /// RDRAM,ROM,...
- /// The
- ///
- /// -
- /// Plain text
- /// Notes
- ///
- ///
- ///
- /// 's memory domain
- /// A brand new
- public static Watch FromString(string line, IMemoryDomains domains)
- {
- string[] parts = line.Split(new[] { '\t' }, 6);
-
- if (parts.Length < 6)
- {
- if (parts.Length >= 3 && parts[2] == "_")
- {
- return SeparatorWatch.Instance;
- }
-
- return null;
- }
-
- long address;
-
- if (long.TryParse(parts[0], NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address))
- {
- WatchSize size = SizeFromChar(parts[1][0]);
- DisplayType type = DisplayTypeFromChar(parts[2][0]);
- bool bigEndian = parts[3] != "0";
- MemoryDomain domain = domains[parts[4]];
- string notes = parts[5].Trim('\r', '\n');
-
- return GenerateWatch(
- domain,
- address,
- size,
- type,
- bigEndian,
- notes);
- }
-
- return null;
- }
-
- ///
- /// Generates a new instance
- /// Can be either , , or
- ///
- /// The where you want to watch
- /// The address into the
- /// The size
- /// How the watch will be displayed
- /// Endianess (true for big endian)
- /// A custom note about the
- /// The current watch value
- /// Previous value
- /// Number of changes occurs in current
- /// New instance. True type is depending of size parameter
- public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian, string note = "", long value = 0, long prev = 0, int changeCount = 0)
- {
- switch (size)
- {
- default:
- case WatchSize.Separator:
- return SeparatorWatch.Instance;
- case WatchSize.Byte:
- return new ByteWatch(domain, address, type, bigEndian, note, (byte)value, (byte)prev, changeCount);
- case WatchSize.Word:
- return new WordWatch(domain, address, type, bigEndian, note, (ushort)value, (ushort)prev, changeCount);
- case WatchSize.DWord:
- return new DWordWatch(domain, address, type, bigEndian, note, (uint)value, (uint)prev, changeCount);
- }
- }
-
- #region Operators
-
- ///
- /// Equality operator between two
- ///
- /// First watch
- /// Second watch
- /// True if both watch are equals; otherwise, false
- public static bool operator ==(Watch a, Watch b)
- {
- if (ReferenceEquals(a, null) || ReferenceEquals(b, null))
- {
- return false;
- }
-
- if (ReferenceEquals(a, b))
- {
- return true;
- }
-
- return a.Equals(b);
- }
-
- ///
- /// Equality operator between a and a
- ///
- /// The watch
- /// The cheat
- /// True if they are equals; otherwise, false
- public static bool operator ==(Watch a, Cheat b)
- {
- if (ReferenceEquals(a, null) || ReferenceEquals(b, null))
- {
- return false;
- }
-
- return a.Equals(b);
- }
-
- ///
- /// Inequality operator between two
- ///
- /// First watch
- /// Second watch
- /// True if both watch are different; otherwise, false
- public static bool operator !=(Watch a, Watch b)
- {
- return !(a == b);
- }
-
- ///
- /// Inequality operator between a and a
- ///
- /// The watch
- /// The cheat
- /// True if they are different; otherwise, false
- public static bool operator !=(Watch a, Cheat b)
- {
- return !(a == b);
- }
-
- ///
- /// Compare two together
- ///
- /// First
- /// Second
- /// True if first is lesser than b; otherwise, false
- /// Occurs when you try to compare two throughout different
- public static bool operator <(Watch a, Watch b)
- {
- return a.CompareTo(b) < 0;
- }
-
- ///
- /// Compare two together
- ///
- /// First
- /// Second
- /// True if first is greater than b; otherwise, false
- /// Occurs when you try to compare two throughout different
- public static bool operator >(Watch a, Watch b)
- {
- return a.CompareTo(b) > 0;
- }
-
- ///
- /// Compare two together
- ///
- /// First
- /// Second
- /// True if first is lesser or equals to b; otherwise, false
- /// Occurs when you try to compare two throughout different
- public static bool operator <=(Watch a, Watch b)
- {
- return a.CompareTo(b) <= 0;
- }
-
- ///
- /// Compare two together
- ///
- /// First
- /// Second
- /// True if first is greater or equals to b; otherwise, false
- /// Occurs when you try to compare two throughout different
- public static bool operator >=(Watch a, Watch b)
- {
- return a.CompareTo(b) >= 0;
- }
-
- #endregion Operators
-
- #endregion Static
-
- #region Abstracts
-
- ///
- /// Gets a list a that can be used for this
- ///
- /// An enumeration that contains all valid
- public abstract IEnumerable AvailableTypes();
-
- ///
- /// Resets the previous value; set it to the current one
- ///
- public abstract void ResetPrevious();
-
- ///
- /// Updates the Watch (read it from
- ///
- public abstract void Update();
-
- #endregion Abstracts
-
- #region Protected
-
- protected byte GetByte(bool bypassFreeze = false)
- {
- if (!bypassFreeze && Global.CheatList.IsActive(_domain, Address))
- {
- // LIAR logic
- return Global.CheatList.GetByteValue(_domain, Address) ?? 0;
- }
-
- if (_domain.Size == 0)
- {
- return _domain.PeekByte(Address);
- }
-
- return _domain.PeekByte(Address % _domain.Size);
- }
-
- protected ushort GetWord(bool bypassFreeze = false)
- {
- if (!bypassFreeze && Global.CheatList.IsActive(_domain, Address))
- {
- // LIAR logic
- return (ushort)(Global.CheatList.GetCheatValue(_domain, Address, WatchSize.Word) ?? 0);
- }
-
- if (_domain.Size == 0)
- {
- return _domain.PeekUshort(Address, BigEndian);
- }
-
- return _domain.PeekUshort(Address % _domain.Size, BigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
- }
-
- protected uint GetDWord(bool bypassFreeze = false)
- {
- if (!bypassFreeze && Global.CheatList.IsActive(_domain, Address))
- {
- // LIAR logic
- return (uint)(Global.CheatList.GetCheatValue(_domain, Address, WatchSize.DWord) ?? 0);
- }
-
- if (_domain.Size == 0)
- {
- return _domain.PeekUint(Address, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
- }
-
- return _domain.PeekUint(Address % _domain.Size, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
- }
-
- protected void PokeByte(byte val)
- {
- if (_domain.Size == 0)
- {
- _domain.PokeByte(Address, val);
- }
- else
- {
- _domain.PokeByte(Address % _domain.Size, val);
- }
- }
-
- protected void PokeWord(ushort val)
- {
- if (_domain.Size == 0)
- {
- _domain.PokeUshort(Address, val, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
- }
- else
- {
- _domain.PokeUshort(Address % _domain.Size, val, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
- }
- }
-
- protected void PokeDWord(uint val)
- {
- if (_domain.Size == 0)
- {
- _domain.PokeUint(Address, val, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
- }
- else
- {
- _domain.PokeUint(Address % _domain.Size, val, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
- }
- }
-
- #endregion Protected
-
- ///
- /// Sets the number of changes to 0
- ///
- public void ClearChangeCount()
- {
- ChangeCount = 0;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Diagnostics;
+
+using BizHawk.Common.NumberExtensions;
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Client.Common
+{
+ ///
+ /// This class holds a watch i.e. something inside a identified by an address
+ /// with a specific size (8, 16 or 32bits).
+ /// This is an abstract class
+ ///
+ [DebuggerDisplay("Note={Notes}, Value={ValueString}")]
+ public abstract class Watch
+ : IEquatable,
+ IEquatable,
+ IComparable
+ {
+ private MemoryDomain _domain;
+ private DisplayType _type;
+
+ ///
+ /// Initializes a new instance of the class
+ ///
+ /// where you want to track
+ /// The address you want to track
+ /// A (byte, word, double word)
+ /// How you you want to display the value See
+ /// Specify the endianess. true for big endian
+ /// A custom note about the
+ /// Occurs when a is incompatible with the
+ protected Watch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian, string note)
+ {
+ if (IsDiplayTypeAvailable(type))
+ {
+ _domain = domain;
+ Address = address;
+ Size = size;
+ _type = type;
+ BigEndian = bigEndian;
+ Notes = note;
+ }
+ else
+ {
+ throw new ArgumentException($"DisplayType {type} is invalid for this type of Watch", nameof(type));
+ }
}
- #region IEquatable
+ #region Methods
- ///
- /// Determines if this is equals to another
- ///
- /// The to compare
- /// True if both object are equals; otherwise, false
- public bool Equals(Watch other)
- {
- if (ReferenceEquals(other, null))
- {
- return false;
- }
-
- return _domain == other._domain &&
- Address == other.Address &&
- Size == other.Size;
+ #region Static
+
+ ///
+ /// Generate sa from a given string
+ /// String is tab separate
+ ///
+ /// Entire string, tab separated for each value Order is:
+ ///
+ /// -
+ /// 0x00
+ /// Address in hexadecimal
+ ///
+ /// -
+ /// b,w or d
+ /// The , byte, word or double word
+ /// s, u, h, b, 1, 2, 3, f
+ /// The signed, unsigned,etc...
+ ///
+ /// -
+ /// 0 or 1
+ /// Big endian or not
+ ///
+ /// -
+ /// RDRAM,ROM,...
+ /// The
+ ///
+ /// -
+ /// Plain text
+ /// Notes
+ ///
+ ///
+ ///
+ /// 's memory domain
+ /// A brand new
+ public static Watch FromString(string line, IMemoryDomains domains)
+ {
+ string[] parts = line.Split(new[] { '\t' }, 6);
+
+ if (parts.Length < 6)
+ {
+ if (parts.Length >= 3 && parts[2] == "_")
+ {
+ return SeparatorWatch.Instance;
+ }
+
+ return null;
+ }
+
+ long address;
+
+ if (long.TryParse(parts[0], NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address))
+ {
+ WatchSize size = SizeFromChar(parts[1][0]);
+ DisplayType type = DisplayTypeFromChar(parts[2][0]);
+ bool bigEndian = parts[3] != "0";
+ MemoryDomain domain = domains[parts[4]];
+ string notes = parts[5].Trim('\r', '\n');
+
+ return GenerateWatch(
+ domain,
+ address,
+ size,
+ type,
+ bigEndian,
+ notes);
+ }
+
+ return null;
}
- #endregion IEquatable
+ ///
+ /// Generates a new instance
+ /// Can be either , , or
+ ///
+ /// The where you want to watch
+ /// The address into the
+ /// The size
+ /// How the watch will be displayed
+ /// Endianess (true for big endian)
+ /// A custom note about the
+ /// The current watch value
+ /// Previous value
+ /// Number of changes occurs in current
+ /// New instance. True type is depending of size parameter
+ public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian, string note = "", long value = 0, long prev = 0, int changeCount = 0)
+ {
+ switch (size)
+ {
+ default:
+ case WatchSize.Separator:
+ return SeparatorWatch.Instance;
+ case WatchSize.Byte:
+ return new ByteWatch(domain, address, type, bigEndian, note, (byte)value, (byte)prev, changeCount);
+ case WatchSize.Word:
+ return new WordWatch(domain, address, type, bigEndian, note, (ushort)value, (ushort)prev, changeCount);
+ case WatchSize.DWord:
+ return new DWordWatch(domain, address, type, bigEndian, note, (uint)value, (uint)prev, changeCount);
+ }
+ }
- #region IEquatable
+ #region Operators
- ///
- /// Determines if this is equals to an instance of
- ///
- /// The to compare
- /// True if both object are equals; otherwise, false
- public bool Equals(Cheat other)
- {
- return !ReferenceEquals(other, null)
- && _domain == other.Domain
- && Address == other.Address
- && Size == other.Size;
- }
-
- #endregion IEquatable
-
- #region IComparable
-
- ///
- /// Compares two together and determine which one comes first.
- /// First we look the address and then the size
- ///
- /// The other to compare to
- /// 0 if they are equals, 1 if the other is greater, -1 if the other is lesser
- /// Occurs when you try to compare two throughout different
- public int CompareTo(Watch other)
- {
- if (_domain != other._domain)
- {
- throw new InvalidOperationException("Watch cannot be compared through different domain");
- }
-
- if (Equals(other))
- {
- return 0;
- }
-
- if (Address.Equals(other.Address))
- {
- return ((int)Size).CompareTo((int)other.Size);
- }
-
- return Address.CompareTo(other.Address);
- }
-
- #endregion IComparable
-
- ///
- /// Determines if this object is Equals to another
- ///
- /// The object to compare
- /// True if both object are equals; otherwise, false
- public override bool Equals(object obj)
- {
- if (obj is Watch)
- {
- return Equals((Watch)obj);
- }
-
- if (obj is Cheat)
- {
- return Equals((Cheat)obj);
- }
-
- return base.Equals(obj);
- }
-
- ///
- /// Hash the current watch and gets a unique value
- ///
- /// that can serves as a unique representation of current Watch
- public override int GetHashCode()
- {
- return Domain.GetHashCode() + (int)Address;
- }
-
- ///
- /// Determines if the specified can be
- /// used for the current
- ///
- /// you want to check
- public bool IsDiplayTypeAvailable(DisplayType type)
- {
- return AvailableTypes().Any(d => d == type);
- }
-
- ///
- /// Transforms the current instance into a string
- ///
- /// A representation of the current
- public override string ToString()
- {
- return $"{(Domain == null && Address == 0 ? "0" : Address.ToHexString((Domain?.Size ?? 0xFF - 1).NumHexDigits()))}\t{SizeAsChar}\t{TypeAsChar}\t{Convert.ToInt32(BigEndian)}\t{Domain?.Name}\t{Notes.Trim('\r', '\n')}";
- }
-
- ///
- /// Transform the current instance into a displayable (short representation) string
- /// It's used by the "Display on screen" option in the RamWatch window
- ///
- /// A well formatted string representation
- public virtual string ToDisplayString()
- {
- return $"{Notes}: {ValueString}";
- }
-
- #endregion
-
- #region Properties
-
- #region Abstracts
-
- ///
- /// Gets a string representation of difference
- /// between current value and the previous one
- ///
- public abstract string Diff { get; }
-
- ///
- /// Gets the maximum possible value
- ///
- public abstract uint MaxValue { get; }
-
- ///
- /// Gets the current value
- ///
- public abstract int Value { get; }
-
- ///
- /// Gets the current value
- /// but with stuff I don't understand
- ///
- /// zero 15-nov-2015 - bypass LIAR LOGIC, see fdc9ea2aa922876d20ba897fb76909bf75fa6c92 https://github.com/TASVideos/BizHawk/issues/326
- public abstract int ValueNoFreeze { get; }
-
- ///
- /// Gets a string representation of the current value
- ///
- public abstract string ValueString { get; }
-
- ///
- /// Try to sets the value into the
- /// at the current address
- ///
- /// Value to set
- /// True if value successfully sets; otherwise, false
- public abstract bool Poke(string value);
-
- ///
- /// Gets the previous value
- ///
- public abstract int Previous { get; }
-
- ///
- /// Gets a string representation of the previous value
- ///
- public abstract string PreviousStr { get; }
-
- #endregion Abstracts
-
- ///
- /// Gets the address in the
- ///
- public long Address { get; }
-
- private string AddressFormatStr
- {
- get
- {
- if (_domain != null)
- {
- return "X" + (_domain.Size - 1).NumHexDigits();
- }
-
- return "";
- }
- }
-
- ///
- /// Gets the address in the formatted as string
- ///
- public string AddressString => Address.ToString(AddressFormatStr);
-
- ///
- /// Gets or sets a value indicating the endianess of current
- /// True for big endian, flase for little endian
- ///
- public bool BigEndian { get; set; }
-
- ///
- /// Gets or sets the number of times that value of current value has changed
- ///
- public int ChangeCount { get; protected set; }
-
- ///
- /// Gets or sets the way current is displayed
- ///
- /// Occurs when a is incompatible with the
- public DisplayType Type
- {
- get
- {
- return _type;
- }
-
- set
- {
- if (IsDiplayTypeAvailable(value))
- {
- _type = value;
- }
- else
- {
- throw new ArgumentException($"DisplayType {value} is invalid for this type of Watch");
- }
- }
- }
-
- ///
- /// Gets the current
- ///
- public MemoryDomain Domain
- {
- get
- {
- return _domain;
- }
-
- internal set
- {
- if (value != null && _domain.Name == value.Name)
- {
- _domain = value;
- }
- else
- {
- throw new InvalidOperationException("You cannot set a different domain to a watch on the fly");
- }
- }
- }
-
- ///
- /// Gets a value indicating whether the current address is
- /// within in the range of current
- ///
- public bool IsOutOfRange => !IsSeparator && _domain.Size != 0 && Address >= _domain.Size;
-
- ///
- /// Gets a value that defined if the current is actually a
- ///
- public bool IsSeparator => this is SeparatorWatch;
-
- ///
- /// Gets or sets notes for current
- ///
- public string Notes { get; set; }
-
- ///
- /// Gets the current size of the watch
- ///
- public WatchSize Size { get; }
-
- #endregion
-
- // TODO: Replace all the following stuff by implementing ISerializable
- public static string DisplayTypeToString(DisplayType type)
- {
- switch (type)
- {
- default:
- return type.ToString();
- case DisplayType.FixedPoint_12_4:
- return "Fixed Point 12.4";
- case DisplayType.FixedPoint_20_12:
- return "Fixed Point 20.12";
- case DisplayType.FixedPoint_16_16:
- return "Fixed Point 16.16";
- }
- }
-
- public static DisplayType StringToDisplayType(string name)
- {
- switch (name)
- {
- default:
- return (DisplayType)Enum.Parse(typeof(DisplayType), name);
- case "Fixed Point 12.4":
- return DisplayType.FixedPoint_12_4;
- case "Fixed Point 20.12":
- return DisplayType.FixedPoint_20_12;
- case "Fixed Point 16.16":
- return DisplayType.FixedPoint_16_16;
- }
- }
-
- public char SizeAsChar
- {
- get
- {
- switch (Size)
- {
- default:
- case WatchSize.Separator:
- return 'S';
- case WatchSize.Byte:
- return 'b';
- case WatchSize.Word:
- return 'w';
- case WatchSize.DWord:
- return 'd';
- }
- }
- }
-
- public static WatchSize SizeFromChar(char c)
- {
- switch (c)
- {
- default:
- case 'S':
- return WatchSize.Separator;
- case 'b':
- return WatchSize.Byte;
- case 'w':
- return WatchSize.Word;
- case 'd':
- return WatchSize.DWord;
- }
- }
-
- public char TypeAsChar
- {
- get
- {
- switch (Type)
- {
- default:
- case DisplayType.Separator:
- return '_';
- case DisplayType.Unsigned:
- return 'u';
- case DisplayType.Signed:
- return 's';
- case DisplayType.Hex:
- return 'h';
- case DisplayType.Binary:
- return 'b';
- case DisplayType.FixedPoint_12_4:
- return '1';
- case DisplayType.FixedPoint_20_12:
- return '2';
- case DisplayType.FixedPoint_16_16:
- return '3';
- case DisplayType.Float:
- return 'f';
- }
- }
- }
-
- public static DisplayType DisplayTypeFromChar(char c)
- {
- switch (c)
- {
- default:
- case '_':
- return DisplayType.Separator;
- case 'u':
- return DisplayType.Unsigned;
- case 's':
- return DisplayType.Signed;
- case 'h':
- return DisplayType.Hex;
- case 'b':
- return DisplayType.Binary;
- case '1':
- return DisplayType.FixedPoint_12_4;
- case '2':
- return DisplayType.FixedPoint_20_12;
- case '3':
- return DisplayType.FixedPoint_16_16;
- case 'f':
- return DisplayType.Float;
- }
- }
- }
-}
+ ///
+ /// Equality operator between two
+ ///
+ /// First watch
+ /// Second watch
+ /// True if both watch are equals; otherwise, false
+ public static bool operator ==(Watch a, Watch b)
+ {
+ if (ReferenceEquals(a, null) || ReferenceEquals(b, null))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(a, b))
+ {
+ return true;
+ }
+
+ return a.Equals(b);
+ }
+
+ ///
+ /// Equality operator between a and a
+ ///
+ /// The watch
+ /// The cheat
+ /// True if they are equals; otherwise, false
+ public static bool operator ==(Watch a, Cheat b)
+ {
+ if (ReferenceEquals(a, null) || ReferenceEquals(b, null))
+ {
+ return false;
+ }
+
+ return a.Equals(b);
+ }
+
+ ///
+ /// Inequality operator between two
+ ///
+ /// First watch
+ /// Second watch
+ /// True if both watch are different; otherwise, false
+ public static bool operator !=(Watch a, Watch b)
+ {
+ return !(a == b);
+ }
+
+ ///
+ /// Inequality operator between a and a
+ ///
+ /// The watch
+ /// The cheat
+ /// True if they are different; otherwise, false
+ public static bool operator !=(Watch a, Cheat b)
+ {
+ return !(a == b);
+ }
+
+ ///
+ /// Compare two together
+ ///
+ /// First
+ /// Second
+ /// True if first is lesser than b; otherwise, false
+ /// Occurs when you try to compare two throughout different
+ public static bool operator <(Watch a, Watch b)
+ {
+ return a.CompareTo(b) < 0;
+ }
+
+ ///
+ /// Compare two together
+ ///
+ /// First
+ /// Second
+ /// True if first is greater than b; otherwise, false
+ /// Occurs when you try to compare two throughout different
+ public static bool operator >(Watch a, Watch b)
+ {
+ return a.CompareTo(b) > 0;
+ }
+
+ ///
+ /// Compare two together
+ ///
+ /// First
+ /// Second
+ /// True if first is lesser or equals to b; otherwise, false
+ /// Occurs when you try to compare two throughout different
+ public static bool operator <=(Watch a, Watch b)
+ {
+ return a.CompareTo(b) <= 0;
+ }
+
+ ///
+ /// Compare two together
+ ///
+ /// First
+ /// Second
+ /// True if first is greater or equals to b; otherwise, false
+ /// Occurs when you try to compare two throughout different
+ public static bool operator >=(Watch a, Watch b)
+ {
+ return a.CompareTo(b) >= 0;
+ }
+
+ #endregion Operators
+
+ #endregion Static
+
+ #region Abstracts
+
+ ///
+ /// Gets a list a that can be used for this
+ ///
+ /// An enumeration that contains all valid
+ public abstract IEnumerable AvailableTypes();
+
+ ///
+ /// Resets the previous value; set it to the current one
+ ///
+ public abstract void ResetPrevious();
+
+ ///
+ /// Updates the Watch (read it from
+ ///
+ public abstract void Update();
+
+ #endregion Abstracts
+
+ #region Protected
+
+ protected byte GetByte(bool bypassFreeze = false)
+ {
+ if (!bypassFreeze && Global.CheatList.IsActive(_domain, Address))
+ {
+ // LIAR logic
+ return Global.CheatList.GetByteValue(_domain, Address) ?? 0;
+ }
+
+ if (_domain.Size == 0)
+ {
+ return _domain.PeekByte(Address);
+ }
+
+ return _domain.PeekByte(Address % _domain.Size);
+ }
+
+ protected ushort GetWord(bool bypassFreeze = false)
+ {
+ if (!bypassFreeze && Global.CheatList.IsActive(_domain, Address))
+ {
+ // LIAR logic
+ return (ushort)(Global.CheatList.GetCheatValue(_domain, Address, WatchSize.Word) ?? 0);
+ }
+
+ if (_domain.Size == 0)
+ {
+ return _domain.PeekUshort(Address, BigEndian);
+ }
+
+ return _domain.PeekUshort(Address % _domain.Size, BigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
+ }
+
+ protected uint GetDWord(bool bypassFreeze = false)
+ {
+ if (!bypassFreeze && Global.CheatList.IsActive(_domain, Address))
+ {
+ // LIAR logic
+ return (uint)(Global.CheatList.GetCheatValue(_domain, Address, WatchSize.DWord) ?? 0);
+ }
+
+ if (_domain.Size == 0)
+ {
+ return _domain.PeekUint(Address, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
+ }
+
+ return _domain.PeekUint(Address % _domain.Size, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
+ }
+
+ protected void PokeByte(byte val)
+ {
+ if (_domain.Size == 0)
+ {
+ _domain.PokeByte(Address, val);
+ }
+ else
+ {
+ _domain.PokeByte(Address % _domain.Size, val);
+ }
+ }
+
+ protected void PokeWord(ushort val)
+ {
+ if (_domain.Size == 0)
+ {
+ _domain.PokeUshort(Address, val, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
+ }
+ else
+ {
+ _domain.PokeUshort(Address % _domain.Size, val, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
+ }
+ }
+
+ protected void PokeDWord(uint val)
+ {
+ if (_domain.Size == 0)
+ {
+ _domain.PokeUint(Address, val, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
+ }
+ else
+ {
+ _domain.PokeUint(Address % _domain.Size, val, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain
+ }
+ }
+
+ #endregion Protected
+
+ ///
+ /// Sets the number of changes to 0
+ ///
+ public void ClearChangeCount()
+ {
+ ChangeCount = 0;
+ }
+
+ #region IEquatable
+
+ ///
+ /// Determines if this is equals to another
+ ///
+ /// The to compare
+ /// True if both object are equals; otherwise, false
+ public bool Equals(Watch other)
+ {
+ if (ReferenceEquals(other, null))
+ {
+ return false;
+ }
+
+ return _domain == other._domain &&
+ Address == other.Address &&
+ Size == other.Size;
+ }
+
+ #endregion IEquatable
+
+ #region IEquatable
+
+ ///
+ /// Determines if this is equals to an instance of
+ ///
+ /// The to compare
+ /// True if both object are equals; otherwise, false
+ public bool Equals(Cheat other)
+ {
+ return !ReferenceEquals(other, null)
+ && _domain == other.Domain
+ && Address == other.Address
+ && Size == other.Size;
+ }
+
+ #endregion IEquatable
+
+ #region IComparable
+
+ ///
+ /// Compares two together and determine which one comes first.
+ /// First we look the address and then the size
+ ///
+ /// The other to compare to
+ /// 0 if they are equals, 1 if the other is greater, -1 if the other is lesser
+ /// Occurs when you try to compare two throughout different
+ public int CompareTo(Watch other)
+ {
+ if (_domain != other._domain)
+ {
+ throw new InvalidOperationException("Watch cannot be compared through different domain");
+ }
+
+ if (Equals(other))
+ {
+ return 0;
+ }
+
+ if (Address.Equals(other.Address))
+ {
+ return ((int)Size).CompareTo((int)other.Size);
+ }
+
+ return Address.CompareTo(other.Address);
+ }
+
+ #endregion IComparable
+
+ ///
+ /// Determines if this object is Equals to another
+ ///
+ /// The object to compare
+ /// True if both object are equals; otherwise, false
+ public override bool Equals(object obj)
+ {
+ if (obj is Watch)
+ {
+ return Equals((Watch)obj);
+ }
+
+ if (obj is Cheat)
+ {
+ return Equals((Cheat)obj);
+ }
+
+ return base.Equals(obj);
+ }
+
+ ///
+ /// Hash the current watch and gets a unique value
+ ///
+ /// that can serves as a unique representation of current Watch
+ public override int GetHashCode()
+ {
+ return Domain.GetHashCode() + (int)Address;
+ }
+
+ ///
+ /// Determines if the specified can be
+ /// used for the current
+ ///
+ /// you want to check
+ public bool IsDiplayTypeAvailable(DisplayType type)
+ {
+ return AvailableTypes().Any(d => d == type);
+ }
+
+ ///
+ /// Transforms the current instance into a string
+ ///
+ /// A representation of the current
+ public override string ToString()
+ {
+ return $"{(Domain == null && Address == 0 ? "0" : Address.ToHexString((Domain?.Size ?? 0xFF - 1).NumHexDigits()))}\t{SizeAsChar}\t{TypeAsChar}\t{Convert.ToInt32(BigEndian)}\t{Domain?.Name}\t{Notes.Trim('\r', '\n')}";
+ }
+
+ ///
+ /// Transform the current instance into a displayable (short representation) string
+ /// It's used by the "Display on screen" option in the RamWatch window
+ ///
+ /// A well formatted string representation
+ public virtual string ToDisplayString()
+ {
+ return $"{Notes}: {ValueString}";
+ }
+
+ #endregion
+
+ #region Properties
+
+ #region Abstracts
+
+ ///
+ /// Gets a string representation of difference
+ /// between current value and the previous one
+ ///
+ public abstract string Diff { get; }
+
+ ///
+ /// Gets the maximum possible value
+ ///
+ public abstract uint MaxValue { get; }
+
+ ///
+ /// Gets the current value
+ ///
+ public abstract int Value { get; }
+
+ ///
+ /// Gets the current value
+ /// but with stuff I don't understand
+ ///
+ /// zero 15-nov-2015 - bypass LIAR LOGIC, see fdc9ea2aa922876d20ba897fb76909bf75fa6c92 https://github.com/TASVideos/BizHawk/issues/326
+ public abstract int ValueNoFreeze { get; }
+
+ ///
+ /// Gets a string representation of the current value
+ ///
+ public abstract string ValueString { get; }
+
+ ///
+ /// Try to sets the value into the
+ /// at the current address
+ ///
+ /// Value to set
+ /// True if value successfully sets; otherwise, false
+ public abstract bool Poke(string value);
+
+ ///
+ /// Gets the previous value
+ ///
+ public abstract int Previous { get; }
+
+ ///
+ /// Gets a string representation of the previous value
+ ///
+ public abstract string PreviousStr { get; }
+
+ #endregion Abstracts
+
+ ///
+ /// Gets the address in the
+ ///
+ public long Address { get; }
+
+ private string AddressFormatStr
+ {
+ get
+ {
+ if (_domain != null)
+ {
+ return "X" + (_domain.Size - 1).NumHexDigits();
+ }
+
+ return "";
+ }
+ }
+
+ ///
+ /// Gets the address in the formatted as string
+ ///
+ public string AddressString => Address.ToString(AddressFormatStr);
+
+ ///
+ /// Gets or sets a value indicating the endianess of current
+ /// True for big endian, false for little endian
+ ///
+ public bool BigEndian { get; set; }
+
+ ///
+ /// Gets or sets the number of times that value of current value has changed
+ ///
+ public int ChangeCount { get; protected set; }
+
+ ///
+ /// Gets or sets the way current is displayed
+ ///
+ /// Occurs when a is incompatible with the
+ public DisplayType Type
+ {
+ get
+ {
+ return _type;
+ }
+
+ set
+ {
+ if (IsDiplayTypeAvailable(value))
+ {
+ _type = value;
+ }
+ else
+ {
+ throw new ArgumentException($"DisplayType {value} is invalid for this type of Watch");
+ }
+ }
+ }
+
+ ///
+ /// Gets the current
+ ///
+ public MemoryDomain Domain
+ {
+ get
+ {
+ return _domain;
+ }
+
+ internal set
+ {
+ if (value != null && _domain.Name == value.Name)
+ {
+ _domain = value;
+ }
+ else
+ {
+ throw new InvalidOperationException("You cannot set a different domain to a watch on the fly");
+ }
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether the current address is
+ /// within in the range of current
+ ///
+ public bool IsOutOfRange => !IsSeparator && _domain.Size != 0 && Address >= _domain.Size;
+
+ ///
+ /// Gets a value that defined if the current is actually a
+ ///
+ public bool IsSeparator => this is SeparatorWatch;
+
+ ///
+ /// Gets or sets notes for current
+ ///
+ public string Notes { get; set; }
+
+ ///
+ /// Gets the current size of the watch
+ ///
+ public WatchSize Size { get; }
+
+ #endregion
+
+ // TODO: Replace all the following stuff by implementing ISerializable
+ public static string DisplayTypeToString(DisplayType type)
+ {
+ switch (type)
+ {
+ default:
+ return type.ToString();
+ case DisplayType.FixedPoint_12_4:
+ return "Fixed Point 12.4";
+ case DisplayType.FixedPoint_20_12:
+ return "Fixed Point 20.12";
+ case DisplayType.FixedPoint_16_16:
+ return "Fixed Point 16.16";
+ }
+ }
+
+ public static DisplayType StringToDisplayType(string name)
+ {
+ switch (name)
+ {
+ default:
+ return (DisplayType)Enum.Parse(typeof(DisplayType), name);
+ case "Fixed Point 12.4":
+ return DisplayType.FixedPoint_12_4;
+ case "Fixed Point 20.12":
+ return DisplayType.FixedPoint_20_12;
+ case "Fixed Point 16.16":
+ return DisplayType.FixedPoint_16_16;
+ }
+ }
+
+ public char SizeAsChar
+ {
+ get
+ {
+ switch (Size)
+ {
+ default:
+ case WatchSize.Separator:
+ return 'S';
+ case WatchSize.Byte:
+ return 'b';
+ case WatchSize.Word:
+ return 'w';
+ case WatchSize.DWord:
+ return 'd';
+ }
+ }
+ }
+
+ public static WatchSize SizeFromChar(char c)
+ {
+ switch (c)
+ {
+ default:
+ case 'S':
+ return WatchSize.Separator;
+ case 'b':
+ return WatchSize.Byte;
+ case 'w':
+ return WatchSize.Word;
+ case 'd':
+ return WatchSize.DWord;
+ }
+ }
+
+ public char TypeAsChar
+ {
+ get
+ {
+ switch (Type)
+ {
+ default:
+ case DisplayType.Separator:
+ return '_';
+ case DisplayType.Unsigned:
+ return 'u';
+ case DisplayType.Signed:
+ return 's';
+ case DisplayType.Hex:
+ return 'h';
+ case DisplayType.Binary:
+ return 'b';
+ case DisplayType.FixedPoint_12_4:
+ return '1';
+ case DisplayType.FixedPoint_20_12:
+ return '2';
+ case DisplayType.FixedPoint_16_16:
+ return '3';
+ case DisplayType.Float:
+ return 'f';
+ }
+ }
+ }
+
+ public static DisplayType DisplayTypeFromChar(char c)
+ {
+ switch (c)
+ {
+ default:
+ case '_':
+ return DisplayType.Separator;
+ case 'u':
+ return DisplayType.Unsigned;
+ case 's':
+ return DisplayType.Signed;
+ case 'h':
+ return DisplayType.Hex;
+ case 'b':
+ return DisplayType.Binary;
+ case '1':
+ return DisplayType.FixedPoint_12_4;
+ case '2':
+ return DisplayType.FixedPoint_20_12;
+ case '3':
+ return DisplayType.FixedPoint_16_16;
+ case 'f':
+ return DisplayType.Float;
+ }
+ }
+ }
+}
diff --git a/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs b/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs
index f1288af7db..37d4b0da37 100644
--- a/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs
+++ b/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs
@@ -29,30 +29,27 @@ namespace BizHawk.Client.Common
public const string DOMAIN = "DomainColumn";
public const string NOTES = "NotesColumn";
- private static readonly WatchDomainComparer domainComparer = new WatchDomainComparer();
- private static readonly WatchAddressComparer addressComparer = new WatchAddressComparer();
- private static readonly WatchValueComparer valueComparer = new WatchValueComparer();
- private static readonly WatchPreviousValueComparer previousValueComparer = new WatchPreviousValueComparer();
- private static readonly WatchValueDifferenceComparer valueDifferenceComparer = new WatchValueDifferenceComparer();
- private static readonly WatchChangeCountComparer changeCountComparer = new WatchChangeCountComparer();
- private static readonly WatchNoteComparer noteComparer = new WatchNoteComparer();
+ private static readonly WatchDomainComparer DomainComparer = new WatchDomainComparer();
+ private static readonly WatchAddressComparer AddressComparer = new WatchAddressComparer();
+ private static readonly WatchValueComparer ValueComparer = new WatchValueComparer();
+ private static readonly WatchPreviousValueComparer PreviousValueComparer = new WatchPreviousValueComparer();
+ private static readonly WatchValueDifferenceComparer ValueDifferenceComparer = new WatchValueDifferenceComparer();
+ private static readonly WatchChangeCountComparer ChangeCountComparer = new WatchChangeCountComparer();
+ private static readonly WatchNoteComparer NoteComparer = new WatchNoteComparer();
+ private readonly List _watchList = new List(0);
+ private readonly string _systemid;
private IMemoryDomains _memoryDomains;
- private List _watchList = new List(0);
- private string _currentFilename = "";
- private string _systemid;
-
#endregion
#region cTor(s)
///
- /// Initialize a new instance of that will
- /// contains a set of
+ /// Initializes a new instance of the class
+ /// that will contains a set of
///
- /// All available memomry domains
- /// Domain you want to watch
+ /// All available memory domains
/// System identifier (NES, SNES, ...)
public WatchList(IMemoryDomains core, string systemid)
{
@@ -84,7 +81,7 @@ namespace BizHawk.Client.Common
{
_watchList.Clear();
Changes = false;
- _currentFilename = "";
+ CurrentFileName = "";
}
///
@@ -92,7 +89,6 @@ namespace BizHawk.Client.Common
/// specified
///
/// The object to
- ///
public bool Contains(Watch watch)
{
return _watchList.Contains(watch);
@@ -187,7 +183,7 @@ namespace BizHawk.Client.Common
return GetEnumerator();
}
- #endregion IEnumerable
+ #endregion IEnumerable
///
/// Add an existing collection of into the current one
@@ -196,7 +192,7 @@ namespace BizHawk.Client.Common
/// of watch to merge
public void AddRange(IEnumerable watches)
{
- Parallel.ForEach(watches, watch =>
+ Parallel.ForEach(watches, watch =>
{
if (!_watchList.Contains(watch))
{
@@ -211,14 +207,14 @@ namespace BizHawk.Client.Common
///
public void ClearChangeCounts()
{
- Parallel.ForEach(_watchList, watch => watch.ClearChangeCount());
+ Parallel.ForEach(_watchList, watch => watch.ClearChangeCount());
}
///
/// Sort the current list based on one of the constant
///
/// Value that specify sorting base
- /// Value that define the ordering. Ascending (true) or desceding (false)
+ /// Value that define the ordering. Ascending (true) or descending (false)
public void OrderWatches(string column, bool reverse)
{
switch (column)
@@ -226,7 +222,7 @@ namespace BizHawk.Client.Common
case ADDRESS:
if (reverse)
{
- _watchList.Sort(addressComparer);
+ _watchList.Sort(AddressComparer);
_watchList.Reverse();
}
else
@@ -239,12 +235,12 @@ namespace BizHawk.Client.Common
case VALUE:
if (reverse)
{
- _watchList.Sort(valueComparer);
+ _watchList.Sort(ValueComparer);
_watchList.Reverse();
}
else
{
- _watchList.Sort(valueComparer);
+ _watchList.Sort(ValueComparer);
}
break;
@@ -252,12 +248,12 @@ namespace BizHawk.Client.Common
case PREV:
if (reverse)
{
- _watchList.Sort(previousValueComparer);
+ _watchList.Sort(PreviousValueComparer);
_watchList.Reverse();
}
else
{
- _watchList.Sort(previousValueComparer);
+ _watchList.Sort(PreviousValueComparer);
}
break;
@@ -265,24 +261,25 @@ namespace BizHawk.Client.Common
case DIFF:
if (reverse)
{
- _watchList.Sort(valueDifferenceComparer);
+ _watchList.Sort(ValueDifferenceComparer);
_watchList.Reverse();
}
else
{
- _watchList.Sort(valueDifferenceComparer);
+ _watchList.Sort(ValueDifferenceComparer);
}
+
break;
case CHANGES:
if (reverse)
{
- _watchList.Sort(changeCountComparer);
+ _watchList.Sort(ChangeCountComparer);
_watchList.Reverse();
}
else
{
- _watchList.Sort(changeCountComparer);
+ _watchList.Sort(ChangeCountComparer);
}
break;
@@ -290,12 +287,12 @@ namespace BizHawk.Client.Common
case DOMAIN:
if (reverse)
{
- _watchList.Sort(domainComparer);
+ _watchList.Sort(DomainComparer);
_watchList.Reverse();
}
else
{
- _watchList.Sort(domainComparer);
+ _watchList.Sort(DomainComparer);
}
break;
@@ -303,12 +300,12 @@ namespace BizHawk.Client.Common
case NOTES:
if (reverse)
{
- _watchList.Sort(noteComparer);
+ _watchList.Sort(NoteComparer);
_watchList.Reverse();
}
else
{
- _watchList.Sort(noteComparer);
+ _watchList.Sort(NoteComparer);
}
break;
@@ -323,7 +320,7 @@ namespace BizHawk.Client.Common
public void RefreshDomains(IMemoryDomains core)
{
_memoryDomains = core;
- Parallel.ForEach(_watchList, watch =>
+ Parallel.ForEach(_watchList, watch =>
{
if (watch.IsSeparator)
{
@@ -338,11 +335,11 @@ namespace BizHawk.Client.Common
}
///
- /// Updates all ine the current collection
+ /// Updates all in the current collection
///
public void UpdateValues()
{
- Parallel.ForEach(_watchList, watch =>
+ Parallel.ForEach(_watchList, watch =>
{
watch.Update();
});
@@ -357,25 +354,13 @@ namespace BizHawk.Client.Common
///
/// Gets the number of elements contained in this
///
- public int Count
- {
- get
- {
- return _watchList.Count;
- }
- }
+ public int Count => _watchList.Count;
///
- /// is alsways read-write
+ /// is always read-write
/// so this value will be always false
///
- public bool IsReadOnly
- {
- get
- {
- return false;
- }
- }
+ public bool IsReadOnly => false;
#endregion ICollection
@@ -392,6 +377,7 @@ namespace BizHawk.Client.Common
{
return _watchList[index];
}
+
set
{
_watchList[index] = value;
@@ -401,24 +387,14 @@ namespace BizHawk.Client.Common
#endregion IList
///
- /// Gets a value indicating if collection has changed or not
+ /// Gets or sets a value indicating whether the collection has changed or not
///
public bool Changes { get; set; }
///
/// Gets or sets current 's filename
///
- public string CurrentFileName
- {
- get
- {
- return _currentFilename;
- }
- set
- {
- _currentFilename = value;
- }
- }
+ public string CurrentFileName { get; set; }
///
/// Gets the number of that are not
@@ -427,7 +403,7 @@ namespace BizHawk.Client.Common
{
get
{
- return _watchList.Count(watch => !watch.IsSeparator);
+ return _watchList.Count(watch => !watch.IsSeparator);
}
}
@@ -613,7 +589,7 @@ namespace BizHawk.Client.Common
notes));
}
- _currentFilename = path;
+ CurrentFileName = path;
}
if (!append)
diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings
index ed3338b64a..5261a70afc 100644
--- a/BizHawk.sln.DotSettings
+++ b/BizHawk.sln.DotSettings
@@ -70,6 +70,7 @@
OSD
PAL
PC
+ PCE
PCECD
PSP
PSX