From af44828a9b1b85611a817afb3626f594cce9e59d Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 14 Dec 2022 22:32:50 +0100 Subject: [PATCH] Use base.h as general mother-of-all-dependencies --- src/base.h | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/base.h b/src/base.h index 49245ce..47a6eca 100644 --- a/src/base.h +++ b/src/base.h @@ -60,9 +60,10 @@ #define staticni ORCA_NOINLINE static -#define ORCA_Y_MAX UINT16_MAX -#define ORCA_X_MAX UINT16_MAX +//---------------------------------------------------------------------------------------- +// Types +//---------------------------------------------------------------------------------------- typedef uint8_t U8; typedef int8_t I8; typedef uint16_t U16; @@ -77,11 +78,24 @@ typedef ssize_t Isz; typedef char Glyph; typedef U8 Mark; +//---------------------------------------------------------------------------------------- +// Constants +//---------------------------------------------------------------------------------------- +#define ORCA_Y_MAX UINT16_MAX +#define ORCA_X_MAX UINT16_MAX + enum { Hud_height = 2 }; + + + +//---------------------------------------------------------------------------------------- +// Utils +//---------------------------------------------------------------------------------------- + ORCA_FORCEINLINE static Usz orca_round_up_power2(Usz x) { assert(x <= SIZE_MAX / 2 + 1); @@ -127,6 +141,16 @@ static ORCA_FORCEINLINE double ms_to_sec(double ms) } +staticni bool str_to_int(char const *str, int *out) +{ + int a; + int res = sscanf(str, "%d", &a); + if (res != 1) + return false; + *out = a; + return true; +} + // Reads something like '5x3' or '5'. Writes the same value to both outputs if // only one is specified. Returns false on error. staticni bool read_nxn_or_n(char const *str, int *out_a, int *out_b) @@ -147,3 +171,4 @@ staticni bool read_nxn_or_n(char const *str, int *out_a, int *out_b) } return false; } +