diff --git a/.gitignore b/.gitignore index 2b540361b5..20ffa86c34 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ ExternalCoreProjects/Virtu/bin/*.* libsnes/vs2015/libsnes.VC.db waterbox/**/*.wbx waterbox/**/*.wbx.in +/BizHawkTool_template.zip diff --git a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj index 9205707a7e..c99d27ef6f 100644 --- a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj +++ b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj @@ -37,6 +37,10 @@ + + False + ..\..\Users\uptho\Documents\BizHawk-2.3\dll\System.Data.SQLite.dll + @@ -48,6 +52,19 @@ + + + + + + + + + + + + + @@ -62,7 +79,25 @@ + + + + + + + + + + + + + + + + + + @@ -95,4 +130,4 @@ --> - + \ No newline at end of file diff --git a/BizHawk.Client.Common/plugins/PluginLibrary.Emu.cs b/BizHawk.Client.ApiHawk/Classes/Api/EmuApi.cs similarity index 91% rename from BizHawk.Client.Common/plugins/PluginLibrary.Emu.cs rename to BizHawk.Client.ApiHawk/Classes/Api/EmuApi.cs index b0ccf94061..3677007d2b 100644 --- a/BizHawk.Client.Common/plugins/PluginLibrary.Emu.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/EmuApi.cs @@ -2,6 +2,7 @@ using System.ComponentModel; using System.Collections.Generic; +using BizHawk.Client.Common; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Emulation.Cores.Nintendo.NES; @@ -12,11 +13,32 @@ using BizHawk.Emulation.Cores.Sega.MasterSystem; using BizHawk.Emulation.Cores.WonderSwan; using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES; -namespace BizHawk.Client.Common +namespace BizHawk.Client.ApiHawk { [Description("A library for interacting with the currently loaded emulator core")] - public sealed class EmulatorPluginLibrary : PluginLibraryBase + public sealed class EmuApi : IEmu { + private static class EmuStatic + { + public static void DisplayVsync(bool enabled) + { + Global.Config.VSync = enabled; + } + public static string GetSystemId() + { + return Global.Game.System; + } + public static void LimitFramerate(bool enabled) + { + Global.Config.ClockThrottle = enabled; + } + + public static void MinimizeFrameskip(bool enabled) + { + Global.Config.AutoMinimizeSkipping = enabled; + } + + } [RequiredService] private IEmulator Emulator { get; set; } @@ -41,12 +63,12 @@ namespace BizHawk.Client.Common public Action FrameAdvanceCallback { get; set; } public Action YieldCallback { get; set; } - public EmulatorPluginLibrary() : base() + public EmuApi() { } - public static void DisplayVsync(bool enabled) + public void DisplayVsync(bool enabled) { - Global.Config.VSync = enabled; + EmuStatic.DisplayVsync(enabled); } public void FrameAdvance() @@ -166,9 +188,9 @@ namespace BizHawk.Client.Common } } - public static string GetSystemId() + public string GetSystemId() { - return Global.Game.System; + return EmuStatic.GetSystemId(); } public bool IsLagged() @@ -217,14 +239,39 @@ namespace BizHawk.Client.Common } } - public static void LimitFramerate(bool enabled) + public void LimitFramerate(bool enabled) { - Global.Config.ClockThrottle = enabled; + EmuStatic.LimitFramerate(enabled); } - public static void MinimizeFrameskip(bool enabled) + public void MinimizeFrameskip(bool enabled) { - Global.Config.AutoMinimizeSkipping = enabled; + EmuStatic.MinimizeFrameskip(enabled); + } + + public void Yield() + { + YieldCallback(); + } + + public string GetDisplayType() + { + if (RegionableCore != null) + { + return RegionableCore.Region.ToString(); + } + + return ""; + } + + public string GetBoardName() + { + if (BoardInfo != null) + { + return BoardInfo.BoardName; + } + + return ""; } public object GetSettings() { @@ -407,30 +454,5 @@ namespace BizHawk.Client.Common return true; } - - public void Yield() - { - YieldCallback(); - } - - public string GetDisplayType() - { - if (RegionableCore != null) - { - return RegionableCore.Region.ToString(); - } - - return ""; - } - - public string GetBoardName() - { - if (BoardInfo != null) - { - return BoardInfo.BoardName; - } - - return ""; - } } } diff --git a/BizHawk.Client.Common/plugins/PluginLibrary.Gameinfo.cs b/BizHawk.Client.ApiHawk/Classes/Api/GameInfoApi.cs similarity index 85% rename from BizHawk.Client.Common/plugins/PluginLibrary.Gameinfo.cs rename to BizHawk.Client.ApiHawk/Classes/Api/GameInfoApi.cs index e74ea5f21b..ca74d09da6 100644 --- a/BizHawk.Client.Common/plugins/PluginLibrary.Gameinfo.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/GameInfoApi.cs @@ -1,16 +1,16 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; +using BizHawk.Client.Common; using BizHawk.Emulation.Common; -namespace BizHawk.Client.Common +namespace BizHawk.Client.ApiHawk { - public sealed class GameInfoPluginLibrary : PluginLibraryBase + public sealed class GameInfoApi : IGameInfo { [OptionalService] private IBoardInfo BoardInfo { get; set; } - public GameInfoPluginLibrary() : base() + public GameInfoApi() { } public string GetRomName() diff --git a/BizHawk.Client.Common/plugins/PluginLibrary.Joypad.cs b/BizHawk.Client.ApiHawk/Classes/Api/JoypadApi.cs similarity index 97% rename from BizHawk.Client.Common/plugins/PluginLibrary.Joypad.cs rename to BizHawk.Client.ApiHawk/Classes/Api/JoypadApi.cs index 5eeb3ff1e6..0c049ed97c 100644 --- a/BizHawk.Client.Common/plugins/PluginLibrary.Joypad.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/JoypadApi.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; -namespace BizHawk.Client.Common +using BizHawk.Client.Common; + +namespace BizHawk.Client.ApiHawk { - public sealed class JoypadPluginLibrary : PluginLibraryBase + public sealed class JoypadApi : IJoypad { - public JoypadPluginLibrary() : base() + public JoypadApi() { } public Dictionary Get(int? controller = null) diff --git a/BizHawk.Client.Common/plugins/PluginLibrary.Memory.cs b/BizHawk.Client.ApiHawk/Classes/Api/MemApi.cs similarity index 95% rename from BizHawk.Client.Common/plugins/PluginLibrary.Memory.cs rename to BizHawk.Client.ApiHawk/Classes/Api/MemApi.cs index 543ea1780b..f54b282550 100644 --- a/BizHawk.Client.Common/plugins/PluginLibrary.Memory.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/MemApi.cs @@ -5,20 +5,16 @@ using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Common.BufferExtensions; -namespace BizHawk.Client.Common +namespace BizHawk.Client.ApiHawk { - public sealed class MemoryPluginLibrary : PluginMemoryBase + public sealed class MemApi : MemApiBase, IMem { private MemoryDomain _currentMemoryDomain; private bool _isBigEndian = false; - public MemoryPluginLibrary() + public MemApi() : base() { } - public void SetBigEndian() - { - _isBigEndian = true; - } protected override MemoryDomain Domain { @@ -44,6 +40,11 @@ namespace BizHawk.Client.Common #region Unique Library Methods + public void SetBigEndian(bool enabled = true) + { + _isBigEndian = enabled; + } + public List GetMemoryDomainList() { var list = new List(); @@ -198,16 +199,16 @@ namespace BizHawk.Client.Common return (sbyte)ReadUnsignedByte(addr, domain); } - public void WriteS8(long addr, uint value, string domain = null) - { - WriteUnsignedByte(addr, value, domain); - } - public uint ReadU8(long addr, string domain = null) { return (byte)ReadUnsignedByte(addr, domain); } + public void WriteS8(long addr, int value, string domain = null) + { + WriteSigned(addr, value, 1, domain); + } + public void WriteU8(long addr, uint value, string domain = null) { WriteUnsignedByte(addr, value, domain); diff --git a/BizHawk.Client.Common/plugins/PluginMemoryBase.cs b/BizHawk.Client.ApiHawk/Classes/Api/MemApiBase.cs similarity index 97% rename from BizHawk.Client.Common/plugins/PluginMemoryBase.cs rename to BizHawk.Client.ApiHawk/Classes/Api/MemApiBase.cs index 21bf8b89e0..bc5c328d66 100644 --- a/BizHawk.Client.Common/plugins/PluginMemoryBase.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/MemApiBase.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; -namespace BizHawk.Client.Common +namespace BizHawk.Client.ApiHawk { /// /// Base class for the Memory and MainMemory plugin libraries /// - public abstract class PluginMemoryBase : PluginLibraryBase + public abstract class MemApiBase : IExternalApi { [RequiredService] protected IEmulator Emulator { get; set; } @@ -18,7 +18,7 @@ namespace BizHawk.Client.Common protected abstract MemoryDomain Domain { get; } - protected PluginMemoryBase() : base() + protected MemApiBase() { } protected IMemoryDomains DomainList diff --git a/BizHawk.Client.Common/plugins/PluginLibrary.MemoryEvents.cs b/BizHawk.Client.ApiHawk/Classes/Api/MemEventsApi.cs similarity index 89% rename from BizHawk.Client.Common/plugins/PluginLibrary.MemoryEvents.cs rename to BizHawk.Client.ApiHawk/Classes/Api/MemEventsApi.cs index 9816e9344d..5848df5fc3 100644 --- a/BizHawk.Client.Common/plugins/PluginLibrary.MemoryEvents.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/MemEventsApi.cs @@ -3,14 +3,14 @@ using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; -namespace BizHawk.Client.Common +namespace BizHawk.Client.ApiHawk { - public sealed class MemoryEventsPluginLibrary : PluginLibraryBase + public sealed class MemEventsApi : IMemEvents { [RequiredService] private IDebuggable DebuggableCore { get; set; } - public MemoryEventsPluginLibrary () : base() + public MemEventsApi () : base() { } public void AddReadCallback(Action cb, uint address, string domain) diff --git a/BizHawk.Client.Common/plugins/PluginLibrary.MemorySavestate.cs b/BizHawk.Client.ApiHawk/Classes/Api/MemorySaveStateApi.cs similarity index 87% rename from BizHawk.Client.Common/plugins/PluginLibrary.MemorySavestate.cs rename to BizHawk.Client.ApiHawk/Classes/Api/MemorySaveStateApi.cs index 90950d6f73..b22eaa7540 100644 --- a/BizHawk.Client.Common/plugins/PluginLibrary.MemorySavestate.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/MemorySaveStateApi.cs @@ -4,11 +4,11 @@ using System.IO; using BizHawk.Emulation.Common; -namespace BizHawk.Client.Common +namespace BizHawk.Client.ApiHawk { - public sealed class MemorySavestatePluginLibrary : PluginLibraryBase + public sealed class MemorySaveStateApi : IMemorySaveState { - public MemorySavestatePluginLibrary() : base() + public MemorySaveStateApi() { } [RequiredService] diff --git a/BizHawk.Client.ApiHawk/Classes/Api/MovieApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/MovieApi.cs new file mode 100644 index 0000000000..0b74cfd5cc --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/MovieApi.cs @@ -0,0 +1,288 @@ +using System; +using System.Collections.Generic; +using System.IO; + +using BizHawk.Client.Common; + +namespace BizHawk.Client.ApiHawk +{ + public sealed class MovieApi : IMovie + { + private static class MoviePluginStatic + { + public static string Filename() + { + return Global.MovieSession.Movie.Filename; + } + + public static bool GetReadOnly() + { + return Global.MovieSession.ReadOnly; + } + + public static ulong GetRerecordCount() + { + return Global.MovieSession.Movie.Rerecords; + } + + public static bool GetRerecordCounting() + { + return Global.MovieSession.Movie.IsCountingRerecords; + } + + public static bool IsLoaded() + { + return Global.MovieSession.Movie.IsActive; + } + + public static double Length() + { + return Global.MovieSession.Movie.FrameCount; + } + + public static string Mode() + { + if (Global.MovieSession.Movie.IsFinished) + { + return "FINISHED"; + } + + if (Global.MovieSession.Movie.IsPlaying) + { + return "PLAY"; + } + + if (Global.MovieSession.Movie.IsRecording) + { + return "RECORD"; + } + + return "INACTIVE"; + } + + public static void SetReadOnly(bool readOnly) + { + Global.MovieSession.ReadOnly = readOnly; + } + + public static void SetRerecordCount(double count) + { + // Lua numbers are always double, integer precision holds up + // to 53 bits, so throw an error if it's bigger than that. + const double PrecisionLimit = 9007199254740992d; + + if (count > PrecisionLimit) + { + throw new Exception("Rerecord count exceeds Lua integer precision."); + } + + Global.MovieSession.Movie.Rerecords = (ulong)count; + } + + public static void SetRerecordCounting(bool counting) + { + Global.MovieSession.Movie.IsCountingRerecords = counting; + } + + public static void Stop() + { + Global.MovieSession.Movie.Stop(); + } + + public static double GetFps() + { + if (Global.MovieSession.Movie.IsActive) + { + var movie = Global.MovieSession.Movie; + var system = movie.HeaderEntries[HeaderKeys.PLATFORM]; + var pal = movie.HeaderEntries.ContainsKey(HeaderKeys.PAL) && + movie.HeaderEntries[HeaderKeys.PAL] == "1"; + + return new PlatformFrameRates()[system, pal]; + } + + return 0.0; + } + + } + public MovieApi() + { } + + public bool StartsFromSavestate() + { + return Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSavestate; + } + + public bool StartsFromSaveram() + { + return Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSaveRam; + } + + public Dictionary GetInput(int frame) + { + if (!Global.MovieSession.Movie.IsActive) + { + Console.WriteLine("No movie loaded"); + return null; + } + + var input = new Dictionary(); + var adapter = Global.MovieSession.Movie.GetInputState(frame); + + if (adapter == null) + { + Console.WriteLine("Can't get input of the last frame of the movie. Use the previous frame"); + return null; + } + + foreach (var button in adapter.Definition.BoolButtons) + { + input[button] = adapter.IsPressed(button); + } + + foreach (var button in adapter.Definition.FloatControls) + { + input[button] = adapter.GetFloat(button); + } + + return input; + } + + public string GetInputAsMnemonic(int frame) + { + if (Global.MovieSession.Movie.IsActive && frame < Global.MovieSession.Movie.InputLogLength) + { + var lg = Global.MovieSession.LogGeneratorInstance(); + lg.SetSource(Global.MovieSession.Movie.GetInputState(frame)); + return lg.GenerateLogEntry(); + } + + return ""; + } + + public void Save(string filename = "") + { + if (!Global.MovieSession.Movie.IsActive) + { + return; + } + + if (!string.IsNullOrEmpty(filename)) + { + filename += "." + Global.MovieSession.Movie.PreferredExtension; + var test = new FileInfo(filename); + if (test.Exists) + { + Console.WriteLine($"File {filename} already exists, will not overwrite"); + return; + } + + Global.MovieSession.Movie.Filename = filename; + } + + Global.MovieSession.Movie.Save(); + } + + public Dictionary GetHeader() + { + var table = new Dictionary(); + if (Global.MovieSession.Movie.IsActive) + { + foreach (var kvp in Global.MovieSession.Movie.HeaderEntries) + { + table[kvp.Key] = kvp.Value; + } + } + + return table; + } + + public List GetComments() + { + var list = new List(Global.MovieSession.Movie.Comments.Count); + if (Global.MovieSession.Movie.IsActive) + { + for (int i = 0; i < Global.MovieSession.Movie.Comments.Count; i++) + { + list[i] = Global.MovieSession.Movie.Comments[i]; + } + } + + return list; + } + + public List GetSubtitles() + { + var list = new List(Global.MovieSession.Movie.Subtitles.Count); + if (Global.MovieSession.Movie.IsActive) + { + for (int i = 0; i < Global.MovieSession.Movie.Subtitles.Count; i++) + { + list[i] = Global.MovieSession.Movie.Subtitles[i].ToString(); + } + } + + return list; + } + + public string Filename() + { + return MoviePluginStatic.Filename(); + } + + public bool GetReadOnly() + { + return MoviePluginStatic.GetReadOnly(); + } + + public ulong GetRerecordCount() + { + return MoviePluginStatic.GetRerecordCount(); + } + + public bool GetRerecordCounting() + { + return MoviePluginStatic.GetRerecordCounting(); + } + + public bool IsLoaded() + { + return MoviePluginStatic.IsLoaded(); + } + + public double Length() + { + return MoviePluginStatic.Length(); + } + + public string Mode() + { + return MoviePluginStatic.Mode(); + } + + public void SetReadOnly(bool readOnly) + { + MoviePluginStatic.SetReadOnly(readOnly); + } + + public void SetRerecordCount(double count) + { + MoviePluginStatic.SetRerecordCount(count); + } + + public void SetRerecordCounting(bool counting) + { + MoviePluginStatic.SetRerecordCounting(counting); + } + + public void Stop() + { + MoviePluginStatic.Stop(); + } + + public double GetFps() + { + return MoviePluginStatic.GetFps(); + } + } +} diff --git a/BizHawk.Client.Common/plugins/PluginBase.cs b/BizHawk.Client.ApiHawk/Classes/Api/PluginBase.cs similarity index 89% rename from BizHawk.Client.Common/plugins/PluginBase.cs rename to BizHawk.Client.ApiHawk/Classes/Api/PluginBase.cs index 7ef2f4453d..24bf62c727 100644 --- a/BizHawk.Client.Common/plugins/PluginBase.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/PluginBase.cs @@ -1,6 +1,6 @@ using BizHawk.Emulation.Common; -namespace BizHawk.Client.Common +namespace BizHawk.Client.ApiHawk { public abstract class PluginBase : IPlugin { @@ -13,7 +13,7 @@ namespace BizHawk.Client.Common /// or register memory callbacks in /// their Init function. /// - protected IPluginAPI _api; + protected IApiContainer _api; public PluginBase() { } @@ -41,7 +41,7 @@ namespace BizHawk.Client.Common public virtual void LoadStateCallback(string name) { } public virtual void InputPollCallback() { } public virtual void ExitCallback() { } - public virtual void Init (IPluginAPI api) + public virtual void Init (IApiContainer api) { _api = api; Running = true; diff --git a/BizHawk.Client.Common/plugins/PluginLibrary.SQL.cs b/BizHawk.Client.ApiHawk/Classes/Api/SqlApi.cs similarity index 95% rename from BizHawk.Client.Common/plugins/PluginLibrary.SQL.cs rename to BizHawk.Client.ApiHawk/Classes/Api/SqlApi.cs index dae76333af..6a18d507af 100644 --- a/BizHawk.Client.Common/plugins/PluginLibrary.SQL.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/SqlApi.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data.SQLite; -namespace BizHawk.Client.Common +namespace BizHawk.Client.ApiHawk { - public sealed class SQLPluginLibrary : PluginLibraryBase + public sealed class SqlApi : ISql { - public SQLPluginLibrary() : base() + public SqlApi() : base() { } SQLiteConnection m_dbConnection; @@ -125,6 +125,5 @@ namespace BizHawk.Client.Common return sqlEX.Message; } } - } } diff --git a/BizHawk.Client.Common/plugins/PluginLibrary.UserData.cs b/BizHawk.Client.ApiHawk/Classes/Api/UserDataApi.cs similarity index 84% rename from BizHawk.Client.Common/plugins/PluginLibrary.UserData.cs rename to BizHawk.Client.ApiHawk/Classes/Api/UserDataApi.cs index 27d2dc5af4..735fe397b9 100644 --- a/BizHawk.Client.Common/plugins/PluginLibrary.UserData.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/UserDataApi.cs @@ -3,11 +3,11 @@ using System.ComponentModel; using BizHawk.Client.Common; -namespace BizHawk.Client.Common +namespace BizHawk.Client.ApiHawk { - public sealed class UserDataPluginLibrary : PluginLibraryBase + public sealed class UserDataApi : IUserData { - public UserDataPluginLibrary() : base() + public UserDataApi() : base() { } public void Set(string name, object value) diff --git a/BizHawk.Client.ApiHawk/Classes/ApiInjector.cs b/BizHawk.Client.ApiHawk/Classes/ApiInjector.cs new file mode 100644 index 0000000000..811807659f --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/ApiInjector.cs @@ -0,0 +1,79 @@ +using System; +using System.Linq; + +using BizHawk.Common.ReflectionExtensions; + +namespace BizHawk.Client.ApiHawk +{ + /// + /// injects Apis into other classes + /// + public static class ApiInjector + { + /// + /// clears all Apis from a target + /// + public static void ClearApis(object target) + { + Type targetType = target.GetType(); + object[] tmp = new object[1]; + + foreach (var propinfo in + targetType.GetPropertiesWithAttrib(typeof(RequiredApiAttribute)) + .Concat(targetType.GetPropertiesWithAttrib(typeof(OptionalApiAttribute)))) + { + propinfo.GetSetMethod(true).Invoke(target, tmp); + } + } + + /// + /// Feeds the target its required Apis. + /// + /// false if update failed + public static bool UpdateApis(IExternalApiProvider source, object target) + { + Type targetType = target.GetType(); + object[] tmp = new object[1]; + + foreach (var propinfo in targetType.GetPropertiesWithAttrib(typeof(RequiredApiAttribute))) + { + tmp[0] = source.GetApi(propinfo.PropertyType); + if (tmp[0] == null) + { + return false; + } + + propinfo.GetSetMethod(true).Invoke(target, tmp); + } + + foreach (var propinfo in targetType.GetPropertiesWithAttrib(typeof(OptionalApiAttribute))) + { + tmp[0] = source.GetApi(propinfo.PropertyType); + propinfo.GetSetMethod(true).Invoke(target, tmp); + } + + return true; + } + + /// + /// Determines whether a target is available, considering its dependencies + /// and the Apis provided by the emulator core. + /// + public static bool IsAvailable(IExternalApiProvider source, Type targetType) + { + return targetType.GetPropertiesWithAttrib(typeof(RequiredApiAttribute)) + .Select(pi => pi.PropertyType) + .All(source.HasApi); + } + } + + [AttributeUsage(AttributeTargets.Property)] + public class RequiredApiAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Property)] + public class OptionalApiAttribute : Attribute + { + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/BasicApiProvider.cs b/BizHawk.Client.ApiHawk/Classes/BasicApiProvider.cs new file mode 100644 index 0000000000..75da59a6d4 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/BasicApiProvider.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace BizHawk.Client.ApiHawk +{ + /// + /// A generic implementation of IExternalApi provider that provides + /// this functionality to any core. + /// The provider will scan an IExternal and register all IExternalApis + /// that the core object itself implements. In addition it provides + /// a Register() method to allow the core to pass in any additional Apis + /// + /// + public class BasicApiProvider : IExternalApiProvider + { + private readonly Dictionary _Apis = new Dictionary(); + + public BasicApiProvider(IApiContainer container) + { + // simplified logic here doesn't scan for possible Apis; just adds what it knows is implemented by the PluginApi + // this removes the possibility of automagically picking up a Api in a nested class, (find the type, then + // find the field), but we're going to keep such logic out of the basic provider. Anything the passed + // container doesn't implement directly needs to be added with Register() + // this also fully allows apis that are not IExternalApi + var libs = container.Libraries; + + _Apis = libs; + } + + /// + /// the client can call this to register an additional Api + /// + /// The to register + public void Register(T api) + where T : IExternalApi + { + if (api == null) + { + throw new ArgumentNullException(nameof(api)); + } + + _Apis[typeof(T)] = api; + } + + public T GetApi() + where T : IExternalApi + { + return (T)GetApi(typeof(T)); + } + + public object GetApi(Type t) + { + IExternalApi Api; + KeyValuePair[] k = _Apis.Where(kvp => t.IsAssignableFrom(kvp.Key)).ToArray(); + if (k.Length > 0) + { + return k[0].Value; + } + + return null; + } + + public bool HasApi() + where T : IExternalApi + { + return HasApi(typeof(T)); + } + + public bool HasApi(Type t) + { + return _Apis.ContainsKey(t); + } + + public IEnumerable AvailableApis + { + get + { + return _Apis.Select(d => d.Key); + } + } + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/ClientApi.cs b/BizHawk.Client.ApiHawk/Classes/ClientApi.cs index 767d755105..8756885f54 100644 --- a/BizHawk.Client.ApiHawk/Classes/ClientApi.cs +++ b/BizHawk.Client.ApiHawk/Classes/ClientApi.cs @@ -5,6 +5,7 @@ using System.Reflection; using System.Threading.Tasks; using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.PCEngine; using BizHawk.Emulation.Cores.Sega.MasterSystem; @@ -21,6 +22,9 @@ namespace BizHawk.Client.ApiHawk { #region Fields + private static IEmulator Emulator; + private static IVideoProvider VideoProvider; + private static readonly Assembly clientAssembly; private static readonly object clientMainFormInstance; private static readonly Type mainFormClass; @@ -68,24 +72,57 @@ namespace BizHawk.Client.ApiHawk mainFormClass = clientAssembly.GetType("BizHawk.Client.EmuHawk.MainForm"); } + public static void UpdateEmulatorAndVP(IEmulator emu = null) + { + Emulator = emu; + VideoProvider = Emulation.Common.IEmulatorExtensions.Extensions.AsVideoProviderOrDefault(emu); + } + #endregion #region Methods + #region Helpers + + private static void InvokeMainFormMethod(string name, dynamic[] paramList = null) + { + List typeList = new List(); + MethodInfo method; + if (paramList != null) + { + foreach (var obj in paramList) + { + typeList.Add(obj.GetType()); + } + method = mainFormClass.GetMethod(name, typeList.ToArray()); + } + else method = mainFormClass.GetMethod(name); + method.Invoke(clientMainFormInstance, paramList); + } + + private static object GetMainFormField(string name) + { + return mainFormClass.GetField(name); + } + + private static void SetMainFormField(string name, object value) + { + mainFormClass.GetField(name).SetValue(clientMainFormInstance, value); + } + + #endregion + #region Public /// /// THE FrameAdvance stuff /// public static void DoFrameAdvance() { - MethodInfo method = mainFormClass.GetMethod("FrameAdvance"); - method.Invoke(clientMainFormInstance, null); + InvokeMainFormMethod("FrameAdvance", null); - method = mainFormClass.GetMethod("StepRunLoop_Throttle", BindingFlags.NonPublic | BindingFlags.Instance); - method.Invoke(clientMainFormInstance, null); + InvokeMainFormMethod("StepRunLoop_Throttle", null); - method = mainFormClass.GetMethod("Render", BindingFlags.NonPublic | BindingFlags.Instance); - method.Invoke(clientMainFormInstance, null); + InvokeMainFormMethod("Render", null); } /// @@ -124,8 +161,7 @@ namespace BizHawk.Client.ApiHawk /// Savetate friendly name public static void LoadState(string name) { - MethodInfo method = mainFormClass.GetMethod("LoadState"); - method.Invoke(clientMainFormInstance, new object[] { Path.Combine(PathManager.GetSaveStatePath(Global.Game), string.Format("{0}.{1}", name, "State")), name, false, false }); + InvokeMainFormMethod("LoadState", new object[] { Path.Combine(PathManager.GetSaveStatePath(Global.Game), string.Format("{0}.{1}", name, "State")), name, false, false }); } @@ -194,12 +230,11 @@ namespace BizHawk.Client.ApiHawk /// /// Raise when a rom is successfully Loaded /// - public static void OnRomLoaded() + public static void OnRomLoaded(IEmulator emu) { - if (RomLoaded != null) - { - RomLoaded(null, EventArgs.Empty); - } + Emulator = emu; + VideoProvider = Emulation.Common.IEmulatorExtensions.Extensions.AsVideoProviderOrDefault(emu); + RomLoaded?.Invoke(null, EventArgs.Empty); allJoypads = new List(RunningSystem.MaxControllers); for (int i = 1; i <= RunningSystem.MaxControllers; i++) @@ -215,11 +250,9 @@ namespace BizHawk.Client.ApiHawk /// Savetate friendly name public static void SaveState(string name) { - MethodInfo method = mainFormClass.GetMethod("SaveState"); - method.Invoke(clientMainFormInstance, new object[] { Path.Combine(PathManager.GetSaveStatePath(Global.Game), string.Format("{0}.{1}", name, "State")), name, false }); + InvokeMainFormMethod("SaveState", new object[] { Path.Combine(PathManager.GetSaveStatePath(Global.Game), string.Format("{0}.{1}", name, "State")), name, false }); } - /// /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements /// @@ -227,24 +260,23 @@ namespace BizHawk.Client.ApiHawk /// Top padding /// Right padding /// Bottom padding - public static void SetExtraPadding(int left, int top, int right, int bottom) + public static void SetGameExtraPadding(int left, int top, int right, int bottom) { FieldInfo f = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin").GetField("DisplayManager"); object displayManager = f.GetValue(null); - f = f.FieldType.GetField("ClientExtraPadding"); + f = f.FieldType.GetField("GameExtraPadding"); f.SetValue(displayManager, new Padding(left, top, right, bottom)); - MethodInfo resize = mainFormClass.GetMethod("FrameBufferResized"); - resize.Invoke(clientMainFormInstance, null); + InvokeMainFormMethod("FrameBufferResized"); } /// /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements /// /// Left padding - public static void SetExtraPadding(int left) + public static void SetGameExtraPadding(int left) { - SetExtraPadding(left, 0, 0, 0); + SetGameExtraPadding(left, 0, 0, 0); } /// @@ -252,9 +284,9 @@ namespace BizHawk.Client.ApiHawk /// /// Left padding /// Top padding - public static void SetExtraPadding(int left, int top) + public static void SetGameExtraPadding(int left, int top) { - SetExtraPadding(left, top, 0, 0); + SetGameExtraPadding(left, top, 0, 0); } /// @@ -263,9 +295,56 @@ namespace BizHawk.Client.ApiHawk /// Left padding /// Top padding /// Right padding - public static void SetExtraPadding(int left, int top, int right) + public static void SetGameExtraPadding(int left, int top, int right) { - SetExtraPadding(left, top, right, 0); + SetGameExtraPadding(left, top, right, 0); + } + + /// + /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements + /// + /// Left padding + /// Top padding + /// Right padding + /// Bottom padding + public static void SetClientExtraPadding(int left, int top, int right, int bottom) + { + FieldInfo f = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin").GetField("DisplayManager"); + object displayManager = f.GetValue(null); + f = f.FieldType.GetField("ClientExtraPadding"); + f.SetValue(displayManager, new Padding(left, top, right, bottom)); + + InvokeMainFormMethod("FrameBufferResized"); + } + + /// + /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements + /// + /// Left padding + public static void SetClientExtraPadding(int left) + { + SetClientExtraPadding(left, 0, 0, 0); + } + + /// + /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements + /// + /// Left padding + /// Top padding + public static void SetClientExtraPadding(int left, int top) + { + SetClientExtraPadding(left, top, 0, 0); + } + + /// + /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements + /// + /// Left padding + /// Top padding + /// Right padding + public static void SetClientExtraPadding(int left, int top, int right) + { + SetClientExtraPadding(left, top, right, 0); } @@ -327,8 +406,7 @@ namespace BizHawk.Client.ApiHawk /// public static void UnpauseEmulation() { - MethodInfo method = mainFormClass.GetMethod("UnpauseEmulator"); - method.Invoke(clientMainFormInstance, null); + InvokeMainFormMethod("UnpauseEmulator", null); } #endregion Public @@ -375,6 +453,275 @@ namespace BizHawk.Client.ApiHawk } } + public static void CloseEmulator() + { + InvokeMainFormMethod("CloseEmulator"); + } + + public static void CloseEmulatorWithCode(int exitCode) + { + InvokeMainFormMethod("CloseEmulator", new object[] {exitCode}); + } + + public static int BorderHeight() + { + var point = new System.Drawing.Point(0, 0); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin"); + FieldInfo f = t.GetField("DisplayManager"); + object displayManager = f.GetValue(null); + MethodInfo m = t.GetMethod("TransFormPoint"); + point = (System.Drawing.Point) m.Invoke(displayManager, new object[] { point }); + return point.Y; + } + + public static int BorderWidth() + { + var point = new System.Drawing.Point(0, 0); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin"); + FieldInfo f = t.GetField("DisplayManager"); + object displayManager = f.GetValue(null); + MethodInfo m = t.GetMethod("TransFormPoint"); + point = (System.Drawing.Point)m.Invoke(displayManager, new object[] { point }); + return point.X; + } + + public static int BufferHeight() + { + return VideoProvider.BufferHeight; + } + + public static int BufferWidth() + { + return VideoProvider.BufferWidth; + } + + public static void ClearAutohold() + { + InvokeMainFormMethod("ClearHolds"); + } + + public static void CloseRom() + { + InvokeMainFormMethod("CloseRom"); + } + + public static void DisplayMessages(bool value) + { + Global.Config.DisplayMessages = value; + } + + public static void EnableRewind(bool enabled) + { + InvokeMainFormMethod("EnableRewind", new object[] {enabled}); + } + + public static void FrameSkip(int numFrames) + { + if (numFrames > 0) + { + Global.Config.FrameSkip = numFrames; + InvokeMainFormMethod("FrameSkipMessage"); + } + else + { + Console.WriteLine("Invalid frame skip value"); + } + } + + public static int GetTargetScanlineIntensity() + { + return Global.Config.TargetScanlineFilterIntensity; + } + + public static int GetWindowSize() + { + return Global.Config.TargetZoomFactors[Emulator.SystemId]; + } + + public static void SetSoundOn(bool enable) + { + Global.Config.SoundEnabled = enable; + } + + public static bool GetSoundOn() + { + return Global.Config.SoundEnabled; + } + + public static bool IsPaused() + { + return (bool) GetMainFormField("EmulatorPaused"); + } + + public static bool IsTurbo() + { + return (bool)GetMainFormField("IsTurboing"); + } + + public static bool IsSeeking() + { + return (bool)GetMainFormField("IsSeeking"); + } + + public static void OpenRom(string path) + { + var ioa = OpenAdvancedSerializer.ParseWithLegacy(path); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin.MainForm.LoadRomArgs"); + object o = Activator.CreateInstance(t); + t.GetField("OpenAdvanced").SetValue(o, ioa); + + InvokeMainFormMethod("LoadRom", new object[] {path, o}); + } + + public static void Pause() + { + InvokeMainFormMethod("PauseEmulator"); + } + + public static void PauseAv() + { + SetMainFormField("PauseAvi", true); + } + + public static void RebootCore() + { + InvokeMainFormMethod("RebootCore"); + } + + public static void SaveRam() + { + InvokeMainFormMethod("FlushSaveRAM"); + } + + public static int ScreenHeight() + { + Type t = GetMainFormField("PresentationPanel").GetType(); + object o = GetMainFormField("PresentationPanel"); + o = t.GetField("NativeSize").GetValue(o); + t = t.GetField("NativeSize").GetType(); + + return (int) t.GetField("Height").GetValue(o); + } + + public static void Screenshot(string path = null) + { + if (path == null) + { + InvokeMainFormMethod("TakeScreenshot"); + } + else + { + InvokeMainFormMethod("TakeScreenshot", new object[] {path}); + } + } + + public static void ScreenshotToClipboard() + { + InvokeMainFormMethod("TakeScreenshotToClipboard"); + } + + public static void SetTargetScanlineIntensity(int val) + { + Global.Config.TargetScanlineFilterIntensity = val; + } + + public static void SetScreenshotOSD(bool value) + { + Global.Config.Screenshot_CaptureOSD = value; + } + + public static int ScreenWidth() + { + Type t = GetMainFormField("PresentationPanel").GetType(); + object o = GetMainFormField("PresentationPanel"); + o = t.GetField("NativeSize").GetValue(o); + t = t.GetField("NativeSize").GetType(); + + return (int) t.GetField("Width").GetValue(o); + } + + public static void SetWindowSize(int size) + { + if (size == 1 || size == 2 || size == 3 || size == 4 || size == 5 || size == 10) + { + Global.Config.TargetZoomFactors[Emulator.SystemId] = size; + InvokeMainFormMethod("FrameBufferResized"); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin"); + FieldInfo f = t.GetField("OSD"); + object osd = f.GetValue(null); + t = f.GetType(); + MethodInfo m = t.GetMethod("AddMessage"); + m.Invoke(osd, new Object[] { "Window size set to " + size + "x" }); + } + else + { + Console.WriteLine("Invalid window size"); + } + } + + public static void SpeedMode(int percent) + { + if (percent > 0 && percent < 6400) + { + InvokeMainFormMethod("ClickSpeedItem", new object[] {percent}); + } + else + { + Console.WriteLine("Invalid speed value"); + } + } + + public static void TogglePause() + { + InvokeMainFormMethod("TogglePause"); + } + + public static int TransformPointX(int x) + { + var point = new System.Drawing.Point(x, 0); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin"); + FieldInfo f = t.GetField("DisplayManager"); + object displayManager = f.GetValue(null); + MethodInfo m = t.GetMethod("TransFormPoint"); + point = (System.Drawing.Point)m.Invoke(displayManager, new object[] { point }); + return point.X; + } + + public static int TransformPointY(int y) + { + var point = new System.Drawing.Point(0, y); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin"); + FieldInfo f = t.GetField("DisplayManager"); + object displayManager = f.GetValue(null); + MethodInfo m = t.GetMethod("TransFormPoint"); + point = (System.Drawing.Point)m.Invoke(displayManager, new object[] { point }); + return point.Y; + } + + public static void Unpause() + { + InvokeMainFormMethod("UnpauseEmulator"); + } + + public static void UnpauseAv() + { + SetMainFormField("PauseAvi", false); + } + + public static int Xpos() + { + object o = GetMainFormField("DesktopLocation"); + Type t = mainFormClass.GetField("DesktopLocation").GetType(); + return (int)t.GetField("X").GetValue(o); + } + + public static int Ypos() + { + object o = GetMainFormField("DesktopLocation"); + Type t = mainFormClass.GetField("DesktopLocation").GetType(); + return (int)t.GetField("Y").GetValue(o); + } + #endregion #region Properties @@ -427,11 +774,11 @@ namespace BizHawk.Client.ApiHawk } else { - return SystemInfo.DualGB; + return SystemInfo.DualGB; } default: - return SystemInfo.FindByCoreSystem(SystemIdConverter.Convert(Global.Emulator.SystemId)); + return SystemInfo.FindByCoreSystem(SystemIdConverter.Convert(Global.Emulator.SystemId)); } } } diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IApiContainer.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IApiContainer.cs new file mode 100644 index 0000000000..ec169fee9d --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IApiContainer.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IApiContainer + { + Dictionary Libraries { get; set; } + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IComm.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IComm.cs new file mode 100644 index 0000000000..9ef8a5e0c0 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IComm.cs @@ -0,0 +1,35 @@ +namespace BizHawk.Client.ApiHawk +{ + public interface IComm : IExternalApi + { + #region Sockets + string SocketServerScreenShot(); + string SocketServerScreenShotResponse(); + string SocketServerSend(string SendString); + string SocketServerResponse(); + bool SocketServerSuccessful(); + void SocketServerSetTimeout(int timeout); + #endregion + + #region MemoryMappedFiles + void MmfSetFilename(string filename); + string MmfSetFilename(); + int MmfScreenshot(); + int MmfWrite(string mmf_filename, string outputString); + string MmfRead(string mmf_filename, int expectedSize); + #endregion + + #region HTTP + string HttpTest(); + string HttpTestGet(); + string HttpGet(string url); + string HttpPost(string url, string payload); + string HttpPostScreenshot(); + void HttpSetTimeout(int timeout); + void HttpSetPostUrl(string url); + void HttpSetGetUrl(string url); + string HttpGetPostUrl(); + string HttpGetGetUrl(); + #endregion + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IEmu.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IEmu.cs new file mode 100644 index 0000000000..51136126ac --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IEmu.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IEmu : IExternalApi + { + Action FrameAdvanceCallback { get; set; } + Action YieldCallback { get; set; } + void DisplayVsync(bool enabled); + void FrameAdvance(); + int FrameCount(); + object Disassemble(uint pc, string name = ""); + ulong? GetRegister(string name); + Dictionary GetRegisters(); + void SetRegister(string register, int value); + long TotalExecutedycles(); + string GetSystemId(); + bool IsLagged(); + void SetIsLagged(bool value = true); + int LagCount(); + void SetLagCount(int count); + void LimitFramerate(bool enabled); + void MinimizeFrameskip(bool enabled); + void Yield(); + string GetDisplayType(); + string GetBoardName(); + object GetSettings(); + bool PutSettings(object settings); + void SetRenderPlanes(params bool[] param); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IExternalApi.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IExternalApi.cs new file mode 100644 index 0000000000..8dc7c9da03 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IExternalApi.cs @@ -0,0 +1,10 @@ +namespace BizHawk.Client.ApiHawk +{ + /// + /// This interface specifies that a client exposes a given interface, such as , + /// for use by external tools. + /// + public interface IExternalApi + { + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IGameInfo.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IGameInfo.cs new file mode 100644 index 0000000000..814a6d268c --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IGameInfo.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IGameInfo : IExternalApi + { + string GetRomName(); + string GetRomHash(); + bool InDatabase(); + string GetStatus(); + bool IsStatusBad(); + string GetBoardType(); + Dictionary GetOptions(); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IGui.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IGui.cs new file mode 100644 index 0000000000..03e3247e51 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IGui.cs @@ -0,0 +1,51 @@ +using System.Drawing; +using System.Drawing.Imaging; +using System.Windows.Forms; + +namespace BizHawk.Client.ApiHawk +{ + public interface IGui : IExternalApi + { + #region Gui API + void ToggleCompositingMode(); + ImageAttributes GetAttributes(); + void SetAttributes(ImageAttributes a); + void DrawNew(string name, bool? clear = true); + void DrawFinish(); + bool HasGUISurface { get; } + #endregion + + #region Helpers + void SetPadding(int all); + void SetPadding(int x, int y); + void SetPadding(int l, int t, int r, int b); + Padding GetPadding(); + #endregion + + void AddMessage(string message); + void ClearGraphics(); + void ClearText(); + void SetDefaultForegroundColor(Color color); + void SetDefaultBackgroundColor(Color color); + void SetDefaultTextBackground(Color color); + void SetDefaultPixelFont(string fontfamily); + void DrawBezier(Point p1, Point p2, Point p3, Point p4, Color? color = null); + void DrawBeziers(Point[] points, Color? color = null); + void DrawBox(int x, int y, int x2, int y2, Color? line = null, Color? background = null); + void DrawEllipse(int x, int y, int width, int height, Color? line = null, Color? background = null); + void DrawIcon(string path, int x, int y, int? width = null, int? height = null); + void DrawImage(string path, int x, int y, int? width = null, int? height = null, bool cache = true); + void ClearImageCache(); + void DrawImageRegion(string path, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int? dest_width = null, int? dest_height = null); + void DrawLine(int x1, int y1, int x2, int y2, Color? color = null); + void DrawAxis(int x, int y, int size, Color? color = null); + void DrawPie(int x, int y, int width, int height, int startangle, int sweepangle, Color? line = null, Color? background = null); + void DrawPixel(int x, int y, Color? color = null); + void DrawPolygon(Point[] points, Color? line = null, Color? background = null); + void DrawRectangle(int x, int y, int width, int height, Color? line = null, Color? background = null); + void DrawString(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, int? fontsize = null, + string fontfamily = null, string fontstyle = null, string horizalign = null, string vertalign = null); + void DrawText(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, string fontfamily = null); + void Text(int x, int y, string message, Color? forecolor = null, string anchor = null); + } +} \ No newline at end of file diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IInput.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IInput.cs new file mode 100644 index 0000000000..507bb024bf --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IInput.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IInput : IExternalApi + { + Dictionary Get(); + Dictionary GetMouse(); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IJoypad.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IJoypad.cs new file mode 100644 index 0000000000..1a8ce3340a --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IJoypad.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IJoypad : IExternalApi + { + Dictionary Get(int? controller = null); + + // TODO: what about float controls? + Dictionary GetImmediate(); + void SetFromMnemonicStr(string inputLogEntry); + void Set(Dictionary buttons, int? controller = null); + void Set(string button, bool? state = null, int? controller = null); + void SetAnalog(Dictionary controls, object controller = null); + void SetAnalog(string control, float? value = null, object controller = null); + + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IMem.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IMem.cs new file mode 100644 index 0000000000..7c8961ac5f --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IMem.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IMem : IExternalApi + { + void SetBigEndian(bool enabled = true); + + #region Domains + List GetMemoryDomainList(); + uint GetMemoryDomainSize(string name = ""); + string GetCurrentMemoryDomain(); + uint GetCurrentMemoryDomainSize(); + bool UseMemoryDomain(string domain); + string HashRegion(long addr, int count, string domain = null); + #endregion + #region Read + #region Special and Legacy Methods + uint ReadByte(long addr, string domain = null); + List ReadByteRange(long addr, int length, string domain = null); + float ReadFloat(long addr, string domain = null); + #endregion + #region Signed + int ReadS8(long addr, string domain = null); + int ReadS16(long addr, string domain = null); + int ReadS24(long addr, string domain = null); + int ReadS32(long addr, string domain = null); + #endregion + #region Unsigned + uint ReadU8(long addr, string domain = null); + uint ReadU16(long addr, string domain = null); + uint ReadU24(long addr, string domain = null); + uint ReadU32(long addr, string domain = null); + #endregion + #endregion + #region Write + #region Special and Legacy Methods + void WriteByte(long addr, uint value, string domain = null); + void WriteByteRange(long addr, List memoryblock, string domain = null); + void WriteFloat(long addr, double value, string domain = null); + #endregion + #region Signed + void WriteS8(long addr, int value, string domain = null); + void WriteS16(long addr, int value, string domain = null); + void WriteS24(long addr, int value, string domain = null); + void WriteS32(long addr, int value, string domain = null); + #endregion + #region Unigned + void WriteU8(long addr, uint value, string domain = null); + void WriteU16(long addr, uint value, string domain = null); + void WriteU24(long addr, uint value, string domain = null); + void WriteU32(long addr, uint value, string domain = null); + #endregion + #endregion + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IMemEvents.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IMemEvents.cs new file mode 100644 index 0000000000..b8650a9139 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IMemEvents.cs @@ -0,0 +1,12 @@ +using System; + +namespace BizHawk.Client.ApiHawk +{ + public interface IMemEvents : IExternalApi + { + void AddReadCallback(Action cb, uint address, string domain); + void AddWriteCallback(Action cb, uint address, string domain); + void AddExecCallback(Action cb, uint address, string domain); + void RemoveMemoryCallback(Action cb); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IMemorySavestate.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IMemorySavestate.cs new file mode 100644 index 0000000000..e3444c7bb5 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IMemorySavestate.cs @@ -0,0 +1,10 @@ +namespace BizHawk.Client.ApiHawk +{ + public interface IMemorySaveState : IExternalApi + { + string SaveCoreStateToMemory(); + void LoadCoreStateFromMemory(string identifier); + void DeleteState(string identifier); + void ClearInMemoryStates(); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IMovie.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IMovie.cs new file mode 100644 index 0000000000..c983ec1df1 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IMovie.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +namespace BizHawk.Client.ApiHawk +{ + public interface IMovie : IExternalApi + { + bool StartsFromSavestate(); + bool StartsFromSaveram(); + string Filename(); + Dictionary GetInput(int frame); + string GetInputAsMnemonic(int frame); + bool GetReadOnly(); + ulong GetRerecordCount(); + bool GetRerecordCounting(); + bool IsLoaded(); + double Length(); + string Mode(); + void Save(string filename = ""); + void SetReadOnly(bool readOnly); + void SetRerecordCount(double count); + void SetRerecordCounting(bool counting); + void Stop(); + double GetFps(); + Dictionary GetHeader(); + List GetComments(); + List GetSubtitles(); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/ISaveState.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/ISaveState.cs new file mode 100644 index 0000000000..8f595610fe --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/ISaveState.cs @@ -0,0 +1,10 @@ +namespace BizHawk.Client.ApiHawk +{ + public interface ISaveState : IExternalApi + { + void Load(string path); + void LoadSlot(int slotNum); + void Save(string path); + void SaveSlot(int slotNum); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/ISql.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/ISql.cs new file mode 100644 index 0000000000..99407ac1c2 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/ISql.cs @@ -0,0 +1,10 @@ +namespace BizHawk.Client.ApiHawk +{ + public interface ISql : IExternalApi + { + string CreateDatabase(string name); + string OpenDatabase(string name); + string WriteCommand(string query = ""); + dynamic ReadCommand(string query = ""); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/ITool.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/ITool.cs new file mode 100644 index 0000000000..ce4cdce516 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/ITool.cs @@ -0,0 +1,16 @@ +using System; +namespace BizHawk.Client.ApiHawk +{ + public interface ITool : IExternalApi + { + Type GetTool(string name); + object CreateInstance(string name); + void OpenCheats(); + void OpenHexEditor(); + void OpenRamWatch(); + void OpenRamSearch(); + void OpenTasStudio(); + void OpenToolBox(); + void OpenTraceLogger(); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IUserData.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IUserData.cs new file mode 100644 index 0000000000..234a7d4695 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IUserData.cs @@ -0,0 +1,11 @@ +namespace BizHawk.Client.ApiHawk +{ + public interface IUserData : IExternalApi + { + void Set(string name, object value); + object Get(string key); + void Clear(); + bool Remove(string key); + bool ContainsKey(string key); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/IExternalApiProvider.cs b/BizHawk.Client.ApiHawk/Interfaces/IExternalApiProvider.cs new file mode 100644 index 0000000000..d44299f7b1 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/IExternalApiProvider.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + /// + /// This interface defines the mechanism by which External tools can retrieve + /// from a client implementation + /// An implementation should collect all available IExternalApi instances. + /// This interface defines only the external interaction. This interface does not specify the means + /// by which a api provider will be populated with available apis. However, an implementation + /// by design must provide this mechanism + /// + /// + public interface IExternalApiProvider + { + /// e + /// Returns whether or not T is available + /// + /// The to check + bool HasApi() where T : IExternalApi; + + /// + /// Returns whether or not t is available + /// + bool HasApi(Type t); + + /// + /// Returns an instance of T if T is available + /// Else returns null + /// + /// The requested + T GetApi() where T : IExternalApi; + + /// + /// Returns an instance of t if t is available + /// Else returns null + /// + object GetApi(Type t); + + /// + /// Gets a list of all currently registered Apis available to be retrieved + /// + IEnumerable AvailableApis { get; } + } +} diff --git a/BizHawk.Client.Common/plugins/IPlugin.cs b/BizHawk.Client.ApiHawk/Interfaces/IPlugin.cs similarity index 73% rename from BizHawk.Client.Common/plugins/IPlugin.cs rename to BizHawk.Client.ApiHawk/Interfaces/IPlugin.cs index 9220e90dbd..444ecec8b2 100644 --- a/BizHawk.Client.Common/plugins/IPlugin.cs +++ b/BizHawk.Client.ApiHawk/Interfaces/IPlugin.cs @@ -1,4 +1,4 @@ -namespace BizHawk.Client.Common +namespace BizHawk.Client.ApiHawk { interface IPlugin { @@ -7,6 +7,6 @@ void SaveStateCallback(string name); void LoadStateCallback(string name); void InputPollCallback(); - void Init(IPluginAPI api); + void Init(IApiContainer api); } } diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index f3bcc12f20..84c1eed24d 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -260,6 +260,7 @@ + diff --git a/BizHawk.Client.EmuHawk/OpenAdvanced.cs b/BizHawk.Client.Common/OpenAdvanced.cs similarity index 94% rename from BizHawk.Client.EmuHawk/OpenAdvanced.cs rename to BizHawk.Client.Common/OpenAdvanced.cs index 9a9cfc1c91..b26bff967e 100644 --- a/BizHawk.Client.EmuHawk/OpenAdvanced.cs +++ b/BizHawk.Client.Common/OpenAdvanced.cs @@ -10,7 +10,7 @@ using Newtonsoft.Json; //this file contains some cumbersome self-"serialization" in order to gain a modicum of control over what the serialized output looks like //I don't want them to look like crufty json -namespace BizHawk.Client.EmuHawk +namespace BizHawk.Client.Common { public interface IOpenAdvanced { @@ -74,7 +74,7 @@ namespace BizHawk.Client.EmuHawk } } - class OpenAdvanced_Libretro : IOpenAdvanced, IOpenAdvancedLibretro + public class OpenAdvanced_Libretro : IOpenAdvanced, IOpenAdvancedLibretro { public OpenAdvanced_Libretro() { @@ -103,7 +103,7 @@ namespace BizHawk.Client.EmuHawk public string CorePath { get { return token.CorePath; } set { token.CorePath = value; } } } - class OpenAdvanced_LibretroNoGame : IOpenAdvanced, IOpenAdvancedLibretro + public class OpenAdvanced_LibretroNoGame : IOpenAdvanced, IOpenAdvancedLibretro { //you might think ideally we'd fetch the libretro core name from the core info inside it //but that would involve spinning up excess libretro core instances, which probably isnt good for stability, no matter how much we wish otherwise, not to mention slow. @@ -140,7 +140,7 @@ namespace BizHawk.Client.EmuHawk public string CorePath { get { return _corePath; } set { _corePath = value; } } } - class OpenAdvanced_OpenRom : IOpenAdvanced + public class OpenAdvanced_OpenRom : IOpenAdvanced { public OpenAdvanced_OpenRom() {} diff --git a/BizHawk.Client.Common/plugins/IPluginAPI.cs b/BizHawk.Client.Common/plugins/IPluginAPI.cs deleted file mode 100644 index 175df3af92..0000000000 --- a/BizHawk.Client.Common/plugins/IPluginAPI.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace BizHawk.Client.Common -{ - public interface IPluginAPI - { - EmulatorPluginLibrary EmuLib { get; } - GameInfoPluginLibrary GameInfoLib { get; } - GUIDrawPluginBase GUILib { get; } - JoypadPluginLibrary JoypadLib { get; } - MemoryPluginLibrary MemLib { get; } - MemoryEventsPluginLibrary MemEventsLib { get; } - MemorySavestatePluginLibrary MemStateLib { get; } - MoviePluginLibrary MovieLib { get; } - SQLPluginLibrary SQLLib { get; } - UserDataPluginLibrary UserDataLib { get; } - Dictionary Libraries { get; } - } -} diff --git a/BizHawk.Client.Common/plugins/PluginLibrary.Movie.cs b/BizHawk.Client.Common/plugins/PluginLibrary.Movie.cs deleted file mode 100644 index ac9552d9cd..0000000000 --- a/BizHawk.Client.Common/plugins/PluginLibrary.Movie.cs +++ /dev/null @@ -1,263 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; - -namespace BizHawk.Client.Common -{ - public sealed class MoviePluginLibrary : PluginLibraryBase - { - public MoviePluginLibrary() : base() - { } - - [LuaMethodExample("if ( movie.startsfromsavestate( ) ) then\r\n\tconsole.log( \"Returns whether or not the movie is a savestate-anchored movie\" );\r\nend;")] - [LuaMethod("startsfromsavestate", "Returns whether or not the movie is a savestate-anchored movie")] - public bool StartsFromSavestate() - { - return Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSavestate; - } - - [LuaMethodExample("if ( movie.startsfromsaveram( ) ) then\r\n\tconsole.log( \"Returns whether or not the movie is a saveram-anchored movie\" );\r\nend;")] - [LuaMethod("startsfromsaveram", "Returns whether or not the movie is a saveram-anchored movie")] - public bool StartsFromSaveram() - { - return Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSaveRam; - } - - [LuaMethodExample("local stmovfil = movie.filename( );")] - [LuaMethod("filename", "Returns the file name including path of the currently loaded movie")] - public static string Filename() - { - return Global.MovieSession.Movie.Filename; - } - - [LuaMethodExample("local nlmovget = movie.getinput( 500 );")] - [LuaMethod("getinput", "Returns a table of buttons pressed on a given frame of the loaded movie")] - public Dictionary GetInput(int frame) - { - if (!Global.MovieSession.Movie.IsActive) - { - Console.WriteLine("No movie loaded"); - return null; - } - - var input = new Dictionary(); - var adapter = Global.MovieSession.Movie.GetInputState(frame); - - if (adapter == null) - { - Console.WriteLine("Can't get input of the last frame of the movie. Use the previous frame"); - return null; - } - - foreach (var button in adapter.Definition.BoolButtons) - { - input[button] = adapter.IsPressed(button); - } - - foreach (var button in adapter.Definition.FloatControls) - { - input[button] = adapter.GetFloat(button); - } - - return input; - } - - [LuaMethodExample("local stmovget = movie.getinputasmnemonic( 500 );")] - [LuaMethod("getinputasmnemonic", "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) - { - var lg = Global.MovieSession.LogGeneratorInstance(); - lg.SetSource(Global.MovieSession.Movie.GetInputState(frame)); - return lg.GenerateLogEntry(); - } - - return ""; - } - - [LuaMethodExample("if ( movie.getreadonly( ) ) then\r\n\tconsole.log( \"Returns true if the movie is in read-only mode, false if in read+write\" );\r\nend;")] - [LuaMethod("getreadonly", "Returns true if the movie is in read-only mode, false if in read+write")] - public static bool GetReadOnly() - { - return Global.MovieSession.ReadOnly; - } - - [LuaMethodExample("local ulmovget = movie.getrerecordcount();")] - [LuaMethod("getrerecordcount", "Gets the rerecord count of the current movie.")] - public static ulong GetRerecordCount() - { - return Global.MovieSession.Movie.Rerecords; - } - - [LuaMethodExample("if ( movie.getrerecordcounting( ) ) then\r\n\tconsole.log( \"Returns whether or not the current movie is incrementing rerecords on loadstate\" );\r\nend;")] - [LuaMethod("getrerecordcounting", "Returns whether or not the current movie is incrementing rerecords on loadstate")] - public static bool GetRerecordCounting() - { - return Global.MovieSession.Movie.IsCountingRerecords; - } - - [LuaMethodExample("if ( movie.isloaded( ) ) then\r\n\tconsole.log( \"Returns true if a movie is loaded in memory ( play, record, or finished modes ), false if not ( inactive mode )\" );\r\nend;")] - [LuaMethod("isloaded", "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; - } - - [LuaMethodExample("local domovlen = movie.length( );")] - [LuaMethod("length", "Returns the total number of frames of the loaded movie")] - public static double Length() - { - return Global.MovieSession.Movie.FrameCount; - } - - [LuaMethodExample("local stmovmod = movie.mode( );")] - [LuaMethod("mode", "Returns the mode of the current movie. Possible modes: \"PLAY\", \"RECORD\", \"FINISHED\", \"INACTIVE\"")] - public static string Mode() - { - if (Global.MovieSession.Movie.IsFinished) - { - return "FINISHED"; - } - - if (Global.MovieSession.Movie.IsPlaying) - { - return "PLAY"; - } - - if (Global.MovieSession.Movie.IsRecording) - { - return "RECORD"; - } - - return "INACTIVE"; - } - - [LuaMethodExample("movie.save( \"C:\\moviename.ext\" );")] - [LuaMethod("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.")] - public void Save(string filename = "") - { - if (!Global.MovieSession.Movie.IsActive) - { - return; - } - - if (!string.IsNullOrEmpty(filename)) - { - filename += "." + Global.MovieSession.Movie.PreferredExtension; - var test = new FileInfo(filename); - if (test.Exists) - { - Console.WriteLine($"File {filename} already exists, will not overwrite"); - return; - } - - Global.MovieSession.Movie.Filename = filename; - } - - Global.MovieSession.Movie.Save(); - } - - [LuaMethodExample("movie.setreadonly( false );")] - [LuaMethod("setreadonly", "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; - } - - [LuaMethodExample("movie.setrerecordcount( 20.0 );")] - [LuaMethod("setrerecordcount", "Sets the rerecord count of the current movie.")] - public static void SetRerecordCount(double count) - { - // Lua numbers are always double, integer precision holds up - // to 53 bits, so throw an error if it's bigger than that. - const double PrecisionLimit = 9007199254740992d; - - if (count > PrecisionLimit) - { - throw new Exception("Rerecord count exceeds Lua integer precision."); - } - - Global.MovieSession.Movie.Rerecords = (ulong)count; - } - - [LuaMethodExample("movie.setrerecordcounting( true );")] - [LuaMethod("setrerecordcounting", "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; - } - - [LuaMethodExample("movie.stop( );")] - [LuaMethod("stop", "Stops the current movie")] - public static void Stop() - { - Global.MovieSession.Movie.Stop(); - } - - [LuaMethodExample("local domovget = movie.getfps( );")] - [LuaMethod("getfps", "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) - { - var movie = Global.MovieSession.Movie; - var system = movie.HeaderEntries[HeaderKeys.PLATFORM]; - var pal = movie.HeaderEntries.ContainsKey(HeaderKeys.PAL) && - movie.HeaderEntries[HeaderKeys.PAL] == "1"; - - return new PlatformFrameRates()[system, pal]; - } - - return 0.0; - } - - [LuaMethodExample("local nlmovget = movie.getheader( );")] - [LuaMethod("getheader", "If a movie is active, will return the movie header as a lua table")] - public Dictionary GetHeader() - { - var table = new Dictionary(); - if (Global.MovieSession.Movie.IsActive) - { - foreach (var kvp in Global.MovieSession.Movie.HeaderEntries) - { - table[kvp.Key] = kvp.Value; - } - } - - return table; - } - - [LuaMethodExample("local nlmovget = movie.getcomments( );")] - [LuaMethod("getcomments", "If a movie is active, will return the movie comments as a lua table")] - public List GetComments() - { - var list = new List(Global.MovieSession.Movie.Comments.Count); - if (Global.MovieSession.Movie.IsActive) - { - for (int i = 0; i < Global.MovieSession.Movie.Comments.Count; i++) - { - list[i] = Global.MovieSession.Movie.Comments[i]; - } - } - - return list; - } - - [LuaMethodExample("local nlmovget = movie.getsubtitles( );")] - [LuaMethod("getsubtitles", "If a movie is active, will return the movie subtitles as a lua table")] - public List GetSubtitles() - { - var list = new List(Global.MovieSession.Movie.Subtitles.Count); - if (Global.MovieSession.Movie.IsActive) - { - for (int i = 0; i < Global.MovieSession.Movie.Subtitles.Count; i++) - { - list[i] = Global.MovieSession.Movie.Subtitles[i].ToString(); - } - } - - return list; - } - } -} diff --git a/BizHawk.Client.Common/plugins/PluginLibraryBase.cs b/BizHawk.Client.Common/plugins/PluginLibraryBase.cs deleted file mode 100644 index 17485c7103..0000000000 --- a/BizHawk.Client.Common/plugins/PluginLibraryBase.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Drawing; - -namespace BizHawk.Client.Common -{ - public abstract class PluginLibraryBase - { - protected PluginLibraryBase() { } - - protected static Color? ToColor(object o) - { - if (o == null) - { - return null; - } - - if (o.GetType() == typeof(double)) - { - return Color.FromArgb((int)(long)(double)o); - } - - if (o.GetType() == typeof(string)) - { - return Color.FromName(o.ToString()); - } - - return null; - } - } -} diff --git a/BizHawk.Client.EmuHawk/Api/ApiContainer.cs b/BizHawk.Client.EmuHawk/Api/ApiContainer.cs new file mode 100644 index 0000000000..6a7b7102a3 --- /dev/null +++ b/BizHawk.Client.EmuHawk/Api/ApiContainer.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Linq; + +using BizHawk.Client.ApiHawk; + +namespace BizHawk.Client.EmuHawk +{ + public sealed class ApiContainer : IApiContainer + { + public IComm Comm => (IComm)Libraries[typeof(CommApi)]; + public IEmu Emu => (IEmu)Libraries[typeof(EmuApi)]; + public IGameInfo GameInfo => (IGameInfo)Libraries[typeof(GameInfoApi)]; + public IGui Gui => (IGui)Libraries[typeof(GuiApi)]; + public IInput Input => (IInput)Libraries[typeof(InputApi)]; + public IJoypad Joypad => (IJoypad)Libraries[typeof(JoypadApi)]; + public IMem Mem => (IMem)Libraries[typeof(MemApi)]; + public IMemEvents MemEvents => (IMemEvents)Libraries[typeof(MemEventsApi)]; + public IMemorySaveState MemorySaveState => (IMemorySaveState)Libraries[typeof(MemorySaveStateApi)]; + public IMovie Movie => (IMovie)Libraries[typeof(MovieApi)]; + public ISaveState SaveState => (ISaveState)Libraries[typeof(SaveStateApi)]; + public ISql Sql => (ISql)Libraries[typeof(SqlApi)]; + public ITool Tool => (ITool)Libraries[typeof(ToolApi)]; + public IUserData UserData => (IUserData)Libraries[typeof(UserDataApi)]; + public Dictionary Libraries { get; set; } + public ApiContainer(Dictionary libs) + { + Libraries = libs; + } + } +} diff --git a/BizHawk.Client.EmuHawk/Plugins/Example/Ecco2AssistantPlugin.cs b/BizHawk.Client.EmuHawk/Api/Example/Ecco2AssistantPlugin.cs similarity index 51% rename from BizHawk.Client.EmuHawk/Plugins/Example/Ecco2AssistantPlugin.cs rename to BizHawk.Client.EmuHawk/Api/Example/Ecco2AssistantPlugin.cs index e7ed248bfb..8764258e3d 100644 --- a/BizHawk.Client.EmuHawk/Plugins/Example/Ecco2AssistantPlugin.cs +++ b/BizHawk.Client.EmuHawk/Api/Example/Ecco2AssistantPlugin.cs @@ -4,13 +4,31 @@ using System.Globalization; using System.Drawing; using System.Linq; -using BizHawk.Client.Common; +using BizHawk.Client.ApiHawk; using BizHawk.Emulation.Cores.Consoles.Sega.gpgx; namespace BizHawk.Client.EmuHawk { public sealed class Ecco2AssistantPlugin : PluginBase { + [RequiredApi] + private IMem Mem {get; set;} + + [RequiredApi] + private IGui Gui { get; set; } + + [RequiredApi] + private IJoypad Joy { get; set; } + + [RequiredApi] + private IEmu Emu { get; set; } + + [RequiredApi] + private IGameInfo GI { get; set; } + + [RequiredApi] + private IMemorySaveState MemSS { get; set; } + public override string Name => "Ecco 2 Assistant"; public override string Description => "Displays a hud with hitboxes, etc. Assists with maintaining maximum speed."; @@ -36,7 +54,6 @@ namespace BizHawk.Client.EmuHawk private int _destY = 0; private int _snapPast = 0; private string _rowStateGuid = string.Empty; - private EmuHawkPluginLibrary _clientLib; private Color[] _turnSignalColors = { Color.FromArgb(_signalAlpha, 127, 127, 0), @@ -53,7 +70,7 @@ namespace BizHawk.Client.EmuHawk { if (refresh) { - _rseed = (int)(_api.MemLib.ReadU16(0xFFE2F8)); + _rseed = (int)(Mem.ReadU16(0xFFE2F8)); } bool odd = (_rseed & 1) != 0; _rseed >>= 1; @@ -73,7 +90,7 @@ namespace BizHawk.Client.EmuHawk }; Color? fillColor = null; if (fillAlpha > 0) fillColor = Color.FromArgb(fillAlpha, color); - _api.GUILib.DrawPolygon(rhombus, color, fillColor); + Gui.DrawPolygon(rhombus, color, fillColor); } private void DrawEccoRhomb_scaled(int x, int y, int width, int height, int rscale, int bscale, int lscale, int tscale, Color color, int fillAlpha = 63) { @@ -85,7 +102,7 @@ namespace BizHawk.Client.EmuHawk }; Color? fillColor = null; if (fillAlpha > 0) fillColor = Color.FromArgb(fillAlpha, color); - _api.GUILib.DrawPolygon(rhombus, color, fillColor); + Gui.DrawPolygon(rhombus, color, fillColor); } private void DrawEccoOct(int x, int y, int r, Color color, int fillAlpha = 63) { @@ -102,7 +119,7 @@ namespace BizHawk.Client.EmuHawk }; Color? fillColor = null; if (fillAlpha > 0) fillColor = Color.FromArgb(fillAlpha, color); - _api.GUILib.DrawPolygon(octagon, color, fillColor); + Gui.DrawPolygon(octagon, color, fillColor); } private void DrawEccoOct_scaled(int x, int y, int xscale, int yscale, int r, Color color, int fillAlpha = 63) { @@ -123,7 +140,7 @@ namespace BizHawk.Client.EmuHawk }; Color? fillColor = null; if (fillAlpha > 0) fillColor = Color.FromArgb(fillAlpha, color); - _api.GUILib.DrawPolygon(octagon, color, fillColor); + Gui.DrawPolygon(octagon, color, fillColor); } private Point? Intersection(Point start1, Point end1, Point start2, Point end2) { @@ -203,7 +220,7 @@ namespace BizHawk.Client.EmuHawk my /= finalShape.ToArray().Length; Color? fillColor = null; if (fillAlpha > 0) fillColor = Color.FromArgb(fillAlpha, color); - _api.GUILib.DrawPolygon(finalShape.OrderBy(p => Math.Atan2(p.Y - my, p.X - mX)).ToArray(), color, fillColor); + Gui.DrawPolygon(finalShape.OrderBy(p => Math.Atan2(p.Y - my, p.X - mX)).ToArray(), color, fillColor); } private void DrawEccoTriangle(int x1, int y1, int x2, int y2, int x3, int y3, Color color, int fillAlpha = 63) { @@ -215,23 +232,23 @@ namespace BizHawk.Client.EmuHawk new Point(x3, y3) }; if (fillAlpha > 0) fillColor = Color.FromArgb(fillAlpha, color); - _api.GUILib.DrawPolygon(triPoints, color, fillColor); + Gui.DrawPolygon(triPoints, color, fillColor); } private void DrawBoxMWH(int x, int y, int w, int h, Color color, int fillAlpha = 63) { Color? fillColor = null; if (fillAlpha > 0) fillColor = Color.FromArgb(fillAlpha, color); - _api.GUILib.DrawRectangle(x - w, y - h, w << 1, h << 1, color, fillColor); + Gui.DrawRectangle(x - w, y - h, w << 1, h << 1, color, fillColor); } private void DrawBox(int x, int y, int x2, int y2, Color color, int fillAlpha = 63) { Color? fillColor = null; if (fillAlpha > 0) fillColor = Color.FromArgb(fillAlpha, color); - _api.GUILib.DrawBox(x, y, x2, y2, color, fillColor); + Gui.DrawBox(x, y, x2, y2, color, fillColor); } private void Print_Text(string message, int x, int y, Color color) { - _api.GUILib.DrawText(x, y, message, color, null); + Gui.DrawText(x, y, message, color, null); } private void PutText(string message, int x, int y, int xl, int yl, int xh, int yh, Color bg, Color fg) { @@ -253,24 +270,24 @@ namespace BizHawk.Client.EmuHawk private void TickerText(string message, Color? fg = null) { if (_dumpMap == 0) - _api.GUILib.Text(1, _tickerY, message, fg); + Gui.Text(1, _tickerY, message, fg); _tickerY += 16; } private void EccoDraw3D() { - int CamX = (_api.MemLib.ReadS32(0xFFD5E0) >> 0xC) - _left; - int CamY = (_api.MemLib.ReadS32(0xFFD5E8) >> 0xC) + _top; - int CamZ = (_api.MemLib.ReadS32(0xFFD5E4) >> 0xC) + _top; - uint curObj = _api.MemLib.ReadU24(0xFFD4C1); + int CamX = (Mem.ReadS32(0xFFD5E0) >> 0xC) - _left; + int CamY = (Mem.ReadS32(0xFFD5E8) >> 0xC) + _top; + int CamZ = (Mem.ReadS32(0xFFD5E4) >> 0xC) + _top; + uint curObj = Mem.ReadU24(0xFFD4C1); while (curObj != 0) { - int Xpos = (_api.MemLib.ReadS32(curObj + 0x6) >> 0xC); - int Ypos = (_api.MemLib.ReadS32(curObj + 0xE) >> 0xC); - int Zpos = (_api.MemLib.ReadS32(curObj + 0xA) >> 0xC); + int Xpos = (Mem.ReadS32(curObj + 0x6) >> 0xC); + int Ypos = (Mem.ReadS32(curObj + 0xE) >> 0xC); + int Zpos = (Mem.ReadS32(curObj + 0xA) >> 0xC); int Xmid = 160 + (Xpos - CamX); int Ymid = 112 - (Ypos - CamY); int Zmid = _top + 112 - (Zpos - CamZ); - uint type = _api.MemLib.ReadU32(curObj + 0x5A); + uint type = Mem.ReadU32(curObj + 0x5A); int width, height, depth = height = width = 0; if (type == 0xD4AB8) // 3D poison Bubble { @@ -285,23 +302,23 @@ namespace BizHawk.Client.EmuHawk else if (type == 0xD817E)// 3D Ring { depth = 8; - if (_api.MemLib.ReadU32(0xFFB166) < 0x1800) depth = 4; + if (Mem.ReadU32(0xFFB166) < 0x1800) depth = 4; int radius = 32; width = radius; - DrawEccoOct(Xmid, Ymid, radius, (_api.MemLib.ReadS16(curObj + 0x62) == 0) ? Color.Orange : Color.Gray); + DrawEccoOct(Xmid, Ymid, radius, (Mem.ReadS16(curObj + 0x62) == 0) ? Color.Orange : Color.Gray); DrawBoxMWH(Xmid, Zmid, width, depth, Color.Red); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Orange, 0); DrawBoxMWH(Xmid, Zmid, 1, 1, Color.Red, 0); - TickerText($"{_api.MemLib.ReadS32(curObj + 0x6) / 4096.0:0.######}:{_api.MemLib.ReadS32(curObj + 0xE) / 4096.0:0.######}:{_api.MemLib.ReadS32(curObj + 0xA) / 2048.0:0.######}:{_api.MemLib.ReadByte(curObj + 0x72)}",Color.Lime); + TickerText($"{Mem.ReadS32(curObj + 0x6) / 4096.0:0.######}:{Mem.ReadS32(curObj + 0xE) / 4096.0:0.######}:{Mem.ReadS32(curObj + 0xA) / 2048.0:0.######}:{Mem.ReadByte(curObj + 0x72)}",Color.Lime); } else if (type == 0xD49CC) // Vines collisions are based on draw position, which is a fucking pain in the ass to calculate { - int Xvel = (_api.MemLib.ReadS32(curObj + 0x3A) - _api.MemLib.ReadS32(curObj + 0x6)); - int Zvel = (_api.MemLib.ReadS32(curObj + 0x3E) - _api.MemLib.ReadS32(curObj + 0xA)); - int dx = _api.MemLib.ReadS32(0xFFD5E0) - _api.MemLib.ReadS32(0xFFD5C8) >> 3; - int dy = _api.MemLib.ReadS32(0xFFD5E8) - _api.MemLib.ReadS32(0xFFD600) >> 3; - int dz = _api.MemLib.ReadS32(0xFFD5E4) - _api.MemLib.ReadS32(0xFFD5CC); - var chargeCount = _api.MemLib.ReadByte(0xFFB19B); + int Xvel = (Mem.ReadS32(curObj + 0x3A) - Mem.ReadS32(curObj + 0x6)); + int Zvel = (Mem.ReadS32(curObj + 0x3E) - Mem.ReadS32(curObj + 0xA)); + int dx = Mem.ReadS32(0xFFD5E0) - Mem.ReadS32(0xFFD5C8) >> 3; + int dy = Mem.ReadS32(0xFFD5E8) - Mem.ReadS32(0xFFD600) >> 3; + int dz = Mem.ReadS32(0xFFD5E4) - Mem.ReadS32(0xFFD5CC); + var chargeCount = Mem.ReadByte(0xFFB19B); if (chargeCount == 0) { dz >>= 2; @@ -314,7 +331,7 @@ namespace BizHawk.Client.EmuHawk { dz >>= 4; } - if (_api.MemLib.ReadByte(curObj + 0x64) == 0) + if (Mem.ReadByte(curObj + 0x64) == 0) { Xvel >>= 0xA; Zvel >>= 9; @@ -324,21 +341,21 @@ namespace BizHawk.Client.EmuHawk Xvel >>= 9; Zvel >>= 0xA; } - Xvel += _api.MemLib.ReadS32(curObj + 0x2E); - Zvel += _api.MemLib.ReadS32(curObj + 0x32); - Zpos = (_api.MemLib.ReadS32(curObj + 0x26) + dz - _api.MemLib.ReadS32(0xFFD5E4)) >> 0xB; + Xvel += Mem.ReadS32(curObj + 0x2E); + Zvel += Mem.ReadS32(curObj + 0x32); + Zpos = (Mem.ReadS32(curObj + 0x26) + dz - Mem.ReadS32(0xFFD5E4)) >> 0xB; if ((Zpos < 0x600) && (Zpos > 0)) { Zpos += 0x20; int Xcur, Xmax, Ycur, Ymax; - int Zpos2 = (_api.MemLib.ReadS32(curObj + 0xA) + Zvel + dz - _api.MemLib.ReadS32(0xFFD5E4)) >> 0xB; + int Zpos2 = (Mem.ReadS32(curObj + 0xA) + Zvel + dz - Mem.ReadS32(0xFFD5E4)) >> 0xB; Zpos2 = Math.Max(Zpos2 + 0x20, 1); - if (_api.MemLib.ReadS16(curObj + 0x62) != 0) + if (Mem.ReadS16(curObj + 0x62) != 0) { - Xmid = _api.MemLib.ReadS32(curObj + 0x6) + dx + Xvel - _api.MemLib.ReadS32(0xFFD5E0); + Xmid = Mem.ReadS32(curObj + 0x6) + dx + Xvel - Mem.ReadS32(0xFFD5E0); if (Math.Abs(Xmid) > 0x400000) continue; - Xpos = _api.MemLib.ReadS32(curObj + 0x22) + dx - _api.MemLib.ReadS32(0xFFD5E0); + Xpos = Mem.ReadS32(curObj + 0x22) + dx - Mem.ReadS32(0xFFD5E0); if (Math.Abs(Xpos) > 0x400000) continue; Xcur = (Xmid << 2) / Zpos2 + (Xmid >> 5) + 0xA000 + (Xmid >> 5); @@ -349,9 +366,9 @@ namespace BizHawk.Client.EmuHawk Xcur = 0; Xmax = 256; } - Ymid = _api.MemLib.ReadS32(0xFFD5E8) + dy - _api.MemLib.ReadS32(curObj + 0xE); + Ymid = Mem.ReadS32(0xFFD5E8) + dy - Mem.ReadS32(curObj + 0xE); Ycur = ((Ymid << 3) / Zpos2) + 0x6000; - Ypos = _api.MemLib.ReadS32(0xFFD5E8) + dy - _api.MemLib.ReadS32(curObj + 0x2A); + Ypos = Mem.ReadS32(0xFFD5E8) + dy - Mem.ReadS32(curObj + 0x2A); Ymax = ((Ypos << 3) / Zpos) + 0x6000; dx = Xmax - Xcur; dy = Ymax - Ycur; @@ -423,8 +440,8 @@ namespace BizHawk.Client.EmuHawk } } } - Xcur += _api.MemLib.ReadS8(0x2CC8 + ang) << 6; - Ycur += _api.MemLib.ReadS8(0x2BC8 + ang) << 6; + Xcur += Mem.ReadS8(0x2CC8 + ang) << 6; + Ycur += Mem.ReadS8(0x2BC8 + ang) << 6; var dSml = Math.Abs(dx); var dBig = Math.Abs(dy); if (dBig < dSml) @@ -438,7 +455,7 @@ namespace BizHawk.Client.EmuHawk dx /= i; dy /= i; - Zmid = (_api.MemLib.ReadS32(curObj + 0xA) + _api.MemLib.ReadS32(curObj + 0x26)) >> 1; + Zmid = (Mem.ReadS32(curObj + 0xA) + Mem.ReadS32(curObj + 0x26)) >> 1; Zmid >>= 0xC; Zmid = 112 + _top - (Zmid - CamZ); do @@ -449,14 +466,14 @@ namespace BizHawk.Client.EmuHawk Xcur += dx; Ycur += dy; } while (i >= 0); - DrawBoxMWH((_api.MemLib.ReadS32(0xFFB1AA) >> 8) + _left, (_api.MemLib.ReadS32(0xFFB1AE) >> 8) + _top, 1, 1, Color.Lime, 0); + DrawBoxMWH((Mem.ReadS32(0xFFB1AA) >> 8) + _left, (Mem.ReadS32(0xFFB1AE) >> 8) + _top, 1, 1, Color.Lime, 0); } } else if ((type == 0xD3B40) || (type == 0xD3DB2)) // 3D Shark and Jellyfish { - width = (_api.MemLib.ReadS32(curObj + 0x12) >> 0xC); - height = (_api.MemLib.ReadS32(curObj + 0x1A) >> 0xC); - depth = (_api.MemLib.ReadS32(curObj + 0x16) >> 0xC); + width = (Mem.ReadS32(curObj + 0x12) >> 0xC); + height = (Mem.ReadS32(curObj + 0x1A) >> 0xC); + depth = (Mem.ReadS32(curObj + 0x16) >> 0xC); DrawBoxMWH(Xmid, Ymid, width, height, Color.Lime); DrawBoxMWH(Xmid, Zmid, width, depth, Color.Blue); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Lime, 0); @@ -502,7 +519,7 @@ namespace BizHawk.Client.EmuHawk DrawBoxMWH(Xmid, Zmid, 1, 1, Color.Red); } } - curObj = _api.MemLib.ReadU24(curObj+1); + curObj = Mem.ReadU24(curObj+1); } } private void EccoDrawBoxes() @@ -511,8 +528,8 @@ namespace BizHawk.Client.EmuHawk int Width2, Height2; //Ecco HP and Air int i = 0; - int HP = _api.MemLib.ReadS16(0xFFAA16) << 3; - int air = _api.MemLib.ReadS16(0xFFAA18); + int HP = Mem.ReadS16(0xFFAA16) << 3; + int air = Mem.ReadS16(0xFFAA18); Color color; int off = 0; for (int j = 0; j < air; j++) @@ -522,66 +539,66 @@ namespace BizHawk.Client.EmuHawk i++; off += 448; } color = Color.FromArgb(j >> 2, j >> 2, j >> 2); - _api.GUILib.DrawLine(_left - 32, j - off, _left - 17, j - off, color); + Gui.DrawLine(_left - 32, j - off, _left - 17, j - off, color); } for (int j = 0; j < HP; j += 8) { color = Color.FromArgb(Math.Max(0x38 - (j >> 3),0), 0, Math.Min(j >> 1,255)); - _api.GUILib.DrawRectangle(_left - 16, j, 15, 7, color, color); + Gui.DrawRectangle(_left - 16, j, 15, 7, color, color); } //Asterite - uint type = _api.MemLib.ReadU32(0xFFD440); + uint type = Mem.ReadU32(0xFFD440); uint curObj = 0; int Xpos, Xpos2, Ypos, Ypos2, Xmid, Ymid, X, X2, Y, Y2; Xpos = Ypos = Xpos2 = Ypos2 = Xmid = Ymid = X = X2 = Y = Y2 = 0; if (type == 0xB119A) { - curObj = _api.MemLib.ReadU24(_api.MemLib.ReadU24(0xFFD429)+5); + curObj = Mem.ReadU24(Mem.ReadU24(0xFFD429)+5); while (curObj != 0) { - Xpos = _api.MemLib.ReadS16(curObj + 0x3C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x24); - Ypos = _api.MemLib.ReadS16(curObj + 0x40); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x28); + Xpos = Mem.ReadS16(curObj + 0x3C); + Xpos2 = Mem.ReadS16(curObj + 0x24); + Ypos = Mem.ReadS16(curObj + 0x40); + Ypos2 = Mem.ReadS16(curObj + 0x28); Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid = (Xpos + Xpos2) >> 1; Ymid = (Ypos + Ypos2) >> 1; - if (_api.MemLib.ReadU8(curObj + 0x71) != 0) + if (Mem.ReadU8(curObj + 0x71) != 0) { DrawEccoOct(Xpos, Ypos, 48, Color.Blue, 16); DrawEccoOct(Xpos2, Ypos2, 48, Color.Blue, 16); } - curObj = _api.MemLib.ReadU24(curObj + 5); + curObj = Mem.ReadU24(curObj + 5); } - if ((_api.MemLib.ReadU8(0xFFA7D0) == 30)) + if ((Mem.ReadU8(0xFFA7D0) == 30)) { - curObj = _api.MemLib.ReadU24(0xFFD425); - if ((curObj != 0) && (_api.MemLib.ReadU32(curObj + 8) != 0)) + curObj = Mem.ReadU24(0xFFD425); + if ((curObj != 0) && (Mem.ReadU32(curObj + 8) != 0)) { - Xpos = _api.MemLib.ReadS16(curObj + 0x1C) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x20) - _camY; + Xpos = Mem.ReadS16(curObj + 0x1C) - _camX; + Ypos = Mem.ReadS16(curObj + 0x20) - _camY; DrawEccoOct(Xpos, Ypos, 20, Color.Orange); } } } else if (type == 0xB2CB8) { - curObj = _api.MemLib.ReadU24(_api.MemLib.ReadU24(0xFFD429) + 5); + curObj = Mem.ReadU24(Mem.ReadU24(0xFFD429) + 5); while (curObj != 0) { - Xpos = _api.MemLib.ReadS16(curObj + 0x3C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x24); - Ypos = _api.MemLib.ReadS16(curObj + 0x40); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x28); + Xpos = Mem.ReadS16(curObj + 0x3C); + Xpos2 = Mem.ReadS16(curObj + 0x24); + Ypos = Mem.ReadS16(curObj + 0x40); + Ypos2 = Mem.ReadS16(curObj + 0x28); Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid = (Xpos + Xpos2) >> 1; Ymid = (Ypos + Ypos2) >> 1; - if (_api.MemLib.ReadU8(curObj + 0x71) != 0) + if (Mem.ReadU8(curObj + 0x71) != 0) { - if (_api.MemLib.ReadByte(0xFFA7D0) != 0x1F) + if (Mem.ReadByte(0xFFA7D0) != 0x1F) { DrawEccoOct(Xpos, Ypos, 40, Color.Lime); DrawEccoOct(Xpos2, Ypos2, 40, Color.Lime); @@ -589,23 +606,23 @@ namespace BizHawk.Client.EmuHawk DrawEccoOct(Xpos, Ypos, 48, Color.Blue, 16); DrawEccoOct(Xpos2, Ypos2, 48, Color.Blue, 16); } - curObj = _api.MemLib.ReadU24(curObj + 5); + curObj = Mem.ReadU24(curObj + 5); } } //aqua tubes - curObj = _api.MemLib.ReadU24(0xFFCFC5); + curObj = Mem.ReadU24(0xFFCFC5); while (curObj != 0) { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2= _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2= _api.MemLib.ReadS16(curObj + 0x38); + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2= Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2= Mem.ReadS16(curObj + 0x38); Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid = (Xpos + Xpos2) >> 1; Ymid = (Ypos + Ypos2) >> 1; // displayed = false; - type = _api.MemLib.ReadU8(curObj + 0x7E); + type = Mem.ReadU8(curObj + 0x7E); switch (type) { case 0x15: @@ -639,7 +656,7 @@ namespace BizHawk.Client.EmuHawk new Point(Xpos2 - (Ymid - Ypos >> 1), Ypos), new Point(Xpos2, Ymid) }; - _api.GUILib.DrawPolygon(trapPoints, Color.Purple, Color.FromArgb(63, Color.Purple)); + Gui.DrawPolygon(trapPoints, Color.Purple, Color.FromArgb(63, Color.Purple)); break; default: DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Purple); @@ -647,22 +664,22 @@ namespace BizHawk.Client.EmuHawk PutText(type.ToString("X2"), Xmid, Ymid, 1, 1, -1, -1, Color.Red, Color.Blue); break; } - curObj = _api.MemLib.ReadU24(curObj+1); + curObj = Mem.ReadU24(curObj+1); } //walls - curObj = _api.MemLib.ReadU24(0xFFCFC1); + curObj = Mem.ReadU24(0xFFCFC1); while (curObj != 0) { - Xmid = _api.MemLib.ReadS16(curObj + 0x24); - Xmid = _api.MemLib.ReadS16(curObj + 0x28); - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2= _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2= _api.MemLib.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS16(curObj + 0x24); + Xmid = Mem.ReadS16(curObj + 0x28); + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2= Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2= Mem.ReadS16(curObj + 0x38); Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; - int colltype = _api.MemLib.ReadS8(curObj + 0x7E); + int colltype = Mem.ReadS8(curObj + 0x7E); switch (colltype) { case 0x10: @@ -674,25 +691,25 @@ namespace BizHawk.Client.EmuHawk Xmid = (Xpos + Xpos2) >> 1; Xpos2 = Xmid; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.FromArgb(63, Color.Yellow)); - _api.GUILib.DrawLine(Xpos2, Ypos, Xpos2, Ypos2, Color.PowderBlue); + Gui.DrawLine(Xpos2, Ypos, Xpos2, Ypos2, Color.PowderBlue); break; case 0x12: Xmid = (Xpos + Xpos2) >> 1; Xpos = Xmid; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.FromArgb(63, Color.Yellow)); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos, Ypos2, Color.PowderBlue); + Gui.DrawLine(Xpos, Ypos, Xpos, Ypos2, Color.PowderBlue); break; case 0x13: Ymid = (Ypos + Ypos2) >> 1; Ypos = Ymid; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.FromArgb(63, Color.Yellow)); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos, Color.PowderBlue); + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos, Color.PowderBlue); break; case 0x14: Ymid = (Ypos + Ypos2) >> 1; Ypos2 = Ymid; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.FromArgb(63, Color.Yellow)); - _api.GUILib.DrawLine(Xpos, Ypos2, Xpos2, Ypos2, Color.PowderBlue); + Gui.DrawLine(Xpos, Ypos2, Xpos2, Ypos2, Color.PowderBlue); break; case 0x15: case 0x16: @@ -702,7 +719,7 @@ namespace BizHawk.Client.EmuHawk Xmid = (Xpos + Xpos2) >> 1; Ymid = (Ypos + Ypos2) >> 1; DrawEccoTriangle(Xmid, Ymid, Xmid, Ypos2, Xpos2, Ymid, Color.FromArgb(63, Color.Yellow)); - _api.GUILib.DrawLine(Xmid, Ypos2, Xpos2, Ymid, Color.PowderBlue); + Gui.DrawLine(Xmid, Ypos2, Xpos2, Ymid, Color.PowderBlue); break; case 0x1A: case 0x1B: @@ -712,7 +729,7 @@ namespace BizHawk.Client.EmuHawk Xmid = (Xpos + Xpos2) >> 1; Ymid = (Ypos + Ypos2) >> 1; DrawEccoTriangle(Xmid, Ymid, Xmid, Ypos2, Xpos, Ymid, Color.FromArgb(63, Color.Yellow)); - _api.GUILib.DrawLine(Xpos, Ymid, Xmid, Ypos2, Color.PowderBlue); + Gui.DrawLine(Xpos, Ymid, Xmid, Ypos2, Color.PowderBlue); break; case 0x1F: case 0x20: @@ -722,7 +739,7 @@ namespace BizHawk.Client.EmuHawk Xmid = (Xpos + Xpos2) >> 1; Ymid = (Ypos + Ypos2) >> 1; DrawEccoTriangle(Xmid, Ymid, Xmid, Ypos, Xpos, Ymid, Color.FromArgb(63,Color.Yellow)); - _api.GUILib.DrawLine(Xpos, Ymid, Xmid, Ypos, Color.PowderBlue); + Gui.DrawLine(Xpos, Ymid, Xmid, Ypos, Color.PowderBlue); break; case 0x24: case 0x25: @@ -732,17 +749,17 @@ namespace BizHawk.Client.EmuHawk Xmid = (Xpos + Xpos2) >> 1; Ymid = (Ypos + Ypos2) >> 1; DrawEccoTriangle(Xmid, Ymid, Xmid, Ypos, Xpos2, Ymid, Color.FromArgb(63,Color.Yellow)); - _api.GUILib.DrawLine(Xmid, Ypos, Xpos2, Ymid, Color.PowderBlue); + Gui.DrawLine(Xmid, Ypos, Xpos2, Ymid, Color.PowderBlue); break; case 0x29: DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.FromArgb(63, Color.Black)); - _api.GUILib.DrawLine(Xpos , Ypos, Xpos , Ypos2, Color.Black); - _api.GUILib.DrawLine(Xpos2, Ypos, Xpos2, Ypos2, Color.Black); + Gui.DrawLine(Xpos , Ypos, Xpos , Ypos2, Color.Black); + Gui.DrawLine(Xpos2, Ypos, Xpos2, Ypos2, Color.Black); break; case 0x2A: DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.FromArgb(63, Color.Black)); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos, Color.Black); - _api.GUILib.DrawLine(Xpos, Ypos2, Xpos2, Ypos2, Color.Black); + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos, Color.Black); + Gui.DrawLine(Xpos, Ypos2, Xpos2, Ypos2, Color.Black); break; case 0x2B: Xmid = (Xpos + Xpos2) >> 1; @@ -754,45 +771,45 @@ namespace BizHawk.Client.EmuHawk new Point(Xpos2 - (Ymid - Ypos >> 1), Ypos), new Point(Xpos2, Ymid) }; - _api.GUILib.DrawPolygon(trapPoints, Color.PowderBlue, Color.FromArgb(63, Color.PowderBlue)); - //_api.GUILib.DrawLine(Xpos, Ymid, Xpos2, Ymid, Color.Yellow); + Gui.DrawPolygon(trapPoints, Color.PowderBlue, Color.FromArgb(63, Color.PowderBlue)); + //Gui.DrawLine(Xpos, Ymid, Xpos2, Ymid, Color.Yellow); break; default: - DrawEccoRhomb_scaled(Xmid, Ymid, _api.MemLib.ReadS16(curObj + 0x44), _api.MemLib.ReadS16(curObj + 0x44), (colltype & 1), (colltype & 2) >> 1, (colltype & 4) >> 2, (colltype & 8) >> 3, Color.PowderBlue); + DrawEccoRhomb_scaled(Xmid, Ymid, Mem.ReadS16(curObj + 0x44), Mem.ReadS16(curObj + 0x44), (colltype & 1), (colltype & 2) >> 1, (colltype & 4) >> 2, (colltype & 8) >> 3, Color.PowderBlue); break; } - curObj = _api.MemLib.ReadU24(curObj+1); + curObj = Mem.ReadU24(curObj+1); } //inanimate objects - curObj = _api.MemLib.ReadU24(0xFFCFBD); + curObj = Mem.ReadU24(0xFFCFBD); while (curObj != 0) { - type = _api.MemLib.ReadU32(curObj + 0xC); - int colltype = _api.MemLib.ReadS8(curObj + 0x7E); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - int Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54) + _api.MemLib.ReadS32(curObj + 0x5C)) >> 16) - _camX; - int Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58) + _api.MemLib.ReadS32(curObj + 0x60)) >> 16) - _camY; - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; + type = Mem.ReadU32(curObj + 0xC); + int colltype = Mem.ReadS8(curObj + 0x7E); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + int Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54) + Mem.ReadS32(curObj + 0x5C)) >> 16) - _camX; + int Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58) + Mem.ReadS32(curObj + 0x60)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; if (type == 0x9CE3A) //Remnant Stars { - uint subObj = _api.MemLib.ReadU24(curObj + 0x5); - uint anim = _api.MemLib.ReadU16(curObj + 0x6C); + uint subObj = Mem.ReadU24(curObj + 0x5); + uint anim = Mem.ReadU16(curObj + 0x6C); if ((anim <= 7) && (subObj == 0xFFA9D4)) { DrawEccoRhomb(Xmid, Ymid, 96, Color.Red); - PutText($"{((7 - anim) * 4) - ((_api.MemLib.ReadByte(0xFFA7C9) & 3) - 4)}", Xmid, Ymid + 4, 1, 1, -1, -1, Color.Lime, Color.Blue); + PutText($"{((7 - anim) * 4) - ((Mem.ReadByte(0xFFA7C9) & 3) - 4)}", Xmid, Ymid + 4, 1, 1, -1, -1, Color.Lime, Color.Blue); } } else if ((type == 0x9CC06) || (type == 0x9CA10)) { - Xvec = ((_api.MemLib.ReadS32(curObj + 0x24) + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((_api.MemLib.ReadS32(curObj + 0x28) + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xvec = ((Mem.ReadS32(curObj + 0x24) + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Mem.ReadS32(curObj + 0x28) + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; } else if (type == 0x9B5D8) { @@ -801,27 +818,27 @@ namespace BizHawk.Client.EmuHawk } else if (type == 0xC0152) // Vortex Future Vertical Gate { - Xvec = _api.MemLib.ReadS16(curObj + 0x1C) - _camX; - Yvec = (_api.MemLib.ReadS32(curObj + 0x20) + _api.MemLib.ReadS32(curObj + 0x60) >> 16) - _camY; - _api.GUILib.DrawLine(Xmid, 0, Xmid, 448, Color.PowderBlue); + Xvec = Mem.ReadS16(curObj + 0x1C) - _camX; + Yvec = (Mem.ReadS32(curObj + 0x20) + Mem.ReadS32(curObj + 0x60) >> 16) - _camY; + Gui.DrawLine(Xmid, 0, Xmid, 448, Color.PowderBlue); DrawBoxMWH(Xvec, Yvec, 1, 1, Color.Blue, 0); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); } else if (type == 0xC3330) // City Of Forever Horizontal Gate Slave { - Xvec = (_api.MemLib.ReadS32(curObj + 0x1C) + _api.MemLib.ReadS32(curObj + 0x5C) >> 16) - _camX; - Yvec = _api.MemLib.ReadS16(curObj + 0x20) - _camY; + Xvec = (Mem.ReadS32(curObj + 0x1C) + Mem.ReadS32(curObj + 0x5C) >> 16) - _camX; + Yvec = Mem.ReadS16(curObj + 0x20) - _camY; DrawBoxMWH(Xvec, Yvec, 1, 1, Color.Blue, 0); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); } else if (type == 0xC35B0) // City Of Forever Horizontal Gate Master { - var mode = _api.MemLib.ReadByte(curObj + 0x15); + var mode = Mem.ReadByte(curObj + 0x15); var tmpx = Xpos; - Xpos = _api.MemLib.ReadS32(curObj + 0x1C); - Xvec = (Xpos + _api.MemLib.ReadS32(curObj + 0x5C) >> 16) - _camX; + Xpos = Mem.ReadS32(curObj + 0x1C); + Xvec = (Xpos + Mem.ReadS32(curObj + 0x5C) >> 16) - _camX; Xpos >>= 16; Xpos -= _camX; - Yvec = _api.MemLib.ReadS16(curObj + 0x20) - _camY; + Yvec = Mem.ReadS16(curObj + 0x20) - _camY; if ((mode == 1) || (mode == 3)) { DrawEccoOct(Xpos, Yvec, 128, Color.Orange); @@ -832,35 +849,35 @@ namespace BizHawk.Client.EmuHawk } else if (type == 0xC343A) // City Of Forever Vertical Gate { - var mode = _api.MemLib.ReadByte(curObj + 0x15); + var mode = Mem.ReadByte(curObj + 0x15); if ((mode == 1) || (mode == 3)) { DrawEccoOct(Xmid, Ymid, 128, Color.Orange); } - Xvec = _api.MemLib.ReadS16(curObj + 0x1C) - _camX; - Yvec = (_api.MemLib.ReadS32(curObj + 0x20) + _api.MemLib.ReadS32(curObj + 0x60) >> 16) - _camY; + Xvec = Mem.ReadS16(curObj + 0x1C) - _camX; + Yvec = (Mem.ReadS32(curObj + 0x20) + Mem.ReadS32(curObj + 0x60) >> 16) - _camY; DrawBoxMWH(Xvec, Yvec, 1, 1, Color.Blue, 0); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); } else if (type == 0xA579A) // Antigrav Ball { - DrawEccoOct(Xmid, Ymid, _api.MemLib.ReadS16(curObj + 0x4C), (_api.MemLib.ReadU16(0xFFA7C8) & 7) == 7 ? Color.Blue : Color.Gray); + DrawEccoOct(Xmid, Ymid, Mem.ReadS16(curObj + 0x4C), (Mem.ReadU16(0xFFA7C8) & 7) == 7 ? Color.Blue : Color.Gray); DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Blue); DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.PowderBlue, 0); Xpos = Ypos = Xpos2 = Ypos2 = _camX - 128; } else if (type == 0xDF4E2) // Moray Abyss Conch Shell { - Xpos = _api.MemLib.ReadS16(curObj + 0x1C) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x20) - _camY; - DrawBox(Xpos - 96, 0 - _camY, Xpos + 96, _api.MemLib.ReadS16(0xFFA7AC) - _camY - 64, Color.Orange, 0); - var mode = _api.MemLib.ReadByte(curObj + 0x15); - var modeTimer = _api.MemLib.ReadS16(curObj + 0x6E); - var Xvel1 = _api.MemLib.ReadS32(curObj + 0x54) / 65536.0; - var Yvel1 = _api.MemLib.ReadS32(curObj + 0x58) / 65536.0; - var Xvel2 = _api.MemLib.ReadS32(curObj + 0x5C) / 65536.0; - var Yvel2 = _api.MemLib.ReadS32(curObj + 0x60) / 65536.0; - TickerText($"{mode}:{modeTimer}:{_api.MemLib.ReadS16(0xFFA7AC) - 64 - Ymid - _camY}", Color.Red); + Xpos = Mem.ReadS16(curObj + 0x1C) - _camX; + Ypos = Mem.ReadS16(curObj + 0x20) - _camY; + DrawBox(Xpos - 96, 0 - _camY, Xpos + 96, Mem.ReadS16(0xFFA7AC) - _camY - 64, Color.Orange, 0); + var mode = Mem.ReadByte(curObj + 0x15); + var modeTimer = Mem.ReadS16(curObj + 0x6E); + var Xvel1 = Mem.ReadS32(curObj + 0x54) / 65536.0; + var Yvel1 = Mem.ReadS32(curObj + 0x58) / 65536.0; + var Xvel2 = Mem.ReadS32(curObj + 0x5C) / 65536.0; + var Yvel2 = Mem.ReadS32(curObj + 0x60) / 65536.0; + TickerText($"{mode}:{modeTimer}:{Mem.ReadS16(0xFFA7AC) - 64 - Ymid - _camY}", Color.Red); TickerText($"{Xvel1:0.######}:{Yvel1:0.######}", Color.Red); TickerText($"{Xvel2:0.######}:{Yvel2:0.######}", Color.Red); TickerText($"{Xvel1 + Xvel2:0.######}:{Yvel1 + Yvel2:0.######}", Color.Red); @@ -882,8 +899,8 @@ namespace BizHawk.Client.EmuHawk break; case 1: DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Orange, 0); - Xpos2 = _api.MemLib.ReadS32(0xFFAA1A) - _api.MemLib.ReadS32(curObj + 0x24); - Ypos2 = _api.MemLib.ReadS32(0xFFAA1E) - _api.MemLib.ReadS32(curObj + 0x28); + Xpos2 = Mem.ReadS32(0xFFAA1A) - Mem.ReadS32(curObj + 0x24); + Ypos2 = Mem.ReadS32(0xFFAA1E) - Mem.ReadS32(curObj + 0x28); var dSml = Math.Abs(Xpos2); var dBig = Math.Abs(Ypos2); if (dBig < dSml) @@ -895,11 +912,11 @@ namespace BizHawk.Client.EmuHawk var rad = (dBig + (dSml >> 1) - (dSml >> 3)) / 65536.0; Xpos2 = (int)(Xpos2 * (256.0 / (rad+1))) >> 20; Ypos2 = (int)(Ypos2 * (256.0 / (rad+1))) >> 20; - _api.GUILib.DrawLine(Xmid, Ymid, Xmid + Xpos2, Ymid + Ypos2, Color.Gray); + Gui.DrawLine(Xmid, Ymid, Xmid + Xpos2, Ymid + Ypos2, Color.Gray); TickerText($"{Xpos2 / 512.0:0.######}:{Ypos2 / 512.0:0.######}", Color.Red); break; case 2: - TickerText($"{_api.MemLib.ReadS32(curObj + 0x4C) / 65536.0:0.######}:{_api.MemLib.ReadS32(curObj + 0x50) / 65536.0:0.######}", Color.Red); + TickerText($"{Mem.ReadS32(curObj + 0x4C) / 65536.0:0.######}:{Mem.ReadS32(curObj + 0x50) / 65536.0:0.######}", Color.Red); break; } } @@ -908,10 +925,10 @@ namespace BizHawk.Client.EmuHawk || (type == 0xA6C4A) || (type == 0xAB65A) || (type == 0x9F2EC)) { } else { - PutText($"{type:X5}:{_api.MemLib.ReadByte(curObj + 0x13)}", Xmid, Ymid - 4, 1, 1, -1, -9, Color.Lime, Color.Blue); + PutText($"{type:X5}:{Mem.ReadByte(curObj + 0x13)}", Xmid, Ymid - 4, 1, 1, -1, -9, Color.Lime, Color.Blue); PutText(curObj.ToString("X6"), Xmid, Ymid + 4, 1, 9, -1, -1, Color.Lime, Color.Blue); } - colltype = _api.MemLib.ReadS8(curObj + 0x7E); + colltype = Mem.ReadS8(curObj + 0x7E); switch (colltype) { case 0x10: @@ -947,7 +964,7 @@ namespace BizHawk.Client.EmuHawk Xmid = (Xpos + Xpos2) >> 1; Ymid = (Ypos + Ypos2) >> 1; DrawEccoTriangle(Xmid, Ymid, Xmid, Ypos2, Xpos2, Ymid, Color.FromArgb(63, Color.Yellow)); - _api.GUILib.DrawLine(Xmid, Ypos2, Xpos2, Ymid, Color.PowderBlue); + Gui.DrawLine(Xmid, Ypos2, Xpos2, Ymid, Color.PowderBlue); break; case 0x1A: case 0x1B: @@ -957,7 +974,7 @@ namespace BizHawk.Client.EmuHawk Xmid = (Xpos + Xpos2) >> 1; Ymid = (Ypos + Ypos2) >> 1; DrawEccoTriangle(Xmid, Ymid, Xmid, Ypos2, Xpos, Ymid, Color.FromArgb(63, Color.Yellow)); - _api.GUILib.DrawLine(Xpos, Ymid, Xmid, Ypos2, Color.PowderBlue); + Gui.DrawLine(Xpos, Ymid, Xmid, Ypos2, Color.PowderBlue); break; case 0x1F: case 0x20: @@ -967,7 +984,7 @@ namespace BizHawk.Client.EmuHawk Xmid = (Xpos + Xpos2) >> 1; Ymid = (Ypos + Ypos2) >> 1; DrawEccoTriangle(Xmid, Ymid, Xmid, Ypos, Xpos, Ymid, Color.FromArgb(63, Color.Yellow)); - _api.GUILib.DrawLine(Xpos, Ymid, Xmid, Ypos, Color.PowderBlue); + Gui.DrawLine(Xpos, Ymid, Xmid, Ypos, Color.PowderBlue); break; case 0x24: case 0x25: @@ -977,12 +994,12 @@ namespace BizHawk.Client.EmuHawk Xmid = (Xpos + Xpos2) >> 1; Ymid = (Ypos + Ypos2) >> 1; DrawEccoTriangle(Xmid, Ymid, Xmid, Ypos, Xpos2, Ymid, Color.FromArgb(63, Color.Yellow)); - _api.GUILib.DrawLine(Xmid, Ypos, Xpos2, Ymid, Color.PowderBlue); + Gui.DrawLine(Xmid, Ypos, Xpos2, Ymid, Color.PowderBlue); break; case 0x2A: DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.FromArgb(63, Color.Black)); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos, Color.Black); - _api.GUILib.DrawLine(Xpos, Ypos2, Xpos2, Ypos2, Color.Black); + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos, Color.Black); + Gui.DrawLine(Xpos, Ypos2, Xpos2, Ypos2, Color.Black); break; case 0x2B: Xmid = (Xpos + Xpos2) >> 1; @@ -994,70 +1011,70 @@ namespace BizHawk.Client.EmuHawk new Point(Xpos2 - (Ymid - Ypos >> 1), Ypos), new Point(Xpos2, Ymid) }; - _api.GUILib.DrawPolygon(trapPoints, Color.PowderBlue, Color.FromArgb(63, Color.PowderBlue)); + Gui.DrawPolygon(trapPoints, Color.PowderBlue, Color.FromArgb(63, Color.PowderBlue)); break; case 0x2C: break; default: - DrawEccoRhomb_scaled(Xmid, Ymid, _api.MemLib.ReadS16(curObj + 0x44), _api.MemLib.ReadS16(curObj + 0x44), (colltype & 1), (colltype & 2) >> 1, (colltype & 4) >> 2, (colltype & 8) >> 3, Color.PowderBlue); + DrawEccoRhomb_scaled(Xmid, Ymid, Mem.ReadS16(curObj + 0x44), Mem.ReadS16(curObj + 0x44), (colltype & 1), (colltype & 2) >> 1, (colltype & 4) >> 2, (colltype & 8) >> 3, Color.PowderBlue); break; } - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); - curObj = _api.MemLib.ReadU24(curObj+1); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + curObj = Mem.ReadU24(curObj+1); } //animate objects if (_mode == Modes.Ecco2) - curObj = _api.MemLib.ReadU24(0xFFCFB9); + curObj = Mem.ReadU24(0xFFCFB9); else - curObj = _api.MemLib.ReadU24(0xFFD829); + curObj = Mem.ReadU24(0xFFD829); while (curObj != 0) { type = 0; switch (_mode) { case Modes.Ecco2: { - uint flags = _api.MemLib.ReadU16(curObj + 0x10); + uint flags = Mem.ReadU16(curObj + 0x10); int Xvec = 0; int Yvec = 0; //if ((flags & 0x2000) || !(flags & 2)); - HP = _api.MemLib.ReadS8(curObj + 0x7B); - type = _api.MemLib.ReadU32(curObj + 0xC); + HP = Mem.ReadS8(curObj + 0x7B); + type = Mem.ReadU32(curObj + 0xC); if ((type == 0xA1FE6) || (type == 0xA208E) // Chain link creatures such as vortex worm, magic arm, etc || (type == 0xA2288) || (type == 0xA27A4) || (type == 0xA2BB0) || (type == 0xA2C50)) { uint subObj = curObj; while (subObj != 0) { - Xpos = _api.MemLib.ReadS32(subObj + 0x24); - Ypos = _api.MemLib.ReadS32(subObj + 0x28); - Xvec = ((Xpos + _api.MemLib.ReadS32(subObj + 0x54)) >> 16) - _camX; - Yvec = ((Ypos + _api.MemLib.ReadS32(subObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS32(subObj + 0x24); + Ypos = Mem.ReadS32(subObj + 0x28); + Xvec = ((Xpos + Mem.ReadS32(subObj + 0x54)) >> 16) - _camX; + Yvec = ((Ypos + Mem.ReadS32(subObj + 0x58)) >> 16) - _camY; Xpos >>= 16; Ypos >>= 16; Xpos -= _camX; Ypos -= _camY; - if (_api.MemLib.ReadS16(subObj + 0x44) == _api.MemLib.ReadS16(subObj + 0x48)) + if (Mem.ReadS16(subObj + 0x44) == Mem.ReadS16(subObj + 0x48)) { - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x44), Color.FromArgb(255, 0, 127)); - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x44), Color.Cyan, 0); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x44), Color.FromArgb(255, 0, 127)); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x44), Color.Cyan, 0); } else { - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x44), Color.FromArgb(255, 0, 127)); - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x44), Color.Lime, 0); - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x44), Color.FromArgb(255, 0, 127)); - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x48), Color.Blue, 0); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x44), Color.FromArgb(255, 0, 127)); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x44), Color.Lime, 0); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x44), Color.FromArgb(255, 0, 127)); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x48), Color.Blue, 0); } DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); - subObj = _api.MemLib.ReadU24(subObj + 5); + Gui.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); + subObj = Mem.ReadU24(subObj + 5); } if (HP > 2) { - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; PutText($"{HP - 1}", Xmid, Ymid, 1, 1, -1, -9, Color.Blue, Color.Red); } } @@ -1069,43 +1086,43 @@ namespace BizHawk.Client.EmuHawk uint subObj = curObj; while (subObj != 0) { - Xpos = _api.MemLib.ReadS32(subObj + 0x24); - Ypos = _api.MemLib.ReadS32(subObj + 0x28); - Xvec = ((Xpos + _api.MemLib.ReadS32(subObj + 0x54)) >> 16) - _camX; - Yvec = ((Ypos + _api.MemLib.ReadS32(subObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS32(subObj + 0x24); + Ypos = Mem.ReadS32(subObj + 0x28); + Xvec = ((Xpos + Mem.ReadS32(subObj + 0x54)) >> 16) - _camX; + Yvec = ((Ypos + Mem.ReadS32(subObj + 0x58)) >> 16) - _camY; Xpos >>= 16; Ypos >>= 16; Xpos -= _camX; Ypos -= _camY; - if (_api.MemLib.ReadS16(subObj + 0x44) == _api.MemLib.ReadS16(subObj + 0x48)) + if (Mem.ReadS16(subObj + 0x44) == Mem.ReadS16(subObj + 0x48)) { - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x44), Color.FromArgb(255, 0, 127)); - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x44), Color.White, 0); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x44), Color.FromArgb(255, 0, 127)); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x44), Color.White, 0); } else { - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x44), Color.FromArgb(255, 0, 127)); - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x44), Color.Lime, 0); - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x48), Color.FromArgb(255, 0, 127)); - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(subObj + 0x48), Color.Magenta, 0); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x44), Color.FromArgb(255, 0, 127)); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x44), Color.Lime, 0); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x48), Color.FromArgb(255, 0, 127)); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(subObj + 0x48), Color.Magenta, 0); } DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); if (type == 0xBA66E) { DrawEccoOct(Xpos, Ypos, 32, Color.Blue, 16); if (subObj == curObj) { - var mode = _api.MemLib.ReadByte(subObj + 0x15); - TickerText($"{_api.MemLib.ReadByte(subObj + 0x14)}:{mode}:{_api.MemLib.ReadByte(subObj + 0x70)}", Color.Red); - TickerText($"{_api.MemLib.ReadS32(subObj + 0x54) / 65536.0:0.######}:{_api.MemLib.ReadS32(subObj + 0x58) / 65536.0:0.######}", Color.Red); - TickerText($"{_api.MemLib.ReadS32(subObj + 0x4C) / 65536.0:0.######}:{_api.MemLib.ReadS32(subObj + 0x50) / 65536.0:0.######}", Color.Red); + var mode = Mem.ReadByte(subObj + 0x15); + TickerText($"{Mem.ReadByte(subObj + 0x14)}:{mode}:{Mem.ReadByte(subObj + 0x70)}", Color.Red); + TickerText($"{Mem.ReadS32(subObj + 0x54) / 65536.0:0.######}:{Mem.ReadS32(subObj + 0x58) / 65536.0:0.######}", Color.Red); + TickerText($"{Mem.ReadS32(subObj + 0x4C) / 65536.0:0.######}:{Mem.ReadS32(subObj + 0x50) / 65536.0:0.######}", Color.Red); switch (mode) { case 0: case 2: case 4: - Xpos2 = _api.MemLib.ReadS32(0xFFAA22) - _api.MemLib.ReadS32(subObj + 0x24); - Ypos2 = _api.MemLib.ReadS32(0xFFAA26) - _api.MemLib.ReadS32(subObj + 0x28); + Xpos2 = Mem.ReadS32(0xFFAA22) - Mem.ReadS32(subObj + 0x24); + Ypos2 = Mem.ReadS32(0xFFAA26) - Mem.ReadS32(subObj + 0x28); var dSml = Math.Abs(Xpos2); var dBig = Math.Abs(Ypos2); if (dBig < dSml) @@ -1117,7 +1134,7 @@ namespace BizHawk.Client.EmuHawk var rad = (dBig + (dSml >> 1) - (dSml >> 3)) / 65536.0; Xpos2 = (int)(Xpos2 * (256.0 / (rad + 1))) >> 20; Ypos2 = (int)(Ypos2 * (256.0 / (rad + 1))) >> 20; - _api.GUILib.DrawLine(Xpos, Ypos, Xpos + Xpos2, Ypos + Ypos2, Color.Red); + Gui.DrawLine(Xpos, Ypos, Xpos + Xpos2, Ypos + Ypos2, Color.Red); break; default: break; @@ -1125,13 +1142,13 @@ namespace BizHawk.Client.EmuHawk } } } - else if ((type == 0xBA52E) && (subObj == _api.MemLib.ReadU24(curObj + 0x1D))) + else if ((type == 0xBA52E) && (subObj == Mem.ReadU24(curObj + 0x1D))) { - DrawEccoOct(Xpos, Ypos, 32, (_api.MemLib.ReadByte(subObj + 0x70) == 0) ? Color.Blue : Color.Gray, 16); - var mode = _api.MemLib.ReadByte(curObj + 0x15); - TickerText($"{_api.MemLib.ReadByte(curObj + 0x14)}:{mode}:{_api.MemLib.ReadS16(curObj + 0x6E)}:{_api.MemLib.ReadByte(subObj + 0x70)}", Color.Red); - TickerText($"{_api.MemLib.ReadS32(subObj + 0x54) / 65536.0:0.######}:{_api.MemLib.ReadS32(subObj + 0x58) / 65536.0:0.######}", Color.Red); - TickerText($"{_api.MemLib.ReadS32(curObj + 0x4C) / 65536.0:0.######}:{_api.MemLib.ReadS32(curObj + 0x50) / 65536.0:0.######}", Color.Red); + DrawEccoOct(Xpos, Ypos, 32, (Mem.ReadByte(subObj + 0x70) == 0) ? Color.Blue : Color.Gray, 16); + var mode = Mem.ReadByte(curObj + 0x15); + TickerText($"{Mem.ReadByte(curObj + 0x14)}:{mode}:{Mem.ReadS16(curObj + 0x6E)}:{Mem.ReadByte(subObj + 0x70)}", Color.Red); + TickerText($"{Mem.ReadS32(subObj + 0x54) / 65536.0:0.######}:{Mem.ReadS32(subObj + 0x58) / 65536.0:0.######}", Color.Red); + TickerText($"{Mem.ReadS32(curObj + 0x4C) / 65536.0:0.######}:{Mem.ReadS32(curObj + 0x50) / 65536.0:0.######}", Color.Red); } else if (type == 0xE0988) { @@ -1139,44 +1156,44 @@ namespace BizHawk.Client.EmuHawk } if (HP > 2) { - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; PutText($"{HP - 1}", Xmid, Ymid, 1, 1, -1, -9, Color.Blue, Color.Red); } - subObj = _api.MemLib.ReadU24(subObj + 5); + subObj = Mem.ReadU24(subObj + 5); } } else if (type == 0xB7DF4) { - Xpos = _api.MemLib.ReadS32(curObj + 0x24); - Ypos = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xpos + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ypos + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS32(curObj + 0x24); + Ypos = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xpos + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ypos + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xpos >>= 16; Ypos >>= 16; Xpos -= _camX; Ypos -= _camY; DrawEccoOct(Xpos, Ypos, 26, Color.PowderBlue); DrawEccoOct(Xpos, Ypos, 26, Color.White); DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xvec, Yvec); + Gui.DrawLine(Xpos, Ypos, Xvec, Yvec); } else if (type == 0xE47EE) { - uint subObj = _api.MemLib.ReadU24(curObj + 5); + uint subObj = Mem.ReadU24(curObj + 5); while (subObj != 0) { - Xpos = _api.MemLib.ReadS32(subObj + 0x1C); - Ypos = _api.MemLib.ReadS32(subObj + 0x20); - Xvec = ((Xpos + _api.MemLib.ReadS32(subObj + 0x54)) >> 16) - _camX; - Yvec = ((Ypos + _api.MemLib.ReadS32(subObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS32(subObj + 0x1C); + Ypos = Mem.ReadS32(subObj + 0x20); + Xvec = ((Xpos + Mem.ReadS32(subObj + 0x54)) >> 16) - _camX; + Yvec = ((Ypos + Mem.ReadS32(subObj + 0x58)) >> 16) - _camY; Xpos >>= 16; Ypos >>= 16; Xpos -= _camX; Ypos -= _camY; - DrawEccoOct(Xpos, Ypos, ((_api.MemLib.ReadS16(subObj + 0x2C) & 0xFFFF) >> 1) + 16, Color.White); - DrawEccoOct(Xpos, Ypos, ((_api.MemLib.ReadS16(subObj + 0x2C) & 0xFFFF) >> 1) + 16, Color.Yellow, 0); + DrawEccoOct(Xpos, Ypos, ((Mem.ReadS16(subObj + 0x2C) & 0xFFFF) >> 1) + 16, Color.White); + DrawEccoOct(Xpos, Ypos, ((Mem.ReadS16(subObj + 0x2C) & 0xFFFF) >> 1) + 16, Color.Yellow, 0); DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); - subObj = _api.MemLib.ReadU24(subObj + 5); + Gui.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); + subObj = Mem.ReadU24(subObj + 5); } } else if (type == 0xDBE64) // Medusa Boss @@ -1185,21 +1202,21 @@ namespace BizHawk.Client.EmuHawk uint next; do { - next = _api.MemLib.ReadU24(subObj + 5); + next = Mem.ReadU24(subObj + 5); if (next != 0) subObj = next; } while (next != 0); - Xpos = _api.MemLib.ReadS16(subObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(subObj + 0x34); - Ypos = _api.MemLib.ReadS16(subObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(subObj + 0x38); + Xpos = Mem.ReadS16(subObj + 0x2C); + Xpos2 = Mem.ReadS16(subObj + 0x34); + Ypos = Mem.ReadS16(subObj + 0x30); + Ypos2 = Mem.ReadS16(subObj + 0x38); Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; DrawEccoOct(Xpos, Ypos, 32, Color.Red); DrawEccoOct(Xpos2, Ypos2, 32, Color.Red); - Xpos = _api.MemLib.ReadS32(curObj + 0x24); - Ypos = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xpos + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ypos + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS32(curObj + 0x24); + Ypos = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xpos + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ypos + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xpos >>= 16; Ypos >>= 16; Xpos -= _camX; Ypos -= _camY; @@ -1212,86 +1229,86 @@ namespace BizHawk.Client.EmuHawk new Point(Xpos + octOff, Ypos - octOff), new Point(Xpos + 60, Ypos) }; - _api.GUILib.DrawPolygon(hemiOctPoints, Color.Cyan, Color.FromArgb(0x3F, Color.Cyan)); + Gui.DrawPolygon(hemiOctPoints, Color.Cyan, Color.FromArgb(0x3F, Color.Cyan)); for (int l = 0; l < 4; l++) { - _api.GUILib.DrawLine(hemiOctPoints[l].X, hemiOctPoints[l].Y, hemiOctPoints[l + 1].X, hemiOctPoints[l + 1].Y, Color.Cyan); + Gui.DrawLine(hemiOctPoints[l].X, hemiOctPoints[l].Y, hemiOctPoints[l + 1].X, hemiOctPoints[l + 1].Y, Color.Cyan); } DrawBoxMWH(Xpos, Ypos + 12, 52, 12, Color.Cyan); DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); } else if (type == 0xDCEE0) // Globe Holder boss { uint subObj; - var mode = _api.MemLib.ReadByte(curObj + 0x15); + var mode = Mem.ReadByte(curObj + 0x15); if (mode < 4) { - subObj = _api.MemLib.ReadU24(curObj + 9); + subObj = Mem.ReadU24(curObj + 9); while (subObj != 0) { - Xmid = _api.MemLib.ReadS32(subObj + 0x24); - Ymid = _api.MemLib.ReadS32(subObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(subObj + 0x54) + _api.MemLib.ReadS32(subObj + 0x5C)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(subObj + 0x58) + _api.MemLib.ReadS32(subObj + 0x60)) >> 16) - _camY; + Xmid = Mem.ReadS32(subObj + 0x24); + Ymid = Mem.ReadS32(subObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(subObj + 0x54) + Mem.ReadS32(subObj + 0x5C)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(subObj + 0x58) + Mem.ReadS32(subObj + 0x60)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawEccoOct(Xmid, Ymid, 12, Color.Orange); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); - var next = _api.MemLib.ReadU24(subObj + 9); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + var next = Mem.ReadU24(subObj + 9); if ((next == 0) && ((mode & 1) != 0)) { - DrawEccoOct(Xmid, Ymid, _api.MemLib.ReadS16(subObj + 0x3C), Color.Orange); + DrawEccoOct(Xmid, Ymid, Mem.ReadS16(subObj + 0x3C), Color.Orange); } - subObj = _api.MemLib.ReadU24(subObj + 9); + subObj = Mem.ReadU24(subObj + 9); } - subObj = _api.MemLib.ReadU24(curObj + 5); + subObj = Mem.ReadU24(curObj + 5); while (subObj != 0) { - Xmid = _api.MemLib.ReadS32(subObj + 0x24); - Ymid = _api.MemLib.ReadS32(subObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(subObj + 0x54) + _api.MemLib.ReadS32(subObj + 0x5C)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(subObj + 0x58) + _api.MemLib.ReadS32(subObj + 0x60)) >> 16) - _camY; + Xmid = Mem.ReadS32(subObj + 0x24); + Ymid = Mem.ReadS32(subObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(subObj + 0x54) + Mem.ReadS32(subObj + 0x5C)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(subObj + 0x58) + Mem.ReadS32(subObj + 0x60)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawEccoOct(Xmid, Ymid, 12, Color.Orange); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); - var next = _api.MemLib.ReadU24(subObj + 5); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + var next = Mem.ReadU24(subObj + 5); if ((next == 0) && ((mode & 2) != 0)) { - DrawEccoOct(Xmid, Ymid, _api.MemLib.ReadS16(subObj + 0x3C), Color.Orange); + DrawEccoOct(Xmid, Ymid, Mem.ReadS16(subObj + 0x3C), Color.Orange); } - subObj = _api.MemLib.ReadU24(subObj + 5); + subObj = Mem.ReadU24(subObj + 5); } } - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; - int Xtmp = _api.MemLib.ReadS32(curObj + 0x2C); - int Ytmp = _api.MemLib.ReadS32(curObj + 0x30); - int Xtmp2 = _api.MemLib.ReadS32(curObj + 0x34); - int Ytmp2 = _api.MemLib.ReadS32(curObj + 0x38); + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; + int Xtmp = Mem.ReadS32(curObj + 0x2C); + int Ytmp = Mem.ReadS32(curObj + 0x30); + int Xtmp2 = Mem.ReadS32(curObj + 0x34); + int Ytmp2 = Mem.ReadS32(curObj + 0x38); Xpos = (Xtmp >> 16) - _camX; Xpos2 = (Xtmp2 >> 16) - _camX; Ypos = (Ytmp >> 16) - _camY; Ypos2 = (Ytmp2 >> 16) - _camY; - Xvec = ((_api.MemLib.ReadS32(curObj + 0x24) + _api.MemLib.ReadS32(curObj + 0x54) + _api.MemLib.ReadS32(curObj + 0x5C)) >> 16) - _camX; - Yvec = ((_api.MemLib.ReadS32(curObj + 0x28) + +_api.MemLib.ReadS32(curObj + 0x58) + _api.MemLib.ReadS32(curObj + 0x60)) >> 16) - _camY; + Xvec = ((Mem.ReadS32(curObj + 0x24) + Mem.ReadS32(curObj + 0x54) + Mem.ReadS32(curObj + 0x5C)) >> 16) - _camX; + Yvec = ((Mem.ReadS32(curObj + 0x28) + +Mem.ReadS32(curObj + 0x58) + Mem.ReadS32(curObj + 0x60)) >> 16) - _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); if (mode < 7) { double overlap = 0; - DrawEccoOct(Xmid, Ymid, 0x5C, _api.MemLib.ReadByte(curObj + 0x7C) == 0 ? Color.Blue : Color.Gray); + DrawEccoOct(Xmid, Ymid, 0x5C, Mem.ReadByte(curObj + 0x7C) == 0 ? Color.Blue : Color.Gray); DrawEccoOct(Xmid, Ymid, 0x5C, Color.Cyan, 0); - Xvec = (_api.MemLib.ReadS32(curObj + 0x54) + _api.MemLib.ReadS32(curObj + 0x5C)); - Yvec = (_api.MemLib.ReadS32(curObj + 0x58) + _api.MemLib.ReadS32(curObj + 0x60)); - subObj = _api.MemLib.ReadU24(curObj + 0x69); + Xvec = (Mem.ReadS32(curObj + 0x54) + Mem.ReadS32(curObj + 0x5C)); + Yvec = (Mem.ReadS32(curObj + 0x58) + Mem.ReadS32(curObj + 0x60)); + subObj = Mem.ReadU24(curObj + 0x69); if (subObj != 0) { - Xpos = _api.MemLib.ReadS32(subObj + 0x2C); - Ypos = _api.MemLib.ReadS32(subObj + 0x30); - Xpos2 = _api.MemLib.ReadS32(subObj + 0x34); - Ypos2 = _api.MemLib.ReadS32(subObj + 0x38); + Xpos = Mem.ReadS32(subObj + 0x2C); + Ypos = Mem.ReadS32(subObj + 0x30); + Xpos2 = Mem.ReadS32(subObj + 0x34); + Ypos2 = Mem.ReadS32(subObj + 0x38); while ((Xtmp > Xpos) && (Xtmp2 < Xpos2) && (Ytmp > Ypos) && (Ytmp2 < Ypos2) && ((Xvec != 0) || (Yvec != 0))) { Xtmp += Xvec; Xtmp2 += Xvec; @@ -1304,19 +1321,19 @@ namespace BizHawk.Client.EmuHawk Ypos -= _camY; Ypos2 -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, (overlap >= 6) ? Color.Orange : Color.White, 0); } - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, (overlap >= 6) ? Color.Orange : Color.White, (overlap >= 6) ? 63 : 0); if (mode < 4) { - Xmid = _api.MemLib.ReadS16(curObj + 0x4C) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x50) - _camY; + Xmid = Mem.ReadS16(curObj + 0x4C) - _camX; + Ymid = Mem.ReadS16(curObj + 0x50) - _camY; if ((mode & 1) == 0) DrawEccoOct(Xmid, Ymid - 0xAE, 32, Color.Orange); if ((mode & 2) == 0) DrawEccoOct(Xmid, Ymid + 0xAE, 32, Color.Orange); } - TickerText($"{mode}:{_api.MemLib.ReadByte(curObj + 0x7F)}:{_api.MemLib.ReadByte(curObj + 0x6D)}:{_api.MemLib.ReadByte(curObj + 0x7C)}", Color.Red); + TickerText($"{mode}:{Mem.ReadByte(curObj + 0x7F)}:{Mem.ReadByte(curObj + 0x6D)}:{Mem.ReadByte(curObj + 0x7C)}", Color.Red); } else if (mode == 8) { @@ -1325,15 +1342,15 @@ namespace BizHawk.Client.EmuHawk } else if (type == 0xE1BA2) // Vortex Queen Boss { - var vulnCount = _api.MemLib.ReadByte(curObj + 0x7F); - var state = _api.MemLib.ReadByte(curObj + 0x7C); - var stateCounter = _api.MemLib.ReadU16(curObj + 0x6E); - var mode = _api.MemLib.ReadU16(curObj + 0x64); - var modeCounter = _api.MemLib.ReadU16(curObj + 0x66); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x40); - Xvec = Xmid + _api.MemLib.ReadS32(curObj + 0x54); - Yvec = Ymid + _api.MemLib.ReadS32(curObj + 0x58); + var vulnCount = Mem.ReadByte(curObj + 0x7F); + var state = Mem.ReadByte(curObj + 0x7C); + var stateCounter = Mem.ReadU16(curObj + 0x6E); + var mode = Mem.ReadU16(curObj + 0x64); + var modeCounter = Mem.ReadU16(curObj + 0x66); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x40); + Xvec = Xmid + Mem.ReadS32(curObj + 0x54); + Yvec = Ymid + Mem.ReadS32(curObj + 0x58); Xvec >>= 16; Yvec >>= 16; Xmid >>= 16; Ymid >>= 16; Xvec -= _camX; Yvec -= _camY; @@ -1350,35 +1367,35 @@ namespace BizHawk.Client.EmuHawk new Point(Xmid - hexOff.X, Ymid + 32), new Point(Xmid + hexOff.X, Ymid + 32) }; - _api.GUILib.DrawPolygon(roundedRect, Color.Orange, Color.FromArgb(63, Color.Orange)); + Gui.DrawPolygon(roundedRect, Color.Orange, Color.FromArgb(63, Color.Orange)); } DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); - TickerText($"{state:X2}:{stateCounter}:{mode}:{modeCounter}:{_api.MemLib.ReadByte(curObj + 0x70) & 0xF}", Color.Red); - var subObj = _api.MemLib.ReadU24(curObj + 0x5); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + TickerText($"{state:X2}:{stateCounter}:{mode}:{modeCounter}:{Mem.ReadByte(curObj + 0x70) & 0xF}", Color.Red); + var subObj = Mem.ReadU24(curObj + 0x5); var tongueMode = mode; - mode = _api.MemLib.ReadByte(subObj + 0x15); - modeCounter = _api.MemLib.ReadU16(subObj + 0x6E); - Xmid = _api.MemLib.ReadS32(subObj + 0x24); - Ymid = _api.MemLib.ReadS32(subObj + 0x40); - Xvec = (Xmid + _api.MemLib.ReadS32(subObj + 0x5C) >> 16) - _camX; - Yvec = (Ymid + _api.MemLib.ReadS32(subObj + 0x60) >> 16) - _camY; + mode = Mem.ReadByte(subObj + 0x15); + modeCounter = Mem.ReadU16(subObj + 0x6E); + Xmid = Mem.ReadS32(subObj + 0x24); + Ymid = Mem.ReadS32(subObj + 0x40); + Xvec = (Xmid + Mem.ReadS32(subObj + 0x5C) >> 16) - _camX; + Yvec = (Ymid + Mem.ReadS32(subObj + 0x60) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; Ymid -= 32; Yvec -= 32; - var levelHeight = _api.MemLib.ReadS16(0xFFA7AC) - _camY; + var levelHeight = Mem.ReadS16(0xFFA7AC) - _camY; switch (mode) { case 0: DrawBox(Xmid - 32, Ymid - ((state == 5) ? 0x60 : 0x70), Xmid + 32, Ymid - 16, Color.Red); break; case 2: - Ypos = _api.MemLib.ReadS16(subObj + 0x50) - _camY; - _api.GUILib.DrawLine(Xmid - 48, Ypos, Xmid + 48, Ypos, Color.Orange); + Ypos = Mem.ReadS16(subObj + 0x50) - _camY; + Gui.DrawLine(Xmid - 48, Ypos, Xmid + 48, Ypos, Color.Orange); DrawBoxMWH(Xmid, Ymid + 32, 1, 1, Color.Orange, 0); break; case 3: - modeCounter = _api.MemLib.ReadByte(subObj + 0x7C); + modeCounter = Mem.ReadByte(subObj + 0x7C); break; case 5: Point[] throatShape = @@ -1390,7 +1407,7 @@ namespace BizHawk.Client.EmuHawk new Point(Xmid + 48, Ymid + 60), new Point(Xmid + 48, levelHeight) }; - _api.GUILib.DrawPolygon(throatShape, Color.Red, Color.FromArgb(63, Color.Red)); + Gui.DrawPolygon(throatShape, Color.Red, Color.FromArgb(63, Color.Red)); DrawEccoOct(Xmid, Ymid, 24, Color.Red); DrawEccoOct(Xmid, Ymid, 24, Color.White, 0); break; @@ -1401,41 +1418,41 @@ namespace BizHawk.Client.EmuHawk } if (tongueMode == 7) { - uint subObj2 = _api.MemLib.ReadU24(0xFFCFCD); + uint subObj2 = Mem.ReadU24(0xFFCFCD); while (subObj2 != 0) { - if (_api.MemLib.ReadU16(subObj2 + 0x10) == 0xFF) + if (Mem.ReadU16(subObj2 + 0x10) == 0xFF) { - Xpos = _api.MemLib.ReadS16(subObj2 + 0x24) - _camX; - Ypos = _api.MemLib.ReadS16(subObj2 + 0x28) - _camY; - Xpos2 = ((_api.MemLib.ReadS32(subObj2 + 0x24) + _api.MemLib.ReadS32(subObj2 + 0x54)) >> 16) - _camX; - Ypos2 = ((_api.MemLib.ReadS32(subObj2 + 0x28) + _api.MemLib.ReadS32(subObj2 + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(subObj2 + 0x24) - _camX; + Ypos = Mem.ReadS16(subObj2 + 0x28) - _camY; + Xpos2 = ((Mem.ReadS32(subObj2 + 0x24) + Mem.ReadS32(subObj2 + 0x54)) >> 16) - _camX; + Ypos2 = ((Mem.ReadS32(subObj2 + 0x28) + Mem.ReadS32(subObj2 + 0x58)) >> 16) - _camY; DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Orange); + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Orange); } - subObj2 = _api.MemLib.ReadU24(subObj2 + 1); + subObj2 = Mem.ReadU24(subObj2 + 1); } } - Ypos = _api.MemLib.ReadS16(subObj + 0x50) - _camY; - _api.GUILib.DrawLine(Xmid - 48, Ypos - 94, Xmid + 48, Ypos - 94, Color.Orange); - _api.GUILib.DrawLine(Xmid - 48, Ypos, Xmid + 48, Ypos, Color.Orange); + Ypos = Mem.ReadS16(subObj + 0x50) - _camY; + Gui.DrawLine(Xmid - 48, Ypos - 94, Xmid + 48, Ypos - 94, Color.Orange); + Gui.DrawLine(Xmid - 48, Ypos, Xmid + 48, Ypos, Color.Orange); DrawBoxMWH(Xmid, Ymid + 32, 1, 1, Color.Orange, 0); break; default: break; } - if ((mode < 7) || ((mode == 7) && (_api.MemLib.ReadU24(0xFFCFC9) != 0))) + if ((mode < 7) || ((mode == 7) && (Mem.ReadU24(0xFFCFC9) != 0))) { - if (_api.MemLib.ReadByte(subObj + 0x70) == 0) + if (Mem.ReadByte(subObj + 0x70) == 0) { DrawEccoOct(Xmid, Ymid, 32, Color.Red); DrawBox(Xmid - 48, Ymid + 32, Xmid + 48, levelHeight, Color.Red); } - Ypos = _api.MemLib.ReadS16(subObj + 0x50) - _camY - 94; - _api.GUILib.DrawLine(Xmid - 48, Ypos, Xmid + 48, Ypos, Color.Orange); + Ypos = Mem.ReadS16(subObj + 0x50) - _camY - 94; + Gui.DrawLine(Xmid - 48, Ypos, Xmid + 48, Ypos, Color.Orange); DrawBoxMWH(Xmid, Ymid + 32, 1, 1, Color.Orange, 0); } - if (_api.MemLib.ReadS32(subObj + 0xC) == 0xE17B4) + if (Mem.ReadS32(subObj + 0xC) == 0xE17B4) { Point[] shapePoints = { @@ -1446,31 +1463,31 @@ namespace BizHawk.Client.EmuHawk new Point(Xmid + 48, Ymid + 60), new Point(Xmid + 48, levelHeight) }; - _api.GUILib.DrawPolygon(shapePoints, Color.Red, Color.FromArgb(63, Color.Red)); + Gui.DrawPolygon(shapePoints, Color.Red, Color.FromArgb(63, Color.Red)); DrawEccoOct(Xmid, Ymid, 24, Color.Red); DrawEccoOct(Xmid, Ymid, 24, Color.White, 0); } - Ypos = (_api.MemLib.ReadS16(subObj + 0x50) - _camY) - 264; + Ypos = (Mem.ReadS16(subObj + 0x50) - _camY) - 264; DrawBoxMWH(160 + _left, Ypos, 320, 12, (32 < stateCounter) && (stateCounter < 160) ? Color.Brown : Color.Gray); if ((32 < stateCounter) && (stateCounter < 160)) { DrawBoxMWH(_left + 160, Ypos, 320, 12, Color.White, 0); } DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); TickerText($"{mode:X2}:{modeCounter}:{HP}:{vulnCount}", Color.Red); HP = 0; } else if (type == 0xA5BD2) // Telekinetic future dolphins { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; @@ -1479,66 +1496,66 @@ namespace BizHawk.Client.EmuHawk DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Red, 0); DrawEccoOct(Xmid, Ymid, 4, Color.Red); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if ((type == 0x9F5B0) || (type == 0x9F4DC) || (type == 0x9F6A0)) // Falling rock, breaks barriers { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); - _api.GUILib.DrawLine(Xpos, Ypos2, Xpos2, Ypos, Color.Lime); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); + Gui.DrawLine(Xpos, Ypos2, Xpos2, Ypos, Color.Lime); + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); if (type == 0x9F6A0) { - int width = _api.MemLib.ReadS16(curObj + 0x44) << 1; + int width = Mem.ReadS16(curObj + 0x44) << 1; DrawBox(Xpos - width, Ypos - (width << 2), Xpos2 + width, Ypos2, Color.Lime); } - TickerText($"{_api.MemLib.ReadS32(curObj + 0x54) / 65536.0:0.######}:{_api.MemLib.ReadS32(curObj + 0x58) / 65536.0:0.######}", Color.Lime); + TickerText($"{Mem.ReadS32(curObj + 0x54) / 65536.0:0.######}:{Mem.ReadS32(curObj + 0x58) / 65536.0:0.######}", Color.Lime); } else if (type == 0xA3B18) { - Xpos = _api.MemLib.ReadS32(curObj + 0x24); - Ypos = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xpos + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ypos + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS32(curObj + 0x24); + Ypos = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xpos + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ypos + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xpos >>= 16; Ypos >>= 16; Xpos -= _camX; Ypos -= _camY; - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(curObj + 0x44), Color.Yellow); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(curObj + 0x44), Color.Yellow); DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); } else if (type == 0xA4018) { - Xpos = _api.MemLib.ReadS32(curObj + 0x24); - Ypos = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xpos + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ypos + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS32(curObj + 0x24); + Ypos = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xpos + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ypos + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xpos >>= 16; Ypos >>= 16; Xpos -= _camX; Ypos -= _camY; - DrawEccoOct(Xpos, Ypos, _api.MemLib.ReadS16(curObj + 0x44), Color.Gray); + DrawEccoOct(Xpos, Ypos, Mem.ReadS16(curObj + 0x44), Color.Gray); DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); } else if (type == 0xA091E) // Blue Whale { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; Xpos = Xmid; Ypos = Ymid; @@ -1548,39 +1565,39 @@ namespace BizHawk.Client.EmuHawk DrawEccoOct_scaled(Xmid, Ymid, 2, 0, 0x30, Color.Red, 31); DrawEccoOct_scaled(Xmid, Ymid, 2, 0, 0x20, Color.Red, 31); DrawEccoOct_scaled(Xmid, Ymid, 2, 0, 0x10, Color.Red, 31); - if (_api.MemLib.ReadByte(curObj + 0x7F) == 0) + if (Mem.ReadByte(curObj + 0x7F) == 0) { - Xpos += (_api.MemLib.ReadS16(curObj + 0x6E) == 0) ? -278 : 162; - Ypos += 44 - _api.MemLib.ReadS16(curObj + 0x48); + Xpos += (Mem.ReadS16(curObj + 0x6E) == 0) ? -278 : 162; + Ypos += 44 - Mem.ReadS16(curObj + 0x48); DrawEccoOct(Xpos, Ypos, 32, Color.Blue); } DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xE66D8) //Vortex Larva { - uint subObj = _api.MemLib.ReadU24(curObj + 5); + uint subObj = Mem.ReadU24(curObj + 5); while (subObj != 0) { - Xpos = _api.MemLib.ReadS16(subObj + 0x1C); - Ypos = _api.MemLib.ReadS16(subObj + 0x20); - Xpos2 = _api.MemLib.ReadS16(subObj + 0x24); - Ypos2 = _api.MemLib.ReadS16(subObj + 0x28); + Xpos = Mem.ReadS16(subObj + 0x1C); + Ypos = Mem.ReadS16(subObj + 0x20); + Xpos2 = Mem.ReadS16(subObj + 0x24); + Ypos2 = Mem.ReadS16(subObj + 0x28); Xpos -= _camX; Ypos -= _camY; Xpos2 -= _camX; Ypos2 -= _camY; DrawEccoOct(Xpos, Ypos, 30, Color.White, 32); DrawEccoOct(Xpos, Ypos, 30, Color.Yellow, 0); DrawEccoOct(Xpos2, Ypos2, 30, Color.White, 32); DrawEccoOct(Xpos2, Ypos2, 30, Color.Yellow, 0); - subObj = _api.MemLib.ReadU24(subObj + 5); + subObj = Mem.ReadU24(subObj + 5); } - Xpos = _api.MemLib.ReadS32(curObj + 0x24); - Ypos = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xpos + _api.MemLib.ReadS32(curObj + 0x54) + _api.MemLib.ReadS32(curObj + 0x5C)) >> 16) - _camX; - Yvec = ((Ypos + _api.MemLib.ReadS32(curObj + 0x58) + _api.MemLib.ReadS32(curObj + 0x60)) >> 16) - _camY; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x72) - _camX; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x76) - _camY; + Xpos = Mem.ReadS32(curObj + 0x24); + Ypos = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xpos + Mem.ReadS32(curObj + 0x54) + Mem.ReadS32(curObj + 0x5C)) >> 16) - _camX; + Yvec = ((Ypos + Mem.ReadS32(curObj + 0x58) + Mem.ReadS32(curObj + 0x60)) >> 16) - _camY; + Xpos2 = Mem.ReadS16(curObj + 0x72) - _camX; + Ypos2 = Mem.ReadS16(curObj + 0x76) - _camY; Xpos >>= 16; Ypos >>= 16; Xpos -= _camX; Ypos -= _camY; DrawEccoOct(Xpos, Ypos, 0xB0, Color.Yellow); @@ -1588,112 +1605,112 @@ namespace BizHawk.Client.EmuHawk DrawEccoOct(Xpos, Ypos, 0x70, Color.Red); DrawEccoOct(Xpos, Ypos, 0x38, Color.White); DrawEccoOct(Xpos, Ypos, 0x38, Color.Red, 0); - DrawEccoOct(Xpos, Ypos, 48, Color.Blue, ((_api.MemLib.ReadByte(curObj + 0x7B) > 2) && (_api.MemLib.ReadByte(curObj + 0x14) != 0)) ? 63 : 0); + DrawEccoOct(Xpos, Ypos, 48, Color.Blue, ((Mem.ReadByte(curObj + 0x7B) > 2) && (Mem.ReadByte(curObj + 0x14) != 0)) ? 63 : 0); DrawEccoOct(Xpos2, Ypos2, 32, Color.Orange); DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Orange); - TickerText($"{_api.MemLib.ReadByte(curObj + 0x14):X2}:{_api.MemLib.ReadByte(curObj + 0x7B):X2}:{_api.MemLib.ReadS16(curObj + 0x6E):D2}", Color.Red); - TickerText($"{ _api.MemLib.ReadByte(curObj + 0x7C):X2}:{_api.MemLib.ReadS16(curObj + 0x18):D3}", Color.Red); - TickerText($"{(_api.MemLib.ReadS32(curObj + 0x54) + _api.MemLib.ReadS32(curObj + 0x5C))/65536.0:0.######}:{(_api.MemLib.ReadS32(curObj + 0x58) + _api.MemLib.ReadS32(curObj + 0x60)) / 65536.0:0.######}", Color.Red); + Gui.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Orange); + TickerText($"{Mem.ReadByte(curObj + 0x14):X2}:{Mem.ReadByte(curObj + 0x7B):X2}:{Mem.ReadS16(curObj + 0x6E):D2}", Color.Red); + TickerText($"{ Mem.ReadByte(curObj + 0x7C):X2}:{Mem.ReadS16(curObj + 0x18):D3}", Color.Red); + TickerText($"{(Mem.ReadS32(curObj + 0x54) + Mem.ReadS32(curObj + 0x5C))/65536.0:0.######}:{(Mem.ReadS32(curObj + 0x58) + Mem.ReadS32(curObj + 0x60)) / 65536.0:0.######}", Color.Red); } else if (type == 0x9CE3A) //Remnant Stars { - flags = _api.MemLib.ReadU16(curObj + 0x10); - uint subObj = _api.MemLib.ReadU24(curObj + 0x5); - uint anim = _api.MemLib.ReadU16(curObj + 0x6C); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); + flags = Mem.ReadU16(curObj + 0x10); + uint subObj = Mem.ReadU24(curObj + 0x5); + uint anim = Mem.ReadU16(curObj + 0x6C); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; if ((anim <= 7) && (subObj == 0xFFA9D4)) { DrawEccoRhomb(Xmid, Ymid, 96, Color.Red); - PutText($"{((7 - anim) * 4) - ((_api.MemLib.ReadByte(0xFFA7C9) & 3) - 4)}", Xmid, Ymid + 4, 1, 1, -1, -1, Color.Blue, Color.Red); + PutText($"{((7 - anim) * 4) - ((Mem.ReadByte(0xFFA7C9) & 3) - 4)}", Xmid, Ymid + 4, 1, 1, -1, -1, Color.Blue, Color.Red); } } else if (type == 0xA997C) // Vortex Soldier { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = (Xmid + _api.MemLib.ReadS32(curObj + 0x54) >> 16) - _camX; - Yvec = (Ymid + _api.MemLib.ReadS32(curObj + 0x58) >> 16) - _camY; - Xvec += _api.MemLib.ReadS16(curObj + 0x64); - Yvec += _api.MemLib.ReadS16(curObj + 0x66); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = (Xmid + Mem.ReadS32(curObj + 0x54) >> 16) - _camX; + Yvec = (Ymid + Mem.ReadS32(curObj + 0x58) >> 16) - _camY; + Xvec += Mem.ReadS16(curObj + 0x64); + Yvec += Mem.ReadS16(curObj + 0x66); Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; - if (_api.MemLib.ReadByte(curObj + 0x7A) == 0) + if (Mem.ReadByte(curObj + 0x7A) == 0) { DrawRectRhombusIntersection(new Point(Xmid, Ymid + 6), new Point(Xmid, Ymid), 50, 44, 64, Color.Red); } DrawRectRhombusIntersection(new Point(Xmid, Ymid - 25), new Point(Xmid, Ymid), 38, 47, 64, Color.Red); - DrawBoxMWH(Xmid, Ymid, _api.MemLib.ReadS16(curObj + 0x44), _api.MemLib.ReadS16(curObj + 0x48), Color.Blue, 16); + DrawBoxMWH(Xmid, Ymid, Mem.ReadS16(curObj + 0x44), Mem.ReadS16(curObj + 0x48), Color.Blue, 16); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if ((type == 0xA6C4A) || (type == 0xC43D4)) // Barrier Glyphs { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; - var subType = _api.MemLib.ReadByte(curObj + 0x13); - if ((_api.MemLib.ReadU8(curObj + 0x7A) == 0) && (_api.MemLib.ReadU8(0xFFA7B5) != 0) + var subType = Mem.ReadByte(curObj + 0x13); + if ((Mem.ReadU8(curObj + 0x7A) == 0) && (Mem.ReadU8(0xFFA7B5) != 0) && ((type != 0xA6C4A) || (subType == 0x14) || (subType == 0x97))) { DrawEccoOct(Xmid, Ymid, 70, Color.Red); } - DrawBoxMWH(Xmid, Ymid, _api.MemLib.ReadS16(curObj + 0x44), _api.MemLib.ReadS16(curObj + 0x48), Color.Blue); - DrawBoxMWH(Xmid, Ymid, _api.MemLib.ReadS16(curObj + 0x44), _api.MemLib.ReadS16(curObj + 0x48), Color.PowderBlue, 0); + DrawBoxMWH(Xmid, Ymid, Mem.ReadS16(curObj + 0x44), Mem.ReadS16(curObj + 0x48), Color.Blue); + DrawBoxMWH(Xmid, Ymid, Mem.ReadS16(curObj + 0x44), Mem.ReadS16(curObj + 0x48), Color.PowderBlue, 0); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if ((type == 0xB4F46) || (type == 0xB4E1C) || (type == 0xB4C18) || (type == 0xB4ACC) || (type == 0xB4B72)) // Guiding Orca/Dolphin { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; - int Xdst = _api.MemLib.ReadS16(curObj + 0x64); + int Xdst = Mem.ReadS16(curObj + 0x64); Xdst <<= 7; Xdst = Xdst + 0x40 - _camX; - int Ydst = _api.MemLib.ReadS16(curObj + 0x66); + int Ydst = Mem.ReadS16(curObj + 0x66); Ydst <<= 7; Ydst = Ydst + 0x40 - _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Blue); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); - _api.GUILib.DrawLine(Xmid, Ymid, Xdst, Ydst, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xdst, Ydst, Color.Orange); DrawBoxMWH(Xdst, Ydst, 64, 64, Color.Orange); - TickerText($"{_api.MemLib.ReadS16(curObj + 0x24)}:{_api.MemLib.ReadS16(curObj + 0x28)}:{_api.MemLib.ReadByte(curObj + 0x7D)}:{_api.MemLib.ReadByte(curObj + 0x7A)}", Color.Lime); - TickerText($"{_api.MemLib.ReadS32(curObj + 0x54) / 65536.0:0.######}:{_api.MemLib.ReadS32(curObj + 0x58) / 65536.0:0.######}", Color.Lime); - TickerText($"{_api.MemLib.ReadS32(curObj + 0x72) / 65536.0:0.######}:{_api.MemLib.ReadS32(curObj + 0x76) / 65536.0:0.######}", Color.Lime); + TickerText($"{Mem.ReadS16(curObj + 0x24)}:{Mem.ReadS16(curObj + 0x28)}:{Mem.ReadByte(curObj + 0x7D)}:{Mem.ReadByte(curObj + 0x7A)}", Color.Lime); + TickerText($"{Mem.ReadS32(curObj + 0x54) / 65536.0:0.######}:{Mem.ReadS32(curObj + 0x58) / 65536.0:0.######}", Color.Lime); + TickerText($"{Mem.ReadS32(curObj + 0x72) / 65536.0:0.######}:{Mem.ReadS32(curObj + 0x76) / 65536.0:0.######}", Color.Lime); } else if (type == 0xB5938) // Lost Orca { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xpos = _api.MemLib.ReadS16(curObj + 0x1C) - _camX; - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xpos = Mem.ReadS16(curObj + 0x1C) - _camX; + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; //DrawBoxMWH(Xmid, Ymid, 64, 32, Color.Lime); - if (_api.MemLib.ReadU16(curObj + 0x6E) == 0) + if (Mem.ReadU16(curObj + 0x6E) == 0) { - if (_api.MemLib.ReadByte(curObj + 0x7D) == 0) + if (Mem.ReadByte(curObj + 0x7D) == 0) { DrawBox(Xmid + 8, Ymid - 32, Xmid + 64, Ymid + 32, Color.Red); } @@ -1702,87 +1719,87 @@ namespace BizHawk.Client.EmuHawk DrawBox(Xmid - 64, Ymid - 32, Xmid - 8, Ymid + 32, Color.Red); } } - _api.GUILib.DrawLine(Xpos - 80, Ymid, Xpos + 80, Ymid, Color.Green); + Gui.DrawLine(Xpos - 80, Ymid, Xpos + 80, Ymid, Color.Green); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if ((type == 0xB552A) || (type == 0xB5C42) || (type == 0xB5AFE)) // Following Orca, Returning Orca, & Idling Orca { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xB624A) // Orca Mother { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; - int height = _api.MemLib.ReadS16(curObj + 0x48) + 32; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; + int height = Mem.ReadS16(curObj + 0x48) + 32; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawBoxMWH(Xmid, Ymid, 80, 32, Color.Red, 31); - DrawBoxMWH(Xmid, Ymid, _api.MemLib.ReadS16(curObj + 0x44), _api.MemLib.ReadS16(curObj + 0x48), Color.Blue); + DrawBoxMWH(Xmid, Ymid, Mem.ReadS16(curObj + 0x44), Mem.ReadS16(curObj + 0x48), Color.Blue); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); - if (_api.MemLib.ReadS32(0xFFAB7E) != 0) + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + if (Mem.ReadS32(0xFFAB7E) != 0) { DrawEccoOct(Xmid, Ymid, 0x50, Color.Red, 31); } } else if (type == 0xC047E) { - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; var width = 2; var height = 2; - if (_api.MemLib.ReadByte(curObj + 0x15) == 0) + if (Mem.ReadByte(curObj + 0x15) == 0) { - width = _api.MemLib.ReadS16(curObj + 0x44); - height = _api.MemLib.ReadS16(curObj + 0x48); + width = Mem.ReadS16(curObj + 0x44); + height = Mem.ReadS16(curObj + 0x48); } DrawBoxMWH(Xmid, Ymid, width, height, Color.Lime); } else if (type == 0xC056E) { - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; - var width = _api.MemLib.ReadS16(curObj + 0x44); - var height = _api.MemLib.ReadS16(curObj + 0x48); + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; + var width = Mem.ReadS16(curObj + 0x44); + var height = Mem.ReadS16(curObj + 0x48); DrawBoxMWH(Xmid, Ymid, width, height, Color.Lime); } else if (type == 0xC4208) // Broken Glyph Base { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; - var width = _api.MemLib.ReadS16(curObj + 0x44); - var height = _api.MemLib.ReadS16(curObj + 0x48); + var width = Mem.ReadS16(curObj + 0x44); + var height = Mem.ReadS16(curObj + 0x48); DrawBoxMWH(Xmid, Ymid, width, height, Color.PowderBlue); - if (_api.MemLib.ReadByte(curObj + 0x15) == 0) + if (Mem.ReadByte(curObj + 0x15) == 0) { DrawRectRhombusIntersection(new Point(Xmid, Ymid), new Point(Xmid, Ymid), 80, 80, 120, Color.Orange); } DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xAC242) // Broken Glyph Top repairing { - uint subObj = _api.MemLib.ReadU24(curObj + 0x5); - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; - Xpos = _api.MemLib.ReadS16(subObj + 0x24) - _camX; - Ypos = _api.MemLib.ReadS16(subObj + 0x28) - _camY; - var width = _api.MemLib.ReadS16(curObj + 0x44); - var height = _api.MemLib.ReadS16(curObj + 0x48); + uint subObj = Mem.ReadU24(curObj + 0x5); + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; + Xpos = Mem.ReadS16(subObj + 0x24) - _camX; + Ypos = Mem.ReadS16(subObj + 0x28) - _camY; + var width = Mem.ReadS16(curObj + 0x44); + var height = Mem.ReadS16(curObj + 0x48); DrawBoxMWH(Xmid, Ymid, width, height, Color.Gray); Point[] rhombPoints = { @@ -1791,98 +1808,98 @@ namespace BizHawk.Client.EmuHawk new Point(Xpos + 3, Ypos), new Point(Xpos, Ypos + 3) }; - _api.GUILib.DrawPolygon(rhombPoints, Color.Orange, Color.FromArgb(63, Color.Orange)); + Gui.DrawPolygon(rhombPoints, Color.Orange, Color.FromArgb(63, Color.Orange)); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xpos, Ypos, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xpos, Ypos, Color.Orange); } else if (type == 0xBE9C8) // Broken Glyph Top free { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Blue); DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Lime, 0); - _api.GUILib.DrawLine(Xpos, Ypos2, Xpos2, Ypos, Color.Lime); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Gui.DrawLine(Xpos, Ypos2, Xpos2, Ypos, Color.Lime); + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - TickerText($"{_api.MemLib.ReadS32(curObj + 0x54) / 65536.0:0.######}:{_api.MemLib.ReadS32(curObj + 0x58) / 65536.0:0.######}", Color.Lime); _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + TickerText($"{Mem.ReadS32(curObj + 0x54) / 65536.0:0.######}:{Mem.ReadS32(curObj + 0x58) / 65536.0:0.######}", Color.Lime); Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if ((type == 0xD9C0E) || (type == 0xDA9EA)) { - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; DrawBoxMWH(Xmid, Ymid, 0xA0, 0x70, Color.Red); } else if ((type == 0xBF204) || (type == 0xDA2C0)) { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54) + _api.MemLib.ReadS32(curObj + 0x5C)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58) + _api.MemLib.ReadS32(curObj + 0x60)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54) + Mem.ReadS32(curObj + 0x5C)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58) + Mem.ReadS32(curObj + 0x60)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.PowderBlue); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xAF9CC) // Mirror Dolphin { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xpos = _api.MemLib.ReadS16(curObj + 0x1C) - _camX + (_api.MemLib.ReadByte(curObj + 0x15) == 0 ? 27 : -27); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54) + _api.MemLib.ReadS32(curObj + 0x5C)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58) + _api.MemLib.ReadS32(curObj + 0x60)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xpos = Mem.ReadS16(curObj + 0x1C) - _camX + (Mem.ReadByte(curObj + 0x15) == 0 ? 27 : -27); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54) + Mem.ReadS32(curObj + 0x5C)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58) + Mem.ReadS32(curObj + 0x60)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; - var width = _api.MemLib.ReadS16(curObj + 0x44); - var height = _api.MemLib.ReadS16(curObj + 0x48); + var width = Mem.ReadS16(curObj + 0x44); + var height = Mem.ReadS16(curObj + 0x48); DrawBoxMWH(Xmid, Ymid, width, height, Color.Blue, 31); - if (_api.MemLib.ReadByte(curObj + 0x13) != 0xAC) + if (Mem.ReadByte(curObj + 0x13) != 0xAC) { DrawBoxMWH(Xmid, Ymid, 96, 96, Color.Orange); } - _api.GUILib.DrawLine(Xpos, 0, Xpos, 448, Color.Red); + Gui.DrawLine(Xpos, 0, Xpos, 448, Color.Red); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xAF43E) // Vortex Lightning Trap { - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; - if (_api.MemLib.ReadByte(curObj + 0x15) != 0) + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; + if (Mem.ReadByte(curObj + 0x15) != 0) { - if (_api.MemLib.ReadS16(0xFFAA12) != 0) + if (Mem.ReadS16(0xFFAA12) != 0) { Ymid -= 8; } DrawBoxMWH(Xmid, Ymid, 92, 16, Color.Red); - PutText(_api.MemLib.ReadByte(curObj + 0x15).ToString(), Xmid, Ymid, 1, 1, -1, -1, Color.Blue, Color.Red); + PutText(Mem.ReadByte(curObj + 0x15).ToString(), Xmid, Ymid, 1, 1, -1, -1, Color.Blue, Color.Red); } else { DrawBoxMWH(Xmid, Ymid, 92, 16, Color.Gray); - PutText(_api.MemLib.ReadByte(curObj + 0x7F).ToString(), Xmid, Ymid, 1, 1, -1, -1, Color.Blue, Color.Red); + PutText(Mem.ReadByte(curObj + 0x7F).ToString(), Xmid, Ymid, 1, 1, -1, -1, Color.Blue, Color.Red); } } else if (type == 0xA6E24) // Barrier Glyph Forcefield { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = _api.MemLib.ReadS32(0xFFAA1A) - Xmid; - Yvec = _api.MemLib.ReadS32(0xFFAA1E) - Ymid; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = Mem.ReadS32(0xFFAA1A) - Xmid; + Yvec = Mem.ReadS32(0xFFAA1E) - Ymid; var div = Math.Abs(Xvec) + Math.Abs(Yvec); Xvec /= div; Yvec /= div; Xvec += Xmid; Yvec += Ymid; @@ -1891,31 +1908,31 @@ namespace BizHawk.Client.EmuHawk Xmid -= _camX; Ymid -= _camY; Xvec -= _camX; Yvec -= _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if ((type == 0xC4A44) || (type == 0xAA32C)) // Pulsar power-up and Vortex bullet-spawner { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Blue, 16); } else if (type == 0xC2F00) // Sky bubbles { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; - var mode = _api.MemLib.ReadByte(curObj + 0x15); + var mode = Mem.ReadByte(curObj + 0x15); switch (mode) { case 0: @@ -1933,75 +1950,75 @@ namespace BizHawk.Client.EmuHawk break; } DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0x9FA7E) //Air refiller/drainer { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.FromArgb(63, Color.Lime)); } else if (type == 0xBFC14) //Pushable fish { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Blue); DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Lime, 0); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); - TickerText($"{_api.MemLib.ReadS32(curObj + 0x54) / 65536.0:0.######}:{_api.MemLib.ReadS32(curObj + 0x58) / 65536.0:0.######}", Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + TickerText($"{Mem.ReadS32(curObj + 0x54) / 65536.0:0.######}:{Mem.ReadS32(curObj + 0x58) / 65536.0:0.######}", Color.Orange); } else if ((type == 0xBE97C) //Slowing Kelp //Default Bounds nose-responsive || (type == 0xACDAE)) //Metasphere { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xACB42) // Turtle { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; - var mode = _api.MemLib.ReadByte(curObj + 0x15); + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; + var mode = Mem.ReadByte(curObj + 0x15); switch (mode) { case 0: case 1: case 2: case 3: - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x4C)) >> 16) - _camX; + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x4C)) >> 16) - _camX; break; case 4: case 5: case 6: case 7: - Xvec = ((Xmid - _api.MemLib.ReadS32(curObj + 0x4C)) >> 16) - _camX; + Xvec = ((Xmid - Mem.ReadS32(curObj + 0x4C)) >> 16) - _camX; break; default: Xvec = (Xmid >> 16) - _camX; @@ -2011,300 +2028,300 @@ namespace BizHawk.Client.EmuHawk Xmid >>= 16; Xmid -= _camX; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); - _api.GUILib.DrawLine(Xpos, Ypos2, Xpos2, Ypos, Color.Lime); - int width = _api.MemLib.ReadS16(curObj + 0x44) << 1; + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); + Gui.DrawLine(Xpos, Ypos2, Xpos2, Ypos, Color.Lime); + int width = Mem.ReadS16(curObj + 0x44) << 1; DrawBox(Xpos - width, Ypos - (width << 2), Xpos2 + width, Ypos2, Color.Lime); - TickerText($"{_api.MemLib.ReadS32(curObj + 0x4C) / 65536.0:0.######}:{_api.MemLib.ReadS32(curObj + 0x50) / 65536.0:0.######}", Color.Lime); + TickerText($"{Mem.ReadS32(curObj + 0x4C) / 65536.0:0.######}:{Mem.ReadS32(curObj + 0x50) / 65536.0:0.######}", Color.Lime); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xACA7E) // Retracting Turtle { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + (_api.MemLib.ReadS32(curObj + 0x4C) >> 1)) >> 16) - _camX; - Yvec = ((Ymid + (_api.MemLib.ReadS32(curObj + 0x50) >> 1)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + (Mem.ReadS32(curObj + 0x4C) >> 1)) >> 16) - _camX; + Yvec = ((Ymid + (Mem.ReadS32(curObj + 0x50) >> 1)) >> 16) - _camY; Xmid >>= 16; Xmid -= _camX; Ymid >>= 16; Ymid -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); - _api.GUILib.DrawLine(Xpos, Ypos2, Xpos2, Ypos, Color.Lime); - int width = _api.MemLib.ReadS16(curObj + 0x44) << 1; + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); + Gui.DrawLine(Xpos, Ypos2, Xpos2, Ypos, Color.Lime); + int width = Mem.ReadS16(curObj + 0x44) << 1; DrawBox(Xpos - width, Ypos - (width << 2), Xpos2 + width, Ypos2, Color.Lime); - TickerText($"{(_api.MemLib.ReadS32(curObj + 0x4C) >> 1) / 65536.0:0.######}:{(_api.MemLib.ReadS32(curObj + 0x50) >> 1) / 65536.0:0.######}", Color.Lime); + TickerText($"{(Mem.ReadS32(curObj + 0x4C) >> 1) / 65536.0:0.######}:{(Mem.ReadS32(curObj + 0x50) >> 1) / 65536.0:0.######}", Color.Lime); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if ((type == 0xB5134) || (type == 0xA7E0C) //Default Bounds sonar-responsive || (type == 0xAF868) || (type == 0xAF960) || (type == 0xD8E5C) || (type == 0xAA5C6)) { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Blue); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if ((type == 0xACCB4) || (type == 0xACD7E) //Default Baunds non-responsive || (type == 0xD8D96) || (type == 0xA955E) || (type == 0xA92E4) || (type == 0xC05DC) || (type == 0xC2684)) { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Gray); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0x9DE86) // Star Wreath { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; - Xpos = _api.MemLib.ReadS32(curObj + 0x1C); - Ypos = _api.MemLib.ReadS32(curObj + 0x20); - Xpos2 = ((Xpos + _api.MemLib.ReadS32(curObj + 0x5C)) >> 16) - _camX; - Ypos2 = ((Ypos + _api.MemLib.ReadS32(curObj + 0x60)) >> 16) - _camY; + Xpos = Mem.ReadS32(curObj + 0x1C); + Ypos = Mem.ReadS32(curObj + 0x20); + Xpos2 = ((Xpos + Mem.ReadS32(curObj + 0x5C)) >> 16) - _camX; + Ypos2 = ((Ypos + Mem.ReadS32(curObj + 0x60)) >> 16) - _camY; Xpos >>= 16; Ypos >>= 16; Xpos -= _camX; Ypos -= _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Orange, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); - DrawBoxMWH(Xpos, Ypos, 1, 1, (_api.MemLib.ReadByte(curObj + 0x7F) == 0) ? Color.Blue : Color.Black, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Orange); - if (_api.MemLib.ReadByte(curObj + 0x12) % 7 == 0) + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + DrawBoxMWH(Xpos, Ypos, 1, 1, (Mem.ReadByte(curObj + 0x7F) == 0) ? Color.Blue : Color.Black, 0); + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Orange); + if (Mem.ReadByte(curObj + 0x12) % 7 == 0) { - TickerText($"{_api.MemLib.ReadS32(curObj + 0x5C) / 65536.0:0.######}:{_api.MemLib.ReadS32(curObj + 0x60) / 65536.0:0.######}:{_api.MemLib.ReadByte(curObj + 0x7F)}", Color.Lime); + TickerText($"{Mem.ReadS32(curObj + 0x5C) / 65536.0:0.######}:{Mem.ReadS32(curObj + 0x60) / 65536.0:0.######}:{Mem.ReadByte(curObj + 0x7F)}", Color.Lime); } } else if ((type == 0x9D774) || (type == 0x9DA26)) // Fish { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; DrawBoxMWH(Xmid, Ymid, 0x14, 0x14, Color.Lime); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xAD87C) // Enemy dolphins in metamorph levels { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; - DrawBoxMWH(_api.MemLib.ReadS16(curObj + 0x1C) - _camX, _api.MemLib.ReadS16(curObj + 0x20) - _camY, 1024, 1024, Color.Orange, 0); + DrawBoxMWH(Mem.ReadS16(curObj + 0x1C) - _camX, Mem.ReadS16(curObj + 0x20) - _camY, 1024, 1024, Color.Orange, 0); DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Red); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xC6128) // Drone attacking dolphin { - Xmid = _api.MemLib.ReadS16(curObj + 0x4C) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x50) - _camY; + Xmid = Mem.ReadS16(curObj + 0x4C) - _camX; + Ymid = Mem.ReadS16(curObj + 0x50) - _camY; DrawEccoOct(Xmid, Ymid, 360, Color.Red, 0); } else if (type == 0xC605A) // Drone attacking dolphin sonar { - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camY; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xmid = Mem.ReadS16(curObj + 0x24) - _camY; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; DrawBox(Xmid, Ymid - 1, Xmid + 32, Ymid + 1, Color.Orange); } else if (type == 0xB1BE0) // Globe { - int mode = _api.MemLib.ReadS8(curObj + 0x15); + int mode = Mem.ReadS8(curObj + 0x15); if (mode == 1) { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Blue); DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Lime, 0); - _api.GUILib.DrawLine(Xpos, Ypos2, Xpos2, Ypos, Color.Lime); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Gui.DrawLine(Xpos, Ypos2, Xpos2, Ypos, Color.Lime); + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Lime); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xB1A10) // Approaching globes { - Xmid = _api.MemLib.ReadS16(0xFFAA1A) - _camX; - Ymid = _api.MemLib.ReadS16(0xFFAA1E) - _camY; + Xmid = Mem.ReadS16(0xFFAA1A) - _camX; + Ymid = Mem.ReadS16(0xFFAA1E) - _camY; DrawEccoOct(Xmid - 56, Ymid, 8, Color.Orange); DrawEccoOct(Xmid + 56, Ymid, 8, Color.Orange); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xpos = _api.MemLib.ReadS32(curObj + 0x4C); - Ypos = _api.MemLib.ReadS32(curObj + 0x50); - Xvec = ((Xmid - _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid - _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; - Xpos2 = ((Xpos + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Ypos2 = ((Ypos + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xpos = Mem.ReadS32(curObj + 0x4C); + Ypos = Mem.ReadS32(curObj + 0x50); + Xvec = ((Xmid - Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid - Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos2 = ((Xpos + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Ypos2 = ((Ypos + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; Xpos >>= 16; Ypos >>= 16; Xpos -= _camX; Ypos -= _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Orange); + Gui.DrawLine(Xpos, Ypos, Xpos2, Ypos2, Color.Orange); } else if (type == 0xB1920) // Orbiting globes { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xpos = _api.MemLib.ReadS16(curObj + 0x4C) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x50) - _camY; - Xvec = ((Xmid - _api.MemLib.ReadS32(curObj + 0x5C)) >> 16) - _camX; - Yvec = ((Ymid - _api.MemLib.ReadS32(curObj + 0x60)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xpos = Mem.ReadS16(curObj + 0x4C) - _camX; + Ypos = Mem.ReadS16(curObj + 0x50) - _camY; + Xvec = ((Xmid - Mem.ReadS32(curObj + 0x5C)) >> 16) - _camX; + Yvec = ((Ymid - Mem.ReadS32(curObj + 0x60)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); DrawBoxMWH(Xpos, Ypos, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xpos, Ypos, Xvec, Yvec, Color.Orange); } else if (type == 0xC28A0) // Control point in Four Islands/Dolphin that gives Rock-breaking song { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; - DrawBox(Xpos, Ypos, Xpos2, Ypos2, _api.MemLib.ReadByte(curObj + 0x15) == 0 ? Color.Orange : Color.Blue); + DrawBox(Xpos, Ypos, Xpos2, Ypos2, Mem.ReadByte(curObj + 0x15) == 0 ? Color.Orange : Color.Blue); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } // Crystal Springs merging glyphs else if (type == 0xC651E) // Bound glyph { - Xpos = _api.MemLib.ReadS16(curObj + 0x1C) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x20) - _camY; + Xpos = Mem.ReadS16(curObj + 0x1C) - _camX; + Ypos = Mem.ReadS16(curObj + 0x20) - _camY; DrawEccoRhomb(Xpos, Ypos, 4 << 4, Color.Orange); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Blue); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xC67E4) // Freed glyph { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Blue); DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.PowderBlue, 0); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xC6970) // Pulled glyph { - uint subObj = _api.MemLib.ReadU24(curObj + 5); - Xvec = _api.MemLib.ReadS32(subObj + 0x54); - Yvec = _api.MemLib.ReadS32(subObj + 0x58); - for (i = 1; i < _api.MemLib.ReadByte(curObj + 0x7F); i++) + uint subObj = Mem.ReadU24(curObj + 5); + Xvec = Mem.ReadS32(subObj + 0x54); + Yvec = Mem.ReadS32(subObj + 0x58); + for (i = 1; i < Mem.ReadByte(curObj + 0x7F); i++) { Xvec ^= Yvec; Yvec ^= Xvec; Xvec ^= Yvec; Xvec = 0 - Xvec; } - Xpos = (Xvec + _api.MemLib.ReadS32(subObj + 0x1C) >> 16) - _camX; - Ypos = (Yvec + _api.MemLib.ReadS32(subObj + 0x20) >> 16) - _camY; + Xpos = (Xvec + Mem.ReadS32(subObj + 0x1C) >> 16) - _camX; + Ypos = (Yvec + Mem.ReadS32(subObj + 0x20) >> 16) - _camY; DrawEccoRhomb(Xpos, Ypos, 3, Color.Orange); - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.PowderBlue, 0); - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Orange, 0); } else if (type == 0xC6BA8) // Delivery Point { - Xvec = _api.MemLib.ReadS32(curObj + 0x54); - Yvec = _api.MemLib.ReadS32(curObj + 0x58); - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xvec = Mem.ReadS32(curObj + 0x54); + Yvec = Mem.ReadS32(curObj + 0x58); + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); for (i = 0; i < 4; i++) { - Xpos = (Xvec + _api.MemLib.ReadS32(curObj + 0x1C) >> 16) - _camX; - Ypos = (Yvec + _api.MemLib.ReadS32(curObj + 0x20) >> 16) - _camY; - _api.GUILib.DrawLine(Xmid, Ymid, Xpos, Ypos, Color.Orange); + Xpos = (Xvec + Mem.ReadS32(curObj + 0x1C) >> 16) - _camX; + Ypos = (Yvec + Mem.ReadS32(curObj + 0x20) >> 16) - _camY; + Gui.DrawLine(Xmid, Ymid, Xpos, Ypos, Color.Orange); Xvec ^= Yvec; Yvec ^= Xvec; Xvec ^= Yvec; @@ -2313,46 +2330,46 @@ namespace BizHawk.Client.EmuHawk } else if (type == 0xC6A6C) // Delivered glyph { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid - _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid - _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid - Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid - Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xC6F82) // Full delivery point { - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; DrawEccoOct(Xmid, Ymid, 3, Color.Orange); } else if (type == 0xC6A9E) // Merging glyph { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid - _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid - _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid - Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid - Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Orange, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xC7052) { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS16(curObj + 0x24); - Ymid = _api.MemLib.ReadS16(curObj + 0x28); + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS16(curObj + 0x24); + Ymid = Mem.ReadS16(curObj + 0x28); Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; - uint dropSpeed = _api.MemLib.ReadU8(curObj + 0x16); + uint dropSpeed = Mem.ReadU8(curObj + 0x16); DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Red); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xmid, Ymid + (int)(dropSpeed), Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xmid, Ymid + (int)(dropSpeed), Color.Orange); } else if ((type == 0xD8B7C) || (type == 0xD89EA) || (type == 0x9E3AA) || (type == 0x9E5A8) // GFX particles don't need displayed. || (type == 0x9B5D8) || (type == 0x9E2A6) || (type == 0xACD1E) || (type == 0xD9678) @@ -2380,14 +2397,14 @@ namespace BizHawk.Client.EmuHawk || (type == 0xC32C8) || (type == 0xAB5E6) || (type == 0xAC796) || (type == 0xAC9F2) || (type == 0xA538A)) { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; @@ -2397,7 +2414,7 @@ namespace BizHawk.Client.EmuHawk if (type != 0xA975E) { DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } if (HP > 2) { @@ -2406,33 +2423,33 @@ namespace BizHawk.Client.EmuHawk } else // Default bounds { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.PowderBlue, 0); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); PutText(type.ToString("X5"), Xmid, Ymid + 8, 1, 9, -1, -1, Color.Blue, Color.Red); } break; } case Modes.Ecco1: - type = _api.MemLib.ReadU32(curObj + 0x6); - Xpos = _api.MemLib.ReadS16(curObj + 0x17); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x1F); - Ypos = _api.MemLib.ReadS16(curObj + 0x1B); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x23); - Xmid = _api.MemLib.ReadS16(curObj + 0x0F); - Ymid = _api.MemLib.ReadS16(curObj + 0x13); + type = Mem.ReadU32(curObj + 0x6); + Xpos = Mem.ReadS16(curObj + 0x17); + Xpos2 = Mem.ReadS16(curObj + 0x1F); + Ypos = Mem.ReadS16(curObj + 0x1B); + Ypos2 = Mem.ReadS16(curObj + 0x23); + Xmid = Mem.ReadS16(curObj + 0x0F); + Ymid = Mem.ReadS16(curObj + 0x13); Xpos >>= 2; Xpos2 >>= 2; Ypos >>= 2; @@ -2446,13 +2463,13 @@ namespace BizHawk.Client.EmuHawk PutText(type.ToString("X8"), Xmid, Ymid, 1, 1, -1, -1, Color.Blue, Color.Red); break; } - curObj = _api.MemLib.ReadU24(curObj+1); + curObj = Mem.ReadU24(curObj+1); } //events - curObj = _api.MemLib.ReadU24(0xFFCFB5); + curObj = Mem.ReadU24(0xFFCFB5); while (curObj != 0) { - type = _api.MemLib.ReadU32(curObj + 0xC); + type = Mem.ReadU32(curObj + 0xC); if ((type == 0) // Null object || (type == 0x9C1FA) || (type == 0x9C6D0) // Skytubes BG Image manager || (type == 0x9ED72) || (type == 0xA57F2) // And Miscellaneous GFX particles @@ -2460,22 +2477,22 @@ namespace BizHawk.Client.EmuHawk || (type == 0xB308A) || (type == 0xA1676) || (type == 0xB6822) || (type == 0xD12E2)) { } else if ((type == 0xA44EE) || (type == 0xD120C)) { - Xmid = _api.MemLib.ReadS16(curObj + 0x1C) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x20) - _camY; + Xmid = Mem.ReadS16(curObj + 0x1C) - _camX; + Ymid = Mem.ReadS16(curObj + 0x20) - _camY; DrawEccoOct(Xmid, Ymid, 0x20, Color.Red); } else if (type == 0x9F0D0) // Water Current { - int Xvec = _api.MemLib.ReadS32(curObj + 0x54); - int Yvec = _api.MemLib.ReadS32(curObj + 0x58); + int Xvec = Mem.ReadS32(curObj + 0x54); + int Yvec = Mem.ReadS32(curObj + 0x58); if ((Xvec != 0) || (Yvec != 0)) { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); Xvec += Xmid; Yvec += Ymid; Xmid >>= 16; Ymid >>= 16; Xvec >>= 16; Yvec >>= 16; @@ -2485,73 +2502,73 @@ namespace BizHawk.Client.EmuHawk Xvec -= _camX; Yvec -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.FromArgb(63, Color.Red)); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } } else if (type == 0xDEF94) { - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; DrawEccoOct(Xmid, Ymid, 0x18, Color.Cyan); } else if (type == 0xA6584) // Eagle { - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; DrawEccoOct(Xmid, Ymid, 0x10, Color.Red); } else if ((type == 0x9BA8A) // Autoscroller controller || (type == 0xE27D4) || (type == 0xE270E) || (type == 0xE26C2)) { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - var Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - var Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + var Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + var Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Orange, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0x9B948) // Autoscroller waypoint { - Xmid = _api.MemLib.ReadS32(curObj + 0x24); - Ymid = _api.MemLib.ReadS32(curObj + 0x28); - var Xvec = ((Xmid + _api.MemLib.ReadS32(curObj + 0x54)) >> 16) - _camX; - var Yvec = ((Ymid + _api.MemLib.ReadS32(curObj + 0x58)) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj + 0x24); + Ymid = Mem.ReadS32(curObj + 0x28); + var Xvec = ((Xmid + Mem.ReadS32(curObj + 0x54)) >> 16) - _camX; + var Yvec = ((Ymid + Mem.ReadS32(curObj + 0x58)) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawBoxMWH(Xmid, Ymid, 8, 8, Color.Orange); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } else if (type == 0xA5448) // Bomb spawner { - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; - PutText($"{_api.MemLib.ReadU16(curObj + 0x6E)}", Xmid, Ymid, 1, 1, -1, -1, Color.White, Color.Blue); + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; + PutText($"{Mem.ReadU16(curObj + 0x6E)}", Xmid, Ymid, 1, 1, -1, -1, Color.White, Color.Blue); } else if ((type == 0xA529C) || (type == 0xA5236) || (type == 0xA51E6)) // Explosion { - uint subObj = _api.MemLib.ReadU24(curObj + 5); + uint subObj = Mem.ReadU24(curObj + 5); if (subObj != 0) { - Xpos = _api.MemLib.ReadS16(subObj + 0x1C) - _camX; - Ypos = _api.MemLib.ReadS16(subObj + 0x28) - _camY; - int Width = _api.MemLib.ReadS16(subObj + 0x24) - Xpos - _camX; + Xpos = Mem.ReadS16(subObj + 0x1C) - _camX; + Ypos = Mem.ReadS16(subObj + 0x28) - _camY; + int Width = Mem.ReadS16(subObj + 0x24) - Xpos - _camX; DrawBoxMWH(Xpos, Ypos, Width, 16, Color.Red); } - subObj = _api.MemLib.ReadU24(curObj + 9); + subObj = Mem.ReadU24(curObj + 9); if (subObj != 0) { - Xpos = _api.MemLib.ReadS16(subObj + 0x1C) - _camX; - Ypos = _api.MemLib.ReadS16(subObj + 0x28) - _camY; - int Width = _api.MemLib.ReadS16(subObj + 0x24) - Xpos - _camX; + Xpos = Mem.ReadS16(subObj + 0x1C) - _camX; + Ypos = Mem.ReadS16(subObj + 0x28) - _camY; + int Width = Mem.ReadS16(subObj + 0x24) - Xpos - _camX; DrawBoxMWH(Xpos, Ypos, Width, 16, Color.Red); } } else if (type == 0x9B5D8) { - var subtype = _api.MemLib.ReadByte(curObj + 0x13); + var subtype = Mem.ReadByte(curObj + 0x13); int width = 0; int height = 0; switch (subtype) @@ -2568,10 +2585,10 @@ namespace BizHawk.Client.EmuHawk case 59: case 87: case 181: - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; - width = _api.MemLib.ReadS16(curObj + 0x44); - height = _api.MemLib.ReadS16(curObj + 0x48); + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; + width = Mem.ReadS16(curObj + 0x44); + height = Mem.ReadS16(curObj + 0x48); DrawEccoOct(Xmid, Ymid, (width + height) >> 1, Color.Lime); break; case 71: @@ -2579,10 +2596,10 @@ namespace BizHawk.Client.EmuHawk case 158: case 159: case 165: - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Red); break; case 82: @@ -2590,71 +2607,71 @@ namespace BizHawk.Client.EmuHawk case 84: case 85: case 86: - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; - width = _api.MemLib.ReadS16(curObj + 0x44); - height = _api.MemLib.ReadS16(curObj + 0x48); + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; + width = Mem.ReadS16(curObj + 0x44); + height = Mem.ReadS16(curObj + 0x48); DrawBoxMWH(Xmid, Ymid, width, height, Color.Red); break; case 210: - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; - width = _api.MemLib.ReadS16(curObj + 0x44); - height = _api.MemLib.ReadS16(curObj + 0x48); + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; + width = Mem.ReadS16(curObj + 0x44); + height = Mem.ReadS16(curObj + 0x48); DrawBoxMWH(Xmid, Ymid, width, height, Color.Blue); break; case 107: - Xmid = (_api.MemLib.ReadS16(curObj + 0x18) << 7) - _camX + 0x40; - Ymid = (_api.MemLib.ReadS16(curObj + 0x1A) << 7) - _camY + 0x40; - Xpos = (_api.MemLib.ReadS16(curObj + 0x64) << 7) - _camX + 0x40; - Ypos = (_api.MemLib.ReadS16(curObj + 0x66) << 7) - _camY + 0x40; + Xmid = (Mem.ReadS16(curObj + 0x18) << 7) - _camX + 0x40; + Ymid = (Mem.ReadS16(curObj + 0x1A) << 7) - _camY + 0x40; + Xpos = (Mem.ReadS16(curObj + 0x64) << 7) - _camX + 0x40; + Ypos = (Mem.ReadS16(curObj + 0x66) << 7) - _camY + 0x40; DrawBoxMWH(Xmid, Ymid, 64, 64, Color.Orange, 0); DrawBoxMWH(Xpos, Ypos, 64, 64, Color.Orange, 0); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xpos, Ypos, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xpos, Ypos, Color.Orange); break; case 110: //Gravity conrol points case 179: - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; - DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.FromArgb(63,_api.MemLib.ReadByte(curObj + 0x15) == 0 ? Color.Gray : Color.Red)); + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; + DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.FromArgb(63,Mem.ReadByte(curObj + 0x15) == 0 ? Color.Gray : Color.Red)); DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Red, 0); - int dir = _api.MemLib.ReadS8(curObj + 0x71) & 7; + int dir = Mem.ReadS8(curObj + 0x71) & 7; int[] xtable = { 7, 4, -3, -10, -14, -11, -3, 4}; int[] ytable = { 11, 4, 7, 4, -3, -11, -14, -11}; - Xmid = _api.MemLib.ReadS16(curObj + 0x24) - _camX; - Ymid = _api.MemLib.ReadS16(curObj + 0x28) - _camY; + Xmid = Mem.ReadS16(curObj + 0x24) - _camX; + Ymid = Mem.ReadS16(curObj + 0x28) - _camY; DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawImage(".\\dll\\gravitometer_bg.png", Xmid - 15, Ymid - 15); - _api.GUILib.DrawImage(".\\dll\\gravitometer_fg.png", Xmid + xtable[dir], Ymid + ytable[dir]); + Gui.DrawImage(".\\dll\\gravitometer_bg.png", Xmid - 15, Ymid - 15); + Gui.DrawImage(".\\dll\\gravitometer_fg.png", Xmid + xtable[dir], Ymid + ytable[dir]); break; case 176: - Xmid = (_api.MemLib.ReadS16(curObj + 0x18) << 7) - _camX + 0x40; - Ymid = (_api.MemLib.ReadS16(curObj + 0x1A) << 7) - _camY + 0x40; - Xpos = (_api.MemLib.ReadS16(curObj + 0x64) << 7) - _camX + 0x40; - Ypos = (_api.MemLib.ReadS16(curObj + 0x66) << 7) - _camY + 0x40; + Xmid = (Mem.ReadS16(curObj + 0x18) << 7) - _camX + 0x40; + Ymid = (Mem.ReadS16(curObj + 0x1A) << 7) - _camY + 0x40; + Xpos = (Mem.ReadS16(curObj + 0x64) << 7) - _camX + 0x40; + Ypos = (Mem.ReadS16(curObj + 0x66) << 7) - _camY + 0x40; DrawEccoOct(Xmid, Ymid, 32, Color.Orange, 0); DrawEccoOct(Xpos, Ypos, 32, Color.Orange, 0); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xpos, Ypos, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xpos, Ypos, Color.Orange); break; case 194: // Kill plane - Xpos = _api.MemLib.ReadS16(curObj + 0x2C) - _camX; - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34) - _camX; - Ypos = _api.MemLib.ReadS16(curObj + 0x30) - _camY; - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38) - _camY; + Xpos = Mem.ReadS16(curObj + 0x2C) - _camX; + Xpos2 = Mem.ReadS16(curObj + 0x34) - _camX; + Ypos = Mem.ReadS16(curObj + 0x30) - _camY; + Ypos2 = Mem.ReadS16(curObj + 0x38) - _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Black, 127); DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Red, 0); break; default: - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2 = _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2 = _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS16(curObj + 0x24); - Ymid = _api.MemLib.ReadS16(curObj + 0x28); + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2 = Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2 = Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS16(curObj + 0x24); + Ymid = Mem.ReadS16(curObj + 0x28); Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; @@ -2666,58 +2683,58 @@ namespace BizHawk.Client.EmuHawk } else { - Xpos = _api.MemLib.ReadS16(curObj + 0x2C); - Xpos2= _api.MemLib.ReadS16(curObj + 0x34); - Ypos = _api.MemLib.ReadS16(curObj + 0x30); - Ypos2= _api.MemLib.ReadS16(curObj + 0x38); - Xmid = _api.MemLib.ReadS16(curObj + 0x24); - Ymid = _api.MemLib.ReadS16(curObj + 0x28); + Xpos = Mem.ReadS16(curObj + 0x2C); + Xpos2= Mem.ReadS16(curObj + 0x34); + Ypos = Mem.ReadS16(curObj + 0x30); + Ypos2= Mem.ReadS16(curObj + 0x38); + Xmid = Mem.ReadS16(curObj + 0x24); + Ymid = Mem.ReadS16(curObj + 0x28); Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.Cyan); - PutText($"{type:X5}:{_api.MemLib.ReadByte(curObj + 0x13)}", Xmid, Ymid - 4, 1, 1, -1, -9, Color.White, Color.Blue); + PutText($"{type:X5}:{Mem.ReadByte(curObj + 0x13)}", Xmid, Ymid - 4, 1, 1, -1, -9, Color.White, Color.Blue); PutText(curObj.ToString("X6"), Xmid, Ymid + 4, 1, 9, -1, -1, Color.White, Color.Blue); } - curObj = _api.MemLib.ReadU24(curObj+1); + curObj = Mem.ReadU24(curObj+1); } //Ecco head - Xpos = _api.MemLib.ReadS16(0xFFA8F8); - Xpos2 = _api.MemLib.ReadS16(0xFFA900); - Ypos = _api.MemLib.ReadS16(0xFFA8FC); - Ypos2 = _api.MemLib.ReadS16(0xFFA904); - Xmid = _api.MemLib.ReadS16(0xFFA8F0); - Ymid = _api.MemLib.ReadS16(0xFFA8F4); + Xpos = Mem.ReadS16(0xFFA8F8); + Xpos2 = Mem.ReadS16(0xFFA900); + Ypos = Mem.ReadS16(0xFFA8FC); + Ypos2 = Mem.ReadS16(0xFFA904); + Xmid = Mem.ReadS16(0xFFA8F0); + Ymid = Mem.ReadS16(0xFFA8F4); Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.PowderBlue); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.PowderBlue, 0); //Ecco tail - Xpos = _api.MemLib.ReadS16(0xFFA978); - Xpos2 = _api.MemLib.ReadS16(0xFFA980); - Ypos = _api.MemLib.ReadS16(0xFFA97C); - Ypos2 = _api.MemLib.ReadS16(0xFFA984); - Xmid = _api.MemLib.ReadS16(0xFFA970); - Ymid = _api.MemLib.ReadS16(0xFFA974); + Xpos = Mem.ReadS16(0xFFA978); + Xpos2 = Mem.ReadS16(0xFFA980); + Ypos = Mem.ReadS16(0xFFA97C); + Ypos2 = Mem.ReadS16(0xFFA984); + Xmid = Mem.ReadS16(0xFFA970); + Ymid = Mem.ReadS16(0xFFA974); Xpos -= _camX; Xpos2 -= _camX; Ypos -= _camY; Ypos2 -= _camY; Xmid -= _camX; Ymid -= _camY; DrawBox(Xpos, Ypos, Xpos2, Ypos2, Color.PowderBlue); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.PowderBlue, 0); //Ecco body - Xpos = _api.MemLib.ReadS32(0xFFAA22); - Ypos = _api.MemLib.ReadS32(0xFFAA26); - Xpos2 = _api.MemLib.ReadS32(0xFFAA2A); - Ypos2 = _api.MemLib.ReadS32(0xFFAA2E); - Xmid = _api.MemLib.ReadS16(0xFFAA1A); - Ymid = _api.MemLib.ReadS16(0xFFAA1E); - int Xvel = _api.MemLib.ReadS32(0xFFAA36); - if (_api.MemLib.ReadU32(0xFFA9D6) > 7) Xvel += _api.MemLib.ReadS32(0xFFA9D6); - if (_api.MemLib.ReadU32(0xFFAA3E) > 7) Xvel += _api.MemLib.ReadS32(0xFFAA3E); - int Yvel = _api.MemLib.ReadS32(0xFFAA3A); - if (_api.MemLib.ReadU32(0xFFA9DA) > 7) Yvel += _api.MemLib.ReadS32(0xFFA9DA); - if (_api.MemLib.ReadU32(0xFFAA42) > 7) Yvel += _api.MemLib.ReadS32(0xFFAA42); + Xpos = Mem.ReadS32(0xFFAA22); + Ypos = Mem.ReadS32(0xFFAA26); + Xpos2 = Mem.ReadS32(0xFFAA2A); + Ypos2 = Mem.ReadS32(0xFFAA2E); + Xmid = Mem.ReadS16(0xFFAA1A); + Ymid = Mem.ReadS16(0xFFAA1E); + int Xvel = Mem.ReadS32(0xFFAA36); + if (Mem.ReadU32(0xFFA9D6) > 7) Xvel += Mem.ReadS32(0xFFA9D6); + if (Mem.ReadU32(0xFFAA3E) > 7) Xvel += Mem.ReadS32(0xFFAA3E); + int Yvel = Mem.ReadS32(0xFFAA3A); + if (Mem.ReadU32(0xFFA9DA) > 7) Yvel += Mem.ReadS32(0xFFA9DA); + if (Mem.ReadU32(0xFFAA42) > 7) Yvel += Mem.ReadS32(0xFFAA42); int XV = ((Xpos + Xvel) >> 16) - _camX; int YV = ((Ypos + Yvel) >> 16) - _camY; int XV2 = ((Xpos2 + Xvel) >> 16) - _camX; @@ -2733,58 +2750,58 @@ namespace BizHawk.Client.EmuHawk int X4 = (Xmid + X2) >> 1; int Y3 = (Ymid + Y) >> 1; int Y4 = (Ymid + Y2) >> 1; - _api.GUILib.DrawLine(X, Y, Xmid, Ymid, Color.Green); - _api.GUILib.DrawLine(Xmid, Ymid, X2, Y2, Color.Green); + Gui.DrawLine(X, Y, Xmid, Ymid, Color.Green); + Gui.DrawLine(Xmid, Ymid, X2, Y2, Color.Green); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Red); DrawBoxMWH(X, Y, 1, 1, Color.Lime); DrawBoxMWH(X2, Y2, 1, 1, Color.Blue); DrawBoxMWH(X3, Y3, 1, 1, Color.Yellow); DrawBoxMWH(X4, Y4, 1, 1, Color.Yellow); - _api.GUILib.DrawLine(X, Y, XV, YV, Color.Orange); - _api.GUILib.DrawLine(X2, Y2, XV2, YV2, Color.Orange); + Gui.DrawLine(X, Y, XV, YV, Color.Orange); + Gui.DrawLine(X2, Y2, XV2, YV2, Color.Orange); // sonar - if (_api.MemLib.ReadU8(0xFFAB77) != 0) + if (Mem.ReadU8(0xFFAB77) != 0) { - Xmid = _api.MemLib.ReadS32(0xFFA9EC); - Ymid = _api.MemLib.ReadS32(0xFFA9F0); - int Xvec = ((_api.MemLib.ReadS32(0xFFAA04) + Xmid) >> 16) - _camX; - int Yvec = ((_api.MemLib.ReadS32(0xFFAA08) + Ymid) >> 16) - _camY; + Xmid = Mem.ReadS32(0xFFA9EC); + Ymid = Mem.ReadS32(0xFFA9F0); + int Xvec = ((Mem.ReadS32(0xFFAA04) + Xmid) >> 16) - _camX; + int Yvec = ((Mem.ReadS32(0xFFAA08) + Ymid) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; - Width2 = _api.MemLib.ReadS16(0xFFA9FC); - Height2 = _api.MemLib.ReadS16(0xFFAA00); - color = ((_api.MemLib.ReadU8(0xFFAA0C) != 0) ? Color.FromArgb(255, 0, 127) : Color.FromArgb(0, 0, 255)); + Width2 = Mem.ReadS16(0xFFA9FC); + Height2 = Mem.ReadS16(0xFFAA00); + color = ((Mem.ReadU8(0xFFAA0C) != 0) ? Color.FromArgb(255, 0, 127) : Color.FromArgb(0, 0, 255)); DrawBoxMWH(Xmid, Ymid, Width2, Height2, color); DrawBoxMWH(Xmid, Ymid, 1, 1, color, 0); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } //Pulsar - curObj = _api.MemLib.ReadU24(0xFFCFD1); - if ((curObj != 0) && ((_api.MemLib.ReadU32(curObj + 0xC) == 0xC9222) || (_api.MemLib.ReadU32(curObj + 0xC) == 0xC9456))) + curObj = Mem.ReadU24(0xFFCFD1); + if ((curObj != 0) && ((Mem.ReadU32(curObj + 0xC) == 0xC9222) || (Mem.ReadU32(curObj + 0xC) == 0xC9456))) { curObj += 0x26; for (int l = 0; l < 4; l++) { - if (_api.MemLib.ReadU16(curObj + 0x12) != 0) + if (Mem.ReadU16(curObj + 0x12) != 0) { - Xmid = _api.MemLib.ReadS32(curObj); - Ymid = _api.MemLib.ReadS32(curObj + 4); - int Xvec = (Xmid + _api.MemLib.ReadS32(curObj + 8) >> 16) - _camX; - int Yvec = (Ymid + _api.MemLib.ReadS32(curObj + 0xC) >> 16) - _camY; + Xmid = Mem.ReadS32(curObj); + Ymid = Mem.ReadS32(curObj + 4); + int Xvec = (Xmid + Mem.ReadS32(curObj + 8) >> 16) - _camX; + int Yvec = (Ymid + Mem.ReadS32(curObj + 0xC) >> 16) - _camY; Xmid >>= 16; Ymid >>= 16; Xmid -= _camX; Ymid -= _camY; DrawBoxMWH(Xmid, Ymid, 0x30, 0x30, Color.Red); DrawBoxMWH(Xmid, Ymid, 1, 1, Color.Blue); - _api.GUILib.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); + Gui.DrawLine(Xmid, Ymid, Xvec, Yvec, Color.Orange); } curObj += 0x14; } } //Water Level - int waterLevel = _api.MemLib.ReadS16(0xFFA7B2); - _api.GUILib.DrawLine(0, waterLevel - _camY, _left + 320 + _right, waterLevel - _camY, Color.Aqua); + int waterLevel = Mem.ReadS16(0xFFA7B2); + Gui.DrawLine(0, waterLevel - _camY, _left + 320 + _right, waterLevel - _camY, Color.Aqua); } @@ -2792,43 +2809,43 @@ namespace BizHawk.Client.EmuHawk { //Modif N - ECCO HACK - make caps lock (weirdly) autofire player 1's C key uint charge; - uint mode = _api.MemLib.ReadU8(0xFFA555); - int frameCount = _api.EmuLib.FrameCount(); - int lagCount = _api.EmuLib.LagCount(); - _api.JoypadLib.Set("Start", on, 1); + uint mode = Mem.ReadU8(0xFFA555); + int frameCount = Emu.FrameCount(); + int lagCount = Emu.LagCount(); + Joy.Set("Start", on, 1); switch (mode) { case 0x00: if (on) { - if (_api.MemLib.ReadU16(0xFFF342) == 0xFFFD) - _api.JoypadLib.Set("C", true, 1); + if (Mem.ReadU16(0xFFF342) == 0xFFFD) + Joy.Set("C", true, 1); else - _api.JoypadLib.Set("C", false, 1); + Joy.Set("C", false, 1); } break; case 0xE6: - if (_api.MemLib.ReadU16(0xFFD5E8) == 0x00000002) { + if (Mem.ReadU16(0xFFD5E8) == 0x00000002) { Dictionary buttons = new Dictionary(); buttons["B"] = buttons["C"] = true; - _api.JoypadLib.Set(buttons, 1); + Joy.Set(buttons, 1); } else { Dictionary buttons = new Dictionary(); buttons["B"] = buttons["C"] = false; - _api.JoypadLib.Set(buttons, 1); + Joy.Set(buttons, 1); } break; case 0xF6: - charge = _api.MemLib.ReadU8(0xFFB19B); + charge = Mem.ReadU8(0xFFB19B); if (on) { - if ((charge <= 1) && ((_api.MemLib.ReadU8(0xFFB1A6) == 0) || (_api.MemLib.ReadU8(0xFFB1A9) != 0))) - _api.JoypadLib.Set("B", true, 1); + if ((charge <= 1) && ((Mem.ReadU8(0xFFB1A6) == 0) || (Mem.ReadU8(0xFFB1A9) != 0))) + Joy.Set("B", true, 1); else if (charge > 1) - _api.JoypadLib.Set("B", false, 1); - _api.JoypadLib.Set("C", (_api.MemLib.ReadU16(0xFFA7C8) % 2) == 0, 1); + Joy.Set("B", false, 1); + Joy.Set("C", (Mem.ReadU16(0xFFA7C8) % 2) == 0, 1); } break; case 0x20: @@ -2836,19 +2853,19 @@ namespace BizHawk.Client.EmuHawk case 0xAC: if (on) { - if ((_api.MemLib.ReadU8(0xFFAB72) & 3) == 0) - _api.JoypadLib.Set("C", (_api.MemLib.ReadS8(0xFFAA6E) < 11), 1); + if ((Mem.ReadU8(0xFFAB72) & 3) == 0) + Joy.Set("C", (Mem.ReadS8(0xFFAA6E) < 11), 1); } break; default: break; } } - public override void Init(IPluginAPI api) + public override void Init(IApiContainer api) { base.Init(api); - _api.MemLib.SetBigEndian(); - string gameName = _api.GameInfoLib.GetRomName(); + Mem.SetBigEndian(); + string gameName = GI.GetRomName(); if ((gameName == "ECCO - The Tides of Time (J) [!]") || (gameName == "ECCO - The Tides of Time (U) [!]") || (gameName == "ECCO - The Tides of Time (E) [!]")) @@ -2858,7 +2875,7 @@ namespace BizHawk.Client.EmuHawk _camYAddr = 0xFFAD9E; _top = _bottom = 112; _left = _right = 160; - EmuHawkPluginLibrary.SetGameExtraPadding(_left, _top, _right, _bottom); + ClientApi.SetGameExtraPadding(_left, _top, _right, _bottom); } else if ((gameName == "ECCO The Dolphin (J) [!]") || (gameName == "ECCO The Dolphin (UE) [!]")) @@ -2869,7 +2886,7 @@ namespace BizHawk.Client.EmuHawk _camYAddr = 0xFFB834; _top = _bottom = 112; _left = _right = 160; - EmuHawkPluginLibrary.SetGameExtraPadding(_left, _top, _right, _bottom); + ClientApi.SetGameExtraPadding(_left, _top, _right, _bottom); } else { @@ -2879,48 +2896,47 @@ namespace BizHawk.Client.EmuHawk } private Color BackdropColor() { - uint color = _api.MemLib.ReadU16(0, "CRAM"); + uint color = Mem.ReadU16(0, "CRAM"); int r = (int)(( color & 0x7) * 0x22); int g = (int)(((color >> 3) & 0x7) * 0x22); int b = (int)(((color >> 6) & 0x7) * 0x22); return Color.FromArgb(r, g, b); - } public override void PreFrameCallback() { - _api.GUILib.ClearText(); + Gui.ClearText(); if (_mode != Modes.disabled) { - _camX = _api.MemLib.ReadS16(_camXAddr) - _left; - _camY = _api.MemLib.ReadS16(_camYAddr) - _top; - EccoAutofire(_api.JoypadLib.Get(1)["Start"]); + _camX = Mem.ReadS16(_camXAddr) - _left; + _camY = Mem.ReadS16(_camYAddr) - _top; + EccoAutofire(Joy.Get(1)["Start"]); if (_dumpMap == 0) { Color bg = BackdropColor(); - _api.GUILib.DrawRectangle(0, 0, _left + 320 + _right, _top, bg, bg); - _api.GUILib.DrawRectangle(0, 0, _left, _top + 224 + _bottom, bg, bg); - _api.GUILib.DrawRectangle(_left + 320, 0, _left + 320 + _right, _top + 224 + _bottom, bg, bg); - _api.GUILib.DrawRectangle(0, _top + 224, _left + 320 + _right, _top + 224 + _bottom, bg, bg); + Gui.DrawRectangle(0, 0, _left + 320 + _right, _top, bg, bg); + Gui.DrawRectangle(0, 0, _left, _top + 224 + _bottom, bg, bg); + Gui.DrawRectangle(_left + 320, 0, _left + 320 + _right, _top + 224 + _bottom, bg, bg); + Gui.DrawRectangle(0, _top + 224, _left + 320 + _right, _top + 224 + _bottom, bg, bg); } - uint mode = _api.MemLib.ReadByte(0xFFA555); + uint mode = Mem.ReadByte(0xFFA555); switch (mode) { case 0x20: case 0x28: case 0xAC: - //EmuHawkPluginLibrary.SetGameExtraPadding(160, 112, 160, 112); + //ClientApi.SetGameExtraPadding(160, 112, 160, 112); if (_dumpMap <= 1) EccoDrawBoxes(); // Uncomment the following block to enable mapdumping - if ((_api.MemLib.ReadU16(0xFFA7C8) > 1) && (_api.MemLib.ReadU16(0xFFA7C8) < 4)) + if ((Mem.ReadU16(0xFFA7C8) > 1) && (Mem.ReadU16(0xFFA7C8) < 4)) { _dumpMap = 1; _rowStateGuid = string.Empty; _top = _bottom = _left = _right = 0; - EmuHawkPluginLibrary.SetGameExtraPadding(0, 0, 0, 0); + ClientApi.SetGameExtraPadding(0, 0, 0, 0); } if (_dumpMap == 3) { - var levelID = _api.MemLib.ReadS8(0xFFA7D0); + var levelID = Mem.ReadS8(0xFFA7D0); int[] nameGroupLengths = { 7,1,11,6, @@ -2946,15 +2962,15 @@ namespace BizHawk.Client.EmuHawk if (i < 0) { i += nameGroupLengths[nameGroup]; - uint strOffset = _api.MemLib.ReadU32(nameStringPtrOffsets[nameGroup] + 0x2E); + uint strOffset = Mem.ReadU32(nameStringPtrOffsets[nameGroup] + 0x2E); Console.WriteLine($"{i}"); - strOffset = _api.MemLib.ReadU32(strOffset + ((i << 3) + (i << 5)) + 0x22); + strOffset = Mem.ReadU32(strOffset + ((i << 3) + (i << 5)) + 0x22); strOffset += 0x20; List strTmp = new List(); byte c; do { - c = (byte)_api.MemLib.ReadByte(strOffset++); + c = (byte)Mem.ReadByte(strOffset++); if (c != 0) strTmp.Add(c); } while (c != 0); @@ -2962,14 +2978,14 @@ namespace BizHawk.Client.EmuHawk TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; name = textInfo.ToTitleCase(name).Replace(" ", string.Empty); } - EmuHawkPluginLibrary.Screenshot($"c:\\Ecco2Maps\\{levelID}_{name}_top.png"); + ClientApi.Screenshot($"c:\\Ecco2Maps\\{levelID}_{name}_top.png"); _destX = _destY = 0; - EmuHawkPluginLibrary.SetGameExtraPadding(0, 0, 0, 0); + ClientApi.SetGameExtraPadding(0, 0, 0, 0); _dumpMap++; } if (_dumpMap == 6) { - var levelID = _api.MemLib.ReadS8(0xFFA7D0); + var levelID = Mem.ReadS8(0xFFA7D0); int[] nameGroupLengths = { 7,1,11,6, @@ -2995,15 +3011,15 @@ namespace BizHawk.Client.EmuHawk if (i < 0) { i += nameGroupLengths[nameGroup]; - uint strOffset = _api.MemLib.ReadU32(nameStringPtrOffsets[nameGroup] + 0x2E); + uint strOffset = Mem.ReadU32(nameStringPtrOffsets[nameGroup] + 0x2E); Console.WriteLine($"{i}"); - strOffset = _api.MemLib.ReadU32(strOffset + ((i << 3) + (i << 5)) + 0x22); + strOffset = Mem.ReadU32(strOffset + ((i << 3) + (i << 5)) + 0x22); strOffset += 0x20; List strTmp = new List(); byte c; do { - c = (byte)_api.MemLib.ReadByte(strOffset++); + c = (byte)Mem.ReadByte(strOffset++); if (c != 0) strTmp.Add(c); } while (c != 0); @@ -3011,11 +3027,11 @@ namespace BizHawk.Client.EmuHawk TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; name = textInfo.ToTitleCase(name).Replace(" ", string.Empty); } - EmuHawkPluginLibrary.Screenshot($"c:\\Ecco2Maps\\{levelID}_{name}_bottom.png"); + ClientApi.Screenshot($"c:\\Ecco2Maps\\{levelID}_{name}_bottom.png"); _destX = _destY = 0; _left = _right = 160; _top = _bottom = 112; - EmuHawkPluginLibrary.SetGameExtraPadding(_left, _top, _right, _bottom); + ClientApi.SetGameExtraPadding(_left, _top, _right, _bottom); _dumpMap = 0; } break; @@ -3025,52 +3041,52 @@ namespace BizHawk.Client.EmuHawk default: break; } - _prevF = _api.MemLib.ReadU32(0xFFA524); + _prevF = Mem.ReadU32(0xFFA524); } } public override void PostFrameCallback() { - uint frame = _api.MemLib.ReadU32(0xFFA524); - if ((frame <= _prevF) && !_api.EmuLib.IsLagged()) + uint frame = Mem.ReadU32(0xFFA524); + if ((frame <= _prevF) && !Emu.IsLagged()) { - _api.EmuLib.SetIsLagged(true); - _api.EmuLib.SetLagCount(_api.EmuLib.LagCount() + 1); + Emu.SetIsLagged(true); + Emu.SetLagCount(Emu.LagCount() + 1); } - uint mode = _api.MemLib.ReadByte(0xFFA555); + uint mode = Mem.ReadByte(0xFFA555); _tickerY = 81; - string valueTicker = $"{_api.MemLib.ReadU32(0xFFA520)}:{_api.MemLib.ReadU32(0xFFA524)}:{_api.MemLib.ReadU16(0xFFA7C8)}:{mode:X2}"; + string valueTicker = $"{Mem.ReadU32(0xFFA520)}:{Mem.ReadU32(0xFFA524)}:{Mem.ReadU16(0xFFA7C8)}:{mode:X2}"; TickerText(valueTicker); switch (mode) { case 0x20: case 0x28: case 0xAC: - valueTicker = $"{_api.MemLib.ReadS16(0xFFAD9C)}:{_api.MemLib.ReadS16(0xFFAD9E)}"; + valueTicker = $"{Mem.ReadS16(0xFFAD9C)}:{Mem.ReadS16(0xFFAD9E)}"; TickerText(valueTicker); - valueTicker = $"{_api.MemLib.ReadS32(0xFFAA1A) / 65536.0:0.######}:{_api.MemLib.ReadS32(0xFFAA1E) / 65536.0:0.######}"; + valueTicker = $"{Mem.ReadS32(0xFFAA1A) / 65536.0:0.######}:{Mem.ReadS32(0xFFAA1E) / 65536.0:0.######}"; TickerText(valueTicker); - valueTicker = $"{_api.MemLib.ReadS32(0xFFAA32) / 65536.0:0.######}:{_api.MemLib.ReadU8(0xFFAA6D)}:{_api.MemLib.ReadU8(0xFFAA6E)}"; + valueTicker = $"{Mem.ReadS32(0xFFAA32) / 65536.0:0.######}:{Mem.ReadU8(0xFFAA6D)}:{Mem.ReadU8(0xFFAA6E)}"; TickerText(valueTicker); - valueTicker = $"{_api.MemLib.ReadS32(0xFFAA36) / 65536.0:0.######}:{_api.MemLib.ReadS32(0xFFAA3A) / 65536.0:0.######}"; + valueTicker = $"{Mem.ReadS32(0xFFAA36) / 65536.0:0.######}:{Mem.ReadS32(0xFFAA3A) / 65536.0:0.######}"; TickerText(valueTicker); - valueTicker = $"{_api.MemLib.ReadS32(0xFFA9D6) / 65536.0:0.######}:{_api.MemLib.ReadS32(0xFFA9DA) / 65536.0:0.######}"; + valueTicker = $"{Mem.ReadS32(0xFFA9D6) / 65536.0:0.######}:{Mem.ReadS32(0xFFA9DA) / 65536.0:0.######}"; TickerText(valueTicker); - valueTicker = $"{_api.MemLib.ReadS32(0xFFAA3E) / 65536.0:0.######}:{_api.MemLib.ReadS32(0xFFAA42) / 65536.0:0.######}"; + valueTicker = $"{Mem.ReadS32(0xFFAA3E) / 65536.0:0.######}:{Mem.ReadS32(0xFFAA42) / 65536.0:0.######}"; TickerText(valueTicker); - valueTicker = $"{(_api.MemLib.ReadS32(0xFFAA36) + _api.MemLib.ReadS32(0xFFA9D6) + _api.MemLib.ReadS32(0xFFAA3E)) / 65536.0:0.######}:" + - $"{(_api.MemLib.ReadS32(0xFFAA3A) + _api.MemLib.ReadS32(0xFFA9DA) + _api.MemLib.ReadS32(0xFFAA42)) / 65536.0:0.######}"; + valueTicker = $"{(Mem.ReadS32(0xFFAA36) + Mem.ReadS32(0xFFA9D6) + Mem.ReadS32(0xFFAA3E)) / 65536.0:0.######}:" + + $"{(Mem.ReadS32(0xFFAA3A) + Mem.ReadS32(0xFFA9DA) + Mem.ReadS32(0xFFAA42)) / 65536.0:0.######}"; TickerText(valueTicker); - valueTicker = $"{_api.MemLib.ReadU8(0xFFAB72)}:{_api.MemLib.ReadU8(0xFFAB70)}:{(short)_api.MemLib.ReadS16(0xFFAA52):X4}:{(short)_api.MemLib.ReadS16(0xFFAA5A):X4}"; + valueTicker = $"{Mem.ReadU8(0xFFAB72)}:{Mem.ReadU8(0xFFAB70)}:{(short)Mem.ReadS16(0xFFAA52):X4}:{(short)Mem.ReadS16(0xFFAA5A):X4}"; TickerText(valueTicker); - switch (_api.MemLib.ReadU8(0xFFA7D0)) + switch (Mem.ReadU8(0xFFA7D0)) { case 1: case 2: case 3: case 30: case 46: - var globeFlags = _api.MemLib.ReadU32(0xFFD434) >> 1; - var globeFlags2 = _api.MemLib.ReadU32(0xFFD438) >> 1; + var globeFlags = Mem.ReadU32(0xFFD434) >> 1; + var globeFlags2 = Mem.ReadU32(0xFFD438) >> 1; int i, j = i = 0; while (globeFlags > 0) { @@ -3089,33 +3105,33 @@ namespace BizHawk.Client.EmuHawk } if (_dumpMap != 0) { - _api.MemLib.WriteS16(0xFFAA16, 7); - _api.MemLib.WriteS16(0xFFAA18, 56); - int PlayerX = _api.MemLib.ReadS16(0xFFAA1A) - _camX; - int PlayerY = _api.MemLib.ReadS16(0xFFAA1E) - _camY; + Mem.WriteS16(0xFFAA16, 7); + Mem.WriteS16(0xFFAA18, 56); + int PlayerX = Mem.ReadS16(0xFFAA1A) - _camX; + int PlayerY = Mem.ReadS16(0xFFAA1E) - _camY; if ((PlayerX < -64) || (PlayerX > 384) || (PlayerY < -64) || (PlayerY > 288)) { - _api.MemLib.WriteByte(0xFFAA70, 0xC); - _api.MemLib.WriteS16(0xFFA7CA, 1); + Mem.WriteByte(0xFFAA70, 0xC); + Mem.WriteS16(0xFFA7CA, 1); } else { - _api.MemLib.WriteByte(0xFFAA70, 0x0); - _api.MemLib.WriteS16(0xFFA7CA, 0); + Mem.WriteByte(0xFFAA70, 0x0); + Mem.WriteS16(0xFFA7CA, 0); } } if (_dumpMap == 1) { - int levelWidth = _api.MemLib.ReadS16(0xFFA7A8); - int levelHeight = _api.MemLib.ReadS16(0xFFA7AC); - var levelID = _api.MemLib.ReadByte(0xFFA7D0); - var s = _api.EmuLib.GetSettings() as GPGX.GPGXSettings; + int levelWidth = Mem.ReadS16(0xFFA7A8); + int levelHeight = Mem.ReadS16(0xFFA7AC); + var levelID = Mem.ReadByte(0xFFA7D0); + var s = Emu.GetSettings() as GPGX.GPGXSettings; s.DrawBGA = false; s.DrawBGB = false; s.DrawBGW = false; s.DrawObj = false; s.Backdrop = true; - _api.EmuLib.PutSettings(s); + Emu.PutSettings(s); if ((_camX == _destX) && (_camY == _destY)) { if ((_prevX != _camX) || (_prevY != _camY)) @@ -3124,9 +3140,9 @@ namespace BizHawk.Client.EmuHawk { if (_rowStateGuid != string.Empty) { - _api.MemStateLib.DeleteState(_rowStateGuid); + MemSS.DeleteState(_rowStateGuid); } - _rowStateGuid = _api.MemStateLib.SaveCoreStateToMemory(); + _rowStateGuid = MemSS.SaveCoreStateToMemory(); } _snapPast = 1; } @@ -3136,14 +3152,14 @@ namespace BizHawk.Client.EmuHawk } if (_snapPast == 0) { - EmuHawkPluginLibrary.Screenshot($"c:\\Ecco2Maps\\{levelID}\\{_destY}_{_destX}_top.png"); + ClientApi.Screenshot($"c:\\Ecco2Maps\\{levelID}\\{_destY}_{_destX}_top.png"); if (_destX >= levelWidth - 320) { if (_destY < levelHeight - 224) { if (_rowStateGuid != string.Empty) { - _api.MemStateLib.LoadCoreStateFromMemory(_rowStateGuid); + MemSS.LoadCoreStateFromMemory(_rowStateGuid); } _destX = 0; _destY = Math.Min(_destY + 111, levelHeight - 224); @@ -3153,70 +3169,70 @@ namespace BizHawk.Client.EmuHawk _destX = Math.Min(_destX + 159, levelWidth - 320); if ((_prevX == _destX) && (_prevY == _destY)) { - EmuHawkPluginLibrary.SetGameExtraPadding(levelWidth - 320, levelHeight - 224, 0, 0); + ClientApi.SetGameExtraPadding(levelWidth - 320, levelHeight - 224, 0, 0); _dumpMap++; } } } - _api.MemLib.WriteS16(0xFFAD8C, _destX); - _api.MemLib.WriteS16(0xFFAD90, _destY); + Mem.WriteS16(0xFFAD8C, _destX); + Mem.WriteS16(0xFFAD90, _destY); } else if (_dumpMap == 2) { if (_rowStateGuid != String.Empty) - _api.MemStateLib.DeleteState(_rowStateGuid); + MemSS.DeleteState(_rowStateGuid); _rowStateGuid = String.Empty; - int levelWidth = _api.MemLib.ReadS16(0xFFA7A8); - int levelHeight = _api.MemLib.ReadS16(0xFFA7AC); - EmuHawkPluginLibrary.SetGameExtraPadding(levelWidth - 320, levelHeight - 224, 0, 0); - var levelID = _api.MemLib.ReadS8(0xFFA7D0); - var s = _api.EmuLib.GetSettings() as GPGX.GPGXSettings; + int levelWidth = Mem.ReadS16(0xFFA7A8); + int levelHeight = Mem.ReadS16(0xFFA7AC); + ClientApi.SetGameExtraPadding(levelWidth - 320, levelHeight - 224, 0, 0); + var levelID = Mem.ReadS8(0xFFA7D0); + var s = Emu.GetSettings() as GPGX.GPGXSettings; s.DrawBGA = false; s.DrawBGB = false; s.DrawBGW = false; s.DrawObj = false; s.Backdrop = true; - _api.EmuLib.PutSettings(s); + Emu.PutSettings(s); - var a = _api.GUILib.GetAttributes(); + var a = Gui.GetAttributes(); a.SetColorKey(Color.FromArgb(0, 0x11, 0x22, 0x33), Color.FromArgb(0, 0x11, 0x22, 0x33)); - _api.GUILib.SetAttributes(a); - _api.GUILib.ToggleCompositingMode(); + Gui.SetAttributes(a); + Gui.ToggleCompositingMode(); - _api.GUILib.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{levelHeight - 224}_{levelWidth - 320}_top.png", 2, 2, 318, 222, (levelWidth - 318), (levelHeight - 222), 318, 222); + Gui.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{levelHeight - 224}_{levelWidth - 320}_top.png", 2, 2, 318, 222, (levelWidth - 318), (levelHeight - 222), 318, 222); for (int x = ((levelWidth - 320) / 159) * 159; x >= 0; x -= 159) { var dx = (x == 0) ? 0 : 2; - _api.GUILib.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{levelHeight - 224}_{x}_top.png", dx, 2, 320 - dx, 222, x + dx, (levelHeight - 222), 320 - dx, 222); + Gui.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{levelHeight - 224}_{x}_top.png", dx, 2, 320 - dx, 222, x + dx, (levelHeight - 222), 320 - dx, 222); } for (int y = ((levelHeight - 224) / 111) * 111; y >= 0; y -= 111) { var dy = (y == 0) ? 0 : 2; - _api.GUILib.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{y}_{levelWidth - 320}_top.png", 2, dy, 318, 224 - 2, levelWidth - 318, y + dy, 318, 224 - dy); + Gui.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{y}_{levelWidth - 320}_top.png", 2, dy, 318, 224 - 2, levelWidth - 318, y + dy, 318, 224 - dy); for (int x = ((levelWidth - 320) / 159) * 159; x >= 0; x -= 159) { var dx = (x == 0) ? 0 : 2; - _api.GUILib.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{y}_{x}_top.png", dx, dy, 320 - dx, 224 - dy, x + dx, y + dy, 320 - dx, 224 - dy); + Gui.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{y}_{x}_top.png", dx, dy, 320 - dx, 224 - dy, x + dx, y + dy, 320 - dx, 224 - dy); } } - _api.GUILib.ToggleCompositingMode(); - _api.GUILib.SetAttributes(new System.Drawing.Imaging.ImageAttributes()); - _api.GUILib.DrawFinish(); + Gui.ToggleCompositingMode(); + Gui.SetAttributes(new System.Drawing.Imaging.ImageAttributes()); + Gui.DrawFinish(); _dumpMap++; } else if (_dumpMap == 4) { - int levelWidth = _api.MemLib.ReadS16(0xFFA7A8); - int levelHeight = _api.MemLib.ReadS16(0xFFA7AC); - var levelID = _api.MemLib.ReadByte(0xFFA7D0); - var s = _api.EmuLib.GetSettings() as GPGX.GPGXSettings; + int levelWidth = Mem.ReadS16(0xFFA7A8); + int levelHeight = Mem.ReadS16(0xFFA7AC); + var levelID = Mem.ReadByte(0xFFA7D0); + var s = Emu.GetSettings() as GPGX.GPGXSettings; s.DrawBGA = (levelID != 29); s.DrawBGB = (levelID == 7); s.DrawBGW = true; s.DrawObj = true; s.Backdrop = false; - _api.EmuLib.PutSettings(s); + Emu.PutSettings(s); if ((_camX == _destX) && (_camY == _destY)) { if ((_prevX != _camX) || (_prevY != _camY)) @@ -3225,9 +3241,9 @@ namespace BizHawk.Client.EmuHawk { if (_rowStateGuid != string.Empty) { - _api.MemStateLib.DeleteState(_rowStateGuid); + MemSS.DeleteState(_rowStateGuid); } - _rowStateGuid = _api.MemStateLib.SaveCoreStateToMemory(); + _rowStateGuid = MemSS.SaveCoreStateToMemory(); } _snapPast = 1; } @@ -3237,14 +3253,14 @@ namespace BizHawk.Client.EmuHawk } if (_snapPast == 0) { - EmuHawkPluginLibrary.Screenshot($"c:\\Ecco2Maps\\{levelID}\\{_destY}_{_destX}_bottom.png"); + ClientApi.Screenshot($"c:\\Ecco2Maps\\{levelID}\\{_destY}_{_destX}_bottom.png"); if (_destX >= levelWidth - 320) { if (_destY < levelHeight - 224) { if (_rowStateGuid != string.Empty) { - _api.MemStateLib.LoadCoreStateFromMemory(_rowStateGuid); + MemSS.LoadCoreStateFromMemory(_rowStateGuid); } _destX = 0; _destY = Math.Min(_destY + 111, levelHeight - 224); @@ -3254,80 +3270,80 @@ namespace BizHawk.Client.EmuHawk _destX = Math.Min(_destX + 159, levelWidth - 320); if ((_prevX == _destX) && (_prevY == _destY)) { - EmuHawkPluginLibrary.SetGameExtraPadding(levelWidth - 320, levelHeight - 224, 0, 0); + ClientApi.SetGameExtraPadding(levelWidth - 320, levelHeight - 224, 0, 0); _dumpMap++; } } } - _api.MemLib.WriteS16(0xFFAD8C, _destX); - _api.MemLib.WriteS16(0xFFAD90, _destY); + Mem.WriteS16(0xFFAD8C, _destX); + Mem.WriteS16(0xFFAD90, _destY); } else if (_dumpMap == 5) { if (_rowStateGuid != String.Empty) - _api.MemStateLib.DeleteState(_rowStateGuid); + MemSS.DeleteState(_rowStateGuid); _rowStateGuid = String.Empty; - int levelWidth = _api.MemLib.ReadS16(0xFFA7A8); - int levelHeight = _api.MemLib.ReadS16(0xFFA7AC); - var levelID = _api.MemLib.ReadS8(0xFFA7D0); - var s = _api.EmuLib.GetSettings() as GPGX.GPGXSettings; + int levelWidth = Mem.ReadS16(0xFFA7A8); + int levelHeight = Mem.ReadS16(0xFFA7AC); + var levelID = Mem.ReadS8(0xFFA7D0); + var s = Emu.GetSettings() as GPGX.GPGXSettings; s.DrawBGA = (levelID != 29); s.DrawBGB = (levelID == 7); s.DrawBGW = true; s.DrawObj = true; s.Backdrop = false; - _api.EmuLib.PutSettings(s); - _api.GUILib.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{levelHeight - 224}_{levelWidth - 320}_bottom.png", 2, 2, 318, 222, (levelWidth - 318), (levelHeight - 222), 318, 222); + Emu.PutSettings(s); + Gui.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{levelHeight - 224}_{levelWidth - 320}_bottom.png", 2, 2, 318, 222, (levelWidth - 318), (levelHeight - 222), 318, 222); for (int x = ((levelWidth - 320) / 159) * 159; x >= 0; x -= 159) { var dx = (x == 0) ? 0 : 2; - _api.GUILib.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{levelHeight - 224}_{x}_bottom.png", dx, 2, 320 - dx, 222, x + dx, (levelHeight - 222), 320 - dx, 222); + Gui.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{levelHeight - 224}_{x}_bottom.png", dx, 2, 320 - dx, 222, x + dx, (levelHeight - 222), 320 - dx, 222); } for (int y = ((levelHeight - 224) / 111) * 111; y >= 0; y -= 111) { var dy = (y == 0) ? 0 : 2; - _api.GUILib.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{y}_{levelWidth - 320}_bottom.png", 2, dy, 318, 224 - 2, levelWidth - 318, y + dy, 318, 224 - dy); + Gui.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{y}_{levelWidth - 320}_bottom.png", 2, dy, 318, 224 - 2, levelWidth - 318, y + dy, 318, 224 - dy); for (int x = ((levelWidth - 320) / 159) * 159; x >= 0; x -= 159) { var dx = (x == 0) ? 0 : 2; - _api.GUILib.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{y}_{x}_bottom.png", dx, dy, 320 - dx, 224 - dy, x + dx, y + dy, 320 - dx, 224 - dy); + Gui.DrawImageRegion($"c:\\Ecco2Maps\\{levelID}\\{y}_{x}_bottom.png", dx, dy, 320 - dx, 224 - dy, x + dx, y + dy, 320 - dx, 224 - dy); } } - _api.GUILib.DrawFinish(); + Gui.DrawFinish(); _dumpMap++; } _prevX = _camX; _prevY = _camY; break; case 0xF6: - valueTicker = $"{_api.MemLib.ReadS32(0xFFD5E0) / 4096.0:0.######}:{_api.MemLib.ReadS32(0xFFD5E8) / 4096.0:0.######}:{_api.MemLib.ReadS32(0xFFD5E4) / 2048.0:0.######}"; + valueTicker = $"{Mem.ReadS32(0xFFD5E0) / 4096.0:0.######}:{Mem.ReadS32(0xFFD5E8) / 4096.0:0.######}:{Mem.ReadS32(0xFFD5E4) / 2048.0:0.######}"; TickerText(valueTicker); - valueTicker = $"{_api.MemLib.ReadS32(0xFFB13A) / 4096.0:0.######}:{_api.MemLib.ReadS32(0xFFB142) / 4096.0:0.######}:{_api.MemLib.ReadS32(0xFFB13E) / 2048.0:0.######}"; + valueTicker = $"{Mem.ReadS32(0xFFB13A) / 4096.0:0.######}:{Mem.ReadS32(0xFFB142) / 4096.0:0.######}:{Mem.ReadS32(0xFFB13E) / 2048.0:0.######}"; TickerText(valueTicker); - valueTicker = $"{_api.MemLib.ReadS32(0xFFB162) / 4096.0:0.######}:{_api.MemLib.ReadS32(0xFFB16A) / 4096.0:0.######}:{_api.MemLib.ReadS32(0xFFB166) / 2048.0:0.######}"; + valueTicker = $"{Mem.ReadS32(0xFFB162) / 4096.0:0.######}:{Mem.ReadS32(0xFFB16A) / 4096.0:0.######}:{Mem.ReadS32(0xFFB166) / 2048.0:0.######}"; TickerText(valueTicker); - valueTicker = $"{_api.MemLib.ReadU8(0xFFB19B)}:{_api.MemLib.ReadU8(0xFFB1A6)}:{_api.MemLib.ReadU8(0xFFB1A9)}"; + valueTicker = $"{Mem.ReadU8(0xFFB19B)}:{Mem.ReadU8(0xFFB1A6)}:{Mem.ReadU8(0xFFB1A9)}"; TickerText(valueTicker); - int SpawnZ = _api.MemLib.ReadS32(0xFFD5F0) + 0x180000; + int SpawnZ = Mem.ReadS32(0xFFD5F0) + 0x180000; int nextRingZ = SpawnZ; while (((nextRingZ >> 17) & 0xF) != 0) { nextRingZ += 0x20000; } - valueTicker = $"{_api.MemLib.ReadS32(0xFFD856) / 4096.0:0.######}:{_api.MemLib.ReadS32(0xFFD85A) / 4096.0:0.######}:{(nextRingZ - 0x160000) / 2048.0:0.######}:{nextRingZ / 2048.0:0.######}"; + valueTicker = $"{Mem.ReadS32(0xFFD856) / 4096.0:0.######}:{Mem.ReadS32(0xFFD85A) / 4096.0:0.######}:{(nextRingZ - 0x160000) / 2048.0:0.######}:{nextRingZ / 2048.0:0.######}"; TickerText(valueTicker); - var levelId = -1 - _api.MemLib.ReadS16(0xFFA79E); + var levelId = -1 - Mem.ReadS16(0xFFA79E); bool spawn = false; bool firstRand = true; int SpawnX, SpawnY, z; - int CamX = (_api.MemLib.ReadS32(0xFFD5E0) >> 0xC) - _left; - int CamY = (_api.MemLib.ReadS32(0xFFD5E8) >> 0xC) + _top; - int CamZ = (_api.MemLib.ReadS32(0xFFD5E4) >> 0xC) + _top; + int CamX = (Mem.ReadS32(0xFFD5E0) >> 0xC) - _left; + int CamY = (Mem.ReadS32(0xFFD5E8) >> 0xC) + _top; + int CamZ = (Mem.ReadS32(0xFFD5E4) >> 0xC) + _top; while (!spawn) { var temp = (SpawnZ >> 17) & 0xFF; - var controlList = _api.MemLib.ReadS32(0x7B54 + (levelId << 2)); - temp = _api.MemLib.ReadS16(controlList + (temp << 1)); + var controlList = Mem.ReadS32(0x7B54 + (levelId << 2)); + temp = Mem.ReadS16(controlList + (temp << 1)); var v = temp & 0xFF; var num = (temp >> 8) + v; temp = v; @@ -3343,7 +3359,7 @@ namespace BizHawk.Client.EmuHawk break; case 2: // Jellyfish - SpawnX = _api.MemLib.ReadS32(0xFFB13A) + 0x40000 - (EccoRand(firstRand) << 3); + SpawnX = Mem.ReadS32(0xFFB13A) + 0x40000 - (EccoRand(firstRand) << 3); firstRand = false; SpawnY = -0xC0000 + (EccoRand() << 3); z = SpawnZ + 0x20000;// ? @@ -3357,7 +3373,7 @@ namespace BizHawk.Client.EmuHawk break; case 3: // Eagle - SpawnX = _api.MemLib.ReadS32(0xFFB13A) + 0x40000 - (EccoRand(firstRand) << 3); + SpawnX = Mem.ReadS32(0xFFB13A) + 0x40000 - (EccoRand(firstRand) << 3); firstRand = false; SpawnY = 0x50000; z = SpawnZ - 0x40000 + 0x20000;// ? @@ -3374,8 +3390,8 @@ namespace BizHawk.Client.EmuHawk bool left = (EccoRand(firstRand) > 0x8000); firstRand = false; var xdiff = 0xC0000 + (EccoRand() << 3); - SpawnX = _api.MemLib.ReadS32(0xFFB13A) + (left ? -xdiff : xdiff); - SpawnY = Math.Min(_api.MemLib.ReadS32(0xFFB142), -0x10000) - (EccoRand() + 0x10000); + SpawnX = Mem.ReadS32(0xFFB13A) + (left ? -xdiff : xdiff); + SpawnY = Math.Min(Mem.ReadS32(0xFFB142), -0x10000) - (EccoRand() + 0x10000); z = SpawnZ + 0x20000; valueTicker = $"{SpawnX / 4096.0:0.######}:{SpawnY / 4096.0:0.######}:{(z - 0x180000) / 2048.0:0.######}:{z / 2048.0:0.######}"; TickerText(valueTicker); @@ -3406,7 +3422,7 @@ namespace BizHawk.Client.EmuHawk break; case 14: // Shell - SpawnX = _api.MemLib.ReadS32(0xFFB13A) - 0x20000 + (EccoRand(firstRand) << 2); + SpawnX = Mem.ReadS32(0xFFB13A) - 0x20000 + (EccoRand(firstRand) << 2); firstRand = false; SpawnY = -0x80000; z = SpawnZ + 0x20000; @@ -3425,16 +3441,16 @@ namespace BizHawk.Client.EmuHawk } break; } - _api.JoypadLib.Set("C", null, 1); - _api.JoypadLib.Set("Start", null, 1); - var color = _turnSignalColors[_api.MemLib.ReadS8(0xFFA7C9) & 7]; - _api.GUILib.DrawRectangle(_left - 48, _top - 112, 15, 15, color, color); + Joy.Set("C", null, 1); + Joy.Set("Start", null, 1); + var color = _turnSignalColors[Mem.ReadS8(0xFFA7C9) & 7]; + Gui.DrawRectangle(_left - 48, _top - 112, 15, 15, color, color); } public override void LoadStateCallback(string name) { - _api.GUILib.DrawNew("emu"); + Gui.DrawNew("emu"); PreFrameCallback(); - _api.GUILib.DrawFinish(); + Gui.DrawFinish(); } } } diff --git a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Communications.cs b/BizHawk.Client.EmuHawk/Api/Libraries/CommApi.cs similarity index 95% rename from BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Communications.cs rename to BizHawk.Client.EmuHawk/Api/Libraries/CommApi.cs index 43012c1817..152658c639 100644 --- a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Communications.cs +++ b/BizHawk.Client.EmuHawk/Api/Libraries/CommApi.cs @@ -2,7 +2,7 @@ using System.ComponentModel; using BizHawk.Emulation.Common; -using BizHawk.Client.Common; +using BizHawk.Client.ApiHawk; using System.Text; using System.Collections.Generic; using System.Net.Http; @@ -11,7 +11,7 @@ using System.Windows.Forms; namespace BizHawk.Client.EmuHawk { - public sealed class CommunicationPluginLibrary : PluginLibraryBase + public sealed class CommApi : IComm { [RequiredService] private IEmulator Emulator { get; set; } @@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk [RequiredService] private IVideoProvider VideoProvider { get; set; } - public CommunicationPluginLibrary() : base() + public CommApi() : base() { } public string SocketServerScreenShot() diff --git a/BizHawk.Client.Common/plugins/PluginLibrary.GUIDraw.cs b/BizHawk.Client.EmuHawk/Api/Libraries/GUIApi.cs similarity index 65% rename from BizHawk.Client.Common/plugins/PluginLibrary.GUIDraw.cs rename to BizHawk.Client.EmuHawk/Api/Libraries/GUIApi.cs index 2647c19a89..5270a6eece 100644 --- a/BizHawk.Client.Common/plugins/PluginLibrary.GUIDraw.cs +++ b/BizHawk.Client.EmuHawk/Api/Libraries/GUIApi.cs @@ -5,44 +5,47 @@ using System.Drawing.Imaging; using System.Windows.Forms; using System.IO; +using BizHawk.Client.ApiHawk; using BizHawk.Emulation.Common; -namespace BizHawk.Client.Common +namespace BizHawk.Client.EmuHawk { - public abstract class GUIDrawPluginBase : PluginLibraryBase + public sealed class GuiApi : IGui { [RequiredService] - protected IEmulator Emulator { get; set; } - - public GUIDrawPluginBase() : base() - { } - - public bool HasGUISurface = false; - - protected Color _defaultForeground = Color.White; - protected Color? _defaultBackground; - protected Color? _defaultTextBackground = Color.FromArgb(128, 0, 0, 0); - protected int _defaultPixelFont = 1; // gens - protected Padding _padding = new Padding(0); - protected ImageAttributes _attributes = new ImageAttributes(); + private IEmulator Emulator { get; set; } + private Color _defaultForeground = Color.White; + private Color? _defaultBackground; + private Color? _defaultTextBackground = Color.FromArgb(128, 0, 0, 0); + private int _defaultPixelFont = 1; // gens + private Padding _padding = new Padding(0); + private ImageAttributes _attributes = new ImageAttributes(); private System.Drawing.Drawing2D.CompositingMode _compositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; - public virtual void ToggleCompositingMode() + + public GuiApi() + { } + + private DisplaySurface _GUISurface = null; + + public bool HasGUISurface => _GUISurface != null; + + #region Gui API + public void ToggleCompositingMode() { _compositingMode = 1 - _compositingMode; } - public virtual ImageAttributes GetAttributes() + public ImageAttributes GetAttributes() { return _attributes; } - public virtual void SetAttributes(ImageAttributes a) + public void SetAttributes(ImageAttributes a) { _attributes = a; } - #region Gui API - public virtual void Dispose() + public void Dispose() { foreach (var brush in _solidBrushes.Values) { @@ -55,16 +58,35 @@ namespace BizHawk.Client.Common } } - public abstract void DrawNew(string name, bool? clear = true); - public abstract void DrawFinish(); + public void DrawNew(string name, bool? clear = true) + { + try + { + DrawFinish(); + _GUISurface = GlobalWin.DisplayManager.LockLuaSurface(name, clear ?? true); + } + catch (InvalidOperationException ex) + { + Console.WriteLine(ex.ToString()); + } + } + + public void DrawFinish() + { + if (_GUISurface != null) + { + GlobalWin.DisplayManager.UnlockLuaSurface(_GUISurface); + } + + _GUISurface = null; + } #endregion #region Helpers - protected readonly Dictionary _imageCache = new Dictionary(); - - protected readonly Dictionary _solidBrushes = new Dictionary(); - protected readonly Dictionary _pens = new Dictionary(); - protected SolidBrush GetBrush(Color color) + private readonly Dictionary _imageCache = new Dictionary(); + private readonly Dictionary _solidBrushes = new Dictionary(); + private readonly Dictionary _pens = new Dictionary(); + private SolidBrush GetBrush(Color color) { SolidBrush b; if (!_solidBrushes.TryGetValue(color, out b)) @@ -76,7 +98,7 @@ namespace BizHawk.Client.Common return b; } - protected Pen GetPen(Color color) + private Pen GetPen(Color color) { Pen p; if (!_pens.TryGetValue(color, out p)) @@ -88,7 +110,22 @@ namespace BizHawk.Client.Common return p; } - protected abstract Graphics GetGraphics(); + private Graphics GetGraphics() + { + var g = _GUISurface == null ? Graphics.FromImage(new Bitmap(1,1)) : _GUISurface.GetGraphics(); + + // we don't like CoreComm, right? Someone should find a different way to do this then. + var tx = Emulator.CoreComm.ScreenLogicalOffsetX; + var ty = Emulator.CoreComm.ScreenLogicalOffsetY; + if (tx != 0 || ty != 0) + { + var transform = g.Transform; + transform.Translate(-tx, -ty); + g.Transform = transform; + } + + return g; + } public void SetPadding(int all) { _padding = new Padding(all); @@ -97,7 +134,7 @@ namespace BizHawk.Client.Common { _padding = new Padding(x / 2, y / 2, x / 2 + x & 1, y / 2 + y & 1); } - public void SetPadding(int l,int t,int r, int b) + public void SetPadding(int l, int t, int r, int b) { _padding = new Padding(l, t, r, b); } @@ -107,11 +144,21 @@ namespace BizHawk.Client.Common } #endregion - public abstract void AddMessage(string message); + public void AddMessage(string message) + { + GlobalWin.OSD.AddMessage(message); + } - public abstract void ClearGraphics(); + public void ClearGraphics() + { + _GUISurface.Clear(); + DrawFinish(); + } - public abstract void ClearText(); + public void ClearText() + { + GlobalWin.OSD.ClearGUIText(); + } public void SetDefaultForegroundColor(Color color) { @@ -352,7 +399,7 @@ namespace BizHawk.Client.Common { using (var g = GetGraphics()) { - g.CompositingMode = _compositingMode; + g.CompositingMode = _compositingMode; g.DrawLine(GetPen(color ?? _defaultForeground), x1, y1, x2, y2); } } @@ -424,12 +471,13 @@ namespace BizHawk.Client.Common var bg = background ?? _defaultBackground; if (bg.HasValue) { - g.FillRectangle(GetBrush(bg.Value), x + 1, y + 1, Math.Max(w - 1, 0), Math.Max(h - 1, 0)); } + g.FillRectangle(GetBrush(bg.Value), x + 1, y + 1, Math.Max(w - 1, 0), Math.Max(h - 1, 0)); + } } } - public void DrawString(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, int? fontsize = null, - string fontfamily = null, string fontstyle = null, string horizalign = null, string vertalign = null) + public void DrawString(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, int? fontsize = null, + string fontfamily = null, string fontstyle = null, string horizalign = null, string vertalign = null) { using (var g = GetGraphics()) { @@ -508,7 +556,7 @@ namespace BizHawk.Client.Common { for (var yd = -1; yd <= 1; yd++) { - g.DrawString(message, font, GetBrush(bg.Value), x+xd, y+yd); + g.DrawString(message, font, GetBrush(bg.Value), x + xd, y + yd); } } } @@ -522,7 +570,86 @@ namespace BizHawk.Client.Common } } - public abstract void DrawText(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, string fontfamily = null); - public abstract void Text(int x, int y, string message, Color? forecolor = null, string anchor = null); + public void DrawText(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, string fontfamily = null) + { + using (var g = GetGraphics()) + { + try + { + var index = 0; + if (string.IsNullOrEmpty(fontfamily)) + { + index = _defaultPixelFont; + } + else + { + switch (fontfamily) + { + case "fceux": + case "0": + index = 0; + break; + case "gens": + case "1": + index = 1; + break; + default: + Console.WriteLine($"Unable to find font family: {fontfamily}"); + return; + } + } + + var f = new StringFormat(StringFormat.GenericTypographic) + { + FormatFlags = StringFormatFlags.MeasureTrailingSpaces + }; + var font = new Font(GlobalWin.DisplayManager.CustomFonts.Families[index], 8, FontStyle.Regular, GraphicsUnit.Pixel); + Size sizeOfText = g.MeasureString(message, font, 0, f).ToSize(); + var rect = new Rectangle(new Point(x, y), sizeOfText + new Size(1, 0)); + if (backcolor.HasValue) g.FillRectangle(GetBrush(backcolor.Value), rect); + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; + g.DrawString(message, font, GetBrush(forecolor ?? _defaultForeground), x, y); + } + catch (Exception) + { + return; + } + } + } + + public void Text(int x, int y, string message, Color? forecolor = null, string anchor = null) + { + var a = 0; + + if (!string.IsNullOrEmpty(anchor)) + { + switch (anchor) + { + case "0": + case "topleft": + a = 0; + break; + case "1": + case "topright": + a = 1; + break; + case "2": + case "bottomleft": + a = 2; + break; + case "3": + case "bottomright": + a = 3; + break; + } + } + else + { + x -= Emulator.CoreComm.ScreenLogicalOffsetX; + y -= Emulator.CoreComm.ScreenLogicalOffsetY; + } + + GlobalWin.OSD.AddGUIText(message, x, y, Color.Black, forecolor ?? Color.White, a); + } } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Input.cs b/BizHawk.Client.EmuHawk/Api/Libraries/InputApi.cs similarity index 92% rename from BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Input.cs rename to BizHawk.Client.EmuHawk/Api/Libraries/InputApi.cs index e2e289bae0..56e2cd767f 100644 --- a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Input.cs +++ b/BizHawk.Client.EmuHawk/Api/Libraries/InputApi.cs @@ -3,13 +3,14 @@ using System.Linq; using System.Collections.Generic; using System.Windows.Forms; +using BizHawk.Client.ApiHawk; using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { - public sealed class InputPluginLibrary : PluginLibraryBase + public sealed class InputApi : IInput { - public InputPluginLibrary() : base() + public InputApi() : base() { } public Dictionary Get() diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/PluginLibrary.cs b/BizHawk.Client.EmuHawk/Api/Libraries/PluginLibrary.cs new file mode 100644 index 0000000000..ca44e44a3d --- /dev/null +++ b/BizHawk.Client.EmuHawk/Api/Libraries/PluginLibrary.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; + +using BizHawk.Common.ReflectionExtensions; +using BizHawk.Emulation.Common; +using BizHawk.Client.ApiHawk; + +namespace BizHawk.Client.EmuHawk + +{ + public static class ApiManager + { + private static ApiContainer container; + private static void Register(IEmulatorServiceProvider serviceProvider) + { + // Register external apis + var libs = Assembly + .Load("BizHawk.Client.ApiHawk") + .GetTypes() + .Where(t => typeof(IExternalApi).IsAssignableFrom(t)) + .Where(t => t.IsSealed) + .Where(t => ServiceInjector.IsAvailable(serviceProvider, t)) + .ToList(); + + libs.AddRange( + Assembly + .GetAssembly(typeof(ApiContainer)) + .GetTypes() + .Where(t => typeof(IExternalApi).IsAssignableFrom(t)) + .Where(t => t.IsSealed) + .Where(t => ServiceInjector.IsAvailable(serviceProvider, t))); + + foreach (var lib in libs) + { + var instance = (IExternalApi)Activator.CreateInstance(lib); + ServiceInjector.UpdateServices(serviceProvider, instance); + Libraries.Add(lib, instance); + } + container = new ApiContainer(Libraries); + GlobalWin.ApiProvider = new BasicApiProvider(container); + } + private static readonly Dictionary Libraries = new Dictionary(); + public static void Restart(IEmulatorServiceProvider newServiceProvider) + { + Libraries.Clear(); + Register(newServiceProvider); + } + } +} diff --git a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Savestate.cs b/BizHawk.Client.EmuHawk/Api/Libraries/SaveStateAPI.cs similarity index 84% rename from BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Savestate.cs rename to BizHawk.Client.EmuHawk/Api/Libraries/SaveStateAPI.cs index 90f4e5e7f6..df75742920 100644 --- a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Savestate.cs +++ b/BizHawk.Client.EmuHawk/Api/Libraries/SaveStateAPI.cs @@ -2,13 +2,13 @@ using System.Collections.Generic; using System.IO; -using BizHawk.Client.Common; +using BizHawk.Client.ApiHawk; namespace BizHawk.Client.EmuHawk { - public sealed class SavestatePluginibrary : PluginLibraryBase + public sealed class SaveStateApi : ISaveState { - public SavestatePluginibrary() : base() + public SaveStateApi() : base() { } public void Load(string path) diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/ToolApi.cs b/BizHawk.Client.EmuHawk/Api/Libraries/ToolApi.cs new file mode 100644 index 0000000000..d356761cdf --- /dev/null +++ b/BizHawk.Client.EmuHawk/Api/Libraries/ToolApi.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using BizHawk.Common; +using BizHawk.Emulation.Common; +using BizHawk.Client.ApiHawk; +using BizHawk.Client.Common; + +namespace BizHawk.Client.EmuHawk +{ + public sealed class ToolApi : ITool + { + private class ToolStatic + { + public Type GetTool(string name) + { + var toolType = ReflectionUtil.GetTypeByName(name) + .FirstOrDefault(x => typeof(IToolForm).IsAssignableFrom(x) && !x.IsInterface); + + if (toolType != null) + { + GlobalWin.Tools.Load(toolType); + } + + var selectedTool = GlobalWin.Tools.AvailableTools + .FirstOrDefault(tool => tool.GetType().Name.ToLower() == name.ToLower()); + + if (selectedTool != null) + { + return selectedTool; + } + + return null; + } + + public object CreateInstance(string name) + { + var possibleTypes = ReflectionUtil.GetTypeByName(name); + + if (possibleTypes.Any()) + { + return Activator.CreateInstance(possibleTypes.First()); + } + + return null; + } + + public static void OpenCheats() + { + GlobalWin.Tools.Load(); + } + + public static void OpenHexEditor() + { + GlobalWin.Tools.Load(); + } + + public static void OpenRamWatch() + { + GlobalWin.Tools.LoadRamWatch(loadDialog: true); + } + + public static void OpenRamSearch() + { + GlobalWin.Tools.Load(); + } + + public static void OpenTasStudio() + { + GlobalWin.Tools.Load(); + } + + public static void OpenToolBox() + { + GlobalWin.Tools.Load(); + } + + public static void OpenTraceLogger() + { + GlobalWin.Tools.Load(); + } + + } + [RequiredService] + private static IEmulator Emulator { get; set; } + + [RequiredService] + private static IVideoProvider VideoProvider { get; set; } + + public ToolApi() + { } + + public Type GetTool(string name) + { + var toolType = ReflectionUtil.GetTypeByName(name) + .FirstOrDefault(x => typeof(IToolForm).IsAssignableFrom(x) && !x.IsInterface); + + if (toolType != null) + { + GlobalWin.Tools.Load(toolType); + } + + var selectedTool = GlobalWin.Tools.AvailableTools + .FirstOrDefault(tool => tool.GetType().Name.ToLower() == name.ToLower()); + + if (selectedTool != null) + { + return selectedTool; + } + + return null; + } + + public object CreateInstance(string name) + { + var possibleTypes = ReflectionUtil.GetTypeByName(name); + + if (possibleTypes.Any()) + { + return Activator.CreateInstance(possibleTypes.First()); + } + + return null; + } + + public void OpenCheats() + { + ToolStatic.OpenCheats(); + } + + public void OpenHexEditor() + { + ToolStatic.OpenHexEditor(); + } + + public void OpenRamWatch() + { + ToolStatic.OpenRamWatch(); + } + + public void OpenRamSearch() + { + ToolStatic.OpenRamSearch(); + } + + public void OpenTasStudio() + { + ToolStatic.OpenTasStudio(); + } + + public void OpenToolBox() + { + ToolStatic.OpenToolBox(); + } + + public void OpenTraceLogger() + { + ToolStatic.OpenTraceLogger(); + } + } +} diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 46f0aa381a..efbb0d391d 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -658,9 +658,14 @@ - - - + + + + + + + + @@ -734,7 +739,6 @@ NameStateForm.cs - Form @@ -747,10 +751,6 @@ PlatformChooser.cs - - - - @@ -1888,7 +1888,6 @@ - diff --git a/BizHawk.Client.EmuHawk/GlobalWin.cs b/BizHawk.Client.EmuHawk/GlobalWin.cs index 5ede6c61fc..06a2bbaab5 100644 --- a/BizHawk.Client.EmuHawk/GlobalWin.cs +++ b/BizHawk.Client.EmuHawk/GlobalWin.cs @@ -1,4 +1,5 @@ using BizHawk.Bizware.BizwareGL; +using BizHawk.Client.ApiHawk; // ReSharper disable StyleCop.SA1401 namespace BizHawk.Client.EmuHawk @@ -7,7 +8,7 @@ namespace BizHawk.Client.EmuHawk { public static MainForm MainForm; public static ToolManager Tools; - public static PluginLibrary Plugins; + public static BasicApiProvider ApiProvider; /// /// the IGL to be used for rendering diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 9fb06ed416..2cc7539c80 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -252,8 +252,6 @@ namespace BizHawk.Client.EmuHawk GlobalWin.Sound.StartSound(); InputManager.RewireInputChain(); GlobalWin.Tools = new ToolManager(this); - GlobalWin.Plugins = new PluginLibrary(Emulator.ServiceProvider); - GlobalWin.Plugins.Load(new Ecco2AssistantPlugin()); RewireSound(); // Workaround for windows, location is -32000 when minimized, if they close it during this time, that's what gets saved @@ -2937,7 +2935,6 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.Tools.LuaConsole.LuaImp.CallFrameBeforeEvent(); } - GlobalWin.Plugins.CallFrameBeforeEvent(); if (IsTurboing) { @@ -3024,7 +3021,6 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.Tools.LuaConsole.LuaImp.CallFrameAfterEvent(); } - GlobalWin.Plugins.CallFrameAfterEvent(); if (IsTurboing) { @@ -3798,7 +3794,7 @@ namespace BizHawk.Client.EmuHawk } GlobalWin.Tools.Restart(); - GlobalWin.Plugins.Restart(Emulator.ServiceProvider); + ApiManager.Restart(Emulator.ServiceProvider); if (Global.Config.LoadCheatFileByGame) { @@ -3846,7 +3842,7 @@ namespace BizHawk.Client.EmuHawk } } - ClientApi.OnRomLoaded(); + ClientApi.OnRomLoaded(Emulator); return true; } else @@ -3857,10 +3853,11 @@ namespace BizHawk.Client.EmuHawk // The ROM has been loaded by a recursive invocation of the LoadROM method. if (!(Emulator is NullEmulator)) { - ClientApi.OnRomLoaded(); + ClientApi.OnRomLoaded(Emulator); return true; } + ClientApi.UpdateEmulatorAndVP(Emulator); HandlePlatformMenus(); _stateSlots.Clear(); UpdateStatusSlots(); @@ -3950,6 +3947,7 @@ namespace BizHawk.Client.EmuHawk var coreComm = CreateCoreComm(); CoreFileProvider.SyncCoreCommInputSignals(coreComm); Emulator = new NullEmulator(coreComm, Global.Config.GetCoreSettings()); + ClientApi.UpdateEmulatorAndVP(Emulator); Global.ActiveController = new Controller(NullController.Instance.Definition); Global.AutoFireController = _autofireNullControls; RewireSound(); @@ -3972,7 +3970,7 @@ namespace BizHawk.Client.EmuHawk Global.Game = GameInfo.NullInstance; GlobalWin.Tools.Restart(); - GlobalWin.Plugins.Restart(Emulator.ServiceProvider); + ApiManager.Restart(Emulator.ServiceProvider); RewireSound(); Text = "BizHawk" + (VersionInfo.DeveloperBuild ? " (interim) " : ""); HandlePlatformMenus(); @@ -4068,7 +4066,6 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.Tools.LuaConsole.LuaImp.CallLoadStateEvent(userFriendlyStateName); } - GlobalWin.Plugins.CallLoadStateEvent(userFriendlyStateName); SetMainformMovieInfo(); GlobalWin.Tools.UpdateToolsBefore(fromLua); @@ -4198,7 +4195,6 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.Tools.LuaConsole.LuaImp.CallSaveStateEvent(quickSlotName); } - GlobalWin.Plugins.CallSaveStateEvent(quickSlotName); } private void SaveStateAs() diff --git a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Client.cs b/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Client.cs deleted file mode 100644 index b37d5f37dc..0000000000 --- a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.Client.cs +++ /dev/null @@ -1,351 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -using BizHawk.Common; -using BizHawk.Emulation.Common; -using BizHawk.Client.Common; - -namespace BizHawk.Client.EmuHawk -{ - public sealed class EmuHawkPluginLibrary : PluginLibraryBase - { - [RequiredService] - private IEmulator Emulator { get; set; } - - [RequiredService] - private IVideoProvider VideoProvider { get; set; } - - private readonly Dictionary _filterMappings = new Dictionary - { - { 0, "None" }, - { 1, "x2SAI" }, - { 2, "SuperX2SAI" }, - { 3, "SuperEagle" }, - { 4, "Scanlines" }, - }; - - public EmuHawkPluginLibrary() : base() - { } - - public void CloseEmulator() - { - GlobalWin.MainForm.CloseEmulator(); - } - - public void CloseEmulatorWithCode(int exitCode) - { - GlobalWin.MainForm.CloseEmulator(exitCode); - } - - public static int BorderHeight() - { - var point = new System.Drawing.Point(0, 0); - return GlobalWin.DisplayManager.TransformPoint(point).Y; - } - - public static int BorderWidth() - { - var point = new System.Drawing.Point(0, 0); - return GlobalWin.DisplayManager.TransformPoint(point).X; - } - - public int BufferHeight() - { - return VideoProvider.BufferHeight; - } - - public int BufferWidth() - { - return VideoProvider.BufferWidth; - } - - public void ClearAutohold() - { - GlobalWin.MainForm.ClearHolds(); - } - - public static void CloseRom() - { - GlobalWin.MainForm.CloseRom(); - } - - public void EnableRewind(bool enabled) - { - GlobalWin.MainForm.EnableRewind(enabled); - } - - public void FrameSkip(int numFrames) - { - if (numFrames > 0) - { - Global.Config.FrameSkip = numFrames; - GlobalWin.MainForm.FrameSkipMessage(); - } - else - { - Console.WriteLine("Invalid frame skip value"); - } - } - - public static int GetTargetScanlineIntensity() - { - return Global.Config.TargetScanlineFilterIntensity; - } - - public int GetWindowSize() - { - return Global.Config.TargetZoomFactors[Emulator.SystemId]; - } - - public static void SetGameExtraPadding(int left, int top, int right, int bottom) - { - GlobalWin.DisplayManager.GameExtraPadding = new System.Windows.Forms.Padding(left, top, right, bottom); - GlobalWin.MainForm.FrameBufferResized(); - } - - public static void SetSoundOn(bool enable) - { - Global.Config.SoundEnabled = enable; - } - - public static bool GetSoundOn() - { - return Global.Config.SoundEnabled; - } - - public static void SetClientExtraPadding(int left, int top, int right, int bottom) - { - GlobalWin.DisplayManager.ClientExtraPadding = new System.Windows.Forms.Padding(left, top, right, bottom); - GlobalWin.MainForm.FrameBufferResized(); - } - - public static bool IsPaused() - { - return GlobalWin.MainForm.EmulatorPaused; - } - - public static bool IsTurbo() - { - return GlobalWin.MainForm.IsTurboing; - } - - public static bool IsSeeking() - { - return GlobalWin.MainForm.IsSeeking; - } - - public static void OpenCheats() - { - GlobalWin.Tools.Load(); - } - - public static void OpenHexEditor() - { - GlobalWin.Tools.Load(); - } - - public static void OpenRamWatch() - { - GlobalWin.Tools.LoadRamWatch(loadDialog: true); - } - - public static void OpenRamSearch() - { - GlobalWin.Tools.Load(); - } - - public static void OpenRom(string path) - { - var ioa = OpenAdvancedSerializer.ParseWithLegacy(path); - GlobalWin.MainForm.LoadRom(path, new MainForm.LoadRomArgs { OpenAdvanced = ioa }); - } - - public static void OpenTasStudio() - { - GlobalWin.Tools.Load(); - } - - public static void OpenToolBox() - { - GlobalWin.Tools.Load(); - } - - public static void OpenTraceLogger() - { - GlobalWin.Tools.Load(); - } - - public static void Pause() - { - GlobalWin.MainForm.PauseEmulator(); - } - - public static void PauseAv() - { - GlobalWin.MainForm.PauseAvi = true; - } - - public static void RebootCore() - { - ((LuaConsole)GlobalWin.Tools.Get()).LuaImp.IsRebootingCore = true; - GlobalWin.MainForm.RebootCore(); - ((LuaConsole)GlobalWin.Tools.Get()).LuaImp.IsRebootingCore = false; - } - - public static int ScreenHeight() - { - return GlobalWin.MainForm.PresentationPanel.NativeSize.Height; - } - - public static void Screenshot(string path = null) - { - if (path == null) - { - GlobalWin.MainForm.TakeScreenshot(); - } - else - { - GlobalWin.MainForm.TakeScreenshot(path); - } - } - - public static void ScreenshotToClipboard() - { - GlobalWin.MainForm.TakeScreenshotToClipboard(); - } - - public static void SetTargetScanlineIntensity(int val) - { - Global.Config.TargetScanlineFilterIntensity = val; - } - - public static void SetScreenshotOSD(bool value) - { - Global.Config.Screenshot_CaptureOSD = value; - } - - public static int ScreenWidth() - { - return GlobalWin.MainForm.PresentationPanel.NativeSize.Width; - } - - public void SetWindowSize(int size) - { - if (size == 1 || size == 2 || size == 3 || size == 4 || size == 5 || size == 10) - { - Global.Config.TargetZoomFactors[Emulator.SystemId] = size; - GlobalWin.MainForm.FrameBufferResized(); - GlobalWin.OSD.AddMessage("Window size set to " + size + "x"); - } - else - { - Console.WriteLine("Invalid window size"); - } - } - - public void SpeedMode(int percent) - { - if (percent > 0 && percent < 6400) - { - GlobalWin.MainForm.ClickSpeedItem(percent); - } - else - { - Console.WriteLine("Invalid speed value"); - } - } - - public static void TogglePause() - { - GlobalWin.MainForm.TogglePause(); - } - - public static int TransformPointX(int x) - { - var point = new System.Drawing.Point(x, 0); - return GlobalWin.DisplayManager.TransformPoint(point).X; - } - - public static int TransformPointY(int y) - { - var point = new System.Drawing.Point(0, y); - return GlobalWin.DisplayManager.TransformPoint(point).Y; - } - - public static void Unpause() - { - GlobalWin.MainForm.UnpauseEmulator(); - } - - public static void UnpauseAv() - { - GlobalWin.MainForm.PauseAvi = false; - } - - public static int Xpos() - { - return GlobalWin.MainForm.DesktopLocation.X; - } - - public static int Ypos() - { - return GlobalWin.MainForm.DesktopLocation.Y; - } - - public List GetAvailableTools() - { - var tools = GlobalWin.Tools.AvailableTools.ToList(); - var t = new List(tools.Count); - for (int i = 0; i < tools.Count; i++) - { - t[i] = tools[i].Name.ToLower(); - } - - return t; - } - - public Type GetTool(string name) - { - var toolType = ReflectionUtil.GetTypeByName(name) - .FirstOrDefault(x => typeof(IToolForm).IsAssignableFrom(x) && !x.IsInterface); - - if (toolType != null) - { - GlobalWin.Tools.Load(toolType); - } - - var selectedTool = GlobalWin.Tools.AvailableTools - .FirstOrDefault(tool => tool.GetType().Name.ToLower() == name.ToLower()); - - if (selectedTool != null) - { - return selectedTool; - } - - return null; - } - - public object CreateInstance(string name) - { - var possibleTypes = ReflectionUtil.GetTypeByName(name); - - if (possibleTypes.Any()) - { - return Activator.CreateInstance(possibleTypes.First()); - } - - return null; - } - - public void DisplayMessages(bool value) - { - Global.Config.DisplayMessages = value; - } - - public void SaveRam() - { - GlobalWin.MainForm.FlushSaveRAM(); - } - } -} diff --git a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.GUI.cs b/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.GUI.cs deleted file mode 100644 index e22bd3e0fd..0000000000 --- a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.GUI.cs +++ /dev/null @@ -1,162 +0,0 @@ -using System; -using System.Drawing; - -using BizHawk.Client.Common; - -namespace BizHawk.Client.EmuHawk -{ - public sealed class GUIPluginLibrary : GUIDrawPluginBase - { - public GUIPluginLibrary() : base() - { } - - private DisplaySurface _GUISurface = null; - - #region Gui API - - public override void DrawNew(string name, bool? clear = true) - { - try - { - DrawFinish(); - _GUISurface = GlobalWin.DisplayManager.LockLuaSurface(name, clear ?? true); - HasGUISurface = (_GUISurface != null); - - } - catch (InvalidOperationException ex) - { - Console.WriteLine(ex.ToString()); - } - } - - public override void DrawFinish() - { - if (_GUISurface != null) - { - GlobalWin.DisplayManager.UnlockLuaSurface(_GUISurface); - } - - _GUISurface = null; - HasGUISurface = false; - - } - #endregion - - #region Helpers - protected override Graphics GetGraphics() - { - var g = _GUISurface == null ? Graphics.FromImage(new Bitmap(1,1)) : _GUISurface.GetGraphics(); - - // we don't like CoreComm, right? Someone should find a different way to do this then. - var tx = Emulator.CoreComm.ScreenLogicalOffsetX; - var ty = Emulator.CoreComm.ScreenLogicalOffsetY; - if (tx != 0 || ty != 0) - { - var transform = g.Transform; - transform.Translate(-tx, -ty); - g.Transform = transform; - } - - return g; - } - #endregion - - public override void AddMessage(string message) - { - GlobalWin.OSD.AddMessage(message); - } - - public override void ClearGraphics() - { - _GUISurface.Clear(); - DrawFinish(); - } - - public override void ClearText() - { - GlobalWin.OSD.ClearGUIText(); - } - - public override void DrawText(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, string fontfamily = null) - { - using (var g = GetGraphics()) - { - try - { - var index = 0; - if (string.IsNullOrEmpty(fontfamily)) - { - index = _defaultPixelFont; - } - else - { - switch (fontfamily) - { - case "fceux": - case "0": - index = 0; - break; - case "gens": - case "1": - index = 1; - break; - default: - Console.WriteLine($"Unable to find font family: {fontfamily}"); - return; - } - } - - var f = new StringFormat(StringFormat.GenericTypographic) - { - FormatFlags = StringFormatFlags.MeasureTrailingSpaces - }; - var font = new Font(GlobalWin.DisplayManager.CustomFonts.Families[index], 8, FontStyle.Regular, GraphicsUnit.Pixel); - Size sizeOfText = g.MeasureString(message, font, 0, f).ToSize(); - var rect = new Rectangle(new Point(x, y), sizeOfText + new Size(1, 0)); - if (backcolor.HasValue) g.FillRectangle(GetBrush(backcolor.Value), rect); - g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; - g.DrawString(message, font, GetBrush(forecolor ?? _defaultForeground), x, y); - } - catch (Exception) - { - return; - } - } - } - - public override void Text(int x, int y, string message, Color? forecolor = null, string anchor = null) - { - var a = 0; - - if (!string.IsNullOrEmpty(anchor)) - { - switch (anchor) - { - case "0": - case "topleft": - a = 0; - break; - case "1": - case "topright": - a = 1; - break; - case "2": - case "bottomleft": - a = 2; - break; - case "3": - case "bottomright": - a = 3; - break; - } - } - else - { - x -= Emulator.CoreComm.ScreenLogicalOffsetX; - y -= Emulator.CoreComm.ScreenLogicalOffsetY; - } - - GlobalWin.OSD.AddGUIText(message, x, y, Color.Black, forecolor ?? Color.White, a); - } - } -} \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.cs b/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.cs deleted file mode 100644 index 132ba4a2df..0000000000 --- a/BizHawk.Client.EmuHawk/Plugins/Libraries/PluginLibrary.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; - -using BizHawk.Common.ReflectionExtensions; -using BizHawk.Emulation.Common; -using BizHawk.Client.Common; - -namespace BizHawk.Client.EmuHawk - -{ - public class PluginLibrary - { -// public LuaDocumentation Docs { get; } - private void Register(IEmulatorServiceProvider serviceProvider) - { - // Docs.Clear(); - - // Register lua libraries - var libs = Assembly - .Load("BizHawk.Client.Common") - .GetTypes() - .Where(t => typeof(PluginLibraryBase).IsAssignableFrom(t)) - .Where(t => t.IsSealed) - .Where(t => ServiceInjector.IsAvailable(serviceProvider, t)) - .ToList(); - - libs.AddRange( - Assembly - .GetAssembly(typeof(PluginLibrary)) - .GetTypes() - .Where(t => typeof(PluginLibraryBase).IsAssignableFrom(t)) - .Where(t => t.IsSealed) - .Where(t => ServiceInjector.IsAvailable(serviceProvider, t))); - - foreach (var lib in libs) - { - var instance = (PluginLibraryBase)Activator.CreateInstance(lib); - ServiceInjector.UpdateServices(serviceProvider, instance); - Libraries.Add(lib, instance); - } - } - public PluginLibrary(IEmulatorServiceProvider serviceProvider) - { - Register(serviceProvider); - } - private readonly Dictionary Libraries = new Dictionary(); - public List PluginList { get; } = new List(); - - public IEnumerable RunningPlugins - { - get { return PluginList.Where(plug => plug.Enabled); } - } - -// private FormsPluginLibrary FormsLibrary => (FormsLuaLibrary)Libraries[typeof(FormsLuaLibrary)]; -// private EmulatorPluginLibrary EmuPluginLibrary => (EmulatorPluginLibrary)Libraries[typeof(EmulatorPluginLibrary)]; - private GUIPluginLibrary GuiLibrary => (GUIPluginLibrary)Libraries[typeof(GUIPluginLibrary)]; - - public void Restart(IEmulatorServiceProvider newServiceProvider) - { - Libraries.Clear(); - Register(newServiceProvider); - foreach (var plugin in PluginList) - { - plugin.Init(new PluginAPI(Libraries)); - } - } - - public void StartPluginDrawing() - { - if (PluginList.Any() && !GuiLibrary.HasGUISurface) - { - GuiLibrary.DrawNew("emu"); - } - } - - public void EndPluginDrawing() - { - if (PluginList.Any()) - { - GuiLibrary.DrawFinish(); - } - } - - public void CallSaveStateEvent(string name) - { - foreach (var plugin in RunningPlugins) plugin.SaveStateCallback(name); - } - - public void CallLoadStateEvent(string name) - { - foreach (var plugin in RunningPlugins) plugin.LoadStateCallback(name); - } - - public void CallFrameBeforeEvent() - { - StartPluginDrawing(); - foreach (var plugin in RunningPlugins) plugin.PreFrameCallback(); - } - - public void CallFrameAfterEvent() - { - foreach (var plugin in RunningPlugins) plugin.PostFrameCallback(); - EndPluginDrawing(); - } - - public void CallExitEvent() - { - foreach (var plugin in RunningPlugins) plugin.ExitCallback(); - } - - public void Close() - { - GuiLibrary.Dispose(); - } - - public void Load(PluginBase plugin) - { - plugin.Init(new PluginAPI(Libraries)); - PluginList.Add(plugin); - } - } -} diff --git a/BizHawk.Client.EmuHawk/Plugins/PluginAPI.cs b/BizHawk.Client.EmuHawk/Plugins/PluginAPI.cs deleted file mode 100644 index c2e1ea3960..0000000000 --- a/BizHawk.Client.EmuHawk/Plugins/PluginAPI.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Linq; - -using BizHawk.Client.Common; - -namespace BizHawk.Client.EmuHawk -{ - public sealed class PluginAPI : IPluginAPI - { - public EmulatorPluginLibrary EmuLib => (EmulatorPluginLibrary)Libraries[typeof(EmulatorPluginLibrary)]; - public GameInfoPluginLibrary GameInfoLib => (GameInfoPluginLibrary)Libraries[typeof(GameInfoPluginLibrary)]; - public GUIDrawPluginBase GUILib => (GUIDrawPluginBase)Libraries[typeof(GUIPluginLibrary)]; - public JoypadPluginLibrary JoypadLib => (JoypadPluginLibrary)Libraries[typeof(JoypadPluginLibrary)]; - public MemoryPluginLibrary MemLib => (MemoryPluginLibrary)Libraries[typeof(MemoryPluginLibrary)]; - public MemoryEventsPluginLibrary MemEventsLib => (MemoryEventsPluginLibrary)Libraries[typeof(MemoryEventsPluginLibrary)]; - public MemorySavestatePluginLibrary MemStateLib => (MemorySavestatePluginLibrary)Libraries[typeof(MemorySavestatePluginLibrary)]; - public MoviePluginLibrary MovieLib => (MoviePluginLibrary)Libraries[typeof(MoviePluginLibrary)]; - public SQLPluginLibrary SQLLib => (SQLPluginLibrary)Libraries[typeof(SQLPluginLibrary)]; - public UserDataPluginLibrary UserDataLib => (UserDataPluginLibrary)Libraries[typeof(UserDataPluginLibrary)]; - public Dictionary Libraries { get; set; } - public PluginAPI(Dictionary libs) - { - Libraries = libs; - } - } -} diff --git a/BizHawk.Client.EmuHawk/tools/ToolBox.cs b/BizHawk.Client.EmuHawk/tools/ToolBox.cs index 503714c6b1..67aefdfd0f 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolBox.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolBox.cs @@ -6,7 +6,7 @@ using System.Reflection; using System.Windows.Forms; using BizHawk.Emulation.Common; -using BizHawk.Client.Common; +using BizHawk.Client.ApiHawk; namespace BizHawk.Client.EmuHawk { @@ -66,6 +66,8 @@ namespace BizHawk.Client.EmuHawk continue; if (!ServiceInjector.IsAvailable(Emulator.ServiceProvider, t)) continue; +// if (!ApiInjector.IsAvailable(, t)) +// continue; var instance = Activator.CreateInstance(t); diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index 05d530176d..321b301c36 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -7,6 +7,7 @@ using System.Reflection; using System.ComponentModel; using System.Windows.Forms; +using BizHawk.Client.ApiHawk; using BizHawk.Client.Common; using BizHawk.Emulation.Common; using BizHawk.Common.ReflectionExtensions; @@ -121,6 +122,11 @@ namespace BizHawk.Client.EmuHawk (newTool as Form).Owner = GlobalWin.MainForm; } + if (isExternal) + { + ApiInjector.UpdateApis(GlobalWin.ApiProvider, newTool); + } + ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, newTool); string toolType = typeof(T).ToString(); @@ -491,6 +497,8 @@ namespace BizHawk.Client.EmuHawk if ((tool.IsHandleCreated && !tool.IsDisposed) || tool is RamWatch) // Hack for RAM Watch - in display watches mode it wants to keep running even closed, it will handle disposed logic { + if (tool is IExternalToolForm) + ApiInjector.UpdateApis(GlobalWin.ApiProvider, tool); tool.Restart(); } } diff --git a/BizHawk.Common/BizHawk.Common.csproj b/BizHawk.Common/BizHawk.Common.csproj index 8b9b8cac99..193d86f3fc 100644 --- a/BizHawk.Common/BizHawk.Common.csproj +++ b/BizHawk.Common/BizHawk.Common.csproj @@ -109,4 +109,4 @@ --> - + \ No newline at end of file