EnvFlags OK (#404)

* Matched

* Remove magic number

* Rename system to EnvFlags
This commit is contained in:
Derek Hensley
2021-11-05 19:15:47 -07:00
committed by GitHub
parent 2907da61c3
commit 49f55ff005
7 changed files with 44 additions and 20 deletions
-9
View File
@@ -1,9 +0,0 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F12D0/func_800F12D0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F12D0/func_800F1304.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F12D0/func_800F1374.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F12D0/func_800F13E8.s")
+33
View File
@@ -0,0 +1,33 @@
#include "global.h"
void EnvFlags_UnsetAll(GlobalContext* globalCtx) {
u8 i;
for (i = 0; i < ARRAY_COUNT(globalCtx->envFlags); i++) {
globalCtx->envFlags[i] = 0;
}
}
void EnvFlags_Set(GlobalContext* globalCtx, s16 flag) {
s16 index = flag / 16;
s16 bit = flag % 16;
s16 mask = 1 << bit;
globalCtx->envFlags[index] |= mask;
}
void EnvFlags_Unset(GlobalContext* globalCtx, s16 flag) {
s16 index = flag / 16;
s16 bit = flag % 16;
s16 mask = (1 << bit) ^ 0xFFFF;
globalCtx->envFlags[index] &= mask;
}
s32 EnvFlags_Get(GlobalContext* globalCtx, s16 flag) {
s16 index = flag / 16;
s16 bit = flag % 16;
s16 mask = 1 << bit;
return globalCtx->envFlags[index] & mask;
}
@@ -98,7 +98,7 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) {
if (grottoType == DOORANA_TYPE_UNK) {
// in OOT decomp its marked as open with storms, but does not seem to open with storms in MM
if ((this->actor.xyzDistToPlayerSq < 40000.0f) && (func_800F13E8(globalCtx, 5))) {
if ((this->actor.xyzDistToPlayerSq < 40000.0f) && (EnvFlags_Get(globalCtx, 5))) {
grottoIsOpen = 1;
this->actor.flags &= ~0x10; // always update OFF
}