dsda: fix button turning for shorttics
move shorttics cals to frontend to explicitly show all the logic that reproduces upstream input handling
This commit is contained in:
parent
fef3b526b6
commit
92df238d9e
Binary file not shown.
|
@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
{
|
||||
if ((playersPresent & (1 << i)) is not 0)
|
||||
{
|
||||
int speedIndex = Convert.ToInt32(controller.IsPressed($"P{i+1} Run")
|
||||
int speedIndex = Convert.ToInt32(controller.IsPressed($"P{i + 1} Run")
|
||||
|| _syncSettings.AlwaysRun);
|
||||
|
||||
int turnSpeed = 0;
|
||||
|
@ -83,12 +83,18 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
players[i].RunSpeed = players[i].RunSpeed.Clamp<int>(-_runSpeeds[1], _runSpeeds[1]);
|
||||
|
||||
// mouse-driven turning
|
||||
// divider recalibrates minimal mouse movement to be 1 (requires global setting)
|
||||
players[i].TurningSpeed -= (int)(axisReaders[i](controller, (int)AxisType.MouseTurning) * _syncSettings.MouseTurnSensitivity / 272.0);
|
||||
var mouseTurning = axisReaders[i](controller, (int)AxisType.MouseTurning) * _syncSettings.MouseTurnSensitivity;
|
||||
if (_syncSettings.TurningResolution == TurningResolution.Longtics)
|
||||
{
|
||||
// divider recalibrates minimal mouse movement to be 1 (requires global setting)
|
||||
mouseTurning = (int)(mouseTurning / 272.0);
|
||||
}
|
||||
players[i].TurningSpeed -= mouseTurning;
|
||||
|
||||
// for shorttics we expose to player and parse from movies only 1 byte, but the core internally works with 2 bytes
|
||||
if (_syncSettings.TurningResolution == TurningResolution.Shorttics)
|
||||
{
|
||||
// calc matches the core
|
||||
players[i].TurningSpeed = ((players[i].TurningSpeed << 8) + 128) >> 8;
|
||||
players[i].TurningSpeed = ((players[i].TurningSpeed + 128) >> 8) << 8;
|
||||
}
|
||||
|
||||
// bool buttons
|
||||
|
|
|
@ -41,9 +41,10 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
public DoomController(int portNum, bool longtics)
|
||||
{
|
||||
PortNum = portNum;
|
||||
_longtics = longtics;
|
||||
Definition = new ControllerDefinition("Doom Input Format")
|
||||
{
|
||||
BoolButtons = BaseDefinition
|
||||
BoolButtons = _baseDefinition
|
||||
.Select(b => $"P{PortNum} " + b)
|
||||
.ToList()
|
||||
}.AddAxis($"P{PortNum} Run Speed", (-50).RangeTo(50), 0)
|
||||
|
@ -59,7 +60,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
|
||||
public ControllerDefinition Definition { get; }
|
||||
|
||||
private static readonly string[] BaseDefinition =
|
||||
private bool _longtics;
|
||||
|
||||
private static readonly string[] _baseDefinition =
|
||||
[
|
||||
"Fire",
|
||||
"Use",
|
||||
|
@ -118,7 +121,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
PortNum = portNum;
|
||||
Definition = new ControllerDefinition("Heretic Input Format")
|
||||
{
|
||||
BoolButtons = BaseDefinition
|
||||
BoolButtons = _baseDefinition
|
||||
.Select(b => $"P{PortNum} " + b)
|
||||
.ToList()
|
||||
}.AddAxis($"P{PortNum} Run Speed", (-50).RangeTo(50), 0)
|
||||
|
@ -136,7 +139,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
|
||||
public ControllerDefinition Definition { get; }
|
||||
|
||||
private static readonly string[] BaseDefinition =
|
||||
private static readonly string[] _baseDefinition =
|
||||
[
|
||||
"Fire",
|
||||
"Use",
|
||||
|
@ -235,7 +238,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
PortNum = portNum;
|
||||
Definition = new ControllerDefinition("Hexen Input Format")
|
||||
{
|
||||
BoolButtons = BaseDefinition
|
||||
BoolButtons = _baseDefinition
|
||||
.Select(b => $"P{PortNum} " + b)
|
||||
.ToList()
|
||||
}.AddAxis($"P{PortNum} Run Speed", (-50).RangeTo(50), 0)
|
||||
|
@ -253,7 +256,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
|
||||
public ControllerDefinition Definition { get; }
|
||||
|
||||
private static readonly string[] BaseDefinition =
|
||||
private static readonly string[] _baseDefinition =
|
||||
[
|
||||
"Fire",
|
||||
"Use",
|
||||
|
|
|
@ -72,6 +72,17 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
[BizImport(CallingConvention.Cdecl, Compatibility = true)]
|
||||
public abstract bool dsda_init(ref InitSettings settings, int argc, string[] argv);
|
||||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract void dsda_get_video(out int w, out int h, out int pitch, ref IntPtr buffer, out int palSize, ref IntPtr palBuffer);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate int load_archive_cb(string filename, IntPtr buffer, int maxsize);
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract int dsda_add_wad_file(string fileName, int fileSize, load_archive_cb feload_archive_cb);
|
||||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract byte dsda_read_memory_array(MemoryArrayType type, uint addr);
|
||||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract bool dsda_frame_advance(
|
||||
ref PackedPlayerInput player1Inputs,
|
||||
|
@ -79,22 +90,5 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
ref PackedPlayerInput player3Inputs,
|
||||
ref PackedPlayerInput player4Inputs,
|
||||
ref PackedRenderInfo renderInfo);
|
||||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract void dsda_get_video(out int w, out int h, out int pitch, ref IntPtr buffer, out int palSize, ref IntPtr palBuffer);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate int load_archive_cb(string filename, IntPtr buffer, int maxsize);
|
||||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract int dsda_add_wad_file(
|
||||
string fileName,
|
||||
int fileSize,
|
||||
load_archive_cb feload_archive_cb);
|
||||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract byte dsda_read_memory_array(
|
||||
MemoryArrayType type,
|
||||
uint addr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,23 +8,21 @@ void send_input(struct PackedPlayerInput *inputs, int playerId)
|
|||
{
|
||||
local_cmds[playerId].forwardmove = inputs->RunSpeed;
|
||||
local_cmds[playerId].sidemove = inputs->StrafingSpeed;
|
||||
local_cmds[playerId].angleturn = (shorttics || !longtics) ? inputs->TurningSpeed << 8 : inputs->TurningSpeed;
|
||||
local_cmds[playerId].lookfly = inputs->FlyLook;
|
||||
local_cmds[playerId].arti = inputs->ArtifactUse;
|
||||
local_cmds[playerId].angleturn = inputs->TurningSpeed;
|
||||
|
||||
if (inputs->Fire) local_cmds[playerId].buttons |= 0b00000001;
|
||||
if (inputs->Action) local_cmds[playerId].buttons |= 0b00000010;
|
||||
if (inputs->EndPlayer) local_cmds[playerId].arti |= 0b01000000;
|
||||
if (inputs->Jump) local_cmds[playerId].arti |= 0b10000000;
|
||||
|
||||
if (inputs->Fire == 1) local_cmds[playerId].buttons |= 0b00000001;
|
||||
if (inputs->Action == 1) local_cmds[playerId].buttons |= 0b00000010;
|
||||
|
||||
if (inputs->WeaponSelect != 0)
|
||||
if (inputs->WeaponSelect)
|
||||
{
|
||||
local_cmds[playerId].buttons |= BT_CHANGE;
|
||||
local_cmds[playerId].buttons |= (inputs->WeaponSelect - 1)<<BT_WEAPONSHIFT;
|
||||
local_cmds[playerId].buttons |= (inputs->WeaponSelect - 1) << BT_WEAPONSHIFT;
|
||||
}
|
||||
|
||||
local_cmds[playerId].lookfly = inputs->FlyLook;
|
||||
local_cmds[playerId].arti = inputs->ArtifactUse;
|
||||
|
||||
if (inputs->EndPlayer == 1) local_cmds[playerId].arti |= 0b01000000;
|
||||
if (inputs->Jump == 1) local_cmds[playerId].arti |= 0b10000000;
|
||||
|
||||
if (inputs->Automap && !last_automap_input[playerId])
|
||||
{
|
||||
if (automap_input)
|
||||
|
@ -33,8 +31,6 @@ void send_input(struct PackedPlayerInput *inputs, int playerId)
|
|||
AM_Start(true);
|
||||
}
|
||||
last_automap_input[playerId] = inputs->Automap;
|
||||
|
||||
// printf("ForwardSpeed: %d - sideMove: %d - angleTurn: %d - buttons: %u\n", forwardSpeed, strafingSpeed, turningSpeed, local_cmds[playerId].buttons);
|
||||
}
|
||||
|
||||
ECL_EXPORT void dsda_get_audio(int *n, void **buffer)
|
||||
|
@ -84,10 +80,10 @@ ECL_EXPORT bool dsda_frame_advance(struct PackedPlayerInput *player1Inputs, stru
|
|||
send_input(player4Inputs, 3);
|
||||
|
||||
// Enabling/Disabling rendering, as required
|
||||
if ( renderInfo->RenderVideo) headlessEnableVideoRendering();
|
||||
if ( renderInfo->RenderAudio) headlessEnableAudioRendering();
|
||||
if (!renderInfo->RenderVideo) headlessDisableVideoRendering();
|
||||
if (renderInfo->RenderVideo) headlessEnableVideoRendering();
|
||||
if (!renderInfo->RenderAudio) headlessDisableAudioRendering();
|
||||
if (renderInfo->RenderAudio) headlessEnableAudioRendering();
|
||||
|
||||
if ((wipe_Pending() || !wipeDone) && dsda_RenderWipeScreen())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue