Skip to content

Commit

Permalink
add hack for games that require the cursor to be in the exact center …
Browse files Browse the repository at this point in the history
…of the screen (Worms 2 / Atlantis)
  • Loading branch information
FunkyFr3sh committed May 12, 2024
1 parent 175d2f5 commit 518b940
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions inc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ typedef struct CNCDDRAWCONFIG
int custom_height;
int min_font_size;
BOOL direct3d_passthrough;
BOOL center_cursor_fix;

/* Hotkeys */

Expand Down
4 changes: 4 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
19 changes: 15 additions & 4 deletions src/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 518b940

Please sign in to comment.