From 98f0d3e026f978d556cc91cfaa815d92a0b182c8 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Tue, 8 Feb 2022 15:39:56 +0100 Subject: Replace x_get functions with macros The PS1 port relies on a heap for primitives since the GPU renders the scene asynchronously. However, SDL-based platforms render primitives synchronously, so structures can be allocated on the stack instead. --- src/instance/src/instance.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/instance') diff --git a/src/instance/src/instance.c b/src/instance/src/instance.c index 03f4872..7fcd9b4 100644 --- a/src/instance/src/instance.c +++ b/src/instance/src/instance.c @@ -34,13 +34,10 @@ void instance_cyclic(void) static int draw_sel(const struct instance *const i, const short x, const short y) { - struct stp_4line *const l = stp_4line_get(); - - if (!l) - return -1; - enum {R = 0, G = 255, B = 0}; + stp_4line_get_or_ret(l, -1); + stp_4line_init(l); l->x = l->vertices[2].x = l->vertices[3].x = x; l->y = l->vertices[0].y = l->vertices[3].y = y; l->vertices[0].x = l->vertices[1].x = x + i->r.w; @@ -60,12 +57,7 @@ static int draw_sel(const struct instance *const i, const short x, const short y l->vertices[0].g = l->vertices[2].g = UCHAR_MAX - line_g; l->vertices[1].g = l->vertices[3].g = line_g; stp_4line_sort(l); - - struct stp_4line *const ll = stp_4line_get(); - - if (!ll) - return -1; - + stp_4line_get_or_ret(ll, -1); *ll = *l; ll->x = ll->vertices[2].x = ll->vertices[3].x = l->x ? l->x - 1 : 0; ll->y = ll->vertices[0].y = ll->vertices[3].y = l->y ? l->y - 1 : 0; -- cgit v1.2.3