2020-07-19 06:15:50 +02:00
|
|
|
#ifndef _MACROS_H_
|
|
|
|
#define _MACROS_H_
|
|
|
|
|
2020-10-13 03:28:01 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
2020-09-22 23:36:30 +02:00
|
|
|
#ifndef SPLAT
|
2021-01-14 04:56:02 +01:00
|
|
|
#ifndef INCLUDE_ASM
|
2020-09-25 23:18:09 +02:00
|
|
|
#define INCLUDE_ASM(TYPE, FOLDER, NAME, ARGS...) \
|
2020-09-22 23:36:30 +02:00
|
|
|
TYPE __attribute__((naked)) NAME(ARGS) { __asm__( ".include \"include/macro.inc\"\n.include \"asm/nonmatchings/"FOLDER"/"#NAME".s\"\n.set reorder\n.set at"); }
|
2021-01-14 04:56:02 +01:00
|
|
|
#endif
|
2020-09-22 23:36:30 +02:00
|
|
|
#else
|
2020-09-25 23:18:09 +02:00
|
|
|
#define INCLUDE_ASM(TYPE, FOLDER, NAME, ARGS...)
|
2020-09-22 23:36:30 +02:00
|
|
|
#endif
|
2020-07-19 06:15:50 +02:00
|
|
|
|
2020-12-02 00:23:26 +01:00
|
|
|
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
|
|
|
|
2021-01-01 02:20:39 +01:00
|
|
|
#define N(sym) NS(NAMESPACE, sym)
|
|
|
|
|
2020-08-09 04:17:37 +02:00
|
|
|
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
|
|
|
|
#define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0]))
|
2020-08-12 03:01:33 +02:00
|
|
|
|
2020-08-17 14:09:19 +02:00
|
|
|
#define ASSERT(condition) if (!(condition)) { while (1) {} }
|
2020-09-18 03:28:34 +02:00
|
|
|
#define PANIC() ASSERT(0)
|
2020-10-21 18:16:42 +02:00
|
|
|
#define STATIC_ASSERT(condition) enum { static_assert_fail = 1/(!!(condition)) } // Causes division by zero ("not integer constant") if false
|
2020-08-17 14:09:19 +02:00
|
|
|
|
2020-11-18 06:20:28 +01:00
|
|
|
#define BATTLE_STATUS (&gBattleStatus)
|
2021-02-04 15:26:24 +01:00
|
|
|
#define PLAYER_ACTOR (gBattleStatus.playerActor)
|
2020-09-14 01:03:22 +02:00
|
|
|
#define GAME_STATUS (*gGameStatusPtr)
|
2020-10-20 00:47:29 +02:00
|
|
|
#define PLAYER_STATUS (&gPlayerStatus)
|
2020-12-05 10:10:01 +01:00
|
|
|
#define UI_STATUS (&gUIStatus)
|
2020-10-21 04:47:13 +02:00
|
|
|
#define PLAYER_DATA (&gPlayerData)
|
2020-11-06 01:30:17 +01:00
|
|
|
#define CAM(id) (&gCameras[id])
|
|
|
|
#define CURRENT_CAM (&gCameras[gCurrentCameraID])
|
2020-11-18 06:32:18 +01:00
|
|
|
#define GET_MAP_ENTRY(cfg, idx) (&(*cfg->entryList)[idx])
|
2020-09-14 01:03:22 +02:00
|
|
|
|
2020-11-10 21:21:37 +01:00
|
|
|
#define BADGE_MENU_PAGE(index) (&gBadgeMenuPages[index])
|
2020-11-12 06:44:10 +01:00
|
|
|
#define ITEM_MENU_PAGE(index) (&gItemMenuPages[index])
|
2020-11-10 21:21:37 +01:00
|
|
|
|
2020-10-13 03:28:01 +02:00
|
|
|
#define MAX_MAPVARS 16
|
|
|
|
#define MAX_MAPFLAGS 3
|
|
|
|
|
2020-11-08 21:40:26 +01:00
|
|
|
#define MAX_ANIMATED_MODELS 16
|
|
|
|
#define MAX_ANIMATED_MESHES 16
|
2020-10-22 02:07:00 +02:00
|
|
|
#define MAX_MODELS 256
|
2020-10-13 03:28:01 +02:00
|
|
|
#define MAX_SCRIPTS 128
|
2020-10-22 02:07:00 +02:00
|
|
|
#define MAX_NPCS 64
|
|
|
|
#define MAX_TRIGGERS 64
|
|
|
|
#define MAX_SHADOWS 60
|
|
|
|
#define MAX_ENTITIES 30
|
|
|
|
#define MAX_DYNAMIC_ENTITIES 16
|
2020-10-13 03:28:01 +02:00
|
|
|
|
2020-10-26 22:45:24 +01:00
|
|
|
// Alternative to libultra's M_PI: non-float version; more digits cause issues
|
|
|
|
#define PI 3.141592f
|
2020-12-20 04:47:09 +01:00
|
|
|
#define TAU 6.28318f
|
2020-10-26 22:45:24 +01:00
|
|
|
|
2020-10-13 03:28:01 +02:00
|
|
|
//NOTE: SCRIPT_ALLOC is probably not quite correct, but this is the closest thing to matching for the functions its used in. Needs more work.
|
|
|
|
#define SCRIPT_ALLOC(new, index) \
|
|
|
|
{ \
|
|
|
|
ScriptList** temp = &gCurrentScriptListPtr; \
|
|
|
|
s32 *numScripts = &gNumScripts; \
|
|
|
|
new = heap_malloc(sizeof(ScriptInstance)); \
|
|
|
|
(**temp)[index] = new; \
|
|
|
|
(*numScripts)++; \
|
|
|
|
ASSERT(new != NULL); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SCRIPT_FREE(index) \
|
|
|
|
{ \
|
|
|
|
ScriptList** temp = &gCurrentScriptListPtr; \
|
|
|
|
s32 *numScripts = &gNumScripts; \
|
|
|
|
heap_free((**temp)[index]); \
|
|
|
|
(**temp)[index] = NULL; \
|
|
|
|
(*numScripts)--; \
|
|
|
|
}
|
|
|
|
|
2020-09-11 22:29:52 +02:00
|
|
|
#define SQ(x) (x*x)
|
|
|
|
|
2020-10-20 05:08:28 +02:00
|
|
|
// Fixed-point short literal
|
|
|
|
#define F16(f) (s16)(f * 327.67f)
|
|
|
|
|
2020-12-28 08:09:39 +01:00
|
|
|
#define _NS(x, y) x ## _ ## y
|
|
|
|
#define NS(x, y) _NS(x, y)
|
2020-10-21 15:12:24 +02:00
|
|
|
|
2021-01-15 04:19:49 +01:00
|
|
|
#define ASCII_TO_U32(a, b, c, d) ((u32)((a << 24) | (b << 16) | (c << 8) | (d << 0)))
|
|
|
|
|
2020-08-12 03:01:33 +02:00
|
|
|
#endif
|