dsda: positioning

This commit is contained in:
feos 2025-03-21 20:23:53 +03:00
parent 92df238d9e
commit f9a3890ac1
7 changed files with 42 additions and 92 deletions

View File

@ -11,56 +11,38 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
{
Definition = new("Doom Demo LMP 1.9 Input Format") { };
if (player1Present) Port1 = ControllerCtors[controllerType](1, longtics);
if (player2Present) Port2 = ControllerCtors[controllerType](2, longtics);
if (player3Present) Port3 = ControllerCtors[controllerType](3, longtics);
if (player4Present) Port4 = ControllerCtors[controllerType](4, longtics);
if (player1Present) _port1 = ControllerCtors[controllerType](1, longtics);
if (player2Present) _port2 = ControllerCtors[controllerType](2, longtics);
if (player3Present) _port3 = ControllerCtors[controllerType](3, longtics);
if (player4Present) _port4 = ControllerCtors[controllerType](4, longtics);
if (player1Present) Definition.BoolButtons.AddRange(Port1.Definition.BoolButtons.ToList());
if (player2Present) Definition.BoolButtons.AddRange(Port2.Definition.BoolButtons.ToList());
if (player3Present) Definition.BoolButtons.AddRange(Port3.Definition.BoolButtons.ToList());
if (player4Present) Definition.BoolButtons.AddRange(Port4.Definition.BoolButtons.ToList());
if (player1Present) Definition.BoolButtons.AddRange(_port1.Definition.BoolButtons.ToList());
if (player2Present) Definition.BoolButtons.AddRange(_port2.Definition.BoolButtons.ToList());
if (player3Present) Definition.BoolButtons.AddRange(_port3.Definition.BoolButtons.ToList());
if (player4Present) Definition.BoolButtons.AddRange(_port4.Definition.BoolButtons.ToList());
if (player1Present) foreach (var kvp in Port1.Definition.Axes) Definition.Axes.Add(kvp);
if (player2Present) foreach (var kvp in Port2.Definition.Axes) Definition.Axes.Add(kvp);
if (player3Present) foreach (var kvp in Port3.Definition.Axes) Definition.Axes.Add(kvp);
if (player4Present) foreach (var kvp in Port4.Definition.Axes) Definition.Axes.Add(kvp);
if (player1Present) foreach (var kvp in _port1.Definition.Axes) Definition.Axes.Add(kvp);
if (player2Present) foreach (var kvp in _port2.Definition.Axes) Definition.Axes.Add(kvp);
if (player3Present) foreach (var kvp in _port3.Definition.Axes) Definition.Axes.Add(kvp);
if (player4Present) foreach (var kvp in _port4.Definition.Axes) Definition.Axes.Add(kvp);
Definition.MakeImmutable();
}
public byte ReadButtons1(IController c)
=> Port1.ReadButtons(c);
public byte ReadButtons2(IController c)
=> Port2.ReadButtons(c);
public byte ReadButtons3(IController c)
=> Port3.ReadButtons(c);
public byte ReadButtons4(IController c)
=> Port4.ReadButtons(c);
public int ReadAxis1(IController c, int axis)
=> Port1.ReadAxis(c, axis);
public int ReadAxis2(IController c, int axis)
=> Port2.ReadAxis(c, axis);
public int ReadAxis3(IController c, int axis)
=> Port3.ReadAxis(c, axis);
public int ReadAxis4(IController c, int axis)
=> Port4.ReadAxis(c, axis);
public ControllerDefinition Definition { get; }
private readonly IPort Port1;
private readonly IPort Port2;
private readonly IPort Port3;
private readonly IPort Port4;
private readonly IPort _port1;
private readonly IPort _port2;
private readonly IPort _port3;
private readonly IPort _port4;
private static IReadOnlyDictionary<DoomControllerTypes, Func<int, bool, IPort>> _controllerCtors;
public ControllerDefinition Definition { get; }
public byte ReadButtons1(IController c) => _port1.ReadButtons(c);
public byte ReadButtons2(IController c) => _port2.ReadButtons(c);
public byte ReadButtons3(IController c) => _port3.ReadButtons(c);
public byte ReadButtons4(IController c) => _port4.ReadButtons(c);
public int ReadAxis1(IController c, int axis) => _port1.ReadAxis(c, axis);
public int ReadAxis2(IController c, int axis) => _port2.ReadAxis(c, axis);
public int ReadAxis3(IController c, int axis) => _port3.ReadAxis(c, axis);
public int ReadAxis4(IController c, int axis) => _port4.ReadAxis(c, axis);
public static IReadOnlyDictionary<DoomControllerTypes, Func<int, bool, IPort>> ControllerCtors => _controllerCtors
??= new Dictionary<DoomControllerTypes, Func<int, bool, IPort>>

View File

