Files
af/include/macros.h
T
Prakxo 02dc7fc7af m_lib OK (#103)
* m_lib OK

* fixes

* rename segmented2virtual macro
2023-09-27 11:03:11 -07:00

31 lines
899 B
C

#ifndef MACROS_H
#define MACROS_H
#include "ultra64.h"
#include "code_variables.h"
#if defined(__GNUC__) || defined(__clang__)
#define UNREACHABLE __builtin_unreachable()
#else
#define UNREACHABLE
#endif
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define PROJECTED_TO_SCREEN_X(projectedPos, invW) ((projectedPos).x * (invW) * (SCREEN_WIDTH / 2) + (SCREEN_WIDTH / 2))
#define PROJECTED_TO_SCREEN_Y(projectedPos, invW) ((projectedPos).y * (invW) * (-SCREEN_HEIGHT / 2) + (SCREEN_HEIGHT / 2))
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
#define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0]))
#define SEGMENTED_TO_K0(addr) (void*)((gSegments[SEGMENT_NUMBER(addr)] + K0BASE) + SEGMENT_OFFSET(addr))
#define ABS(x) (((x) >= 0) ? (x): -(x))
#define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))
#define DECR(x) ((x) == 0 ? 0 : --(x))
#endif