Commit b7c8f56b authored by Richard Gobeille's avatar Richard Gobeille
Browse files

Duke3d: preprocessor definitions for extbits, bump extbits up to uint32_t

parent 248c7be6
......@@ -4022,18 +4022,19 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura
if (tilehasmodelorvoxel(t->picnum, t->pal))
{
static int32_t targetang = 0;
uint32_t const extBits = g_player[playerNum].input.extbits;
if (g_player[playerNum].input.extbits&(1<<1))
if (extBits&BIT(EXT_BACK))
{
if (g_player[playerNum].input.extbits&(1<<2))targetang += 16;
else if (g_player[playerNum].input.extbits&(1<<3)) targetang -= 16;
if (extBits&BIT(EXT_STRAFELEFT)) targetang += 16;
else if (extBits&BIT(EXT_STRAFERIGHT)) targetang -= 16;
else if (targetang > 0) targetang -= targetang>>2;
else if (targetang < 0) targetang += (-targetang)>>2;
}
else
{
if (g_player[playerNum].input.extbits&(1<<2))targetang -= 16;
else if (g_player[playerNum].input.extbits&(1<<3)) targetang += 16;
if (extBits&BIT(EXT_STRAFELEFT)) targetang -= 16;
else if (extBits&BIT(EXT_STRAFERIGHT)) targetang += 16;
else if (targetang > 0) targetang -= targetang>>2;
else if (targetang < 0) targetang += (-targetang)>>2;
}
......@@ -4065,7 +4066,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura
spritesortcnt++;
}
if (g_player[playerNum].input.extbits & (1 << 7) && !ud.pause_on && spritesortcnt < maxspritesonscreen)
if (g_player[playerNum].input.extbits & (1 << EXT_TYPING) && !ud.pause_on && spritesortcnt < maxspritesonscreen)
{
auto const playerTyping = &tsprite[spritesortcnt];
......
......@@ -99,6 +99,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define SK_INVENTORY 30
#define SK_ESCAPE 31
#define EXT_FWD 0
#define EXT_BACK 1
#define EXT_STRAFELEFT 2
#define EXT_STRAFERIGHT 3
#define EXT_TURNLEFT 4
#define EXT_TURNRIGHT 5
#define EXT_ALTFIRE 6
#define EXT_TYPING 7
#define EXT_CENTERING 8
// rotatesprite flags
#define ROTATE_SPRITE_TRANSLUCENT (BIT(0))
#define ROTATE_SPRITE_VIEW_CLIP (BIT(1)) // clip to view
......
......@@ -3135,7 +3135,7 @@ void P_GetInput(int const playerNum)
thisPlayer.lastViewUpdate = 0;
localInput = {};
localInput.bits = (((int32_t)g_gameQuit) << SK_GAMEQUIT);
localInput.extbits |= (1<<7);
localInput.extbits |= (1<<EXT_TYPING);
return;
}
......@@ -3376,13 +3376,14 @@ void P_GetInput(int const playerNum)
if (PWEAPON(playerNum, pPlayer->curr_weapon, Flags) & WEAPON_SEMIAUTO && BUTTON(gamefunc_Fire))
CONTROL_ClearButton(gamefunc_Fire);
localInput.extbits |= (BUTTON(gamefunc_Move_Forward) || (input.fvel > 0));
localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
localInput.extbits |= BUTTON(gamefunc_Turn_Left)<<4;
localInput.extbits |= BUTTON(gamefunc_Turn_Right)<<5;
localInput.extbits |= BUTTON(gamefunc_Alt_Fire)<<6;
localInput.extbits |= (BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)) << EXT_FWD;
localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << EXT_BACK;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << EXT_STRAFELEFT;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << EXT_STRAFERIGHT;
localInput.extbits |= BUTTON(gamefunc_Turn_Left)<<EXT_TURNLEFT;
localInput.extbits |= BUTTON(gamefunc_Turn_Right)<<EXT_TURNRIGHT;
localInput.extbits |= BUTTON(gamefunc_Alt_Fire)<<EXT_ALTFIRE;
localInput.extbits |= (CONTROL_LastSeenInput == LastSeenInput::Joystick && ud.config.JoystickViewCentering)<<EXT_CENTERING;
int const movementLocked = P_CheckLockedMovement(playerNum);
......@@ -4226,7 +4227,7 @@ static void P_ProcessWeapon(int playerNum)
}
bool const doFire = (playerBits & BIT(SK_FIRE) && (*weaponFrame) == 0);
bool const doAltFire = g_player[playerNum].input.extbits & (1 << 6);
bool const doAltFire = g_player[playerNum].input.extbits & BIT(EXT_ALTFIRE);
if (doAltFire)
{
......@@ -5517,15 +5518,15 @@ void P_ProcessInput(int playerNum)
}
}
if (pInput.extbits & (1)) VM_OnEvent(EVENT_MOVEFORWARD, pPlayer->i, playerNum);
if (pInput.extbits & (1 << 1)) VM_OnEvent(EVENT_MOVEBACKWARD, pPlayer->i, playerNum);
if (pInput.extbits & (1 << 2)) VM_OnEvent(EVENT_STRAFELEFT, pPlayer->i, playerNum);
if (pInput.extbits & (1 << 3)) VM_OnEvent(EVENT_STRAFERIGHT, pPlayer->i, playerNum);
if (pInput.extbits & BIT(EXT_FWD)) VM_OnEvent(EVENT_MOVEFORWARD, pPlayer->i, playerNum);
if (pInput.extbits & BIT(EXT_BACK)) VM_OnEvent(EVENT_MOVEBACKWARD, pPlayer->i, playerNum);
if (pInput.extbits & BIT(EXT_STRAFELEFT)) VM_OnEvent(EVENT_STRAFELEFT, pPlayer->i, playerNum);
if (pInput.extbits & BIT(EXT_STRAFERIGHT)) VM_OnEvent(EVENT_STRAFERIGHT, pPlayer->i, playerNum);
if (pInput.extbits & (1 << 4) || pInput.q16avel < 0)
if (pInput.extbits & BIT(EXT_TURNLEFT) || pInput.q16avel < 0)
VM_OnEvent(EVENT_TURNLEFT, pPlayer->i, playerNum);
if (pInput.extbits & (1 << 5) || pInput.q16avel > 0)
if (pInput.extbits & BIT(EXT_TURNRIGHT) || pInput.q16avel > 0)
VM_OnEvent(EVENT_TURNRIGHT, pPlayer->i, playerNum);
if (pPlayer->vel.x || pPlayer->vel.y || pInput.fvel || pInput.svel)
......
......@@ -167,14 +167,14 @@ typedef struct {
char inven_icon, jetpack_on, heat_on;
} DukeStatus_t;
#pragma pack(push,1)
typedef struct {
uint32_t bits;
int16_t fvel, svel;
fix16_t q16avel, q16horz;
uint8_t extbits;
uint32_t extbits;
} input_t;
#pragma pack(push,1)
// XXX: r1625 changed a lot types here, among others
// * int32_t --> int16_t
// * int16_t --> int8_t
......
......@@ -2594,7 +2594,8 @@ void P_HandleSharedKeys(int playerNum)
if (pPlayer->cheat_phase == 1) return;
uint32_t playerBits = g_player[playerNum].input.bits, weaponNum;
uint32_t playerBits = g_player[playerNum].input.bits;
uint32_t const extBits = g_player[playerNum].input.extbits;
// 1<<0 = jump
// 1<<1 = crouch
......@@ -2629,6 +2630,8 @@ void P_HandleSharedKeys(int playerNum)
int const aimMode = pPlayer->aim_mode;
pPlayer->aim_mode = (playerBits>>SK_AIMMODE)&1;
pPlayer->aim_mode |= ((extBits>>EXT_CENTERING)&1)<<1;
if (pPlayer->aim_mode < aimMode)
pPlayer->return_to_center = 9;
......@@ -2643,7 +2646,7 @@ void P_HandleSharedKeys(int playerNum)
}
}
weaponNum = playerBits & ((15u<<SK_WEAPON_BITS)|BIT(SK_STEROIDS)|BIT(SK_NIGHTVISION)|BIT(SK_MEDKIT)|BIT(SK_QUICK_KICK)| \
uint32_t weaponNum = playerBits & ((15u<<SK_WEAPON_BITS)|BIT(SK_STEROIDS)|BIT(SK_NIGHTVISION)|BIT(SK_MEDKIT)|BIT(SK_QUICK_KICK)| \
BIT(SK_HOLSTER)|BIT(SK_INV_LEFT)|BIT(SK_PAUSE)|BIT(SK_HOLODUKE)|BIT(SK_JETPACK)|BIT(SK_INV_RIGHT)| \
BIT(SK_TURNAROUND)|BIT(SK_OPEN)|BIT(SK_INVENTORY)|BIT(SK_ESCAPE));
playerBits = weaponNum & ~pPlayer->interface_toggle;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment