- fixed Ramsed head display and not freezing the input when it is active.

This commit is contained in:
Christoph Oelckers 2020-08-26 21:28:57 +02:00
parent 096a2bd4e9
commit 83c8770d02
2 changed files with 84 additions and 76 deletions

View file

@ -160,7 +160,8 @@ void PlayerInterruptKeys()
return; return;
localInput = {}; localInput = {};
PlayerInput input {}; InputPacket input {};
fix16_t input_angle = 0;
if (PlayerList[nLocalPlayer].nHealth == 0) if (PlayerList[nLocalPlayer].nHealth == 0)
{ {
@ -177,35 +178,35 @@ void PlayerInterruptKeys()
if (buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
input.xVel -= info.mousex * 4.f; input.svel -= info.mousex * 4.f;
input.xVel -= info.dyaw * keyMove; input.svel -= info.dyaw * keyMove;
} }
else else
{ {
input.nAngle = fix16_sadd(input.nAngle, fix16_from_float(info.mousex)); input_angle = fix16_sadd(input_angle, fix16_from_float(info.mousex));
input.nAngle = fix16_sadd(input.nAngle, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); input_angle = fix16_sadd(input_angle, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
} }
g_MyAimMode = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming); g_MyAimMode = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
if (g_MyAimMode) if (g_MyAimMode)
input.horizon = fix16_sadd(input.horizon, fix16_from_float(info.mousey)); input.q16horz = fix16_sadd(input.q16horz, fix16_from_float(info.mousey));
else else
input.yVel -= info.mousey * 8.f; input.fvel -= info.mousey * 8.f;
if (!in_mouseflip) input.horizon = -input.horizon; if (!in_mouseflip) input.q16horz = -input.q16horz;
input.horizon = fix16_ssub(input.horizon, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch))); input.q16horz = fix16_ssub(input.q16horz, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch)));
input.xVel -= info.dx * keyMove; input.svel -= info.dx * keyMove;
input.yVel -= info.dz * keyMove; input.fvel -= info.dz * keyMove;
if (buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
if (buttonMap.ButtonDown(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
input.xVel -= -keyMove; input.svel -= -keyMove;
if (buttonMap.ButtonDown(gamefunc_Turn_Right)) if (buttonMap.ButtonDown(gamefunc_Turn_Right))
input.xVel -= keyMove; input.svel -= keyMove;
} }
else else
{ {
@ -242,32 +243,35 @@ void PlayerInterruptKeys()
} }
//if ((counter++) % 4 == 0) // what was this for??? //if ((counter++) % 4 == 0) // what was this for???
input.nAngle = fix16_sadd(input.nAngle, fix16_from_dbl(scaleAdjustmentToInterval(turn * 2))); input_angle = fix16_sadd(input_angle, fix16_from_dbl(scaleAdjustmentToInterval(turn * 2)));
} }
if (buttonMap.ButtonDown(gamefunc_Strafe_Left)) if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
input.xVel += keyMove; input.svel += keyMove;
if (buttonMap.ButtonDown(gamefunc_Strafe_Right)) if (buttonMap.ButtonDown(gamefunc_Strafe_Right))
input.xVel += -keyMove; input.svel += -keyMove;
if (buttonMap.ButtonDown(gamefunc_Move_Forward)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
input.yVel += keyMove; input.fvel += keyMove;
if (buttonMap.ButtonDown(gamefunc_Move_Backward)) if (buttonMap.ButtonDown(gamefunc_Move_Backward))
input.yVel += -keyMove; input.fvel += -keyMove;
localInput.fvel = clamp(localInput.fvel + input.yVel, -12, 12); localInput.fvel = clamp(localInput.fvel + input.fvel, -12, 12);
localInput.svel = clamp(localInput.svel + input.xVel, -12, 12); localInput.svel = clamp(localInput.svel + input.svel, -12, 12);
localInput.q16avel = fix16_sadd(localInput.q16avel, input.nAngle); localInput.q16avel = fix16_sadd(localInput.q16avel, input_angle);
PlayerList[nLocalPlayer].q16angle = fix16_sadd(PlayerList[nLocalPlayer].q16angle, input.nAngle) & 0x7FFFFFF;
if (!nFreeze)
{
PlayerList[nLocalPlayer].q16angle = fix16_sadd(PlayerList[nLocalPlayer].q16angle, input_angle) & 0x7FFFFFF;
// A horiz diff of 128 equal 45 degrees, // A horiz diff of 128 equal 45 degrees,
// so we convert horiz to 1024 angle units // so we convert horiz to 1024 angle units
float const horizAngle = clamp(atan2f(PlayerList[nLocalPlayer].q16horiz - fix16_from_int(92), fix16_from_int(128)) * (512.f / fPI) + fix16_to_float(input.horizon), -255.f, 255.f); float const horizAngle = clamp(atan2f(PlayerList[nLocalPlayer].q16horiz - fix16_from_int(92), fix16_from_int(128)) * (512.f / fPI) + fix16_to_float(input.q16horz), -255.f, 255.f);
PlayerList[nLocalPlayer].q16horiz = fix16_from_int(92) + Blrintf(fix16_from_int(128) * tanf(horizAngle * (fPI / 512.f))); PlayerList[nLocalPlayer].q16horiz = fix16_from_int(92) + Blrintf(fix16_from_int(128) * tanf(horizAngle * (fPI / 512.f)));
// Look/aim up/down functions. // Look/aim up/down functions.
@ -291,6 +295,7 @@ void PlayerInterruptKeys()
bPlayerPan = true; bPlayerPan = true;
nDestVertPan[nLocalPlayer] = PlayerList[nLocalPlayer].q16horiz; nDestVertPan[nLocalPlayer] = PlayerList[nLocalPlayer].q16horiz;
} }
}
// loc_1C048: // loc_1C048:
if (totalvel[nLocalPlayer] > 20) { if (totalvel[nLocalPlayer] > 20) {
@ -308,6 +313,8 @@ void PlayerInterruptKeys()
ecx = 0; ecx = 0;
} }
if (!nFreeze)
{
if (ecx) if (ecx)
{ {
if (ecx / 4 == 0) if (ecx / 4 == 0)
@ -338,6 +345,7 @@ void PlayerInterruptKeys()
} }
PlayerList[nLocalPlayer].q16horiz = fix16_clamp(PlayerList[nLocalPlayer].q16horiz, fix16_from_int(0), fix16_from_int(184)); PlayerList[nLocalPlayer].q16horiz = fix16_clamp(PlayerList[nLocalPlayer].q16horiz, fix16_from_int(0), fix16_from_int(184));
}
} }
void RestoreSavePoint(int nPlayer, int *x, int *y, int *z, short *nSector, short *nAngle) void RestoreSavePoint(int nPlayer, int *x, int *y, int *z, short *nSector, short *nAngle)

