From f58644cb5ad682b4b35b0f1fcfe761907499f612 Mon Sep 17 00:00:00 2001 From: feos Date: Tue, 8 Apr 2025 22:49:50 +0300 Subject: [PATCH] dsda: make strafe50 possible in vanilla doom, turn key + strafe key = strafe in the direction of the turning key. but if directional strafe key is added to the mix, both strafe speeds are ADDED TOGETHER. on top of that, max strafe speed is max vertical movement speed (50), NOT the speed you get if you strafe while holding the run key (40). all of this makes strafe50 possible in vanilla, and turning is impossible at that time (because strafe key turns turning into strafing). --- .../Base Implementations/Bk2MnemonicLookup.cs | 1 + .../Computers/Doom/DSDA.IEmulator.cs | 32 +++++++++++++------ .../Computers/Doom/DSDAControllers.cs | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/BizHawk.Emulation.Common/Base Implementations/Bk2MnemonicLookup.cs b/src/BizHawk.Emulation.Common/Base Implementations/Bk2MnemonicLookup.cs index 36656aea36..b6c56c10f8 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/Bk2MnemonicLookup.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/Bk2MnemonicLookup.cs @@ -839,6 +839,7 @@ namespace BizHawk.Emulation.Common ["Forward"] = '^', ["Jump"] = 'J', ["Run"] = 'R', + ["Strafe"] = 'S', ["Strafe Left"] = '<', ["Strafe Right"] = '>', ["Turn Left"] = '{', diff --git a/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.IEmulator.cs b/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.IEmulator.cs index 1e0071e9a7..befce89279 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.IEmulator.cs @@ -49,6 +49,7 @@ 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") || _syncSettings.AlwaysRun); @@ -65,18 +66,29 @@ namespace BizHawk.Emulation.Cores.Computers.Doom } // initial axis read - players[i].RunSpeed = axisReaders[i](controller, (int)AxisType.RunSpeed); + players[i].RunSpeed = axisReaders[i](controller, (int)AxisType.RunSpeed); players[i].StrafingSpeed = axisReaders[i](controller, (int)AxisType.StrafingSpeed); - players[i].TurningSpeed = axisReaders[i](controller, (int)AxisType.TurningSpeed); - players[i].WeaponSelect = axisReaders[i](controller, (int)AxisType.WeaponSelect); + players[i].TurningSpeed = axisReaders[i](controller, (int)AxisType.TurningSpeed); + players[i].WeaponSelect = axisReaders[i](controller, (int)AxisType.WeaponSelect); // 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]; - 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{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]; + 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]; + } + 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; + } + // ultimately strafe speed is limited to max run speed, NOT max strafe speed + players[i].StrafingSpeed = players[i].StrafingSpeed.Clamp(-_runSpeeds[1], _runSpeeds[1]); // mouse-driven running // divider matches the core @@ -109,7 +121,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom players[i].ArtifactUse = axisReaders[i](controller, (int)AxisType.UseArtifact); if (_syncSettings.InputFormat is DoomControllerTypes.Hexen) { - players[i].Jump = (actionsBitfield & 0b01000) >> 3; + players[i].Jump = (actionsBitfield & 0b01000) >> 3; players[i].EndPlayer = (actionsBitfield & 0b10000) >> 4; } } diff --git a/src/BizHawk.Emulation.Cores/Computers/Doom/DSDAControllers.cs b/src/BizHawk.Emulation.Cores/Computers/Doom/DSDAControllers.cs index 5dad652505..e4a554f18d 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Doom/DSDAControllers.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Doom/DSDAControllers.cs @@ -45,7 +45,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom .Select(b => $"P{PortNum} " + b) .ToList() }.AddAxis($"P{PortNum} Run Speed", (-50).RangeTo(50), 0) - .AddAxis($"P{PortNum} Strafing Speed", (-128).RangeTo(127), 0) + .AddAxis($"P{PortNum} Strafing Speed", (-50).RangeTo(50), 0) .AddAxis($"P{PortNum} Turning Speed", (-128).RangeTo(127), 0) .AddAxis($"P{PortNum} Weapon Select", (0).RangeTo(7), 0) .AddAxis($"P{PortNum} Mouse Running", (-128).RangeTo(127), 0)