misc Client.Common code cleanups

This commit is contained in:
adelikat 2017-05-09 13:19:55 -05:00
parent a996453fc0
commit e0985465b6
64 changed files with 1216 additions and 1264 deletions

View File

@ -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)
{

View File

@ -160,7 +160,7 @@ namespace BizHawk.Client.Common
public void ApplyAxisConstraints(string constraintClass)
{
_type.ApplyAxisConstraints(constraintClass,_floatButtons);
_type.ApplyAxisConstraints(constraintClass, _floatButtons);
}
/// <summary>

View File

@ -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 };

View File

@ -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":

View File

@ -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<Octoshock>(), GetCoreSyncSettings<Octoshock>());
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;
}

View File

@ -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)

View File

@ -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<string, string> PreferredPlatformsForExtensions = new Dictionary<string, string>
{
{ ".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;
/// <summary>
@ -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
{
/// <summary>the physical stick that we're bound to</summary>
public string Value;
/// <summary>sensitivity and flip</summary>
public float Mult;
/// <summary>portion of axis to ignore</summary>
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;
}
}

View File

@ -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 |

View File

@ -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)

View File

@ -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))

View File

@ -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();

View File

@ -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();

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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();

View File

@ -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();

View File

@ -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)

View File

@ -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();

View File

@ -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++)

View File

@ -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);

View File

@ -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])

View File

@ -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";

View File

@ -46,7 +46,7 @@ namespace BizHawk.Client.Common
}
/// <summary>
/// Returns a list of extensions for all IMovie implementations
/// Gets a list of extensions for all <seealso cref="IMovie"/> implementations
/// </summary>
public static IEnumerable<string> 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
/// </summary>
public static IMovie DefaultInstance
{
get
{
return new Bk2Movie();
}
}
public static IMovie DefaultInstance => new Bk2Movie();
}
}

View File

@ -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!

View File

