remove sleep hack and add a smarter game speed limiter that takes the games performance into account
This commit is contained in:
parent
2d4841beda
commit
0e6d415f63
4 changed files with 34 additions and 12 deletions
18
src/main.c
18
src/main.c
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue