- Blood fixes for changes in timer and mouse input interface-

This commit is contained in:
Christoph Oelckers 2019-09-20 22:08:06 +02:00
parent 94cfcb4fbd
commit afe5128c70
7 changed files with 60 additions and 58 deletions

View file

@ -470,7 +470,7 @@ void PreloadCache(void)
sndTryPlaySpecialMusic(MUS_LOADING);
gSoundRes.PrecacheSounds();
PreloadTiles();
int clock = totalclock;
int clock = totalclock.Ticks();
int cnt = 0;
int percentDisplayed = -1;
@ -503,12 +503,12 @@ void PreloadCache(void)
if (totalclock - clock >= 1)
{
clock = totalclock;
clock = totalclock.Ticks();
percentDisplayed++;
}
}
clock = totalclock;
clock = totalclock.Ticks();
}
}
}

View file

@ -96,8 +96,8 @@ void CChoke::sub_84110(int x, int y)
gFrameClock = gGameClock;
at8->x = x;
at8->y = y;
int vd = totalclock-at10;
at10 = totalclock;
int vd = totalclock.Ticks()-at10;
at10 = totalclock.Ticks();
atc -= vd;
if (atc <= 0 || atc > at8->at10)
atc = at8->at10;
@ -121,7 +121,7 @@ void CChoke::sub_84110(int x, int y)
void CChoke::sub_84218()
{
atc = at8->at10;
at10 = totalclock;
at10 = totalclock.Ticks();
}
void sub_84230(PLAYER *pPlayer)

View file

@ -195,25 +195,26 @@ void ctrlGetInput(void)
CONTROL_GetInput(&info);
if (MouseDeadZone)
{
if (info.dpitch > 0)
info.dpitch = max(info.dpitch - MouseDeadZone, 0);
else if (info.dpitch < 0)
info.dpitch = min(info.dpitch + MouseDeadZone, 0);
if (MouseDeadZone)
{
if (info.mousey > 0)
info.mousey = max(info.mousey - MouseDeadZone, 0);
else if (info.mousey < 0)
info.mousey = min(info.mousey + MouseDeadZone, 0);
if (info.dyaw > 0)
info.dyaw = max(info.dyaw - MouseDeadZone, 0);
else if (info.dyaw < 0)
info.dyaw = min(info.dyaw + MouseDeadZone, 0);
}
if (info.mousex > 0)
info.mousex = max(info.mousex - MouseDeadZone, 0);
else if (info.mousex < 0)
info.mousex = min(info.mousex + MouseDeadZone, 0);
}
if (MouseBias)
{
if (klabs(info.dyaw) > klabs(info.dpitch))
info.dpitch = tabledivide32_noinline(info.dpitch, MouseBias);
else info.dyaw = tabledivide32_noinline(info.dyaw, MouseBias);
}
if (MouseBias)
{
if (klabs(info.mousex) > klabs(info.mousey))
info.mousey = tabledivide32_noinline(info.mousey, MouseBias);
else
info.mousex = tabledivide32_noinline(info.mousex, MouseBias);
}
if (gQuitRequest)
gInput.keyFlags.quit = 1;
@ -453,9 +454,9 @@ void ctrlGetInput(void)
turn <<= 1;
if (BUTTON(gamefunc_Strafe))
strafe = ClipRange(strafe - info.dyaw, -2048, 2048);
strafe = ClipRange(strafe - info.mousex, -2048, 2048);
else
turn = fix16_clamp(turn + fix16_div(fix16_from_int(info.dyaw), F16(32)), F16(-1024)>>2, F16(1024)>>2);
turn = fix16_clamp(turn + fix16_div(fix16_from_int(info.mousex), F16(32)), F16(-1024)>>2, F16(1024)>>2);
strafe = ClipRange(strafe-(info.dx<<5), -2048, 2048);
@ -465,7 +466,7 @@ void ctrlGetInput(void)
else
gInput.mlook = ClipRange(info.dz>>7, -127, 127);
#endif
gInput.q16mlook = fix16_clamp(fix16_div(fix16_from_int(info.dpitch), F16(256)), F16(-127)>>2, F16(127)>>2);
gInput.q16mlook = fix16_clamp(fix16_div(fix16_from_int(info.mousey*2), F16(256)), F16(-127)>>2, F16(127)>>2);
if (!gMouseAimingFlipped)
gInput.q16mlook = -gInput.q16mlook;
forward = ClipRange(forward - info.dz, -2048, 2048);

