|
1 | 1 | #ifndef MACROS_H |
2 | 2 | #define MACROS_H |
3 | 3 |
|
4 | | -#include "versions.h" |
5 | | - |
6 | | -#define SCREEN_WIDTH 320 |
7 | | -#define SCREEN_HEIGHT 240 |
8 | | - |
9 | | -#ifndef AVOID_UB |
10 | | -#define BAD_RETURN(type) type |
11 | | -#else |
12 | | -#define BAD_RETURN(type) void |
13 | | -#endif |
14 | | - |
15 | 4 | #define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0])) |
16 | 5 | #define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0])) |
17 | 6 | #define ARRAY_COUNT_2D(arr) (s32)(sizeof(arr) / sizeof(arr[0][0])) |
18 | 7 |
|
19 | | -#define ABS(x) ((x) >= 0 ? (x) : -(x)) |
20 | | -#define DECR(x) ((x) == 0 ? 0 : --(x)) |
21 | | -#define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) |
22 | | -#define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) |
23 | | -#define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x)) |
24 | | - |
25 | | -#define SWAP(type, a, b) \ |
26 | | - { \ |
27 | | - type _temp = (a); \ |
28 | | - (a) = (b); \ |
29 | | - (b) = _temp; \ |
30 | | - } \ |
31 | | - (void)0 |
32 | | - |
33 | | -#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 24) | (((g) & 0xFF) << 16) | (((b) & 0xFF) << 8) | (((a) & 0xFF) << 0)) |
34 | | - |
35 | 8 | #define CHECK_FLAG_ALL(flags, mask) (((flags) & (mask)) == (mask)) |
36 | 9 |
|
37 | | -#if PLATFORM_N64 || DEBUG_FEATURES |
38 | | -#define HUNGUP_AND_CRASH(file, line) Fault_AddHungupAndCrash(file, line) |
39 | | -#else |
40 | | -#define HUNGUP_AND_CRASH(file, line) LogUtils_HungupThread(file, line) |
41 | | -#endif |
42 | | - |
43 | | -#define MATRIX_FINALIZE_AND_LOAD(pkt, gfxCtx, file, line) \ |
44 | | - gSPMatrix(pkt, MATRIX_FINALIZE(gfxCtx, file, line), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW) |
45 | | - |
46 | | -#if OOT_NTSC |
47 | | -#define LANGUAGE_ARRAY(jpn, eng, ger, fra) { jpn, eng } |
48 | | -#else |
49 | | -#define LANGUAGE_ARRAY(jpn, eng, ger, fra) { eng, ger, fra } |
50 | | -#endif |
51 | | - |
52 | | -/** |
53 | | - * `x` vertex x |
54 | | - * `y` vertex y |
55 | | - * `z` vertex z |
56 | | - * `s` texture s coordinate |
57 | | - * `t` texture t coordinate |
58 | | - * `crnx` red component of color vertex, or x component of normal vertex |
59 | | - * `cgny` green component of color vertex, or y component of normal vertex |
60 | | - * `cbnz` blue component of color vertex, or z component of normal vertex |
61 | | - * `a` alpha |
62 | | - */ |
63 | | -#define VTX(x,y,z,s,t,crnx,cgny,cbnz,a) { { { x, y, z }, 0, { s, t }, { crnx, cgny, cbnz, a } } } |
64 | | - |
65 | | -#define VTX_T(x,y,z,s,t,cr,cg,cb,a) { { x, y, z }, 0, { s, t }, { cr, cg, cb, a } } |
66 | | - |
67 | | -#define gDPSetTileCustom(pkt, fmt, siz, uls, ult, lrs, lrt, pal, \ |
68 | | - cms, cmt, masks, maskt, shifts, shiftt) \ |
69 | | -_DW({ \ |
70 | | - gDPPipeSync(pkt); \ |
71 | | - gDPTileSync(pkt); \ |
72 | | - gDPSetTile(pkt, fmt, siz, \ |
73 | | - (((((lrs) - (uls) + 1) * siz##_TILE_BYTES) + 7) >> 3), 0, \ |
74 | | - G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, \ |
75 | | - shifts); \ |
76 | | - gDPTileSync(pkt); \ |
77 | | - gDPSetTile(pkt, fmt, siz, \ |
78 | | - (((((lrs) - (uls) + 1) * siz##_LINE_BYTES) + 7) >> 3), 0, \ |
79 | | - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, shifts); \ |
80 | | - gDPSetTileSize(pkt, G_TX_RENDERTILE, \ |
81 | | - (uls) << G_TEXTURE_IMAGE_FRAC, \ |
82 | | - (ult) << G_TEXTURE_IMAGE_FRAC, \ |
83 | | - (lrs) << G_TEXTURE_IMAGE_FRAC, \ |
84 | | - (lrt) << G_TEXTURE_IMAGE_FRAC); \ |
85 | | -}) |
86 | | - |
87 | 10 | #endif |
0 commit comments