From a7a2884c30a92654b676be05338947f7555bba58 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 6 Sep 2025 12:10:37 -0700 Subject: Tidy --- src/gfx2d.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/gfx2d.c') diff --git a/src/gfx2d.c b/src/gfx2d.c index f1f26cb..8d78c2b 100644 --- a/src/gfx2d.c +++ b/src/gfx2d.c @@ -150,8 +150,8 @@ static inline vec2 cart2iso(vec2 cart, int s, int t, int w) { const double one_over_s = 1. / (double)s; const double one_over_t = 1. / (double)t; const double x = cart.x - (double)(w / 2); - return (vec2){.x = (one_over_s * x + one_over_t * cart.y), - .y = (-one_over_s * x + one_over_t * cart.y)}; + return (vec2){.x = ((one_over_s * x) + (one_over_t * cart.y)), + .y = ((-one_over_s * x) + (one_over_t * cart.y))}; } static inline const Pixel* screen_xy_const_ref( @@ -161,10 +161,10 @@ static inline const Pixel* screen_xy_const_ref( assert(y >= 0); assert(x < screen->width); assert(y < screen->height); - return &screen->pixels[y * screen->width + x]; + return &screen->pixels[(y * screen->width) + x]; } -static inline Pixel screen_xy(Screen* screen, int x, int y) { +static inline Pixel screen_xy(const Screen* screen, int x, int y) { return *screen_xy_const_ref(screen, x, y); } @@ -360,10 +360,10 @@ static void make_tile_from_colour( const int height = tile->height; const int r = width / height; for (int y = 0; y < height / 2; ++y) { - const int mask_start = width / 2 - r * y - 1; - const int mask_end = width / 2 + r * y + 1; + const int mask_start = (width / 2) - (r * y) - 1; + const int mask_end = (width / 2) + (r * y) + 1; for (int x = 0; x < width; ++x) { - const bool mask = (mask_start <= x) && (x <= mask_end); + const bool mask = ((mask_start <= x) && (x <= mask_end)) != 0; const Pixel val = mask ? colour : (Pixel){.r = 0, .g = 0, .b = 0, .a = 0}; // Top half. -- cgit v1.2.3