Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
global.h
Go to the documentation of this file.
1#ifndef _global_h_
2#define _global_h_
3
4#include "dolphin/types.h"
5
6#define ARRAY_SIZE(o) (sizeof((o)) / sizeof(*(o)))
7
8// Align X to the previous N bytes (N must be power of two)
9#define ALIGN_PREV(X, N) ((X) & ~((N)-1))
10// Align X to the next N bytes (N must be power of two)
11#define ALIGN_NEXT(X, N) ALIGN_PREV(((X) + (N)-1), N)
12#define IS_ALIGNED(X, N) (((X) & ((N)-1)) == 0)
13#define IS_NOT_ALIGNED(X, N) (((X) & ((N)-1)) != 0)
14
15#define ROUND(n, a) (((u32)(n) + (a)-1) & ~((a)-1))
16#define TRUNC(n, a) (((u32)(n)) & ~((a)-1))
17
18#define JUT_EXPECT(...)
19#define FLAG_ON(V, F) (((V) & (F)) == 0)
20
21#define FLOAT_LABEL(x) (*(f32*)&x)
22#define DOUBLE_LABEL(x) (*(f64*)&x)
23
24#define _SDA_BASE_(dummy) 0
25#define _SDA2_BASE_(dummy) 0
26
27#ifdef __MWERKS__
28#define GLUE(a, b) a##b
29#define GLUE2(a, b) GLUE(a, b)
30#define STATIC_ASSERT(cond) typedef char GLUE2(static_assertion_failed, __LINE__)[(cond) ? 1 : -1]
31#else
32#define STATIC_ASSERT(...)
33#endif
34
35// hack to make functions that return comparisons as int match
36extern int __cntlzw(unsigned int);
37inline BOOL checkEqual(s32 a, s32 b) {
38 return (u32)__cntlzw(a - b) >> 5;
39}
40
41#define FAST_DIV(x, n) (x >> (n / 2))
42
43// hack to make strings with no references compile properly
44#define DEAD_STRING(s) OSReport(s)
45
46#define UNK_BSS(name) \
47 static u8 lit_##name[1 + 3 /* padding */];
48
49#define UNK_REL_DATA \
50 static u8 cNullVec__6Z2Calc[12] = { \
51 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
52 }; \
53 static u32 lit_1787[1 + 4 /* padding */] = { \
54 0x02000201, \
55 0x40080000, \
56 0x00000000, \
57 0x3FE00000, \
58 0x00000000, \
59 };
60
61#endif
BOOL checkEqual(s32 a, s32 b)
Definition global.h:37
int __cntlzw(unsigned int)
a
Definition k_cos.c:89
int BOOL
Definition types.h:27
unsigned long u32
Definition types.h:10
signed long s32
Definition types.h:6