From d2cff2838f79f82fb2f50bb7e9e234b5437cc053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Wed, 13 May 2020 21:18:22 -0300 Subject: [PATCH] Fix black edge caused by UB Seems to affect certain targets such as `aarch64`. This fix originally by @Emill. --- include/gfx_dimensions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/gfx_dimensions.h b/include/gfx_dimensions.h index dfc0394d..5dc8f6b8 100644 --- a/include/gfx_dimensions.h +++ b/include/gfx_dimensions.h @@ -6,8 +6,8 @@ #include "pc/gfx/gfx_pc.h" #define GFX_DIMENSIONS_FROM_LEFT_EDGE(v) (SCREEN_WIDTH / 2 - SCREEN_HEIGHT / 2 * gfx_current_dimensions.aspect_ratio + (v)) #define GFX_DIMENSIONS_FROM_RIGHT_EDGE(v) (SCREEN_WIDTH / 2 + SCREEN_HEIGHT / 2 * gfx_current_dimensions.aspect_ratio - (v)) -#define GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(v) floorf(GFX_DIMENSIONS_FROM_LEFT_EDGE(v)) -#define GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(v) ceilf(GFX_DIMENSIONS_FROM_RIGHT_EDGE(v)) +#define GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(v) ((int)floorf(GFX_DIMENSIONS_FROM_LEFT_EDGE(v))) +#define GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(v) ((int)ceilf(GFX_DIMENSIONS_FROM_RIGHT_EDGE(v))) #define GFX_DIMENSIONS_ASPECT_RATIO (gfx_current_dimensions.aspect_ratio) #else #define GFX_DIMENSIONS_FROM_LEFT_EDGE(v) (v)