aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2024-01-27 13:41:14 +0100
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2024-01-27 17:38:12 +0100
commitdaf6f84ccdf817f7088aa527b4b37c2cca91c052 (patch)
treef2676fd88c5c87bc7731fc9a92ecad898ee0d689
parentda33e4668b23d3280f96d2ec0df68a829a0ef2d5 (diff)
gfx: Add return value to *_sort functions
-rw-r--r--src/camera/src/camera.c11
-rw-r--r--src/font/src/font.c7
-rw-r--r--src/gfx/inc/gfx.h8
-rw-r--r--src/gfx/ps1/src/sort.c12
-rw-r--r--src/gfx/sdl-1.2/src/env.c12
-rw-r--r--src/gfx/sdl-1.2/src/line.c3
-rw-r--r--src/gfx/sdl-1.2/src/quad.c7
-rw-r--r--src/gfx/sdl-1.2/src/rect.c6
-rw-r--r--src/gfx/sdl-1.2/src/sprite.c7
-rw-r--r--src/gui/src/bar.c22
-rw-r--r--src/gui/src/button_sprite.c9
-rw-r--r--src/gui/src/button_type1.c8
-rw-r--r--src/gui/src/line_edit.c24
-rw-r--r--src/gui/src/rounded_rect.c14
14 files changed, 117 insertions, 33 deletions
diff --git a/src/camera/src/camera.c b/src/camera/src/camera.c
index 81053fd..9d3d062 100644
--- a/src/camera/src/camera.c
+++ b/src/camera/src/camera.c
@@ -40,7 +40,10 @@ int cursor_render(const struct cursor *const c)
sprite_get_or_ret(s, -1);
if (sprite_clone(&cursor_sprite, s))
+ {
+ fprintf(stderr, "%s: sprite_clone failed\n", __func__);
return -1;
+ }
s->x = c->x;
s->y = c->y;
@@ -57,8 +60,12 @@ int cursor_render(const struct cursor *const c)
break;
}
- sprite_sort(s);
- return 0;
+ const int ret = sprite_sort(s);
+
+ if (ret)
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+
+ return ret;
}
void cursor_init(struct cursor *const c)
diff --git a/src/font/src/font.c b/src/font/src/font.c
index ab6865a..482acaa 100644
--- a/src/font/src/font.c
+++ b/src/font/src/font.c
@@ -86,7 +86,12 @@ static int renderstr(const enum font f, const short x, short y,
s->v += v;
s->x = rx;
s->y = y;
- sprite_sort(s);
+
+ if (sprite_sort(s))
+ {
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+ return -1;
+ }
}
rx += cfg->fs;
diff --git a/src/gfx/inc/gfx.h b/src/gfx/inc/gfx.h
index a6a16bc..99deeeb 100644
--- a/src/gfx/inc/gfx.h
+++ b/src/gfx/inc/gfx.h
@@ -17,14 +17,14 @@ int gfx_set_fullscreen(short w, short h);
bool gfx_fullscreen_available(void);
bool gfx_fullscreen(void);
int gfx_display_size(short *w, short *h);
-void sprite_sort(struct sprite *s);
+int sprite_sort(struct sprite *s);
int sprite_clone(const struct sprite *src, struct sprite *dst);
void rect_init(struct rect *r);
void semitrans_rect_init(struct rect *r);
void stp_4line_init(struct stp_4line *l);
-void quad_sort(struct quad *q);
-void rect_sort(struct rect *r);
-void stp_4line_sort(struct stp_4line *l);
+int quad_sort(struct quad *q);
+int rect_sort(struct rect *r);
+int stp_4line_sort(struct stp_4line *l);
int sprite_from_fp(struct sprite *s, FILE *f);
int quad_from_sprite(const struct sprite *s, struct quad *q);
bool gfx_inside_drawenv(short x, short y, short w, short h);
diff --git a/src/gfx/ps1/src/sort.c b/src/gfx/ps1/src/sort.c
index c517b89..3f949be 100644
--- a/src/gfx/ps1/src/sort.c
+++ b/src/gfx/ps1/src/sort.c
@@ -19,24 +19,28 @@ static void add_to_list(union gfx_sznext *const p)
last = p;
}
-void sprite_sort(struct sprite *const s)
+int sprite_sort(struct sprite *const s)
{
add_to_list(&s->sznext);
+ return 0;
}
-void quad_sort(struct quad *const q)
+int quad_sort(struct quad *const q)
{
add_to_list(&q->sznext);
+ return 0;
}
-void rect_sort(struct rect *const r)
+int rect_sort(struct rect *const r)
{
add_to_list(&r->sznext);
+ return 0;
}
-void stp_4line_sort(struct stp_4line *const l)
+int stp_4line_sort(struct stp_4line *const l)
{
add_to_list(&l->sznext);
+ return 0;
}
static void gfx_sync(void)
diff --git a/src/gfx/sdl-1.2/src/env.c b/src/gfx/sdl-1.2/src/env.c
index 734fe5b..c1376c5 100644
--- a/src/gfx/sdl-1.2/src/env.c
+++ b/src/gfx/sdl-1.2/src/env.c
@@ -98,7 +98,10 @@ static int resize_screen(int w, int h, const bool full_screen)
for (size_t i = 0; i < list_len; i++)
if (sprite_screen_resize_ev(list[i]))
+ {
+ fprintf(stderr, "%s: sprite_screen_resize_ev failed\n", __func__);
return -1;
+ }
screen_w = w;
screen_h = h;
@@ -152,14 +155,16 @@ static int get_resize_events(void)
const SDL_ResizeEvent *const res = &ev.resize;
if (resize_screen(res->w, res->h, false))
+ {
+ fprintf(stderr, "%s: resize_screen failed\n", __func__);
return -1;
+ }
}
}
if (n < 0)
{
- fprintf(stderr, "%s: SDL_PeepEvents: %s\n",
- __func__, SDL_GetError());
+ fprintf(stderr, "%s: SDL_PeepEvents: %s\n", __func__, SDL_GetError());
return -1;
}
@@ -208,6 +213,5 @@ int gfx_draw(void)
return -1;
}
- get_resize_events();
- return 0;
+ return get_resize_events();
}
diff --git a/src/gfx/sdl-1.2/src/line.c b/src/gfx/sdl-1.2/src/line.c
index 3886204..7788acf 100644
--- a/src/gfx/sdl-1.2/src/line.c
+++ b/src/gfx/sdl-1.2/src/line.c
@@ -11,6 +11,7 @@ void semitrans_stp_4line_init(struct stp_4line *r)
{
}
-void stp_4line_sort(struct stp_4line *const r)
+int stp_4line_sort(struct stp_4line *const r)
{
+ return 0;
}
diff --git a/src/gfx/sdl-1.2/src/quad.c b/src/gfx/sdl-1.2/src/quad.c
index 0bdead6..f57ff9e 100644
--- a/src/gfx/sdl-1.2/src/quad.c
+++ b/src/gfx/sdl-1.2/src/quad.c
@@ -17,7 +17,7 @@ int quad_from_sprite(const struct sprite *const s, struct quad *const q)
return 0;
}
-void quad_sort(struct quad *const q)
+int quad_sort(struct quad *const q)
{
const bool xflip = q->x0 > q->x1;
@@ -40,5 +40,10 @@ void quad_sort(struct quad *const q)
SDL_Surface *const s = xflip ? q->s_x : q->s;
if (SDL_BlitSurface(s, &clip, gfx_screen(), &r))
+ {
fprintf(stderr, "SDL_BlitSurface: %s\n", SDL_GetError());
+ return -1;
+ }
+
+ return 0;
}
diff --git a/src/gfx/sdl-1.2/src/rect.c b/src/gfx/sdl-1.2/src/rect.c
index bf4b54d..0998cb5 100644
--- a/src/gfx/sdl-1.2/src/rect.c
+++ b/src/gfx/sdl-1.2/src/rect.c
@@ -3,7 +3,7 @@
#include <sdl-1.2/gfx_private.h>
#include <SDL.h>
-void rect_sort(struct rect *const r)
+int rect_sort(struct rect *const r)
{
SDL_Rect rct =
{
@@ -19,8 +19,10 @@ void rect_sort(struct rect *const r)
if (SDL_FillRect(screen, &rct, map))
{
fprintf(stderr, "SDL_FillRect: %s\n", SDL_GetError());
- return;
+ return -1;
}
+
+ return 0;
}
void rect_init(struct rect *const r)
diff --git a/src/gfx/sdl-1.2/src/sprite.c b/src/gfx/sdl-1.2/src/sprite.c
index d4921ca..80da9ab 100644
--- a/src/gfx/sdl-1.2/src/sprite.c
+++ b/src/gfx/sdl-1.2/src/sprite.c
@@ -126,7 +126,7 @@ int sprite_from_fp(struct sprite *const s, FILE *const f)
return 0;
}
-void sprite_sort(struct sprite *const s)
+int sprite_sort(struct sprite *const s)
{
SDL_Rect r =
{
@@ -143,5 +143,10 @@ void sprite_sort(struct sprite *const s)
};
if (SDL_BlitSurface(s->s, &clip, gfx_screen(), &r))
+ {
fprintf(stderr, "SDL_BlitSurface: %s\n", SDL_GetError());
+ return -1;
+ }
+
+ return 0;
}
diff --git a/src/gui/src/bar.c b/src/gui/src/bar.c
index 25446e0..bd38cd6 100644
--- a/src/gui/src/bar.c
+++ b/src/gui/src/bar.c
@@ -15,8 +15,13 @@ static int render_topleft(const struct gui_bar *const b, const short x,
s->x = x;
s->y = y;
- sprite_sort(s);
- return 0;
+
+ const int ret = sprite_sort(s);
+
+ if (ret)
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+
+ return ret;
}
static int render_topright(const struct gui_bar *const b, const short x,
@@ -29,7 +34,12 @@ static int render_topright(const struct gui_bar *const b, const short x,
s->x = x + b->w - s->w;
s->y = y;
- sprite_sort(s);
+
+ const int ret = sprite_sort(s);
+
+ if (ret)
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+
return 0;
}
@@ -66,7 +76,11 @@ static int render_topmid(const struct gui_bar *const b, const short x,
else
m->w = mid_w;
- sprite_sort(m);
+ if (sprite_sort(m))
+ {
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+ return -1;
+ }
}
return 0;
diff --git a/src/gui/src/button_sprite.c b/src/gui/src/button_sprite.c
index 5bdc1b0..c98bdea 100644
--- a/src/gui/src/button_sprite.c
+++ b/src/gui/src/button_sprite.c
@@ -13,8 +13,13 @@ int gui_button_render_sprite(const struct gui_button *const b)
return -1;
gui_coords(&b->common, &s->x, &s->y);
- sprite_sort(s);
- return 0;
+
+ const int ret = sprite_sort(s);
+
+ if (ret)
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+
+ return ret;
}
void gui_button_get_dim_sprite(const struct gui_button *const b,
diff --git a/src/gui/src/button_type1.c b/src/gui/src/button_type1.c
index f07f2f3..da59d8b 100644
--- a/src/gui/src/button_type1.c
+++ b/src/gui/src/button_type1.c
@@ -19,7 +19,13 @@ static int render_left(const struct gui_button *const b,
s->x = *x;
s->y = y;
- sprite_sort(s);
+
+ if (sprite_sort(s))
+ {
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+ return -1;
+ }
+
*x = s->x + s->w;
return 0;
}
diff --git a/src/gui/src/line_edit.c b/src/gui/src/line_edit.c
index df52fd0..a7d56c8 100644
--- a/src/gui/src/line_edit.c
+++ b/src/gui/src/line_edit.c
@@ -26,7 +26,13 @@ static int render_left(const struct gui_line_edit *const l,
s->x = *x;
s->y = y;
- sprite_sort(s);
+
+ if (sprite_sort(s))
+ {
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+ return -1;
+ }
+
*x = s->x + s->w;
return 0;
}
@@ -66,7 +72,12 @@ static int render_mid(const struct gui_line_edit *const l,
else
m->w = mid_w;
- sprite_sort(m);
+ if (sprite_sort(m))
+ {
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+ return -1;
+ }
+
*x += m->w;
}
}
@@ -85,8 +96,13 @@ static int render_right(const short x, const short y)
s->x = x;
s->y = y;
- sprite_sort(s);
- return 0;
+
+ const int ret = sprite_sort(s);
+
+ if (ret)
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+
+ return ret;
}
static int render(const struct gui_common *const g)
diff --git a/src/gui/src/rounded_rect.c b/src/gui/src/rounded_rect.c
index b60a05a..4ae3780 100644
--- a/src/gui/src/rounded_rect.c
+++ b/src/gui/src/rounded_rect.c
@@ -19,7 +19,12 @@ static int render_top(const struct gui_rounded_rect *const r,
left->x = x;
left->y = y;
- sprite_sort(left);
+
+ if (sprite_sort(left))
+ {
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+ return -1;
+ }
}
{
@@ -33,7 +38,12 @@ static int render_top(const struct gui_rounded_rect *const r,
right->x = x + r->w - ref->w;
right->y = y;
- sprite_sort(right);
+
+ if (sprite_sort(right))
+ {
+ fprintf(stderr, "%s: sprite_sort failed\n", __func__);
+ return -1;
+ }
}
return 0;