diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-02-08 15:39:56 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-03-30 08:20:21 +0200 |
| commit | 3d90015c627f05edd32260758581a0e11c269948 (patch) | |
| tree | cef420e393d030cebc4f0b4870b6107fe972acab /src/instance | |
| parent | df2ecf50e0679f7792f0d356de51d16b56049110 (diff) | |
| download | rts-3d90015c627f05edd32260758581a0e11c269948.tar.gz | |
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.
Diffstat (limited to 'src/instance')
| -rw-r--r-- | src/instance/src/instance.c | 14 |
1 files changed, 3 insertions, 11 deletions
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; |
