mirror of
https://github.com/zeldaret/st
synced 2026-05-23 15:01:41 -04:00
90203403dd
* GameModeAdventure_001 OK * GameModeAdventure_024 17% * GameModeAdventure_024 73% * GameModeAdventure_024 99% * jp region differences * rename GameModeAdventure_024 and GameModeAdventure + UnkStruct_ov000_020d8660_024 OK * UnkActorSystem1OK * UnkActorSystem2 OK * delink more of ov024 & UnkStruct_027e0998_024 OK * improve instance stuff & UnkStruct_027e0cf8_024 OK * AdventureModeManager_160_024 OK & GameModeStartUp OK * fix regressions * fix regressions 2 * AdventureModeManager_170 OK * AdventureModeManager_174_Base OK * AdventureModeManager_174 OK * mark GameModeAdventure_024 as complete * AdventureModeManager_178 OK * AdventureModeManager_180 OK * AdventureModeManager_184_024 OK * AdventureModeManager_18C_024 OK & AdventureModeManager_190_024 OK * AdventureModeManager_15C_20_00 61% * AdventureModeManager_15C_20_00 OK * jp version differences * delink what's left in the overlay * fix regressions * AdventureModeManager_1B8_Base_024 98% * AdventureModeManager_1B8 48% and link AdventureModeManager_024 * AdventureModeManager_1B8_Base and AdventureModeManager_1B8 OK * oops * mark statics as local
34 lines
1.6 KiB
C
34 lines
1.6 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)))))
|
|
|
|
//! 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__))
|