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

save last flip tick to force redraw in case the game switches between blt and flip

This commit is contained in:
FunkyFr3sh 2018-11-19 08:36:18 +01:00
parent add701a7f6
commit 5d2d258d52
2 changed files with 15 additions and 3 deletions

View File

@ -50,6 +50,7 @@ typedef struct IDirectDrawSurfaceImpl
HBITMAP bitmap;
HDC hDC;
DDCOLORKEY colorKey;
DWORD lastFlipTick;
} IDirectDrawSurfaceImpl;

View File

@ -21,6 +21,9 @@
#include "surface.h"
#include "scale_pattern.h"
// enables redraw via blt/unlock if there wasn't any flip for X ms
#define FLIP_REDRAW_TIMEOUT 1000 / 20
void dump_ddbltflags(DWORD dwFlags);
void dump_ddscaps(DWORD dwCaps);
void dump_ddsd(DWORD dwFlags);
@ -425,7 +428,9 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
}
}
if(This->caps & DDSCAPS_PRIMARYSURFACE && !(This->flags & DDSD_BACKBUFFERCOUNT) && ddraw->render.run)
if(This->caps & DDSCAPS_PRIMARYSURFACE &&
ddraw->render.run &&
(!(This->flags & DDSD_BACKBUFFERCOUNT) || This->lastFlipTick + FLIP_REDRAW_TIMEOUT < timeGetTime()))
{
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
@ -564,7 +569,9 @@ HRESULT __stdcall ddraw_surface_BltFast(IDirectDrawSurfaceImpl *This, DWORD dst_
}
}
if (This->caps & DDSCAPS_PRIMARYSURFACE && !(This->flags & DDSD_BACKBUFFERCOUNT) && ddraw->render.run)
if (This->caps & DDSCAPS_PRIMARYSURFACE &&
ddraw->render.run &&
(!(This->flags & DDSD_BACKBUFFERCOUNT) || This->lastFlipTick + FLIP_REDRAW_TIMEOUT < timeGetTime()))
{
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
@ -639,6 +646,8 @@ HRESULT __stdcall ddraw_surface_Flip(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWS
if(This->caps & DDSCAPS_PRIMARYSURFACE && ddraw->render.run)
{
This->lastFlipTick = timeGetTime();
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
if (ddraw->renderer == render_soft_main)
@ -912,7 +921,9 @@ HRESULT __stdcall ddraw_surface_Unlock(IDirectDrawSurfaceImpl *This, LPVOID lpRe
printf("DirectDrawSurface::Unlock(This=%p, lpRect=%p)\n", This, lpRect);
#endif
if(This->caps & DDSCAPS_PRIMARYSURFACE && !(This->flags & DDSD_BACKBUFFERCOUNT) && ddraw->render.run)
if (This->caps & DDSCAPS_PRIMARYSURFACE &&
ddraw->render.run &&
(!(This->flags & DDSD_BACKBUFFERCOUNT) || This->lastFlipTick + FLIP_REDRAW_TIMEOUT < timeGetTime()))
{
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
ReleaseSemaphore(ddraw->render.sem, 1, NULL);