mirror of
https://github.com/zeldaret/st
synced 2026-06-17 15:16:49 -04:00
5e934a8c9b
* name func_01ffd3d8 and func_01ffd400 * name func_01ffd3b0 * match func_ov024_020cf9d4 + improve the Random struct * UnkStruct_027e0cf8_00_0C_024 45% * match PassengerManager::GetRandomIndex * UnkStruct_027e0cf8_00_0C_024 OK * UnkStruct_027e0cf8_00_0C_024: do other sections * UnkStruct_027e0cf8_08_024 55% * cleanup: remplace delete into null by the delete macro * UnkStruct_027e0cf8_08_024 OK * fix build issues * UnkStruct_ov024_020d86a0_024 OK * PlayerActor_A0_38_024 .text OK, CreditsEndingType OK * tools: create courselist.py to convert .CLB data to yaml * UnkDataStruct4_14 OK * UnkDataStruct4 17% * UnkDataStruct4 OK * MiscAdvManager OK * PassengerManager OK * fix build issues * ZeldaTrainBinary OK * mark PassengerManager as complete and adjust delinks * UnkStruct_027e0cf8_08_00_024 OK * document more of UnkStruct_027e0ce0 * savefile hotfixes * UnkStruct_027e0ce0_34_024 OK * code_020d46b4_024 OK * UnkStruct_027e0d00 & UnkStruct_027e0d00_20 OK * code_020d51dc_024 OK * fix weird formatting * UnkTrainSystem1 OK * fix jp broken match * UnkTrainSystem2 OK * UnkStruct_027e0d08_024 31% * fix build issues * UnkStruct_027e0d08 OK!!! * remove useless parenthesis * ActorUnk_ov000_020a8bb0_EC OK * move ActorUnk_ov000_020a8bb0_EC to MainGame/Actor/ * ActorUnkOBPC OK * add sjiswrap support * solve remaining gaps and fix build issues * reorganise files + counter docs * tools: remove format command execution from defaults
38 lines
1.8 KiB
C
38 lines
1.8 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))
|
|
|
|
#define GET_FLAG_ALT(arr, pos) (((arr)[(pos) >> 5] & (1 << ((0x1F - ((pos) & 0x1F))))) != 0)
|
|
#define SET_FLAG_ALT(arr, pos) ((arr)[(pos) >> 5] |= 1 << ((0x1F - ((pos) & 0x1F))))
|
|
#define UNSET_FLAG_ALT(arr, pos) ((arr)[(pos) >> 5] &= ~(1 << ((0x1F - ((pos) & 0x1F)))))
|
|
|
|
#define GET_FLAG_ALT2(arr, a, b) (((arr)[((u32) (a))] & (1 << (b))) != 0)
|
|
#define SET_FLAG_ALT2(arr, a, b) ((arr)[((u32) (a))] |= 1 << (b))
|
|
#define UNSET_FLAG_ALT2(arr, a, b) ((arr)[((u32) (a))] &= ~(1 << (b)))
|
|
|
|
//! 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__))
|