Skip to content

Commit ebbdc1a

Browse files
committed
dsda: send inputs by struct pointer
greatly simplifies adding more inputs (like automap control)
1 parent 6b012ef commit ebbdc1a

File tree

4 files changed

+43
-68
lines changed

4 files changed

+43
-68
lines changed

Assets/dll/dsda.wbx.zst

-85 Bytes
Binary file not shown.

waterbox/dsda/BizhawkInterface.c

Lines changed: 39 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,40 @@
22

33
bool foundIWAD = false;
44
bool wipeDone = true;
5+
int last_automap_input[4] = { 0 };
6+
7+
void send_input(struct PackedPlayerInput *inputs, int playerId)
8+
{
9+
local_cmds[playerId].forwardmove = inputs->RunSpeed;
10+
local_cmds[playerId].sidemove = inputs->StrafingSpeed;
11+
local_cmds[playerId].angleturn = (shorttics || !longtics) ? inputs->TurningSpeed << 8 : inputs->TurningSpeed;
12+
13+
if (inputs->Fire == 1) local_cmds[playerId].buttons |= 0b00000001;
14+
if (inputs->Action == 1) local_cmds[playerId].buttons |= 0b00000010;
15+
16+
if (inputs->WeaponSelect != 0)
17+
{
18+
local_cmds[playerId].buttons |= BT_CHANGE;
19+
local_cmds[playerId].buttons |= (inputs->WeaponSelect - 1)<<BT_WEAPONSHIFT;
20+
}
21+
22+
local_cmds[playerId].lookfly = inputs->FlyLook;
23+
local_cmds[playerId].arti = inputs->ArtifactUse;
24+
25+
if (inputs->EndPlayer == 1) local_cmds[playerId].arti |= 0b01000000;
26+
if (inputs->Jump == 1) local_cmds[playerId].arti |= 0b10000000;
27+
28+
if (inputs->Automap && !last_automap_input[playerId])
29+
{
30+
if (automap_input)
31+
AM_Stop(true);
32+
else
33+
AM_Start(true);
34+
}
35+
last_automap_input[playerId] = inputs->Automap;
36+
37+
// printf("ForwardSpeed: %d - sideMove: %d - angleTurn: %d - buttons: %u\n", forwardSpeed, strafingSpeed, turningSpeed, local_cmds[playerId].buttons);
38+
}
539

640
ECL_EXPORT void dsda_get_audio(int *n, void **buffer)
741
{
@@ -43,73 +77,11 @@ ECL_EXPORT bool dsda_frame_advance(struct PackedPlayerInput *player1Inputs, stru
4377
// Setting inputs
4478
headlessClearTickCommand();
4579

46-
// Setting Player 1 inputs
47-
headlessSetTickCommand
48-
(
49-
0,
50-
player1Inputs->RunSpeed,
51-
player1Inputs->StrafingSpeed,
52-
player1Inputs->TurningSpeed,
53-
player1Inputs->Fire,
54-
player1Inputs->Action,
55-
player1Inputs->WeaponSelect,
56-
player1Inputs->Automap,
57-
player1Inputs->FlyLook,
58-
player1Inputs->ArtifactUse,
59-
player1Inputs->Jump,
60-
player1Inputs->EndPlayer
61-
);
62-
63-
// Setting Player 2 inputs
64-
headlessSetTickCommand
65-
(
66-
1,
67-
player2Inputs->RunSpeed,
68-
player2Inputs->StrafingSpeed,
69-
player2Inputs->TurningSpeed,
70-
player2Inputs->Fire,
71-
player2Inputs->Action,
72-
player2Inputs->WeaponSelect,
73-
player2Inputs->Automap,
74-
player2Inputs->FlyLook,
75-
player2Inputs->ArtifactUse,
76-
player2Inputs->Jump,
77-
player2Inputs->EndPlayer
78-
);
79-
80-
// Setting Player 3 inputs
81-
headlessSetTickCommand
82-
(
83-
2,
84-
player3Inputs->RunSpeed,
85-
player3Inputs->StrafingSpeed,
86-
player3Inputs->TurningSpeed,
87-
player3Inputs->Fire,
88-
player3Inputs->Action,
89-
player3Inputs->WeaponSelect,
90-
player3Inputs->Automap,
91-
player3Inputs->FlyLook,
92-
player3Inputs->ArtifactUse,
93-
player3Inputs->Jump,
94-
player3Inputs->EndPlayer
95-
);
96-
97-
// Setting Player 4 inputs
98-
headlessSetTickCommand
99-
(
100-
3,
101-
player4Inputs->RunSpeed,
102-
player4Inputs->StrafingSpeed,
103-
player4Inputs->TurningSpeed,
104-
player4Inputs->Fire,
105-
player4Inputs->Action,
106-
player4Inputs->WeaponSelect,
107-
player4Inputs->Automap,
108-
player4Inputs->FlyLook,
109-
player4Inputs->ArtifactUse,
110-
player4Inputs->Jump,
111-
player4Inputs->EndPlayer
112-
);
80+
// Setting Players inputs
81+
send_input(player1Inputs, 0);
82+
send_input(player2Inputs, 1);
83+
send_input(player3Inputs, 2);
84+
send_input(player4Inputs, 3);
11385

11486
// Enabling/Disabling rendering, as required
11587
if (!renderInfo->RenderVideo) headlessDisableVideoRendering();

waterbox/dsda/BizhawkInterface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#define __BIZHAWK_INTERFACE__
33

44
#include "emulibc.h"
5+
6+
#include "am_map.h"
57
#include "d_main.h"
68
#include "d_player.h"
79
#include "doomstat.h"
@@ -10,6 +12,7 @@
1012
#include "i_sound.h"
1113
#include "i_video.h"
1214
#include "p_mobj.h"
15+
1316
#include "dsda/args.h"
1417
#include "dsda/settings.h"
1518

waterbox/dsda/core

0 commit comments

Comments
 (0)