2022-01-01 17:45:41 +00:00
|
|
|
#ifndef COMMON_H
|
|
|
|
#define COMMON_H
|
|
|
|
|
|
|
|
#include "include_asm.h"
|
2022-10-15 22:17:26 +00:00
|
|
|
#include "macros.h"
|
2023-05-09 11:49:20 +00:00
|
|
|
#include "settings.h"
|
2022-01-01 17:45:41 +00:00
|
|
|
#include "types.h"
|
|
|
|
|
2023-05-04 22:32:35 +00:00
|
|
|
#if defined(_internal_version_us)
|
|
|
|
#define VERSION_US
|
2023-06-12 18:59:48 +00:00
|
|
|
#define VERSION "us"
|
2023-05-04 22:32:35 +00:00
|
|
|
#elif defined(_internal_version_hd)
|
|
|
|
#define VERSION_HD
|
2023-06-12 18:59:48 +00:00
|
|
|
#define VERSION "hd"
|
2023-08-31 21:55:23 +00:00
|
|
|
#elif defined(_internal_version_beta)
|
|
|
|
#define VERSION_BETA
|
|
|
|
#define VERSION "beta"
|
2023-05-04 22:32:35 +00:00
|
|
|
#else
|
|
|
|
#warning "Version not specified. Falling back to the US version."
|
|
|
|
#define VERSION_US
|
2023-06-12 18:59:48 +00:00
|
|
|
#define VERSION "us"
|
2023-05-04 22:32:35 +00:00
|
|
|
#endif
|
|
|
|
|
2023-03-24 12:42:41 +00:00
|
|
|
#define LEN(x) ((s32)(sizeof(x) / sizeof(*(x))))
|
|
|
|
#define LENU(x) ((u32)(sizeof(x) / sizeof(*(x))))
|
2023-03-28 12:14:13 +00:00
|
|
|
#define STRCPY(dst, src) __builtin_memcpy(dst, src, sizeof(src))
|
2023-03-24 12:29:18 +00:00
|
|
|
|
2023-03-04 01:26:05 +00:00
|
|
|
#define LOH(x) (*(s16*)&(x))
|
2023-07-06 11:20:53 +00:00
|
|
|
#define LOHU(x) (*(u16*)&(x))
|
2023-05-27 10:13:49 +00:00
|
|
|
#define LOW(x) (*(s32*)&(x))
|
2023-07-06 11:20:53 +00:00
|
|
|
#define LOWU(x) (*(u32*)&(x))
|
2023-05-27 10:13:49 +00:00
|
|
|
|
2023-03-13 01:43:07 +00:00
|
|
|
#if defined(HACKS) && !defined(PERMUTER)
|
2023-03-12 00:13:28 +00:00
|
|
|
#define ALIGNED4 __attribute__((aligned(4)))
|
2023-03-12 00:11:04 +00:00
|
|
|
#else
|
|
|
|
#define ALIGNED4
|
|
|
|
#endif
|
2023-03-04 01:26:05 +00:00
|
|
|
|
2022-12-22 10:32:56 +00:00
|
|
|
int sprintf(char* dst, const char* fmt, ...);
|
|
|
|
|
2023-08-05 18:36:00 +00:00
|
|
|
#define FIX(x) ((s32)((x)*65536.0))
|
2023-08-08 17:12:53 +00:00
|
|
|
#define FIX_TO_I(x) ((s32)((x) >> 16))
|
2023-07-30 16:44:26 +00:00
|
|
|
|
2023-11-18 02:39:10 +00:00
|
|
|
// The second argument to CreateEntFactoryFromEntity has weird bit packing,
|
|
|
|
// this takes the 2 relevant inputs and packs them up.
|
|
|
|
// A0 should be a value like 0x##00 where ## is two hexadecimal digits.
|
|
|
|
// BLUEPRINTNUM is which blueprint gets loaded from g_FactoryBlueprints.
|
|
|
|
#define FACTORY(A0, BLUEPRINTNUM) (A0 << 8 | BLUEPRINTNUM)
|
2023-11-18 23:53:38 +00:00
|
|
|
// Tests multiple bits of x being set, based on the bitmask defined in y.
|
|
|
|
#define TEST_BITS(x, y) ((x & y) == y)
|
2023-11-18 02:39:10 +00:00
|
|
|
|
2023-10-09 23:05:57 +00:00
|
|
|
// PSX SDK libraries do not use float. Instead they use a fix-point number
|
|
|
|
// where 4096 is equal to 1.0.
|
|
|
|
#define FLT(x) ((s32)((x)*4096.0))
|
|
|
|
|
2022-01-01 17:45:41 +00:00
|
|
|
#endif
|