mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +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;
|
||||
|
||||
BOOL detect_cutscene();
|
||||
void LimitGameTicks();
|
||||
void LimitGameTicks(BOOL isBltOrFlip);
|
||||
DWORD WINAPI render_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;
|
||||
}
|
||||
|
||||
void LimitGameTicks()
|
||||
void LimitGameTicks(BOOL isBltOrFlip)
|
||||
{
|
||||
static DWORD nextGameTick;
|
||||
static DWORD lastBltOrFlipTick;
|
||||
if (!nextGameTick)
|
||||
{
|
||||
nextGameTick = timeGetTime();
|
||||
return;
|
||||
}
|
||||
nextGameTick += ddraw->ticklength;
|
||||
|
||||
DWORD tickCount = timeGetTime();
|
||||
|
||||
if (isBltOrFlip)
|
||||
lastBltOrFlipTick = tickCount;
|
||||
else if (lastBltOrFlipTick + ddraw->ticklength >= tickCount)
|
||||
return;
|
||||
|
||||
nextGameTick += ddraw->ticklength;
|
||||
int sleepTime = nextGameTick - tickCount;
|
||||
|
||||
if (sleepTime <= 0 || sleepTime > ddraw->ticklength)
|
||||
nextGameTick = tickCount;
|
||||
else
|
||||
|
@ -240,6 +240,9 @@ static void CreateSettingsIni()
|
||||
"noactivateapp=true\n"
|
||||
"maxgameticks=60\n"
|
||||
"\n"
|
||||
"[BM]\n"
|
||||
"maxgameticks=60\n"
|
||||
"\n"
|
||||
|
||||
, fh);
|
||||
fclose(fh);
|
||||
|
@ -200,7 +200,7 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
|
||||
}
|
||||
|
||||
if (ddraw->ticklength > 0)
|
||||
LimitGameTicks();
|
||||
LimitGameTicks(TRUE);
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
@ -369,7 +369,7 @@ HRESULT __stdcall ddraw_surface_Flip(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWS
|
||||
}
|
||||
|
||||
if (ddraw->ticklength > 0)
|
||||
LimitGameTicks();
|
||||
LimitGameTicks(TRUE);
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
@ -604,6 +604,9 @@ HRESULT __stdcall ddraw_surface_Unlock(IDirectDrawSurfaceImpl *This, LPVOID lpRe
|
||||
{
|
||||
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
|
||||
if (ddraw->ticklength > 0)
|
||||
LimitGameTicks(FALSE);
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user