View file

@ -245,7 +245,7 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav)
UpdateDacs(0, true);
timerUpdate();
int32_t nStartTime = totalclock;
int32_t nStartTime = totalclock.Ticks();
ctrlClearAllInput();
@ -253,7 +253,7 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav)
do
{
G_HandleAsync();
if (scale(totalclock-nStartTime, nFrameRate, kTicRate) < nFrame)
if (scale(totalclock.Ticks() -nStartTime, nFrameRate, kTicRate) < nFrame)
continue;
if (ctrlCheckAllInput())

View file

@ -175,7 +175,7 @@ void CGameMenuMgr::Draw(void)
if (MOUSEACTIVECONDITIONAL(mouseAdvanceClickState()) || m_mousepos.x != m_prevmousepos.x || m_mousepos.y != m_prevmousepos.y)
{
m_prevmousepos = m_mousepos;
m_mouselastactivity = totalclock;
m_mouselastactivity = totalclock.Ticks();
}
else
m_mousewake_watchpoint = 0;
@ -611,7 +611,7 @@ void CGameMenuItemZBool::Draw(void)
int shade = bEnable ? 32 : 48;
int pal = bEnable ? 0 : 5;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
if (m_pzText)
gMenuTextMgr.DrawText(m_pzText, m_nFont, m_nX, m_nY, shade, pal, false);
const char *value = at20 ? at21 : at25;
@ -686,7 +686,7 @@ void CGameMenuItemChain::Draw(void)
int shade = bEnable ? 32 : 48;
int pal = bEnable ? 0 : 5;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
int width, height;
int x = m_nX;
int y = m_nY;
@ -772,7 +772,7 @@ void CGameMenuItem7EA1C::Draw(void)
int shade = bEnable ? 32 : 48;
int pal = bEnable ? 0 : 5;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
int width;
int x = m_nX;
switch (at20)
@ -887,7 +887,7 @@ void CGameMenuItem7EE34::Draw(void)
int shade = bEnable ? 32 : 48;
int pal = bEnable ? 0 : 5;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
int width;
int x = m_nX;
switch (at24)
@ -1011,7 +1011,7 @@ void CGameMenuItemBitmap::Draw(void)
int shade = bEnable ? 32 : 48;
int pal = bEnable ? 0 : 5;
if (bEnable && pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
int x = m_nX;
int y = m_nY;
if (m_pzText)
@ -1051,7 +1051,7 @@ void CGameMenuItemBitmapLS::Draw(void)
int shade = bEnable ? 32 : 48;
int pal = bEnable ? 0 : 5;
if (bEnable && pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
int x = m_nX;
int y = m_nY;
if (m_pzText)
@ -1156,7 +1156,7 @@ void CGameMenuItemKeyList::Draw(void)
{
shade = 32;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
viewDrawText(3, buffer, m_nX, y, shade, 0, 0, false);
const char *sVal;
if (bScan && (gGameClock & 32))
@ -1304,13 +1304,13 @@ bool CGameMenuItemKeyList::MouseEvent(CGameMenuEvent &event)
event.at0 = kMenuEventNone;
if (MOUSEACTIVECONDITIONAL(MOUSE_GetButtons()&WHEELUP_MOUSE))
{
gGameMenuMgr.m_mouselastactivity = totalclock;
gGameMenuMgr.m_mouselastactivity = totalclock.Ticks();
MOUSE_ClearButton(WHEELUP_MOUSE);
event.at0 = kMenuEventScrollUp;
}
else if (MOUSEACTIVECONDITIONAL(MOUSE_GetButtons()&WHEELDOWN_MOUSE))
{
gGameMenuMgr.m_mouselastactivity = totalclock;
gGameMenuMgr.m_mouselastactivity = totalclock.Ticks();
MOUSE_ClearButton(WHEELDOWN_MOUSE);
event.at0 = kMenuEventScrollDown;
}
@ -1389,7 +1389,7 @@ void CGameMenuItemSlider::Draw(void)
int shade2 = bEnable ? 0 : 16;
int pal = bEnable ? 0 : 5;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
if (m_pzText)
gMenuTextMgr.DrawText(m_pzText, m_nFont, m_nX, m_nY, shade, pal, false);
int sliderX = m_nX+m_nWidth-1-tilesiz[nSliderTile].x/2;
@ -1621,7 +1621,7 @@ void CGameMenuItemSliderFloat::Draw(void)
int shade2 = bEnable ? 0 : 16;
int pal = bEnable ? 0 : 5;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
if (m_pzText)
gMenuTextMgr.DrawText(m_pzText, m_nFont, m_nX, m_nY, shade, pal, false);
int sliderX = m_nX+m_nWidth-1-tilesiz[nSliderTile].x/2;
@ -1803,7 +1803,7 @@ void CGameMenuItemZEdit::Draw(void)
int shade = bEnable ? 32 : 48;
int pal = bEnable ? 0 : 5;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
if (at30)
shade = -128;
if (m_pzText)
@ -1988,7 +1988,7 @@ void CGameMenuItemZEditBitmap::Draw(void)
int shade = bEnable ? 32 : 48;
int pal = bEnable ? 0 : 5;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
at2c->at24 = -1;
if (at34)
shade = -128;
@ -2150,8 +2150,8 @@ void CGameMenuItemQAV::Draw(void)
{
int backFC = gFrameClock;
gFrameClock = gGameClock;
int nTicks = totalclock - at30;
at30 = totalclock;
int nTicks = totalclock.Ticks() - at30;
at30 = totalclock.Ticks();
at2c -= nTicks;
if (at2c <= 0 || at2c > at28->at10)
{
@ -2229,7 +2229,7 @@ bool CGameMenuItemQAV::Event(CGameMenuEvent &event)
at28->y = m_nY;
at28->Preload();
at2c = at28->at10;
at30 = totalclock;
at30 = totalclock.Ticks();
return false;
}
gSysRes.Lock(at24);
@ -2250,7 +2250,7 @@ bool CGameMenuItemQAV::Event(CGameMenuEvent &event)
void CGameMenuItemQAV::Reset(void)
{
at2c = at28->at10;
at30 = totalclock;
at30 = totalclock.Ticks();
}
CGameMenuItemZCycleSelect::CGameMenuItemZCycleSelect()
@ -2298,7 +2298,7 @@ void CGameMenuItemZCycleSelect::Draw(void)
{
shade = 32;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
viewDrawText(3, m_pzStrings[k], m_nX, y, shade, 0, 0, false);
}
else
@ -2396,13 +2396,13 @@ bool CGameMenuItemZCycleSelect::MouseEvent(CGameMenuEvent &event)
event.at0 = kMenuEventNone;
if (MOUSEACTIVECONDITIONAL(MOUSE_GetButtons()&WHEELUP_MOUSE))
{
gGameMenuMgr.m_mouselastactivity = totalclock;
gGameMenuMgr.m_mouselastactivity = totalclock.Ticks();
MOUSE_ClearButton(WHEELUP_MOUSE);
event.at0 = kMenuEventScrollUp;
}
else if (MOUSEACTIVECONDITIONAL(MOUSE_GetButtons()&WHEELDOWN_MOUSE))
{
gGameMenuMgr.m_mouselastactivity = totalclock;
gGameMenuMgr.m_mouselastactivity = totalclock.Ticks();
MOUSE_ClearButton(WHEELDOWN_MOUSE);
event.at0 = kMenuEventScrollDown;
}
@ -2464,7 +2464,7 @@ void CGameMenuItemZCycle::Draw(void)
int shade = bEnable ? 32 : 48;
int pal = bEnable ? 0 : 5;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
int x = m_nX;
int y = m_nY;
@ -2666,7 +2666,7 @@ void CGameMenuItemYesNoQuit::Draw(void)
if (!m_pzText) return;
int shade = 32;
if (pMenu->IsFocusItem(this))
shade = 32-(totalclock&63);
shade = 32-(totalclock.Ticks() &63);
int width;
int x = m_nX;
switch (at20)
@ -2859,7 +2859,7 @@ void CGameMenuItemPassword::Draw(void)
{
bool focus = pMenu->IsFocusItem(this);
int shade = 32;
int shadef = 32-(totalclock&63);
int shadef = 32-(totalclock.Ticks() &63);
int width;
switch (at37)
{
@ -2886,12 +2886,12 @@ void CGameMenuItemPassword::Draw(void)
shadef = 32;
break;
case 4:
if ((totalclock - at5b) & 32)
if ((totalclock.Ticks() - at5b) & 32)
{
gMenuTextMgr.GetFontInfo(m_nFont, kInvalidPasswordMsg, &width, NULL);
gMenuTextMgr.DrawText(kInvalidPasswordMsg, m_nFont, m_nX - width / 2, m_nY + 20, shade, 0, false);
}
if (at5b && totalclock-at5b > 256)
if (at5b && totalclock.Ticks() -at5b > 256)
{
at5b = 0;
at37 = 0;
@ -2934,7 +2934,7 @@ bool CGameMenuItemPassword::Event(CGameMenuEvent &event)
at37 = 4;
if (!at36)
{
at5b = totalclock;
at5b = totalclock.Ticks();
pMenu->FocusPrevItem();
}
else
@ -2962,7 +2962,7 @@ bool CGameMenuItemPassword::Event(CGameMenuEvent &event)
at37 = 0;
}
else
at5b = totalclock;
at5b = totalclock.Ticks();
return false;
case 3:
strcpy(at20, at29);

View file

@ -39,8 +39,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// alpha increments of 3 --> 255 / 3 = 85 --> round up to power of 2 --> 128 --> divide by 2 --> 64 alphatabs required
// use 16 anyway :P
#define MOUSEUSEALPHA (videoGetRenderMode() != REND_CLASSIC || numalphatabs >= 15)
#define MOUSEALPHA (MOUSEUSEALPHA ? clamp((totalclock - gGameMenuMgr.m_mouselastactivity - 90)*3, 0, 255) : 0)
#define CURSORALPHA (MOUSEUSEALPHA ? clamp((totalclock - gGameMenuMgr.m_mouselastactivity - 90)*2 + (255/3), (255/3), 255) : 255/3)
#define MOUSEALPHA (MOUSEUSEALPHA ? clamp((totalclock.Ticks() - gGameMenuMgr.m_mouselastactivity - 90)*3, 0, 255) : 0)
#define CURSORALPHA (MOUSEUSEALPHA ? clamp((totalclock.Ticks() - gGameMenuMgr.m_mouselastactivity - 90)*2 + (255/3), (255/3), 255) : 255/3)
#define MOUSEACTIVECONDITION (totalclock - gGameMenuMgr.m_mouselastactivity < M_MOUSETIMEOUT)
#define MOUSEACTIVECONDITIONAL(condition) (MOUSEACTIVECONDITION && (condition))
#define MOUSEINACTIVECONDITIONAL(condition) (!MOUSEACTIVECONDITION && (condition))

View file

@ -131,6 +131,7 @@ public:
explicit operator uint32_t() const { return wholeTicks; };
explicit operator int32_t() const { return wholeTicks; };
int32_t Ticks() const { return wholeTicks; }
private:
//POGO: wholeTicks must be first in member-order to ensure the address of