diff --git a/ChocolArm64/ATranslator.cs b/ChocolArm64/ATranslator.cs index 7937aaf7fd..a83eb08ea3 100644 --- a/ChocolArm64/ATranslator.cs +++ b/ChocolArm64/ATranslator.cs @@ -22,7 +22,7 @@ namespace ChocolArm64 public bool EnableCpuTrace { get; set; } - public static ManualResetEvent PauseResetEvent = new ManualResetEvent(true); + private ManualResetEvent PauseResetEvent = new ManualResetEvent(true); public ATranslator(IReadOnlyDictionary SymbolTable = null) { @@ -64,7 +64,7 @@ namespace ChocolArm64 OpCode.Interpreter(State, Memory, OpCode); - PauseResetEvent.WaitOne(1000); + PauseResetEvent.WaitOne(); } while (State.R15 != 0 && State.Running); } @@ -209,5 +209,15 @@ namespace ChocolArm64 } } } + + public void Pause() + { + PauseResetEvent.Reset(); + } + + public void Resume() + { + PauseResetEvent.Set(); + } } } \ No newline at end of file diff --git a/Ryujinx.Graphics/Gal/IGalRenderer.cs b/Ryujinx.Graphics/Gal/IGalRenderer.cs index 61d42dfa3b..48db59b11e 100644 --- a/Ryujinx.Graphics/Gal/IGalRenderer.cs +++ b/Ryujinx.Graphics/Gal/IGalRenderer.cs @@ -2,7 +2,7 @@ using System; namespace Ryujinx.Graphics.Gal { - public unsafe interface IGalRenderer : IDisposable + public interface IGalRenderer : IDisposable { void QueueAction(Action ActionMthd); diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs index 8837f49b92..cd52762c79 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs @@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL } } - public class FrameBuffer + private class FrameBuffer { public int Width { get; set; } public int Height { get; set; } diff --git a/Ryujinx.HLE/Loaders/Executables/Nro.cs b/Ryujinx.HLE/Loaders/Executables/Nro.cs index 4861920c7f..21e3dba9d0 100644 --- a/Ryujinx.HLE/Loaders/Executables/Nro.cs +++ b/Ryujinx.HLE/Loaders/Executables/Nro.cs @@ -1,7 +1,4 @@ -using System; -using System.Drawing; using System.IO; -using System.Text; namespace Ryujinx.HLE.Loaders.Executables { @@ -43,12 +40,12 @@ namespace Ryujinx.HLE.Loaders.Executables int DataSize = Reader.ReadInt32(); int BssSize = Reader.ReadInt32(); - this.Mod0Offset = Mod0Offset; - this.TextOffset = TextOffset; - this.ROOffset = ROOffset; - this.DataOffset = DataOffset; - this.BssSize = BssSize; - this.FileSize = FileSize; + this.Mod0Offset = Mod0Offset; + this.TextOffset = TextOffset; + this.ROOffset = ROOffset; + this.DataOffset = DataOffset; + this.BssSize = BssSize; + this.FileSize = FileSize; byte[] Read(long Position, int Size) { diff --git a/Ryujinx.HLE/OsHle/Horizon.cs b/Ryujinx.HLE/OsHle/Horizon.cs index 7b8b4b40c4..0e3f0eb076 100644 --- a/Ryujinx.HLE/OsHle/Horizon.cs +++ b/Ryujinx.HLE/OsHle/Horizon.cs @@ -195,15 +195,7 @@ namespace Ryujinx.HLE.OsHle if (Processes.TryRemove(ProcessId, out Process)) { - try - { - Process.StopAllThreadsAsync(); - Process.Dispose(); - } - catch (ObjectDisposedException Ex) - { - - } + Process.StopAllThreadsAsync(); if (Processes.Count == 0) { diff --git a/Ryujinx.HLE/OsHle/Process.cs b/Ryujinx.HLE/OsHle/Process.cs index f0619111ee..a7cf026a76 100644 --- a/Ryujinx.HLE/OsHle/Process.cs +++ b/Ryujinx.HLE/OsHle/Process.cs @@ -176,7 +176,7 @@ namespace Ryujinx.HLE.OsHle throw new ObjectDisposedException(nameof(Process)); } - ATranslator.PauseResetEvent.Reset(); + Translator.Pause(); } public void Resume() @@ -186,7 +186,7 @@ namespace Ryujinx.HLE.OsHle throw new ObjectDisposedException(nameof(Process)); } - ATranslator.PauseResetEvent.Set(); + Translator.Resume(); } private void MapRWMemRegion(long Position, long Size, MemoryType Type) @@ -198,7 +198,7 @@ namespace Ryujinx.HLE.OsHle { if (Disposed) { - throw new ObjectDisposedException(nameof(Process)); + return; } if (MainThread != null) @@ -423,7 +423,7 @@ namespace Ryujinx.HLE.OsHle { if (Disposing && !Disposed) { - ATranslator.PauseResetEvent.Set(); + Translator.Resume(); //If there is still some thread running, disposing the objects is not //safe as the thread may try to access those resources. Instead, we set diff --git a/Ryujinx.UI/EmulationController.cs b/Ryujinx.UI/EmulationController.cs index b965d27652..c4985d809d 100644 --- a/Ryujinx.UI/EmulationController.cs +++ b/Ryujinx.UI/EmulationController.cs @@ -19,22 +19,21 @@ namespace Ryujinx.UI public void Resume() { - lock (Ns) - Ns.Os.ResumeAllProcesses(); + Ns.Os.ResumeAllProcesses(); } public void Pause() { - lock (Ns) - Ns.Os.PauseAllProcesses(); + Ns.Os.PauseAllProcesses(); } public void ShutDown() { - lock (Ns) - Ns.Dispose(); - Ns = null; + Ns.Dispose(); + + Ns = null; IsLoaded = false; + IsShutDown.Invoke(null,null); } diff --git a/Ryujinx.UI/Extensions/ControlArchive.cs b/Ryujinx.UI/Extensions/ControlArchive.cs index c85ef04302..4e7cbdec4a 100644 --- a/Ryujinx.UI/Extensions/ControlArchive.cs +++ b/Ryujinx.UI/Extensions/ControlArchive.cs @@ -45,10 +45,9 @@ namespace Ryujinx.UI } } - public struct LanguageEntry { public string AplicationName; public string DeveloperName; } -} +} \ No newline at end of file diff --git a/Ryujinx.UI/Extensions/Nro.cs b/Ryujinx.UI/Extensions/Nro.cs index c94d6b6c17..167cc7e8ff 100644 --- a/Ryujinx.UI/Extensions/Nro.cs +++ b/Ryujinx.UI/Extensions/Nro.cs @@ -15,7 +15,6 @@ namespace Ryujinx.UI public ControlArchive ControlArchive { get; set; } - public Nro(Stream Input, string Name) : base(Input, Name) { BinaryReader Reader = new BinaryReader(Input); diff --git a/Ryujinx.UI/GUI/Widgets/FilePicker.cs b/Ryujinx.UI/GUI/Widgets/FilePicker.cs index db76997636..0eeac2ad7c 100644 --- a/Ryujinx.UI/GUI/Widgets/FilePicker.cs +++ b/Ryujinx.UI/GUI/Widgets/FilePicker.cs @@ -5,10 +5,8 @@ using System.Numerics; namespace ImGuiNET { - /// - /// Adapted from Mellinoe's file picker for imgui - /// https://github.com/mellinoe/synthapp/blob/master/src/synthapp/Widgets/FilePicker.cs - /// + // Adapted from Mellinoe's file picker for imgui + // https://github.com/mellinoe/synthapp/blob/master/src/synthapp/Widgets/FilePicker.cs public class FilePicker { private const string FilePickerID = "###FilePicker"; diff --git a/Ryujinx.UI/GUI/Widgets/GameList.cs b/Ryujinx.UI/GUI/Widgets/GameList.cs index b58d179521..59746f1f3f 100644 --- a/Ryujinx.UI/GUI/Widgets/GameList.cs +++ b/Ryujinx.UI/GUI/Widgets/GameList.cs @@ -61,7 +61,7 @@ namespace Ryujinx.UI.Widgets } } - public unsafe static Tuple DrawList() + public unsafe static (bool,string) DrawList() { uint id = 100; @@ -131,7 +131,7 @@ namespace Ryujinx.UI.Widgets if (ImGui.IsMouseDoubleClicked(0) && ImGui.IsItemHovered(HoveredFlags.AllowWhenOverlapped) && GameItem == SelectedGame) { - return new Tuple(true, GameItem.Path); + return (true, GameItem.Path); } else if (ImGui.IsMouseClicked(0) && ImGui.IsItemHovered(HoveredFlags.AllowWhenOverlapped | HoveredFlags.RootAndChildWindows)) { @@ -145,7 +145,7 @@ namespace Ryujinx.UI.Widgets ImGui.EndChildFrame(); } - return new Tuple(false,string.Empty); + return (false, string.Empty); } } @@ -174,15 +174,11 @@ namespace Ryujinx.UI.Widgets } else AppletType = AppletType.Cartridge; - } + } public byte[] GetIconData() { - if (IsNro) - { - return Nro.IconData; - } - else return null; + return IsNro ? Nro.IconData : null; } } diff --git a/Ryujinx.UI/GUI/Widgets/HomeUI.cs b/Ryujinx.UI/GUI/Widgets/HomeUI.cs index 819f3e2372..188306e0bf 100644 --- a/Ryujinx.UI/GUI/Widgets/HomeUI.cs +++ b/Ryujinx.UI/GUI/Widgets/HomeUI.cs @@ -1,5 +1,6 @@ using ImGuiNET; using System; +using System.Numerics; namespace Ryujinx.UI { @@ -7,30 +8,30 @@ namespace Ryujinx.UI { void RenderMainUI() { - ImGui.SetNextWindowPos(System.Numerics.Vector2.Zero, Condition.Always, - System.Numerics.Vector2.Zero); - ImGui.SetNextWindowSize(new System.Numerics.Vector2(Width, Height), Condition.Always); + ImGui.SetNextWindowPos(Vector2.Zero, Condition.Always, + Vector2.Zero); + ImGui.SetNextWindowSize(new Vector2(Width, Height), Condition.Always); if (ImGui.BeginWindow("MainWindow", ref showMainUI, WindowFlags.NoTitleBar | WindowFlags.NoMove | WindowFlags.AlwaysAutoResize)) { - if (ImGui.BeginChildFrame(0, new System.Numerics.Vector2(-1, -1), + if (ImGui.BeginChildFrame(0, new Vector2(-1, -1), WindowFlags.AlwaysAutoResize)) { ImGuiNative.igBeginGroup(); - if (ImGui.Button("Load Package", new System.Numerics.Vector2(Values.ButtonWidth, + if (ImGui.Button("Load Package", new Vector2(Values.ButtonWidth, Values.ButtonHeight))) { CurrentPage = Page.PackageLoader; } - if (ImGui.Button("Game List", new System.Numerics.Vector2(Values.ButtonWidth, + if (ImGui.Button("Game List", new Vector2(Values.ButtonWidth, Values.ButtonHeight))) { CurrentPage = Page.GameList; } - if (ImGui.Button("Settings", new System.Numerics.Vector2(Values.ButtonWidth, + if (ImGui.Button("Settings", new Vector2(Values.ButtonWidth, Values.ButtonHeight))) { CurrentPage = Page.Configuration; @@ -78,7 +79,7 @@ namespace Ryujinx.UI void DrawQuitButton() { - if (ImGui.Button("Quit Ryujinx", new System.Numerics.Vector2(Values.ButtonWidth, + if (ImGui.Button("Quit Ryujinx", new Vector2(Values.ButtonWidth, Values.ButtonHeight))) { ImGui.OpenPopup("Quit"); diff --git a/Ryujinx.UI/GUI/WindowHelper.cs b/Ryujinx.UI/GUI/WindowHelper.cs index 593f3364db..ca93d2782c 100644 --- a/Ryujinx.UI/GUI/WindowHelper.cs +++ b/Ryujinx.UI/GUI/WindowHelper.cs @@ -179,8 +179,6 @@ namespace Ryujinx.UI GL.ClearColor(ClearColor.X, ClearColor.Y, ClearColor.Z, ClearColor.W); GL.Clear(ClearBufferMask.ColorBufferBit); - // We are using the OpenGL fixed pipeline to make the example code simpler to read! - // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers. GL.GetInteger(GetPName.TextureBinding2D, out int last_texture); GL.PushAttrib(AttribMask.EnableBit | AttribMask.ColorBufferBit | AttribMask.TransformBit); GL.Enable(EnableCap.Blend);