From af8a3304229f110b72b8aac6b750cdb5b7fc607e Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Fri, 15 Jan 2021 21:32:07 +1000 Subject: [PATCH] Replace unnecessary init props w/ ctors, remove hack for init props --- src/BizHawk.Common/IsExternalInit.cs | 4 --- .../Consoles/Nintendo/GBHawk/GBHawk.cs | 6 ++--- .../Consoles/Nintendo/Gameboy/Gambatte.cs | 24 +++++++++-------- .../Consoles/Nintendo/Gameboy/Sameboy.cs | 26 ++++++++++--------- 4 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 src/BizHawk.Common/IsExternalInit.cs diff --git a/src/BizHawk.Common/IsExternalInit.cs b/src/BizHawk.Common/IsExternalInit.cs deleted file mode 100644 index 3618710c91..0000000000 --- a/src/BizHawk.Common/IsExternalInit.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace System.Runtime.CompilerServices -{ - public static class IsExternalInit {} -} diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs index 0db4fa670a..a102a52877 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs @@ -288,11 +288,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { public IntPtr Vram { get; } - public IntPtr Oam { get; init; } + public IntPtr Oam { get; } - public IntPtr Sppal { get; init; } + public IntPtr Sppal { get; } - public IntPtr Bgpal { get; init; } + public IntPtr Bgpal { get; } private readonly List _handles = new(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index 49747d8c74..af382419ee 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -396,24 +396,26 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { throw new InvalidOperationException("Unexpected error in gambatte_getmemoryarea"); } - return new GPUMemoryAreas - { - Vram = _vram, - Oam = _oam, - Sppal = _sppal, - Bgpal = _bgpal, - }; + return new GPUMemoryAreas(vram: _vram, oam: _oam, sppal: _sppal, bgpal: _bgpal); } private class GPUMemoryAreas : IGPUMemoryAreas { - public IntPtr Vram { get; init; } + public IntPtr Vram { get; } - public IntPtr Oam { get; init; } + public IntPtr Oam { get; } - public IntPtr Sppal { get; init; } + public IntPtr Sppal { get; } - public IntPtr Bgpal { get; init; } + public IntPtr Bgpal { get; } + + public GPUMemoryAreas(IntPtr vram, IntPtr oam, IntPtr sppal, IntPtr bgpal) + { + Vram = vram; + Oam = oam; + Sppal = sppal; + Bgpal = bgpal; + } public void Dispose() {} } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs index 59ec6a3b99..fd5ef63c03 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs @@ -312,13 +312,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy _exe.Enter(); try { - return new GPUMemoryAreas(_exe) - { - Vram = _cachedGpuPointers[0], - Oam = _cachedGpuPointers[1], - Sppal = _cachedGpuPointers[3], - Bgpal = _cachedGpuPointers[2] - }; + return new GPUMemoryAreas(_exe, + vram: _cachedGpuPointers[0], + oam: _cachedGpuPointers[1], + sppal: _cachedGpuPointers[3], + bgpal: _cachedGpuPointers[2]); } catch { @@ -330,17 +328,21 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy private class GPUMemoryAreas : IGPUMemoryAreas { private IMonitor _monitor; - public IntPtr Vram { get; init; } + public IntPtr Vram { get; } - public IntPtr Oam { get; init; } + public IntPtr Oam { get; } - public IntPtr Sppal { get; init; } + public IntPtr Sppal { get; } - public IntPtr Bgpal { get; init; } + public IntPtr Bgpal { get; } - public GPUMemoryAreas(IMonitor monitor) + public GPUMemoryAreas(IMonitor monitor, IntPtr vram, IntPtr oam, IntPtr sppal, IntPtr bgpal) { _monitor = monitor; + Vram = vram; + Oam = oam; + Sppal = sppal; + Bgpal = bgpal; } public void Dispose()