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 | 98f0d3e026f978d556cc91cfaa815d92a0b182c8 (patch) | |
| tree | bd9f39354da8fcbed0453bf45152c39e803abbf6 /src/gfx/sdl-1.2 | |
| parent | 56286a0a962119ddebf26df58d4a7c5d2f6a3fc7 (diff) | |
| download | jancity-98f0d3e026f978d556cc91cfaa815d92a0b182c8.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/gfx/sdl-1.2')
| -rw-r--r-- | src/gfx/sdl-1.2/inc/gfx/port.h | 3 | ||||
| -rw-r--r-- | src/gfx/sdl-1.2/src/heap.c | 11 | ||||
| -rw-r--r-- | src/gfx/sdl-1.2/src/sort.c | 22 |
3 files changed, 2 insertions, 34 deletions
diff --git a/src/gfx/sdl-1.2/inc/gfx/port.h b/src/gfx/sdl-1.2/inc/gfx/port.h index ec1093e..3dbc23b 100644 --- a/src/gfx/sdl-1.2/inc/gfx/port.h +++ b/src/gfx/sdl-1.2/inc/gfx/port.h @@ -43,7 +43,8 @@ struct stp_4line } vertices[4]; }; -SDL_Surface *gfx_port_screen(void); +#define common_get_or_ret(t, x, ret) \ + struct t x##__, *const x = &x##__ #ifdef __cplusplus } diff --git a/src/gfx/sdl-1.2/src/heap.c b/src/gfx/sdl-1.2/src/heap.c deleted file mode 100644 index b84760a..0000000 --- a/src/gfx/sdl-1.2/src/heap.c +++ /dev/null @@ -1,11 +0,0 @@ -#include <gfx.h> -#include <gfx_private.h> -#include <stddef.h> - -void *gfx_port_heap(size_t *const n) -{ - static char heap[5120]; - - *n = sizeof heap / sizeof *heap; - return heap; -} diff --git a/src/gfx/sdl-1.2/src/sort.c b/src/gfx/sdl-1.2/src/sort.c deleted file mode 100644 index 2cc4e75..0000000 --- a/src/gfx/sdl-1.2/src/sort.c +++ /dev/null @@ -1,22 +0,0 @@ -#include <gfx.h> -#include <gfx_private.h> -#include <gfx/port.h> -#include <SDL/SDL.h> -#include <stdio.h> - -void gfx_draw(void) -{ - enum {FPS = 50, REFRESH_MS = 1000 / FPS}; - static Uint32 prev; - const Uint32 cur = SDL_GetTicks(); - - if (cur - prev < REFRESH_MS) - SDL_Delay(REFRESH_MS - (cur - prev)); - - prev = SDL_GetTicks(); - - if (SDL_Flip(gfx_port_screen())) - fprintf(stderr, "SDL_Flip: %s\n", SDL_GetError()); - - gfx_reset_heap(); -} |
