dsda: split out common buttons from players and only send them once
This commit is contained in:
parent
5409d0964e
commit
590d6bdc01
Binary file not shown.
|
@ -26,6 +26,22 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
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.BoolButtons.AddRange([
|
||||
"Change Gamma",
|
||||
"Automap Toggle",
|
||||
"Automap +",
|
||||
"Automap -",
|
||||
"Automap Full/Zoom",
|
||||
"Automap Follow",
|
||||
"Automap Up",
|
||||
"Automap Down",
|
||||
"Automap Right",
|
||||
"Automap Left",
|
||||
"Automap Grid",
|
||||
"Automap Mark",
|
||||
"Automap Clear Marks"
|
||||
]);
|
||||
|
||||
Definition.MakeImmutable();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,10 +40,26 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
_controllerDeck.ReadButtons4,
|
||||
];
|
||||
|
||||
int commonButtons = 0;
|
||||
|
||||
int playersPresent = Convert.ToInt32(_syncSettings.Player1Present)
|
||||
| Convert.ToInt32(_syncSettings.Player2Present) << 1
|
||||
| Convert.ToInt32(_syncSettings.Player3Present) << 2
|
||||
| Convert.ToInt32(_syncSettings.Player4Present) << 3;
|
||||
|
||||
if (controller.IsPressed("Change Gamma")) commonButtons |= (1 << 0);
|
||||
if (controller.IsPressed("Automap Toggle")) commonButtons |= (1 << 1);
|
||||
if (controller.IsPressed("Automap +")) commonButtons |= (1 << 2);
|
||||
if (controller.IsPressed("Automap -")) commonButtons |= (1 << 3);
|
||||
if (controller.IsPressed("Automap Full/Zoom")) commonButtons |= (1 << 4);
|
||||
if (controller.IsPressed("Automap Follow")) commonButtons |= (1 << 5);
|
||||
if (controller.IsPressed("Automap Up")) commonButtons |= (1 << 6);
|
||||
if (controller.IsPressed("Automap Down")) commonButtons |= (1 << 7);
|
||||
if (controller.IsPressed("Automap Right")) commonButtons |= (1 << 8);
|
||||
if (controller.IsPressed("Automap Left")) commonButtons |= (1 << 9);
|
||||
if (controller.IsPressed("Automap Grid")) commonButtons |= (1 << 10);
|
||||
if (controller.IsPressed("Automap Mark")) commonButtons |= (1 << 11);
|
||||
if (controller.IsPressed("Automap Clear Marks")) commonButtons |= (1 << 12);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
|
@ -139,6 +155,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
renderInfo.PlayerPointOfView = _settings.DisplayPlayer - 1;
|
||||
|
||||
IsLagFrame = _core.dsda_frame_advance(
|
||||
commonButtons,
|
||||
ref players[0],
|
||||
ref players[1],
|
||||
ref players[2],
|
||||
|
|
|
@ -72,7 +72,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
"Strafe Right",
|
||||
"Run",
|
||||
"Strafe",
|
||||
"Change Gamma",
|
||||
"Weapon Select 1",
|
||||
"Weapon Select 2",
|
||||
"Weapon Select 3",
|
||||
|
@ -80,39 +79,14 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
"Weapon Select 5",
|
||||
"Weapon Select 6",
|
||||
"Weapon Select 7",
|
||||
"Automap Toggle",
|
||||
"Automap +",
|
||||
"Automap -",
|
||||
"Automap Full/Zoom",
|
||||
"Automap Follow",
|
||||
"Automap Up",
|
||||
"Automap Down",
|
||||
"Automap Right",
|
||||
"Automap Left",
|
||||
"Automap Grid",
|
||||
"Automap Mark",
|
||||
"Automap Clear Marks",
|
||||
];
|
||||
|
||||
public int ReadButtons(IController c)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (c.IsPressed($"P{PortNum} Fire")) result |= (1 << 0);
|
||||
if (c.IsPressed($"P{PortNum} Use")) result |= (1 << 1);
|
||||
if (c.IsPressed($"P{PortNum} Change Gamma")) result |= (1 << 2);
|
||||
if (c.IsPressed($"P{PortNum} Automap Toggle")) result |= (1 << 3);
|
||||
if (c.IsPressed($"P{PortNum} Automap +")) result |= (1 << 4);
|
||||
if (c.IsPressed($"P{PortNum} Automap -")) result |= (1 << 5);
|
||||
if (c.IsPressed($"P{PortNum} Automap Full/Zoom")) result |= (1 << 6);
|
||||
if (c.IsPressed($"P{PortNum} Automap Follow")) result |= (1 << 7);
|
||||
if (c.IsPressed($"P{PortNum} Automap Up")) result |= (1 << 8);
|
||||
if (c.IsPressed($"P{PortNum} Automap Down")) result |= (1 << 9);
|
||||
if (c.IsPressed($"P{PortNum} Automap Right")) result |= (1 << 10);
|
||||
if (c.IsPressed($"P{PortNum} Automap Left")) result |= (1 << 11);
|
||||
if (c.IsPressed($"P{PortNum} Automap Grid")) result |= (1 << 12);
|
||||
if (c.IsPressed($"P{PortNum} Automap Mark")) result |= (1 << 13);
|
||||
if (c.IsPressed($"P{PortNum} Automap Clear Marks")) result |= (1 << 14);
|
||||
if (c.IsPressed($"P{PortNum} Fire")) result |= (1 << 0);
|
||||
if (c.IsPressed($"P{PortNum} Use")) result |= (1 << 1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract bool dsda_frame_advance(
|
||||
int commonInputs,
|
||||
ref PackedPlayerInput player1Inputs,
|
||||
ref PackedPlayerInput player2Inputs,
|
||||
ref PackedPlayerInput player3Inputs,
|
||||
|
|
|
@ -2,13 +2,25 @@
|
|||
|
||||
bool foundIWAD = false;
|
||||
bool wipeDone = true;
|
||||
AllButtons last_buttons[4] = { 0 };
|
||||
CommonButtons last_buttons = { 0 };
|
||||
|
||||
void handle_automap_input(AllButtons buttons, int playerId)
|
||||
void common_input(CommonButtons buttons)
|
||||
{
|
||||
static int bigstate = 0;
|
||||
m_paninc.y = 0;
|
||||
m_paninc.x = 0;
|
||||
|
||||
if (buttons.AutomapToggle && !last_buttons[playerId].AutomapToggle)
|
||||
if (buttons.ChangeGamma && !last_buttons.ChangeGamma)
|
||||
{
|
||||
dsda_CycleConfig(dsda_config_usegamma, true);
|
||||
dsda_AddMessage(usegamma == 0 ? GAMMALVL0 :
|
||||
usegamma == 1 ? GAMMALVL1 :
|
||||
usegamma == 2 ? GAMMALVL2 :
|
||||
usegamma == 3 ? GAMMALVL3 :
|
||||
GAMMALVL4);
|
||||
}
|
||||
|
||||
if (buttons.AutomapToggle && !last_buttons.AutomapToggle)
|
||||
{
|
||||
if (automap_active)
|
||||
{
|
||||
|
@ -19,19 +31,19 @@ void handle_automap_input(AllButtons buttons, int playerId)
|
|||
AM_Start(true);
|
||||
}
|
||||
|
||||
if (buttons.AutomapFollow && !last_buttons[playerId].AutomapFollow)
|
||||
if (buttons.AutomapFollow && !last_buttons.AutomapFollow)
|
||||
{
|
||||
dsda_ToggleConfig(dsda_config_automap_follow, true);
|
||||
dsda_AddMessage(automap_follow ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF);
|
||||
}
|
||||
|
||||
if (buttons.AutomapGrid && !last_buttons[playerId].AutomapGrid)
|
||||
if (buttons.AutomapGrid && !last_buttons.AutomapGrid)
|
||||
{
|
||||
dsda_ToggleConfig(dsda_config_automap_grid, true);
|
||||
dsda_AddMessage(automap_grid ? AMSTR_GRIDON : AMSTR_GRIDOFF);
|
||||
}
|
||||
|
||||
if (buttons.AutomapMark && !last_buttons[playerId].AutomapMark)
|
||||
if (buttons.AutomapMark && !last_buttons.AutomapMark)
|
||||
{
|
||||
if (!raven)
|
||||
{
|
||||
|
@ -40,13 +52,13 @@ void handle_automap_input(AllButtons buttons, int playerId)
|
|||
}
|
||||
}
|
||||
|
||||
if (buttons.AutomapClearMarks && !last_buttons[playerId].AutomapClearMarks)
|
||||
if (buttons.AutomapClearMarks && !last_buttons.AutomapClearMarks)
|
||||
{
|
||||
AM_clearMarks();
|
||||
dsda_AddMessage(AMSTR_MARKSCLEARED);
|
||||
}
|
||||
|
||||
if (buttons.AutomapFullZoom && !last_buttons[playerId].AutomapFullZoom)
|
||||
if (buttons.AutomapFullZoom && !last_buttons.AutomapFullZoom)
|
||||
{
|
||||
bigstate = !bigstate;
|
||||
if (bigstate)
|
||||
|
@ -86,9 +98,11 @@ void handle_automap_input(AllButtons buttons, int playerId)
|
|||
if (buttons.AutomapRight) m_paninc.x += FTOM(map_pan_speed);
|
||||
if (buttons.AutomapLeft) m_paninc.x -= FTOM(map_pan_speed);
|
||||
}
|
||||
|
||||
last_buttons = buttons;
|
||||
}
|
||||
|
||||
void send_input(struct PackedPlayerInput *inputs, int playerId)
|
||||
void player_input(struct PackedPlayerInput *inputs, int playerId)
|
||||
{
|
||||
local_cmds[playerId].forwardmove = inputs->RunSpeed;
|
||||
local_cmds[playerId].sidemove = inputs->StrafingSpeed;
|
||||
|
@ -106,19 +120,6 @@ void send_input(struct PackedPlayerInput *inputs, int playerId)
|
|||
local_cmds[playerId].buttons |= BT_CHANGE;
|
||||
local_cmds[playerId].buttons |= (inputs->WeaponSelect - 1) << BT_WEAPONSHIFT;
|
||||
}
|
||||
|
||||
if (inputs->Buttons.ChangeGamma && !last_buttons[playerId].ChangeGamma)
|
||||
{
|
||||
dsda_CycleConfig(dsda_config_usegamma, true);
|
||||
dsda_AddMessage(usegamma == 0 ? GAMMALVL0 :
|
||||
usegamma == 1 ? GAMMALVL1 :
|
||||
usegamma == 2 ? GAMMALVL2 :
|
||||
usegamma == 3 ? GAMMALVL3 :
|
||||
GAMMALVL4);
|
||||
}
|
||||
|
||||
handle_automap_input(inputs->Buttons, playerId);
|
||||
last_buttons[playerId] = inputs->Buttons;
|
||||
}
|
||||
|
||||
ECL_EXPORT void dsda_get_audio(int *n, void **buffer)
|
||||
|
@ -156,19 +157,17 @@ ECL_EXPORT void dsda_get_video(int *w, int *h, int *pitch, uint8_t **buffer, int
|
|||
*paletteBuffer = _convertedPaletteBuffer;
|
||||
}
|
||||
|
||||
ECL_EXPORT bool dsda_frame_advance(struct PackedPlayerInput *player1Inputs, struct PackedPlayerInput *player2Inputs, struct PackedPlayerInput *player3Inputs, struct PackedPlayerInput *player4Inputs, struct PackedRenderInfo *renderInfo)
|
||||
ECL_EXPORT bool dsda_frame_advance(CommonButtons commonButtons, struct PackedPlayerInput *player1Inputs, struct PackedPlayerInput *player2Inputs, struct PackedPlayerInput *player3Inputs, struct PackedPlayerInput *player4Inputs, struct PackedRenderInfo *renderInfo)
|
||||
{
|
||||
// Setting inputs
|
||||
headlessClearTickCommand();
|
||||
|
||||
m_paninc.y = 0;
|
||||
m_paninc.x = 0;
|
||||
common_input(commonButtons);
|
||||
|
||||
// Setting Players inputs
|
||||
send_input(player1Inputs, 0);
|
||||
send_input(player2Inputs, 1);
|
||||
send_input(player3Inputs, 2);
|
||||
send_input(player4Inputs, 3);
|
||||
player_input(player1Inputs, 0);
|
||||
player_input(player2Inputs, 1);
|
||||
player_input(player3Inputs, 2);
|
||||
player_input(player4Inputs, 3);
|
||||
|
||||
// Enabling/Disabling rendering, as required
|
||||
if ( renderInfo->RenderVideo) headlessEnableVideoRendering();
|
||||
|
|
|
@ -96,6 +96,14 @@ typedef union
|
|||
{
|
||||
bool Fire:1;
|
||||
bool Use:1;
|
||||
};
|
||||
uint8_t data;
|
||||
} PlayerButtons;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
bool ChangeGamma:1;
|
||||
bool AutomapToggle:1;
|
||||
bool AutomapZoomIn:1;
|
||||
|
@ -111,7 +119,7 @@ typedef union
|
|||
bool AutomapClearMarks:1;
|
||||
};
|
||||
uint32_t data;
|
||||
} AllButtons;
|
||||
} CommonButtons;
|
||||
|
||||
struct InitSettings
|
||||
{
|
||||
|
@ -133,7 +141,7 @@ struct PackedPlayerInput
|
|||
int StrafingSpeed;
|
||||
int TurningSpeed;
|
||||
int WeaponSelect;
|
||||
AllButtons Buttons;
|
||||
PlayerButtons Buttons;
|
||||
int FlyLook;
|
||||
int ArtifactUse;
|
||||
int Jump;
|
||||
|
|
Loading…
Reference in New Issue