diff --git a/BizHawk.Client.Common/BinarySaveStates.cs b/BizHawk.Client.Common/BinarySaveStates.cs index 7b8a3a7ab4..9ef4aa1023 100644 --- a/BizHawk.Client.Common/BinarySaveStates.cs +++ b/BizHawk.Client.Common/BinarySaveStates.cs @@ -327,8 +327,8 @@ namespace BizHawk.Client.Common { _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); + ////_zip = new SharpZipWriter(path, Global.Config.SaveStateCompressionLevelNormal); + ////_zip = new SevenZipWriter(path, Global.Config.SaveStateCompressionLevelNormal); if (notamovie) { diff --git a/BizHawk.Client.Common/ControllerBinding.cs b/BizHawk.Client.Common/ControllerBinding.cs index 5aa86244b9..62ce889c64 100644 --- a/BizHawk.Client.Common/ControllerBinding.cs +++ b/BizHawk.Client.Common/ControllerBinding.cs @@ -160,7 +160,7 @@ namespace BizHawk.Client.Common public void ApplyAxisConstraints(string constraintClass) { - _type.ApplyAxisConstraints(constraintClass,_floatButtons); + _type.ApplyAxisConstraints(constraintClass, _floatButtons); } /// diff --git a/BizHawk.Client.Common/CoreFileProvider.cs b/BizHawk.Client.Common/CoreFileProvider.cs index dce89b5e2c..44b7993b37 100644 --- a/BizHawk.Client.Common/CoreFileProvider.cs +++ b/BizHawk.Client.Common/CoreFileProvider.cs @@ -135,7 +135,7 @@ namespace BizHawk.Client.Common string superhack = null; if (target.CoreFileProvider != null && target.CoreFileProvider is CoreFileProvider) { - superhack = ((CoreFileProvider)target.CoreFileProvider ).SubfileDirectory; + superhack = ((CoreFileProvider)target.CoreFileProvider).SubfileDirectory; } var cfp = new CoreFileProvider(target.ShowMessage) { SubfileDirectory = superhack }; diff --git a/BizHawk.Client.Common/Global.cs b/BizHawk.Client.Common/Global.cs index 0674a15acd..718029df6d 100644 --- a/BizHawk.Client.Common/Global.cs +++ b/BizHawk.Client.Common/Global.cs @@ -42,7 +42,7 @@ namespace BizHawk.Client.Common // the original source controller, bound to the user, sort of the "input" port for the chain, i think public static Controller ActiveController; - //rapid fire version on the user controller, has its own key bindings and is OR'ed against ActiveController + // rapid fire version on the user controller, has its own key bindings and is OR'ed against ActiveController public static AutofireController AutoFireController; // the "output" port for the controller chain. @@ -79,7 +79,7 @@ namespace BizHawk.Client.Common { get { - switch(Emulator.SystemId) + switch (Emulator.SystemId) { default: case "NULL": diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index 0592b4b883..91007b5cb6 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -394,7 +394,7 @@ namespace BizHawk.Client.Common } else { - sw.WriteLine("Disc was identified (99.99% confidently) as known good with disc id hash CRC32:{0:X8}",discHash); + sw.WriteLine("Disc was identified (99.99% confidently) as known good with disc id hash CRC32:{0:X8}", discHash); sw.WriteLine("Nonetheless it could be an unrecognized romhack or patched version."); sw.WriteLine("According to redump.org, the ideal hash for entire disc is: CRC32:{0:X8}", game.GetStringValue("dh")); sw.WriteLine("The file you loaded hasn't been hashed entirely (it would take too long)"); @@ -686,7 +686,7 @@ namespace BizHawk.Client.Common nextEmulator = new Octoshock(nextComm, psf, GetCoreSettings(), GetCoreSyncSettings()); nextEmulator.CoreComm.RomStatusDetails = "It's a PSF, what do you want. Oh, tags maybe?"; - //total garbage, this + // total garbage, this rom = new RomGame(file); game = rom.GameInfo; } diff --git a/BizHawk.Client.Common/config/Binding.cs b/BizHawk.Client.Common/config/Binding.cs index 3b7a056bb3..7ca0490f20 100644 --- a/BizHawk.Client.Common/config/Binding.cs +++ b/BizHawk.Client.Common/config/Binding.cs @@ -72,7 +72,7 @@ namespace BizHawk.Client.Common public void ResolveWithDefaults() { - //TODO - this method is potentially disastrously O(N^2) slow due to linear search nested in loop + // TODO - this method is potentially disastrously O(N^2) slow due to linear search nested in loop // Add missing entries foreach (Binding default_binding in DefaultValues) diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index 960188eedb..6138918fc8 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -4,6 +4,10 @@ using System.Drawing; using BizHawk.Emulation.Common; +// ReSharper disable FieldCanBeMadeReadOnly.Global +// ReSharper disable InconsistentNaming +// ReSharper disable StyleCop.SA1310 +// ReSharper disable StyleCop.SA1401 namespace BizHawk.Client.Common { public class Config @@ -38,10 +42,10 @@ namespace BizHawk.Client.Common // Core preference for generic file extension, key: file extension, value: a systemID or empty if no preference public Dictionary PreferredPlatformsForExtensions = new Dictionary { - { ".bin", "" }, - { ".rom", "" }, - { ".iso", "" }, - { ".img", "" }, + { ".bin", string.Empty }, + { ".rom", string.Empty }, + { ".iso", string.Empty }, + { ".img", string.Empty }, }; // Path Settings ************************************/ @@ -83,8 +87,8 @@ namespace BizHawk.Client.Common public int TargetScanlineFilterIntensity = 128; // choose between 0 and 256 public int TargetDisplayFilter = 0; - public int DispFinalFilter = 0; //None - public string DispUserFilterPath = ""; + public int DispFinalFilter = 0; // None + public string DispUserFilterPath = string.Empty; public RecentFiles RecentRoms = new RecentFiles(10); public RecentFiles RecentRomSessions = new RecentFiles(8); // Only used for MultiHawk public bool PauseWhenMenuActivated = true; @@ -115,7 +119,7 @@ namespace BizHawk.Client.Common public int AutofireOn = 1; public int AutofireOff = 1; public bool AutofireLagFrames = true; - public int SaveSlot = 0; //currently selected savestate slot + public int SaveSlot = 0; // currently selected savestate slot public bool AutoLoadLastSaveSlot = false; public bool WIN32_CONSOLE = true; public bool SkipLagFrame = false; @@ -125,33 +129,50 @@ namespace BizHawk.Client.Common public bool FirstBoot = true; public bool Update_AutoCheckEnabled = false; public DateTime? Update_LastCheckTimeUTC = null; - public string Update_LatestVersion = ""; - public string Update_IgnoreVersion = ""; + public string Update_LatestVersion = string.Empty; + public string Update_IgnoreVersion = string.Empty; public bool CDLAutoSave = true, CDLAutoStart = true; - //public bool TurboSeek = true; // When PauseOnFrame is set, this will decide whether the client goes into turbo mode or not + ////public bool TurboSeek = true; // When PauseOnFrame is set, this will decide whether the client goes into turbo mode or not private bool _turboSeek; public bool TurboSeek { - get { return _turboSeek; } + get + { + return _turboSeek; + } + set { _turboSeek = value; } } - public enum EDispMethod { OpenGL, GdiPlus, SlimDX9 }; + public enum EDispMethod + { + OpenGL, GdiPlus, SlimDX9 + } - public enum ESoundOutputMethod { DirectSound, XAudio2, OpenAL, Dummy }; + public enum ESoundOutputMethod + { + DirectSound, XAudio2, OpenAL, Dummy + } - public enum EDispManagerAR { None, System, - //actually, custom SIZE (fixme on major release) + public enum EDispManagerAR + { + None, + System, + + // actually, custom SIZE (fixme on major release) Custom, CustomRatio - }; + } - public enum SaveStateTypeE { Default, Binary, Text }; + public enum SaveStateTypeE + { + Default, Binary, Text + } public MovieEndAction MovieEndAction = MovieEndAction.Finish; @@ -187,9 +208,9 @@ namespace BizHawk.Client.Common public int RewindFrequencySmall = 1; public int RewindFrequencyMedium = 4; public int RewindFrequencyLarge = 60; - public int Rewind_MediumStateSize = 262144; //256kb - public int Rewind_LargeStateSize = 1048576; //1mb - public int Rewind_BufferSize = 128; //in mb + public int Rewind_MediumStateSize = 262144; // 256kb + public int Rewind_LargeStateSize = 1048576; // 1mb + public int Rewind_BufferSize = 128; // in mb public bool Rewind_OnDisk = false; public bool Rewind_IsThreaded = Environment.ProcessorCount > 1; public int RewindSpeedMultiplier = 1; @@ -198,8 +219,8 @@ namespace BizHawk.Client.Common public SaveStateTypeE SaveStateType = SaveStateTypeE.Default; public const int DefaultSaveStateCompressionLevelNormal = 0; public int SaveStateCompressionLevelNormal = DefaultSaveStateCompressionLevelNormal; - public const int DefaultSaveStateCompressionLevelRewind = 0;//this isnt actually used yet - public int SaveStateCompressionLevelRewind = DefaultSaveStateCompressionLevelRewind;//this isnt actually used yet + public const int DefaultSaveStateCompressionLevelRewind = 0; // this isnt actually used yet + public int SaveStateCompressionLevelRewind = DefaultSaveStateCompressionLevelRewind; // this isnt actually used yet public int MovieCompressionLevel = 2; /// @@ -265,7 +286,6 @@ namespace BizHawk.Client.Common public bool DispAutoPrescale = true; public int DispSpeedupFeatures = 2; - public int DispFPSx = DefaultMessageOptions.DispFPSx; public int DispFPSy = DefaultMessageOptions.DispFPSy; public int DispFrameCx = DefaultMessageOptions.DispFrameCx; @@ -302,7 +322,7 @@ namespace BizHawk.Client.Common public int DispPrescale = 1; - //warning: we dont even want to deal with changing this at runtime. but we want it changed here for config purposes. so dont check this variable. check in GlobalWin or something like that. + // warning: we dont even want to deal with changing this at runtime. but we want it changed here for config purposes. so dont check this variable. check in GlobalWin or something like that. public EDispMethod DispMethod = EDispMethod.SlimDX9; public int DispChrome_FrameWindowed = 2; @@ -316,10 +336,11 @@ namespace BizHawk.Client.Common public EDispManagerAR DispManagerAR = EDispManagerAR.System; - //these are misnomers. they're actually a fixed size (fixme on major release) + // these are misnomers. they're actually a fixed size (fixme on major release) public int DispCustomUserARWidth = -1; public int DispCustomUserARHeight = -1; - //these are more like the actual AR ratio (i.e. 4:3) (fixme on major release) + + // these are more like the actual AR ratio (i.e. 4:3) (fixme on major release) public float DispCustomUserARX = -1; public float DispCustomUserARY = -1; @@ -336,7 +357,7 @@ namespace BizHawk.Client.Common public int SoundVolume = 100; // Range 0-100 public int SoundVolumeRWFF = 50; // Range 0-100 public bool SoundThrottle = false; - public string SoundDevice = ""; + public string SoundDevice = string.Empty; public int SoundBufferSizeMs = 100; // Log Window @@ -369,12 +390,12 @@ namespace BizHawk.Client.Common public Color HexHighlightFreezeColor = Color.Violet; // Video dumping settings - public string VideoWriter = ""; + public string VideoWriter = string.Empty; public int JMDCompression = 3; public int JMDThreads = 3; - public string FFmpegFormat = ""; + public string FFmpegFormat = string.Empty; public string FFmpegCustomCommand = "-c:a foo -c:v bar -f baz"; - public string AVICodecToken = ""; + public string AVICodecToken = string.Empty; public int GifWriterFrameskip = 3; public int GifWriterDelay = -1; @@ -470,11 +491,11 @@ namespace BizHawk.Client.Common public bool VBAStyleMovieLoadState = false; public bool MoviePlaybackPokeMode = false; - //Play Movie Dialog + // Play Movie Dialog public bool PlayMovie_IncludeSubdir = false; public bool PlayMovie_MatchHash = true; - //TI83 + // TI83 public ToolDialogSettings TI83KeypadSettings = new ToolDialogSettings(); public bool TI83autoloadKeyPad = true; public bool TI83ToolTips = true; @@ -489,15 +510,18 @@ namespace BizHawk.Client.Common { /// the physical stick that we're bound to public string Value; + /// sensitivity and flip public float Mult; + /// portion of axis to ignore public float Deadzone; - public AnalogBind(string Value, float Mult, float Deadzone) + + public AnalogBind(string value, float mult, float deadzone) { - this.Value = Value; - this.Mult = Mult; - this.Deadzone = Deadzone; + Value = value; + Mult = mult; + Deadzone = deadzone; } } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs index 966cb58a55..21810528e4 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs @@ -16,137 +16,92 @@ namespace BizHawk.Client.Common public override string Name => "bit"; - [LuaMethodAttributes( - "band", - "Bitwise AND of 'val' against 'amt'" - )] + [LuaMethodAttributes("band", "Bitwise AND of 'val' against 'amt'")] public static uint Band(uint val, uint amt) { return val & amt; } - [LuaMethodAttributes( - "bnot", - "Bitwise NOT of 'val' against 'amt'" - )] + [LuaMethodAttributes("bnot", "Bitwise NOT of 'val' against 'amt'")] public static uint Bnot(uint val) { return ~val; } - [LuaMethodAttributes( - "bor", - "Bitwise OR of 'val' against 'amt'" - )] + [LuaMethodAttributes("bor", "Bitwise OR of 'val' against 'amt'")] public static uint Bor(uint val, uint amt) { return val | amt; } - [LuaMethodAttributes( - "bxor", - "Bitwise XOR of 'val' against 'amt'" - )] + [LuaMethodAttributes("bxor", "Bitwise XOR of 'val' against 'amt'")] public static uint Bxor(uint val, uint amt) { return val ^ amt; } - [LuaMethodAttributes( - "lshift", - "Logical shift left of 'val' by 'amt' bits" - )] + [LuaMethodAttributes("lshift", "Logical shift left of 'val' by 'amt' bits")] public static uint Lshift(uint val, int amt) { return val << amt; } - [LuaMethodAttributes( - "rol", - "Left rotate 'val' by 'amt' bits" - )] + [LuaMethodAttributes("rol", "Left rotate 'val' by 'amt' bits")] public static uint Rol(uint val, int amt) { return (val << amt) | (val >> (32 - amt)); } - [LuaMethodAttributes( - "ror", - "Right rotate 'val' by 'amt' bits" - )] + [LuaMethodAttributes("ror", "Right rotate 'val' by 'amt' bits")] public static uint Ror(uint val, int amt) { return (val >> amt) | (val << (32 - amt)); } - [LuaMethodAttributes( - "rshift", - "Logical shift right of 'val' by 'amt' bits" - )] + [LuaMethodAttributes("rshift", "Logical shift right of 'val' by 'amt' bits")] public static uint Rshift(uint val, int amt) { return (uint)(val >> amt); } - [LuaMethodAttributes( - "arshift", - "Arithmetic shift right of 'val' by 'amt' bits" - )] + [LuaMethodAttributes("arshift", "Arithmetic shift right of 'val' by 'amt' bits")] public static int Arshift(int val, int amt) { return (int)(val >> amt); } - [LuaMethodAttributes( - "check", - "Returns result of bit 'pos' being set in 'num'" - )] + [LuaMethodAttributes("check", "Returns result of bit 'pos' being set in 'num'")] public static bool Check(long num, int pos) { return (num & (1 << pos)) != 0; } - [LuaMethodAttributes( - "set", - "Sets the bit 'pos' in 'num'" - )] + [LuaMethodAttributes("set", "Sets the bit 'pos' in 'num'")] public static uint Set(uint num, int pos) { return (uint)(num | (uint)1 << pos); } - [LuaMethodAttributes( - "clear", - "Clears the bit 'pos' in 'num'" - )] + [LuaMethodAttributes("clear", "Clears the bit 'pos' in 'num'")] public static long Clear(uint num, int pos) { return num & ~(1 << pos); } - [LuaMethodAttributes( - "byteswap_16", - "Byte swaps 'short', i.e. bit.byteswap_16(0xFF00) would return 0x00FF" - )] + [LuaMethodAttributes("byteswap_16", "Byte swaps 'short', i.e. bit.byteswap_16(0xFF00) would return 0x00FF")] public static ushort Byteswap16(ushort val) { return (ushort)((val & 0xFFU) << 8 | (val & 0xFF00U) >> 8); } - [LuaMethodAttributes( - "byteswap_32", - "Byte swaps 'dword'" - )] + [LuaMethodAttributes("byteswap_32", "Byte swaps 'dword'")] public static uint Byteswap32(uint val) { return (val & 0x000000FFU) << 24 | (val & 0x0000FF00U) << 8 | (val & 0x00FF0000U) >> 8 | (val & 0xFF000000U) >> 24; } - [LuaMethodAttributes( - "byteswap_64", - "Byte swaps 'long'" - )] + [LuaMethodAttributes("byteswap_64", "Byte swaps 'long'")] public static ulong Byteswap64(ulong val) { return (val & 0x00000000000000FFUL) << 56 | (val & 0x000000000000FF00UL) << 40 | diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs index ae37751a1a..2f15a13d67 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs @@ -45,37 +45,25 @@ namespace BizHawk.Client.Common public override string Name => "emu"; - [LuaMethodAttributes( - "displayvsync", - "Sets the display vsync property of the emulator" - )] + [LuaMethodAttributes("displayvsync", "Sets the display vsync property of the emulator")] public static void DisplayVsync(bool enabled) { Global.Config.VSync = enabled; } - [LuaMethodAttributes( - "frameadvance", - "Signals to the emulator to resume emulation. Necessary for any lua script while loop or else the emulator will freeze!" - )] + [LuaMethodAttributes("frameadvance", "Signals to the emulator to resume emulation. Necessary for any lua script while loop or else the emulator will freeze!")] public void FrameAdvance() { FrameAdvanceCallback(); } - [LuaMethodAttributes( - "framecount", - "Returns the current frame count" - )] + [LuaMethodAttributes("framecount", "Returns the current frame count")] public int FrameCount() { return Emulator.Frame; } - [LuaMethodAttributes( - "disassemble", - "Returns the disassembly object (disasm string and length int) for the given PC address. Uses System Bus domain if no domain name provided" - )] + [LuaMethodAttributes("disassemble", "Returns the disassembly object (disasm string and length int) for the given PC address. Uses System Bus domain if no domain name provided")] public object Disassemble(uint pc, string name = "") { try @@ -105,9 +93,7 @@ namespace BizHawk.Client.Common // TODO: what about 64 bit registers? [LuaMethodAttributes( - "getregister", - "returns the value of a cpu register or flag specified by name. For a complete list of possible registers or flags for a given core, use getregisters" - )] + "getregister", "returns the value of a cpu register or flag specified by name. For a complete list of possible registers or flags for a given core, use getregisters")] public int GetRegister(string name) { try @@ -133,9 +119,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "getregisters", - "returns the complete set of available flags and registers for a given core" - )] + "getregisters", "returns the complete set of available flags and registers for a given core")] public LuaTable GetRegisters() { var table = Lua.NewTable(); @@ -160,10 +144,7 @@ namespace BizHawk.Client.Common return table; } - [LuaMethodAttributes( - "setregister", - "sets the given register name to the given value" - )] + [LuaMethodAttributes("setregister", "sets the given register name to the given value")] public void SetRegister(string register, int value) { try @@ -181,10 +162,7 @@ namespace BizHawk.Client.Common } } - [LuaMethodAttributes( - "totalexecutedcycles", - "gets the total number of executed cpu cycles" - )] + [LuaMethodAttributes("totalexecutedcycles", "gets the total number of executed cpu cycles")] public int TotalExecutedycles() { try @@ -206,19 +184,13 @@ namespace BizHawk.Client.Common } } - [LuaMethodAttributes( - "getsystemid", - "Returns the ID string of the current core loaded. Note: No ROM loaded will return the string NULL" - )] + [LuaMethodAttributes("getsystemid", "Returns the ID string of the current core loaded. Note: No ROM loaded will return the string NULL")] public static string GetSystemId() { return Global.Game.System; } - [LuaMethodAttributes( - "islagged", - "Returns whether or not the current frame is a lag frame" - )] + [LuaMethodAttributes("islagged", "Returns whether or not the current frame is a lag frame")] public bool IsLagged() { if (InputPollableCore != null) @@ -230,10 +202,7 @@ namespace BizHawk.Client.Common return false; } - [LuaMethodAttributes( - "setislagged", - "Sets the lag flag for the current frame. If no value is provided, it will default to true" - )] + [LuaMethodAttributes("setislagged", "Sets the lag flag for the current frame. If no value is provided, it will default to true")] public void SetIsLagged(bool value = true) { if (InputPollableCore != null) @@ -246,10 +215,7 @@ namespace BizHawk.Client.Common } } - [LuaMethodAttributes( - "lagcount", - "Returns the current lag count" - )] + [LuaMethodAttributes("lagcount", "Returns the current lag count")] public int LagCount() { if (InputPollableCore != null) @@ -261,10 +227,7 @@ namespace BizHawk.Client.Common return 0; } - [LuaMethodAttributes( - "setlagcount", - "Sets the current lag count" - )] + [LuaMethodAttributes("setlagcount", "Sets the current lag count")] public void SetLagCount(int count) { if (InputPollableCore != null) @@ -277,28 +240,19 @@ namespace BizHawk.Client.Common } } - [LuaMethodAttributes( - "limitframerate", - "sets the limit framerate property of the emulator" - )] + [LuaMethodAttributes("limitframerate", "sets the limit framerate property of the emulator")] public static void LimitFramerate(bool enabled) { Global.Config.ClockThrottle = enabled; } - [LuaMethodAttributes( - "minimizeframeskip", - "Sets the autominimizeframeskip value of the emulator" - )] + [LuaMethodAttributes("minimizeframeskip", "Sets the autominimizeframeskip value of the emulator")] public static void MinimizeFrameskip(bool enabled) { Global.Config.AutoMinimizeSkipping = enabled; } - [LuaMethodAttributes( - "setrenderplanes", - "Toggles the drawing of sprites and background planes. Set to false or nil to disable a pane, anything else will draw them" - )] + [LuaMethodAttributes("setrenderplanes", "Toggles the drawing of sprites and background planes. Set to false or nil to disable a pane, anything else will draw them")] public void SetRenderPlanes(params bool[] luaParam) { if (Emulator is NES) @@ -372,19 +326,13 @@ namespace BizHawk.Client.Common return true; } - [LuaMethodAttributes( - "yield", - "allows a script to run while emulation is paused and interact with the gui/main window in realtime " - )] + [LuaMethodAttributes("yield", "allows a script to run while emulation is paused and interact with the gui/main window in realtime ")] public void Yield() { YieldCallback(); } - [LuaMethodAttributes( - "getdisplaytype", - "returns the display type (PAL vs NTSC) that the emulator is currently running in" - )] + [LuaMethodAttributes("getdisplaytype", "returns the display type (PAL vs NTSC) that the emulator is currently running in")] public string GetDisplayType() { if (RegionableCore != null) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs index 37dea1ac11..86c716116d 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs @@ -159,9 +159,7 @@ namespace BizHawk.Client.Common #endregion [LuaMethodAttributes( - "onframeend", - "Calls the given lua function at the end of each frame, after all emulation and drawing has completed. Note: this is the default behavior of lua scripts" - )] + "onframeend", "Calls the given lua function at the end of each frame, after all emulation and drawing has completed. Note: this is the default behavior of lua scripts")] public string OnFrameEnd(LuaFunction luaf, string name = null) { var nlf = new NamedLuaFunction(luaf, "OnFrameEnd", LogOutputCallback, CurrentThread, name); @@ -170,9 +168,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "onframestart", - "Calls the given lua function at the beginning of each frame before any emulation and drawing occurs" - )] + "onframestart", "Calls the given lua function at the beginning of each frame before any emulation and drawing occurs")] public string OnFrameStart(LuaFunction luaf, string name = null) { var nlf = new NamedLuaFunction(luaf, "OnFrameStart", LogOutputCallback, CurrentThread, name); @@ -181,9 +177,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "oninputpoll", - "Calls the given lua function after each time the emulator core polls for input" - )] + "oninputpoll", "Calls the given lua function after each time the emulator core polls for input")] public string OnInputPoll(LuaFunction luaf, string name = null) { var nlf = new NamedLuaFunction(luaf, "OnInputPoll", LogOutputCallback, CurrentThread, name); @@ -213,9 +207,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "onloadstate", - "Fires after a state is loaded. Receives a lua function name, and registers it to the event immediately following a successful savestate event" - )] + "onloadstate", "Fires after a state is loaded. Receives a lua function name, and registers it to the event immediately following a successful savestate event")] public string OnLoadState(LuaFunction luaf, string name = null) { var nlf = new NamedLuaFunction(luaf, "OnSavestateLoad", LogOutputCallback, CurrentThread, name); @@ -223,10 +215,7 @@ namespace BizHawk.Client.Common return nlf.Guid.ToString(); } - [LuaMethodAttributes( - "onmemoryexecute", - "Fires after the given address is executed by the core" - )] + [LuaMethodAttributes("onmemoryexecute", "Fires after the given address is executed by the core")] public string OnMemoryExecute(LuaFunction luaf, uint address, string name = null) { try @@ -258,9 +247,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "onmemoryread", - "Fires after the given address is read by the core. If no address is given, it will attach to every memory read" - )] + "onmemoryread", "Fires after the given address is read by the core. If no address is given, it will attach to every memory read")] public string OnMemoryRead(LuaFunction luaf, uint? address = null, string name = null) { try @@ -291,9 +278,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "onmemorywrite", - "Fires after the given address is written by the core. If no address is given, it will attach to every memory write" - )] + "onmemorywrite", "Fires after the given address is written by the core. If no address is given, it will attach to every memory write")] public string OnMemoryWrite(LuaFunction luaf, uint? address = null, string name = null) { try @@ -323,10 +308,7 @@ namespace BizHawk.Client.Common return Guid.Empty.ToString(); } - [LuaMethodAttributes( - "onsavestate", - "Fires after a state is saved" - )] + [LuaMethodAttributes("onsavestate", "Fires after a state is saved")] public string OnSaveState(LuaFunction luaf, string name = null) { var nlf = new NamedLuaFunction(luaf, "OnSavestateSave", LogOutputCallback, CurrentThread, name); @@ -334,10 +316,7 @@ namespace BizHawk.Client.Common return nlf.Guid.ToString(); } - [LuaMethodAttributes( - "onexit", - "Fires after the calling script has stopped" - )] + [LuaMethodAttributes("onexit", "Fires after the calling script has stopped")] public string OnExit(LuaFunction luaf, string name = null) { var nlf = new NamedLuaFunction(luaf, "OnExit", LogOutputCallback, CurrentThread, name); @@ -346,9 +325,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "unregisterbyid", - "Removes the registered function that matches the guid. If a function is found and remove the function will return true. If unable to find a match, the function will return false." - )] + "unregisterbyid", "Removes the registered function that matches the guid. If a function is found and remove the function will return true. If unable to find a match, the function will return false.")] public bool UnregisterById(string guid) { foreach (var nlf in _luaFunctions.Where(nlf => nlf.Guid.ToString() == guid.ToString())) @@ -361,9 +338,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "unregisterbyname", - "Removes the first registered function that matches Name. If a function is found and remove the function will return true. If unable to find a match, the function will return false." - )] + "unregisterbyname", "Removes the first registered function that matches Name. If a function is found and remove the function will return true. If unable to find a match, the function will return false.")] public bool UnregisterByName(string name) { foreach (var nlf in _luaFunctions.Where(nlf => nlf.Name == name)) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs index 37ad535e2e..bd009b9d06 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs @@ -22,9 +22,7 @@ namespace BizHawk.Client.Common public override string Name => "gameinfo"; [LuaMethodAttributes( - "getromname", - "returns the path of the currently loaded rom, if a rom is loaded" - )] + "getromname", "returns the path of the currently loaded rom, if a rom is loaded")] public string GetRomName() { if (Global.Game != null) @@ -36,9 +34,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "getromhash", - "returns the hash of the currently loaded rom, if a rom is loaded" - )] + "getromhash", "returns the hash of the currently loaded rom, if a rom is loaded")] public string GetRomHash() { if (Global.Game != null) @@ -50,9 +46,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "indatabase", - "returns whether or not the currently loaded rom is in the game database" - )] + "indatabase", "returns whether or not the currently loaded rom is in the game database")] public bool InDatabase() { if (Global.Game != null) @@ -64,23 +58,19 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "getstatus", - "returns the game database status of the currently loaded rom. Statuses are for example: GoodDump, BadDump, Hack, Unknown, NotInDatabase" - )] + "getstatus", "returns the game database status of the currently loaded rom. Statuses are for example: GoodDump, BadDump, Hack, Unknown, NotInDatabase")] public string GetStatus() { if (Global.Game != null) { - return Global.Game.Status.ToString() ?? string.Empty; + return Global.Game.Status.ToString(); } return string.Empty; } [LuaMethodAttributes( - "isstatusbad", - "returns the currently loaded rom's game database status is considered 'bad'" - )] + "isstatusbad", "returns the currently loaded rom's game database status is considered 'bad'")] public bool IsStatusBad() { if (Global.Game != null) @@ -92,18 +82,14 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "getboardtype", - "returns identifying information about the 'mapper' or similar capability used for this game. empty if no such useful distinction can be drawn" - )] + "getboardtype", "returns identifying information about the 'mapper' or similar capability used for this game. empty if no such useful distinction can be drawn")] public string GetBoardType() { return BoardInfo?.BoardName ?? string.Empty; } [LuaMethodAttributes( - "getoptions", - "returns the game options for the currently loaded rom. Options vary per platform" - )] + "getoptions", "returns the game options for the currently loaded rom. Options vary per platform")] public LuaTable GetOptions() { var options = Lua.NewTable(); diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Genesis.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Genesis.cs index 09dda7fddd..cbf6205bba 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Genesis.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Genesis.cs @@ -1,8 +1,10 @@ -using System.ComponentModel; +using System; +using System.ComponentModel; + +using LuaInterface; + using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Consoles.Sega.gpgx; -using LuaInterface; -using System; namespace BizHawk.Client.Common { @@ -37,8 +39,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getlayer_bga", - "Returns whether the bg layer A is displayed" - )] + "Returns whether the bg layer A is displayed")] public bool GetLayerBgA() { return GetSettings().DrawBGA; @@ -46,8 +47,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getlayer_bgb", - "Returns whether the bg layer B is displayed" - )] + "Returns whether the bg layer B is displayed")] public bool GetLayerBgB() { return GetSettings().DrawBGB; @@ -55,8 +55,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getlayer_bgw", - "Returns whether the bg layer W is displayed" - )] + "Returns whether the bg layer W is displayed")] public bool GetLayerBgW() { return GetSettings().DrawBGW; @@ -64,8 +63,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "setlayer_bga", - "Sets whether the bg layer A is displayed" - )] + "Sets whether the bg layer A is displayed")] public void SetLayerBgA(bool value) { var s = GetSettings(); @@ -75,8 +73,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "setlayer_bgb", - "Sets whether the bg layer B is displayed" - )] + "Sets whether the bg layer B is displayed")] public void SetLayerBgB(bool value) { var s = GetSettings(); @@ -86,8 +83,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "setlayer_bgw", - "Sets whether the bg layer W is displayed" - )] + "Sets whether the bg layer W is displayed")] public void SetLayerBgW(bool value) { var s = GetSettings(); diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs index e24346f73f..07581c8b33 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs @@ -14,9 +14,7 @@ namespace BizHawk.Client.Common public override string Name => "joypad"; [LuaMethodAttributes( - "get", - "returns a lua table of the controller buttons pressed. If supplied, it will only return a table of buttons for the given controller" - )] + "get", "returns a lua table of the controller buttons pressed. If supplied, it will only return a table of buttons for the given controller")] public LuaTable Get(int? controller = null) { var buttons = Lua.NewTable(); @@ -54,9 +52,7 @@ namespace BizHawk.Client.Common // TODO: what about float controls? [LuaMethodAttributes( - "getimmediate", - "returns a lua table of any controller buttons currently pressed by the user" - )] + "getimmediate", "returns a lua table of any controller buttons currently pressed by the user")] public LuaTable GetImmediate() { var buttons = Lua.NewTable(); @@ -69,9 +65,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "setfrommnemonicstr", - "sets the given buttons to their provided values for the current frame, string will be interpretted the same way an entry from a movie input log would be" - )] + "setfrommnemonicstr", "sets the given buttons to their provided values for the current frame, string will be interpretted the same way an entry from a movie input log would be")] public void SetFromMnemonicStr(string inputLogEntry) { try @@ -96,9 +90,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "set", - "sets the given buttons to their provided values for the current frame" - )] + "set", "sets the given buttons to their provided values for the current frame")] public void Set(LuaTable buttons, int? controller = null) { try @@ -163,9 +155,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "setanalog", - "sets the given analog controls to their provided values for the current frame. Note that unlike set() there is only the logic of overriding with the given value." - )] + "setanalog", "sets the given analog controls to their provided values for the current frame. Note that unlike set() there is only the logic of overriding with the given value.")] public void SetAnalog(LuaTable controls, object controller = null) { try diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs index 9e1063e859..b553955725 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs @@ -37,19 +37,13 @@ namespace BizHawk.Client.Common #region Unique Library Methods - [LuaMethodAttributes( - "getname", - "returns the name of the domain defined as main memory for the given core" - )] + [LuaMethodAttributes("getname", "returns the name of the domain defined as main memory for the given core")] public string GetName() { return Domain.Name; } - [LuaMethodAttributes( - "getcurrentmemorydomainsize", - "Returns the number of bytes of the domain defined as main memory" - )] + [LuaMethodAttributes("getcurrentmemorydomainsize", "Returns the number of bytes of the domain defined as main memory")] public uint GetSize() { return (uint)Domain.Size; @@ -59,54 +53,40 @@ namespace BizHawk.Client.Common #region Common Special and Legacy Methods - [LuaMethodAttributes( - "readbyte", "gets the value from the given address as an unsigned byte" - )] + [LuaMethodAttributes("readbyte", "gets the value from the given address as an unsigned byte")] public uint ReadByte(int addr) { return ReadUnsignedByte(addr); } - [LuaMethodAttributes( - "writebyte", - "Writes the given value to the given address as an unsigned byte" - )] + [LuaMethodAttributes("writebyte", "Writes the given value to the given address as an unsigned byte")] public void WriteByte(int addr, uint value) { WriteUnsignedByte(addr, value); } [LuaMethodAttributes( - "readbyterange", - "Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key)." - )] + "readbyterange", "Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key).")] public LuaTable ReadByteRange(int addr, int length) { return base.ReadByteRange(addr, length); } - [LuaMethodAttributes( - "writebyterange", - "Writes the given values to the given addresses as unsigned bytes" - )] + [LuaMethodAttributes("writebyterange", "Writes the given values to the given addresses as unsigned bytes")] public void WriteByteRange(LuaTable memoryblock) { base.WriteByteRange(memoryblock); } [LuaMethodAttributes( - "readfloat", - "Reads the given address as a 32-bit float value from the main memory domain with th e given endian" - )] + "readfloat", "Reads the given address as a 32-bit float value from the main memory domain with th e given endian")] public float ReadFloat(int addr, bool bigendian) { return base.ReadFloat(addr, bigendian); } [LuaMethodAttributes( - "writefloat", - "Writes the given 32-bit float value to the given address and endian" - )] + "writefloat", "Writes the given 32-bit float value to the given address and endian")] public void WriteFloat(int addr, double value, bool bigendian) { base.WriteFloat(addr, value, bigendian); diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs index 489f66d580..c3dd95aa3a 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs @@ -53,9 +53,7 @@ namespace BizHawk.Client.Common #region Unique Library Methods [LuaMethodAttributes( - "getmemorydomainlist", - "Returns a string of the memory domains for the loaded platform core. List will be a single string delimited by line feeds" - )] + "getmemorydomainlist", "Returns a string of the memory domains for the loaded platform core. List will be a single string delimited by line feeds")] public LuaTable GetMemoryDomainList() { var table = Lua.NewTable(); @@ -71,39 +69,33 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "getmemorydomainsize", - "Returns the number of bytes of the specified memory domain. If no domain is specified, or the specified domain doesn't exist, returns the current domain size" - )] + "getmemorydomainsize", "Returns the number of bytes of the specified memory domain. If no domain is specified, or the specified domain doesn't exist, returns the current domain size")] public uint GetMemoryDomainSize(string name = "") { if (string.IsNullOrEmpty(name)) + { return (uint)Domain.Size; - else - return (uint)DomainList[VerifyMemoryDomain(name)].Size; + } + + return (uint)DomainList[VerifyMemoryDomain(name)].Size; } [LuaMethodAttributes( - "getcurrentmemorydomain", - "Returns a string name of the current memory domain selected by Lua. The default is Main memory" - )] + "getcurrentmemorydomain", "Returns a string name of the current memory domain selected by Lua. The default is Main memory")] public string GetCurrentMemoryDomain() { return Domain.Name; } [LuaMethodAttributes( - "getcurrentmemorydomainsize", - "Returns the number of bytes of the current memory domain selected by Lua. The default is Main memory" - )] + "getcurrentmemorydomainsize", "Returns the number of bytes of the current memory domain selected by Lua. The default is Main memory")] public uint GetCurrentMemoryDomainSize() { return (uint)Domain.Size; } [LuaMethodAttributes( - "usememorydomain", - "Attempts to set the current memory domain to the given domain. If the name does not match a valid memory domain, the function returns false, else it returns true" - )] + "usememorydomain", "Attempts to set the current memory domain to the given domain. If the name does not match a valid memory domain, the function returns false, else it returns true")] public bool UseMemoryDomain(string domain) { try @@ -113,12 +105,9 @@ namespace BizHawk.Client.Common _currentMemoryDomain = DomainList[domain]; return true; } - else - { - Log($"Unable to find domain: {domain}"); - return false; - } + Log($"Unable to find domain: {domain}"); + return false; } catch // Just in case { @@ -132,55 +121,37 @@ namespace BizHawk.Client.Common #region Common Special and Legacy Methods - [LuaMethodAttributes( - "readbyte", - "gets the value from the given address as an unsigned byte" - )] + [LuaMethodAttributes("readbyte", "gets the value from the given address as an unsigned byte")] public uint ReadByte(int addr, string domain = null) { return ReadUnsignedByte(addr, domain); } - [LuaMethodAttributes( - "writebyte", - "Writes the given value to the given address as an unsigned byte" - )] + [LuaMethodAttributes("writebyte", "Writes the given value to the given address as an unsigned byte")] public void WriteByte(int addr, uint value, string domain = null) { WriteUnsignedByte(addr, value, domain); } - [LuaMethodAttributes( - "readbyterange", - "Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key)." - )] + [LuaMethodAttributes("readbyterange", "Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key).")] public new LuaTable ReadByteRange(int addr, int length, string domain = null) { return base.ReadByteRange(addr, length, domain); } - [LuaMethodAttributes( - "writebyterange", - "Writes the given values to the given addresses as unsigned bytes" - )] + [LuaMethodAttributes("writebyterange", "Writes the given values to the given addresses as unsigned bytes")] public new void WriteByteRange(LuaTable memoryblock, string domain = null) { base.WriteByteRange(memoryblock, domain); } - [LuaMethodAttributes( - "readfloat", - "Reads the given address as a 32-bit float value from the main memory domain with th e given endian" - )] + [LuaMethodAttributes("readfloat", "Reads the given address as a 32-bit float value from the main memory domain with th e given endian")] public new float ReadFloat(int addr, bool bigendian, string domain = null) { return base.ReadFloat(addr, bigendian, domain); } - [LuaMethodAttributes( - "writefloat", - "Writes the given 32-bit float value to the given address and endian" - )] + [LuaMethodAttributes("writefloat", "Writes the given 32-bit float value to the given address and endian")] public new void WriteFloat(int addr, double value, bool bigendian, string domain = null) { base.WriteFloat(addr, value, bigendian, domain); diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.MemorySavestate.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.MemorySavestate.cs index e84348f7d7..cb4ca5725e 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.MemorySavestate.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.MemorySavestate.cs @@ -24,9 +24,7 @@ namespace BizHawk.Client.Common private IStatable _statableCore { get; set; } [LuaMethodAttributes( - "savecorestate", - "creates a core savestate and stores it in memory. Note: a core savestate is only the raw data from the core, and not extras such as movie input logs, or framebuffers. Returns a unique identifer for the savestate" - )] + "savecorestate", "creates a core savestate and stores it in memory. Note: a core savestate is only the raw data from the core, and not extras such as movie input logs, or framebuffers. Returns a unique identifer for the savestate")] public string SaveCoreStateToMemory() { var guid = Guid.NewGuid(); @@ -37,10 +35,7 @@ namespace BizHawk.Client.Common return guid.ToString(); } - [LuaMethodAttributes( - "loadcorestate", - "loads an in memory state with the given identifier" - )] + [LuaMethodAttributes("loadcorestate", "loads an in memory state with the given identifier")] public void LoadCoreStateFromMemory(string identifier) { var guid = new Guid(identifier); @@ -61,20 +56,14 @@ namespace BizHawk.Client.Common } } - [LuaMethodAttributes( - "removestate", - "removes the savestate with the given identifier from memory" - )] + [LuaMethodAttributes("removestate", "removes the savestate with the given identifier from memory")] public void DeleteState(string identifier) { var guid = new Guid(identifier); MemorySavestates.Remove(guid); } - [LuaMethodAttributes( - "clearstatesfrommemory", - "clears all savestates stored in memory" - )] + [LuaMethodAttributes("clearstatesfrommemory", "clears all savestates stored in memory")] public void ClearInMemoryStates() { MemorySavestates.Clear(); diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs index 71dc1f7ea9..adfd01ac37 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs @@ -17,8 +17,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "startsfromsavestate", - "Returns whether or not the movie is a savestate-anchored movie" - )] + "Returns whether or not the movie is a savestate-anchored movie")] public bool StartsFromSavestate() { return Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSavestate; @@ -26,8 +25,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "startsfromsaveram", - "Returns whether or not the movie is a saveram-anchored movie" - )] + "Returns whether or not the movie is a saveram-anchored movie")] public bool StartsFromSaveram() { return Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSaveRam; @@ -35,8 +33,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "filename", - "Returns the file name including path of the currently loaded movie" - )] + "Returns the file name including path of the currently loaded movie")] public static string Filename() { return Global.MovieSession.Movie.Filename; @@ -44,8 +41,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getinput", - "Returns a table of buttons pressed on a given frame of the loaded movie" - )] + "Returns a table of buttons pressed on a given frame of the loaded movie")] public LuaTable GetInput(int frame) { if (!Global.MovieSession.Movie.IsActive) @@ -78,8 +74,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getinputasmnemonic", - "Returns the input of a given frame of the loaded movie in a raw inputlog string" - )] + "Returns the input of a given frame of the loaded movie in a raw inputlog string")] public string GetInputAsMnemonic(int frame) { if (Global.MovieSession.Movie.IsActive && frame < Global.MovieSession.Movie.InputLogLength) @@ -94,8 +89,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getreadonly", - "Returns true if the movie is in read-only mode, false if in read+write" - )] + "Returns true if the movie is in read-only mode, false if in read+write")] public static bool GetReadOnly() { return Global.MovieSession.ReadOnly; @@ -103,8 +97,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getrerecordcount", - "Gets the rerecord count of the current movie." - )] + "Gets the rerecord count of the current movie.")] public static ulong GetRerecordCount() { return Global.MovieSession.Movie.Rerecords; @@ -112,8 +105,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getrerecordcounting", - "Returns whether or not the current movie is incrementing rerecords on loadstate" - )] + "Returns whether or not the current movie is incrementing rerecords on loadstate")] public static bool GetRerecordCounting() { return Global.MovieSession.Movie.IsCountingRerecords; @@ -121,8 +113,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "isloaded", - "Returns true if a movie is loaded in memory (play, record, or finished modes), false if not (inactive mode)" - )] + "Returns true if a movie is loaded in memory (play, record, or finished modes), false if not (inactive mode)")] public static bool IsLoaded() { return Global.MovieSession.Movie.IsActive; @@ -130,8 +121,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "length", - "Returns the total number of frames of the loaded movie" - )] + "Returns the total number of frames of the loaded movie")] public static double Length() { return Global.MovieSession.Movie.FrameCount; @@ -139,8 +129,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "mode", - "Returns the mode of the current movie. Possible modes: \"PLAY\", \"RECORD\", \"FINISHED\", \"INACTIVE\"" - )] + "Returns the mode of the current movie. Possible modes: \"PLAY\", \"RECORD\", \"FINISHED\", \"INACTIVE\"")] public static string Mode() { if (Global.MovieSession.Movie.IsFinished) @@ -163,8 +152,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "rerecordcount", - "[Deprecated] Alias of getrerecordcount" - )] + "[Deprecated] Alias of getrerecordcount")] public static string RerecordCount() { return GetRerecordCount().ToString(); @@ -172,8 +160,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "save", - "Saves the current movie to the disc. If the filename is provided (no extension or path needed), the movie is saved under the specified name to the current movie directory. The filename may contain a subdirectory, it will be created if it doesn't exist. Existing files won't get overwritten." - )] + "Saves the current movie to the disc. If the filename is provided (no extension or path needed), the movie is saved under the specified name to the current movie directory. The filename may contain a subdirectory, it will be created if it doesn't exist. Existing files won't get overwritten.")] public void Save(string filename = "") { if (!Global.MovieSession.Movie.IsActive) @@ -199,8 +186,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "setreadonly", - "Sets the read-only state to the given value. true for read only, false for read+write" - )] + "Sets the read-only state to the given value. true for read only, false for read+write")] public static void SetReadOnly(bool readOnly) { Global.MovieSession.ReadOnly = readOnly; @@ -208,8 +194,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "setrerecordcount", - "Sets the rerecord count of the current movie." - )] + "Sets the rerecord count of the current movie.")] public static void SetRerecordCount(double count) { // Lua numbers are always double, integer precision holds up @@ -226,8 +211,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "setrerecordcounting", - "Sets whether or not the current movie will increment the rerecord counter on loadstate" - )] + "Sets whether or not the current movie will increment the rerecord counter on loadstate")] public static void SetRerecordCounting(bool counting) { Global.MovieSession.Movie.IsCountingRerecords = counting; @@ -235,8 +219,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "stop", - "Stops the current movie" - )] + "Stops the current movie")] public static void Stop() { Global.MovieSession.Movie.Stop(); @@ -244,8 +227,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getfps", - "If a movie is loaded, gets the frames per second used by the movie to determine the movie length time" - )] + "If a movie is loaded, gets the frames per second used by the movie to determine the movie length time")] public static double GetFps() { if (Global.MovieSession.Movie.IsActive) @@ -263,8 +245,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getheader", - "If a movie is active, will return the movie header as a lua table" - )] + "If a movie is active, will return the movie header as a lua table")] public LuaTable GetHeader() { var luaTable = Lua.NewTable(); @@ -281,8 +262,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getcomments", - "If a movie is active, will return the movie comments as a lua table" - )] + "If a movie is active, will return the movie comments as a lua table")] public LuaTable GetComments() { var luaTable = Lua.NewTable(); @@ -299,8 +279,7 @@ namespace BizHawk.Client.Common [LuaMethodAttributes( "getsubtitles", - "If a movie is active, will return the movie subtitles as a lua table" - )] + "If a movie is active, will return the movie subtitles as a lua table")] public LuaTable GetSubtitles() { var luaTable = Lua.NewTable(); diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs index 930c7d786f..a7053e2c37 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs @@ -39,9 +39,7 @@ namespace BizHawk.Client.Common public override string Name => "nes"; [LuaMethodAttributes( - "addgamegenie", - "Adds the specified game genie code. If an NES game is not currently loaded or the code is not a valid game genie code, this will have no effect" - )] + "addgamegenie", "Adds the specified game genie code. If an NES game is not currently loaded or the code is not a valid game genie code, this will have no effect")] public void AddGameGenie(string code) { if (NESAvailable && HasMemoryDOmains) @@ -63,9 +61,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "getallowmorethaneightsprites", - "Gets the NES setting 'Allow more than 8 sprites per scanline' value" - )] + "getallowmorethaneightsprites", "Gets the NES setting 'Allow more than 8 sprites per scanline' value")] public bool GetAllowMoreThanEightSprites() { if (_quicknes != null) @@ -82,9 +78,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "getbottomscanline", - "Gets the current value for the bottom scanline value" - )] + "getbottomscanline", "Gets the current value for the bottom scanline value")] public int GetBottomScanline(bool pal = false) { if (_quicknes != null) @@ -103,9 +97,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "getclipleftandright", - "Gets the current value for the Clip Left and Right sides option" - )] + "getclipleftandright", "Gets the current value for the Clip Left and Right sides option")] public bool GetClipLeftAndRight() { if (_quicknes != null) @@ -122,9 +114,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "getdispbackground", - "Indicates whether or not the bg layer is being displayed" - )] + "getdispbackground", "Indicates whether or not the bg layer is being displayed")] public bool GetDisplayBackground() { if (_quicknes != null) @@ -141,9 +131,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "getdispsprites", - "Indicates whether or not sprites are being displayed" - )] + "getdispsprites", "Indicates whether or not sprites are being displayed")] public bool GetDisplaySprites() { if (_quicknes != null) @@ -160,9 +148,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "gettopscanline", - "Gets the current value for the top scanline value" - )] + "gettopscanline", "Gets the current value for the top scanline value")] public int GetTopScanline(bool pal = false) { if (_quicknes != null) @@ -181,9 +167,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "removegamegenie", - "Removes the specified game genie code. If an NES game is not currently loaded or the code is not a valid game genie code, this will have no effect" - )] + "removegamegenie", "Removes the specified game genie code. If an NES game is not currently loaded or the code is not a valid game genie code, this will have no effect")] public void RemoveGameGenie(string code) { if (NESAvailable) @@ -195,9 +179,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "setallowmorethaneightsprites", - "Sets the NES setting 'Allow more than 8 sprites per scanline'" - )] + "setallowmorethaneightsprites", "Sets the NES setting 'Allow more than 8 sprites per scanline'")] public void SetAllowMoreThanEightSprites(bool allow) { if (_neshawk != null) @@ -215,9 +197,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "setclipleftandright", - "Sets the Clip Left and Right sides option" - )] + "setclipleftandright", "Sets the Clip Left and Right sides option")] public void SetClipLeftAndRight(bool leftandright) { if (_neshawk != null) @@ -235,9 +215,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "setdispbackground", - "Sets whether or not the background layer will be displayed" - )] + "setdispbackground", "Sets whether or not the background layer will be displayed")] public void SetDisplayBackground(bool show) { if (_neshawk != null) @@ -249,9 +227,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "setdispsprites", - "Sets whether or not sprites will be displayed" - )] + "setdispsprites", "Sets whether or not sprites will be displayed")] public void SetDisplaySprites(bool show) { if (_neshawk != null) @@ -269,9 +245,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "setscanlines", - "sets the top and bottom scanlines to be drawn (same values as in the graphics options dialog). Top must be in the range of 0 to 127, bottom must be between 128 and 239. Not supported in the Quick Nes core" - )] + "setscanlines", "sets the top and bottom scanlines to be drawn (same values as in the graphics options dialog). Top must be in the range of 0 to 127, bottom must be between 128 and 239. Not supported in the Quick Nes core")] public void SetScanlines(int top, int bottom, bool pal = false) { if (_neshawk != null) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs index 0f0c0193f2..c431d9625b 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs @@ -35,82 +35,55 @@ namespace BizHawk.Client.Common Snes?.PutSettings(settings); } - [LuaMethodAttributes( - "getlayer_bg_1", - "Returns whether the bg 1 layer is displayed" - )] + [LuaMethodAttributes("getlayer_bg_1", "Returns whether the bg 1 layer is displayed")] public bool GetLayerBg1() { return GetSettings().ShowBG1_1; } - [LuaMethodAttributes( - "getlayer_bg_2", - "Returns whether the bg 2 layer is displayed" - )] + [LuaMethodAttributes("getlayer_bg_2", "Returns whether the bg 2 layer is displayed")] public bool GetLayerBg2() { return GetSettings().ShowBG2_1; } - [LuaMethodAttributes( - "getlayer_bg_3", - "Returns whether the bg 3 layer is displayed" - )] + [LuaMethodAttributes("getlayer_bg_3", "Returns whether the bg 3 layer is displayed")] public bool GetLayerBg3() { return GetSettings().ShowBG3_1; } - [LuaMethodAttributes( - "getlayer_bg_4", - "Returns whether the bg 4 layer is displayed" - )] + [LuaMethodAttributes("getlayer_bg_4", "Returns whether the bg 4 layer is displayed")] public bool GetLayerBg4() { return GetSettings().ShowBG4_1; } - [LuaMethodAttributes( - "getlayer_obj_1", - "Returns whether the obj 1 layer is displayed" - )] + [LuaMethodAttributes("getlayer_obj_1", "Returns whether the obj 1 layer is displayed")] public bool GetLayerObj1() { return GetSettings().ShowOBJ_0; } - [LuaMethodAttributes( - "getlayer_obj_2", - "Returns whether the obj 2 layer is displayed" - )] + [LuaMethodAttributes("getlayer_obj_2", "Returns whether the obj 2 layer is displayed")] public bool GetLayerObj2() { return GetSettings().ShowOBJ_1; } - [LuaMethodAttributes( - "getlayer_obj_3", - "Returns whether the obj 3 layer is displayed" - )] + [LuaMethodAttributes("getlayer_obj_3", "Returns whether the obj 3 layer is displayed")] public bool GetLayerObj3() { return GetSettings().ShowOBJ_2; } - [LuaMethodAttributes( - "getlayer_obj_4", - "Returns whether the obj 4 layer is displayed" - )] + [LuaMethodAttributes("getlayer_obj_4", "Returns whether the obj 4 layer is displayed")] public bool GetLayerObj4() { return GetSettings().ShowOBJ_3; } - [LuaMethodAttributes( - "setlayer_bg_1", - "Sets whether the bg 1 layer is displayed" - )] + [LuaMethodAttributes("setlayer_bg_1", "Sets whether the bg 1 layer is displayed")] public void SetLayerBg1(bool value) { var s = GetSettings(); @@ -118,10 +91,7 @@ namespace BizHawk.Client.Common PutSettings(s); } - [LuaMethodAttributes( - "setlayer_bg_2", - "Sets whether the bg 2 layer is displayed" - )] + [LuaMethodAttributes("setlayer_bg_2", "Sets whether the bg 2 layer is displayed")] public void SetLayerBg2(bool value) { var s = GetSettings(); @@ -129,10 +99,7 @@ namespace BizHawk.Client.Common PutSettings(s); } - [LuaMethodAttributes( - "setlayer_bg_3", - "Sets whether the bg 3 layer is displayed" - )] + [LuaMethodAttributes("setlayer_bg_3", "Sets whether the bg 3 layer is displayed")] public void SetLayerBg3(bool value) { var s = GetSettings(); @@ -140,10 +107,7 @@ namespace BizHawk.Client.Common PutSettings(s); } - [LuaMethodAttributes( - "setlayer_bg_4", - "Sets whether the bg 4 layer is displayed" - )] + [LuaMethodAttributes("setlayer_bg_4", "Sets whether the bg 4 layer is displayed")] public void SetLayerBg4(bool value) { var s = GetSettings(); @@ -151,10 +115,7 @@ namespace BizHawk.Client.Common PutSettings(s); } - [LuaMethodAttributes( - "setlayer_obj_1", - "Sets whether the obj 1 layer is displayed" - )] + [LuaMethodAttributes("setlayer_obj_1", "Sets whether the obj 1 layer is displayed")] public void SetLayerObj1(bool value) { var s = GetSettings(); @@ -162,10 +123,7 @@ namespace BizHawk.Client.Common PutSettings(s); } - [LuaMethodAttributes( - "setlayer_obj_2", - "Sets whether the obj 2 layer is displayed" - )] + [LuaMethodAttributes("setlayer_obj_2", "Sets whether the obj 2 layer is displayed")] public void SetLayerObj2(bool value) { var s = GetSettings(); @@ -173,10 +131,7 @@ namespace BizHawk.Client.Common PutSettings(s); } - [LuaMethodAttributes( - "setlayer_obj_3", - "Sets whether the obj 3 layer is displayed" - )] + [LuaMethodAttributes("setlayer_obj_3", "Sets whether the obj 3 layer is displayed")] public void SetLayerObj3(bool value) { var s = GetSettings(); @@ -184,10 +139,7 @@ namespace BizHawk.Client.Common PutSettings(s); } - [LuaMethodAttributes( - "setlayer_obj_4", - "Sets whether the obj 4 layer is displayed" - )] + [LuaMethodAttributes("setlayer_obj_4", "Sets whether the obj 4 layer is displayed")] public void SetLayerObj4(bool value) { var s = GetSettings(); diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs index c3f870cecc..235436874b 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs @@ -18,9 +18,7 @@ namespace BizHawk.Client.Common : base(lua, logOutputCallback) { } [LuaMethodAttributes( - "hex", - "Converts the number to a string representation of the hexadecimal value of the given number" - )] + "hex", "Converts the number to a string representation of the hexadecimal value of the given number")] public static string Hex(long num) { var hex = $"{num:X}"; @@ -33,9 +31,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "binary", - "Converts the number to a string representation of the binary value of the given number" - )] + "binary", "Converts the number to a string representation of the binary value of the given number")] public static string Binary(long num) { var binary = Convert.ToString(num, 2); @@ -44,9 +40,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "octal", - "Converts the number to a string representation of the octal value of the given number" - )] + "octal", "Converts the number to a string representation of the octal value of the given number")] public static string Octal(long num) { var octal = Convert.ToString(num, 8); @@ -59,9 +53,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "trim", - "returns a string that trims whitespace on the left and right ends of the string" - )] + "trim", "returns a string that trims whitespace on the left and right ends of the string")] public static string Trim(string str) { if (string.IsNullOrEmpty(str)) @@ -73,9 +65,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "replace", - "Returns a string that replaces all occurances of str2 in str1 with the value of replace" - )] + "replace", "Returns a string that replaces all occurances of str2 in str1 with the value of replace")] public static string Replace(string str, string str2, string replace) { if (string.IsNullOrEmpty(str)) @@ -86,10 +76,7 @@ namespace BizHawk.Client.Common return str.Replace(str2, replace); } - [LuaMethodAttributes( - "toupper", - "Returns an uppercase version of the given string" - )] + [LuaMethodAttributes("toupper", "Returns an uppercase version of the given string")] public static string ToUpper(string str) { if (string.IsNullOrEmpty(str)) @@ -100,10 +87,7 @@ namespace BizHawk.Client.Common return str.ToUpper(); } - [LuaMethodAttributes( - "tolower", - "Returns an lowercase version of the given string" - )] + [LuaMethodAttributes("tolower", "Returns an lowercase version of the given string")] public static string ToLower(string str) { if (string.IsNullOrEmpty(str)) @@ -115,9 +99,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "substring", - "Returns a string that represents a substring of str starting at position for the specified length" - )] + "substring", "Returns a string that represents a substring of str starting at position for the specified length")] public static string SubString(string str, int position, int length) { if (string.IsNullOrEmpty(str)) @@ -129,9 +111,7 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "remove", - "Returns a string that represents str with the given position and count removed" - )] + "remove", "Returns a string that represents str with the given position and count removed")] public static string Remove(string str, int position, int count) { if (string.IsNullOrEmpty(str)) @@ -142,10 +122,7 @@ namespace BizHawk.Client.Common return str.Remove(position, count); } - [LuaMethodAttributes( - "contains", - "Returns whether or not str contains str2" - )] + [LuaMethodAttributes("contains", "Returns whether or not str contains str2")] public static bool Contains(string str, string str2) { if (string.IsNullOrEmpty(str)) @@ -156,10 +133,7 @@ namespace BizHawk.Client.Common return str.Contains(str2); } - [LuaMethodAttributes( - "startswith", - "Returns whether str starts with str2" - )] + [LuaMethodAttributes("startswith", "Returns whether str starts with str2")] public static bool StartsWith(string str, string str2) { if (string.IsNullOrEmpty(str)) @@ -170,10 +144,7 @@ namespace BizHawk.Client.Common return str.StartsWith(str2); } - [LuaMethodAttributes( - "endswith", - "Returns whether str ends wth str2" - )] + [LuaMethodAttributes("endswith", "Returns whether str ends wth str2")] public static bool EndsWith(string str, string str2) { if (string.IsNullOrEmpty(str)) @@ -185,16 +156,14 @@ namespace BizHawk.Client.Common } [LuaMethodAttributes( - "split", - "Splits str based on separator into a LuaTable. Separator must be one character!. Same functionality as .NET string.Split() using the RemoveEmptyEntries option" - )] + "split", "Splits str based on separator into a LuaTable. Separator must be one character!. Same functionality as .NET string.Split() using the RemoveEmptyEntries option")] public LuaTable Split(string str, string separator) { var table = Lua.NewTable(); if (!string.IsNullOrEmpty(str)) { var splitStr = str.Split( - new char[] { separator.FirstOrDefault() }, + new[] { separator.FirstOrDefault() }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < splitStr.Length; i++) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs index e342a12849..b68b3dcb2a 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; using LuaInterface; -using BizHawk.Common; -using BizHawk.Emulation.Common; + using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk @@ -23,8 +20,7 @@ namespace BizHawk.Client.EmuHawk [LuaMethodAttributes( "set", - "adds or updates the data with the given key with the given value" - )] + "adds or updates the data with the given key with the given value")] public void Set(string name, object value) { Global.UserBag[name] = value; @@ -32,8 +28,7 @@ namespace BizHawk.Client.EmuHawk [LuaMethodAttributes( "get", - "gets the data with the given key, if the key does not exist it will return nil" - )] + "gets the data with the given key, if the key does not exist it will return nil")] public object Get(string key) { if (Global.UserBag.ContainsKey(key)) @@ -46,8 +41,7 @@ namespace BizHawk.Client.EmuHawk [LuaMethodAttributes( "clear", - "clears all user data" - )] + "clears all user data")] public void Clear() { Global.UserBag.Clear(); @@ -55,8 +49,7 @@ namespace BizHawk.Client.EmuHawk [LuaMethodAttributes( "remove", - "remove the data with the given key. Returns true if the element is successfully found and removed; otherwise, false." - )] + "remove the data with the given key. Returns true if the element is successfully found and removed; otherwise, false.")] public bool Remove(string key) { return Global.UserBag.Remove(key); @@ -64,8 +57,7 @@ namespace BizHawk.Client.EmuHawk [LuaMethodAttributes( "containskey", - "returns whether or not there is an entry for the given key" - )] + "returns whether or not there is an entry for the given key")] public bool ContainsKey(string key) { return Global.UserBag.ContainsKey(key); diff --git a/BizHawk.Client.Common/lua/LuaSandbox.cs b/BizHawk.Client.Common/lua/LuaSandbox.cs index 7b419f55e0..740525d044 100644 --- a/BizHawk.Client.Common/lua/LuaSandbox.cs +++ b/BizHawk.Client.Common/lua/LuaSandbox.cs @@ -43,15 +43,15 @@ namespace BizHawk.Client.Common if (currDirSpeedHack == path) return true; - //WARNING: setting the current directory is SLOW!!! security checks for some reason. - //so we're bypassing it with windows hacks + // WARNING: setting the current directory is SLOW!!! security checks for some reason. + // so we're bypassing it with windows hacks #if WINDOWS fixed (byte* pstr = &System.Text.Encoding.Unicode.GetBytes(target + "\0")[0]) return SetCurrentDirectoryW(pstr); #else - if(System.IO.Directory.Exists(CurrentDirectory)) //race condition for great justice + if (System.IO.Directory.Exists(CurrentDirectory)) // race condition for great justice { - Environment.CurrentDirectory = CurrentDirectory; //thats right, you can't set a directory as current that doesnt exist because .net's got to do SENSELESS SLOW-ASS SECURITY CHECKS on it and it can't do that on a NONEXISTENT DIRECTORY + Environment.CurrentDirectory = CurrentDirectory; // thats right, you can't set a directory as current that doesnt exist because .net's got to do SENSELESS SLOW-ASS SECURITY CHECKS on it and it can't do that on a NONEXISTENT DIRECTORY return true; } else return false; @@ -60,10 +60,10 @@ namespace BizHawk.Client.Common string CoolGetCurrentDirectory() { - //GUESS WHAT! - //.NET DOES A SECURITY CHECK ON THE DIRECTORY WE JUST RETRIEVED - //AS IF ASKING FOR THE CURRENT DIRECTORY IS EQUIVALENT TO TRYING TO ACCESS IT - //SCREW YOU + // GUESS WHAT! + // .NET DOES A SECURITY CHECK ON THE DIRECTORY WE JUST RETRIEVED + // AS IF ASKING FOR THE CURRENT DIRECTORY IS EQUIVALENT TO TRYING TO ACCESS IT + // SCREW YOU #if WINDOWS var buf = new byte[32768]; fixed(byte* pBuf = &buf[0]) diff --git a/BizHawk.Client.Common/movie/HeaderKeys.cs b/BizHawk.Client.Common/movie/HeaderKeys.cs index 0e46312d58..691c188aeb 100644 --- a/BizHawk.Client.Common/movie/HeaderKeys.cs +++ b/BizHawk.Client.Common/movie/HeaderKeys.cs @@ -12,7 +12,7 @@ namespace BizHawk.Client.Common public const string RERECORDS = "rerecordCount"; public const string STARTSFROMSAVESTATE = "StartsFromSavestate"; public const string STARTSFROMSAVERAM = "StartsFromSaveRam"; - public const string SAVESTATEBINARYBASE64BLOB = "SavestateBinaryBase64Blob"; //this string will not contain base64: ; it's implicit (this is to avoid another big string op to dice off the base64: substring) + public const string SAVESTATEBINARYBASE64BLOB = "SavestateBinaryBase64Blob"; // this string will not contain base64: ; it's implicit (this is to avoid another big string op to dice off the base64: substring) public const string FOURSCORE = "FourScore"; public const string SHA1 = "SHA1"; public const string FIRMWARESHA1 = "FirmwareSHA1"; @@ -20,6 +20,7 @@ namespace BizHawk.Client.Common public const string BOARDNAME = "BoardName"; public const string SYNCSETTINGS = "SyncSettings"; public const string LOOPOFFSET = "LoopOffset"; + // Core Setting public const string CORE = "Core"; diff --git a/BizHawk.Client.Common/movie/MovieService.cs b/BizHawk.Client.Common/movie/MovieService.cs index 8cd4cf2b84..eb35f9c52e 100644 --- a/BizHawk.Client.Common/movie/MovieService.cs +++ b/BizHawk.Client.Common/movie/MovieService.cs @@ -46,7 +46,7 @@ namespace BizHawk.Client.Common } /// - /// Returns a list of extensions for all IMovie implementations + /// Gets a list of extensions for all implementations /// public static IEnumerable MovieExtensions { @@ -60,7 +60,7 @@ namespace BizHawk.Client.Common public static bool IsValidMovieExtension(string ext) { - if (MovieExtensions.Contains(ext.ToLower().Replace(".", ""))) + if (MovieExtensions.Contains(ext.ToLower().Replace(".", string.Empty))) { return true; } @@ -72,12 +72,6 @@ namespace BizHawk.Client.Common /// Creates a default instance of the default implementation, /// no path is specified so this is in a minimal state that would not be able to be saved /// - public static IMovie DefaultInstance - { - get - { - return new Bk2Movie(); - } - } + public static IMovie DefaultInstance => new Bk2Movie(); } } diff --git a/BizHawk.Client.Common/movie/MovieSession.cs b/BizHawk.Client.Common/movie/MovieSession.cs index 08181f14d7..417a626f9d 100644 --- a/BizHawk.Client.Common/movie/MovieSession.cs +++ b/BizHawk.Client.Common/movie/MovieSession.cs @@ -8,8 +8,6 @@ using BizHawk.Emulation.Cores.Nintendo.SNES9X; using BizHawk.Emulation.Cores.Nintendo.SNES; using BizHawk.Emulation.Cores.Nintendo.GBA; -using BizHawk.Client.Common; - namespace BizHawk.Client.Common { public enum MovieEndAction { Stop, Pause, Record, Finish } @@ -36,7 +34,7 @@ namespace BizHawk.Client.Common } public MultitrackRecorder MultiTrack { get; private set; } - public IMovieController MovieControllerAdapter{ get; set; } + public IMovieController MovieControllerAdapter { get; set; } public IMovie Movie { get; set; } public bool ReadOnly { get; set; } @@ -98,10 +96,7 @@ namespace BizHawk.Client.Common private void Output(string message) { - if (MessageCallback != null) - { - MessageCallback(message); - } + MessageCallback?.Invoke(message); } public void LatchMultitrackPlayerInput(IController playerSource, MultitrackRewiringControllerAdapter rewiredSource) @@ -139,7 +134,9 @@ namespace BizHawk.Client.Common // adelikat: TODO: this is likely the source of frame 0 TAStudio bugs, I think the intent is to check if the movie is 0 length? if (Global.Emulator.Frame == 0) // Hacky + { HandleMovieAfterFrameLoop(); // Frame 0 needs to be handled. + } if (input == null) { @@ -157,7 +154,7 @@ namespace BizHawk.Client.Common private void HandlePlaybackEnd() { // TODO: mainform callback to update on mode change - switch(Global.Config.MovieEndAction) + switch (Global.Config.MovieEndAction) { case MovieEndAction.Stop: Movie.Stop(); @@ -340,7 +337,7 @@ namespace BizHawk.Client.Common } } - //TODO: maybe someone who understands more about what's going on here could rename these step1 and step2 into something more descriptive + // TODO: maybe someone who understands more about what's going on here could rename these step1 and step2 into something more descriptive public bool HandleMovieLoadState_HackyStep2(TextReader reader) { if (!Movie.IsActive) @@ -348,21 +345,17 @@ namespace BizHawk.Client.Common return true; } - if (ReadOnly) { - } else { - string errorMsg; //// fixme: this is evil (it causes crashes in binary states because InflaterInputStream can't have its position set, even to zero. - //((StreamReader)reader).BaseStream.Position = 0; - //((StreamReader)reader).DiscardBufferedData(); - //edit: zero 18-apr-2014 - this was solved by HackyStep1 and HackyStep2, so that the zip stream can be re-acquired instead of needing its position reset - + ////((StreamReader)reader).BaseStream.Position = 0; + ////((StreamReader)reader).DiscardBufferedData(); + // edit: zero 18-apr-2014 - this was solved by HackyStep1 and HackyStep2, so that the zip stream can be re-acquired instead of needing its position reset var result = Movie.ExtractInputLog(reader, out errorMsg); if (!result) { @@ -377,7 +370,10 @@ namespace BizHawk.Client.Common public bool HandleMovieLoadState(TextReader reader) { if (!HandleMovieLoadState_HackyStep1(reader)) + { return false; + } + return HandleMovieLoadState_HackyStep2(reader); } @@ -388,10 +384,9 @@ namespace BizHawk.Client.Common return true; } - string errorMsg; - if (ReadOnly) { + string errorMsg; var result = Movie.CheckTimeLines(reader, out errorMsg); if (!result) { @@ -418,7 +413,6 @@ namespace BizHawk.Client.Common { Movie.SwitchToRecord(); } - } return true; @@ -481,19 +475,16 @@ namespace BizHawk.Client.Common if (movie.SystemID != emulator.SystemId) { throw new MoviePlatformMismatchException( - string.Format( - "Movie system Id ({0}) does not match the currently loaded platform ({1}), unable to load", - movie.SystemID, - emulator.SystemId)); + $"Movie system Id ({movie.SystemID}) does not match the currently loaded platform ({emulator.SystemId}), unable to load"); } } // TODO: Delete this, this save is utterly useless. // Movie was saved immediately before calling QueeuNewMovie. (StartNewMovie) - //if (Movie.IsActive && !string.IsNullOrEmpty(Movie.Filename)) - //{ - // Movie.Save(); - //} + ////if (Movie.IsActive && !string.IsNullOrEmpty(Movie.Filename)) + ////{ + //// Movie.Save(); + ////} // Note: this populates MovieControllerAdapter's Type with the approparite controller // Don't set it to a movie instance of the adapter or you will lose the definition! diff --git a/BizHawk.Client.Common/movie/MultitrackRecording.cs b/BizHawk.Client.Common/movie/MultitrackRecording.cs index 226c3351e8..b587d1f24d 100644 --- a/BizHawk.Client.Common/movie/MultitrackRecording.cs +++ b/BizHawk.Client.Common/movie/MultitrackRecording.cs @@ -10,11 +10,11 @@ namespace BizHawk.Client.Common } public bool IsActive { get; set; } - public int CurrentPlayer{ get; private set; } + public int CurrentPlayer { get; private set; } public bool RecordAll { get; private set; } /// - /// A user friendly multi-track status + /// Gets a user friendly multi-track status /// public string Status { diff --git a/BizHawk.Client.Common/movie/PlatformFrameRates.cs b/BizHawk.Client.Common/movie/PlatformFrameRates.cs index a8bf3655db..ba5cbcb01a 100644 --- a/BizHawk.Client.Common/movie/PlatformFrameRates.cs +++ b/BizHawk.Client.Common/movie/PlatformFrameRates.cs @@ -10,9 +10,9 @@ namespace BizHawk.Client.Common // are we collecting them anywhere else? for avi-writing code perhaps? // just some constants, according to specs - private static readonly double PAL_CARRIER = 15625 * 283.75 + 25; // 4.43361875 MHz - private static readonly double NTSC_CARRIER = 4500000 * 227.5 / 286; // 3.579545454... MHz - private static readonly double PAL_N_CARRIER = 15625 * 229.25 + 25; // 3.58205625 MHz + private static readonly double PAL_CARRIER = 15625 * 283.75 + 25; // 4.43361875 MHz + private static readonly double NTSC_CARRIER = 4500000 * 227.5 / 286; // 3.579545454... MHz + private static readonly double PAL_N_CARRIER = 15625 * 229.25 + 25; // 3.58205625 MHz private static readonly Dictionary _rates = new Dictionary { @@ -34,13 +34,14 @@ namespace BizHawk.Client.Common { "SG_PAL", (3546893 / 313.0 / 228.0) }, // 49.7014320946 { "NGP", (6144000.0 / (515 * 198)) }, // 60.2530155928 { "VBOY", (20000000.0 / (259 * 384 * 4)) }, // 50.2734877735 - { "Lynx", 16000000.0 / ( 16 * 105 * 159 ) }, // 59.89817310572028 + { "Lynx", 16000000.0 / (16 * 105 * 159) }, // 59.89817310572028 { "WSWAN", (3072000.0 / (159 * 256)) }, // 75.4716981132 { "GB", 262144.0 / 4389.0 }, // 59.7275005696 { "GBC", 262144.0 / 4389.0 }, // 59.7275005696 { "GBA", 262144.0 / 4389.0 }, // 59.7275005696 { "GEN", 53693175 / (3420.0 * 262) }, { "GEN_PAL", 53203424 / (3420.0 * 313) }, + // while the number of scanlines per frame is software controlled and variable, we // enforce exactly 262 (NTSC) 312 (PAL) per reference time frame { "A26", 315000000.0 / 88.0 / 262.0 / 228.0 }, // 59.922751013550531429197560173856 @@ -51,13 +52,13 @@ namespace BizHawk.Client.Common { "Coleco", 59.9227510135505 }, // according to http://problemkaputt.de/psx-spx.htm - { "PSX", 44100.0*768*11/7/263/3413 }, // 59.292862562 - { "PSX_PAL", 44100.0*768*11/7/314/3406 }, // 49.7645593576 + { "PSX", 44100.0 * 768 * 11 / 7 / 263 / 3413 }, // 59.292862562 + { "PSX_PAL", 44100.0 * 768 * 11 / 7 / 314 / 3406 }, // 49.7645593576 - { "C64_PAL", PAL_CARRIER*2/9/312/63 }, - { "C64_NTSC", NTSC_CARRIER*2/7/263/65 }, - { "C64_NTSC_OLD", NTSC_CARRIER*2/7/262/64 }, - { "C64_DREAN", PAL_N_CARRIER*2/7/312/65 }, + { "C64_PAL", PAL_CARRIER * 2 / 9 / 312 / 63 }, + { "C64_NTSC", NTSC_CARRIER * 2 / 7 / 263 / 65 }, + { "C64_NTSC_OLD", NTSC_CARRIER * 2 / 7 / 262 / 64 }, + { "C64_DREAN", PAL_N_CARRIER * 2 / 7 / 312 / 65 }, { "INTV", 59.92 } // according to ryphecha, using diff --git a/BizHawk.Client.Common/movie/SubtitleList.cs b/BizHawk.Client.Common/movie/SubtitleList.cs index b2894c7b7b..1c802aa4d5 100644 --- a/BizHawk.Client.Common/movie/SubtitleList.cs +++ b/BizHawk.Client.Common/movie/SubtitleList.cs @@ -90,10 +90,12 @@ namespace BizHawk.Client.Common int lastframe = 0; subs = subs.OrderBy(s => s.Frame).ThenBy(s => s.Y).ToList(); - for (int i = 0; ; i++) + for (int i = 0;; i++) { - if (i == subs.Count()) // we're modifying it + if (i == subs.Count) // we're modifying it + { break; + } subs[i].Message = subs[i].Message.Trim(); diff --git a/BizHawk.Client.Common/movie/bk2/Bk2ControllerAdapter.cs b/BizHawk.Client.Common/movie/bk2/Bk2ControllerAdapter.cs index 107f36929e..c9ca237f43 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2ControllerAdapter.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2ControllerAdapter.cs @@ -14,8 +14,7 @@ namespace BizHawk.Client.Common private readonly WorkingDictionary MyFloatControls = new WorkingDictionary(); public Bk2ControllerAdapter() - { - + { } public Bk2ControllerAdapter(string key) diff --git a/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs b/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs index 409f28cf71..129aaeb7fb 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs @@ -82,8 +82,8 @@ namespace BizHawk.Client.Common { "Mouse Center", 'c' }, { "Mouse Start", 's' }, - {"Mode", 'M'}, - {"MODE", 'M'}, + { "Mode", 'M' }, + { "MODE", 'M' }, { "Fire", 'F' }, { "Lightgun Trigger", 'T' }, @@ -197,10 +197,10 @@ namespace BizHawk.Client.Common "TI83", new Dictionary { - { "UP", 'U'}, - { "DOWN", 'D'}, - { "LEFT", 'L'}, - { "RIGHT", 'R'}, + { "UP", 'U' }, + { "DOWN", 'D' }, + { "LEFT", 'L' }, + { "RIGHT", 'R' }, { "DOT", '`' }, { "ON", 'O' }, { "ENTER", '=' }, @@ -211,8 +211,8 @@ namespace BizHawk.Client.Common { "CLEAR", 'c' }, { "EXP", '^' }, { "DASH", '-' }, - { "PARAOPEN", '('}, - { "PARACLOSE", ')'}, + { "PARAOPEN", '(' }, + { "PARACLOSE", ')' }, { "TAN", 'T' }, { "VARS", 'V' }, { "COS", 'C' }, @@ -265,7 +265,7 @@ namespace BizHawk.Client.Common { "Colon", ':' }, { "Semicolon", ';' }, { "Equal", '=' }, - { "Return", 'e'}, + { "Return", 'e' }, { "Commodore", 'o' }, { "Left Shift", 's' }, { "Comma", ',' }, diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs index 2945307c39..3eec799f7a 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs @@ -4,7 +4,11 @@ namespace BizHawk.Client.Common { public partial class Bk2Movie { - protected enum Moviemode { Inactive, Play, Record, Finished } + protected enum Moviemode + { + Inactive, Play, Record, Finished + } + protected Moviemode _mode = Moviemode.Inactive; public bool IsActive => _mode != Moviemode.Inactive; diff --git a/BizHawk.Client.Common/movie/bk2/StringLogs.cs b/BizHawk.Client.Common/movie/bk2/StringLogs.cs index 97b8a11a09..af5e3b2974 100644 --- a/BizHawk.Client.Common/movie/bk2/StringLogs.cs +++ b/BizHawk.Client.Common/movie/bk2/StringLogs.cs @@ -153,7 +153,7 @@ namespace BizHawk.Client.Common { foreach (var item in collection) { - Insert(index++,item); + Insert(index++, item); } } diff --git a/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs b/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs index e2334999a7..2e343ea40f 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs @@ -16,166 +16,166 @@ namespace BizHawk.Client.Common { "Lynx Controller", new Dictionary { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Select", "s"}, {"Start", "S"}, {"B", "B"}, {"A", "A"} + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "A", "A" } } }, { "GBA Controller", new Dictionary { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Select", "s"}, {"Start", "S"}, {"B", "B"}, - {"A", "A"}, {"L", "L"}, {"R", "R"} + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, + { "A", "A" }, { "L", "L" }, { "R", "R" } } }, { "Genesis 3-Button Controller", new Dictionary { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Start", "S"}, {"A", "A"}, {"B", "B"}, - {"C", "C"} + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Start", "S" }, { "A", "A" }, { "B", "B" }, + { "C", "C" } } }, { "GPGX Genesis Controller", new Dictionary { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"A", "A"}, {"B", "B"}, {"C", "C"}, - {"Start", "S"}, {"X", "X"}, {"Y", "Y"}, {"Z", "Z"}, {"Mode", "M"} + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "A", "A" }, { "B", "B" }, { "C", "C" }, + { "Start", "S" }, { "X", "X" }, { "Y", "Y" }, { "Z", "Z" }, { "Mode", "M" } } }, { "GPGX 3-Button Controller", new Dictionary { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"A", "A"}, {"B", "B"}, - {"C", "C"}, {"Start", "S"}, + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "A", "A" }, { "B", "B" }, + { "C", "C" }, { "Start", "S" }, } }, { "NES Controller", new Dictionary { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Select", "s"}, {"Start", "S"}, {"B", "B"}, - {"A", "A"} + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, + { "A", "A" } } }, { "SNES Controller", new Dictionary { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Select", "s"}, {"Start", "S"}, {"B", "B"}, - {"A", "A"}, {"X", "X"}, {"Y", "Y"}, {"L", "L"}, {"R", "R"} + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, + { "A", "A" }, { "X", "X" }, { "Y", "Y" }, { "L", "L" }, { "R", "R" } } }, { "PC Engine Controller", new Dictionary { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Select", "s"}, {"Run", "r"}, {"B2", "2"}, - {"B1", "1"} + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Run", "r" }, { "B2", "2" }, + { "B1", "1" } } }, { "SMS Controller", new Dictionary { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"B1", "1"}, {"B2", "2"} + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "B1", "1" }, { "B2", "2" } } }, { "TI83 Controller", new Dictionary { - {"0", "0"}, {"1", "1"}, {"2", "2"}, {"3", "3"}, {"4", "4"}, {"5", "5"}, {"6", "6"}, {"7", "7"}, - {"8", "8"}, {"9", "9"}, {"DOT", "`"}, {"ON", "O"}, {"ENTER", "="}, {"UP", "U"}, {"DOWN", "D"}, - {"LEFT", "L"}, {"RIGHT", "R"}, {"PLUS", "+"}, {"MINUS", "_"}, {"MULTIPLY", "*"}, {"DIVIDE", "/"}, - {"CLEAR", "c"}, {"EXP", "^"}, {"DASH", "-"}, {"PARAOPEN", "("}, {"PARACLOSE", ")"}, {"TAN", "T"}, - {"VARS", "V"}, {"COS", "C"}, {"PRGM", "P"}, {"STAT", "s"}, {"MATRIX", "m"}, {"X", "X"}, {"STO", ">"}, - {"LN", "n"}, {"LOG", "L"}, {"SQUARED", "2"}, {"NEG1", "1"}, {"MATH", "H"}, {"ALPHA", "A"}, - {"GRAPH", "G"}, {"TRACE", "t"}, {"ZOOM", "Z"}, {"WINDOW", "W"}, {"Y", "Y"}, {"2ND", "&"}, {"MODE", "O"}, - {"DEL", "D"}, {"COMMA", ","}, {"SIN", "S"} + { "0", "0" }, { "1", "1" }, { "2", "2" }, { "3", "3" }, { "4", "4" }, { "5", "5" }, { "6", "6" }, { "7", "7" }, + { "8", "8" }, { "9", "9" }, { "DOT", "`" }, { "ON", "O" }, { "ENTER", "=" }, { "UP", "U" }, { "DOWN", "D" }, + { "LEFT", "L" }, { "RIGHT", "R" }, { "PLUS", "+" }, { "MINUS", "_" }, { "MULTIPLY", "*" }, { "DIVIDE", "/" }, + { "CLEAR", "c" }, { "EXP", "^" }, { "DASH", "-" }, { "PARAOPEN", "(" }, { "PARACLOSE", ")" }, { "TAN", "T" }, + { "VARS", "V" }, { "COS", "C" }, { "PRGM", "P" }, { "STAT", "s" }, { "MATRIX", "m" }, { "X", "X" }, { "STO", ">" }, + { "LN", "n" }, { "LOG", "L" }, { "SQUARED", "2" }, { "NEG1", "1" }, { "MATH", "H" }, { "ALPHA", "A" }, + { "GRAPH", "G" }, { "TRACE", "t" }, { "ZOOM", "Z" }, { "WINDOW", "W" }, { "Y", "Y" }, { "2ND", "&" }, { "MODE", "O" }, + { "DEL", "D" }, { "COMMA", "," }, { "SIN", "S" } } }, { - "Atari 2600 Basic Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Button", "B"} + "Atari 2600 Basic Controller", new Dictionary + { + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" } } }, { - "Atari 7800 ProLine Joystick Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Trigger", "1"}, {"Trigger 2", "2"} + "Atari 7800 ProLine Joystick Controller", new Dictionary + { + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Trigger", "1" }, { "Trigger 2", "2" } } }, { - "Commodore 64 Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Button", "B"} + "Commodore 64 Controller", new Dictionary + { + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" } } }, { - "Commodore 64 Keyboard", new Dictionary + "Commodore 64 Keyboard", new Dictionary { - {"Key F1", "1"}, {"Key F3", "3"}, {"Key F5", "5"}, {"Key F7", "7"}, - {"Key Left Arrow", "l"}, {"Key 1", "1"}, {"Key 2", "2"}, {"Key 3", "3"}, {"Key 4", "4"}, {"Key 5", "5"}, {"Key 6", "6"}, {"Key 7", "7"}, {"Key 8", "8"}, {"Key 9", "9"}, {"Key 0", "0"}, {"Key Plus", "+"}, {"Key Minus", "-"}, {"Key Pound", "l"}, {"Key Clear/Home", "c"}, {"Key Insert/Delete", "i"}, - {"Key Control", "c"}, {"Key Q", "Q"}, {"Key W", "W"}, {"Key E", "E"}, {"Key R", "R"}, {"Key T", "T"}, {"Key Y", "Y"}, {"Key U", "U"}, {"Key I", "I"}, {"Key O", "O"}, {"Key P", "P"}, {"Key At", "@"}, {"Key Asterisk", "*"}, {"Key Up Arrow", "u"}, {"Key Restore", "r"}, - {"Key Run/Stop", "s"}, {"Key Lck", "k"}, {"Key A", "A"}, {"Key S", "S"}, {"Key D", "D"}, {"Key F", "F"}, {"Key G", "G"}, {"Key H", "H"}, {"Key J", "J"}, {"Key K", "K"}, {"Key L", "L"}, {"Key Colon", ":"}, {"Key Semicolon", ";"}, {"Key Equal", "="}, {"Key Return", "e"}, - {"Key Commodore", "o"}, {"Key Left Shift", "s"}, {"Key Z", "Z"}, {"Key X", "X"}, {"Key C", "C"}, {"Key V", "V"}, {"Key B", "B"}, {"Key N", "N"}, {"Key M", "M"}, {"Key Comma", ","}, {"Key Period", ">"}, {"Key Slash", "/"}, {"Key Right Shift", "s"}, {"Key Cursor Up/Down", "u"}, {"Key Cursor Left/Right", "l"}, - {"Key Space", "_"} + { "Key F1", "1" }, { "Key F3", "3" }, { "Key F5", "5" }, { "Key F7", "7" }, + { "Key Left Arrow", "l" }, { "Key 1", "1" }, { "Key 2", "2" }, { "Key 3", "3" }, { "Key 4", "4" }, { "Key 5", "5" }, { "Key 6", "6" }, { "Key 7", "7" }, { "Key 8", "8" }, { "Key 9", "9" }, { "Key 0", "0" }, { "Key Plus", "+" }, { "Key Minus", "-" }, { "Key Pound", "l" }, { "Key Clear/Home", "c" }, { "Key Insert/Delete", "i" }, + { "Key Control", "c" }, { "Key Q", "Q" }, { "Key W", "W" }, { "Key E", "E" }, { "Key R", "R" }, { "Key T", "T" }, { "Key Y", "Y" }, { "Key U", "U" }, { "Key I", "I" }, { "Key O", "O" }, { "Key P", "P" }, { "Key At", "@" }, { "Key Asterisk", "*" }, { "Key Up Arrow", "u" }, { "Key Restore", "r" }, + { "Key Run/Stop", "s" }, { "Key Lck", "k" }, { "Key A", "A" }, { "Key S", "S" }, { "Key D", "D" }, { "Key F", "F" }, { "Key G", "G" }, { "Key H", "H" }, { "Key J", "J" }, { "Key K", "K" }, { "Key L", "L" }, { "Key Colon", ":" }, { "Key Semicolon", ";" }, { "Key Equal", "=" }, { "Key Return", "e" }, + { "Key Commodore", "o" }, { "Key Left Shift", "s" }, { "Key Z", "Z" }, { "Key X", "X" }, { "Key C", "C" }, { "Key V", "V" }, { "Key B", "B" }, { "Key N", "N" }, { "Key M", "M" }, { "Key Comma", "," }, { "Key Period", ">" }, { "Key Slash", "/" }, { "Key Right Shift", "s" }, { "Key Cursor Up/Down", "u" }, { "Key Cursor Left/Right", "l" }, + { "Key Space", "_" } } }, { "ColecoVision Basic Controller", new Dictionary { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"L", "l"}, {"R", "r"}, - {"Key1", "1"}, {"Key2", "2"}, {"Key3", "3"}, {"Key4", "4"}, {"Key5", "5"}, {"Key6", "6"}, - {"Key7", "7"}, {"Key8", "8"}, {"Key9", "9"}, {"Star", "*"}, {"Key0", "0"}, {"Pound", "#"} + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "L", "l" }, { "R", "r" }, + { "Key1", "1" }, { "Key2", "2" }, { "Key3", "3" }, { "Key4", "4" }, { "Key5", "5" }, { "Key6", "6" }, + { "Key7", "7" }, { "Key8", "8" }, { "Key9", "9" }, { "Star", "*" }, { "Key0", "0" }, { "Pound", "#" } } }, { "Nintento 64 Controller", new Dictionary - { - {"DPad U", "U"}, {"DPad D", "D"}, {"DPad L", "L"}, {"DPad R", "R"}, - {"B", "B"}, {"A", "A"}, {"Z", "Z"}, {"Start", "S"}, {"L", "L"}, {"R", "R"}, - {"C Up", "u"}, {"C Down", "d"}, {"C Left", "l"}, {"C Right", "r"} + { + { "DPad U", "U" }, { "DPad D", "D" }, { "DPad L", "L" }, { "DPad R", "R" }, + { "B", "B" }, { "A", "A" }, { "Z", "Z" }, { "Start", "S" }, { "L", "L" }, { "R", "R" }, + { "C Up", "u" }, { "C Down", "d" }, { "C Left", "l" }, { "C Right", "r" } } }, { "Saturn Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, - {"Start", "S"}, {"X", "X"}, {"Y", "Y"}, {"Z", "Z"}, {"A", "A"}, {"B", "B"}, {"C", "C"}, - {"L", "l"}, {"R", "r"}, + { + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, + { "Start", "S" }, { "X", "X" }, { "Y", "Y" }, { "Z", "Z" }, { "A", "A" }, { "B", "B" }, { "C", "C" }, + { "L", "l" }, { "R", "r" }, } } }; public static readonly Dictionary> ANALOGS = new Dictionary> { - {"Nintento 64 Controller", new Dictionary {{"X Axis", "X"}, {"Y Axis", "Y"}}} + { "Nintento 64 Controller", new Dictionary { { "X Axis", "X" }, { "Y Axis", "Y" } } } }; public static readonly Dictionary> COMMANDS = new Dictionary> { - {"Atari 2600 Basic Controller", new Dictionary {{"Reset", "r"}, {"Select", "s"}}}, - {"Atari 7800 ProLine Joystick Controller", new Dictionary {{"Reset", "r"}, {"Select", "s"}}}, - {"Gameboy Controller", new Dictionary {{"Power", "P"}}}, - {"GBA Controller", new Dictionary {{"Power", "P"}}}, - {"Genesis 3-Button Controller", new Dictionary {{"Reset", "r"}}}, - {"GPGX Genesis Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, - {"NES Controller", new Dictionary {{"Reset", "r"}, {"Power", "P"}, {"FDS Eject", "E"}, {"FDS Insert 0", "0"}, {"FDS Insert 1", "1"}, {"VS Coin 1", "c"}, {"VS Coin 2", "C"}}}, - {"SNES Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, - {"PC Engine Controller", new Dictionary()}, - {"SMS Controller", new Dictionary {{"Pause", "p"}, {"Reset", "r"}}}, - {"TI83 Controller", new Dictionary()}, - {"Nintento 64 Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, - {"Saturn Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, - {"GPGX 3-Button Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, + { "Atari 2600 Basic Controller", new Dictionary { { "Reset", "r" }, { "Select", "s" } } }, + { "Atari 7800 ProLine Joystick Controller", new Dictionary { { "Reset", "r" }, { "Select", "s" } } }, + { "Gameboy Controller", new Dictionary { { "Power", "P" } } }, + { "GBA Controller", new Dictionary { { "Power", "P" } } }, + { "Genesis 3-Button Controller", new Dictionary { { "Reset", "r" } } }, + { "GPGX Genesis Controller", new Dictionary { { "Power", "P" }, { "Reset", "r" } } }, + { "NES Controller", new Dictionary { { "Reset", "r" }, { "Power", "P" }, { "FDS Eject", "E" }, { "FDS Insert 0", "0" }, { "FDS Insert 1", "1" }, { "VS Coin 1", "c" }, { "VS Coin 2", "C" } } }, + { "SNES Controller", new Dictionary { { "Power", "P" }, { "Reset", "r" } } }, + { "PC Engine Controller", new Dictionary() }, + { "SMS Controller", new Dictionary { { "Pause", "p" }, { "Reset", "r" } } }, + { "TI83 Controller", new Dictionary() }, + { "Nintento 64 Controller", new Dictionary { { "Power", "P" }, { "Reset", "r" } } }, + { "Saturn Controller", new Dictionary { { "Power", "P" }, { "Reset", "r" } } }, + { "GPGX 3-Button Controller", new Dictionary { { "Power", "P" }, { "Reset", "r" } } } }; public static readonly Dictionary PLAYERS = new Dictionary { - {"Gameboy Controller", 1}, {"GBA Controller", 1}, {"Genesis 3-Button Controller", 2}, {"GPGX Genesis Controller", 2}, {"NES Controller", 4}, - {"SNES Controller", 4}, {"PC Engine Controller", 5}, {"SMS Controller", 2}, {"TI83 Controller", 1}, {"Atari 2600 Basic Controller", 2}, {"Atari 7800 ProLine Joystick Controller", 2}, - {"ColecoVision Basic Controller", 2}, {"Commodore 64 Controller", 2}, {"Nintento 64 Controller", 4}, {"Saturn Controller", 2}, - {"GPGX 3-Button Controller", 2}, { "Lynx Controller", 1 } + { "Gameboy Controller", 1 }, { "GBA Controller", 1 }, { "Genesis 3-Button Controller", 2 }, { "GPGX Genesis Controller", 2 }, { "NES Controller", 4 }, + { "SNES Controller", 4 }, { "PC Engine Controller", 5 }, { "SMS Controller", 2 }, { "TI83 Controller", 1 }, { "Atari 2600 Basic Controller", 2 }, { "Atari 7800 ProLine Joystick Controller", 2 }, + { "ColecoVision Basic Controller", 2 }, { "Commodore 64 Controller", 2 }, { "Nintento 64 Controller", 4 }, { "Saturn Controller", 2 }, + { "GPGX 3-Button Controller", 2 }, { "Lynx Controller", 1 } }; // just experimenting with different possibly more painful ways to handle mnemonics // |P|UDLRsSBA| - public static Tuple[] DGBMnemonic = + public static readonly Tuple[] DGBMnemonic = { new Tuple(null, '|'), new Tuple("P1 Power", 'P'), @@ -202,7 +202,7 @@ namespace BizHawk.Client.Common new Tuple(null, '|') }; - public static Tuple[] WSMnemonic = + public static readonly Tuple[] WSMnemonic = { new Tuple(null, '|'), new Tuple("P1 X1", '1'), diff --git a/BizHawk.Client.Common/movie/bkm/BkmMovie.HeaderApi.cs b/BizHawk.Client.Common/movie/bkm/BkmMovie.HeaderApi.cs index 3661b76c04..89394dcd67 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmMovie.HeaderApi.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmMovie.HeaderApi.cs @@ -85,6 +85,6 @@ namespace BizHawk.Client.Common public string TextSavestate { get; set; } public byte[] BinarySavestate { get; set; } public int[] SavestateFramebuffer { get { return null; } set { } } // eat and ignore framebuffers - public byte[] SaveRam { get { return null; } set { } } // Bkm does not support Saveram anchored movies + public byte[] SaveRam { get { return null; } set { } } // Bkm does not support Saveram anchored movies } } diff --git a/BizHawk.Client.Common/movie/import/Fm2Import.cs b/BizHawk.Client.Common/movie/import/Fm2Import.cs index 22b472762c..bdbb2eab35 100644 --- a/BizHawk.Client.Common/movie/import/Fm2Import.cs +++ b/BizHawk.Client.Common/movie/import/Fm2Import.cs @@ -46,8 +46,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")) - ); + string.Format("{0} {1} version {2}", EMULATIONORIGIN, emulator, ParseHeader(line, "emuVersion"))); } else if (line.ToLower().StartsWith("version")) { @@ -96,7 +95,7 @@ namespace BizHawk.Client.Common } else if (line.ToLower().StartsWith("guid")) { - continue; //We no longer care to keep this info + continue; // We no longer care to keep this info } else if (line.ToLower().StartsWith("startsfromsavestate")) { @@ -113,7 +112,7 @@ namespace BizHawk.Client.Common } else if (line.ToLower().StartsWith("fourscore")) { - bool fourscore = (ParseHeader(line, "fourscore") == "1"); + bool fourscore = ParseHeader(line, "fourscore") == "1"; if (fourscore) { // TODO: set controller config sync settings diff --git a/BizHawk.Client.Common/movie/import/IMovieImport.cs b/BizHawk.Client.Common/movie/import/IMovieImport.cs index bea7525307..4becee0e2c 100644 --- a/BizHawk.Client.Common/movie/import/IMovieImport.cs +++ b/BizHawk.Client.Common/movie/import/IMovieImport.cs @@ -61,8 +61,7 @@ namespace BizHawk.Client.Common { // Case-insensitive search. int x = line.ToLower().LastIndexOf( - headerName.ToLower() - ) + headerName.Length; + headerName.ToLower()) + headerName.Length; string str = line.Substring(x + 1, line.Length - x - 1); return str.Trim(); } diff --git a/BizHawk.Client.Common/movie/import/MovieImport.cs b/BizHawk.Client.Common/movie/import/MovieImport.cs index a3a92f8ca8..3e53523539 100644 --- a/BizHawk.Client.Common/movie/import/MovieImport.cs +++ b/BizHawk.Client.Common/movie/import/MovieImport.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; -using System.Reflection; using BizHawk.Common; using BizHawk.Common.BufferExtensions; @@ -19,25 +18,25 @@ namespace BizHawk.Client.Common public static class MovieImport { // Movies 2.0 TODO: this is Movie.cs specific, can it be IMovie based? If not, needs to be refactored to a hardcoded 2.0 implementation, client needs to know what kind of type it imported to, or the mainform method needs to be moved here - public const string COMMENT = "comment"; - public const string COREORIGIN = "CoreOrigin"; - public const string CRC16 = "CRC16"; - public const string CRC32 = "CRC32"; - public const string EMULATIONORIGIN = "emuOrigin"; - public const string GAMECODE = "GameCode"; - public const string INTERNALCHECKSUM = "InternalChecksum"; - public const string JAPAN = "Japan"; - public const string MD5 = "MD5"; - public const string MOVIEORIGIN = "MovieOrigin"; - public const string PORT1 = "port1"; - public const string PORT2 = "port2"; - public const string PROJECTID = "ProjectID"; - public const string SHA256 = "SHA256"; - public const string SUPERGAMEBOYMODE = "SuperGameBoyMode"; - public const string STARTSECOND = "StartSecond"; - public const string STARTSUBSECOND = "StartSubSecond"; - public const string SYNCHACK = "SyncHack"; - public const string UNITCODE = "UnitCode"; + private const string COMMENT = "comment"; + private const string COREORIGIN = "CoreOrigin"; + private const string CRC16 = "CRC16"; + private const string CRC32 = "CRC32"; + private const string EMULATIONORIGIN = "emuOrigin"; + private const string GAMECODE = "GameCode"; + private const string INTERNALCHECKSUM = "InternalChecksum"; + private const string JAPAN = "Japan"; + private const string MD5 = "MD5"; + private const string MOVIEORIGIN = "MovieOrigin"; + private const string PORT1 = "port1"; + private const string PORT2 = "port2"; + private const string PROJECTID = "ProjectID"; + private const string SHA256 = "SHA256"; + private const string SUPERGAMEBOYMODE = "SuperGameBoyMode"; + private const string STARTSECOND = "StartSecond"; + private const string STARTSUBSECOND = "StartSubSecond"; + private const string SYNCHACK = "SyncHack"; + private const string UNITCODE = "UnitCode"; public static void ProcessMovieImport(string fn, Action conversionErrorCallback, Action messageCallback) { @@ -97,8 +96,8 @@ namespace BizHawk.Client.Common try { var result = importer.Import(path); - if (result.Errors.Count() > 0) errorMsg = result.Errors.First(); - if (result.Warnings.Count() > 0) warningMsg = result.Warnings.First(); + if (result.Errors.Count > 0) errorMsg = result.Errors.First(); + if (result.Warnings.Count > 0) warningMsg = result.Warnings.First(); movie = result.Movie; } catch (Exception ex) @@ -128,10 +127,8 @@ namespace BizHawk.Client.Common { return true; } - else - { - return false; - } + + return false; } private static BkmMovie LegacyImportFile(string ext, string path, out string errorMsg, out string warningMsg) @@ -139,7 +136,6 @@ namespace BizHawk.Client.Common errorMsg = string.Empty; warningMsg = string.Empty; - BkmMovie m = new BkmMovie(); try @@ -153,7 +149,7 @@ namespace BizHawk.Client.Common m = ImportFM2(path, out errorMsg, out warningMsg); break; case ".FMV": - m = ImportFMV(path, out errorMsg, out warningMsg); + m = ImportFmv(path, out errorMsg, out warningMsg); break; case ".GMV": m = ImportGMV(path, out errorMsg, out warningMsg); @@ -174,19 +170,19 @@ namespace BizHawk.Client.Common m = ImportNMV(path, out errorMsg, out warningMsg); break; case ".SMV": - m = ImportSMV(path, out errorMsg, out warningMsg); + m = ImportSmv(path, out errorMsg, out warningMsg); break; case ".VBM": - m = ImportVBM(path, out errorMsg, out warningMsg); + m = ImportVbm(path, out errorMsg, out warningMsg); break; case ".VMV": - m = ImportVMV(path, out errorMsg, out warningMsg); + m = ImportVmv(path, out errorMsg, out warningMsg); break; case ".YMV": - m = ImportYMV(path, out errorMsg, out warningMsg); + m = ImportYmv(path, out errorMsg, out warningMsg); break; case ".ZMV": - m = ImportZMV(path, out errorMsg, out warningMsg); + m = ImportZmv(path, out errorMsg, out warningMsg); break; case ".BKM": m.Filename = path; @@ -262,12 +258,11 @@ namespace BizHawk.Client.Common } // Import a frame from a text-based format. - private static BkmMovie ImportTextFrame(string line, int lineNum, BkmMovie m, string path, string platform, - ref string warningMsg) + private static BkmMovie ImportTextFrame(string line, int lineNum, BkmMovie m, string path, string platform, ref string warningMsg) { string[] buttons = { }; var controller = string.Empty; - var ext = path != null ? Path.GetExtension(path).ToUpper() : ""; + var ext = path != null ? Path.GetExtension(path).ToUpper() : string.Empty; switch (ext) { case ".FM2": @@ -279,7 +274,8 @@ namespace BizHawk.Client.Common controller = "PC Engine Controller"; break; case ".LSMV": - buttons = new[] { + buttons = new[] + { "B", "Y", "Select", "Start", "Up", "Down", "Left", "Right", "A", "X", "L", "R" }; controller = "SNES Controller"; @@ -288,18 +284,22 @@ namespace BizHawk.Client.Common buttons = new[] { "A", "B", "Select", "Start", "Right", "Left", "Up", "Down" }; controller = "Gameboy Controller"; } + break; case ".YMV": buttons = new[] { "Left", "Right", "Up", "Down", "Start", "A", "B", "C", "X", "Y", "Z", "L", "R" }; controller = "Saturn Controller"; break; } + var controllers = new SimpleController { Definition = new ControllerDefinition { Name = controller } }; + // Split up the sections of the frame. string[] sections = line.Split('|'); if (ext == ".FM2" && sections.Length >= 2 && sections[1].Length != 0) { - controllers["Reset"] = (sections[1][0] == '1'); + controllers["Reset"] = sections[1][0] == '1'; + // Get the first invalid command warning message that arises. if (string.IsNullOrEmpty((warningMsg))) { @@ -314,6 +314,7 @@ namespace BizHawk.Client.Common { warningMsg = "hard reset"; } + break; case '4': warningMsg = "FDS Insert"; @@ -325,7 +326,8 @@ namespace BizHawk.Client.Common warningMsg = "unknown"; break; } - if (warningMsg != "") + + if (warningMsg != string.Empty) { warningMsg = "Unable to import " + warningMsg + " command on line " + lineNum + "."; } @@ -337,20 +339,26 @@ namespace BizHawk.Client.Common char[] off = { '.', ' ', '\t', '\n', '\r' }; if (flags.Length == 0 || off.Contains(flags[0])) { - if (warningMsg == "") + if (warningMsg == string.Empty) + { warningMsg = "Unable to import subframe."; + } + return m; } - bool reset = (flags.Length >= 2 && !off.Contains(flags[1])); + + bool reset = flags.Length >= 2 && !off.Contains(flags[1]); flags = SingleSpaces(flags.Substring(2)); if (reset && ((flags.Length >= 2 && flags[1] != '0') || (flags.Length >= 4 && flags[3] != '0'))) { - if (warningMsg == "") + if (warningMsg == string.Empty) { warningMsg = "Unable to import delayed reset."; } + return m; } + controllers["Reset"] = reset; } /* @@ -371,25 +379,27 @@ namespace BizHawk.Client.Common { // The player number is one less than the section number for the reasons explained above. int player = section + player_offset; - string prefix = "P" + (player) + " "; + string prefix = "P" + player + " "; + // Gameboy doesn't currently have a prefix saying which player the input is for. if (controllers.Definition.Name == "Gameboy Controller") { - prefix = ""; + prefix = string.Empty; } + // Only count lines with that have the right number of buttons and are for valid players. if ( sections[section].Length == buttons.Length && - player <= BkmMnemonicConstants.PLAYERS[controllers.Definition.Name] - ) + player <= BkmMnemonicConstants.PLAYERS[controllers.Definition.Name]) { for (int button = 0; button < buttons.Length; button++) { // Consider the button pressed so long as its spot is not occupied by a ".". - controllers[prefix + buttons[button]] = (sections[section][button] != '.'); + controllers[prefix + buttons[button]] = sections[section][button] != '.'; } } } + // Convert the data for the controllers to a mnemonic and add it as a frame. m.AppendFrame(controllers); return m; @@ -399,6 +409,7 @@ namespace BizHawk.Client.Common private static BkmMovie ImportTextSubtitle(string line, BkmMovie m, string path) { line = SingleSpaces(line); + // The header name, frame, and message are separated by whitespace. int first = line.IndexOf(' '); int second = line.IndexOf(' ', first + 1); @@ -407,7 +418,7 @@ namespace BizHawk.Client.Common // Concatenate the frame and message with default values for the additional fields. string frame; string length; - string ext = path != null ? Path.GetExtension(path).ToUpper() : ""; + string ext = path != null ? Path.GetExtension(path).ToUpper() : string.Empty; if (ext != ".LSMV") { @@ -419,9 +430,11 @@ namespace BizHawk.Client.Common frame = line.Substring(0, first); length = line.Substring(first + 1, second - first - 1); } + string message = line.Substring(second + 1).Trim(); m.Subtitles.AddFromString("subtitle " + frame + " 0 0 " + length + " FFFFFFFF " + message); } + return m; } @@ -455,14 +468,14 @@ namespace BizHawk.Client.Common while ((line = sr.ReadLine()) != null) { lineNum++; - if (line == "") + if (line == string.Empty) { continue; } else if (line[0] == '|') { m = ImportTextFrame(line, lineNum, m, path, platform, ref warningMsg); - if (errorMsg != "") + if (errorMsg != string.Empty) { sr.Close(); return null; @@ -475,15 +488,13 @@ namespace BizHawk.Client.Common else if (line.ToLower().StartsWith("emuversion")) { m.Comments.Add( - EMULATIONORIGIN + " " + emulator + " version " + ParseHeader(line, "emuVersion") - ); + EMULATIONORIGIN + " " + emulator + " version " + ParseHeader(line, "emuVersion")); } else if (line.ToLower().StartsWith("version")) { string version = ParseHeader(line, "version"); m.Comments.Add( - MOVIEORIGIN + " " + Path.GetExtension(path) + " version " + version - ); + MOVIEORIGIN + " " + Path.GetExtension(path) + " version " + version); if (Path.GetExtension(path).ToUpper() == ".FM2" && version != "3") { errorMsg = ".FM2 movie version must always be 3."; @@ -519,6 +530,7 @@ namespace BizHawk.Client.Common else if (line.ToLower().StartsWith("rerecordcount")) { int rerecordCount; + // Try to parse the re-record count as an integer, defaulting to 0 if it fails. try { @@ -533,7 +545,7 @@ namespace BizHawk.Client.Common } else if (line.ToLower().StartsWith("guid")) { - continue; //We no longer care to keep this info + continue; // We no longer care to keep this info } else if (line.ToLower().StartsWith("startsfromsavestate")) { @@ -547,17 +559,17 @@ namespace BizHawk.Client.Common } else if (line.ToLower().StartsWith("palflag")) { - bool pal = (ParseHeader(line, "palFlag") == "1"); + bool pal = ParseHeader(line, "palFlag") == "1"; m.Header[HeaderKeys.PAL] = pal.ToString(); } else if (line.ToLower().StartsWith("ispal")) { - bool pal = (ParseHeader(line, "isPal") == "1"); + bool pal = ParseHeader(line, "isPal") == "1"; m.Header[HeaderKeys.PAL] = pal.ToString(); } else if (line.ToLower().StartsWith("fourscore")) { - bool fourscore = (ParseHeader(line, "fourscore") == "1"); + bool fourscore = ParseHeader(line, "fourscore") == "1"; m.Header[HeaderKeys.FOURSCORE] = fourscore.ToString(); } else @@ -566,6 +578,7 @@ namespace BizHawk.Client.Common m.Comments.Add(line); } } + sr.Close(); return m; } @@ -575,8 +588,7 @@ namespace BizHawk.Client.Common { // Case-insensitive search. int x = line.ToLower().LastIndexOf( - headerName.ToLower() - ) + headerName.Length; + headerName.ToLower()) + headerName.Length; string str = line.Substring(x + 1, line.Length - x - 1); return str.Trim(); } @@ -629,6 +641,7 @@ namespace BizHawk.Client.Common BkmMovie m = new BkmMovie(path); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader r = new BinaryReader(fs); + // 000 4-byte signature: 46 43 4D 1A "FCM\x1A" string signature = r.ReadStringFixedAscii(4); if (signature != "FCM\x1A") @@ -638,6 +651,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // 004 4-byte little-endian unsigned int: version number, must be 2 uint version = r.ReadUInt32(); if (version != 2) @@ -648,11 +662,13 @@ namespace BizHawk.Client.Common return null; } m.Comments.Add(MOVIEORIGIN + " .FCM version " + version); + // 008 1-byte flags byte flags = r.ReadByte(); - // bit 0: reserved, set to 0 + /* - bit 1: + * bit 0: reserved, set to 0 + * bit 1: * if "0", movie begins from an embedded "quicksave" snapshot * if "1", movie begins from reset or power-on[1] */ @@ -663,6 +679,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + /* bit 2: * if "0", NTSC timing @@ -671,19 +688,25 @@ namespace BizHawk.Client.Common unfortunately it is not reliable - the emulator does not take the "PAL" setting from the ROM, but from a user preference. This means that this site cannot calculate movie lengths reliably. */ - bool pal = (((flags >> 2) & 0x1) != 0); + bool pal = ((flags >> 2) & 0x1) != 0; m.Header[HeaderKeys.PAL] = pal.ToString(); + // other: reserved, set to 0 - bool syncHack = (((flags >> 4) & 0x1) != 0); + bool syncHack = ((flags >> 4) & 0x1) != 0; m.Comments.Add(SYNCHACK + " " + syncHack); + // 009 1-byte flags: reserved, set to 0 r.ReadByte(); + // 00A 1-byte flags: reserved, set to 0 r.ReadByte(); + // 00B 1-byte flags: reserved, set to 0 r.ReadByte(); + // 00C 4-byte little-endian unsigned int: number of frames uint frameCount = r.ReadUInt32(); + // 010 4-byte little-endian unsigned int: rerecord count uint rerecordCount = r.ReadUInt32(); m.Rerecords = rerecordCount; @@ -694,22 +717,30 @@ namespace BizHawk.Client.Common reset-based. */ r.ReadUInt32(); + // 01C 4-byte little-endian unsigned int: offset to the controller data inside file uint firstFrameOffset = r.ReadUInt32(); + // 020 16-byte md5sum of the ROM used byte[] md5 = r.ReadBytes(16); m.Header[MD5] = md5.BytesToHexString().ToLower(); + // 030 4-byte little-endian unsigned int: version of the emulator used uint emuVersion = r.ReadUInt32(); m.Comments.Add(EMULATIONORIGIN + " FCEU " + emuVersion); + // 034 name of the ROM used - UTF8 encoded nul-terminated string. List gameBytes = new List(); while (r.PeekChar() != 0) + { gameBytes.Add(r.ReadByte()); + } + // Advance past null byte. r.ReadByte(); string gameName = Encoding.UTF8.GetString(gameBytes.ToArray()); m.Header[HeaderKeys.GAMENAME] = gameName; + /* After the header comes "metadata", which is UTF8-coded movie title string. The metadata begins after the ROM name and ends at the savestate offset. This string is displayed as "Author Info" in the Windows version of the @@ -717,11 +748,15 @@ namespace BizHawk.Client.Common */ List authorBytes = new List(); while (r.PeekChar() != 0) + { authorBytes.Add(r.ReadByte()); + } + // Advance past null byte. r.ReadByte(); string author = Encoding.UTF8.GetString(authorBytes.ToArray()); m.Header[HeaderKeys.AUTHOR] = author; + // Advance to first byte of input data. r.BaseStream.Position = firstFrameOffset; SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = "NES Controller" } }; @@ -732,9 +767,11 @@ namespace BizHawk.Client.Common while (frame <= frameCount) { byte update = r.ReadByte(); + // aa: Number of delta bytes to follow int delta = (update >> 5) & 0x3; int frames = 0; + /* The delta byte(s) indicate the number of emulator frames between this update and the next update. It is encoded in little-endian format and its size depends on the magnitude of the delta: @@ -756,54 +793,50 @@ namespace BizHawk.Client.Common { controllers["Reset"] = false; } + frames--; } + if (((update >> 7) & 0x1) != 0) { // Control update: 1aabbbbb bool reset = false; int command = update & 0x1F; + // bbbbb: - controllers["Reset"] = (command == 1); - if (warningMsg == "") + controllers["Reset"] = command == 1; + if (warningMsg == string.Empty) { switch (command) { - // Do nothing - case 0: + case 0: // Do nothing break; - // Reset - case 1: + case 1: // Reset reset = true; break; - // Power cycle - case 2: + case 2: // Power cycle reset = true; if (frame != 1) { warningMsg = "hard reset"; } + break; - // VS System Insert Coin - case 7: + case 7: // VS System Insert Coin warningMsg = "VS System Insert Coin"; break; - // VS System Dipswitch 0 Toggle - case 8: + case 8: // VS System Dipswitch 0 Toggle warningMsg = "VS System Dipswitch 0 Toggle"; break; - // FDS Insert - case 24: + case 24: // FDS Insert fds = true; warningMsg = "FDS Insert"; break; - // FDS Eject - case 25: + case 25: // FDS Eject fds = true; warningMsg = "FDS Eject"; break; - // FDS Select Side - case 26: + case 26: // FDS Select Side fds = true; warningMsg = "FDS Select Side"; break; @@ -811,11 +844,13 @@ namespace BizHawk.Client.Common warningMsg = "unknown"; break; } - if (warningMsg != "") + + if (warningMsg != string.Empty) { warningMsg = "Unable to import " + warningMsg + " command at frame " + frame + "."; } } + /* 1 Even if the header says "movie begins from reset", the file still contains a quicksave, and the quicksave is actually loaded. This flag can't therefore be trusted. To check if the movie actually @@ -841,6 +876,7 @@ namespace BizHawk.Client.Common { fourscore = true; } + /* ccc: * 0 A @@ -853,6 +889,7 @@ namespace BizHawk.Client.Common * 7 Right */ int button = update & 0x7; + /* The controller update toggles the affected input. Controller update data is emitted to the movie file only when the state of the controller changes. @@ -860,8 +897,13 @@ namespace BizHawk.Client.Common controllers["P" + player + " " + buttons[button]] = !controllers["P" + player + " " + buttons[button]]; } } + m.Header[HeaderKeys.PLATFORM] = "NES"; - if (fds) { m.Header[HeaderKeys.BOARDNAME] = "FDS"; } + if (fds) + { + m.Header[HeaderKeys.BOARDNAME] = "FDS"; + } + m.Header[HeaderKeys.FOURSCORE] = fourscore.ToString(); r.Close(); fs.Close(); @@ -875,12 +917,13 @@ namespace BizHawk.Client.Common } // FMV file format: http://tasvideos.org/FMV.html - private static BkmMovie ImportFMV(string path, out string errorMsg, out string warningMsg) + private static BkmMovie ImportFmv(string path, out string errorMsg, out string warningMsg) { errorMsg = warningMsg = string.Empty; BkmMovie m = new BkmMovie(path); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader r = new BinaryReader(fs); + // 000 4-byte signature: 46 4D 56 1A "FMV\x1A" string signature = r.ReadStringFixedAscii(4); if (signature != "FMV\x1A") @@ -890,8 +933,10 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // 004 1-byte flags: byte flags = r.ReadByte(); + // bit 7: 0=reset-based, 1=savestate-based if (((flags >> 2) & 0x1) != 0) { @@ -900,19 +945,21 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // other bits: unknown, set to 0 // 005 1-byte flags: flags = r.ReadByte(); + // bit 5: is a FDS recording - bool FDS; + bool fds; if (((flags >> 5) & 0x1) != 0) { - FDS = true; + fds = true; m.Header[HeaderKeys.BOARDNAME] = "FDS"; } else { - FDS = false; + fds = false; } @@ -920,42 +967,52 @@ namespace BizHawk.Client.Common // bit 6: uses controller 2 bool controller2 = (((flags >> 6) & 0x1) != 0); + // bit 7: uses controller 1 bool controller1 = (((flags >> 7) & 0x1) != 0); + // other bits: unknown, set to 0 // 006 4-byte little-endian unsigned int: unknown, set to 00000000 r.ReadInt32(); + // 00A 4-byte little-endian unsigned int: rerecord count minus 1 uint rerecordCount = r.ReadUInt32(); + /* The rerecord count stored in the file is the number of times a savestate was loaded. If a savestate was never loaded, the number is 0. Famtasia however displays "1" in such case. It always adds 1 to the number found in the file. */ m.Rerecords = rerecordCount + 1; + // 00E 2-byte little-endian unsigned int: unknown, set to 0000 r.ReadInt16(); + // 010 64-byte zero-terminated emulator identifier string string emuVersion = NullTerminated(r.ReadStringFixedAscii(64)); m.Comments.Add(EMULATIONORIGIN + " Famtasia version " + emuVersion); m.Comments.Add(MOVIEORIGIN + " .FMV"); + // 050 64-byte zero-terminated movie title string string description = NullTerminated(r.ReadStringFixedAscii(64)); m.Comments.Add(COMMENT + " " + description); - if (!controller1 && !controller2 && !FDS) + if (!controller1 && !controller2 && !fds) { warningMsg = "No input recorded."; r.Close(); fs.Close(); return m; } + /* The file format has no means of identifying NTSC/"PAL". It is always assumed that the game is NTSC - that is, 60 fps. */ m.Header[HeaderKeys.PAL] = "False"; + // 090 frame data begins here - SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = "NES Controller" } }; + var controllers = new SimpleController { Definition = new ControllerDefinition { Name = "NES Controller" } }; + /* * 01 Right * 02 Left @@ -967,7 +1024,7 @@ namespace BizHawk.Client.Common * 80 Start */ string[] buttons = { "Right", "Left", "Up", "Down", "B", "A", "Select", "Start" }; - bool[] masks = { controller1, controller2, FDS }; + bool[] masks = { controller1, controller2, fds }; /* The file has no terminator byte or frame count. The number of frames is the divided by . @@ -980,6 +1037,7 @@ namespace BizHawk.Client.Common bytesPerFrame++; } } + long frameCount = (fs.Length - 144) / bytesPerFrame; for (long frame = 1; frame <= frameCount; frame++) { @@ -994,6 +1052,7 @@ namespace BizHawk.Client.Common { continue; } + byte controllerState = r.ReadByte(); if (player != 3) { @@ -1007,8 +1066,10 @@ namespace BizHawk.Client.Common warningMsg = "FDS commands are not properly supported."; } } + m.AppendFrame(controllers); } + r.Close(); fs.Close(); return m; @@ -1018,9 +1079,10 @@ namespace BizHawk.Client.Common private static BkmMovie ImportGMV(string path, out string errorMsg, out string warningMsg) { errorMsg = warningMsg = string.Empty; - BkmMovie m = new BkmMovie(path); - FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); - BinaryReader r = new BinaryReader(fs); + var m = new BkmMovie(path); + var fs = new FileStream(path, FileMode.Open, FileAccess.Read); + var r = new BinaryReader(fs); + // 000 16-byte signature and format version: "Gens Movie TEST9" string signature = r.ReadStringFixedAscii(15); if (signature != "Gens Movie TEST") @@ -1030,16 +1092,21 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + m.Header[HeaderKeys.PLATFORM] = "GEN"; + // 00F ASCII-encoded GMV file format version. The most recent is 'A'. (?) string version = r.ReadStringFixedAscii(1); m.Comments.Add(MOVIEORIGIN + " .GMV version " + version); m.Comments.Add(EMULATIONORIGIN + " Gens"); + // 010 4-byte little-endian unsigned int: rerecord count uint rerecordCount = r.ReadUInt32(); m.Rerecords = rerecordCount; + // 014 ASCII-encoded controller config for player 1. '3' or '6'. string player1Config = r.ReadStringFixedAscii(1); + // 015 ASCII-encoded controller config for player 2. '3' or '6'. string player2Config = r.ReadStringFixedAscii(1); SimpleController controllers = new SimpleController { Definition = new ControllerDefinition() }; @@ -1051,8 +1118,10 @@ namespace BizHawk.Client.Common { controllers.Definition.Name = "GPGX 3-Button Controller"; } + // 016 special flags (Version A and up only) byte flags = r.ReadByte(); + /* bit 7 (most significant): if "1", movie runs at 50 frames per second; if "0", movie runs at 60 frames per second The file format has no means of identifying NTSC/"PAL", but the FPS can still be derived from the @@ -1060,6 +1129,7 @@ namespace BizHawk.Client.Common */ bool pal = (((flags >> 7) & 0x1) != 0); m.Header[HeaderKeys.PAL] = pal.ToString(); + // bit 6: if "1", movie requires a savestate. if (((flags >> 6) & 0x1) != 0) { @@ -1068,13 +1138,17 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // bit 5: if "1", movie is 3-player movie; if "0", movie is 2-player movie - bool threePlayers = (((flags >> 5) & 0x1) != 0); + bool threePlayers = ((flags >> 5) & 0x1) != 0; + // Unknown. r.ReadByte(); + // 018 40-byte zero-terminated ASCII movie name string string description = NullTerminated(r.ReadStringFixedAscii(40)); m.Comments.Add(COMMENT + " " + description); + /* 040 frame data For controller bytes, each value is determined by OR-ing together values for whichever of the following are @@ -1102,6 +1176,7 @@ namespace BizHawk.Client.Common * 0x80 Controller 2 Mode */ string[] other = { "X", "Y", "Z", "Mode" }; + // The file has no terminator byte or frame count. The number of frames is the divided by 3. long frameCount = (fs.Length - 64) / 3; for (long frame = 1; frame <= frameCount; frame++) @@ -1110,12 +1185,13 @@ namespace BizHawk.Client.Common for (int player = 1; player <= 3; player++) { byte controllerState = r.ReadByte(); + // * is controller 3 if a 3-player movie, or XYZ-mode if a 2-player movie. if (player != 3 || threePlayers) { for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = (((controllerState >> button) & 0x1) == 0); + controllers["P" + player + " " + buttons[button]] = ((controllerState >> button) & 0x1) == 0; } } else @@ -1124,17 +1200,20 @@ namespace BizHawk.Client.Common { if (player1Config == "6") { - controllers["P1 " + other[button]] = (((controllerState >> button) & 0x1) == 0); + controllers["P1 " + other[button]] = ((controllerState >> button) & 0x1) == 0; } + if (player2Config == "6") { - controllers["P2 " + other[button]] = (((controllerState >> (button + 4)) & 0x1) == 0); + controllers["P2 " + other[button]] = ((controllerState >> (button + 4)) & 0x1) == 0; } } } } + m.AppendFrame(controllers); } + return m; } @@ -1144,6 +1223,7 @@ namespace BizHawk.Client.Common errorMsg = warningMsg = string.Empty; var m = new BkmMovie(path); var hf = new HawkFile(path); + // .LSMV movies are .zip files containing data files. if (!hf.IsArchive) { @@ -1158,33 +1238,38 @@ namespace BizHawk.Client.Common hf.BindArchiveMember(item.Index); var stream = hf.GetStream(); string authors = Encoding.UTF8.GetString(stream.ReadAllBytes()); - string author_list = ""; - string author_last = ""; - using (StringReader reader = new StringReader(authors)) + string author_list = string.Empty; + string author_last = string.Empty; + using (var reader = new StringReader(authors)) { string line; + // Each author is on a different line. while ((line = reader.ReadLine()) != null) { string author = line.Trim(); - if (author != "") + if (author != string.Empty) { - if (author_last != "") + if (author_last != string.Empty) { author_list += author_last + ", "; } + author_last = author; } } } - if (author_list != "") + + if (author_list != string.Empty) { author_list += "and "; } - if (author_last != "") + + if (author_last != string.Empty) { author_list += author_last; } + m.Header[HeaderKeys.AUTHOR] = author_list; hf.Unbind(); } @@ -1209,6 +1294,7 @@ namespace BizHawk.Client.Common hf.BindArchiveMember(item.Index); var stream = hf.GetStream(); string gametype = Encoding.UTF8.GetString(stream.ReadAllBytes()).Trim(); + // TODO: Handle the other types. switch (gametype) { @@ -1225,7 +1311,8 @@ namespace BizHawk.Client.Common Global.Config.GB_AsSGB = true; break; } - bool pal = (gametype == "snes_pal" || gametype == "sgb_pal"); + + bool pal = gametype == "snes_pal" || gametype == "sgb_pal"; m.Header[HeaderKeys.PAL] = pal.ToString(); hf.Unbind(); } @@ -1236,13 +1323,13 @@ namespace BizHawk.Client.Common string input = Encoding.UTF8.GetString(stream.ReadAllBytes()); int lineNum = 0; - using (StringReader reader = new StringReader(input)) + using (var reader = new StringReader(input)) { lineNum++; string line; while ((line = reader.ReadLine()) != null) { - if (line == "") + if (line == string.Empty) { continue; } @@ -1257,17 +1344,18 @@ namespace BizHawk.Client.Common { // Note that this logic assumes the first non-empty log entry is a valid input log entry // and that it is NOT a subframe input entry. It seems safe to assume subframe input would not be on the first line - m.AppendFrame(EmptyLmsvFrame(line)); //line is needed to parse pipes and know the controller configuration + m.AppendFrame(EmptyLmsvFrame(line)); // line is needed to parse pipes and know the controller configuration } m = ImportTextFrame(line, lineNum, m, path, platform, ref warningMsg); - if (errorMsg != "") + if (errorMsg != string.Empty) { hf.Unbind(); return null; } } } + hf.Unbind(); } else if (item.Name.StartsWith("moviesram.")) @@ -1281,6 +1369,7 @@ namespace BizHawk.Client.Common hf.Unbind(); return null; } + hf.Unbind(); } else if (item.Name == "port1") @@ -1313,6 +1402,7 @@ namespace BizHawk.Client.Common var stream = hf.GetStream(); string rerecords = Encoding.UTF8.GetString(stream.ReadAllBytes()); int rerecordCount; + // Try to parse the re-record count as an integer, defaulting to 0 if it fails. try { @@ -1322,6 +1412,7 @@ namespace BizHawk.Client.Common { rerecordCount = 0; } + m.Rerecords = (ulong)rerecordCount; hf.Unbind(); } @@ -1349,8 +1440,11 @@ namespace BizHawk.Client.Common { string line; while ((line = reader.ReadLine()) != null) + { m = ImportTextSubtitle(line, m, path); + } } + hf.Unbind(); } else if (item.Name == "starttime.second") @@ -1381,8 +1475,7 @@ namespace BizHawk.Client.Common m.Header[HeaderKeys.PLATFORM] = platform; - LibsnesCore.SnesSyncSettings ss = new LibsnesCore.SnesSyncSettings(); - ss.Profile = "Compatibility"; + var ss = new LibsnesCore.SnesSyncSettings { Profile = "Compatibility" }; m.SyncSettingsJson = ConfigService.SaveWithType(ss); return m; @@ -1398,6 +1491,7 @@ namespace BizHawk.Client.Common BkmMovie m = new BkmMovie(path); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader r = new BinaryReader(fs); + // 000 8-byte "MDFNMOVI" signature var signature = r.ReadStringFixedAscii(8); if (signature != "MDFNMOVI") @@ -1407,23 +1501,30 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // 008 uint32 Mednafen Version (Current is 0A 08) uint emuVersion = r.ReadUInt32(); m.Comments.Add(EMULATIONORIGIN + " Mednafen " + emuVersion); + // 00C uint32 Movie Format Version (Current is 01) uint version = r.ReadUInt32(); m.Comments.Add(MOVIEORIGIN + " .MCM version " + version); + // 010 32-byte MD5 of the ROM used byte[] md5 = r.ReadBytes(16); + // Discard the second 16 bytes. r.ReadBytes(16); m.Header[MD5] = md5.BytesToHexString().ToLower(); + // 030 64-byte Filename of the ROM used (with extension) string gameName = NullTerminated(r.ReadStringFixedAscii(64)); m.Header[HeaderKeys.GAMENAME] = gameName; + // 070 uint32 Re-record Count uint rerecordCount = r.ReadUInt32(); m.Rerecords = (ulong)rerecordCount; + // 074 5-byte Console indicator (pce, ngp, pcfx, wswan) string platform = NullTerminated(r.ReadStringFixedAscii(5)); Dictionary> platforms = new Dictionary> @@ -1436,15 +1537,15 @@ namespace BizHawk.Client.Common */ "nes", new Dictionary { - {"name", "NES"}, {"ports", 4}, {"bytesPerPort", 1}, - {"buttons", new[] { "A", "B", "Select", "Start", "Up", "Down", "Left", "Right" }} + { "name", "NES" }, { "ports", 4 }, { "bytesPerPort", 1 }, + { "buttons", new[] { "A", "B", "Select", "Start", "Up", "Down", "Left", "Right" } } } }, { "pce", new Dictionary { - {"name", "PC Engine"}, {"ports", 5}, {"bytesPerPort", 2}, - {"buttons", new[] { "B1", "B2", "Select", "Run", "Up", "Right", "Down", "Left" }} + { "name", "PC Engine" }, { "ports", 5 }, { "bytesPerPort", 2 }, + { "buttons", new[] { "B1", "B2", "Select", "Run", "Up", "Right", "Down", "Left" } } } }, { @@ -1462,20 +1563,25 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + string name = (string)platforms[platform]["name"]; - string systemID = name.ToUpper(); // Hack + string systemId = name.ToUpper(); // Hack + + m.Header[HeaderKeys.PLATFORM] = systemId; - m.Header[HeaderKeys.PLATFORM] = systemID; // 079 32-byte Author name string author = NullTerminated(r.ReadStringFixedAscii(32)); m.Header[HeaderKeys.AUTHOR] = author; + // 099 103-byte Padding 0s r.ReadBytes(103); + // TODO: Verify if NTSC/"PAL" mode used for the movie can be detected or not. // 100 variable Input data SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = name + " Controller" } }; int bytes = 256; + // The input stream consists of 1 byte for power-on and reset, and then X bytes per each input port per frame. if (platform == "nes") { @@ -1483,9 +1589,11 @@ namespace BizHawk.Client.Common r.ReadByte(); bytes++; } + string[] buttons = (string[])platforms[platform]["buttons"]; int ports = (int)platforms[platform]["ports"]; int bytesPerPort = (int)platforms[platform]["bytesPerPort"]; + // Frame Size (with Control Byte) int size = (ports * bytesPerPort) + 1; long frameCount = (fs.Length - bytes) / size; @@ -1501,17 +1609,19 @@ namespace BizHawk.Client.Common ushort controllerState = r.ReadByte(); for (int button = 0; button < buttons.Length; button++) { - string prefix = platform == "lynx" ? "" : ("P" + player + " "); // hack - controllers[prefix + buttons[button]] = (((controllerState >> button) & 0x1) != 0); + string prefix = platform == "lynx" ? string.Empty : "P" + player + " "; // hack + controllers[prefix + buttons[button]] = ((controllerState >> button) & 0x1) != 0; } } r.ReadByte(); - if (platform == "nes" && warningMsg == "") + if (platform == "nes" && warningMsg == string.Empty) { warningMsg = "Control commands are not properly supported."; } + m.AppendFrame(controllers); } + r.Close(); fs.Close(); return m; @@ -1530,6 +1640,7 @@ namespace BizHawk.Client.Common BkmMovie m = new BkmMovie(path); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader r = new BinaryReader(fs); + // 0000: 4-byte signature: "MMV\0" string signature = r.ReadStringFixedAscii(4); if (signature != "MMV\0") @@ -1539,15 +1650,19 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // 0004: 4-byte little endian unsigned int: dega version uint emuVersion = r.ReadUInt32(); m.Comments.Add(EMULATIONORIGIN + " Dega version " + emuVersion); m.Comments.Add(MOVIEORIGIN + " .MMV"); + // 0008: 4-byte little endian unsigned int: frame count uint frameCount = r.ReadUInt32(); + // 000c: 4-byte little endian unsigned int: rerecord count uint rerecordCount = r.ReadUInt32(); m.Rerecords = rerecordCount; + // 0010: 4-byte little endian flag: begin from reset? uint reset = r.ReadUInt32(); if (reset == 0) @@ -1557,24 +1672,32 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // 0014: 4-byte little endian unsigned int: offset of state information r.ReadUInt32(); + // 0018: 4-byte little endian unsigned int: offset of input data r.ReadUInt32(); + // 001c: 4-byte little endian unsigned int: size of input packet r.ReadUInt32(); + // 0020-005f: string: author info (UTF-8) string author = NullTerminated(r.ReadStringFixedAscii(64)); m.Header[HeaderKeys.AUTHOR] = author; + // 0060: 4-byte little endian flags byte flags = r.ReadByte(); + // bit 0: unused // bit 1: "PAL" - bool pal = (((flags >> 1) & 0x1) != 0); + bool pal = ((flags >> 1) & 0x1) != 0; m.Header[HeaderKeys.PAL] = pal.ToString(); + // bit 2: Japan bool japan = (((flags >> 2) & 0x1) != 0); m.Header[JAPAN] = japan.ToString(); + // bit 3: Game Gear (version 1.16+) bool gamegear; if (((flags >> 3) & 0x1) != 0) @@ -1587,15 +1710,19 @@ namespace BizHawk.Client.Common gamegear = false; m.Header[HeaderKeys.PLATFORM] = "SMS"; } + // bits 4-31: unused r.ReadBytes(3); + // 0064-00e3: string: rom name (ASCII) string gameName = NullTerminated(r.ReadStringFixedAscii(128)); m.Header[HeaderKeys.GAMENAME] = gameName; + // 00e4-00f3: binary: rom MD5 digest byte[] md5 = r.ReadBytes(16); - m.Header[MD5] = string.Format("{0:x8}", md5.BytesToHexString().ToLower()); + m.Header[MD5] = $"{md5.BytesToHexString().ToLower():x8}"; var controllers = new SimpleController { Definition = new ControllerDefinition { Name = "SMS Controller" } }; + /* 76543210 * bit 0 (0x01): up @@ -1620,18 +1747,20 @@ namespace BizHawk.Client.Common byte controllerState = r.ReadByte(); for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = (((controllerState >> button) & 0x1) != 0); + controllers["P" + player + " " + buttons[button]] = ((controllerState >> button) & 0x1) != 0; } + if (player == 1) { - controllers["Pause"] = ( - (((controllerState >> 6) & 0x1) != 0 && (!gamegear)) || - (((controllerState >> 7) & 0x1) != 0 && gamegear) - ); + controllers["Pause"] = + (((controllerState >> 6) & 0x1) != 0 && (!gamegear)) + || (((controllerState >> 7) & 0x1) != 0 && gamegear); } } + m.AppendFrame(controllers); } + r.Close(); fs.Close(); return m; @@ -1641,9 +1770,10 @@ namespace BizHawk.Client.Common private static BkmMovie ImportNMV(string path, out string errorMsg, out string warningMsg) { errorMsg = warningMsg = string.Empty; - BkmMovie m = new BkmMovie(path); - FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); - BinaryReader r = new BinaryReader(fs); + var m = new BkmMovie(path); + var fs = new FileStream(path, FileMode.Open, FileAccess.Read); + var r = new BinaryReader(fs); + // 000 4-byte signature: 4E 53 53 1A "NSS\x1A" string signature = r.ReadStringFixedAscii(4); if (signature != "NSS\x1A") @@ -1653,12 +1783,15 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // 004 4-byte version string (example "0960") string emuVersion = r.ReadStringFixedAscii(4); m.Comments.Add(EMULATIONORIGIN + " Nintendulator version " + emuVersion); m.Comments.Add(MOVIEORIGIN + " .NMV"); + // 008 4-byte file size, not including the 16-byte header r.ReadUInt32(); + /* 00C 4-byte file type string * "NSAV" - standard savestate @@ -1673,6 +1806,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + /* Individual blocks begin with an 8-byte header, consisting of a 4-byte signature and a 4-byte length (which does not include the length of the block header). @@ -1686,11 +1820,15 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + r.ReadUInt32(); + // 000 1-byte controller #1 type (see below) byte controller1 = r.ReadByte(); + // 001 1-byte controller #2 type (or four-score mask, see below) byte controller2 = r.ReadByte(); + /* Controller data is variant, depending on which controllers are attached at the time of recording. The following controllers are implemented: @@ -1703,9 +1841,9 @@ namespace BizHawk.Client.Common * 6 - SNES controller (2 bytes) - A/B become B/Y, adds A/X and L/R shoulder buttons * 7 - Vs Unisystem Zapper (3 bytes) */ - bool fourscore = (controller1 == 5); + bool fourscore = controller1 == 5; m.Header[HeaderKeys.FOURSCORE] = fourscore.ToString(); - bool[] masks = new[] { false, false, false, false, false }; + bool[] masks = { false, false, false, false, false }; if (fourscore) { /* @@ -1715,18 +1853,20 @@ namespace BizHawk.Client.Common */ for (int controller = 1; controller < masks.Length; controller++) { - masks[controller - 1] = (((controller2 >> (controller - 1)) & 0x1) != 0); + masks[controller - 1] = ((controller2 >> (controller - 1)) & 0x1) != 0; } + warningMsg = "Nintendulator's Four Score recording is seemingly broken."; } else { - byte[] types = new[] { controller1, controller2 }; + byte[] types = { controller1, controller2 }; for (int controller = 1; controller <= types.Length; controller++) { - masks[controller - 1] = (types[controller - 1] == 1); + masks[controller - 1] = types[controller - 1] == 1; + // Get the first unsupported controller warning message that arises. - if (warningMsg == "") + if (warningMsg == string.Empty) { switch (types[controller - 1]) { @@ -1751,15 +1891,18 @@ namespace BizHawk.Client.Common warningMsg = "Vs Unisystem Zapper"; break; } - if (warningMsg != "") + + if (warningMsg != string.Empty) { warningMsg = warningMsg + " is not properly supported."; } } } } + // 002 1-byte expansion port controller type byte expansion = r.ReadByte(); + /* The expansion port can potentially have an additional controller connected. The following expansion controllers are implemented: @@ -1771,14 +1914,16 @@ namespace BizHawk.Client.Common * 5 - Family Trainer (2 bytes) * 6 - Oeka Kids writing tablet (3 bytes) */ - string[] expansions = new[] { + string[] expansions = + { "Unconnected", "Famicom 4-player adapter", "Famicom Arkanoid paddle", "Family Basic Keyboard", "Alternate keyboard layout", "Family Trainer", "Oeka Kids writing tablet" }; - if (expansion != 0 && warningMsg == "") + if (expansion != 0 && warningMsg == string.Empty) { warningMsg = "Expansion port is not properly supported. This movie uses " + expansions[expansion] + "."; } + // 003 1-byte number of bytes per frame, plus flags byte data = r.ReadByte(); int bytesPerFrame = data & 0xF; @@ -1790,6 +1935,7 @@ namespace BizHawk.Client.Common bytes++; } } + /* Depending on the mapper used by the game in question, an additional byte of data may be stored during each frame. This is most frequently used for FDS games (storing either the disk number or 0xFF to eject) or VS @@ -1800,25 +1946,30 @@ namespace BizHawk.Client.Common { masks[4] = true; } + // bit 6: Game Genie active /* bit 7: Framerate * if "0", NTSC timing * if "1", "PAL" timing */ - bool pal = (((data >> 7) & 0x1) != 0); + bool pal = ((data >> 7) & 0x1) != 0; m.Header[HeaderKeys.PAL] = pal.ToString(); + // 004 4-byte little-endian unsigned int: rerecord count uint rerecordCount = r.ReadUInt32(); m.Rerecords = rerecordCount; + /* 008 4-byte little-endian unsigned int: length of movie description 00C (variable) null-terminated UTF-8 text, movie description (currently not implemented) */ string movieDescription = NullTerminated(r.ReadStringFixedAscii((int)r.ReadUInt32())); m.Comments.Add(COMMENT + " " + movieDescription); + // ... 4-byte little-endian unsigned int: length of controller data in bytes uint length = r.ReadUInt32(); + // ... (variable) controller data SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = "NES Controller" } }; /* @@ -1833,7 +1984,8 @@ namespace BizHawk.Client.Common * 80: Right Other controllers store data in their own formats, and are beyond the scope of this document. */ - string[] buttons = new[] { "A", "B", "Select", "Start", "Up", "Down", "Left", "Right" }; + string[] buttons = { "A", "B", "Select", "Start", "Up", "Down", "Left", "Right" }; + // The controller data contains / frames. long frameCount = length / bytesPerFrame; for (int frame = 1; frame <= frameCount; frame++) @@ -1850,27 +2002,30 @@ namespace BizHawk.Client.Common { for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = (((controllerState >> button) & 0x1) != 0); + controllers["P" + player + " " + buttons[button]] = ((controllerState >> button) & 0x1) != 0; } } - else if (warningMsg == "") + else if (warningMsg == string.Empty) { warningMsg = "Extra input is not properly supported."; } } + m.AppendFrame(controllers); } + r.Close(); fs.Close(); return m; } - private static BkmMovie ImportSMV(string path, out string errorMsg, out string warningMsg) + private static BkmMovie ImportSmv(string path, out string errorMsg, out string warningMsg) { errorMsg = warningMsg = string.Empty; BkmMovie m = new BkmMovie(path); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader r = new BinaryReader(fs); + // 000 4-byte signature: 53 4D 56 1A "SMV\x1A" string signature = r.ReadStringFixedAscii(4); if (signature != "SMV\x1A") @@ -1881,6 +2036,7 @@ namespace BizHawk.Client.Common return null; } m.Header[HeaderKeys.PLATFORM] = "SNES"; + // 004 4-byte little-endian unsigned int: version number uint versionNumber = r.ReadUInt32(); string version; @@ -1911,8 +2067,10 @@ namespace BizHawk.Client.Common // 00C 4-byte little-endian unsigned int: rerecord count m.Rerecords = r.ReadUInt32(); + // 010 4-byte little-endian unsigned int: number of frames uint frameCount = r.ReadUInt32(); + // 014 1-byte flags "controller mask" byte controllerFlags = r.ReadByte(); /* @@ -1927,8 +2085,9 @@ namespace BizHawk.Client.Common bool[] controllersUsed = new bool[5]; for (int controller = 1; controller <= controllersUsed.Length; controller++) { - controllersUsed[controller - 1] = (((controllerFlags >> (controller - 1)) & 0x1) != 0); + controllersUsed[controller - 1] = ((controllerFlags >> (controller - 1)) & 0x1) != 0; } + // 015 1-byte flags "movie options" byte movieFlags = r.ReadByte(); /* @@ -1943,6 +2102,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // bit 1: if "0", movie is NTSC (60 fps); if "1", movie is PAL (50 fps) bool pal = (((movieFlags >> 1) & 0x1) != 0); m.Header[HeaderKeys.PAL] = pal.ToString(); @@ -1973,11 +2133,14 @@ namespace BizHawk.Client.Common is used (and MOVIE_SYNC_DATA_EXISTS is set), 0 bytes otherwise. */ int extraRomInfo = (((syncFlags >> 6) & 0x1) != 0 && (syncFlags & 0x1) != 0) ? 30 : 0; + // 018 4-byte little-endian unsigned int: offset to the savestate inside file uint savestateOffset = r.ReadUInt32(); + // 01C 4-byte little-endian unsigned int: offset to the controller data inside file uint firstFrameOffset = r.ReadUInt32(); int[] controllerTypes = new int[2]; + // The (.SMV 1.51 and up) header has an additional 32 bytes at the end if (version != "1.43") { @@ -1989,13 +2152,17 @@ namespace BizHawk.Client.Common */ controllerTypes[0] = r.ReadByte(); controllerTypes[1] = r.ReadByte(); + // 026 4 1-byte signed ints: controller IDs of port 1, or -1 for unplugged r.ReadBytes(4); + // 02A 4 1-byte signed ints: controller IDs of port 2, or -1 for unplugged r.ReadBytes(4); + // 02E 18 bytes: reserved for future use r.ReadBytes(18); } + /* After the header comes "metadata", which is UTF16-coded movie title string (author info). The metadata begins from position 32 (0x20 (0x40 for 1.51 and up)) and ends at > button) & 0x1) != 0 - ); + controllers["P" + player + " " + buttons[button]] = + ((controllerState >> button) & 0x1) != 0; } } - else if (warningMsg == "") + else if (warningMsg == string.Empty) { warningMsg = "Controller " + player + " not supported."; } } + // The controller data contains frames. if (frame == 0) { continue; } + m.AppendFrame(controllers); } + r.Close(); fs.Close(); - LibsnesCore.SnesSyncSettings ss = new LibsnesCore.SnesSyncSettings(); - ss.Profile = "Compatibility"; + var ss = new LibsnesCore.SnesSyncSettings { Profile = "Compatibility" }; m.SyncSettingsJson = ConfigService.SaveWithType(ss); return m; } - + // VBM file format: http://code.google.com/p/vba-rerecording/wiki/VBM - private static BkmMovie ImportVBM(string path, out string errorMsg, out string warningMsg) + private static BkmMovie ImportVbm(string path, out string errorMsg, out string warningMsg) { errorMsg = warningMsg = string.Empty; - BkmMovie m = new BkmMovie(path); - FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); - BinaryReader r = new BinaryReader(fs); + var m = new BkmMovie(path); + var fs = new FileStream(path, FileMode.Open, FileAccess.Read); + var r = new BinaryReader(fs); + // 000 4-byte signature: 56 42 4D 1A "VBM\x1A" string signature = r.ReadStringFixedAscii(4); if (signature != "VBM\x1A") @@ -2156,6 +2328,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // 004 4-byte little-endian unsigned int: major version number, must be "1" uint majorVersion = r.ReadUInt32(); if (majorVersion != 1) @@ -2165,6 +2338,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + /* 008 4-byte little-endian integer: movie "uid" - identifies the movie-savestate relationship, also used as the recording time in Unix epoch format @@ -2173,15 +2347,20 @@ namespace BizHawk.Client.Common // 00C 4-byte little-endian unsigned int: number of frames uint frameCount = r.ReadUInt32(); + // 010 4-byte little-endian unsigned int: rerecord count uint rerecordCount = r.ReadUInt32(); m.Rerecords = rerecordCount; + // 014 1-byte flags: (movie start flags) byte flags = r.ReadByte(); + // bit 0: if "1", movie starts from an embedded "quicksave" snapshot - bool startfromquicksave = ((flags & 0x1) != 0); + bool startfromquicksave = (flags & 0x1) != 0; + // bit 1: if "1", movie starts from reset with an embedded SRAM - bool startfromsram = (((flags >> 1) & 0x1) != 0); + bool startfromsram = ((flags >> 1) & 0x1) != 0; + // other: reserved, set to 0 // (If both bits 0 and 1 are "1", the movie file is invalid) if (startfromquicksave && startfromsram) @@ -2191,6 +2370,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + if (startfromquicksave) { errorMsg = "Movies that begin with a savestate are not supported."; @@ -2198,6 +2378,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + if (startfromsram) { errorMsg = "Movies that begin with SRAM are not supported."; @@ -2205,6 +2386,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // 015 1-byte flags: controller flags byte controllerFlags = r.ReadByte(); /* @@ -2218,6 +2400,7 @@ namespace BizHawk.Client.Common { controllersUsed[controller - 1] = (((controllerFlags >> (controller - 1)) & 0x1) != 0); } + if (!controllersUsed[0]) { errorMsg = "Controller 1 must be in use."; @@ -2225,41 +2408,50 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // other: reserved // 016 1-byte flags: system flags (game always runs at 60 frames/sec) flags = r.ReadByte(); + // bit 0: if "1", movie is for the GBA system - bool is_gba = ((flags & 0x1) != 0); + bool isGBA = (flags & 0x1) != 0; + // bit 1: if "1", movie is for the GBC system - bool is_gbc = (((flags >> 1) & 0x1) != 0); + bool isGBC = ((flags >> 1) & 0x1) != 0; + // bit 2: if "1", movie is for the SGB system - bool is_sgb = (((flags >> 2) & 0x1) != 0); + bool isSGB = ((flags >> 2) & 0x1) != 0; + // other: reserved, set to 0 // (At most one of bits 0, 1, 2 can be "1") - //if (!(is_gba ^ is_gbc ^ is_sgb) && (is_gba || is_gbc || is_sgb)) //TODO: adelikat: this doesn't do what the comment above suggests it is trying to check for, it is always false! - //{ - //errorMsg = "This is not a valid .VBM file."; - //r.Close(); - //fs.Close(); - //return null; - //} + ////if (!(is_gba ^ is_gbc ^ is_sgb) && (is_gba || is_gbc || is_sgb)) //TODO: adelikat: this doesn't do what the comment above suggests it is trying to check for, it is always false! + ////{ + ////errorMsg = "This is not a valid .VBM file."; + ////r.Close(); + ////fs.Close(); + ////return null; + ////} // (If all 3 of these bits are "0", it is for regular GB.) string platform = "GB"; - if (is_gba) + if (isGBA) { platform = "GBA"; } - if (is_gbc) + + if (isGBC) { platform = "GBC"; } - if (is_sgb) + + if (isSGB) { m.Comments.Add(SUPERGAMEBOYMODE + " True"); } + m.Header[HeaderKeys.PLATFORM] = platform; + // 017 1-byte flags: (values of some boolean emulator options) flags = r.ReadByte(); /* @@ -2267,8 +2459,8 @@ namespace BizHawk.Client.Common * bit 1: (skipBiosFile) if "0" and the movie was made with a GBA BIOS file, the BIOS intro is included in the * movie. * bit 2: (rtcEnable) if "1", the emulator "real time clock" feature was enabled. + * bit 3: (unsupported) must be "0" or the movie file is considered invalid (legacy). */ - // bit 3: (unsupported) must be "0" or the movie file is considered invalid (legacy). if (((flags >> 3) & 0x1) != 0) { errorMsg = "This is not a valid .VBM file."; @@ -2276,6 +2468,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + /* * bit 4: (lagReduction) if "0" and the movie is of a GBA game, the movie was made using the old excessively * laggy GBA timing. @@ -2297,10 +2490,12 @@ namespace BizHawk.Client.Common */ string gameName = NullTerminated(r.ReadStringFixedAscii(12)); m.Header[HeaderKeys.GAMENAME] = gameName; + // 030 1-byte unsigned char: minor version/revision number of current VBM version, the latest is "1" byte minorVersion = r.ReadByte(); m.Comments.Add(MOVIEORIGIN + " .VBM version " + majorVersion + "." + minorVersion); m.Comments.Add(EMULATIONORIGIN + " Visual Boy Advance"); + // 031 1-byte unsigned char: the internal CRC of the ROM used while recording r.ReadByte(); /* @@ -2312,24 +2507,28 @@ namespace BizHawk.Client.Common 034 4-byte little-endian unsigned int: the Game Code of the ROM used while recording, or the Unit Code if not GBA */ - uint gameCode_unitCode = r.ReadUInt32(); + uint gameCodeUnitCode = r.ReadUInt32(); if (platform == "GBA") { m.Header[CRC16] = checksum_crc16.ToString(); - m.Header[GAMECODE] = gameCode_unitCode.ToString(); + m.Header[GAMECODE] = gameCodeUnitCode.ToString(); } else { m.Header[INTERNALCHECKSUM] = checksum_crc16.ToString(); - m.Header[UNITCODE] = gameCode_unitCode.ToString(); + m.Header[UNITCODE] = gameCodeUnitCode.ToString(); } + // 038 4-byte little-endian unsigned int: offset to the savestate or SRAM inside file, set to 0 if unused r.ReadBytes(4); + // 03C 4-byte little-endian unsigned int: offset to the controller data inside file uint firstFrameOffset = r.ReadUInt32(); + // After the header is 192 bytes of text. The first 64 of these 192 bytes are for the author's name (or names). string author = NullTerminated(r.ReadStringFixedAscii(64)); m.Header[HeaderKeys.AUTHOR] = author; + // The following 128 bytes are for a description of the movie. Both parts must be null-terminated. string movieDescription = NullTerminated(r.ReadStringFixedAscii(128)); m.Comments.Add(COMMENT + " " + movieDescription); @@ -2366,7 +2565,7 @@ namespace BizHawk.Client.Common */ string[] other = { - "Reset (old timing)" , "Reset (new timing since version 1.1)", "Left motion sensor", + "Reset (old timing)", "Reset (new timing since version 1.1)", "Left motion sensor", "Right motion sensor", "Down motion sensor", "Up motion sensor" }; for (int frame = 1; frame <= frameCount; frame++) @@ -2378,14 +2577,15 @@ namespace BizHawk.Client.Common ushort controllerState = r.ReadUInt16(); for (int button = 0; button < buttons.Length; button++) { - controllers[buttons[button]] = (((controllerState >> button) & 0x1) != 0); + controllers[buttons[button]] = ((controllerState >> button) & 0x1) != 0; if (((controllerState >> button) & 0x1) != 0 && button > 7) { continue; } } + // TODO: Handle the other buttons. - if (warningMsg == "") + if (warningMsg == string.Empty) { for (int button = 0; button < other.Length; button++) { @@ -2396,6 +2596,7 @@ namespace BizHawk.Client.Common } } } + // TODO: Handle the additional controllers. for (int player = 2; player <= controllersUsed.Length; player++) { @@ -2404,20 +2605,23 @@ namespace BizHawk.Client.Common r.ReadBytes(2); } } + m.AppendFrame(controllers); } + r.Close(); fs.Close(); return m; } // VMV file format: http://tasvideos.org/VMV.html - private static BkmMovie ImportVMV(string path, out string errorMsg, out string warningMsg) + private static BkmMovie ImportVmv(string path, out string errorMsg, out string warningMsg) { errorMsg = warningMsg = string.Empty; BkmMovie m = new BkmMovie(path); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader r = new BinaryReader(fs); + // 000 12-byte signature: "VirtuaNES MV" string signature = r.ReadStringFixedAscii(12); if (signature != "VirtuaNES MV") @@ -2427,14 +2631,18 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + m.Header[HeaderKeys.PLATFORM] = "NES"; + // 00C 2-byte little-endian integer: movie version 0x0400 ushort version = r.ReadUInt16(); m.Comments.Add(MOVIEORIGIN + " .VMV version " + version); m.Comments.Add(EMULATIONORIGIN + " VirtuaNES"); + // 00E 2-byte little-endian integer: record version ushort recordVersion = r.ReadUInt16(); m.Comments.Add(COMMENT + " Record version " + recordVersion); + // 010 4-byte flags (control byte) uint flags = r.ReadUInt32(); /* @@ -2448,6 +2656,7 @@ namespace BizHawk.Client.Common { controllersUsed[controller - 1] = (((flags >> (controller - 1)) & 0x1) != 0); } + bool fourscore = (controllersUsed[2] || controllersUsed[3]); m.Header[HeaderKeys.FOURSCORE] = fourscore.ToString(); /* @@ -2462,6 +2671,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + /* bit 7: disable rerecording For the other control bytes, if a key from 1P to 4P (whichever one) is entirely ON, the following 4 bytes @@ -2470,10 +2680,13 @@ namespace BizHawk.Client.Common */ // 014 DWORD Ext0; // ROM:program CRC FDS:program ID r.ReadBytes(4); + // 018 WORD Ext1; // ROM:unused,0 FDS:maker ID r.ReadBytes(2); + // 01A WORD Ext2; // ROM:unused,0 FDS:disk no. r.ReadBytes(2); + // 01C 4-byte little-endian integer: rerecord count uint rerecordCount = r.ReadUInt32(); m.Rerecords = rerecordCount; @@ -2484,23 +2697,32 @@ namespace BizHawk.Client.Common 4=TILE_RENDER */ r.ReadByte(); + // 021 BYTE IRQtype // IRQ type r.ReadByte(); + // 022 BYTE FrameIRQ // FrameIRQ not allowed r.ReadByte(); + // 023 1-byte flag: 0=NTSC (60 Hz), 1="PAL" (50 Hz) bool pal = (r.ReadByte() == 1); m.Header[HeaderKeys.PAL] = pal.ToString(); + // 024 8-bytes: reserved, set to 0 r.ReadBytes(8); + // 02C 4-byte little-endian integer: save state start offset r.ReadBytes(4); + // 030 4-byte little-endian integer: save state end offset r.ReadBytes(4); + // 034 4-byte little-endian integer: movie data offset uint firstFrameOffset = r.ReadUInt32(); + // 038 4-byte little-endian integer: movie frame count uint frameCount = r.ReadUInt32(); + // 03C 4-byte little-endian integer: CRC (CRC excluding this data(to prevent cheating)) int crc32 = r.ReadInt32(); m.Header[CRC32] = crc32.ToString(); @@ -2511,6 +2733,7 @@ namespace BizHawk.Client.Common fs.Close(); return m; } + r.BaseStream.Position = firstFrameOffset; SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = "NES Controller" } }; /* @@ -2523,7 +2746,7 @@ namespace BizHawk.Client.Common * 40 Left * 80 Right */ - string[] buttons = new[] { "A", "B", "Select", "Start", "Up", "Down", "Left", "Right" }; + string[] buttons = { "A", "B", "Select", "Start", "Up", "Down", "Left", "Right" }; for (int frame = 1; frame <= frameCount; frame++) { /* @@ -2538,58 +2761,48 @@ namespace BizHawk.Client.Common { continue; } + byte controllerState = r.ReadByte(); if (controllerState >= 0xF0) { if (controllerState == 0xF0) { ushort command = r.ReadUInt16(); - string commandName = ""; + string commandName = string.Empty; if ((command & 0xFF00) == 0) { switch (command & 0x00FF) { - // NESCMD_NONE - case 0: + case 0: // NESCMD_NONE break; - // NESCMD_HWRESET - case 1: + case 1: // NESCMD_HWRESET controllers["Reset"] = true; break; - // NESCMD_SWRESET - case 2: + case 2: // NESCMD_SWRESET controllers["Reset"] = true; break; - // NESCMD_EXCONTROLLER - case 3: + case 3: // NESCMD_EXCONTROLLER commandName = "NESCMD_EXCONTROLLER, 0"; break; - // NESCMD_DISK_THROTTLE_ON - case 4: + case 4: // NESCMD_DISK_THROTTLE_ON commandName = "NESCMD_DISK_THROTTLE_ON, 0"; break; - // NESCMD_DISK_THROTTLE_OFF - case 5: + case 5: // NESCMD_DISK_THROTTLE_OFF commandName = "NESCMD_DISK_THROTTLE_OFF, 0"; break; - // NESCMD_DISK_EJECT - case 6: + case 6: // NESCMD_DISK_EJECT commandName = "NESCMD_DISK_EJECT, 0"; break; - // NESCMD_DISK_0A - case 7: + case 7: // NESCMD_DISK_0A commandName = "NESCMD_DISK_0A, 0"; break; - // NESCMD_DISK_0B - case 8: + case 8: // NESCMD_DISK_0B commandName = "NESCMD_DISK_0B, 0"; break; - // NESCMD_DISK_1A - case 9: + case 9: // NESCMD_DISK_1A commandName = "NESCMD_DISK_1A, 0"; break; - // NESCMD_DISK_1B - case 10: + case 10: // NESCMD_DISK_1B commandName = "NESCMD_DISK_1B, 0"; break; default: @@ -2601,7 +2814,8 @@ namespace BizHawk.Client.Common { commandName = "NESCMD_EXCONTROLLER, " + (command & 0xFF00); } - if (commandName != "" && warningMsg == "") + + if (commandName != string.Empty && warningMsg == string.Empty) { warningMsg = "Unable to run command \"" + commandName + "\"."; } @@ -2609,39 +2823,45 @@ namespace BizHawk.Client.Common else if (controllerState == 0xF3) { uint dwdata = r.ReadUInt32(); + // TODO: Make a clearer warning message. - if (warningMsg == "") + if (warningMsg == string.Empty) { warningMsg = "Unable to run SetSyncExData(" + dwdata + ")."; } } + controllerState = r.ReadByte(); } + for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = (((controllerState >> button) & 0x1) != 0); + controllers["P" + player + " " + buttons[button]] = ((controllerState >> button) & 0x1) != 0; } } + m.AppendFrame(controllers); } + r.Close(); fs.Close(); return m; } // YMV file format: https://code.google.com/p/yabause-rr/wiki/YMVfileformat - private static BkmMovie ImportYMV(string path, out string errorMsg, out string warningMsg) + private static BkmMovie ImportYmv(string path, out string errorMsg, out string warningMsg) { return ImportText(path, out errorMsg, out warningMsg); } // ZMV file format: http://tasvideos.org/ZMV.html - private static BkmMovie ImportZMV(string path, out string errorMsg, out string warningMsg) + private static BkmMovie ImportZmv(string path, out string errorMsg, out string warningMsg) { errorMsg = warningMsg = string.Empty; BkmMovie m = new BkmMovie(path); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader r = new BinaryReader(fs); + // 000 3-byte signature: 5A 4D 56 "ZMV" string signature = r.ReadStringFixedAscii(3); if (signature != "ZMV") @@ -2651,33 +2871,46 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + m.Header[HeaderKeys.PLATFORM] = "SNES"; + // 003 2-byte little-endian unsigned int: zsnes version number short version = r.ReadInt16(); m.Comments.Add(EMULATIONORIGIN + " ZSNES version " + version); m.Comments.Add(MOVIEORIGIN + " .ZMV"); + // 005 4-byte little-endian integer: CRC32 of the ROM int crc32 = r.ReadInt32(); m.Header[CRC32] = crc32.ToString(); + // 009 4-byte little-endian unsigned int: number of frames uint frameCount = r.ReadUInt32(); + // 00D 4-byte little-endian unsigned int: number of rerecords uint rerecordCount = r.ReadUInt32(); m.Rerecords = rerecordCount; + // 011 4-byte little-endian unsigned int: number of frames removed by rerecord r.ReadBytes(4); + // 015 4-byte little-endian unsigned int: number of frames advanced step by step r.ReadBytes(4); + // 019 1-byte: average recording frames per second r.ReadByte(); + // 01A 4-byte little-endian unsigned int: number of key combos r.ReadBytes(4); + // 01E 2-byte little-endian unsigned int: number of internal chapters ushort internalChaptersCount = r.ReadUInt16(); + // 020 2-byte little-endian unsigned int: length of the author name field in bytes ushort authorSize = r.ReadUInt16(); + // 022 3-byte little-endian unsigned int: size of an uncompressed save state in bytes r.ReadBytes(3); + // 025 1-byte: reserved r.ReadByte(); /* @@ -2692,28 +2925,32 @@ namespace BizHawk.Client.Common bit 0: super scope in second port */ byte controllerFlags = r.ReadByte(); - string peripheral = ""; - bool superScope = ((controllerFlags & 0x1) != 0); + string peripheral = string.Empty; + bool superScope = (controllerFlags & 0x1) != 0; if (superScope) { peripheral = "Super Scope"; } + controllerFlags >>= 1; - bool secondMouse = ((controllerFlags & 0x1) != 0); - if (secondMouse && peripheral == "") + bool secondMouse = (controllerFlags & 0x1) != 0; + if (secondMouse && peripheral == string.Empty) { peripheral = "Second Mouse"; } + controllerFlags >>= 1; - bool firstMouse = ((controllerFlags & 0x1) != 0); - if (firstMouse && peripheral == "") + bool firstMouse = (controllerFlags & 0x1) != 0; + if (firstMouse && peripheral == string.Empty) { peripheral = "First Mouse"; } - if (peripheral != "") + + if (peripheral != string.Empty) { warningMsg = "Unable to import " + peripheral + "."; } + // 027 1-byte flags: byte movieFlags = r.ReadByte(); byte begins = (byte)(movieFlags & 0xC0); @@ -2728,6 +2965,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // if "10", movie begins from reset // if "01", movie begins from power-on if (begins == 0x40) @@ -2737,6 +2975,7 @@ namespace BizHawk.Client.Common fs.Close(); return null; } + // if "11", movie begins from power-on with SRAM clear // bit 5: if "0", movie is NTSC (60 fps); if "1", movie is PAL (50 fps) bool pal = (((movieFlags >> 5) & 0x1) != 0); @@ -2747,6 +2986,7 @@ namespace BizHawk.Client.Common specifies size */ uint savestateSize = (uint)((r.ReadByte() | (r.ReadByte() << 8) | (r.ReadByte() << 16)) & 0x7FFFFF); + // Next follows a ZST format savestate. r.ReadBytes((int)savestateSize); SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = "SNES Controller" } }; @@ -2807,6 +3047,7 @@ namespace BizHawk.Client.Common { throw new ArgumentException("RLE data repeats for frames beyond the total frame count."); } + for (; frames <= frame; frames++) { m.AppendFrame(controllers); @@ -2819,12 +3060,16 @@ namespace BizHawk.Client.Common 000 3-byte little endian unsigned int: save state size in format defined above */ savestateSize = (uint)((r.ReadByte() | (r.ReadByte() << 8) | (r.ReadByte() << 16)) & 0x7FFFFF); + // 001 above size: save state r.ReadBytes((int)savestateSize); + // above size+001 4-byte little endian unsigned int: frame number save state loads to r.ReadBytes(4); + // above size+005 2-byte: controller status bit field, see below r.ReadBytes(2); + // above size+007 9-byte: previous controller input bits r.ReadBytes(9); internalChapters++; @@ -2909,23 +3154,25 @@ namespace BizHawk.Client.Common { for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = ( - ((controllerState >> button) & 0x1) != 0 - ); + controllers["P" + player + " " + buttons[button]] = + ((controllerState >> button) & 0x1) != 0; } } } - else if (warningMsg == "") + else if (warningMsg == string.Empty) { warningMsg = "Controller " + player + " not supported."; } } } + m.AppendFrame(controllers); frames++; } } + r.BaseStream.Position = r.BaseStream.Length - authorSize; + // Last in the file comes the author name field, which is an UTF-8 encoded text string. var author = Encoding.UTF8.GetString(r.ReadBytes(authorSize)); m.Header[HeaderKeys.AUTHOR] = author; diff --git a/BizHawk.Client.Common/movie/import/PJMImport.cs b/BizHawk.Client.Common/movie/import/PJMImport.cs index 32c9fbaab1..eb2a5ff9ea 100644 --- a/BizHawk.Client.Common/movie/import/PJMImport.cs +++ b/BizHawk.Client.Common/movie/import/PJMImport.cs @@ -1,17 +1,17 @@ using BizHawk.Emulation.Cores.Sony.PSX; -using Newtonsoft.Json; using System; using System.IO; +using Newtonsoft.Json; + namespace BizHawk.Client.Common { [ImportExtension(".pjm")] - public class PJMImport : MovieImporter + public class PjmImport : MovieImporter { protected override void RunImport() { Bk2Movie movie = Result.Movie; - MiscHeaderInfo info; movie.HeaderEntries[HeaderKeys.PLATFORM] = "PSX"; @@ -19,17 +19,17 @@ namespace BizHawk.Client.Common { using (var br = new BinaryReader(fs)) { - info = parseHeader(movie, "PJM ", br); + var info = ParseHeader(movie, "PJM ", br); fs.Seek(info.controllerDataOffset, SeekOrigin.Begin); if (info.binaryFormat) { - parseBinaryInputLog(br, movie, info); + ParseBinaryInputLog(br, movie, info); } else { - parseTextInputLog(br, movie, info); + ParseTextInputLog(br, movie, info); } } } @@ -37,7 +37,7 @@ namespace BizHawk.Client.Common movie.Save(); } - protected MiscHeaderInfo parseHeader(Bk2Movie movie, string expectedMagic, BinaryReader br) + protected MiscHeaderInfo ParseHeader(Bk2Movie movie, string expectedMagic, BinaryReader br) { var info = new MiscHeaderInfo(); @@ -48,10 +48,10 @@ namespace BizHawk.Client.Common return info; } - UInt32 movieVersionNumber = br.ReadUInt32(); + uint movieVersionNumber = br.ReadUInt32(); if (movieVersionNumber != 2) { - Result.Warnings.Add(String.Format("Unexpected movie version: got {0}, expecting 2", movieVersionNumber)); + Result.Warnings.Add($"Unexpected movie version: got {movieVersionNumber}, expecting 2"); } // 008: UInt32 emulator version. @@ -63,26 +63,32 @@ namespace BizHawk.Client.Common { Result.Errors.Add("Movie starts from savestate; this is currently unsupported."); } + if ((flags & 0x04) != 0) { movie.HeaderEntries[HeaderKeys.PAL] = "1"; } + if ((flags & 0x08) != 0) { Result.Errors.Add("Movie contains embedded memory cards; this is currently unsupported."); } + if ((flags & 0x10) != 0) { Result.Errors.Add("Movie contains embedded cheat list; this is currently unsupported."); } + if ((flags & 0x20) != 0 || (flags2 & 0x06) != 0) { Result.Errors.Add("Movie relies on emulator hacks; this is currently unsupported."); } + if ((flags & 0x40) != 0) { info.binaryFormat = false; } + if ((flags & 0x80) != 0 || (flags2 & 0x01) != 0) { Result.Errors.Add("Movie uses multitap; this is currently unsupported."); @@ -127,14 +133,23 @@ namespace BizHawk.Client.Common return info; } - Octoshock.SyncSettings syncsettings = new Octoshock.SyncSettings(); - syncsettings.FIOConfig.Devices8 = - new[] { - info.player1Type, - OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None, - info.player2Type, - OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None - }; + var syncsettings = new Octoshock.SyncSettings + { + FIOConfig = + { + Devices8 = new[] + { + info.player1Type, + OctoshockDll.ePeripheralType.None, + OctoshockDll.ePeripheralType.None, + OctoshockDll.ePeripheralType.None, + info.player2Type, + OctoshockDll.ePeripheralType.None, + OctoshockDll.ePeripheralType.None, + OctoshockDll.ePeripheralType.None + } + } + }; // Annoying kludge to force the json serializer to serialize the type name for "o" object. // For just the "o" object to have type information, it must be cast to a superclass such @@ -147,7 +162,7 @@ namespace BizHawk.Client.Common movie.SyncSettingsJson = JsonConvert.SerializeObject(new { o = (object)syncsettings }, jsonSettings); info.frameCount = br.ReadUInt32(); - UInt32 rerecordCount = br.ReadUInt32(); + uint rerecordCount = br.ReadUInt32(); movie.HeaderEntries[HeaderKeys.RERECORDS] = rerecordCount.ToString(); // 018: UInt32 savestateOffset @@ -158,12 +173,11 @@ namespace BizHawk.Client.Common // 028: UInt32 cdRomIdOffset // Source format is just the first up-to-8 alphanumeric characters of the CD label, // so not so useful. - br.ReadBytes(20); info.controllerDataOffset = br.ReadUInt32(); - UInt32 authorNameLength = br.ReadUInt32(); + uint authorNameLength = br.ReadUInt32(); char[] authorName = br.ReadChars((int)authorNameLength); movie.HeaderEntries[HeaderKeys.AUTHOR] = new string(authorName); @@ -172,21 +186,24 @@ namespace BizHawk.Client.Common return info; } - protected void parseBinaryInputLog(BinaryReader br, Bk2Movie movie, MiscHeaderInfo info) + protected void ParseBinaryInputLog(BinaryReader br, Bk2Movie movie, MiscHeaderInfo info) { Octoshock.SyncSettings settings = new Octoshock.SyncSettings(); SimpleController controllers = new SimpleController(); - settings.FIOConfig.Devices8 = - new[] { - info.player1Type, - OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None, - info.player2Type, - OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None - }; + settings.FIOConfig.Devices8 = new[] + { + info.player1Type, + OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None, + info.player2Type, + OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None + }; controllers.Definition = Octoshock.CreateControllerDefinition(settings); - string[] buttons = { "Select", "L3", "R3", "Start", "Up", "Right", "Down", "Left", - "L2", "R2", "L1", "R1", "Triangle", "Circle", "Cross", "Square"}; + string[] buttons = + { + "Select", "L3", "R3", "Start", "Up", "Right", "Down", "Left", + "L2", "R2", "L1", "R1", "Triangle", "Circle", "Cross", "Square" + }; bool isCdTrayOpen = false; int cdNumber = 1; @@ -195,7 +212,7 @@ namespace BizHawk.Client.Common { if (info.player1Type != OctoshockDll.ePeripheralType.None) { - UInt16 controllerState = br.ReadUInt16(); + ushort controllerState = br.ReadUInt16(); // As L3 and R3 don't exist on a standard gamepad, handle them separately later. Unfortunately // due to the layout, we handle select separately too first. @@ -203,7 +220,7 @@ namespace BizHawk.Client.Common for (int button = 3; button < buttons.Length; button++) { - controllers["P1 " + buttons[button]] = (((controllerState >> button) & 0x1) != 0); + controllers["P1 " + buttons[button]] = ((controllerState >> button) & 0x1) != 0; if (((controllerState >> button) & 0x1) != 0 && button > 15) { continue; @@ -225,10 +242,10 @@ namespace BizHawk.Client.Common if (info.player2Type != OctoshockDll.ePeripheralType.None) { - UInt16 controllerState = br.ReadUInt16(); + ushort controllerState = br.ReadUInt16(); for (int button = 0; button < buttons.Length; button++) { - controllers["P2 " + buttons[button]] = (((controllerState >> button) & 0x1) != 0); + controllers["P2 " + buttons[button]] = ((controllerState >> button) & 0x1) != 0; if (((controllerState >> button) & 0x1) != 0 && button > 15) { continue; @@ -279,21 +296,24 @@ namespace BizHawk.Client.Common } } - protected void parseTextInputLog(BinaryReader br, Bk2Movie movie, MiscHeaderInfo info) + protected void ParseTextInputLog(BinaryReader br, Bk2Movie movie, MiscHeaderInfo info) { Octoshock.SyncSettings settings = new Octoshock.SyncSettings(); SimpleController controllers = new SimpleController(); - settings.FIOConfig.Devices8 = - new[] { - info.player1Type, - OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None, - info.player2Type, - OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None - }; + settings.FIOConfig.Devices8 = new[] + { + info.player1Type, + OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None, + info.player2Type, + OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None + }; controllers.Definition = Octoshock.CreateControllerDefinition(settings); - string[] buttons = { "Select", "L3", "R3", "Start", "Up", "Right", "Down", "Left", - "L2", "R2", "L1", "R1", "Triangle", "Circle", "Cross", "Square"}; + string[] buttons = + { + "Select", "L3", "R3", "Start", "Up", "Right", "Down", "Left", + "L2", "R2", "L1", "R1", "Triangle", "Circle", "Cross", "Square" + }; bool isCdTrayOpen = false; int cdNumber = 1; diff --git a/BizHawk.Client.Common/movie/import/PXMImport.cs b/BizHawk.Client.Common/movie/import/PXMImport.cs index a4ef2ebdd3..8c3fee251b 100644 --- a/BizHawk.Client.Common/movie/import/PXMImport.cs +++ b/BizHawk.Client.Common/movie/import/PXMImport.cs @@ -2,7 +2,6 @@ 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 // base class methods via a subclass. @@ -10,12 +9,11 @@ namespace BizHawk.Client.Common.movie.import // However, the magic number/file signature is slightly different, requiring some // refactoring to avoid PXM-specific code in the PJMImport class. [ImportExtension(".pxm")] - class PXMImport : PJMImport + public class PxmImport : PjmImport { protected override void RunImport() { Bk2Movie movie = Result.Movie; - MiscHeaderInfo info; movie.HeaderEntries[HeaderKeys.PLATFORM] = "PSX"; @@ -23,17 +21,17 @@ namespace BizHawk.Client.Common.movie.import { using (var br = new BinaryReader(fs)) { - info = parseHeader(movie, "PXM ", br); + var info = ParseHeader(movie, "PXM ", br); fs.Seek(info.controllerDataOffset, SeekOrigin.Begin); if (info.binaryFormat) { - parseBinaryInputLog(br, movie, info); + ParseBinaryInputLog(br, movie, info); } else { - parseTextInputLog(br, movie, info); + ParseTextInputLog(br, movie, info); } } } diff --git a/BizHawk.Client.Common/movie/interfaces/IMovieController.cs b/BizHawk.Client.Common/movie/interfaces/IMovieController.cs index efaa2f45cb..af9a76ab05 100644 --- a/BizHawk.Client.Common/movie/interfaces/IMovieController.cs +++ b/BizHawk.Client.Common/movie/interfaces/IMovieController.cs @@ -2,7 +2,7 @@ namespace BizHawk.Client.Common { - public interface IMovieController: IController + public interface IMovieController : IController { new ControllerDefinition Definition { get; set; } diff --git a/BizHawk.Client.Common/movie/tasproj/TasBranch.cs b/BizHawk.Client.Common/movie/tasproj/TasBranch.cs index ff89183660..399e9a4e4e 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasBranch.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasBranch.cs @@ -87,7 +87,7 @@ namespace BizHawk.Client.Common b.LagLog.Save(bw); }); - bs.PutLump(nmarkers, delegate (TextWriter tw) + bs.PutLump(nmarkers, delegate(TextWriter tw) { tw.WriteLine(b.Markers.ToString()); }); @@ -181,7 +181,7 @@ namespace BizHawk.Client.Common }); b.Markers = new TasMovieMarkerList(movie); - bl.GetLump(nmarkers, false, delegate (TextReader tr) + bl.GetLump(nmarkers, false, delegate(TextReader tr) { string line; while ((line = tr.ReadLine()) != null) diff --git a/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs b/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs index 5e8b317d59..e070b8904b 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs @@ -118,8 +118,8 @@ namespace BizHawk.Client.Common { LagLog.Clear(); WasLag.Clear(); - //if (br.BaseStream.Length > 0) - //{ BaseStream.Length does not return the expected value. + ////if (br.BaseStream.Length > 0) + ////{ BaseStream.Length does not return the expected value. int formatVersion = br.ReadByte(); if (formatVersion == 0) { @@ -141,10 +141,13 @@ namespace BizHawk.Client.Common LagLog.Add(br.ReadBoolean()); WasLag.Add(br.ReadBoolean()); } + for (int i = length; i < lenWas; i++) + { WasLag.Add(br.ReadBoolean()); + } } - //} + ////} } public bool? History(int frame) @@ -152,7 +155,9 @@ namespace BizHawk.Client.Common if (frame < WasLag.Count) { if (frame < 0) + { return null; + } return WasLag[frame]; } @@ -165,18 +170,21 @@ namespace BizHawk.Client.Common get { if (LagLog.Count == 0) + { return 0; + } + return LagLog.Count - 1; } } public TasLagLog Clone() { - var log = new TasLagLog(); - log.LagLog = LagLog.ToList(); - log.WasLag = WasLag.ToList(); - - return log; + return new TasLagLog + { + LagLog = LagLog.ToList(), + WasLag = WasLag.ToList() + }; } public void FromLagLog(TasLagLog log) diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs index 21f2cc62a6..1893b2df18 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; -using System.IO; +using System.Collections.Generic; using System.Linq; -using BizHawk.Common; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; @@ -16,7 +13,9 @@ namespace BizHawk.Client.Common public override void RecordFrame(int frame, IController source) { if (frame != 0) - ChangeLog.AddGeneralUndo(frame -1, frame -1, "Record Frame: " + frame); + { + ChangeLog.AddGeneralUndo(frame - 1, frame - 1, "Record Frame: " + frame); + } base.RecordFrame(frame, source); @@ -24,10 +23,14 @@ namespace BizHawk.Client.Common LagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame; if (IsRecording) + { StateManager.Invalidate(frame + 1); + } if (frame != 0) + { ChangeLog.SetGeneralRedo(); + } } public override void Truncate(int frame) @@ -48,7 +51,9 @@ namespace BizHawk.Client.Common ChangeLog.SetGeneralRedo(); if (endBatch) + { ChangeLog.EndBatch(); + } } public override void PokeFrame(int frame, IController source) @@ -98,11 +103,16 @@ namespace BizHawk.Client.Common { TasMovieMarker m = Markers.ElementAt(i); if (m.Frame == frame) + { Markers.Remove(m); + } else + { Markers.Move(m.Frame, m.Frame - 1); + } } } + ChangeLog.IsRecording = wasRecording; } @@ -111,7 +121,9 @@ namespace BizHawk.Client.Common ChangeLog.SetGeneralRedo(); if (endBatch) + { ChangeLog.EndBatch(); + } } // TODO: consider making this IEnumerable instead of forcing the collection to be an array @@ -127,7 +139,10 @@ namespace BizHawk.Client.Common foreach (var frame in frames.OrderByDescending(x => x)) // Removin them in reverse order allows us to remove by index; { if (frame < _log.Count) + { _log.RemoveAt(frame); + } + if (BindMarkersToInput) // TODO: This is slow, is there a better way to do it? { bool wasRecording = ChangeLog.IsRecording; @@ -139,9 +154,13 @@ namespace BizHawk.Client.Common { TasMovieMarker m = Markers.ElementAt(i); if (m.Frame == frame) + { Markers.Remove(m); + } else + { Markers.Move(m.Frame, m.Frame - 1); + } } } ChangeLog.IsRecording = wasRecording; @@ -153,7 +172,9 @@ namespace BizHawk.Client.Common ChangeLog.SetGeneralRedo(); if (endBatch) + { ChangeLog.EndBatch(); + } } } @@ -163,7 +184,9 @@ namespace BizHawk.Client.Common ChangeLog.AddGeneralUndo(removeStart, InputLogLength - 1); for (int i = removeUpTo - 1; i >= removeStart; i--) + { _log.RemoveAt(i); + } if (BindMarkersToInput) { @@ -176,11 +199,16 @@ namespace BizHawk.Client.Common { TasMovieMarker m = Markers.ElementAt(i); if (m.Frame < removeUpTo) + { Markers.Remove(m); + } else + { Markers.Move(m.Frame, m.Frame - (removeUpTo - removeStart), fromHistory); + } } } + ChangeLog.IsRecording = wasRecording; } @@ -189,7 +217,9 @@ namespace BizHawk.Client.Common ChangeLog.SetGeneralRedo(); if (endBatch) + { ChangeLog.EndBatch(); + } } public void InsertInput(int frame, string inputState) @@ -214,12 +244,15 @@ namespace BizHawk.Client.Common Markers.Move(m.Frame, m.Frame + 1); } } + ChangeLog.IsRecording = wasRecording; } ChangeLog.SetGeneralRedo(); if (endBatch) + { ChangeLog.EndBatch(); + } } public void InsertInput(int frame, IEnumerable inputLog) @@ -244,12 +277,15 @@ namespace BizHawk.Client.Common Markers.Move(m.Frame, m.Frame + inputLog.Count()); } } + ChangeLog.IsRecording = wasRecording; } ChangeLog.SetGeneralRedo(); if (endBatch) + { ChangeLog.EndBatch(); + } } public void InsertInput(int frame, IEnumerable inputStates) @@ -275,7 +311,9 @@ namespace BizHawk.Client.Common var states = inputStates.ToList(); if (_log.Count < states.Count + frame) + { ExtendMovieForEdit(states.Count + frame - _log.Count); + } ChangeLog.AddGeneralUndo(frame, frame + inputStates.Count() - 1, "Copy Over Input: " + frame); @@ -303,10 +341,14 @@ namespace BizHawk.Client.Common lg.SetSource(Global.MovieSession.MovieControllerInstance()); if (frame > _log.Count()) + { frame = _log.Count(); + } for (int i = 0; i < count; i++) + { _log.Insert(frame, lg.EmptyEntry); + } if (BindMarkersToInput) { @@ -321,6 +363,7 @@ namespace BizHawk.Client.Common Markers.Move(m.Frame, m.Frame + count, fromHistory); } } + ChangeLog.IsRecording = wasRecording; } @@ -330,10 +373,14 @@ namespace BizHawk.Client.Common ChangeLog.SetGeneralRedo(); if (endBatch) + { ChangeLog.EndBatch(); + } if (Global.Emulator.Frame < _log.Count) // Don't stay in recording mode? Fixes TAStudio recording after paint inserting. + { this.SwitchToPlay(); + } } private void ExtendMovieForEdit(int numFrames) @@ -348,22 +395,30 @@ namespace BizHawk.Client.Common lg.SetSource(Global.MovieOutputHardpoint); // account for autohold. needs autohold pattern to be already recorded in the current frame for (int i = 0; i < numFrames; i++) + { _log.Add(lg.GenerateLogEntry()); + } Changes = true; ChangeLog.SetGeneralRedo(); if (endBatch) + { ChangeLog.EndBatch(); + } if (Global.Emulator.Frame < _log.Count) // Don't stay in recording mode? Fixes TAStudio recording after paint inserting. + { this.SwitchToPlay(); + } } public void ToggleBoolState(int frame, string buttonName) { if (frame >= _log.Count) // Insert blank frames up to this point + { ExtendMovieForEdit(frame - _log.Count + 1); + } var adapter = GetInputState(frame) as Bk2ControllerAdapter; adapter[buttonName] = !adapter.IsPressed(buttonName); @@ -380,7 +435,9 @@ namespace BizHawk.Client.Common public void SetBoolState(int frame, string buttonName, bool val) { if (frame >= _log.Count) // Insert blank frames up to this point + { ExtendMovieForEdit(frame - _log.Count + 1); + } var adapter = GetInputState(frame) as Bk2ControllerAdapter; var old = adapter.IsPressed(buttonName); @@ -401,7 +458,9 @@ namespace BizHawk.Client.Common public void SetBoolStates(int frame, int count, string buttonName, bool val) { if (frame + count >= _log.Count) // Insert blank frames up to this point + { ExtendMovieForEdit(frame - _log.Count + 1); + } ChangeLog.AddGeneralUndo(frame, frame + count - 1, "Set " + buttonName + "(" + (val ? "On" : "Off") + "): " + frame + "-" + (frame + count - 1)); @@ -417,7 +476,9 @@ namespace BizHawk.Client.Common _log[frame + i] = lg.GenerateLogEntry(); if (changed == -1 && old != val) + { changed = frame + i; + } } if (changed != -1) @@ -432,7 +493,9 @@ namespace BizHawk.Client.Common public void SetFloatState(int frame, string buttonName, float val) { if (frame >= _log.Count) // Insert blank frames up to this point + { ExtendMovieForEdit(frame - _log.Count + 1); + } var adapter = GetInputState(frame) as Bk2ControllerAdapter; var old = adapter.GetFloat(buttonName); @@ -453,7 +516,9 @@ namespace BizHawk.Client.Common public void SetFloatStates(int frame, int count, string buttonName, float val) { if (frame + count >= _log.Count) // Insert blank frames up to this point + { ExtendMovieForEdit(frame - _log.Count + 1); + } ChangeLog.AddGeneralUndo(frame, frame + count - 1, "Set " + buttonName + "(" + val + "): " + frame + "-" + (frame + count - 1)); @@ -481,7 +546,8 @@ namespace BizHawk.Client.Common ChangeLog.SetGeneralRedo(); } - #region "LagLog" + #region LagLog + public void RemoveLagHistory(int frame) { LagLog.RemoveHistoryAt(frame); @@ -495,6 +561,7 @@ namespace BizHawk.Client.Common { 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 d67c90fdde..29fa42bc9d 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs @@ -1,9 +1,6 @@ -using System.Collections.Generic; -using System.Globalization; -using System.IO; +using System; +using System.Collections.Generic; using System.Linq; -using System.Text; -using System; namespace BizHawk.Client.Common { diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs index ef79cf5af3..c0d75b5846 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs @@ -18,7 +18,7 @@ namespace BizHawk.Client.Common public const string DefaultProjectName = "default"; public BackgroundWorker _progressReportWorker = null; public bool LastPositionStable = true; - public string NewBranchText = ""; + public string NewBranchText = string.Empty; 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; @@ -36,13 +36,20 @@ namespace BizHawk.Client.Common public int LastValidFrame { get { return LagLog.LastValidFrame; } } public override string PreferredExtension { get { return Extension; } } public TasStateManager TasStateManager { get { return StateManager; } } - public TasMovieRecord this[int index] { get { return new TasMovieRecord { - // State = StateManager[index], - HasState = StateManager.HasState(index), - LogEntry = GetInputLogEntry(index), - Lagged = LagLog[index + 1], - WasLagged = LagLog.History(index + 1) - }; } } + public TasMovieRecord this[int index] + { + get + { + return new TasMovieRecord + { + // State = StateManager[index], + HasState = StateManager.HasState(index), + LogEntry = GetInputLogEntry(index), + Lagged = LagLog[index + 1], + WasLagged = LagLog.History(index + 1) + }; + } + } public TasMovie(string path, bool startsFromSavestate = false, BackgroundWorker progressReportWorker = null) : base(path) @@ -347,7 +354,7 @@ namespace BizHawk.Client.Common _log.Clear(); _log.AddRange(newLog); } - else //Multitrack mode + else // Multitrack mode { // TODO: consider TimelineBranchFrame here, my thinking is that there's never a scenario to invalidate state/lag data during multitrack var i = 0; @@ -499,7 +506,7 @@ namespace BizHawk.Client.Common if (_log != null) _log.Dispose(); _log = branch.InputLog.Clone(); - //_changes = true; + ////_changes = true; // if there are branch states, they will be loaded anyway // but if there's none, or only *after* divergent point, don't invalidate the entire movie anymore @@ -514,7 +521,7 @@ namespace BizHawk.Client.Common StateManager.LoadBranch(Branches.IndexOf(branch)); StateManager.SetState(branch.Frame, branch.CoreData); - //ChangeLog = branch.ChangeLog; + ////ChangeLog = branch.ChangeLog; if (BindMarkersToInput) // pretty critical not to erase them Markers = branch.Markers; diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs b/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs index d74de738ce..76edfb7755 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs @@ -93,7 +93,7 @@ namespace BizHawk.Client.Common { if (CollectionChanged != null) { - //TODO Allow different types + // TODO Allow different types CollectionChanged.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } } diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovieRecord.cs b/BizHawk.Client.Common/movie/tasproj/TasMovieRecord.cs index 8aeb697ea6..0351032521 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovieRecord.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovieRecord.cs @@ -1,18 +1,11 @@ -using System.Collections.Generic; -using System.Linq; - -namespace BizHawk.Client.Common +namespace BizHawk.Client.Common { public class TasMovieRecord { - // public KeyValuePair State { get; set; } public bool? Lagged { get; set; } public bool? WasLagged { get; set; } public string LogEntry { get; set; } public bool HasState { get; set; } - //{ - // get { return State.Value.Any(); } - //} } } diff --git a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs index f29d2cc120..2aa9268846 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs @@ -100,10 +100,9 @@ namespace BizHawk.Client.Common public void Dispose() { + // States and BranchStates don't need cleaning because they would only contain an ndbdatabase entry which was demolished by the below if (ndbdatabase != null) ndbdatabase.Dispose(); - - //States and BranchStates don't need cleaning because they would only contain an ndbdatabase entry which was demolished by the above } /// @@ -395,7 +394,7 @@ namespace BizHawk.Client.Common if (BranchStates[frame][branch].IsOnDisk) BranchStates[frame][branch].Dispose(); else - //Used -= (ulong)BranchStates[frame][branch].Length; + ////Used -= (ulong)BranchStates[frame][branch].Length; BranchStates[frame].RemoveAt(BranchStates[frame].IndexOfKey(branch)); if (BranchStates[frame].Count == 0) @@ -598,7 +597,7 @@ namespace BizHawk.Client.Common bw.Write(kvp.Key); bw.Write(kvp.Value.Length); bw.Write(kvp.Value.State); - //_movie.ReportProgress(100d / States.Count * i); + ////_movie.ReportProgress(100d / States.Count * i); } } @@ -613,11 +612,12 @@ namespace BizHawk.Client.Common int frame = br.ReadInt32(); int len = br.ReadInt32(); byte[] data = br.ReadBytes(len); + // whether we should allow state removal check here is an interesting question // nothing was edited yet, so it might make sense to show the project untouched first SetState(frame, data); - //States.Add(frame, data); - //Used += len; + ////States.Add(frame, data); + ////Used += len; } } catch (EndOfStreamException) { } @@ -673,11 +673,10 @@ namespace BizHawk.Client.Common // Map: // 4 bytes - total savestate count - //[Foreach state] + // [Foreach state] // 4 bytes - frame // 4 bytes - length of savestate // 0 - n savestate - private ulong _used; private ulong Used { @@ -907,7 +906,7 @@ namespace BizHawk.Client.Common int branchHash = _movie.BranchHashByIndex(index); - //Invalidate(0); // Not a good way of doing it? + ////Invalidate(0); // Not a good way of doing it? foreach (KeyValuePair> kvp in BranchStates) { diff --git a/BizHawk.Client.Common/rewind/Rewinder.cs b/BizHawk.Client.Common/rewind/Rewinder.cs index 906a012095..9885a0c3ea 100644 --- a/BizHawk.Client.Common/rewind/Rewinder.cs +++ b/BizHawk.Client.Common/rewind/Rewinder.cs @@ -212,16 +212,15 @@ namespace BizHawk.Client.Common // state. That's why the data portion of the delta comes from the previous state, // and also why the previous state is used if we have to bail out and capture the // full state instead. - if (currentState.Length != _lastState.Length) { // If the state sizes mismatch, capture a full state rather than trying to do anything clever goto CaptureFullState; } - if(currentState.Length == 0) + if (currentState.Length == 0) { - //handle empty states as a "full" (empty) state + // handle empty states as a "full" (empty) state goto CaptureFullState; } diff --git a/BizHawk.Client.Common/rewind/StreamBlobDatabase.cs b/BizHawk.Client.Common/rewind/StreamBlobDatabase.cs index 6ed4d57415..d9ad3e5926 100644 --- a/BizHawk.Client.Common/rewind/StreamBlobDatabase.cs +++ b/BizHawk.Client.Common/rewind/StreamBlobDatabase.cs @@ -152,7 +152,7 @@ namespace BizHawk.Client.Common CLEANUP: // while the head impinges on tail items, discard them - for (; ; ) + for (;;) { if (_mTail == null) { @@ -172,9 +172,9 @@ namespace BizHawk.Client.Common } } - //one final check: in case we clobbered from the tail to make room and ended up after the capacity, we need to try again - //this has to be done this way, because we need one cleanup pass to purge all the tail items before the capacity; - //and then again to purge tail items impinged by this new item at the beginning + // one final check: in case we clobbered from the tail to make room and ended up after the capacity, we need to try again + // this has to be done this way, because we need one cleanup pass to purge all the tail items before the capacity; + // and then again to purge tail items impinged by this new item at the beginning if (_mHead.Value.EndExclusive > _mCapacity) { var temp = _mHead.Previous; @@ -248,7 +248,7 @@ namespace BizHawk.Client.Common int ts = _mTail.Value.Timestamp; LinkedListNode curr = _mTail; - for (; ; ) + for (;;) { if (curr == null) { @@ -313,7 +313,7 @@ namespace BizHawk.Client.Common Random r = new Random(0); byte[] temp = new byte[1024]; int trials = 0; - for (; ; ) + for (;;) { int len = r.Next(1024) + 1; if (r.Next(100) == 0) diff --git a/BizHawk.Client.Common/tools/Cheat.cs b/BizHawk.Client.Common/tools/Cheat.cs index 8b4c8c900d..469bdaf616 100644 --- a/BizHawk.Client.Common/tools/Cheat.cs +++ b/BizHawk.Client.Common/tools/Cheat.cs @@ -13,7 +13,7 @@ namespace BizHawk.Client.Common LESS_THAN, LESS_THAN_OR_EQUAL, NOT_EQUAL - }; + } private readonly Watch _watch; private int? _compare; diff --git a/BizHawk.Client.Common/tools/CheatList.cs b/BizHawk.Client.Common/tools/CheatList.cs index 0ae2df92df..bfcad4710e 100644 --- a/BizHawk.Client.Common/tools/CheatList.cs +++ b/BizHawk.Client.Common/tools/CheatList.cs @@ -479,7 +479,7 @@ namespace BizHawk.Client.Common // For backwards compatibility, don't assume these values exist if (vals.Length > 9) { - if(!Enum.TryParse(vals[9], out comparisonType)) + if (!Enum.TryParse(vals[9], out comparisonType)) { continue; // Not sure if this is the best answer, could just resort to == } diff --git a/BizHawk.Client.Common/tools/RamSearchEngine.cs b/BizHawk.Client.Common/tools/RamSearchEngine.cs index a624d48930..a7d52b25a7 100644 --- a/BizHawk.Client.Common/tools/RamSearchEngine.cs +++ b/BizHawk.Client.Common/tools/RamSearchEngine.cs @@ -10,10 +10,17 @@ namespace BizHawk.Client.Common { public class RamSearchEngine { - public enum ComparisonOperator { Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, NotEqual, DifferentBy } - public enum Compare { Previous, SpecificValue, SpecificAddress, Changes, Difference } + public enum ComparisonOperator + { + Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, NotEqual, DifferentBy + } - private int? _differentBy; //zero 07-sep-2014 - this isnt ideal. but dont bother changing it (to a long, for instance) until it can support floats. maybe store it as a double here. + public enum Compare + { + Previous, SpecificValue, SpecificAddress, Changes, Difference + } + + private int? _differentBy; // zero 07-sep-2014 - this isnt ideal. but dont bother changing it (to a long, for instance) until it can support floats. maybe store it as a double here. private Compare _compareTo = Compare.Previous; private long? _compareValue; @@ -144,8 +151,7 @@ namespace BizHawk.Client.Common string.Empty, 0, _watchList[index].Previous, - (_watchList[index] as IMiniWatchDetails).ChangeCount - ); + (_watchList[index] as IMiniWatchDetails).ChangeCount); } else { @@ -158,8 +164,7 @@ namespace BizHawk.Client.Common string.Empty, 0, _watchList[index].Previous, - 0 - ); + 0); } } } @@ -673,16 +678,12 @@ namespace BizHawk.Client.Common => (SignExtendAsNeeded(GetValue(x.Address)) + _differentBy.Value == _compareValue.Value) || (SignExtendAsNeeded(GetValue(x.Address)) - _differentBy.Value == _compareValue.Value)); } - else - { - throw new InvalidOperationException(); - } + + throw new InvalidOperationException(); } } - else - { - throw new InvalidOperationException(); - } + + throw new InvalidOperationException(); } private IEnumerable CompareSpecificAddress(IEnumerable watchList) @@ -709,16 +710,12 @@ namespace BizHawk.Client.Common { return watchList.Where(x => (x.Address + _differentBy.Value == _compareValue.Value) || (x.Address - _differentBy.Value == _compareValue.Value)); } - else - { - throw new InvalidOperationException(); - } + + throw new InvalidOperationException(); } } - else - { - throw new InvalidOperationException(); - } + + throw new InvalidOperationException(); } private IEnumerable CompareChanges(IEnumerable watchList) @@ -766,16 +763,12 @@ namespace BizHawk.Client.Common .Where(x => (x.ChangeCount + _differentBy.Value == _compareValue.Value) || (x.ChangeCount - _differentBy.Value == _compareValue.Value)) .Cast(); } - else - { - throw new InvalidOperationException(); - } + + throw new InvalidOperationException(); } } - else - { - throw new InvalidCastException(); - } + + throw new InvalidCastException(); } private IEnumerable CompareDifference(IEnumerable watchList) @@ -840,16 +833,12 @@ namespace BizHawk.Client.Common => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous) + _differentBy.Value == _compareValue) || (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous) - _differentBy.Value == _compareValue)); } - else - { - throw new InvalidOperationException(); - } + + throw new InvalidOperationException(); } } - else - { - throw new InvalidCastException(); - } + + throw new InvalidCastException(); } #endregion @@ -975,7 +964,7 @@ namespace BizHawk.Client.Common public sealed class MiniDWordWatch : IMiniWatch { - public long Address { get; private set; } + public long Address { get; } private uint _previous; public MiniDWordWatch(MemoryDomain domain, long addr, bool bigEndian) @@ -994,7 +983,7 @@ namespace BizHawk.Client.Common private sealed class MiniByteWatchDetailed : IMiniWatch, IMiniWatchDetails { - public long Address { get; private set; } + public long Address { get; } private byte _previous; private byte _prevFrame; @@ -1034,7 +1023,10 @@ namespace BizHawk.Client.Common break; case PreviousType.LastChange: if (_prevFrame != value) + { _previous = _prevFrame; + } + break; } @@ -1049,7 +1041,7 @@ namespace BizHawk.Client.Common private sealed class MiniWordWatchDetailed : IMiniWatch, IMiniWatchDetails { - public long Address { get; private set; } + public long Address { get; } private ushort _previous; private ushort _prevFrame; @@ -1105,7 +1097,7 @@ namespace BizHawk.Client.Common public sealed class MiniDWordWatchDetailed : IMiniWatch, IMiniWatchDetails { - public long Address { get; private set; } + public long Address { get; } private uint _previous; private uint _prevFrame; @@ -1122,15 +1114,9 @@ namespace BizHawk.Client.Common _previous = _prevFrame = domain.PeekUint(Address % domain.Size, bigendian); } - public long Previous - { - get { return (int)_previous; } - } + public long Previous => (int)_previous; - public int ChangeCount - { - get { return _changecount; } - } + public int ChangeCount => _changecount; public void Update(PreviousType type, MemoryDomain domain, bool bigendian) { @@ -1150,7 +1136,10 @@ namespace BizHawk.Client.Common break; case PreviousType.LastChange: if (_prevFrame != value) + { _previous = _prevFrame; + } + break; } @@ -1180,7 +1169,10 @@ namespace BizHawk.Client.Common } /*Require restart*/ - public enum SearchMode { Fast, Detailed } + public enum SearchMode + { + Fast, Detailed + } public SearchMode Mode { get; set; } public MemoryDomain Domain { get; set; } diff --git a/BizHawk.Client.Common/tools/Watch/DwordWatch.cs b/BizHawk.Client.Common/tools/Watch/DwordWatch.cs index a6050a0dad..70037d49de 100644 --- a/BizHawk.Client.Common/tools/Watch/DwordWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/DwordWatch.cs @@ -24,7 +24,7 @@ namespace BizHawk.Client.Common #region cTor(s) /// - /// Inialize a new instance of + /// Initialize a new instance of /// /// where you want to track /// The address you want to track @@ -56,7 +56,7 @@ namespace BizHawk.Client.Common #region Methods /// - /// Enumerate wich are valid for a + /// Gets a list of for a /// public static IEnumerable ValidTypes { @@ -75,7 +75,7 @@ namespace BizHawk.Client.Common #region Implements /// - /// Get a list a that can be used for this + /// Get a list of that can be used for a /// /// An enumeration that contains all valid public override IEnumerable AvailableTypes() @@ -96,7 +96,7 @@ namespace BizHawk.Client.Common /// at the current address /// /// Value to set - /// True if value successfully sets; othewise, false + /// True if value successfully sets; otherwise, false public override bool Poke(string value) { try @@ -226,7 +226,7 @@ namespace BizHawk.Client.Common #endregion Implements - //TODO: Implements IFormattable + // TODO: Implements IFormattable public string FormatValue(uint val) { switch (Type) @@ -245,7 +245,7 @@ namespace BizHawk.Client.Common case DisplayType.Float: var bytes = BitConverter.GetBytes(val); var _float = BitConverter.ToSingle(bytes, 0); - //return string.Format("{0:0.######}", _float); + ////return string.Format("{0:0.######}", _float); return _float.ToString(); // adelikat: decided that we like sci notation instead of spooky rounding } } diff --git a/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs b/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs index a7314c7f4c..ecf1b2aec0 100644 --- a/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace BizHawk.Client.Common { @@ -13,16 +12,14 @@ namespace BizHawk.Client.Common /// Initialize a new separator instance /// internal SeparatorWatch() - :base(null, 0, WatchSize.Separator, DisplayType.Separator, true, string.Empty) - { } + : base(null, 0, WatchSize.Separator, DisplayType.Separator, true, string.Empty) + { + } /// /// Gets the separator instance /// - public static SeparatorWatch Instance - { - get { return new SeparatorWatch(); } - } + public static SeparatorWatch Instance => new SeparatorWatch(); /// /// Get the appropriate DisplayType @@ -38,42 +35,27 @@ namespace BizHawk.Client.Common /// /// Ignore that stuff /// - public override int Value - { - get { return 0; } - } + public override int Value => 0; /// /// Ignore that stuff /// - public override int ValueNoFreeze - { - get { return 0; } - } + public override int ValueNoFreeze => 0; /// /// Ignore that stuff /// - public override int Previous - { - get { return 0; } - } + public override int Previous => 0; /// /// Ignore that stuff /// - public override string ValueString - { - get { return string.Empty; } - } + public override string ValueString => string.Empty; /// /// Ignore that stuff /// - public override string PreviousStr - { - get { return string.Empty; } - } + public override string PreviousStr => string.Empty; /// /// TTransform the current instance into a displayable (short representation) string @@ -98,27 +80,25 @@ namespace BizHawk.Client.Common /// public override void ResetPrevious() { - return; } /// /// Ignore that stuff /// - public override string Diff { get { return string.Empty; } } + public override string Diff => string.Empty; /// /// Ignore that stuff /// - public override uint MaxValue + public override uint MaxValue => 0; + + /// + /// Ignore that stuff + /// + public override void Update() { - get { return 0; } } - /// - /// Ignore that stuff - /// - public override void Update() { return; } - #endregion } } diff --git a/BizHawk.Client.Common/tools/Watch/Watch.cs b/BizHawk.Client.Common/tools/Watch/Watch.cs index b40ea178df..560a9febdc 100644 --- a/BizHawk.Client.Common/tools/Watch/Watch.cs +++ b/BizHawk.Client.Common/tools/Watch/Watch.cs @@ -103,7 +103,7 @@ namespace BizHawk.Client.Common /// A brand new public static Watch FromString(string line, IMemoryDomains domains) { - string[] parts = line.Split(new char[] { '\t' }, 6); + string[] parts = line.Split(new[] { '\t' }, 6); if (parts.Length < 6) { @@ -114,24 +114,24 @@ namespace BizHawk.Client.Common return null; } + long address; if (long.TryParse(parts[0], NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address)) { - WatchSize size = Watch.SizeFromChar(parts[1][0]); - DisplayType type = Watch.DisplayTypeFromChar(parts[2][0]); + WatchSize size = SizeFromChar(parts[1][0]); + DisplayType type = DisplayTypeFromChar(parts[2][0]); bool bigEndian = parts[3] == "0" ? false : true; MemoryDomain domain = domains[parts[4]]; string notes = parts[5].Trim(new char[] { '\r', '\n' }); - return Watch.GenerateWatch( + return GenerateWatch( domain, address, size, type, bigEndian, - notes - ); + notes); } else { @@ -346,81 +346,84 @@ namespace BizHawk.Client.Common { if (!bypassFreeze && Global.CheatList.IsActive(_domain, _address)) { - //LIAR logic + // LIAR logic return Global.CheatList.GetByteValue(_domain, _address) ?? 0; } - else + + if (_domain.Size == 0) { - if (_domain.Size == 0) - { - return _domain.PeekByte(_address); - } - else - { - return _domain.PeekByte(_address % _domain.Size); - } + 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 + // LIAR logic return (ushort)(Global.CheatList.GetCheatValue(_domain, _address, WatchSize.Word) ?? 0); - } - else + } + + if (_domain.Size == 0) { - if (_domain.Size == 0) - { - return _domain.PeekUshort(_address, _bigEndian); - } - else - { - return _domain.PeekUshort(_address % _domain.Size, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain - } + 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 + // LIAR logic return (uint)(Global.CheatList.GetCheatValue(_domain, _address, WatchSize.DWord) ?? 0); } - else + + if (_domain.Size == 0) { - if (_domain.Size == 0) - { - return _domain.PeekUint(_address, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain - } - else - { - return _domain.PeekUint(_address % _domain.Size, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain - } + return _domain.PeekUint(_address, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain } + + return _domain.PeekUint(_address % _domain.Size, _bigEndian); // TODO: % size stil lisn'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); + } + else + { + _domain.PokeByte(_address % _domain.Size, val); + } } protected void PokeWord(ushort val) { - if (_domain.Size == 0) + if (_domain.Size == 0) + { _domain.PokeUshort(_address, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain - else _domain.PokeUshort(_address % _domain.Size, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain + } + else + { + _domain.PokeUshort(_address % _domain.Size, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain + } } protected void PokeDWord(uint val) { - if (_domain.Size == 0) + if (_domain.Size == 0) + { _domain.PokeUint(_address, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain - else _domain.PokeUint(_address % _domain.Size, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain + } + else + { + _domain.PokeUint(_address % _domain.Size, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain + } } #endregion Protected @@ -521,14 +524,12 @@ namespace BizHawk.Client.Common return Equals((Watch)obj); } - else if (obj is Cheat) + if (obj is Cheat) { return Equals((Cheat)obj); } - else - { - return base.Equals(obj); - } + + return base.Equals(obj); } /// @@ -557,14 +558,7 @@ namespace BizHawk.Client.Common /// A representation of the current public override string ToString() { - return string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}" - , Domain == null && Address == 0 ? "0" : Address.ToHexString((Domain.Size - 1).NumHexDigits()) - , SizeAsChar - , TypeAsChar - , Convert.ToInt32(BigEndian) - , DomainName - , Notes.Trim('\r', '\n') - ); + return $"{(Domain == null && Address == 0 ? "0" : Address.ToHexString((Domain.Size - 1).NumHexDigits()))}\t{SizeAsChar}\t{TypeAsChar}\t{Convert.ToInt32(BigEndian)}\t{DomainName}\t{Notes.Trim('\r', '\n')}"; } /// @@ -574,7 +568,7 @@ namespace BizHawk.Client.Common /// A well formatted string representation public virtual string ToDisplayString() { - return string.Format("{0}: {1}", Notes, ValueString); + return $"{Notes}: {ValueString}"; } #endregion @@ -634,13 +628,7 @@ namespace BizHawk.Client.Common /// /// Gets the address in the /// - public long Address - { - get - { - return _address; - } - } + public long Address => _address; /// /// Gets the format tha should be used by string.Format() @@ -661,13 +649,7 @@ namespace BizHawk.Client.Common /// /// Gets the address in the formatted as string /// - public string AddressString - { - get - { - return _address.ToString(AddressFormatStr); - } - } + public string AddressString => _address.ToString(AddressFormatStr); /// /// Gets or sets the endianess of current @@ -688,16 +670,10 @@ namespace BizHawk.Client.Common /// /// Gets the number of time tha value of current has changed /// - public int ChangeCount - { - get - { - return _changecount; - } - } + public int ChangeCount => _changecount; /// - /// Gets or set the way current is displayed + /// Gets or sets the way current is displayed /// /// Occurs when a is incompatible with the public DisplayType Type @@ -730,7 +706,7 @@ namespace BizHawk.Client.Common } internal set { - if (value != null &&_domain.Name == value.Name) + if (value != null && _domain.Name == value.Name) { _domain = value; } @@ -811,7 +787,7 @@ namespace BizHawk.Client.Common #endregion - //TODO: Replace all the following stuff by implementing ISerializable + // TODO: Replace all the following stuff by implementing ISerializable public static string DisplayTypeToString(DisplayType type) { switch (type) diff --git a/BizHawk.Client.Common/tools/Watch/WatchList/WatchChangeCountComparer.cs b/BizHawk.Client.Common/tools/Watch/WatchList/WatchChangeCountComparer.cs index ceb96266d4..bbe4852692 100644 --- a/BizHawk.Client.Common/tools/Watch/WatchList/WatchChangeCountComparer.cs +++ b/BizHawk.Client.Common/tools/Watch/WatchList/WatchChangeCountComparer.cs @@ -13,13 +13,12 @@ namespace BizHawk.Client.Common /// based on the number of changes /// private sealed class WatchChangeCountComparer - :WatchEqualityComparer - ,IComparer + : WatchEqualityComparer, IComparer { /// /// Compares two between them - /// and determines wich one comes first. - /// If they are equals, comapraison will done one the address and next on size + /// and determines which one comes first. + /// If they are equals, comparison will done one the address and next on size /// /// First /// Second @@ -30,21 +29,18 @@ namespace BizHawk.Client.Common { return 0; } - else if (x.ChangeCount.Equals(y.ChangeCount)) + + if (x.ChangeCount.Equals(y.ChangeCount)) { if (x.Address.Equals(y.Address)) { return x.Size.CompareTo(y.Size); } - else - { - return x.Address.CompareTo(y.Address); - } - } - else - { - return x.ChangeCount.CompareTo(y.ChangeCount); + + return x.Address.CompareTo(y.Address); } + + return x.ChangeCount.CompareTo(y.ChangeCount); } } } diff --git a/BizHawk.Client.Common/tools/Watch/WatchList/WatchDomainComparer.cs b/BizHawk.Client.Common/tools/Watch/WatchList/WatchDomainComparer.cs index 4293797f48..c32d606dfc 100644 --- a/BizHawk.Client.Common/tools/Watch/WatchList/WatchDomainComparer.cs +++ b/BizHawk.Client.Common/tools/Watch/WatchList/WatchDomainComparer.cs @@ -22,7 +22,7 @@ namespace BizHawk.Client.Common /// If they are equals, comapraison will done one the address and next on size /// /// First - ///Second + /// Second /// 0 for equality, 1 if x comes first; -1 if y comes first public int Compare(Watch x, Watch y) { diff --git a/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs b/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs index e074022cea..29475da630 100644 --- a/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs +++ b/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs @@ -328,13 +328,15 @@ namespace BizHawk.Client.Common Parallel.ForEach(_watchList, watch => { if (watch.IsSeparator) + { return; + } + watch.Domain = core[watch.Domain.Name]; watch.ResetPrevious(); watch.Update(); watch.ClearChangeCount(); - } - ); + }); } /// diff --git a/BizHawk.Client.Common/tools/Watch/WatchList/WatchNoteComparer.cs b/BizHawk.Client.Common/tools/Watch/WatchList/WatchNoteComparer.cs index 8c8caa5432..14eb8a53b1 100644 --- a/BizHawk.Client.Common/tools/Watch/WatchList/WatchNoteComparer.cs +++ b/BizHawk.Client.Common/tools/Watch/WatchList/WatchNoteComparer.cs @@ -13,7 +13,7 @@ namespace BizHawk.Client.Common /// based on their note /// private sealed class WatchNoteComparer - :WatchEqualityComparer, + : WatchEqualityComparer, IComparer { /// diff --git a/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueComparer.cs b/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueComparer.cs index c0ec61d2d9..e35d13a4b1 100644 --- a/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueComparer.cs +++ b/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueComparer.cs @@ -22,7 +22,7 @@ namespace BizHawk.Client.Common /// If they are equals, comapraison will done one the address and next on size /// /// First - ///Second + /// Second /// 0 for equality, 1 if x comes first; -1 if y comes first public int Compare(Watch x, Watch y) { diff --git a/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueDifferenceComparer.cs b/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueDifferenceComparer.cs index 662b7886fc..9c771888b3 100644 --- a/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueDifferenceComparer.cs +++ b/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueDifferenceComparer.cs @@ -9,18 +9,17 @@ namespace BizHawk.Client.Common public sealed partial class WatchList { /// - /// Netsed private class that define how to compare two - /// based on the diffence between current and previous value + /// Nested private class that define how to compare two + /// based on the difference between current and previous value /// private sealed class WatchValueDifferenceComparer - : WatchEqualityComparer - , IComparer + : WatchEqualityComparer, IComparer { /// /// Compares two between them - /// and determines wich one comes first. - /// If they are equals, comapraison will done one the address and next on size + /// and determines which one comes first. + /// If they are equals, comparison will done one the address and next on size /// /// First /// Second @@ -31,21 +30,18 @@ namespace BizHawk.Client.Common { return 0; } - else if (x.Diff.Equals(y.Diff)) + + if (x.Diff.Equals(y.Diff)) { if (x.Address.Equals(y.Address)) { return x.Size.CompareTo(y.Size); } - else - { - return x.Address.CompareTo(y.Address); - } - } - else - { - return x.Diff.CompareTo(y.Diff); + + return x.Address.CompareTo(y.Address); } + + return x.Diff.CompareTo(y.Diff); } } } diff --git a/BizHawk.Client.Common/tools/Watch/WordWatch.cs b/BizHawk.Client.Common/tools/Watch/WordWatch.cs index 8d8e06f8f9..9376ec25ca 100644 --- a/BizHawk.Client.Common/tools/Watch/WordWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/WordWatch.cs @@ -212,7 +212,7 @@ namespace BizHawk.Client.Common #endregion Implements - //TODO: Implements IFormattable + // TODO: Implements IFormattable public string FormatValue(ushort val) { switch (Type) diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index 41a4c9f0a7..7cafd6a57d 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -1,4 +1,7 @@  + False + True + ExplicitlyExcluded DO_NOT_SHOW DO_NOT_SHOW DO_NOT_SHOW @@ -45,6 +48,7 @@ NTSC OBJ OR + OSD PAL PC PCECD @@ -59,5 +63,6 @@ TI TIA VBA + ROM <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /> \ No newline at end of file