mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
make maxgameticks working via surface unlock for atomic bomberman
This commit is contained in:
parent
0e3e7659cb
commit
bdb5675459
@ -32,7 +32,7 @@ extern BOOL ShowDriverWarning;
|
|||||||
extern RECT WindowRect;
|
extern RECT WindowRect;
|
||||||
|
|
||||||
BOOL detect_cutscene();
|
BOOL detect_cutscene();
|
||||||
void LimitGameTicks();
|
void LimitGameTicks(BOOL isBltOrFlip);
|
||||||
DWORD WINAPI render_main(void);
|
DWORD WINAPI render_main(void);
|
||||||
DWORD WINAPI render_soft_main(void);
|
DWORD WINAPI render_soft_main(void);
|
||||||
|
|
||||||
|
12
src/main.c
12
src/main.c
@ -133,18 +133,26 @@ BOOL detect_cutscene()
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitGameTicks()
|
void LimitGameTicks(BOOL isBltOrFlip)
|
||||||
{
|
{
|
||||||
static DWORD nextGameTick;
|
static DWORD nextGameTick;
|
||||||
|
static DWORD lastBltOrFlipTick;
|
||||||
if (!nextGameTick)
|
if (!nextGameTick)
|
||||||
{
|
{
|
||||||
nextGameTick = timeGetTime();
|
nextGameTick = timeGetTime();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nextGameTick += ddraw->ticklength;
|
|
||||||
DWORD tickCount = timeGetTime();
|
DWORD tickCount = timeGetTime();
|
||||||
|
|
||||||
|
if (isBltOrFlip)
|
||||||
|
lastBltOrFlipTick = tickCount;
|
||||||
|
else if (lastBltOrFlipTick + ddraw->ticklength >= tickCount)
|
||||||
|
return;
|
||||||
|
|
||||||
|
nextGameTick += ddraw->ticklength;
|
||||||
int sleepTime = nextGameTick - tickCount;
|
int sleepTime = nextGameTick - tickCount;
|
||||||
|
|
||||||
if (sleepTime <= 0 || sleepTime > ddraw->ticklength)
|
if (sleepTime <= 0 || sleepTime > ddraw->ticklength)
|
||||||
nextGameTick = tickCount;
|
nextGameTick = tickCount;
|
||||||
else
|
else
|
||||||
|
@ -240,6 +240,9 @@ static void CreateSettingsIni()
|
|||||||
"noactivateapp=true\n"
|
"noactivateapp=true\n"
|
||||||
"maxgameticks=60\n"
|
"maxgameticks=60\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"[BM]\n"
|
||||||
|
"maxgameticks=60\n"
|
||||||
|
"\n"
|
||||||
|
|
||||||
, fh);
|
, fh);
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
|
@ -200,7 +200,7 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ddraw->ticklength > 0)
|
if (ddraw->ticklength > 0)
|
||||||
LimitGameTicks();
|
LimitGameTicks(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
@ -369,7 +369,7 @@ HRESULT __stdcall ddraw_surface_Flip(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWS
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ddraw->ticklength > 0)
|
if (ddraw->ticklength > 0)
|
||||||
LimitGameTicks();
|
LimitGameTicks(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
@ -604,6 +604,9 @@ HRESULT __stdcall ddraw_surface_Unlock(IDirectDrawSurfaceImpl *This, LPVOID lpRe
|
|||||||
{
|
{
|
||||||
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
|
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
|
||||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||||
|
|
||||||
|
if (ddraw->ticklength > 0)
|
||||||
|
LimitGameTicks(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user