Loading [MathJax]/extensions/MathMenu.js
Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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 VERSION_GCN_USA 0
7#define VERSION_GCN_PAL 1
8#define VERSION_GCN_JPN 2
9#define VERSION_SHIELD_DEBUG 3
10
11#define ALIGN_DECL(ALIGNMENT) __attribute__((aligned(ALIGNMENT)))
12
13#define ARRAY_SIZE(o) (sizeof((o)) / sizeof(*(o)))
14
15// Align X to the previous N bytes (N must be power of two)
16#define ALIGN_PREV(X, N) ((X) & ~((N)-1))
17// Align X to the next N bytes (N must be power of two)
18#define ALIGN_NEXT(X, N) ALIGN_PREV(((X) + (N)-1), N)
19#define IS_ALIGNED(X, N) (((X) & ((N)-1)) == 0)
20#define IS_NOT_ALIGNED(X, N) (((X) & ((N)-1)) != 0)
21
22#define ROUND(n, a) (((u32)(n) + (a)-1) & ~((a)-1))
23#define TRUNC(n, a) (((u32)(n)) & ~((a)-1))
24
25#define JUT_EXPECT(...)
26#define FLAG_ON(V, F) (((V) & (F)) == 0)
27
28#define FLOAT_LABEL(x) (*(f32*)&x)
29#define DOUBLE_LABEL(x) (*(f64*)&x)
30
31#define _SDA_BASE_(dummy) 0
32#define _SDA2_BASE_(dummy) 0
33
34#ifdef __MWERKS__
35#define GLUE(a, b) a##b
36#define GLUE2(a, b) GLUE(a, b)
37
38#if VERSION != VERSION_SHIELD_DEBUG
39#define STATIC_ASSERT(cond) typedef char GLUE2(static_assertion_failed, __LINE__)[(cond) ? 1 : -1]
40#else
41#define STATIC_ASSERT(...)
42#endif
43#else
44#define STATIC_ASSERT(...)
45#endif
46
47// hack to make functions that return comparisons as int match
48extern int __cntlzw(unsigned int);
49inline BOOL checkEqual(s32 a, s32 b) {
50 return (u32)__cntlzw(a - b) >> 5;
51}
52
53#ifndef __MWERKS__
54void* __memcpy(void*, const void*, int);
55#endif
56
57#define FAST_DIV(x, n) (x >> (n / 2))
58
59#define SQUARE(x) ((x) * (x))
60
61// hack to make strings with no references compile properly
62#define DEAD_STRING(s) OSReport(s)
63
64#define UNK_BSS(name) \
65 static u8 lit_##name[1 + 3 /* padding */];
66
67#define UNK_REL_BSS \
68 static u8 lit_1109[1]; \
69 static u8 lit_1107[1]; \
70 static u8 lit_1105[1]; \
71 static u8 lit_1104[1]; \
72 static u8 lit_1099[1]; \
73 static u8 lit_1097[1]; \
74 static u8 lit_1095[1]; \
75 static u8 lit_1094[1]; \
76 static u8 lit_1057[1]; \
77 static u8 lit_1055[1]; \
78 static u8 lit_1053[1]; \
79 static u8 lit_1052[1]; \
80 static u8 lit_1014[1]; \
81 static u8 lit_1012[1]; \
82 static u8 lit_1010[1]; \
83 static u8 lit_1009[1];
84
85
86#define UNK_REL_DATA \
87 static u8 cNullVec__6Z2Calc[12] = { \
88 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
89 }; \
90 static u32 lit_1787[1 + 4 /* padding */] = { \
91 0x02000201, \
92 0x40080000, \
93 0x00000000, \
94 0x3FE00000, \
95 0x00000000, \
96 };
97
98#define READU32_BE(ptr, offset) \
99 (((u32)ptr[offset] << 24) | ((u32)ptr[offset + 1] << 16) | ((u32)ptr[offset + 2] << 8) | (u32)ptr[offset + 3]);
100
101#endif
BOOL checkEqual(s32 a, s32 b)
Definition global.h:49
int __cntlzw(unsigned int)
void * __memcpy(void *, const void *, int)
a
Definition k_cos.c:89
int BOOL
Definition types.h:30
unsigned long u32
Definition types.h:9
signed long s32
Definition types.h:8