@ -7,10 +7,11 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
public partial class DSDA : IEmulator
{
public IEmulatorServiceProvider ServiceProvider { get; }
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
private delegate int ReadPot(IController c, int pot);
public int Frame { get; private set; }
public string SystemId => VSystemID.Raw.Doom;
public bool DeterministicEmulation => true;
private delegate int ReadAxis(IController c, int axis);
private delegate byte ReadPort(IController c);
public bool FrameAdvance(IController controller, bool renderVideo, bool renderAudio)
@ -23,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
new PackedPlayerInput()
];
ReadPot[] axisReaders =
ReadAxis[] axisReaders =
[
_controllerDeck.ReadAxis1,
_controllerDeck.ReadAxis2,
@ -145,12 +146,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
return true;
}
public int Frame { get; private set; }
public string SystemId => VSystemID.Raw.Doom;
public bool DeterministicEmulation => true;
public void ResetCounters()
{
Frame = 0;

View File

@ -4,11 +4,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
{
public partial class DSDA : IInputPollable
{
private readonly InputCallbackSystem _inputCallbacks = [ ];
public int LagCount { get; set; } = 0;
public bool IsLagFrame { get; set; } = false;
public IInputCallbackSystem InputCallbacks => _inputCallbacks;
private readonly InputCallbackSystem _inputCallbacks = [ ];
}
}

View File

@ -9,8 +9,8 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
{
private readonly short[] _samples = new short[6280];
private int _nsamp;
public bool CanProvideAsync => false;
public SyncSoundMode SyncMode => SyncSoundMode.Sync;
public void GetSamplesSync(out short[] samples, out int nsamp)
{
@ -30,8 +30,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
}
public SyncSoundMode SyncMode => SyncSoundMode.Sync;
public void GetSamplesAsync(short[] samples)
=> throw new InvalidOperationException("Async mode is not supported.");

View File

@ -5,26 +5,17 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
{
public partial class DSDA : IVideoProvider
{
public int[] GetVideoBuffer() => _vidBuff;
public int VirtualWidth => BufferHeight * 4 / 3;
public int VirtualHeight => BufferHeight;
public int PaletteSize { get; private set; }
public int BufferWidth { get; private set; }
public int BufferHeight { get; private set; }
public int BackgroundColor => unchecked((int)0xff000000);
public int VsyncNumerator { get; }
public int VsyncDenominator { get; }
private int[] _palBuffer = [ ];
private int[] _vidBuff = [ ];
public int VirtualWidth => BufferHeight * 4 / 3;
public int VirtualHeight => BufferHeight;
public int PaletteSize { get; private set; }
public int BufferWidth { get; private set; }
public int BufferHeight { get; private set; }
public int BackgroundColor => unchecked((int)0xff000000);
public int VsyncNumerator { get; }
public int VsyncDenominator { get; }
public int[] GetVideoBuffer() => _vidBuff;
private unsafe void UpdateVideo()
{

View File

@ -181,11 +181,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
_args.Add("-warp");
ConditionalArg(_syncSettings.InitialEpisode is not 0 && _gameMode != CInterface.GameMode.Commercial, $"{_syncSettings.InitialEpisode}");
_args.Add($"{_syncSettings.InitialMap}");
_args.AddRange([ "-skill", $"{(int)_syncSettings.SkillLevel}" ]);
_args.AddRange([ "-complevel", $"{(int)_syncSettings.CompatibilityLevel}" ]);
_args.AddRange([ "-config", "dsda-doom.cfg" ]);
ConditionalArg(!_syncSettings.StrictMode, "-tas");
ConditionalArg(_syncSettings.FastMonsters, "-fast");
ConditionalArg(_syncSettings.MonstersRespawn, "-respawn");
@ -223,6 +221,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
private List<string> _args;
private List<IRomAsset> _wadFiles;
private CInterface.GameMode _gameMode;
public string RomDetails { get; } // IRomInfo
/// <summary>
/// core callback for file loading
@ -284,11 +283,5 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
throw new InvalidOperationException($"Unknown error processing file '{filename}'");
}
}
// IRegionable
public DisplayType Region { get; }
// IRomInfo
public string RomDetails { get; }
}
}

View File

@ -28,11 +28,8 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
public interface IPort
{
byte ReadButtons(IController c);
int ReadAxis(IController c, int axis);
ControllerDefinition Definition { get; }
int PortNum { get; }
}
@ -57,9 +54,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
public int PortNum { get; }
public ControllerDefinition Definition { get; }
private bool _longtics;
private static readonly string[] _baseDefinition =
@ -136,7 +131,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
public int PortNum { get; }
public ControllerDefinition Definition { get; }
private static readonly string[] _baseDefinition =
@ -253,7 +247,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
public int PortNum { get; }
public ControllerDefinition Definition { get; }
private static readonly string[] _baseDefinition =