dsda: fix shorttics and lmp import (not all)
This commit is contained in:
parent
e97a154f30
commit
61a6074bd1
|
@ -49,6 +49,7 @@ namespace BizHawk.Client.Common
|
|||
TurningResolution = DSDA.TurningResolution.Shorttics,
|
||||
RenderWipescreen = false,
|
||||
};
|
||||
|
||||
_ = input[i++]; // DisplayPlayer is a non-sync setting so importers can't* set it
|
||||
syncSettings.Player1Present = input[i++] is not 0;
|
||||
syncSettings.Player2Present = input[i++] is not 0;
|
||||
|
@ -56,9 +57,18 @@ namespace BizHawk.Client.Common
|
|||
syncSettings.Player4Present = input[i++] is not 0;
|
||||
Result.Movie.SyncSettingsJson = ConfigService.SaveWithType(syncSettings);
|
||||
|
||||
var doomController1 = new DoomController(1, false);
|
||||
var controller = new SimpleController(doomController1.Definition);
|
||||
var doomController = new DoomControllerDeck(
|
||||
DoomControllerTypes.Doom,
|
||||
syncSettings.Player1Present,
|
||||
syncSettings.Player2Present,
|
||||
syncSettings.Player3Present,
|
||||
syncSettings.Player4Present,
|
||||
syncSettings.TurningResolution == DSDA.TurningResolution.Longtics);
|
||||
|
||||
var controller = new SimpleController(doomController.Definition);
|
||||
controller.Definition.BuildMnemonicsCache(Result.Movie.SystemID);
|
||||
Result.Movie.LogKey = Bk2LogEntryGenerator.GenerateLogKey(controller.Definition);
|
||||
|
||||
void ParsePlayer(string playerPfx)
|
||||
{
|
||||
controller.AcceptNewAxis(playerPfx + "Run Speed", unchecked((sbyte) input[i++]));
|
||||
|
@ -72,6 +82,7 @@ namespace BizHawk.Client.Common
|
|||
int weapon = changeWeapon ? (((specialValue & 0b00111000) >> 3) + 1) : 0;
|
||||
controller.AcceptNewAxis(playerPfx + "Weapon Select", weapon);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (syncSettings.Player1Present) ParsePlayer("P1 ");
|
||||
|
|
|
@ -55,10 +55,10 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
public int ReadButtons2(IController c) => _port2.ReadButtons(c);
|
||||
public int ReadButtons3(IController c) => _port3.ReadButtons(c);
|
||||
public int 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 int ReadAxis1(IController c, string axis) => _port1.ReadAxis(c, axis);
|
||||
public int ReadAxis2(IController c, string axis) => _port2.ReadAxis(c, axis);
|
||||
public int ReadAxis3(IController c, string axis) => _port3.ReadAxis(c, axis);
|
||||
public int ReadAxis4(IController c, string axis) => _port4.ReadAxis(c, axis);
|
||||
|
||||
public static IReadOnlyDictionary<DoomControllerTypes, Func<int, bool, IPort>> ControllerCtors => _controllerCtors
|
||||
??= new Dictionary<DoomControllerTypes, Func<int, bool, IPort>>
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
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 int ReadPort(IController c);
|
||||
|
||||
public bool FrameAdvance(IController controller, bool renderVideo, bool renderAudio)
|
||||
|
@ -23,14 +22,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
new LibDSDA.PackedPlayerInput()
|
||||
];
|
||||
|
||||
ReadAxis[] axisReaders =
|
||||
[
|
||||
_controllerDeck.ReadAxis1,
|
||||
_controllerDeck.ReadAxis2,
|
||||
_controllerDeck.ReadAxis3,
|
||||
_controllerDeck.ReadAxis4,
|
||||
];
|
||||
|
||||
ReadPort[] buttonsReaders =
|
||||
[
|
||||
_controllerDeck.ReadButtons1,
|
||||
|
@ -70,13 +61,14 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
{
|
||||
if ((playersPresent & (1 << i)) is not 0)
|
||||
{
|
||||
bool strafe = controller.IsPressed($"P{i + 1} Strafe");
|
||||
int speedIndex = Convert.ToInt32(controller.IsPressed($"P{i + 1} Run")
|
||||
int port = i + 1;
|
||||
bool strafe = controller.IsPressed($"P{port} Strafe");
|
||||
int speedIndex = Convert.ToInt32(controller.IsPressed($"P{port} Run")
|
||||
|| _syncSettings.AlwaysRun);
|
||||
|
||||
int turnSpeed = 0;
|
||||
// lower speed for tapping turn buttons
|
||||
if (controller.IsPressed($"P{i + 1} Turn Right") || controller.IsPressed($"P{i + 1} Turn Left"))
|
||||
if (controller.IsPressed($"P{port} Turn Right") || controller.IsPressed($"P{port} Turn Left"))
|
||||
{
|
||||
_turnHeld[i]++;
|
||||
turnSpeed = _turnHeld[i] < 6 ? _turnSpeeds[2] : _turnSpeeds[speedIndex];
|
||||
|
@ -87,41 +79,49 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
}
|
||||
|
||||
// initial axis read
|
||||
players[i].RunSpeed = axisReaders[i](controller, (int)AxisType.RunSpeed);
|
||||
players[i].StrafingSpeed = axisReaders[i](controller, (int)AxisType.StrafingSpeed);
|
||||
players[i].WeaponSelect = axisReaders[i](controller, (int)AxisType.WeaponSelect);
|
||||
// core counts left angle as positive, so turning direction is "reversed"
|
||||
players[i].TurningSpeed = axisReaders[i](controller, (int)AxisType.TurningSpeed) << 8;
|
||||
players[i].RunSpeed = controller.AxisValue($"P{port} Run Speed");
|
||||
players[i].StrafingSpeed = controller.AxisValue($"P{port} Strafing Speed");
|
||||
players[i].WeaponSelect = controller.AxisValue($"P{port} Weapon Select");
|
||||
// core counts angle counterclockwise
|
||||
players[i].TurningSpeed = controller.AxisValue($"P{port} Turning Speed") << 8;
|
||||
|
||||
if (_syncSettings.TurningResolution == TurningResolution.Longtics)
|
||||
{
|
||||
players[i].TurningSpeed += axisReaders[i](controller, (int) AxisType.TurningSpeedFrac);
|
||||
players[i].TurningSpeed += controller.AxisValue($"P{port} Turning Speed Frac.");
|
||||
}
|
||||
|
||||
// override weapon axis based on buttons
|
||||
var weaponRange = controller.Definition.Axes[$"P{port} Weapon Select"].Range;
|
||||
for (var unit = weaponRange.Start; unit <= weaponRange.EndInclusive; unit++)
|
||||
{
|
||||
// if several weapon buttons are pressed, highest one overrides lower
|
||||
if (controller.IsPressed($"P{port} Weapon Select {unit}")) players[i].WeaponSelect = unit;
|
||||
}
|
||||
|
||||
// override axis based on movement buttons (turning is reversed upstream)
|
||||
if (controller.IsPressed($"P{i + 1} Forward")) players[i].RunSpeed = _runSpeeds [speedIndex];
|
||||
if (controller.IsPressed($"P{i + 1} Backward")) players[i].RunSpeed = -_runSpeeds [speedIndex];
|
||||
if (controller.IsPressed($"P{i + 1} Strafe Right")) players[i].StrafingSpeed = _strafeSpeeds[speedIndex];
|
||||
if (controller.IsPressed($"P{i + 1} Strafe Left")) players[i].StrafingSpeed = -_strafeSpeeds[speedIndex];
|
||||
// override movement axis based on buttons (turning is reversed upstream)
|
||||
if (controller.IsPressed($"P{port} Forward")) players[i].RunSpeed = _runSpeeds [speedIndex];
|
||||
if (controller.IsPressed($"P{port} Backward")) players[i].RunSpeed = -_runSpeeds [speedIndex];
|
||||
// turning with strafe button held will later be ADDED to these values (which is what makes strafe50 possible)
|
||||
if (controller.IsPressed($"P{port} Strafe Right")) players[i].StrafingSpeed = _strafeSpeeds[speedIndex];
|
||||
if (controller.IsPressed($"P{port} Strafe Left")) players[i].StrafingSpeed = -_strafeSpeeds[speedIndex];
|
||||
if (strafe)
|
||||
{
|
||||
// strafe50 needs this speed to be ADDED to whatever we got from directional strafe buttons
|
||||
if (controller.IsPressed($"P{i + 1} Turn Right")) players[i].StrafingSpeed += _strafeSpeeds[speedIndex];
|
||||
if (controller.IsPressed($"P{i + 1} Turn Left")) players[i].StrafingSpeed -= _strafeSpeeds[speedIndex];
|
||||
if (controller.IsPressed($"P{port} Turn Right")) players[i].StrafingSpeed += _strafeSpeeds[speedIndex];
|
||||
if (controller.IsPressed($"P{port} Turn Left")) players[i].StrafingSpeed -= _strafeSpeeds[speedIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (controller.IsPressed($"P{i + 1} Turn Right")) players[i].TurningSpeed -= turnSpeed;
|
||||
if (controller.IsPressed($"P{i + 1} Turn Left")) players[i].TurningSpeed += turnSpeed;
|
||||
if (controller.IsPressed($"P{port} Turn Right")) players[i].TurningSpeed -= turnSpeed;
|
||||
if (controller.IsPressed($"P{port} Turn Left")) players[i].TurningSpeed += turnSpeed;
|
||||
}
|
||||
|
||||
// mouse-driven running
|
||||
// divider matches the core
|
||||
players[i].RunSpeed -= (int)(axisReaders[i](controller, (int)AxisType.MouseRunning) * _syncSettings.MouseRunSensitivity / 8.0);
|
||||
players[i].RunSpeed -= (int)(controller.AxisValue($"P{port} Mouse Running") * _syncSettings.MouseRunSensitivity / 8.0);
|
||||
players[i].RunSpeed = players[i].RunSpeed.Clamp<int>(-_runSpeeds[1], _runSpeeds[1]);
|
||||
|
||||
// mouse-driven turning
|
||||
var mouseTurning = axisReaders[i](controller, (int)AxisType.MouseTurning) * _syncSettings.MouseTurnSensitivity;
|
||||
var mouseTurning = controller.AxisValue($"P{port} Mouse Turning") * _syncSettings.MouseTurnSensitivity;
|
||||
if (strafe)
|
||||
{
|
||||
players[i].StrafingSpeed += mouseTurning / 5;
|
||||
|
@ -155,8 +155,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
// Raven Games
|
||||
if (_syncSettings.InputFormat is DoomControllerTypes.Heretic or DoomControllerTypes.Hexen)
|
||||
{
|
||||
players[i].FlyLook = axisReaders[i](controller, (int)AxisType.FlyLook);
|
||||
players[i].ArtifactUse = axisReaders[i](controller, (int)AxisType.UseArtifact);
|
||||
players[i].FlyLook = controller.AxisValue($"P{port} Fly / Look");
|
||||
players[i].ArtifactUse = controller.AxisValue($"P{port} Use Artifact");
|
||||
|
||||
if (_syncSettings.InputFormat is DoomControllerTypes.Hexen)
|
||||
{
|
||||
players[i].Jump = (actionsBitfield & 0b01000) >> 3;
|
||||
|
|
|
@ -12,24 +12,10 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
Hexen
|
||||
}
|
||||
|
||||
// must match the order of axes added
|
||||
public enum AxisType : int
|
||||
{
|
||||
RunSpeed,
|
||||
StrafingSpeed,
|
||||
TurningSpeed,
|
||||
TurningSpeedFrac,
|
||||
WeaponSelect,
|
||||
MouseRunning,
|
||||
MouseTurning,
|
||||
FlyLook,
|
||||
UseArtifact,
|
||||
}
|
||||
|
||||
public interface IPort
|
||||
{
|
||||
int ReadButtons(IController c);
|
||||
int ReadAxis(IController c, int axis);
|
||||
int ReadAxis(IController c, string axis);
|
||||
ControllerDefinition Definition { get; }
|
||||
int PortNum { get; }
|
||||
}
|
||||
|
@ -100,23 +86,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
return result;
|
||||
}
|
||||
|
||||
public int ReadAxis(IController c, int axis)
|
||||
public int ReadAxis(IController c, string axis)
|
||||
{
|
||||
int x = c.AxisValue(Definition.Axes[axis]);
|
||||
|
||||
// Handling weapon select keys overriding axes values
|
||||
if (Definition.Axes[axis] == $"P{PortNum} Weapon Select")
|
||||
{
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 1")) x = 1;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 2")) x = 2;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 3")) x = 3;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 4")) x = 4;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 5")) x = 5;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 6")) x = 6;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 7")) x = 7;
|
||||
}
|
||||
|
||||
return x;
|
||||
return c.AxisValue(axis);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,65 +146,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
return result;
|
||||
}
|
||||
|
||||
public int ReadAxis(IController c, int axis)
|
||||
public int ReadAxis(IController c, string axis)
|
||||
{
|
||||
int x = c.AxisValue(Definition.Axes[axis]);
|
||||
|
||||
// Handling running keys overriding axes values
|
||||
if (Definition.Axes[axis] == $"P{PortNum} Run Speed")
|
||||
{
|
||||
if (c.IsPressed($"P{PortNum} Forward"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? 50 : 25;
|
||||
}
|
||||
|
||||
if (c.IsPressed($"P{PortNum} Backward"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? -50 : -25;
|
||||
}
|
||||
}
|
||||
|
||||
// Handling strafing keys overriding axes values
|
||||
if (Definition.Axes[axis] == $"P{PortNum} Strafing Speed")
|
||||
{
|
||||
if (c.IsPressed($"P{PortNum} Strafe Right"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? 40 : 24;
|
||||
}
|
||||
|
||||
if (c.IsPressed($"P{PortNum} Strafe Left"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? -40 : -24;
|
||||
}
|
||||
}
|
||||
|
||||
// Handling turning keys overriding axes values
|
||||
if (Definition.Axes[axis] == $"P{PortNum} Turning Speed")
|
||||
{
|
||||
if (c.IsPressed($"P{PortNum} Turn Left"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? 5 : 2;
|
||||
}
|
||||
|
||||
if (c.IsPressed($"P{PortNum} Turn Right"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? -5 : -2;
|
||||
}
|
||||
}
|
||||
|
||||
// Handling weapon select keys overriding axes values
|
||||
if (Definition.Axes[axis] == $"P{PortNum} Weapon Select")
|
||||
{
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 1")) x = 1;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 2")) x = 2;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 3")) x = 3;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 4")) x = 4;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 5")) x = 5;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 6")) x = 6;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 7")) x = 7;
|
||||
}
|
||||
|
||||
return x;
|
||||
return c.AxisValue(axis);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,62 +208,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
return result;
|
||||
}
|
||||
|
||||
public int ReadAxis(IController c, int axis)
|
||||
public int ReadAxis(IController c, string axis)
|
||||
{
|
||||
int x = c.AxisValue(Definition.Axes[axis]);
|
||||
|
||||
// Handling running keys overriding axes values
|
||||
if (Definition.Axes[axis] == $"P{PortNum} Run Speed")
|
||||
{
|
||||
if (c.IsPressed($"P{PortNum} Forward"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? 50 : 25;
|
||||
}
|
||||
|
||||
if (c.IsPressed($"P{PortNum} Backward"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? -50 : -25;
|
||||
}
|
||||
}
|
||||
|
||||
// Handling strafing keys overriding axes values
|
||||
if (Definition.Axes[axis] == $"P{PortNum} Strafing Speed")
|
||||
{
|
||||
if (c.IsPressed($"P{PortNum} Strafe Right"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? 40 : 24;
|
||||
}
|
||||
|
||||
if (c.IsPressed($"P{PortNum} Strafe Left"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? -40 : -24;
|
||||
}
|
||||
}
|
||||
|
||||
// Handling turning keys overriding axes values
|
||||
if (Definition.Axes[axis] == $"P{PortNum} Turning Speed")
|
||||
{
|
||||
if (c.IsPressed($"P{PortNum} Turn Left"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? 5 : 2;
|
||||
}
|
||||
|
||||
if (c.IsPressed($"P{PortNum} Turn Right"))
|
||||
{
|
||||
x = c.IsPressed($"P{PortNum} Run") ? -5 : -2;
|
||||
}
|
||||
}
|
||||
|
||||
// Handling weapon select keys overriding axes values
|
||||
if (Definition.Axes[axis] == $"P{PortNum} Weapon Select")
|
||||
{
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 1")) x = 1;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 2")) x = 2;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 3")) x = 3;
|
||||
if (c.IsPressed($"P{PortNum} Weapon Select 4")) x = 4;
|
||||
}
|
||||
|
||||
return x;
|
||||
return c.AxisValue(axis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue