Mario Kart 64
Loading...
Searching...
No Matches
mk64.h
Go to the documentation of this file.
1#ifndef MK64_H
2#define MK64_H
3
4// Global header for Mario Kart 64
5
6#include <types.h>
7#include "config.h"
8
9#define GFX_GET_OPCODE(var) ((s32)((var) & 0xFF000000))
10
11// Pointer casting is technically UB, and avoiding it gets rid of endian issues
12// as well as a nice side effect.
13#ifdef AVOID_UB
14#define GET_HIGH_U16_OF_32(var) ((u16)((var) >> 16))
15#define GET_HIGH_S16_OF_32(var) ((s16)((var) >> 16))
16#define GET_LOW_U16_OF_32(var) ((u16)((var) & 0xFFFF))
17#define GET_LOW_S16_OF_32(var) ((s16)((var) & 0xFFFF))
18#define SET_HIGH_U16_OF_32(var, x) ((var) = ((var) & 0xFFFF) | ((x) << 16))
19#define SET_HIGH_S16_OF_32(var, x) ((var) = ((var) & 0xFFFF) | ((x) << 16))
20#else
21#define GET_HIGH_U16_OF_32(var) (((u16 *)&(var))[0])
22#define GET_HIGH_S16_OF_32(var) (((s16 *)&(var))[0])
23#define GET_LOW_U16_OF_32(var) (((u16 *)&(var))[1])
24#define GET_LOW_S16_OF_32(var) (((s16 *)&(var))[1])
25#define SET_HIGH_U16_OF_32(var, x) ((((u16 *)&(var))[0]) = (x))
26#define SET_HIGH_S16_OF_32(var, x) ((((s16 *)&(var))[0]) = (x))
27#endif
28
29#endif // MK64_H