1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-22 15:01:17 +00:00

Defines for SaveContext flags (eventChkInf, itemGetInf, infTable, eventInf) (#1094)

* script-assisted `itemGetInf` flags

* comment near non-trivial `itemGetInf` usage

* Run formatter

* Try something with the itemgetinf flags that can't use the packed value

* Add defines for `eventChkInf` (direct access)

* Add defines for `eventChkInf` (access through `Flags_GetEventChkInf`)

* Add defines for `eventChkInf` (access through `Flags_SetEventChkInf`)

* Add defines for `infTable` (direct access)

* Add defines for `infTable` (used by `Flags_GetInfTable`)

* Add defines for `infTable` (used by `Flags_SetInfTable`)

* Add defines for `eventInf`

* parenthesis cleanup near `GET_EVENTCHKINF` usage

* parenthesis cleanup near `GET_ITEMGETINF` usage

* parenthesis cleanup near `GET_INFTABLE` usage

* fixup one `eventInf` usage

* parenthesis cleanup near `GET_EVENTINF` usage

* parenthesis cleanup near `Flags_GetEventChkInf` usage

* slight `z64save.h` formatting improvement

* Improve itemGetInf flags in z_bg_dy_yoseizo

* Questionable improvement in z_en_ge2

* Questionable improvement in z_en_daiku

* Questionable improvement in z_en_mu

* Run formatter

* Parentheses around `gSaveContext` macros arguments

* Move individual flags define to the end of z64save.h, and improve comments separating the groups
This commit is contained in:
Dragorn421 2022-04-29 20:19:48 +02:00 committed by GitHub
parent 16790bc253
commit 6336df5fcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
146 changed files with 1931 additions and 1315 deletions

View file

@ -429,9 +429,9 @@ u16 func_80A6F810(GlobalContext* globalCtx, Actor* thisx) {
switch (this->actor.params & 0x7F) {
case ENHY_TYPE_AOB:
if (globalCtx->sceneNum == SCENE_KAKARIKO) {
return (this->unk_330 & 0x800) ? 0x508D : ((gSaveContext.infTable[12] & 0x800) ? 0x508C : 0x508B);
return (this->unk_330 & EVENTCHKINF_6B_MASK) ? 0x508D : (GET_INFTABLE(INFTABLE_CB) ? 0x508C : 0x508B);
} else if (globalCtx->sceneNum == SCENE_MARKET_DAY) {
return (gSaveContext.eventInf[3] & 1) ? 0x709B : 0x709C;
return GET_EVENTINF(EVENTINF_30) ? 0x709B : 0x709C;
} else if (gSaveContext.dogIsLost) {
s16 followingDog = (gSaveContext.dogParams & 0xF00) >> 8;
@ -445,77 +445,73 @@ u16 func_80A6F810(GlobalContext* globalCtx, Actor* thisx) {
return 0x70A0;
}
case ENHY_TYPE_COB:
if (gSaveContext.eventChkInf[8] & 1) {
return (gSaveContext.infTable[12] & 2) ? 0x7017 : 0x7045;
if (GET_EVENTCHKINF(EVENTCHKINF_80)) {
return GET_INFTABLE(INFTABLE_C1) ? 0x7017 : 0x7045;
} else {
return (gSaveContext.infTable[12] & 1) ? 0x7017 : 0x7016;
return GET_INFTABLE(INFTABLE_C0) ? 0x7017 : 0x7016;
}
case ENHY_TYPE_AHG_2:
if (globalCtx->sceneNum == SCENE_KAKARIKO) {
return 0x5086;
} else if (globalCtx->sceneNum == SCENE_SPOT01) {
return 0x5085;
} else if (gSaveContext.eventChkInf[8] & 1) {
return (gSaveContext.infTable[12] & 8) ? 0x701A : 0x7047;
} else if (gSaveContext.eventChkInf[1] & 0x10) {
} else if (GET_EVENTCHKINF(EVENTCHKINF_80)) {
return GET_INFTABLE(INFTABLE_C3) ? 0x701A : 0x7047;
} else if (GET_EVENTCHKINF(EVENTCHKINF_14)) {
return 0x701A;
} else if (gSaveContext.eventChkInf[1] & 1) {
} else if (GET_EVENTCHKINF(EVENTCHKINF_10)) {
return 0x701B;
} else if (gSaveContext.infTable[12] & 4) {
} else if (GET_INFTABLE(INFTABLE_C2)) {
return 0x701C;
} else {
return 0x701A;
}
case ENHY_TYPE_BOJ_3:
return (gSaveContext.eventChkInf[8] & 1) ? ((gSaveContext.infTable[12] & 0x10) ? 0x7001 : 0x70EB) : 0x7001;
return GET_EVENTCHKINF(EVENTCHKINF_80) ? (GET_INFTABLE(INFTABLE_C4) ? 0x7001 : 0x70EB) : 0x7001;
case ENHY_TYPE_AHG_4:
return (gSaveContext.eventChkInf[8] & 1) ? 0x704B : ((gSaveContext.infTable[12] & 0x20) ? 0x7024 : 0x7023);
return GET_EVENTCHKINF(EVENTCHKINF_80) ? 0x704B : (GET_INFTABLE(INFTABLE_C5) ? 0x7024 : 0x7023);
case ENHY_TYPE_BOJ_5:
player->exchangeItemId = EXCH_ITEM_BLUE_FIRE;
return 0x700C;
case ENHY_TYPE_BBA:
return (gSaveContext.eventChkInf[8] & 1) ? 0x704A : ((gSaveContext.infTable[12] & 0x40) ? 0x7022 : 0x7021);
return GET_EVENTCHKINF(EVENTCHKINF_80) ? 0x704A : (GET_INFTABLE(INFTABLE_C6) ? 0x7022 : 0x7021);
case ENHY_TYPE_BJI_7:
if (globalCtx->sceneNum == SCENE_KAKARIKO) {
return 0x5088;
} else if (globalCtx->sceneNum == SCENE_SPOT01) {
return 0x5087;
} else {
return (gSaveContext.eventChkInf[8] & 1) ? 0x704D
: ((gSaveContext.infTable[12] & 0x80) ? 0x7028 : 0x7027);
return GET_EVENTCHKINF(EVENTCHKINF_80) ? 0x704D : (GET_INFTABLE(INFTABLE_C7) ? 0x7028 : 0x7027);
}
case ENHY_TYPE_CNE_8:
if (gSaveContext.eventChkInf[8] & 1) {
return (gSaveContext.infTable[12] & 0x200) ? 0x701E : 0x7048;
if (GET_EVENTCHKINF(EVENTCHKINF_80)) {
return GET_INFTABLE(INFTABLE_C9) ? 0x701E : 0x7048;
} else {
return (gSaveContext.infTable[12] & 0x100) ? 0x701E : 0x701D;
return GET_INFTABLE(INFTABLE_C8) ? 0x701E : 0x701D;
}
case ENHY_TYPE_BOJ_9:
if (globalCtx->sceneNum == SCENE_KAKARIKO) {
return (gSaveContext.eventChkInf[10] & 0x400) ? 0x5082 : 0x5081;
return GET_EVENTCHKINF(EVENTCHKINF_AA) ? 0x5082 : 0x5081;
} else if (globalCtx->sceneNum == SCENE_SPOT01) {
return CHECK_QUEST_ITEM(QUEST_MEDALLION_SHADOW) ? 0x5080 : 0x507F;
} else {
return (gSaveContext.eventChkInf[8] & 1) ? 0x7049
: ((gSaveContext.infTable[12] & 0x400) ? 0x7020 : 0x701F);
return GET_EVENTCHKINF(EVENTCHKINF_80) ? 0x7049 : (GET_INFTABLE(INFTABLE_CA) ? 0x7020 : 0x701F);
}
case ENHY_TYPE_BOJ_10:
if (globalCtx->sceneNum == SCENE_LABO) {
return (gSaveContext.eventChkInf[10] & 0x400) ? 0x507E : 0x507D;
return GET_EVENTCHKINF(EVENTCHKINF_AA) ? 0x507E : 0x507D;
} else if (globalCtx->sceneNum == SCENE_SPOT01) {
return CHECK_QUEST_ITEM(QUEST_MEDALLION_SHADOW) ? 0x507C : 0x507B;
} else {
return (gSaveContext.eventChkInf[8] & 1) ? 0x7046
: ((gSaveContext.infTable[12] & 0x2000) ? 0x7019 : 0x7018);
return GET_EVENTCHKINF(EVENTCHKINF_80) ? 0x7046 : (GET_INFTABLE(INFTABLE_CD) ? 0x7019 : 0x7018);
}
case ENHY_TYPE_CNE_11:
return (gSaveContext.infTable[8] & 0x800) ? ((gSaveContext.infTable[12] & 0x1000) ? 0x7014 : 0x70A4)
: 0x7014;
return GET_INFTABLE(INFTABLE_8B) ? (GET_INFTABLE(INFTABLE_CC) ? 0x7014 : 0x70A4) : 0x7014;
case ENHY_TYPE_BOJ_12:
if (globalCtx->sceneNum == SCENE_SPOT01) {
return !IS_DAY ? 0x5084 : 0x5083;
} else {
return (gSaveContext.eventChkInf[8] & 1) ? 0x7044 : 0x7015;
return GET_EVENTCHKINF(EVENTCHKINF_80) ? 0x7044 : 0x7015;
}
case ENHY_TYPE_AHG_13:
return 0x7055;
@ -528,20 +524,20 @@ u16 func_80A6F810(GlobalContext* globalCtx, Actor* thisx) {
case ENHY_TYPE_AHG_17:
if (!LINK_IS_ADULT) {
if (IS_DAY) {
return (gSaveContext.infTable[22] & 1) ? 0x5058 : 0x5057;
return GET_INFTABLE(INFTABLE_160) ? 0x5058 : 0x5057;
} else {
return (gSaveContext.infTable[22] & 2) ? 0x505A : 0x5059;
return GET_INFTABLE(INFTABLE_161) ? 0x505A : 0x5059;
}
} else if (IS_DAY) {
return (gSaveContext.infTable[22] & 4) ? 0x505C : 0x505B;
return GET_INFTABLE(INFTABLE_162) ? 0x505C : 0x505B;
} else {
return 0x5058;
}
case ENHY_TYPE_BOB_18:
if (!LINK_IS_ADULT) {
return (gSaveContext.eventChkInf[8] & 1) ? 0x505F : ((gSaveContext.infTable[22] & 8) ? 0x505E : 0x505D);
return GET_EVENTCHKINF(EVENTCHKINF_80) ? 0x505F : (GET_INFTABLE(INFTABLE_163) ? 0x505E : 0x505D);
} else {
return (this->unk_330 & 0x800) ? 0x5062 : ((gSaveContext.infTable[22] & 0x10) ? 0x5061 : 0x5060);
return (this->unk_330 & EVENTCHKINF_6B_MASK) ? 0x5062 : (GET_INFTABLE(INFTABLE_164) ? 0x5061 : 0x5060);
}
case ENHY_TYPE_BJI_19:
return 0x7120;
@ -599,67 +595,67 @@ s16 func_80A70058(GlobalContext* globalCtx, Actor* thisx) {
Player_UpdateBottleHeld(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE);
break;
case 0x7016:
gSaveContext.infTable[12] |= 1;
SET_INFTABLE(INFTABLE_C0);
break;
case 0x7045:
gSaveContext.infTable[12] |= 2;
SET_INFTABLE(INFTABLE_C1);
break;
case 0x701B:
gSaveContext.infTable[12] |= 4;
SET_INFTABLE(INFTABLE_C2);
break;
case 0x7047:
gSaveContext.infTable[12] |= 8;
SET_INFTABLE(INFTABLE_C3);
break;
case 0x70EB:
gSaveContext.infTable[12] |= 0x10;
SET_INFTABLE(INFTABLE_C4);
break;
case 0x7023:
gSaveContext.infTable[12] |= 0x20;
SET_INFTABLE(INFTABLE_C5);
break;
case 0x7021:
gSaveContext.infTable[12] |= 0x40;
SET_INFTABLE(INFTABLE_C6);
break;
case 0x7027:
gSaveContext.infTable[12] |= 0x80;
SET_INFTABLE(INFTABLE_C7);
break;
case 0x701D:
gSaveContext.infTable[12] |= 0x100;
SET_INFTABLE(INFTABLE_C8);
break;
case 0x7048:
gSaveContext.infTable[12] |= 0x200;
SET_INFTABLE(INFTABLE_C9);
break;
case 0x701F:
gSaveContext.infTable[12] |= 0x400;
SET_INFTABLE(INFTABLE_CA);
break;
case 0x7018:
gSaveContext.infTable[12] |= 0x2000;
SET_INFTABLE(INFTABLE_CD);
break;
case 0x70A4:
gSaveContext.infTable[12] |= 0x1000;
SET_INFTABLE(INFTABLE_CC);
break;
case 0x5057:
gSaveContext.infTable[22] |= 1;
SET_INFTABLE(INFTABLE_160);
break;
case 0x5059:
gSaveContext.infTable[22] |= 2;
SET_INFTABLE(INFTABLE_161);
break;
case 0x505B:
gSaveContext.infTable[22] |= 4;
SET_INFTABLE(INFTABLE_162);
break;
case 0x505D:
gSaveContext.infTable[22] |= 8;
SET_INFTABLE(INFTABLE_163);
break;
case 0x5060:
gSaveContext.infTable[22] |= 0x10;
SET_INFTABLE(INFTABLE_164);
break;
case 0x508B:
gSaveContext.infTable[12] |= 0x800;
SET_INFTABLE(INFTABLE_CB);
break;
case 0x709E:
gSaveContext.dogParams = 0;
break;
case 0x709F:
func_80A6F7CC(this, globalCtx, (gSaveContext.infTable[25] & 2) ? GI_RUPEE_BLUE : GI_HEART_PIECE);
func_80A6F7CC(this, globalCtx, GET_INFTABLE(INFTABLE_191) ? GI_RUPEE_BLUE : GI_HEART_PIECE);
this->actionFunc = func_80A714C4;
break;
}
@ -854,7 +850,7 @@ s32 EnHy_ShouldSpawn(EnHy* this, GlobalContext* globalCtx) {
return true;
} else if (IS_NIGHT) {
return false;
} else if ((gSaveContext.eventChkInf[8] & 1) && !(gSaveContext.eventChkInf[4] & 0x20)) {
} else if (GET_EVENTCHKINF(EVENTCHKINF_80) && !GET_EVENTCHKINF(EVENTCHKINF_45)) {
return false;
} else {
return true;
@ -913,7 +909,7 @@ void EnHy_InitImpl(EnHy* this, GlobalContext* globalCtx) {
}
if (globalCtx->sceneNum == SCENE_KAKARIKO) {
this->unk_330 = gSaveContext.eventChkInf[6];
this->unk_330 = gSaveContext.eventChkInf[EVENTCHKINF_6B_INDEX];
}
EnHy_InitSetProperties(this);
@ -970,7 +966,7 @@ void func_80A710F8(EnHy* this, GlobalContext* globalCtx) {
if (this->skelAnime.animation != &gObjOsAnim_0BFC) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENHY_ANIM_26);
}
} else if (gSaveContext.eventInf[3] & 1) {
} else if (GET_EVENTINF(EVENTINF_30)) {
if (this->skelAnime.animation != &gObjOsAnim_0FE4) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENHY_ANIM_25);
}
@ -1061,7 +1057,7 @@ void func_80A71530(EnHy* this, GlobalContext* globalCtx) {
case GI_HEART_PIECE:
gSaveContext.dogParams = 0;
gSaveContext.dogIsLost = false;
gSaveContext.infTable[25] |= 2;
SET_INFTABLE(INFTABLE_191);
break;
case GI_RUPEE_BLUE:
Rupees_ChangeBy(5);