1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-03 06:24:30 +00:00

Generic actor params getters (#1359)

* Initial PARAMS_GET macros

* NOSHIFT macro

* Use number of bits rather than raw mask values

* Add descriptions for each generic macro

* Reformat

* Adjust comment

* format

* edit en_door macro names

* edit redead macro name

* edit bdan switch macro name, and remove unneeded comments in go2

* mizushutter macro names

* remove PARAMS_GET_S, rework ishi switch flag handling

* actually remove PARAMS_GET_S

* remove PARAMS_GET2_S

* PARAMS_GET_U and PARAMS_GET_S

* format

* fix merge

* format

---------

Co-authored-by: fig02 <fig02srl@gmail.com>
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
Tharo 2024-08-14 20:29:43 +01:00 committed by GitHub
parent 137e0d2a10
commit eaf955ad22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
200 changed files with 1113 additions and 1045 deletions

View file

@ -641,9 +641,6 @@ typedef struct ActorContext {
/* 0x13C */ void* absoluteSpace; // Space used to allocate actor overlays with alloc type ACTOROVL_ALLOC_ABSOLUTE
} ActorContext; // size = 0x140
#define TRANSITION_ACTOR_PARAMS_INDEX_SHIFT 10
#define GET_TRANSITION_ACTOR_INDEX(actor) ((u16)(actor)->params >> TRANSITION_ACTOR_PARAMS_INDEX_SHIFT)
// EnDoor and DoorKiller share openAnim and playerIsOpening
// Due to alignment, a substruct cannot be used in the structs of these actors.
#define DOOR_ACTOR_BASE \
@ -710,4 +707,33 @@ typedef struct NpcInteractInfo {
/* 0x24 */ char unk_24[0x4];
} NpcInteractInfo; // size = 0x28
// Converts a number of bits to a bitmask, helper for params macros
// e.g. 3 becomes 0b111 (7)
#define NBITS_TO_MASK(n) \
((1 << (n)) - 1)
// Extracts the `n`-bit value at position `s` in `p`, shifts then masks
// Unsigned variant, no possibility of sign extension
#define PARAMS_GET_U(p, s, n) \
(((p) >> (s)) & NBITS_TO_MASK(n))
// Extracts the `n`-bit value at position `s` in `p`, masks then shifts
// Signed variant, possibility of sign extension
#define PARAMS_GET_S(p, s, n) \
(((p) & (NBITS_TO_MASK(n) << (s))) >> (s))
// Extracts all bits past position `s` in `p`
#define PARAMS_GET_NOMASK(p, s) \
((p) >> (s))
// Extracts the `n`-bit value at position `s` in `p` without shifting it from its current position
#define PARAMS_GET_NOSHIFT(p, s, n) \
((p) & (NBITS_TO_MASK(n) << (s)))
// Generates a bitmask for bit position `s` of length `n`
#define PARAMS_MAKE_MASK(s, n) PARAMS_GET_NOSHIFT(~0, s, n)
#define TRANSITION_ACTOR_PARAMS_INDEX_SHIFT 10
#define GET_TRANSITION_ACTOR_INDEX(actor) PARAMS_GET_NOMASK((u16)(actor)->params, 10)
#endif