mirror of
https://github.com/zeldaret/st
synced 2026-05-25 23:35:14 -04:00
645ed65b76
* playrget progress and match treasuremanager remaining functions * some docs * fix build issues * random docs * match func_ov094_02172290 * random docs * actor cleanup * match freestanding item funcs * mType -> mpProfile * decompile random functions * docs and start of wip chest stuff * random docs * more random docs * match func_ov036_0211d0a8 * match func_ov036_0211d2dc & func_ov036_0211d570 * match func_ov110_02184a40 * random doc * document letter/stamps system * match func_ov001_020bb9f8 * fix build issues * decompile tres * start decomp chest base * fix regressions * name TRES * name UnkStruct_ov024_020d86b0 * name stamp types and update save struct stuff * name things and document BMG IDs
30 lines
1.3 KiB
C
30 lines
1.3 KiB
C
#pragma once
|
|
|
|
#include "types.h"
|
|
|
|
/**
|
|
* Flags value format:
|
|
* - 0x001F: 0000 0000 0001 1111 -> the shift value to read or write the flag's bit
|
|
* - 0xFFE0: 1111 1111 1110 0000 -> index of the value in the array
|
|
*
|
|
* `FLAG` is a macro that allows you to get the final value from the index and the slot number.
|
|
*/
|
|
|
|
#define GET_FLAG(arr, pos) (((arr)[((u32) (pos)) >> 5] & (1 << ((pos) & 0x1F))) != 0)
|
|
#define GET_FLAG2(var, pos) ((var) & (1 << pos))
|
|
#define SET_FLAG(arr, pos) ((arr)[((u32) (pos)) >> 5] |= 1 << ((pos) & 0x1F))
|
|
#define UNSET_FLAG(arr, pos) ((arr)[((u32) (pos)) >> 5] &= ~(1 << ((pos) & 0x1F)))
|
|
#define FLAG(index, pos) (((index) << 5) | ((pos) & 0x1F))
|
|
|
|
//! TODO: improve or remove? idk
|
|
#define VA_NARGS_IMPL(_1, _2, _3, _4, N, ...) N
|
|
#define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 4, 3, 2, 1)
|
|
#define GET_FLAGS_1(f1) (1 << (f1))
|
|
#define GET_FLAGS_2(f1, f2) GET_FLAGS_1(f1) | (1 << (f2))
|
|
#define GET_FLAGS_3(f1, f2, f3) GET_FLAGS_2(f1, f2) | (1 << (f3))
|
|
#define GET_FLAGS_4(f1, f2, f3, f4) GET_FLAGS_3(f1, f2, f3) | (1 << (f4))
|
|
#define GET_FLAGS_IMPL2(N, ...) GET_FLAGS_##N(__VA_ARGS__)
|
|
#define GET_FLAGS_IMPL(N, ...) GET_FLAGS_IMPL2(N, __VA_ARGS__)
|
|
#define GET_FLAGS(...) GET_FLAGS_IMPL(VA_NARGS(__VA_ARGS__), __VA_ARGS__)
|
|
#define SET_FLAGS(arr, ...) (*(arr) = GET_FLAGS_IMPL(VA_NARGS(__VA_ARGS__), __VA_ARGS__))
|