Skip to content

Commit

Permalink
Fix some framerate things on Classic DOOM
Browse files Browse the repository at this point in the history
  • Loading branch information
MadDeCoDeR committed Nov 1, 2024
1 parent bf35d05 commit a9af297
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
18 changes: 12 additions & 6 deletions doomclassic/doom/d_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,15 +684,20 @@ bool InterpolateTics() {
if (::g->timeDelta >= expectedFrameMs) {
::g->accumulatedTimeDelta += ::g->timeDelta - expectedFrameMs;
if (::g->accumulatedTimeDelta >= expectedFrameMs) {
::g->skipTicInterpolationCheck = true;
::g->accumulatedTimeDelta2 += ::g->accumulatedTimeDelta - expectedFrameMs;
if (::g->accumulatedTimeDelta2 >= expectedFrameMs) {
::g->skipTicInterpolationCheck++;
::g->accumulatedTimeDelta2 = 0;
}
::g->skipTicInterpolationCheck++;
::g->accumulatedTimeDelta = 0;
}
::g->lastTicTime = currentTime;
return true;
}
}
else {
::g->skipTicInterpolationCheck = false;
::g->skipTicInterpolationCheck--;
return true;
}
return false;
Expand Down Expand Up @@ -749,10 +754,11 @@ bool TryRunTics ( idUserCmdMgr * userCmdMgr )
::g->trt_realtics = ::g->trt_entertic - ::g->oldtrt_entertics;
::g->oldtrt_entertics = ::g->trt_entertic;

if (FRAME_TO_MSEC(::g->trt_entertic) - ::g->firstClock >= 1000) {
int tempcounttics[3] = { 0, 0, 0 };
memcpy(::g->counttics, tempcounttics, sizeof(tempcounttics));
::g->firstClock = FRAME_TO_MSEC(::g->trt_entertic);
int currentTime = Sys_Milliseconds();
if (currentTime - ::g->firstClock >= 1000) {
/*int tempcounttics[3] = { 0, 0, 0 };
memcpy(::g->counttics, tempcounttics, sizeof(tempcounttics));*/
::g->firstClock = currentTime;
::g->dgameframe = ::g->gameframecount;
::g->gameframecount = 0;
}
Expand Down
17 changes: 12 additions & 5 deletions doomclassic/doom/g_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,19 @@ void G_BuildTiccmd (ticcmd_t* cmd, idUserCmdMgr * userCmdMgr, int newTics )
angleDelta.pitch /= newTics;
}


int currentTime = Sys_Milliseconds();
int frameTime = currentTime - ::g->prevMouseTime;
if (newTics > 0) {
::g->prevMouseTime = currentTime;
}
float estimatedFPS = roundf(1000.0f * (1.0f/frameTime));
float engineHz_denominator = com_engineHz_denominator / 100.0f;
float accelerator = engineHz_denominator / com_engineHz_latched;

angleDelta.yaw *= accelerator;
angleDelta.pitch *= accelerator;
float accelerator = estimatedFPS / com_engineHz_latched;
//I_Printf("Estimated FPS: %f, Accelerator: %f\n", estimatedFPS, accelerator);
if (accelerator >= 1) {
angleDelta.yaw *= accelerator;
angleDelta.pitch *= accelerator;
}

//I_Printf("Mouse Pitch: %f, Mouse Yaw: %f\n", angleDelta.pitch, angleDelta.yaw);

Expand Down
8 changes: 6 additions & 2 deletions doomclassic/doom/vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -1133,5 +1133,9 @@ int lastMasocTick;
//GK: New Frame Rate Interpolation
int timeDelta;
int lastTicTime;
bool skipTicInterpolationCheck;
int accumulatedTimeDelta;
int skipTicInterpolationCheck;
int accumulatedTimeDelta;
int accumulatedTimeDelta2;

//GK: Mouse Acceleration Fix
int prevMouseTime;

0 comments on commit a9af297

Please sign in to comment.