Enable NRTs in `EmulationApi`

This commit is contained in:
YoshiRulz 2022-03-01 11:17:28 +10:00
parent 64505fd23e
commit e8b3f5ffef
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 25 additions and 19 deletions

View File

@ -1,4 +1,6 @@
using System;
#nullable enable
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -20,29 +22,29 @@ namespace BizHawk.Client.Common
public sealed class EmulationApi : IEmulationApi
{
[RequiredService]
private IEmulator Emulator { get; set; }
private IEmulator? Emulator { get; set; }
[OptionalService]
private IBoardInfo BoardInfo { get; set; }
private IBoardInfo? BoardInfo { get; set; }
[OptionalService]
private IDebuggable DebuggableCore { get; set; }
private IDebuggable? DebuggableCore { get; set; }
[OptionalService]
private IDisassemblable DisassemblableCore { get; set; }
private IDisassemblable? DisassemblableCore { get; set; }
[OptionalService]
private IInputPollable InputPollableCore { get; set; }
private IInputPollable? InputPollableCore { get; set; }
[OptionalService]
private IMemoryDomains MemoryDomains { get; set; }
private IMemoryDomains? MemoryDomains { get; set; }
[OptionalService]
private IRegionable RegionableCore { get; set; }
private IRegionable? RegionableCore { get; set; }
private readonly Config _config;
private readonly IGameInfo _game;
private readonly IGameInfo? _game;
private readonly Action<string> LogCallback;
@ -58,7 +60,7 @@ namespace BizHawk.Client.Common
public bool ForbiddenConfigReferenceUsed { get; private set; }
public EmulationApi(Action<string> logCallback, Config config, IGameInfo game)
public EmulationApi(Action<string> logCallback, Config config, IGameInfo? game)
{
_config = config;
_game = game;
@ -67,9 +69,10 @@ namespace BizHawk.Client.Common
public void DisplayVsync(bool enabled) => _config.VSync = enabled;
public int FrameCount() => Emulator.Frame;
public int FrameCount()
=> Emulator!.Frame;
public object Disassemble(uint pc, string name = "")
public object? Disassemble(uint pc, string? name = null)
{
try
{
@ -77,7 +80,7 @@ namespace BizHawk.Client.Common
{
return new {
disasm = DisassemblableCore.Disassemble(
string.IsNullOrEmpty(name) ? MemoryDomains.SystemBus : MemoryDomains[name]!,
string.IsNullOrEmpty(name) ? MemoryDomains!.SystemBus : MemoryDomains![name!]!,
pc,
out var l
),
@ -97,7 +100,7 @@ namespace BizHawk.Client.Common
if (DebuggableCore != null)
{
var registers = DebuggableCore.GetCpuFlagsAndRegisters();
return registers.TryGetValue(name, out var rv) ? rv.Value : (ulong?) null;
return registers.TryGetValue(name, out var rv) ? rv.Value : null;
}
}
catch (NotImplementedException) {}
@ -146,7 +149,8 @@ namespace BizHawk.Client.Common
return default;
}
public string GetSystemId() => _game.System;
public string GetSystemId()
=> _game!.System;
public bool IsLagged()
{
@ -182,7 +186,7 @@ namespace BizHawk.Client.Common
public string GetBoardName() => BoardInfo?.BoardName ?? "";
public object GetSettings() => Emulator switch
public object? GetSettings() => Emulator switch
{
GPGX gpgx => gpgx.GetSettings(),
LibsnesCore snes => snes.GetSettings(),

View File

@ -1,4 +1,6 @@
using System.Collections.Generic;
#nullable enable
using System.Collections.Generic;
using BizHawk.Emulation.Common;
@ -8,7 +10,7 @@ namespace BizHawk.Client.Common
{
void DisplayVsync(bool enabled);
int FrameCount();
object Disassemble(uint pc, string name = "");
object? Disassemble(uint pc, string? name = null);
ulong? GetRegister(string name);
IReadOnlyDictionary<string, ulong> GetRegisters();
void SetRegister(string register, int value);
@ -22,7 +24,7 @@ namespace BizHawk.Client.Common
void MinimizeFrameskip(bool enabled);
string GetDisplayType();
string GetBoardName();
object GetSettings();
object? GetSettings();
PutSettingsDirtyBits PutSettings(object settings);
void SetRenderPlanes(params bool[] args);
}