mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
add new limiter_type type (PeekMessage)
This commit is contained in:
parent
fb85d6ea03
commit
7674328410
2
inc/dd.h
2
inc/dd.h
@ -51,6 +51,7 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute
|
|||||||
#define LIMIT_TESTCOOP 1
|
#define LIMIT_TESTCOOP 1
|
||||||
#define LIMIT_BLTFAST 2
|
#define LIMIT_BLTFAST 2
|
||||||
#define LIMIT_UNLOCK 3
|
#define LIMIT_UNLOCK 3
|
||||||
|
#define LIMIT_PEEKMESSAGE 4
|
||||||
|
|
||||||
#define CENTER_WINDOW_NEVER 0
|
#define CENTER_WINDOW_NEVER 0
|
||||||
#define CENTER_WINDOW_AUTO 1
|
#define CENTER_WINDOW_AUTO 1
|
||||||
@ -126,6 +127,7 @@ typedef struct CNCDDRAW
|
|||||||
LONG palette_updated;
|
LONG palette_updated;
|
||||||
LONG surface_updated;
|
LONG surface_updated;
|
||||||
LONG clear_screen;
|
LONG clear_screen;
|
||||||
|
LONG screen_updated;
|
||||||
|
|
||||||
float scale_w;
|
float scale_w;
|
||||||
float scale_h;
|
float scale_h;
|
||||||
|
@ -290,7 +290,7 @@ static void cfg_create_ini()
|
|||||||
"; Note: Usually one of the following values will work: 60 / 30 / 25 / 20 / 15 (lower value = slower game speed)\n"
|
"; Note: Usually one of the following values will work: 60 / 30 / 25 / 20 / 15 (lower value = slower game speed)\n"
|
||||||
"maxgameticks=0\n"
|
"maxgameticks=0\n"
|
||||||
"\n"
|
"\n"
|
||||||
"; Method that should be used to limit game ticks (maxgameticks=): 0 = Automatic, 1 = TestCooperativeLevel, 2 = BltFast, 3 = Unlock\n"
|
"; Method that should be used to limit game ticks (maxgameticks=): 0 = Automatic, 1 = TestCooperativeLevel, 2 = BltFast, 3 = Unlock, 4 = PeekMessage\n"
|
||||||
"limiter_type=0\n"
|
"limiter_type=0\n"
|
||||||
"\n"
|
"\n"
|
||||||
"; Force minimum FPS, possible values: 0 = disabled, -1 = use 'maxfps=' value, -2 = same as -1 but force full redraw, 1-1000 = custom FPS\n"
|
"; Force minimum FPS, possible values: 0 = disabled, -1 = use 'maxfps=' value, -2 = same as -1 but force full redraw, 1-1000 = custom FPS\n"
|
||||||
|
@ -430,6 +430,7 @@ HRESULT dds_Blt(
|
|||||||
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
|
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
|
||||||
{
|
{
|
||||||
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
|
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
|
||||||
|
InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
|
||||||
|
|
||||||
if (!(This->flags & DDSD_BACKBUFFERCOUNT) || This->last_flip_tick + FLIP_REDRAW_TIMEOUT < timeGetTime())
|
if (!(This->flags & DDSD_BACKBUFFERCOUNT) || This->last_flip_tick + FLIP_REDRAW_TIMEOUT < timeGetTime())
|
||||||
{
|
{
|
||||||
@ -438,7 +439,7 @@ HRESULT dds_Blt(
|
|||||||
ReleaseSemaphore(g_ddraw.render.sem, 1, NULL);
|
ReleaseSemaphore(g_ddraw.render.sem, 1, NULL);
|
||||||
SwitchToThread();
|
SwitchToThread();
|
||||||
|
|
||||||
if (g_ddraw.ticks_limiter.tick_length > 0)
|
if (g_ddraw.ticks_limiter.tick_length > 0 && g_config.limiter_type != LIMIT_PEEKMESSAGE)
|
||||||
{
|
{
|
||||||
g_ddraw.ticks_limiter.dds_unlock_limiter_disabled = TRUE;
|
g_ddraw.ticks_limiter.dds_unlock_limiter_disabled = TRUE;
|
||||||
util_limit_game_ticks();
|
util_limit_game_ticks();
|
||||||
@ -666,6 +667,7 @@ HRESULT dds_BltFast(
|
|||||||
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
|
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
|
||||||
{
|
{
|
||||||
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
|
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
|
||||||
|
InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
|
||||||
|
|
||||||
DWORD time = timeGetTime();
|
DWORD time = timeGetTime();
|
||||||
|
|
||||||
@ -824,6 +826,7 @@ HRESULT dds_Flip(IDirectDrawSurfaceImpl* This, IDirectDrawSurfaceImpl* lpDDSurfa
|
|||||||
This->last_flip_tick = timeGetTime();
|
This->last_flip_tick = timeGetTime();
|
||||||
|
|
||||||
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
|
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
|
||||||
|
InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
|
||||||
ReleaseSemaphore(g_ddraw.render.sem, 1, NULL);
|
ReleaseSemaphore(g_ddraw.render.sem, 1, NULL);
|
||||||
SwitchToThread();
|
SwitchToThread();
|
||||||
|
|
||||||
@ -832,7 +835,7 @@ HRESULT dds_Flip(IDirectDrawSurfaceImpl* This, IDirectDrawSurfaceImpl* lpDDSurfa
|
|||||||
dd_WaitForVerticalBlank(DDWAITVB_BLOCKEND, NULL);
|
dd_WaitForVerticalBlank(DDWAITVB_BLOCKEND, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ddraw.ticks_limiter.tick_length > 0)
|
if (g_ddraw.ticks_limiter.tick_length > 0 && g_config.limiter_type != LIMIT_PEEKMESSAGE)
|
||||||
{
|
{
|
||||||
g_ddraw.ticks_limiter.dds_unlock_limiter_disabled = TRUE;
|
g_ddraw.ticks_limiter.dds_unlock_limiter_disabled = TRUE;
|
||||||
util_limit_game_ticks();
|
util_limit_game_ticks();
|
||||||
@ -1027,6 +1030,7 @@ HRESULT dds_ReleaseDC(IDirectDrawSurfaceImpl* This, HDC hDC)
|
|||||||
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
|
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
|
||||||
{
|
{
|
||||||
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
|
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
|
||||||
|
InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
|
||||||
|
|
||||||
DWORD time = timeGetTime();
|
DWORD time = timeGetTime();
|
||||||
|
|
||||||
@ -1212,6 +1216,7 @@ HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect)
|
|||||||
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
|
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
|
||||||
{
|
{
|
||||||
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
|
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
|
||||||
|
InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
|
||||||
|
|
||||||
DWORD time = timeGetTime();
|
DWORD time = timeGetTime();
|
||||||
|
|
||||||
@ -1221,6 +1226,7 @@ HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect)
|
|||||||
ReleaseSemaphore(g_ddraw.render.sem, 1, NULL);
|
ReleaseSemaphore(g_ddraw.render.sem, 1, NULL);
|
||||||
|
|
||||||
if (g_ddraw.ticks_limiter.tick_length > 0 &&
|
if (g_ddraw.ticks_limiter.tick_length > 0 &&
|
||||||
|
g_config.limiter_type != LIMIT_PEEKMESSAGE &&
|
||||||
(!g_ddraw.ticks_limiter.dds_unlock_limiter_disabled || g_config.limiter_type == LIMIT_UNLOCK))
|
(!g_ddraw.ticks_limiter.dds_unlock_limiter_disabled || g_config.limiter_type == LIMIT_UNLOCK))
|
||||||
{
|
{
|
||||||
util_limit_game_ticks();
|
util_limit_game_ticks();
|
||||||
|
@ -780,6 +780,13 @@ BOOL WINAPI fake_GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wM
|
|||||||
|
|
||||||
BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
|
BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
|
||||||
{
|
{
|
||||||
|
if (g_config.limiter_type == LIMIT_PEEKMESSAGE &&
|
||||||
|
g_ddraw.ticks_limiter.tick_length > 0 &&
|
||||||
|
InterlockedExchange(&g_ddraw.render.screen_updated, FALSE))
|
||||||
|
{
|
||||||
|
util_limit_game_ticks();
|
||||||
|
}
|
||||||
|
|
||||||
if (g_ddraw.ref && (!hWnd || hWnd == g_ddraw.hwnd))
|
if (g_ddraw.ref && (!hWnd || hWnd == g_ddraw.hwnd))
|
||||||
g_ddraw.last_msg_pull_tick = timeGetTime();
|
g_ddraw.last_msg_pull_tick = timeGetTime();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user