summaryrefslogtreecommitdiff
path: root/src/gfx2d.c
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-09-06 12:10:37 -0700
committer3gg <3gg@shellblade.net>2025-09-06 12:10:37 -0700
commita7a2884c30a92654b676be05338947f7555bba58 (patch)
treef1baaa7c6ebecd9d9373755f5e39d1e6007a2a30 /src/gfx2d.c
parentf46c66485b758385417431d290e1a2958dececea (diff)
Tidy
Diffstat (limited to 'src/gfx2d.c')
-rw-r--r--src/gfx2d.c14
1 files changed, 7 insertions, 7 deletions
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) {
150 const double one_over_s = 1. / (double)s; 150 const double one_over_s = 1. / (double)s;
151 const double one_over_t = 1. / (double)t; 151 const double one_over_t = 1. / (double)t;
152 const double x = cart.x - (double)(w / 2); 152 const double x = cart.x - (double)(w / 2);
153 return (vec2){.x = (one_over_s * x + one_over_t * cart.y), 153 return (vec2){.x = ((one_over_s * x) + (one_over_t * cart.y)),
154 .y = (-one_over_s * x + one_over_t * cart.y)}; 154 .y = ((-one_over_s * x) + (one_over_t * cart.y))};
155} 155}
156 156
157static inline const Pixel* screen_xy_const_ref( 157static inline const Pixel* screen_xy_const_ref(
@@ -161,10 +161,10 @@ static inline const Pixel* screen_xy_const_ref(
161 assert(y >= 0); 161 assert(y >= 0);
162 assert(x < screen->width); 162 assert(x < screen->width);
163 assert(y < screen->height); 163 assert(y < screen->height);
164 return &screen->pixels[y * screen->width + x]; 164 return &screen->pixels[(y * screen->width) + x];
165} 165}
166 166
167static inline Pixel screen_xy(Screen* screen, int x, int y) { 167static inline Pixel screen_xy(const Screen* screen, int x, int y) {
168 return *screen_xy_const_ref(screen, x, y); 168 return *screen_xy_const_ref(screen, x, y);
169} 169}
170 170
@@ -360,10 +360,10 @@ static void make_tile_from_colour(
360 const int height = tile->height; 360 const int height = tile->height;
361 const int r = width / height; 361 const int r = width / height;
362 for (int y = 0; y < height / 2; ++y) { 362 for (int y = 0; y < height / 2; ++y) {
363 const int mask_start = width / 2 - r * y - 1; 363 const int mask_start = (width / 2) - (r * y) - 1;
364 const int mask_end = width / 2 + r * y + 1; 364 const int mask_end = (width / 2) + (r * y) + 1;
365 for (int x = 0; x < width; ++x) { 365 for (int x = 0; x < width; ++x) {
366 const bool mask = (mask_start <= x) && (x <= mask_end); 366 const bool mask = ((mask_start <= x) && (x <= mask_end)) != 0;
367 const Pixel val = mask ? colour : (Pixel){.r = 0, .g = 0, .b = 0, .a = 0}; 367 const Pixel val = mask ? colour : (Pixel){.r = 0, .g = 0, .b = 0, .a = 0};
368 368
369 // Top half. 369 // Top half.