papermario/include/macros.h

49 lines
1.3 KiB
C
Raw Normal View History

#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
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"); }
#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-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-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-08-17 14:09:19 +02:00
2020-09-14 01:03:22 +02:00
#define GAME_STATUS (*gGameStatusPtr)
2020-10-13 03:28:01 +02:00
#define MAX_MAPVARS 16
#define MAX_MAPFLAGS 3
#define MAX_SCRIPTS 128
//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)--; \
}
#define SQ(x) (x*x)
#endif