Paper Mario DX
Paper Mario (N64) modding
Loading...
Searching...
No Matches
macros.h
Go to the documentation of this file.
1
#ifndef _MACROS_H_
2
#define _MACROS_H_
3
4
#include "
types.h
"
5
#include "
include_asm.h
"
6
7
#define BSS __attribute__ ((nocommon, section (".bss")))
8
#define TRANSPARENT_UNION __attribute__ ((__transparent_union__))
9
10
#define ALIGNED(x) __attribute__((aligned(x)))
11
12
#ifndef BBPLAYER
13
# define OSALIGNED(x) ALIGNED(x)
14
#else
15
# define OSALIGNED(x)
16
#endif
17
18
# define BBALIGNED(x) ALIGNED(x)
19
20
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
21
#define ALIGN8(val) (((val) + 0x7) & ~0x7)
22
23
#ifdef _LANGUAGE_C_PLUS_PLUS
24
#define EXTERN_C extern "C"
25
#else
26
#define EXTERN_C extern
27
#endif
28
29
#define NAME_SUFFIX
30
#define NAME_PREFIX
31
#ifdef _LANGUAGE_C_PLUS_PLUS
32
// use C++ namespaces instead of these macros!
33
#define A(sym) sym
34
#define N(sym) sym
35
#else
36
#define A(sym) NS(AREA, NAME_PREFIX, sym, NAME_SUFFIX)
37
#define N(sym) NS(NAMESPACE, NAME_PREFIX, sym, NAME_SUFFIX)
38
#endif
39
40
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
41
42
#define PTR_LIST_END ((void*) -1)
43
44
#define API_CALLABLE(name) ApiStatus name(Evt* script, b32 isInitialCall)
45
46
#define PHYSICAL_TO_VIRTUAL(addr) (void*)((u32)(addr) + 0x80000000)
47
#define VIRTUAL_TO_PHYSICAL(addr) (u32)((u8*)(addr) - 0x80000000)
48
49
//#ifdef DEBUG
50
#define IS_DEBUG_PANIC(statement) is_debug_panic(statement)
51
/*#else
52
#define IS_DEBUG_PANIC(statement) do {} while(TRUE)
53
#endif*/
54
55
#define PANIC() IS_DEBUG_PANIC("Panic")
56
#define PANIC_MSG(msg, args...) \
57
do { \
58
char panicMsg[0x40]; \
59
sprintf(panicMsg, msg, ##args); \
60
IS_DEBUG_PANIC(msg); \
61
} while (0)
62
#define ASSERT(condition) \
63
if (!(condition)) { \
64
IS_DEBUG_PANIC("Assertion failed: " #condition); \
65
}
66
#define ASSERT_MSG(condition, msg, args...) \
67
if (!(condition)) { \
68
char assertMsg[0x40]; \
69
sprintf(assertMsg, msg, ##args); \
70
IS_DEBUG_PANIC(assertMsg); \
71
}
72
73
#define BADGE_MENU_PAGE(index) (&gPauseBadgesPages[index])
74
#define ITEM_MENU_PAGE(index) (&gPauseItemsPages[index])
75
76
#define MENU_PANEL_SELECTED_GRID_DATA(panel) \
77
(panel)->gridData[(panel)->state * (panel)->numCols * (panel)->numRows + \
78
(panel)->numCols * (panel)->row + \
79
(panel)->col]
80
81
#define MAX_MAPVARS 16
82
#define MAX_MAPFLAGS 3
83
#define MAX_ENEMY_ACTORS 24
84
85
#define MAX_ANIMATED_MODELS 16
86
#define MAX_ANIMATED_MESHES 16
87
#define MAX_ENTITY_MODELS 256
88
#define MAX_MODELS 256
89
#define MAX_MODEL_TRANSFORM_GROUPS 4
90
#define MAX_SCRIPTS 128
91
#define MAX_NPCS 64
92
#define MAX_TRIGGERS 64
93
#define MAX_SHADOWS 60
94
#define MAX_ENTITIES 30
95
#define MAX_WORKERS 16
96
#define MAX_TEX_PANNERS 16
97
#define MAX_ITEM_ENTITIES 256
98
#define MAX_IMGFX_INSTANCES 90
99
100
#define MAX_STAR_PIECES 222
101
102
#define SP_PER_BAR 256
103
#define SP_PER_SEG 32
104
105
#define SCREEN_WIDTH 320
106
#define SCREEN_HEIGHT 240
107
108
#define LAST_DEMO_SCENE_IDX 18
109
110
#define WORLD_ENTITY_HEAP_SIZE 0x17FF0
111
#define COLLISION_HEAP_SIZE 0x18000
112
#define GENERAL_HEAP_SIZE 0x54000
113
#define SPRITE_HEAP_SIZE 0x60000
114
#define BATTLE_HEAP_SIZE 0x25800
115
#define FRAME_BUFFER_SIZE 0x25800
116
117
#define CAM_NEAR_CLIP 16
118
#define CAM_FAR_CLIP 4096
119
120
// Size of tmem in bytes (4kB)
121
#define TMEM_SIZE 0x1000
122
// Height of tiles to use when copying fullscreen images (6)
123
#define SCREEN_COPY_TILE_HEIGHT ((TMEM_SIZE) / ((SCREEN_WIDTH) * (2)))
124
125
// Alternative to libultra's M_PI: non-float version; more digits cause issues
126
#define PI 3.141592f
127
#define PI_D 3.141592
128
#define TAU 6.28318f
129
#define PI_S 3.14159f
// Shorter PI
130
131
// Angle conversion macros
132
#define DEG_TO_BINANG(x) ((x) * (0x8000 / 180.0f))
133
#define RAD_TO_BINANG(x) ((x) * (f32)(0x8000 / M_PI))
134
#define DEG_TO_RAD(deg) (((deg) * TAU) / 360.0f)
135
136
// Should be 1.0f / 0x7FFF, but precision is wrong for a double
137
#define SHT_MINV 3.051851e-05
138
139
#define SPRITE_WORLD_SCALE_F (5.0f/7.0f)
140
#define SPRITE_WORLD_SCALE_D (5.0/7.0)
141
142
#define SPR_PAL_SIZE 16
143
144
#define BATTLE_ID_BIT 0x800
145
#define BATTLE_NPC_ID_BIT 0x800
146
#define BATTLE_ENTITY_ID_BIT 0x800
147
148
#define UNPACK_BTL_AREA(battleID) (((battleID) >> 8) & 0xFF)
149
#define UNPACK_BTL_INDEX(battleID) ((battleID) & 0xFF)
150
151
#define COLLISION_WITH_NPC_BIT 0x2000
152
#define COLLISION_WITH_ENTITY_BIT 0x4000
153
154
#define ENTITY_COLLIDER_ID(entityIndex) (entityIndex | COLLISION_WITH_ENTITY_BIT)
155
156
#define NO_COLLIDER -1
157
158
#define NPC_DISPOSE_LOCATION 0,-1000,0
159
#define NPC_DISPOSE_POS_X 0
160
#define NPC_DISPOSE_POS_Y -1000
161
#define NPC_DISPOSE_POS_Z 0
162
163
#define PACK_FILL_COLOR(r, g, b, a) (GPACK_RGBA5551(r, g, b, a) << 0x10) | GPACK_RGBA5551(r, g, b, a)
164
#define PACK_FILL_DEPTH(z,dz) (GPACK_ZDZ(z, dz) << 0x10) | GPACK_ZDZ(z, dz)
165
166
#define SQ(x) ((x) * (x))
167
#define CUBE(x) ((x) * (x) * (x))
168
#define QUART(x) ((x) * (x) * (x) * (x))
169
171
#define F16(f) (s16)(f * 327.67f)
172
174
#define X10(f) (s32)(f * 1024.0f)
175
176
#define _NS(w, x, y, z) w ## _ ## x ## y ## z
177
#define NS(w, x, y, z) _NS(w, x, y, z)
178
179
#define ASCII_TO_U32(a, b, c, d) ((u32)((a << 24) | (b << 16) | (c << 8) | (d << 0)))
180
181
#define ITEM_VIS_GROUP(itemID, visGroupID) ((visGroupID) << 16 | (itemID))
182
#define PACK_ROOM_FLAGS(itemVisGroup, roomFlags) ((itemVisGroup) << 12 | (roomFlags))
183
184
// loads integrator with standard parameter set used for falling
185
186
#define LOAD_INTEGRATOR_FALL(ptr) \
187
(ptr)[0] = 0.11430f; \
188
(ptr)[1] = -0.28710f; \
189
(ptr)[2] = -0.18230f; \
190
(ptr)[3] = 0.01152f; \
191
192
/* common AI function and script variables */
193
// ai script
194
#define AI_TEMP_STATE functionTemp[0]
195
#define AI_TEMP_STATE_AFTER_SUSPEND functionTemp[1]
196
#define AI_PATROL_GOAL_INDEX functionTemp[2]
197
// melee enemy
198
#define AI_VAR_ATTACK_STATE varTable[0]
199
#define AI_VAR_MELEE_PRE_TIME varTable[1]
200
#define AI_VAR_MELEE_HIT_TIME varTable[2]
201
#define AI_VAR_MELEE_MISS_TIME varTable[3]
202
#define AI_VAR_NEXT_STATE varTable[7]
203
// melee hitbox
204
#define AI_VAR_HITNPC_YOFFSET varTable[0]
205
#define AI_VAR_HITNPC_DIST varTable[1]
206
#define AI_VAR_HITNPC_2 varTable[2]
207
#define AI_VAR_HITNPC_3 varTable[3]
208
#define AI_VAR_HITNPC_4 varTable[4]
209
#define AI_VAR_HITNPC_SOUND varTable[15]
210
// projectile hitbox
211
#define VAR_PROJECTILE_HITBOX_STATE varTable[0]
212
#define AI_PROJECTILE_AMMO_COUNT varTable[3]
213
214
#define INTEGER_LOG2(x) ((x) <= 2 ? 1 : (x) <= 4 ? 2 : (x) <= 8 ? 3 : (x) <= 16 ? 4 : (x) <= 32 ? 5 : (x) <= 64 ? 6 : (x) <= 128 ? 7 : (x) <= 256 ? 8 : (x) <= 512 ? 9 : 10)
215
216
#define FOLIAGE_MODEL_LIST(names...) \
217
{ \
218
.count = __NARG__(names), \
219
.models = { names } \
220
}
221
222
#define STATUS_KEY_IGNORE_RES 0xFE
223
#define STATUS_KEY_NEVER 0xFF
224
#define DMG_STATUS_KEY(typeFlag, duration, chance) (STATUS_FLAG_80000000 | typeFlag | (duration << 8) | chance)
225
#define DMG_STATUS_ALWAYS(typeFlag, duration) (STATUS_FLAG_80000000 | STATUS_FLAG_RIGHT_ON | typeFlag | (duration << 8))
226
#define DMG_STATUS_IGNORE_RES(typeFlag, duration) (STATUS_KEY_IGNORE_RES | typeFlag | (duration << 8))
227
228
#define _RDP_WHOLE(x) (((s32)(x * 65536.0) >> 16) & 0xFFFF)
229
#define _RDP_FRAC(x) ((s32)(x * 65536.0) & 0xFFFF)
230
#define _RDP_PACK_WHOLE(a, b) (_RDP_WHOLE(a) << 16) | _RDP_WHOLE(b)
231
#define _RDP_PACK_FRAC(a, b) (_RDP_FRAC(a) << 16) | _RDP_FRAC(b)
232
233
#define RDP_MATRIX( \
234
Ax, Bx, Cx, Dx, \
235
Ay, By, Cy, Dy, \
236
Az, Bz, Cz, Dz, \
237
Aw, Bw, Cw, Dw ) \
238
{ \
239
.m = { \
240
{ \
241
_RDP_PACK_WHOLE(Ax, Ay), \
242
_RDP_PACK_WHOLE(Az, Aw), \
243
_RDP_PACK_WHOLE(Bx, By), \
244
_RDP_PACK_WHOLE(Bz, Bw), \
245
}, \
246
{ \
247
_RDP_PACK_WHOLE(Cx, Cy), \
248
_RDP_PACK_WHOLE(Cz, Cw), \
249
_RDP_PACK_WHOLE(Dx, Dy), \
250
_RDP_PACK_WHOLE(Dz, Dw), \
251
}, \
252
{ \
253
_RDP_PACK_FRAC(Ax, Ay), \
254
_RDP_PACK_FRAC(Az, Aw), \
255
_RDP_PACK_FRAC(Bx, By), \
256
_RDP_PACK_FRAC(Bz, Bw), \
257
}, \
258
{ \
259
_RDP_PACK_FRAC(Cx, Cy), \
260
_RDP_PACK_FRAC(Cz, Cw), \
261
_RDP_PACK_FRAC(Dx, Dy), \
262
_RDP_PACK_FRAC(Dz, Dw), \
263
} \
264
} \
265
};
266
267
#define UNPACK_PAL_R(color) (((color) >> 11) & 0x1F)
268
#define UNPACK_PAL_G(color) (((color) >> 6) & 0x1F)
269
#define UNPACK_PAL_B(color) (((color) >> 1) & 0x1F)
270
#define UNPACK_PAL_A(color) ((color) & 1)
271
272
#define PACK_PAL_RGBA(r, g, b, a) (((r) << 11) | ((g) << 6) | ((b) << 1) | (a));
273
274
#define PM_RM_SHROUD GBL_c1(G_BL_CLR_BL, G_BL_A_FOG, G_BL_CLR_IN, G_BL_1MA)
275
276
#define PM_CC_01 0, 0, 0, TEXEL0, PRIMITIVE, 0, TEXEL0, 0
277
#define PM_CC_02 0, 0, 0, TEXEL0, TEXEL0, 0, PRIMITIVE, 0
278
#define PM_CC_03 TEXEL0, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0
279
#define PM_CC_04 PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0
280
#define PM_CC_05 TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0
281
#define PM_CC_06 COMBINED, 0, PRIMITIVE_ALPHA, 0, 0, 0, 0, COMBINED
282
#define PM_CC_07 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0
283
#define PM_CC_PRIM_FULL_ALPHA 0, 0, 0, PRIMITIVE, 0, 0, 0, 1
284
#define PM_CC_PRIM_NO_ALPHA 0, 0, 0, PRIMITIVE, 0, 0, 0, 0
285
#define PM_CC_0A 0, 0, 0, 0, ENVIRONMENT, 0, TEXEL0, 0
286
287
#define PM_CC_0B 0, 0, 0, 0, ENVIRONMENT, 0, TEXEL1, 0
288
#define PM_CC_0D 0, 0, 0, 0, SHADE, 0, TEXEL1, 0
289
#define PM_CC_0C 0, 0, 0, 0, 0, 0, 0, COMBINED
290
291
#define PM_CC_0E 0, 0, 0, TEXEL0, 0, 0, 0, 0
292
#define PM_CC_0F 0, 0, 0, TEXEL0, 0, 0, 0, 1
293
#define PM_CC_10 0, 0, 0, TEXEL0, 0, 0, 0, PRIMITIVE
294
#define PM_CC_11 0, 0, 0, TEXEL0, SHADE, 0, TEXEL0, 0
295
#define PM_CC_12 0, 0, 0, TEXEL0, TEXEL0, 0, SHADE, 0
296
297
#define PM_CC_MSG_UP_ARROW \
298
TEXEL0, 0, PRIMITIVE, 0, \
299
0, 0, 0, TEXEL1
300
301
#define PM_CC_14 PRIMITIVE, ENVIRONMENT, TEXEL1, ENVIRONMENT, PRIMITIVE, 0, TEXEL1, 0
302
#define PM_CC_15 PRIMITIVE, ENVIRONMENT, TEXEL1, ENVIRONMENT, 0, 0, 0, TEXEL1
303
304
// multiply the combined color from cycle1 with PRIMITIVE color; PRIMITIVE alpha is ignored
305
#define PM_CC2_MULTIPLY_PRIM COMBINED, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED
306
307
// multiply the combined color from cycle1 with SHADE color; SHADE alpha is ignored
308
#define PM_CC2_MULTIPLY_SHADE COMBINED, 0, SHADE, 0, 0, 0, 0, COMBINED
309
310
#define PM_CC_NOISE NOISE, 0, SHADE_ALPHA, 0, 0, 0, 0, 1
311
312
#define PM_CC_1A TEXEL0, 0, PRIMITIVE_ALPHA, PRIMITIVE, 0, 0, 0, TEXEL0
313
314
// implements ENV_TINT_DEPTH for untextured models
315
// applies just the base color; depth-based fog color will be added during RDP blend step
316
// color = SHADE * PRIM_ALPHA + PRIM
317
// alpha = SHADE
318
#define PM_CC_TINT_DEPTH_NOTEX \
319
SHADE, 0, PRIMITIVE_ALPHA, PRIMITIVE, \
320
0, 0, 0, SHADE
321
322
// implements ENV_TINT_DEPTH for single-textured or mipmaped models
323
// applies just the base color; depth-based fog color will be added during RDP blend step
324
// color = COMB * PRIM_ALPHA + PRIM
325
// alpha = COMB
326
#define PM_CC_TINT_DEPTH_NO_SHADE \
327
COMBINED, 0, PRIMITIVE_ALPHA, PRIMITIVE, \
328
0, 0, 0, COMBINED
329
330
// color = (COMB - PRIM) * PRIM_ALPHA + COMB
331
// alpha = COMB
332
#define PM_CC_20 \
333
COMBINED, PRIMITIVE, PRIMITIVE_ALPHA, COMBINED, \
334
0, 0, 0, COMBINED
335
336
#define PM_CC_TINT_DEPTH_MIPMAPS \
337
COMBINED, 0, SHADE, PRIMITIVE, \
338
0, 0, 0, COMBINED
339
340
// implements ENV_TINT_REMAP for untextured models
341
// color = SHADE * PRIM + ENV
342
// alpha = SHADE
343
#define PM_CC_TINT_REMAP_NOTEX \
344
SHADE, 0, PRIMITIVE, ENVIRONMENT, \
345
0, 0, 0, SHADE
346
347
// implements ENV_TINT_REMAP for single-textured or mipmaped models
348
// NOTE: SHADE color is not used
349
// color = COMB * PRIM + ENV
350
// alpha = COMB
351
#define PM_CC_TINT_REMAP_NO_SHADE \
352
COMBINED, 0, PRIMITIVE, ENVIRONMENT, \
353
0, 0, 0, COMBINED
354
355
// implements ENV_TINT_REMAP for multi-textured models
356
// only SHADE alpha is used
357
// color = COMB * PRIM + ENV
358
// alpha = COMB * SHADE
359
#define PM_CC_TINT_REMAP_SHADE_ALPHA \
360
COMBINED, 0, PRIMITIVE, ENVIRONMENT, \
361
COMBINED, 0, SHADE, 0
362
363
#define PM_CC_22 TEXEL0, TEXEL1, SHADE_ALPHA, TEXEL1, 0, 0, 0, TEXEL0
364
#define PM_CC_23 1, TEXEL0, PRIMITIVE, TEXEL0, 0, 0, 0, TEXEL0
365
#define PM_CC1_24 1, TEXEL0, PRIMITIVE, TEXEL0, 1, TEXEL0, TEXEL1, TEXEL0
366
#define PM_CC2_24 1, TEXEL1, TEXEL0, COMBINED, 0, 0, 0, COMBINED
367
368
#define PM_CC_TEX_COMBINE_3A 0, 0, 0, 0, TEXEL0, TEXEL1, SHADE, 0
369
#define PM_CC_TEX_COMBINE_3B 0, 0, 0, SHADE, 0, 0, 0, COMBINED
370
#define PM_CC_TEX_COMBINE_3C SHADE, 0, PRIMITIVE, ENVIRONMENT, 0, 0, 0, COMBINED
371
372
#define PM_CC1_29 TEXEL0, SHADE, TEXEL0, TEXEL0, 1, TEXEL1, TEXEL0, TEXEL1
373
#define PM_CC2_29 TEXEL0, COMBINED, TEXEL0_ALPHA, TEXEL0, 1, TEXEL0, TEXEL1, TEXEL0
374
375
// same as G_CC_INTERFERENCE, except the roles of TEXEL0 and TEXEL1 are swapped
376
#define PM_CC_ALT_INTERFERENCE \
377
TEXEL1, 0, TEXEL0, 0, \
378
TEXEL1, 0, TEXEL0, 0
379
380
#define PM_CC_2B PRIMITIVE, 0, TEXEL1, 0, 0, 0, 0, TEXEL1
381
#define PM_CC_2C PRIMITIVE, 0, TEXEL1, 0, TEXEL1, 0, PRIMITIVE, 0
382
#define PM_CC_2D PRIMITIVE, 0, TEXEL0, 0, 0, 0, 0, TEXEL0
383
#define PM_CC_2E 0, 0, 0, TEXEL0, TEXEL1, 0, PRIMITIVE, 0
384
#define PM_CC_2F PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0
385
#define PM_CC_32 PRIMITIVE, 0, TEXEL0, 0, TEXEL0, 0, PRIMITIVE, 0
386
387
#define PM_CC_33 ENVIRONMENT, PRIMITIVE, COMBINED, PRIMITIVE, COMBINED, 0, PRIMITIVE, 0
388
389
#define PM_CC_34 TEXEL0, CENTER, SCALE, ENVIRONMENT, 0, 0, 0, TEXEL0
390
#define PM_CC_35 0, PRIMITIVE, COMBINED, ENVIRONMENT, 0, 0, 0, COMBINED
391
392
#define PM_CC_36 TEXEL0, TEXEL1, TEXEL0, TEXEL1, 1, TEXEL0, TEXEL1, 1
393
#define PM_CC_37 0, 0, 0, COMBINED, COMBINED, TEXEL1, TEXEL1, TEXEL1
394
395
#define PM_CC_38 TEXEL1, K4, PRIMITIVE_ALPHA, TEXEL0, TEXEL0, TEXEL1, ENVIRONMENT, ENVIRONMENT
396
#define PM_CC_39 TEXEL1, K4, COMBINED_ALPHA, COMBINED, 0, 0, 0, 1
397
398
#define PM_CC_3A 0, 0, 0, PRIMITIVE, 1, TEXEL0, PRIMITIVE, TEXEL0
399
400
#define PM_CC_SCREEN_OVERLAY \
401
0, 0, 0, SHADE, \
402
1, 0, PRIMITIVE, 0
403
404
#define PM_CC_3C 0, 0, 0, PRIMITIVE, SHADE, 0, PRIMITIVE, 0
405
406
#define PM_CC_3D SHADE, ENVIRONMENT, TEXEL0, TEXEL0, PRIMITIVE, 0, TEXEL0, 0
407
408
#define PM_CC_3F TEXEL0, 0, SHADE, 0, SHADE, 0, PRIMITIVE, 0
409
410
// animated tiles spreading over the screen when the game is reset
411
// color = pure black
412
// alpha = texture
413
#define PM_CC_RESET_TILES 0, 0, 0, 0, 0, 0, 0, TEXEL0
414
415
// light with animated alpha surrounding the flower gate in mac_01 as it appears
416
// color = pure white
417
// alpha = SHADE * PRIM
418
#define PM_CC_FLOWER_GATE_GLOW 0, 0, 0, 1, SHADE, 0, PRIMITIVE, 0
419
420
// light with animated alpha pouring through the opening in kkj_27 as the secret wall rotates
421
// color = TEXEL0 * SHADE
422
// alpha = PRIM
423
#define PM_CC_KKJ_SPILL_LIGHT TEXEL0, 0, SHADE, 0, 0, 0, 0, PRIMITIVE
424
425
// color = pass from cycle1
426
// alpha = PRIM
427
#define PM_CC_KKJ14_FIRE 0, 0, 0, COMBINED, 0, 0, 0, PRIMITIVE
428
429
// color = SHADE + PRIM
430
// alpha = PRIMITIVE * TEXEL0
431
#define PM_CC_DAMAGE_INDICATOR 1, 0, SHADE, PRIMITIVE, PRIMITIVE, 0, TEXEL0, 0
432
433
// custom combine modes for shadows
434
#define PM_CC1_SHADOW 0, 0, 0, 0, PRIMITIVE, 0, TEXEL0, 0
435
#define PM_CC2_SHADOW 0, 0, 0, 0, TEXEL0, 0, PRIMITIVE, 0
436
437
// custom cycle1 modes for window styles
438
#define PM_CC_WINDOW_2 PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, TEXEL1
439
#define PM_CC_WINDOW_3 PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL1, 0
440
#define PM_CC_WINDOW_4 PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, PRIMITIVE
441
#define PM_CC_WINDOW_5 0, 0, 0, TEXEL1, 0, 0, 0, TEXEL1
442
#define PM_CC_WINDOW_6 0, 0, 0, TEXEL1, PRIMITIVE, 0, TEXEL1, 0
443
#define PM_CC_WINDOW_7 PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, 1
444
// custom cycle2 modes for window styles
445
#define PM_CC_WINDOW_1 COMBINED, 0, TEXEL0, 0, 0, 0, 0, COMBINED
446
447
#define PM_CC_IMGFX_COLOR_FILL 0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0
448
#define PM_CC_IMGFX_HOLOGRAM NOISE, PRIMITIVE, PRIMITIVE, TEXEL0, TEXEL0, 0, PRIMITIVE, 0
449
450
#define PM_CC_MSG_NOISE_OUTLINE NOISE, 0, TEXEL0, 0, 0, 0, 0, TEXEL0
451
#define PM_CC_MSG_STATIC NOISE, TEXEL0, ENVIRONMENT, TEXEL0, 0, 0, 0, TEXEL0
452
453
#define PM_CC_CANDLE_1 TEXEL0, TEXEL1, TEXEL0, 1, 1, TEXEL0, TEXEL1, 1
454
#define PM_CC_CANDLE_2 0, PRIMITIVE, COMBINED, ENVIRONMENT, COMBINED, TEXEL1, TEXEL1, TEXEL1
455
456
#define PM_CC_BOX1_OPAQUE TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, TEXEL1
457
#define PM_CC_BOX2_OPAQUE TEXEL0, 0, TEXEL1, 0, 0, 0, 0, TEXEL1
458
#define PM_CC_BOX1_TRANSPARENT TEXEL0, 0, PRIMITIVE, 0, TEXEL1, 0, PRIMITIVE, 0
459
#define PM_CC_BOX2_TRANSPARENT TEXEL0, 0, TEXEL1, 0, TEXEL1, 0, PRIMITIVE, 0
460
461
#define PM_CC_BOX1_CYC2 TEXEL0, ENVIRONMENT, ENV_ALPHA, COMBINED, 0, 0, 0, COMBINED
462
#define PM_CC_BOX2_CYC2 PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, 0, 0, 0, COMBINED
463
464
#define PM_CC_30 1, 0, TEXEL1, 0, 0, 0, 0, TEXEL1
465
#define PM_CC_31 1, 0, TEXEL1, 0, TEXEL1, 0, PRIMITIVE, 0
466
467
#define PM_CC_42 TEXEL0, 0, SHADE, 0, TEXEL0, 0, 0, TEXEL0
468
469
#define PM_CC_43 PRIMITIVE, TEXEL0, PRIMITIVE_ALPHA, TEXEL0, 0, 0, 0, 1
470
#define PM_CC_44 PRIMITIVE, TEXEL1, PRIMITIVE_ALPHA, TEXEL1, 0, 0, 0, 1
471
472
#define PM_CC_45 TEXEL0, 0, PRIMITIVE, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0
473
#define PM_CC_46 TEXEL0, ENVIRONMENT, PRIMITIVE, 0, PRIMITIVE, 0, TEXEL0, 0
474
#define PM_CC_47 TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, 0, TEXEL0, 0
475
476
#define PM_CC_48 PRIMITIVE, 0, PRIMITIVE_ALPHA, TEXEL0, 0, 0, 0, SHADE
477
478
#define PM_CC_49 TEXEL0, 0, SHADE, 0, PRIMITIVE, 0, TEXEL0, 0
479
480
#define PM_CC_4A TEXEL1, TEXEL0, ENV_ALPHA, TEXEL0, TEXEL1, TEXEL0, ENVIRONMENT, TEXEL0
481
#define PM_CC_4B PRIMITIVE, CENTER, COMBINED, ENVIRONMENT, 0, 0, 0, COMBINED
482
#define PM_CC_4C 1, COMBINED, PRIMITIVE, COMBINED, 0, 0, 0, COMBINED
483
#define PM_CC_4D ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0
484
#define PM_CC_4E SHADE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, SHADE, 0
485
#define PM_CC_4F 0, 0, 0, COMBINED, COMBINED, 0, PRIMITIVE, 0
486
487
#define PM_CC_50 TEXEL0, 0, TEXEL1, 0, 0, 0, 0, TEXEL1
488
#define PM_CC_51 TEXEL0, 0, TEXEL1, 0, PRIMITIVE, 0, TEXEL1, 0
489
#define PM_CC_52 SHADE, ENVIRONMENT, COMBINED, COMBINED, 0, 0, 0, COMBINED
490
491
#define PM_CC_53 TEXEL1, 0, PRIMITIVE, 0, 0, 0, 0, TEXEL0
492
#define PM_CC_54 COMBINED, TEXEL0, COMBINED_ALPHA, TEXEL0, PRIMITIVE, 0, TEXEL0, 0
493
#define PM_CC_55 PRIMITIVE, ENVIRONMENT, TEXEL0_ALPHA, ENVIRONMENT, 0, 0, 0, 1
494
495
#define PM_CC_56 0, 0, 0, 0, PRIMITIVE, TEXEL0, PRIMITIVE, 0
496
#define PM_CC_57 1, TEXEL0, PRIMITIVE, 0, TEXEL0, 0, ENVIRONMENT, PRIMITIVE
497
#define PM_CC_58 0, 0, 0, 0, 1, 0, ENVIRONMENT, PRIMITIVE
498
499
#define PM_CC_59 0, 0, 0, 0, SHADE, 0, TEXEL0, 0
500
#define PM_CC_5A SHADE, ENVIRONMENT, TEXEL0, TEXEL0, 0, 0, 0, TEXEL0
501
502
#define PM_CC_5B 1, PRIMITIVE, TEXEL0, PRIMITIVE, 0, 0, 0, TEXEL0
503
#define PM_CC_5C 1, 0, TEXEL0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0
504
#define PM_CC_5D 1, SHADE, TEXEL0, SHADE, 0, 0, 0, TEXEL0
505
#define PM_CC_5E 1, SHADE, TEXEL0, SHADE, TEXEL0, 0, SHADE, 0
506
507
#define PM_CC_HOS_BG_SHADE 0, 0, 0, SHADE, SHADE, 0, PRIMITIVE, 0
508
509
#define PM_CC_CONST_ALPHA_1 0, 0, 0, 0, 0, 0, 0, 1
510
#define PM_CC_CONST_0 0, 0, 0, 0, 0, 0, 0, 0
511
#define PM_CC_CONST_1 0, 0, 0, 1, 0, 0, 0, 1
512
513
#ifdef OLD_GCC
514
#define VLA 0
515
#else
516
#define VLA
517
#endif
518
519
#if VERSION_PAL
520
#define DT (50.0f/60.0f)
521
#else
522
#define DT (1.0f)
523
#endif
524
525
#define DMA_COPY_SEGMENT(segment) dma_copy(segment##_ROM_START, segment##_ROM_END, segment##_VRAM)
526
527
#ifdef __GNUC__
528
#define NODISCARD __attribute__((warn_unused_result))
529
#else
530
#define NODISCARD
531
#endif
532
533
// Avoid compiler warnings for unused variables.
534
#ifdef __GNUC__
535
#define UNUSED __attribute__((unused))
536
#else
537
#define UNUSED
538
#endif
539
540
// Avoid undefined behaviour for non-returning functions.
541
#ifdef __GNUC__
542
#define NORETURN __attribute__((noreturn))
543
#else
544
#define NORETURN
545
#endif
546
547
// Always inline a function.
548
#ifdef __GNUC__
549
#define ALWAYS_INLINE inline __attribute__((always_inline))
550
#else
551
#define ALWAYS_INLINE inline
552
#endif
553
554
// Fall through a switch case.
555
#ifdef __GNUC__
556
#define FALL_THROUGH __attribute__((fallthrough))
557
#else
558
#define FALL_THROUGH
559
#endif
560
561
// Use Og when compiling the function.
562
#ifdef __GNUC__
563
#define OPTIMIZE_OG __attribute__((optimize("Og")))
564
#else
565
#define OPTIMIZE_OG
566
#endif
567
568
// Use Os when compiling the function.
569
#ifdef __GNUC__
570
#define OPTIMIZE_OS __attribute__((optimize("Os")))
571
#else
572
#define OPTIMIZE_OS
573
#endif
574
575
// Use Ofast when compiling the function.
576
#ifdef __GNUC__
577
#define OPTIMIZE_OFAST __attribute__((optimize("Ofast")))
578
#else
579
#define OPTIMIZE_OFAST
580
#endif
581
582
// Ignore 4-byte alignment in structs.
583
#ifdef __GNUC__
584
#define PACKED __attribute__((packed))
585
#else
586
#define PACKED
587
#endif
588
589
// Align to 4-byte boundary.
590
#ifdef __GNUC__
591
#define ALIGNED4 __attribute__((aligned(4)))
592
#else
593
#define ALIGNED4
594
#endif
595
596
// Align to 8-byte boundary (for DMA requirements).
597
#ifdef __GNUC__
598
#define ALIGNED8 __attribute__((aligned(8)))
599
#else
600
#define ALIGNED8
601
#endif
602
603
// Align to 16-byte boundary (for audio lib requirements).
604
#ifdef __GNUC__
605
#define ALIGNED16 __attribute__((aligned(16)))
606
#else
607
#define ALIGNED16
608
#endif
609
610
// Align to 32-byte boundary.
611
#ifdef __GNUC__
612
#define ALIGNED32 __attribute__((aligned(32)))
613
#else
614
#define ALIGNED32
615
#endif
616
617
// Align to 64-byte boundary.
618
#ifdef __GNUC__
619
#define ALIGNED64 __attribute__((aligned(64)))
620
#else
621
#define ALIGNED64
622
#endif
623
624
#endif
include_asm.h
types.h
include
macros.h
Generated by
1.10.0