From 518b940365137a99b9f787002d6ac31a52348efb Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sun, 12 May 2024 21:35:28 +0200 Subject: [PATCH] add hack for games that require the cursor to be in the exact center of the screen (Worms 2 / Atlantis) --- inc/config.h | 1 + src/config.c | 4 ++++ src/dd.c | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/inc/config.h b/inc/config.h index badf4feb2d..ec737ebc33 100644 --- a/inc/config.h +++ b/inc/config.h @@ -75,6 +75,7 @@ typedef struct CNCDDRAWCONFIG int custom_height; int min_font_size; BOOL direct3d_passthrough; + BOOL center_cursor_fix; /* Hotkeys */ diff --git a/src/config.c b/src/config.c index 70079d099c..624f12b990 100644 --- a/src/config.c +++ b/src/config.c @@ -88,6 +88,7 @@ void cfg_load() GET_INT(g_config.custom_height, "custom_height", 0); GET_INT(g_config.min_font_size, "min_font_size", 0); GET_BOOL(g_config.direct3d_passthrough, "direct3d_passthrough", FALSE); + GET_BOOL(g_config.center_cursor_fix, "center_cursor_fix", FALSE); /* Hotkeys */ @@ -300,6 +301,7 @@ static void cfg_create_ini() "custom_height=0\n" "min_font_size=0\n" "direct3d_passthrough=false\n" + "center_cursor_fix=false\n" "\n" "\n" "\n" @@ -433,6 +435,7 @@ static void cfg_create_ini() "[ATLANTIS]\n" "renderer=opengl\n" "maxgameticks=60\n" + "center_cursor_fix=true\n" "\n" "; Airline Tycoon Deluxe\n" "[AT]\n" @@ -1052,6 +1055,7 @@ static void cfg_create_ini() "[worms2]\n" "flipclear=true\n" "game_handles_close=true\n" + "center_cursor_fix=true\n" "\n" "; Worms Armageddon\n" "[WA]\n" diff --git a/src/dd.c b/src/dd.c index c71a4d0913..3bb332f225 100644 --- a/src/dd.c +++ b/src/dd.c @@ -841,10 +841,21 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl g_ddraw.render.unscale_w = ((float)g_ddraw.width / g_ddraw.render.viewport.width); g_ddraw.render.unscale_h = ((float)g_ddraw.height / g_ddraw.render.viewport.height); - g_ddraw.mouse.scale_x = ((float)(g_ddraw.render.viewport.width - 1) / (g_ddraw.width - 1)); - g_ddraw.mouse.scale_y = ((float)(g_ddraw.render.viewport.height - 1) / (g_ddraw.height - 1)); - g_ddraw.mouse.unscale_x = ((float)(g_ddraw.width - 1) / (g_ddraw.render.viewport.width - 1)); - g_ddraw.mouse.unscale_y = ((float)(g_ddraw.height - 1) / (g_ddraw.render.viewport.height - 1)); + /* Hack for games that require the cursor to be in the exact center of the screen (Worms 2 / Atlantis) */ + if (g_config.center_cursor_fix) + { + g_ddraw.mouse.scale_x = ((float)(g_ddraw.render.viewport.width) / (g_ddraw.width)); + g_ddraw.mouse.scale_y = ((float)(g_ddraw.render.viewport.height) / (g_ddraw.height)); + g_ddraw.mouse.unscale_x = ((float)(g_ddraw.width) / (g_ddraw.render.viewport.width)); + g_ddraw.mouse.unscale_y = ((float)(g_ddraw.height) / (g_ddraw.render.viewport.height)); + } + else + { + g_ddraw.mouse.scale_x = ((float)(g_ddraw.render.viewport.width - 1) / (g_ddraw.width - 1)); + g_ddraw.mouse.scale_y = ((float)(g_ddraw.render.viewport.height - 1) / (g_ddraw.height - 1)); + g_ddraw.mouse.unscale_x = ((float)(g_ddraw.width - 1) / (g_ddraw.render.viewport.width - 1)); + g_ddraw.mouse.unscale_y = ((float)(g_ddraw.height - 1) / (g_ddraw.render.viewport.height - 1)); + } g_ddraw.mouse.x_adjust = g_ddraw.render.viewport.x; g_ddraw.mouse.y_adjust = g_ddraw.render.viewport.y;