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 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(); 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"); throw new InvalidOperationException("Unexpected error in gambatte_getmemoryarea");
} }
return new GPUMemoryAreas return new GPUMemoryAreas(vram: _vram, oam: _oam, sppal: _sppal, bgpal: _bgpal);
{
Vram = _vram,
Oam = _oam,
Sppal = _sppal,
Bgpal = _bgpal,
};
} }
private class GPUMemoryAreas : IGPUMemoryAreas 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() {} public void Dispose() {}
} }

View File

@ -312,13 +312,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
_exe.Enter(); _exe.Enter();
try try
{ {
return new GPUMemoryAreas(_exe) return new GPUMemoryAreas(_exe,
{ vram: _cachedGpuPointers[0],
Vram = _cachedGpuPointers[0], oam: _cachedGpuPointers[1],
Oam = _cachedGpuPointers[1], sppal: _cachedGpuPointers[3],
Sppal = _cachedGpuPointers[3], bgpal: _cachedGpuPointers[2]);
Bgpal = _cachedGpuPointers[2]
};
} }
catch catch
{ {
@ -330,17 +328,21 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
private class GPUMemoryAreas : IGPUMemoryAreas private class GPUMemoryAreas : IGPUMemoryAreas
{ {
private IMonitor _monitor; 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; _monitor = monitor;
Vram = vram;
Oam = oam;
Sppal = sppal;
Bgpal = bgpal;
} }
public void Dispose() public void Dispose()