- moved the main game ticker out of app_main.

This commit is contained in:
Christoph Oelckers 2020-08-23 07:49:58 +02:00
parent 3a3ba43985
commit 5ba384db35
2 changed files with 52 additions and 42 deletions

View file

@ -528,6 +528,56 @@ void GameMove(void)
moveframes--;
}
void GameTicker()
{
while ((totalclock - ototalclock) >= 1 || !bInMove)
{
ototalclock = ototalclock + 1;
if (!((int)ototalclock & 3) && moveframes < 4)
moveframes++;
GetLocalInput();
PlayerInterruptKeys();
nPlayerDAng = fix16_sadd(nPlayerDAng, localInput.nAngle);
inita &= kAngleMask;
lPlayerXVel += localInput.yVel * Cos(inita) + localInput.xVel * Sin(inita);
lPlayerYVel += localInput.yVel * Sin(inita) - localInput.xVel * Cos(inita);
lPlayerXVel -= (lPlayerXVel >> 5) + (lPlayerXVel >> 6);
lPlayerYVel -= (lPlayerYVel >> 5) + (lPlayerYVel >> 6);
sPlayerInput[nLocalPlayer].xVel = lPlayerXVel;
sPlayerInput[nLocalPlayer].yVel = lPlayerYVel;
sPlayerInput[nLocalPlayer].buttons = lLocalButtons | lLocalCodes;
sPlayerInput[nLocalPlayer].nAngle = nPlayerDAng;
sPlayerInput[nLocalPlayer].nTarget = besttarget;
Ra[nLocalPlayer].nTarget = besttarget;
lLocalCodes = 0;
nPlayerDAng = 0;
sPlayerInput[nLocalPlayer].horizon = PlayerList[nLocalPlayer].q16horiz;
while (!EndLevel && totalclock >= tclocks + 4)
{
tclocks += 4;
GameMove();
}
}
if (nPlayerLives[nLocalPlayer] <= 0) {
//startmainmenu();
}
#if 0
if (!bInDemo && levelnew > nBestLevel && levelnew != 0 && levelnew <= kMap20 && SavePosition > -1) {
menu_GameSave(SavePosition);
}
#endif
}
int32_t r_maxfpsoffset = 0;

View file

@ -75,6 +75,7 @@ void DoTitle(CompletionFunc completion);
void ResetEngine();
void CheckKeys();
void CheckKeys2();
void GameTicker();
void FinishLevel()
{
@ -436,49 +437,8 @@ GAMELOOP:
}
else
{
while ((totalclock - ototalclock) >= 1 || !bInMove)
{
ototalclock = ototalclock + 1;
if (!((int)ototalclock&3) && moveframes < 4)
moveframes++;
GetLocalInput();
PlayerInterruptKeys();
nPlayerDAng = fix16_sadd(nPlayerDAng, localInput.nAngle);
inita &= kAngleMask;
lPlayerXVel += localInput.yVel * Cos(inita) + localInput.xVel * Sin(inita);
lPlayerYVel += localInput.yVel * Sin(inita) - localInput.xVel * Cos(inita);
lPlayerXVel -= (lPlayerXVel >> 5) + (lPlayerXVel >> 6);
lPlayerYVel -= (lPlayerYVel >> 5) + (lPlayerYVel >> 6);
sPlayerInput[nLocalPlayer].xVel = lPlayerXVel;
sPlayerInput[nLocalPlayer].yVel = lPlayerYVel;
sPlayerInput[nLocalPlayer].buttons = lLocalButtons | lLocalCodes;
sPlayerInput[nLocalPlayer].nAngle = nPlayerDAng;
sPlayerInput[nLocalPlayer].nTarget = besttarget;
Ra[nLocalPlayer].nTarget = besttarget;
lLocalCodes = 0;
nPlayerDAng = 0;
sPlayerInput[nLocalPlayer].horizon = PlayerList[nLocalPlayer].q16horiz;
while (levelnew < 0 && totalclock >= tclocks + 4)
{
tclocks += 4;
GameMove();
if (EndLevel)
{
goto getoutofhere;
GameTicker();
}
}
}
}
getoutofhere:
bInMove = false;
PlayerInterruptKeys();