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 --- include/isogfx/asset.h | 8 ++++---- src/gfx2d.c | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/isogfx/asset.h b/include/isogfx/asset.h index 361ffcd..cc70ee3 100644 --- a/include/isogfx/asset.h +++ b/include/isogfx/asset.h @@ -154,7 +154,7 @@ static inline const Pixel* ts_tile_get_pixels( } /// Return the tile's pixel at (x,y). -static const Pixel* ts_tile_xy( +static inline const Pixel* ts_tile_xy( const Pixel* tile_pixels, const Ts_Tile* tile, int x, int y) { assert(tile_pixels); assert(tile); @@ -166,9 +166,9 @@ static const Pixel* ts_tile_xy( } /// Return the tile's pixel at (x,y). -static Pixel* ts_tile_xy_mut( - const Pixel* pixels, const Ts_Tile* tile, int x, int y) { - return (Pixel*)ts_tile_xy(pixels, tile, x, y); +static inline Pixel* ts_tile_xy_mut( + Pixel* tile_pixels, const Ts_Tile* tile, int x, int y) { + return (Pixel*)ts_tile_xy(tile_pixels, tile, x, y); } /// Return the ith layer in the tile map. 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