Replace unnecessary init props w/ ctors, remove hack for init props

This commit is contained in:
YoshiRulz 2021-01-15 21:32:07 +10:00
parent 7f0947108c
commit af8a330422
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
4 changed files with 30 additions and 30 deletions

View File

@ -1,4 +0,0 @@
namespace System.Runtime.CompilerServices
{
public static class IsExternalInit {}
}

View File

@ -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<GCHandle> _handles = new();

View File

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

View File

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