@ -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; }
/// <summary>
/// A user friendly multi-track status
/// Gets a user friendly multi-track status
/// </summary>
public string Status
{

View File

@ -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<string, double> _rates = new Dictionary<string, double>
{
@ -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

View File

@ -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();

View File

@ -14,8 +14,7 @@ namespace BizHawk.Client.Common
private readonly WorkingDictionary<string, float> MyFloatControls = new WorkingDictionary<string, float>();
public Bk2ControllerAdapter()
{
{
}
public Bk2ControllerAdapter(string key)

View File

@ -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<string, char>
{
{ "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", ',' },

View File

@ -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;

View File

@ -153,7 +153,7 @@ namespace BizHawk.Client.Common
{
foreach (var item in collection)
{
Insert(index++,item);
Insert(index++, item);
}
}

View File

@ -16,166 +16,166 @@ namespace BizHawk.Client.Common
{
"Lynx Controller", new Dictionary<string, string>
{
{"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<string, string>
{
{"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<string, string>
{
{"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<string, string>
{
{"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<string, string>
{
{"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<string, string>
{
{"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<string, string>
{
{"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<string, string>
{
{"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<string, string>
{
{"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<string, string>
{
{"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<string,string>
{
{"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Button", "B"}
"Atari 2600 Basic Controller", new Dictionary<string, string>
{
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" }
}
},
{
"Atari 7800 ProLine Joystick Controller", new Dictionary<string,string>
{
{"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Trigger", "1"}, {"Trigger 2", "2"}
"Atari 7800 ProLine Joystick Controller", new Dictionary<string, string>
{
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Trigger", "1" }, { "Trigger 2", "2" }
}
},
{
"Commodore 64 Controller", new Dictionary<string,string>
{
{"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Button", "B"}
"Commodore 64 Controller", new Dictionary<string, string>
{
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" }
}
},
{
"Commodore 64 Keyboard", new Dictionary<string,string>
"Commodore 64 Keyboard", new Dictionary<string, string>
{
{"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<string, string>
{
{"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<string, string>
{
{"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<string, string>
{
{"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<string, Dictionary<string, string>> ANALOGS = new Dictionary<string, Dictionary<string, string>>
{
{"Nintento 64 Controller", new Dictionary<string, string> {{"X Axis", "X"}, {"Y Axis", "Y"}}}
{ "Nintento 64 Controller", new Dictionary<string, string> { { "X Axis", "X" }, { "Y Axis", "Y" } } }
};
public static readonly Dictionary<string, Dictionary<string, string>> COMMANDS = new Dictionary<string, Dictionary<string, string>>
{
{"Atari 2600 Basic Controller", new Dictionary<string, string> {{"Reset", "r"}, {"Select", "s"}}},
{"Atari 7800 ProLine Joystick Controller", new Dictionary<string, string> {{"Reset", "r"}, {"Select", "s"}}},
{"Gameboy Controller", new Dictionary<string, string> {{"Power", "P"}}},
{"GBA Controller", new Dictionary<string, string> {{"Power", "P"}}},
{"Genesis 3-Button Controller", new Dictionary<string, string> {{"Reset", "r"}}},
{"GPGX Genesis Controller", new Dictionary<string, string> {{"Power", "P"}, {"Reset", "r"}}},
{"NES Controller", new Dictionary<string, string> {{"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<string, string> {{"Power", "P"}, {"Reset", "r"}}},
{"PC Engine Controller", new Dictionary<string, string>()},
{"SMS Controller", new Dictionary<string, string> {{"Pause", "p"}, {"Reset", "r"}}},
{"TI83 Controller", new Dictionary<string, string>()},
{"Nintento 64 Controller", new Dictionary<string, string> {{"Power", "P"}, {"Reset", "r"}}},
{"Saturn Controller", new Dictionary<string, string> {{"Power", "P"}, {"Reset", "r"}}},
{"GPGX 3-Button Controller", new Dictionary<string, string> {{"Power", "P"}, {"Reset", "r"}}},
{ "Atari 2600 Basic Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Select", "s" } } },
{ "Atari 7800 ProLine Joystick Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Select", "s" } } },
{ "Gameboy Controller", new Dictionary<string, string> { { "Power", "P" } } },
{ "GBA Controller", new Dictionary<string, string> { { "Power", "P" } } },
{ "Genesis 3-Button Controller", new Dictionary<string, string> { { "Reset", "r" } } },
{ "GPGX Genesis Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "NES Controller", new Dictionary<string, string> { { "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<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "PC Engine Controller", new Dictionary<string, string>() },
{ "SMS Controller", new Dictionary<string, string> { { "Pause", "p" }, { "Reset", "r" } } },
{ "TI83 Controller", new Dictionary<string, string>() },
{ "Nintento 64 Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "Saturn Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "GPGX 3-Button Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } }
};
public static readonly Dictionary<string, int> PLAYERS = new Dictionary<string, int>
{
{"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<string, char>[] DGBMnemonic =
public static readonly Tuple<string, char>[] DGBMnemonic =
{
new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P1 Power", 'P'),
@ -202,7 +202,7 @@ namespace BizHawk.Client.Common
new Tuple<string, char>(null, '|')
};
public static Tuple<string, char>[] WSMnemonic =
public static readonly Tuple<string, char>[] WSMnemonic =
{
new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P1 X1", '1'),

View File

@ -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
}
}

View File

@ -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

View File

@ -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();
}

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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);
}
}
}

View File

@ -2,7 +2,7 @@
namespace BizHawk.Client.Common
{
public interface IMovieController: IController
public interface IMovieController : IController
{
new ControllerDefinition Definition { get; set; }

View File

@ -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)

View File

@ -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)

View File

@ -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<int> 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<string> 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<IController> 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
}
}

View File

@ -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
{

View File

@ -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;

View File

@ -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));
}
}

View File

@ -1,18 +1,11 @@
using System.Collections.Generic;
using System.Linq;
namespace BizHawk.Client.Common
namespace BizHawk.Client.Common
{
public class TasMovieRecord
{
// public KeyValuePair<int, byte[]> 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(); }
//}
}
}

View File

@ -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
}
/// <summary>
@ -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<int, SortedList<int, StateManagerState>> kvp in BranchStates)
{

View File

@ -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;
}

View File

@ -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<ListItem> 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)

View File

@ -13,7 +13,7 @@ namespace BizHawk.Client.Common
LESS_THAN,
LESS_THAN_OR_EQUAL,
NOT_EQUAL
};
}
private readonly Watch _watch;
private int? _compare;

View File

@ -479,7 +479,7 @@ namespace BizHawk.Client.Common
// For backwards compatibility, don't assume these values exist
if (vals.Length > 9)
{
if(!Enum.TryParse<Cheat.COMPARISONTYPE>(vals[9], out comparisonType))
if (!Enum.TryParse<Cheat.COMPARISONTYPE>(vals[9], out comparisonType))
{
continue; // Not sure if this is the best answer, could just resort to ==
}

View File

@ -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<IMiniWatch> CompareSpecificAddress(IEnumerable<IMiniWatch> 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<IMiniWatch> CompareChanges(IEnumerable<IMiniWatch> watchList)
@ -766,16 +763,12 @@ namespace BizHawk.Client.Common
.Where(x => (x.ChangeCount + _differentBy.Value == _compareValue.Value) || (x.ChangeCount - _differentBy.Value == _compareValue.Value))
.Cast<IMiniWatch>();
}
else
{
throw new InvalidOperationException();
}
throw new InvalidOperationException();
}
}
else
{
throw new InvalidCastException();
}
throw new InvalidCastException();
}
private IEnumerable<IMiniWatch> CompareDifference(IEnumerable<IMiniWatch> 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; }

View File

@ -24,7 +24,7 @@ namespace BizHawk.Client.Common
#region cTor(s)
/// <summary>
/// Inialize a new instance of <see cref="DWordWatch"/>
/// Initialize a new instance of <see cref="DWordWatch"/>
/// </summary>
/// <param name="domain"><see cref="MemoryDomain"/> where you want to track</param>
/// <param name="address">The address you want to track</param>
@ -56,7 +56,7 @@ namespace BizHawk.Client.Common
#region Methods
/// <summary>
/// Enumerate wich <see cref="DisplayType"/> are valid for a <see cref="DWordWatch"/>
/// Gets a list of <see cref="DisplayType"/> for a <see cref="DWordWatch"/>
/// </summary>
public static IEnumerable<DisplayType> ValidTypes
{
@ -75,7 +75,7 @@ namespace BizHawk.Client.Common
#region Implements
/// <summary>
/// Get a list a <see cref="DisplayType"/> that can be used for this <see cref="DWordWatch"/>
/// Get a list of <see cref="DisplayType"/> that can be used for a <see cref="DWordWatch"/>
/// </summary>
/// <returns>An enumeration that contains all valid <see cref="DisplayType"/></returns>
public override IEnumerable<DisplayType> AvailableTypes()
@ -96,7 +96,7 @@ namespace BizHawk.Client.Common
/// at the current <see cref="Watch"/> address
/// </summary>
/// <param name="value">Value to set</param>
/// <returns>True if value successfully sets; othewise, false</returns>
/// <returns>True if value successfully sets; otherwise, false</returns>
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
}
}

View File

@ -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
/// </summary>
internal SeparatorWatch()
:base(null, 0, WatchSize.Separator, DisplayType.Separator, true, string.Empty)
{ }
: base(null, 0, WatchSize.Separator, DisplayType.Separator, true, string.Empty)
{
}
/// <summary>
/// Gets the separator instance
/// </summary>
public static SeparatorWatch Instance
{
get { return new SeparatorWatch(); }
}
public static SeparatorWatch Instance => new SeparatorWatch();
/// <summary>
/// Get the appropriate DisplayType
@ -38,42 +35,27 @@ namespace BizHawk.Client.Common
/// <summary>
/// Ignore that stuff
/// </summary>
public override int Value
{
get { return 0; }
}
public override int Value => 0;
/// <summary>
/// Ignore that stuff
/// </summary>
public override int ValueNoFreeze
{
get { return 0; }
}
public override int ValueNoFreeze => 0;
/// <summary>
/// Ignore that stuff
/// </summary>
public override int Previous
{
get { return 0; }
}
public override int Previous => 0;
/// <summary>
/// Ignore that stuff
/// </summary>
public override string ValueString
{
get { return string.Empty; }
}
public override string ValueString => string.Empty;
/// <summary>
/// Ignore that stuff
/// </summary>
public override string PreviousStr
{
get { return string.Empty; }
}
public override string PreviousStr => string.Empty;
/// <summary>
/// TTransform the current instance into a displayable (short representation) string
@ -98,27 +80,25 @@ namespace BizHawk.Client.Common
/// </summary>
public override void ResetPrevious()
{
return;
}
/// <summary>
/// Ignore that stuff
/// </summary>
public override string Diff { get { return string.Empty; } }
public override string Diff => string.Empty;
/// <summary>
/// Ignore that stuff
/// </summary>
public override uint MaxValue
public override uint MaxValue => 0;
/// <summary>
/// Ignore that stuff
/// </summary>
public override void Update()
{
get { return 0; }
}
/// <summary>
/// Ignore that stuff
/// </summary>
public override void Update() { return; }
#endregion
}
}

View File

@ -103,7 +103,7 @@ namespace BizHawk.Client.Common
/// <returns>A brand new <see cref="Watch"/></returns>
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);
}
/// <summary>
@ -557,14 +558,7 @@ namespace BizHawk.Client.Common
/// <returns>A <see cref="string"/> representation of the current <see cref="Watch"/></returns>
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')}";
}
/// <summary>
@ -574,7 +568,7 @@ namespace BizHawk.Client.Common
/// <returns>A well formatted string representation</returns>
public virtual string ToDisplayString()
{
return string.Format("{0}: {1}", Notes, ValueString);
return $"{Notes}: {ValueString}";
}
#endregion
@ -634,13 +628,7 @@ namespace BizHawk.Client.Common
/// <summary>
/// Gets the address in the <see cref="MemoryDomain"/>
/// </summary>
public long Address
{
get
{
return _address;
}
}
public long Address => _address;
/// <summary>
/// Gets the format tha should be used by string.Format()
@ -661,13 +649,7 @@ namespace BizHawk.Client.Common
/// <summary>
/// Gets the address in the <see cref="MemoryDomain"/> formatted as string
/// </summary>
public string AddressString
{
get
{
return _address.ToString(AddressFormatStr);
}
}
public string AddressString => _address.ToString(AddressFormatStr);
/// <summary>
/// Gets or sets the endianess of current <see cref="Watch"/>
@ -688,16 +670,10 @@ namespace BizHawk.Client.Common
/// <summary>
/// Gets the number of time tha value of current <see cref="Watch"/> has changed
/// </summary>
public int ChangeCount
{
get
{
return _changecount;
}
}
public int ChangeCount => _changecount;
/// <summary>
/// Gets or set the way current <see cref="Watch"/> is displayed
/// Gets or sets the way current <see cref="Watch"/> is displayed
/// </summary>
/// <exception cref="ArgumentException">Occurs when a <see cref="DisplayType"/> is incompatible with the <see cref="WatchSize"/></exception>
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)

View File

@ -13,13 +13,12 @@ namespace BizHawk.Client.Common
/// based on the number of changes
/// </summary>
private sealed class WatchChangeCountComparer
:WatchEqualityComparer
,IComparer<Watch>
: WatchEqualityComparer, IComparer<Watch>
{
/// <summary>
/// Compares two <see cref="Watch"/> 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
/// </summary>
/// <param name="x">First <see cref="Watch"/></param>
/// <param name="y">Second <see cref="Watch"/></param>
@ -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);
}
}
}

View File

@ -22,7 +22,7 @@ namespace BizHawk.Client.Common
/// If they are equals, comapraison will done one the address and next on size
/// </summary>
/// <param name="x">First <see cref="Watch"/></param>
///<param name="y">Second <see cref="Watch"/></param>
/// <param name="y">Second <see cref="Watch"/></param>
/// <returns>0 for equality, 1 if x comes first; -1 if y comes first</returns>
public int Compare(Watch x, Watch y)
{

View File

@ -328,13 +328,15 @@ namespace BizHawk.Client.Common
Parallel.ForEach<Watch>(_watchList, watch =>
{
if (watch.IsSeparator)
{
return;
}
watch.Domain = core[watch.Domain.Name];
watch.ResetPrevious();
watch.Update();
watch.ClearChangeCount();
}
);
});
}
/// <summary>

View File

@ -13,7 +13,7 @@ namespace BizHawk.Client.Common
/// based on their note
/// </summary>
private sealed class WatchNoteComparer
:WatchEqualityComparer,
: WatchEqualityComparer,
IComparer<Watch>
{
/// <summary>

View File

@ -22,7 +22,7 @@ namespace BizHawk.Client.Common
/// If they are equals, comapraison will done one the address and next on size
/// </summary>
/// <param name="x">First <see cref="Watch"/></param>
///<param name="y">Second <see cref="Watch"/></param>
/// <param name="y">Second <see cref="Watch"/></param>
/// <returns>0 for equality, 1 if x comes first; -1 if y comes first</returns>
public int Compare(Watch x, Watch y)
{

View File

@ -9,18 +9,17 @@ namespace BizHawk.Client.Common
public sealed partial class WatchList
{
/// <summary>
/// Netsed private class that define how to compare two <see cref="Watch"/>
/// based on the diffence between current and previous value
/// Nested private class that define how to compare two <see cref="Watch"/>
/// based on the difference between current and previous value
/// </summary>
private sealed class WatchValueDifferenceComparer
: WatchEqualityComparer
, IComparer<Watch>
: WatchEqualityComparer, IComparer<Watch>
{
/// <summary>
/// Compares two <see cref="Watch"/> 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
/// </summary>
/// <param name="x">First <see cref="Watch"/></param>
/// <param name="y">Second <see cref="Watch"/></param>
@ -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);
}
}
}

View File

@ -212,7 +212,7 @@ namespace BizHawk.Client.Common
#endregion Implements
//TODO: Implements IFormattable
// TODO: Implements IFormattable
public string FormatValue(ushort val)
{
switch (Type)

View File

@ -1,4 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Emin_002Ejs/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Emin_002Ejs/@EntryIndexRemoved">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=24A0AA3C_002DB25F_002D4197_002DB23D_002D476D6462DBA0_002Fd_003A7z/@EntryIndexedValue">ExplicitlyExcluded</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantCaseLabel/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantExtendsListEntry/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1101/@EntryIndexedValue">DO_NOT_SHOW</s:String>
@ -45,6 +48,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NTSC/@EntryIndexedValue">NTSC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OBJ/@EntryIndexedValue">OBJ</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OR/@EntryIndexedValue">OR</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OSD/@EntryIndexedValue">OSD</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PAL/@EntryIndexedValue">PAL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PC/@EntryIndexedValue">PC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PCECD/@EntryIndexedValue">PCECD</s:String>
@ -59,5 +63,6 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TI/@EntryIndexedValue">TI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TIA/@EntryIndexedValue">TIA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VBA/@EntryIndexedValue">VBA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ROM/@EntryIndexedValue">ROM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=MethodPropertyEvent/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String></wpf:ResourceDictionary>