1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 14:14:47 +01:00

force 5 min. FPS

This commit is contained in:
FunkyFr3sh 2020-10-06 01:32:38 +02:00
parent 5f0f8f8737
commit b2ba8896b2
3 changed files with 29 additions and 20 deletions

View File

@ -566,7 +566,7 @@ static void Render()
glEnable(GL_TEXTURE_2D);
while (UseOpenGL && ddraw->render.run &&
(ddraw->render.forcefps || WaitForSingleObject(ddraw->render.sem, INFINITE) != WAIT_FAILED))
(ddraw->render.forcefps || WaitForSingleObject(ddraw->render.sem, 200) != WAIT_FAILED))
{
#if _DEBUG
DrawFrameInfoStart();

View File

@ -62,7 +62,7 @@ DWORD WINAPI render_soft_main(void)
}
while (ddraw->render.run &&
(ddraw->render.forcefps || WaitForSingleObject(ddraw->render.sem, INFINITE) != WAIT_FAILED))
(ddraw->render.forcefps || WaitForSingleObject(ddraw->render.sem, 200) != WAIT_FAILED))
{
#if _DEBUG
DrawFrameInfoStart();

View File

@ -460,18 +460,20 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
}
}
if(This->caps & DDSCAPS_PRIMARYSURFACE &&
ddraw->render.run &&
(!(This->flags & DDSD_BACKBUFFERCOUNT) || This->lastFlipTick + FLIP_REDRAW_TIMEOUT < timeGetTime()))
if((This->caps & DDSCAPS_PRIMARYSURFACE) && ddraw->render.run)
{
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
SwitchToThread();
if (ddraw->ticksLimiter.ticklength > 0)
if (!(This->flags & DDSD_BACKBUFFERCOUNT) || This->lastFlipTick + FLIP_REDRAW_TIMEOUT < timeGetTime())
{
ddraw->ticksLimiter.useBltOrFlip = TRUE;
LimitGameTicks();
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
SwitchToThread();
if (ddraw->ticksLimiter.ticklength > 0)
{
ddraw->ticksLimiter.useBltOrFlip = TRUE;
LimitGameTicks();
}
}
}
@ -598,12 +600,17 @@ HRESULT __stdcall ddraw_surface_BltFast(IDirectDrawSurfaceImpl *This, DWORD dst_
}
}
if (This->caps & DDSCAPS_PRIMARYSURFACE &&
ddraw->render.run &&
(!(This->flags & DDSD_BACKBUFFERCOUNT) || This->lastFlipTick + FLIP_REDRAW_TIMEOUT < timeGetTime()))
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && ddraw->render.run)
{
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
if (!(This->flags & DDSD_BACKBUFFERCOUNT) || This->lastFlipTick + FLIP_REDRAW_TIMEOUT < timeGetTime())
{
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
if (ddraw->ticksLimiter.ticklength > 0 && !ddraw->ticksLimiter.useBltOrFlip)
LimitGameTicks();
}
}
return DD_OK;
@ -1017,15 +1024,17 @@ HRESULT __stdcall ddraw_surface_Unlock(IDirectDrawSurfaceImpl *This, LPVOID lpRe
}
}
if (This->caps & DDSCAPS_PRIMARYSURFACE &&
ddraw->render.run &&
(!(This->flags & DDSD_BACKBUFFERCOUNT) || This->lastFlipTick + FLIP_REDRAW_TIMEOUT < timeGetTime()))
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && ddraw->render.run)
{
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
if (ddraw->ticksLimiter.ticklength > 0 && !ddraw->ticksLimiter.useBltOrFlip)
LimitGameTicks();
if (!(This->flags & DDSD_BACKBUFFERCOUNT) || This->lastFlipTick + FLIP_REDRAW_TIMEOUT < timeGetTime())
{
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
if (ddraw->ticksLimiter.ticklength > 0 && !ddraw->ticksLimiter.useBltOrFlip)
LimitGameTicks();
}
}
return DD_OK;