remove sleep hack and add a smarter game speed limiter that takes the games performance into account

This commit is contained in:
FunkyFr3sh 2018-10-31 11:48:41 +01:00
parent 2d4841beda
commit 0e6d415f63
4 changed files with 34 additions and 12 deletions

View file

@ -131,6 +131,24 @@ BOOL detect_cutscene()
return FALSE;
}
void LimitGameTicks()
{
static DWORD nextGameTick;
if (!nextGameTick)
{
nextGameTick = timeGetTime();
return;
}
nextGameTick += ddraw->ticklength;
DWORD tickCount = timeGetTime();
int sleepTime = nextGameTick - tickCount;
if (sleepTime <= 0 || sleepTime > ddraw->ticklength)
nextGameTick = tickCount;
else
Sleep(sleepTime);
}
HRESULT __stdcall ddraw_Compact(IDirectDrawImpl *This)
{
printf("DirectDraw::Compact(This=%p) ???\n", This);