View file

@ -37,15 +37,15 @@ int lNextStateChange;
int nPixels; int nPixels;
int nHeadTimeStart; int nHeadTimeStart;
short nHeadStage; short nHeadStage;
short curx[97 * 106]; short curx[kSpiritY * kSpiritX];
short cury[97 * 106]; short cury[kSpiritY * kSpiritX];
int8_t destvelx[97 * 106]; int8_t destvelx[kSpiritY * kSpiritX];
int8_t destvely[97 * 106]; int8_t destvely[kSpiritY * kSpiritX];
uint8_t pixelval[97 * 106]; uint8_t pixelval[kSpiritY * kSpiritX];
int8_t origy[97 * 106]; int8_t origy[kSpiritY * kSpiritX];
int8_t origx[97 * 106]; int8_t origx[kSpiritY * kSpiritX];
int8_t velx[97 * 106]; int8_t velx[kSpiritY * kSpiritX];
int8_t vely[97 * 106]; int8_t vely[kSpiritY * kSpiritX];
short nMouthTile; short nMouthTile;
short nPupData = 0; short nPupData = 0;
@ -88,7 +88,7 @@ void InitSpiritHead()
{ {
if (*pTile != TRANSPARENT_INDEX) if (*pTile != TRANSPARENT_INDEX)
{ {
pixelval[nPixels] = *(pGold + x * 106 + y); pixelval[nPixels] = *(pGold + x * kSpiritX + y);
origx[nPixels] = x - 48; origx[nPixels] = x - 48;
origy[nPixels] = y - 53; origy[nPixels] = y - 53;
curx[nPixels] = 0; curx[nPixels] = 0;
@ -123,7 +123,7 @@ void InitSpiritHead()
nHeadStage = 0; nHeadStage = 0;
// work tile is twice as big as the normal head size // work tile is twice as big as the normal head size
Worktile = TileFiles.tileCreate(kTileRamsesWorkTile, kSpiritX * 2, kSpiritY * 2); Worktile = TileFiles.tileCreate(kTileRamsesWorkTile, kSpiritY * 2, kSpiritX * 2);
sprite[nSpiritSprite].cstat &= 0x7FFF; sprite[nSpiritSprite].cstat &= 0x7FFF;